diff options
-rw-r--r-- | svgio/inc/svgio/svgreader/svgnode.hxx | 9 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgtools.hxx | 8 | ||||
-rw-r--r-- | svgio/source/svgreader/svgnode.cxx | 32 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 4 |
4 files changed, 33 insertions, 20 deletions
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx index 725fb5cb2b8a..7c1c39b968d9 100644 --- a/svgio/inc/svgio/svgreader/svgnode.hxx +++ b/svgio/inc/svgio/svgreader/svgnode.hxx @@ -134,9 +134,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 0dbedf87eac5..138a06546a0b 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 3bc092d5ec3e..e1698e81c472 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -491,13 +491,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(); } @@ -507,14 +503,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(); } @@ -524,6 +523,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 2b89f0df6f1b..7607a439a3ed 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: { |