SVG: improve handling of visibility property

visible children of an invisible parent are now visible

Change-Id: I2eafbd15d22f54ec39f12bfd32175925ab8a6184
Reviewed-on: https://gerrit.libreoffice.org/12504
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Chr. Rossmanith
2014-11-16 21:43:13 +01:00
committed by Caolán McNamara
parent c0fbb6be4f
commit 5f98e35f81
2 changed files with 15 additions and 14 deletions

View File

@@ -496,12 +496,6 @@ namespace svgio
return; return;
} }
const SvgStyleAttributes* pStyles = getSvgStyleAttributes();
if(pStyles && (Visibility_hidden == pStyles->getVisibility() || Visibility_collapse == pStyles->getVisibility()))
{
return;
}
if(!bReferenced) if(!bReferenced)
{ {
if(SVGTokenDefs == getType() || if(SVGTokenDefs == getType() ||
@@ -540,11 +534,14 @@ namespace svgio
if(pCandidate && Display_none != pCandidate->getDisplay()) if(pCandidate && Display_none != pCandidate->getDisplay())
{ {
const SvgNodeVector& rGrandChildren = pCandidate->getChildren();
const SvgStyleAttributes* pChildStyles = pCandidate->getSvgStyleAttributes(); const SvgStyleAttributes* pChildStyles = pCandidate->getSvgStyleAttributes();
if(pChildStyles && Visibility_hidden != pChildStyles->getVisibility()) // decompose:
// - visible terminal nodes
// - all non-terminal nodes (might contain visible nodes down the hierarchy)
if( !rGrandChildren.empty() || ( pChildStyles && (Visibility_visible == pChildStyles->getVisibility())) )
{ {
drawinglayer::primitive2d::Primitive2DSequence aNewTarget; drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
pCandidate->decomposeSvgNode(aNewTarget, bReferenced); pCandidate->decomposeSvgNode(aNewTarget, bReferenced);
if(aNewTarget.hasElements()) if(aNewTarget.hasElements())
@@ -552,15 +549,16 @@ namespace svgio
drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aNewTarget); drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aNewTarget);
} }
} }
} }
else if(!pCandidate) else if(!pCandidate)
{ {
OSL_ENSURE(false, "Null-Pointer in child node list (!)"); OSL_ENSURE(false, "Null-Pointer in child node list (!)");
} }
} }
if(rTarget.hasElements()) if(rTarget.hasElements())
{ {
const SvgStyleAttributes* pStyles = getSvgStyleAttributes();
if(pStyles) if(pStyles)
{ {
// check if we have Title or Desc // check if we have Title or Desc

View File

@@ -1230,15 +1230,18 @@ namespace svgio
mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType()), mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType()),
mbStrokeDasharraySet(false) mbStrokeDasharraySet(false)
{ {
const SvgStyleAttributes* pParentStyle = getParentStyle();
if(!mbIsClipPathContent) if(!mbIsClipPathContent)
{ {
const SvgStyleAttributes* pParentStyle = getParentStyle();
if(pParentStyle) if(pParentStyle)
{ {
mbIsClipPathContent = pParentStyle->mbIsClipPathContent; mbIsClipPathContent = pParentStyle->mbIsClipPathContent;
} }
} }
if(pParentStyle)
{
maVisibility = pParentStyle->maVisibility;
}
} }
SvgStyleAttributes::~SvgStyleAttributes() SvgStyleAttributes::~SvgStyleAttributes()