[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - svgio/inc svgio/source

Thorsten Behrens tbehrens at suse.com
Thu Jun 27 12:24:45 PDT 2013


 svgio/inc/svgio/svgreader/svgnode.hxx  |    9 ++++++---
 svgio/inc/svgio/svgreader/svgtools.hxx |    8 +++++---
 svgio/source/svgreader/svgnode.cxx     |   32 ++++++++++++++++++++------------
 svgio/source/svgreader/svgtools.cxx    |    4 ++--
 4 files changed, 33 insertions(+), 20 deletions(-)

New commits:
commit 1d405e396361d2a01b29e97ed9f8f0199614fefa
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Thu Jun 27 20:41:29 2013 +0200

    Fix fdo#65847 - avoid infinite recursion in style resolution.
    
    That was previously asking back the node for the font size, which
    was again asking the SvgNumber, which was ...
    In this case, if the node has relative sizes, this is always
    relative to the parent.
    
    Change-Id: Iaa81d0238d9eb73f5af24df347d12d7cb8ba8c0a
    (cherry picked from commit d9b09a3ff38b2cf11ee0b9f9f03d47375f2b11e8)
    Reviewed-on: https://gerrit.libreoffice.org/4594
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index 759859b..7274489 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -103,9 +103,12 @@ namespace svgio
             const SvgNodeVector& getChildren() const { return maChildren; }
 
             /// InfoProvider support for %, em and ex values
-            virtual const basegfx::B2DRange* getCurrentViewPort() const;
-            virtual double getCurrentFontSize() const;
-            virtual double getCurrentXHeight() const;
+            virtual const basegfx::B2DRange* getCurrentViewPort() const SAL_OVERRIDE;
+            virtual double getCurrentFontSizeInherited() const SAL_OVERRIDE;
+            virtual double getCurrentXHeightInherited() const SAL_OVERRIDE;
+
+            double getCurrentFontSize() const;
+            double getCurrentXHeight() const;
 
             /// Id access
             const OUString* getId() const { return mpId; }
diff --git a/svgio/inc/svgio/svgreader/svgtools.hxx b/svgio/inc/svgio/svgreader/svgtools.hxx
index 0dbedf8..138a065 100644
--- a/svgio/inc/svgio/svgreader/svgtools.hxx
+++ b/svgio/inc/svgio/svgreader/svgtools.hxx
@@ -62,10 +62,12 @@ namespace svgio
         class InfoProvider
         {
         public:
-        virtual ~InfoProvider() {}
+            virtual ~InfoProvider() {}
             virtual const basegfx::B2DRange* getCurrentViewPort() const = 0;
-            virtual double getCurrentFontSize() const = 0;
-            virtual double getCurrentXHeight() const = 0;
+            /// return font size of node inherited from parents
+            virtual double getCurrentFontSizeInherited() const = 0;
+            /// return xheight of node inherited from parents
+            virtual double getCurrentXHeightInherited() const = 0;
         };
 
         enum SvgUnit
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index ff44050..262ec56 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -342,13 +342,9 @@ namespace svgio
             }
         }
 
-        double SvgNode::getCurrentFontSize() const
+        double SvgNode::getCurrentFontSizeInherited() const
         {
-            if(getSvgStyleAttributes())
-            {
-                return getSvgStyleAttributes()->getFontSize().solve(*this, xcoordinate);
-            }
-            else if(getParent())
+            if(getParent())
             {
                 return getParent()->getCurrentFontSize();
             }
@@ -358,14 +354,17 @@ namespace svgio
             }
         }
 
-        double SvgNode::getCurrentXHeight() const
+        double SvgNode::getCurrentFontSize() const
         {
             if(getSvgStyleAttributes())
-            {
-                // for XHeight, use FontSize currently
-                return getSvgStyleAttributes()->getFontSize().solve(*this, ycoordinate);
-            }
-            else if(getParent())
+                return getSvgStyleAttributes()->getFontSize().solve(*this, xcoordinate);
+
+            return getCurrentFontSizeInherited();
+        }
+
+        double SvgNode::getCurrentXHeightInherited() const
+        {
+            if(getParent())
             {
                 return getParent()->getCurrentXHeight();
             }
@@ -375,6 +374,15 @@ namespace svgio
             }
         }
 
+        double SvgNode::getCurrentXHeight() const
+        {
+            if(getSvgStyleAttributes())
+                // for XHeight, use FontSize currently
+                return getSvgStyleAttributes()->getFontSize().solve(*this, ycoordinate);
+
+            return getCurrentXHeightInherited();
+        }
+
         void SvgNode::setId(const OUString* pfId)
         {
             if(mpId)
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx
index 8e107a7..dd871ac 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -159,11 +159,11 @@ namespace svgio
                 {
                     case Unit_em:
                     {
-                        return mfNumber * rInfoProvider.getCurrentFontSize();
+                        return mfNumber * rInfoProvider.getCurrentFontSizeInherited();
                     }
                     case Unit_ex:
                     {
-                        return mfNumber * rInfoProvider.getCurrentXHeight() * 0.5;
+                        return mfNumber * rInfoProvider.getCurrentXHeightInherited() * 0.5;
                     }
                     case Unit_px:
                     {


More information about the Libreoffice-commits mailing list