summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-08-14 11:56:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-08-14 12:08:11 +0100
commit342438c6e0f377b938c4ff213dca9e9665b709d9 (patch)
tree3138c2d5046a9a26f833d20dd2f512740b0adda0 /svgio
parentb1ac43d1ab416d334a0feb93244941eee447abcf (diff)
returning pointers to temporaries
Change-Id: I1bb65ee0ff3059ee47f83d54814f3a228994d960
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgio/svgreader/svgsvgnode.hxx2
-rw-r--r--svgio/source/svgreader/svgsvgnode.cxx13
2 files changed, 10 insertions, 5 deletions
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 <svgio/svgreader/svgstyleattributes.hxx>
+#include <boost/scoped_ptr.hpp>
//////////////////////////////////////////////////////////////////////////////
@@ -36,6 +37,7 @@ namespace svgio
/// variable scan values, dependent of given XAttributeList
basegfx::B2DRange* mpViewBox;
+ mutable boost::scoped_ptr<basegfx::B2DRange> 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