Kaydet (Commit) d5649ae7 authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Xisco Faulí

SVGIO: tdf#97539: clip-path elements might contain...

reference to other clip-paths

Change-Id: I3722b31cefa4df6225e369b3d1db9f46be5933ff
Reviewed-on: https://gerrit.libreoffice.org/22956Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarXisco Faulí <anistenis@gmail.com>
üst 3c465c25
...@@ -32,6 +32,7 @@ namespace svgio { namespace svgreader { ...@@ -32,6 +32,7 @@ namespace svgio { namespace svgreader {
class SvgGradientNode; class SvgGradientNode;
class SvgPatternNode; class SvgPatternNode;
class SvgMarkerNode; class SvgMarkerNode;
class SvgClipPathNode;
}} }}
...@@ -215,6 +216,7 @@ namespace svgio ...@@ -215,6 +216,7 @@ namespace svgio
/// link to content. If set, the node can be fetched on demand /// link to content. If set, the node can be fetched on demand
OUString maClipPathXLink; OUString maClipPathXLink;
const SvgClipPathNode* mpClipPathXLink;
OUString maMaskXLink; OUString maMaskXLink;
/// link to markers. If set, the node can be fetched on demand /// link to markers. If set, the node can be fetched on demand
...@@ -441,7 +443,8 @@ namespace svgio ...@@ -441,7 +443,8 @@ namespace svgio
void setDesc(const OUString& rNew) { maDesc = rNew; } void setDesc(const OUString& rNew) { maDesc = rNew; }
// ClipPathXLink content // ClipPathXLink content
const OUString getClipPathXLink() const { return maClipPathXLink; } OUString getClipPathXLink() const;
const SvgClipPathNode* accessClipPathXLink() const;
// MaskXLink content // MaskXLink content
const OUString getMaskXLink() const { return maMaskXLink; } const OUString getMaskXLink() const { return maMaskXLink; }
......
...@@ -1145,16 +1145,11 @@ namespace svgio ...@@ -1145,16 +1145,11 @@ namespace svgio
aSource = drawinglayer::primitive2d::Primitive2DContainer { xRef }; aSource = drawinglayer::primitive2d::Primitive2DContainer { xRef };
} }
if(!getClipPathXLink().isEmpty()) const SvgClipPathNode* mpClip = accessClipPathXLink();
if(mpClip)
{ {
// try to access linked ClipPath // #i124852# transform may be needed when userSpaceOnUse
const SvgClipPathNode* mpClip = dynamic_cast< const SvgClipPathNode* >(mrOwner.getDocument().findSvgNodeById(getClipPathXLink())); mpClip->apply(aSource, pTransform);
if(mpClip)
{
// #i124852# transform may be needed when userSpaceOnUse
mpClip->apply(aSource, pTransform);
}
} }
if(!aSource.empty()) // test again, applied clipPath may have lead to empty geometry if(!aSource.empty()) // test again, applied clipPath may have lead to empty geometry
...@@ -1215,6 +1210,7 @@ namespace svgio ...@@ -1215,6 +1210,7 @@ namespace svgio
maTitle(), maTitle(),
maDesc(), maDesc(),
maClipPathXLink(), maClipPathXLink(),
mpClipPathXLink(nullptr),
maMaskXLink(), maMaskXLink(),
maMarkerStartXLink(), maMarkerStartXLink(),
mpMarkerStartXLink(nullptr), mpMarkerStartXLink(nullptr),
...@@ -2659,6 +2655,38 @@ namespace svgio ...@@ -2659,6 +2655,38 @@ namespace svgio
return nullptr; return nullptr;
} }
OUString SvgStyleAttributes::getClipPathXLink() const
{
if(!maClipPathXLink.isEmpty())
{
return maClipPathXLink;
}
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes && !pSvgStyleAttributes->maClipPathXLink.isEmpty())
{
return pSvgStyleAttributes->getClipPathXLink();
}
return OUString();
}
const SvgClipPathNode* SvgStyleAttributes::accessClipPathXLink() const
{
if(!mpClipPathXLink)
{
const OUString aClipPath(getClipPathXLink());
if(!aClipPath.isEmpty())
{
const_cast< SvgStyleAttributes* >(this)->mpClipPathXLink = dynamic_cast< const SvgClipPathNode* >(mrOwner.getDocument().findSvgNodeById(getClipPathXLink()));
}
}
return mpClipPathXLink;
}
OUString SvgStyleAttributes::getMarkerStartXLink() const OUString SvgStyleAttributes::getMarkerStartXLink() const
{ {
if(!maMarkerStartXLink.isEmpty()) if(!maMarkerStartXLink.isEmpty())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment