svgio/inc/svgio/svgreader/svgstyleattributes.hxx |    5 ++
 svgio/source/svgreader/svgstyleattributes.cxx    |   46 ++++++++++++++++++-----
 2 files changed, 41 insertions(+), 10 deletions(-)

New commits:
commit ecc7f698b5f080530f006218fa3dd82da43d9abb
Author: Xisco Fauli <aniste...@gmail.com>
Date:   Mon Mar 7 23:05:59 2016 +0100

    SVGIO: Fix problem when style's parent contains a mask element
    
    Change-Id: I26aab6c0f959f6cc78d040f59f1acf0c7e29931b
    Reviewed-on: https://gerrit.libreoffice.org/23045
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noelgran...@gmail.com>

diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx 
b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
index fcd6114..f711feb 100644
--- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
+++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
@@ -33,6 +33,7 @@ namespace svgio { namespace svgreader {
     class SvgPatternNode;
     class SvgMarkerNode;
     class SvgClipPathNode;
+    class SvgMaskNode;
 }}
 
 
@@ -218,6 +219,7 @@ namespace svgio
             OUString               maClipPathXLink;
             const SvgClipPathNode* mpClipPathXLink;
             OUString               maMaskXLink;
+            const SvgMaskNode*     mpMaskXLink;
 
             /// link to markers. If set, the node can be fetched on demand
             OUString               maMarkerStartXLink;
@@ -447,7 +449,8 @@ namespace svgio
             const SvgClipPathNode* accessClipPathXLink() const;
 
             // MaskXLink content
-            const OUString getMaskXLink() const { return maMaskXLink; }
+            OUString getMaskXLink() const;
+            const SvgMaskNode* accessMaskXLink() const;
 
             // MarkerStartXLink content
             OUString getMarkerStartXLink() const;
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 691a1f8..b226770 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1154,16 +1154,11 @@ namespace svgio
 
                 if(!aSource.empty()) // test again, applied clipPath may have 
lead to empty geometry
                 {
-                    if(!getMaskXLink().isEmpty())
+                    const SvgMaskNode* mpMask = accessMaskXLink();
+                    if(mpMask)
                     {
-                        // try to access linked Mask
-                        const SvgMaskNode* mpMask = dynamic_cast< const 
SvgMaskNode* >(mrOwner.getDocument().findSvgNodeById(getMaskXLink()));
-
-                        if(mpMask)
-                        {
-                            // #i124852# transform may be needed when 
userSpaceOnUse
-                            mpMask->apply(aSource, pTransform);
-                        }
+                        // #i124852# transform may be needed when 
userSpaceOnUse
+                        mpMask->apply(aSource, pTransform);
                     }
 
                     if(!aSource.empty()) // test again, applied mask may have 
lead to empty geometry
@@ -1212,6 +1207,7 @@ namespace svgio
             maClipPathXLink(),
             mpClipPathXLink(nullptr),
             maMaskXLink(),
+            mpMaskXLink(nullptr),
             maMarkerStartXLink(),
             mpMarkerStartXLink(nullptr),
             maMarkerMidXLink(),
@@ -2687,6 +2683,38 @@ namespace svgio
             return mpClipPathXLink;
         }
 
+        OUString SvgStyleAttributes::getMaskXLink() const
+        {
+            if(!maMaskXLink.isEmpty())
+            {
+                return maMaskXLink;
+            }
+
+            const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+            if(pSvgStyleAttributes && 
!pSvgStyleAttributes->maMaskXLink.isEmpty())
+            {
+                return pSvgStyleAttributes->getMaskXLink();
+            }
+
+            return OUString();
+        }
+
+        const SvgMaskNode* SvgStyleAttributes::accessMaskXLink() const
+        {
+            if(!mpMaskXLink)
+            {
+                const OUString aMask(getMaskXLink());
+
+                if(!aMask.isEmpty())
+                {
+                    const_cast< SvgStyleAttributes* >(this)->mpMaskXLink = 
dynamic_cast< const SvgMaskNode* 
>(mrOwner.getDocument().findSvgNodeById(getMaskXLink()));
+                }
+            }
+
+            return mpMaskXLink;
+        }
+
         OUString SvgStyleAttributes::getMarkerStartXLink() const
         {
             if(!maMarkerStartXLink.isEmpty())
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to