diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2013-08-21 09:39:21 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-08-21 13:20:46 +0100 |
commit | 199eb7607cfb02ce9a68bff22c37aca91a8e9fb8 (patch) | |
tree | fae747e4e124eaeeec402c6e2361d9bc5164ce8b /svgio | |
parent | 172c37522bca256b1d0bd9f966d06f49845ba102 (diff) |
Related: #i122600# access memory problem in SvgSvgNode::getCurrentViewPort
(cherry picked from commit d41dc0bbe76922fee4ce177ecac0d84b9efc4206)
Conflicts:
svgio/inc/svgio/svgreader/svgnode.hxx
svgio/inc/svgio/svgreader/svgtools.hxx
Change-Id: Ie4d5cd29461845edb5b8a57fe639302947d80ebd
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgio/svgreader/svgmarkernode.hxx | 2 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgnode.hxx | 2 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgpatternnode.hxx | 2 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgsvgnode.hxx | 2 | ||||
-rw-r--r-- | svgio/inc/svgio/svgreader/svgtools.hxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgmarkernode.cxx | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgnode.cxx | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgpatternnode.cxx | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgsvgnode.cxx | 10 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 17 |
10 files changed, 24 insertions, 25 deletions
diff --git a/svgio/inc/svgio/svgreader/svgmarkernode.hxx b/svgio/inc/svgio/svgreader/svgmarkernode.hxx index 14fa5f14082b..0112f3a376f7 100644 --- a/svgio/inc/svgio/svgreader/svgmarkernode.hxx +++ b/svgio/inc/svgio/svgreader/svgmarkernode.hxx @@ -71,7 +71,7 @@ namespace svgio const drawinglayer::primitive2d::Primitive2DSequence& getMarkerPrimitives() const; /// InfoProvider support for % values - virtual const basegfx::B2DRange* getCurrentViewPort() const; + virtual const basegfx::B2DRange getCurrentViewPort() const; /// viewBox content const basegfx::B2DRange* getViewBox() const { return mpViewBox; } diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx index 7c1c39b968d9..a76c18b2c37b 100644 --- a/svgio/inc/svgio/svgreader/svgnode.hxx +++ b/svgio/inc/svgio/svgreader/svgnode.hxx @@ -134,7 +134,7 @@ namespace svgio const SvgNodeVector& getChildren() const { return maChildren; } /// InfoProvider support for %, em and ex values - virtual const basegfx::B2DRange* getCurrentViewPort() const SAL_OVERRIDE; + virtual const basegfx::B2DRange getCurrentViewPort() const SAL_OVERRIDE; virtual double getCurrentFontSizeInherited() const SAL_OVERRIDE; virtual double getCurrentXHeightInherited() const SAL_OVERRIDE; diff --git a/svgio/inc/svgio/svgreader/svgpatternnode.hxx b/svgio/inc/svgio/svgreader/svgpatternnode.hxx index e70abce816dd..ecb9ec1e5ea1 100644 --- a/svgio/inc/svgio/svgreader/svgpatternnode.hxx +++ b/svgio/inc/svgio/svgreader/svgpatternnode.hxx @@ -74,7 +74,7 @@ namespace svgio const drawinglayer::primitive2d::Primitive2DSequence& getPatternPrimitives() const; /// InfoProvider support for % values - virtual const basegfx::B2DRange* getCurrentViewPort() const; + virtual const basegfx::B2DRange getCurrentViewPort() const; /// viewBox content const basegfx::B2DRange* getViewBox() const; diff --git a/svgio/inc/svgio/svgreader/svgsvgnode.hxx b/svgio/inc/svgio/svgreader/svgsvgnode.hxx index 7226d7fcfc27..8455b7c94876 100644 --- a/svgio/inc/svgio/svgreader/svgsvgnode.hxx +++ b/svgio/inc/svgio/svgreader/svgsvgnode.hxx @@ -62,7 +62,7 @@ namespace svgio // The returned 'CurrentViewPort' is the viewport as it is set by this svg element // and as it is needed to resolve relative values in childs // The method does not check for invalid width and height - virtual const basegfx::B2DRange* getCurrentViewPort() const; + virtual const basegfx::B2DRange getCurrentViewPort() const; /// viewBox content const basegfx::B2DRange* getViewBox() const { return mpViewBox; } diff --git a/svgio/inc/svgio/svgreader/svgtools.hxx b/svgio/inc/svgio/svgreader/svgtools.hxx index 8a808b29b976..c6ede61a1145 100644 --- a/svgio/inc/svgio/svgreader/svgtools.hxx +++ b/svgio/inc/svgio/svgreader/svgtools.hxx @@ -66,7 +66,7 @@ namespace svgio { public: virtual ~InfoProvider() {} - virtual const basegfx::B2DRange* getCurrentViewPort() const = 0; + virtual const basegfx::B2DRange getCurrentViewPort() const = 0; /// return font size of node inherited from parents virtual double getCurrentFontSizeInherited() const = 0; /// return xheight of node inherited from parents diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx index 94eb24a3037c..dd900e4e7a0c 100644 --- a/svgio/source/svgreader/svgmarkernode.cxx +++ b/svgio/source/svgreader/svgmarkernode.cxx @@ -190,11 +190,11 @@ namespace svgio return aPrimitives; } - const basegfx::B2DRange* SvgMarkerNode::getCurrentViewPort() const + const basegfx::B2DRange SvgMarkerNode::getCurrentViewPort() const { if(getViewBox()) { - return getViewBox(); + return *(getViewBox()); } else { diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index e1698e81c472..d25f6daf3dbe 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -479,7 +479,7 @@ namespace svgio } } - const basegfx::B2DRange* SvgNode::getCurrentViewPort() const + const basegfx::B2DRange SvgNode::getCurrentViewPort() const { if(getParent()) { @@ -487,7 +487,7 @@ namespace svgio } else { - return 0; + return basegfx::B2DRange(); // return empty B2DRange } } diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx index dd406394e78a..c743caa8e175 100644 --- a/svgio/source/svgreader/svgpatternnode.cxx +++ b/svgio/source/svgreader/svgpatternnode.cxx @@ -287,11 +287,11 @@ namespace svgio return aPrimitives; } - const basegfx::B2DRange* SvgPatternNode::getCurrentViewPort() const + const basegfx::B2DRange SvgPatternNode::getCurrentViewPort() const { if(getViewBox()) { - return getViewBox(); + return *(getViewBox()); } else { diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx index 8524a016c3e5..5798fd739738 100644 --- a/svgio/source/svgreader/svgsvgnode.cxx +++ b/svgio/source/svgreader/svgsvgnode.cxx @@ -600,11 +600,11 @@ namespace svgio } } - const basegfx::B2DRange* SvgSvgNode::getCurrentViewPort() const + const basegfx::B2DRange SvgSvgNode::getCurrentViewPort() const { if(getViewBox()) { - return getViewBox(); + return *(getViewBox()); } else // viewport should be given by x, y, width, and height { @@ -628,7 +628,7 @@ namespace svgio if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute) { - return &basegfx::B2DRange(fX, fY, fX+fW, fY+fH); + return basegfx::B2DRange(fX, fY, fX+fW, fY+fH); } else // try to resolve relative values { @@ -671,7 +671,7 @@ namespace svgio if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute) { - return &basegfx::B2DRange(fX, fY, fX+fW, fY+fH); + return basegfx::B2DRange(fX, fY, fX+fW, fY+fH); } else // relative values could not be resolved, there exists no fallback { @@ -690,7 +690,7 @@ namespace svgio double fH( bHeightIsAbsolute ? getHeight().solveNonPercentage(*this) : 0.0); if (bWidthIsAbsolute && bHeightIsAbsolute) { - return &basegfx::B2DRange(0.0, 0.0, fW, fH); + return basegfx::B2DRange(0.0, 0.0, fW, fH); } else // no fallback exists { diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 9ace14f5b0f4..8b5454dfeb2f 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -226,40 +226,39 @@ namespace svgio case Unit_percent: { double fRetval(mfNumber * 0.01); - const basegfx::B2DRange* pViewPort = rInfoProvider.getCurrentViewPort(); + basegfx::B2DRange aViewPort = rInfoProvider.getCurrentViewPort(); - if(!pViewPort) + if ( aViewPort.isEmpty() ) { #ifdef DBG_UTIL myAssert(rtl::OUString::createFromAscii("Design error, this case should have been handled in the caller")); #endif // no viewPort, assume a normal page size (A4) - static basegfx::B2DRange aDinA4Range( + aViewPort = basegfx::B2DRange( 0.0, 0.0, 210.0 * F_SVG_PIXEL_PER_INCH / 2.54, 297.0 * F_SVG_PIXEL_PER_INCH / 2.54); - pViewPort = &aDinA4Range; } - if(pViewPort) + if ( !aViewPort.isEmpty() ) { if(xcoordinate == aNumberType) { // it's a x-coordinate, relative to current width (w) - fRetval *= pViewPort->getWidth(); + fRetval *= aViewPort.getWidth(); } else if(ycoordinate == aNumberType) { // it's a y-coordinate, relative to current height (h) - fRetval *= pViewPort->getHeight(); + fRetval *= aViewPort.getHeight(); } else // length { // it's a length, relative to sqrt(w*w + h*h)/sqrt(2) - const double fCurrentWidth(pViewPort->getWidth()); - const double fCurrentHeight(pViewPort->getHeight()); + const double fCurrentWidth(aViewPort.getWidth()); + const double fCurrentHeight(aViewPort.getHeight()); const double fCurrentLength( sqrt(fCurrentWidth * fCurrentWidth + fCurrentHeight * fCurrentHeight)/sqrt(2.0)); |