svgio/inc/svgio/svgreader/svgstyleattributes.hxx | 5 ++ svgio/source/svgreader/svgstyleattributes.cxx | 46 ++++++++++++++++++----- 2 files changed, 41 insertions(+), 10 deletions(-)
New commits: commit d5649ae7b76278cb3155f951d6327157c7c92b65 Author: Xisco Fauli <aniste...@gmail.com> Date: Sun Mar 6 19:03:27 2016 +0100 SVGIO: tdf#97539: clip-path elements might contain... reference to other clip-paths Change-Id: I3722b31cefa4df6225e369b3d1db9f46be5933ff Reviewed-on: https://gerrit.libreoffice.org/22956 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Xisco Faulà <aniste...@gmail.com> diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx index f0c21ba..fcd6114 100644 --- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx +++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx @@ -32,6 +32,7 @@ namespace svgio { namespace svgreader { class SvgGradientNode; class SvgPatternNode; class SvgMarkerNode; + class SvgClipPathNode; }} @@ -215,6 +216,7 @@ namespace svgio /// link to content. If set, the node can be fetched on demand OUString maClipPathXLink; + const SvgClipPathNode* mpClipPathXLink; OUString maMaskXLink; /// link to markers. If set, the node can be fetched on demand @@ -441,7 +443,8 @@ namespace svgio void setDesc(const OUString& rNew) { maDesc = rNew; } // ClipPathXLink content - const OUString getClipPathXLink() const { return maClipPathXLink; } + OUString getClipPathXLink() const; + const SvgClipPathNode* accessClipPathXLink() const; // MaskXLink content const OUString getMaskXLink() const { return maMaskXLink; } diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 3e454e4..691a1f8 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1145,16 +1145,11 @@ namespace svgio aSource = drawinglayer::primitive2d::Primitive2DContainer { xRef }; } - if(!getClipPathXLink().isEmpty()) + const SvgClipPathNode* mpClip = accessClipPathXLink(); + if(mpClip) { - // try to access linked ClipPath - const SvgClipPathNode* mpClip = dynamic_cast< const SvgClipPathNode* >(mrOwner.getDocument().findSvgNodeById(getClipPathXLink())); - - if(mpClip) - { - // #i124852# transform may be needed when userSpaceOnUse - mpClip->apply(aSource, pTransform); - } + // #i124852# transform may be needed when userSpaceOnUse + mpClip->apply(aSource, pTransform); } if(!aSource.empty()) // test again, applied clipPath may have lead to empty geometry @@ -1215,6 +1210,7 @@ namespace svgio maTitle(), maDesc(), maClipPathXLink(), + mpClipPathXLink(nullptr), maMaskXLink(), maMarkerStartXLink(), mpMarkerStartXLink(nullptr), @@ -2659,6 +2655,38 @@ namespace svgio 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 { if(!maMarkerStartXLink.isEmpty())
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits