From 342438c6e0f377b938c4ff213dca9e9665b709d9 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 14 Aug 2013 11:56:39 +0100 Subject: returning pointers to temporaries Change-Id: I1bb65ee0ff3059ee47f83d54814f3a228994d960 --- svgio/inc/svgio/svgreader/svgsvgnode.hxx | 2 ++ svgio/source/svgreader/svgsvgnode.cxx | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'svgio') diff --git a/svgio/inc/svgio/svgreader/svgsvgnode.hxx b/svgio/inc/svgio/svgreader/svgsvgnode.hxx index 7226d7fcfc27..157637a9f399 100644 --- a/svgio/inc/svgio/svgreader/svgsvgnode.hxx +++ b/svgio/inc/svgio/svgreader/svgsvgnode.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVGIO_SVGREADER_SVGSVGNODE_HXX #include +#include ////////////////////////////////////////////////////////////////////////////// @@ -36,6 +37,7 @@ namespace svgio /// variable scan values, dependent of given XAttributeList basegfx::B2DRange* mpViewBox; + mutable boost::scoped_ptr xGeneratedBox; SvgAspectRatio maSvgAspectRatio; SvgNumber maX; SvgNumber maY; diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx index 8524a016c3e5..1c8e2f746982 100644 --- a/svgio/source/svgreader/svgsvgnode.cxx +++ b/svgio/source/svgreader/svgsvgnode.cxx @@ -611,7 +611,7 @@ namespace svgio // Extract known viewport data // bXXXIsAbsolute tracks whether relative values could be resolved to absolute values if (getParent()) - { + { // If width or height is not provided, the default 100% is used, see SVG 1.1 section 5.1.2 // value 0.0 here is only to initialize variable bool bWidthIsAbsolute(getWidth().isSet() && Unit_percent != getWidth().getUnit()); @@ -628,7 +628,8 @@ namespace svgio if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute) { - return &basegfx::B2DRange(fX, fY, fX+fW, fY+fH); + xGeneratedBox.reset(new basegfx::B2DRange(fX, fY, fX+fW, fY+fH)); + return xGeneratedBox.get(); } else // try to resolve relative values { @@ -671,7 +672,8 @@ namespace svgio if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute) { - return &basegfx::B2DRange(fX, fY, fX+fW, fY+fH); + xGeneratedBox.reset(new basegfx::B2DRange(fX, fY, fX+fW, fY+fH)); + return xGeneratedBox.get(); } else // relative values could not be resolved, there exists no fallback { @@ -690,11 +692,12 @@ namespace svgio double fH( bHeightIsAbsolute ? getHeight().solveNonPercentage(*this) : 0.0); if (bWidthIsAbsolute && bHeightIsAbsolute) { - return &basegfx::B2DRange(0.0, 0.0, fW, fH); + xGeneratedBox.reset(new basegfx::B2DRange(0.0, 0.0, fW, fH)); + return xGeneratedBox.get(); } else // no fallback exists { - return SvgNode::getCurrentViewPort(); + return SvgNode::getCurrentViewPort(); } } // ToDo: Is it possible to decompose and use the bounding box of the childs, if even the -- cgit v1.2.3