[Libreoffice-commits] core.git: Branch 'aoo/trunk' - svgio/inc svgio/source
Oliver-Rainer Wittmann
orw at apache.org
Wed Aug 21 03:10:41 PDT 2013
svgio/inc/svgio/svgreader/svgmarkernode.hxx | 2 +-
svgio/inc/svgio/svgreader/svgnode.hxx | 2 +-
svgio/inc/svgio/svgreader/svgpatternnode.hxx | 2 +-
svgio/inc/svgio/svgreader/svgsvgnode.hxx | 2 +-
svgio/inc/svgio/svgreader/svgtools.hxx | 2 +-
svgio/source/svgreader/svgmarkernode.cxx | 4 ++--
svgio/source/svgreader/svgnode.cxx | 4 ++--
svgio/source/svgreader/svgpatternnode.cxx | 4 ++--
svgio/source/svgreader/svgsvgnode.cxx | 10 +++++-----
svgio/source/svgreader/svgtools.cxx | 17 ++++++++---------
10 files changed, 24 insertions(+), 25 deletions(-)
New commits:
commit d41dc0bbe76922fee4ce177ecac0d84b9efc4206
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Wed Aug 21 09:39:21 2013 +0000
122600: solve access memory problem of <SvgSvgNode::getCurrentViewPort()>
diff --git a/svgio/inc/svgio/svgreader/svgmarkernode.hxx b/svgio/inc/svgio/svgreader/svgmarkernode.hxx
index b5562f7..ca88681 100644
--- a/svgio/inc/svgio/svgreader/svgmarkernode.hxx
+++ b/svgio/inc/svgio/svgreader/svgmarkernode.hxx
@@ -74,7 +74,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 2711405..7142feb 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -137,7 +137,7 @@ namespace svgio
const SvgNodeVector& getChildren() const { return maChildren; }
/// InfoProvider support for %, em and ex values
- virtual const basegfx::B2DRange* getCurrentViewPort() const;
+ virtual const basegfx::B2DRange getCurrentViewPort() const;
virtual double getCurrentFontSize() const;
virtual double getCurrentXHeight() const;
diff --git a/svgio/inc/svgio/svgreader/svgpatternnode.hxx b/svgio/inc/svgio/svgreader/svgpatternnode.hxx
index faf0994..3841166 100644
--- a/svgio/inc/svgio/svgreader/svgpatternnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgpatternnode.hxx
@@ -77,7 +77,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 134dabe..38b7c2d 100644
--- a/svgio/inc/svgio/svgreader/svgsvgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgsvgnode.hxx
@@ -65,7 +65,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 3efc337..c7b0dca 100644
--- a/svgio/inc/svgio/svgreader/svgtools.hxx
+++ b/svgio/inc/svgio/svgreader/svgtools.hxx
@@ -68,7 +68,7 @@ namespace svgio
class InfoProvider
{
public:
- virtual const basegfx::B2DRange* getCurrentViewPort() const = 0;
+ virtual const basegfx::B2DRange getCurrentViewPort() const = 0;
virtual double getCurrentFontSize() const = 0;
virtual double getCurrentXHeight() const = 0;
};
diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx
index d10f8e0..8cc7e6c 100644
--- a/svgio/source/svgreader/svgmarkernode.cxx
+++ b/svgio/source/svgreader/svgmarkernode.cxx
@@ -196,11 +196,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 db5cb57..2d726a7 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -485,7 +485,7 @@ namespace svgio
}
}
- const basegfx::B2DRange* SvgNode::getCurrentViewPort() const
+ const basegfx::B2DRange SvgNode::getCurrentViewPort() const
{
if(getParent())
{
@@ -493,7 +493,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 feac0e2..c3db761 100644
--- a/svgio/source/svgreader/svgpatternnode.cxx
+++ b/svgio/source/svgreader/svgpatternnode.cxx
@@ -293,11 +293,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 fb46d3e..fc613db 100644
--- a/svgio/source/svgreader/svgsvgnode.cxx
+++ b/svgio/source/svgreader/svgsvgnode.cxx
@@ -605,11 +605,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
{
@@ -633,7 +633,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
{
@@ -676,7 +676,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
{
@@ -695,7 +695,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 2dcc229..ed35eed 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -237,40 +237,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));
More information about the Libreoffice-commits
mailing list