[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/source

Oliver-Rainer Wittmann orw at apache.org
Wed Aug 21 05:21:19 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     |    4 +---
 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        |   17 +++++++----------
 svgio/source/svgreader/svgtools.cxx          |   17 ++++++++---------
 10 files changed, 26 insertions(+), 32 deletions(-)

New commits:
commit 199eb7607cfb02ce9a68bff22c37aca91a8e9fb8
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Wed Aug 21 09:39:21 2013 +0000

    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

diff --git a/svgio/inc/svgio/svgreader/svgmarkernode.hxx b/svgio/inc/svgio/svgreader/svgmarkernode.hxx
index 14fa5f1..0112f3a 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 7c1c39b..a76c18b 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 e70abce..ecb9ec1 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 7226d7f..8455b7c 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 8a808b2..c6ede61 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 94eb24a..dd900e4 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 e1698e8..d25f6da 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 dd40639..c743caa 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 8524a01..5798fd7 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 9ace14f..8b5454d 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));
 
commit 172c37522bca256b1d0bd9f966d06f49845ba102
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Aug 21 13:17:01 2013 +0100

    Revert "returning pointers to temporaries"
    
    This reverts commit 342438c6e0f377b938c4ff213dca9e9665b709d9.

diff --git a/svgio/inc/svgio/svgreader/svgsvgnode.hxx b/svgio/inc/svgio/svgreader/svgsvgnode.hxx
index 157637a..7226d7f 100644
--- a/svgio/inc/svgio/svgreader/svgsvgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgsvgnode.hxx
@@ -21,7 +21,6 @@
 #define INCLUDED_SVGIO_SVGREADER_SVGSVGNODE_HXX
 
 #include <svgio/svgreader/svgstyleattributes.hxx>
-#include <boost/scoped_ptr.hpp>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -37,7 +36,6 @@ 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 1c8e2f7..8524a01 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,8 +628,7 @@ namespace svgio
 
                     if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute)
                     {
-                        xGeneratedBox.reset(new basegfx::B2DRange(fX, fY, fX+fW, fY+fH));
-                        return xGeneratedBox.get();
+                        return &basegfx::B2DRange(fX, fY, fX+fW, fY+fH);
                     }
                     else // try to resolve relative values
                     {
@@ -672,8 +671,7 @@ namespace svgio
 
                         if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute)
                         {
-                            xGeneratedBox.reset(new basegfx::B2DRange(fX, fY, fX+fW, fY+fH));
-                            return xGeneratedBox.get();
+                            return &basegfx::B2DRange(fX, fY, fX+fW, fY+fH);
                         }
                         else // relative values could not be resolved, there exists no fallback
                         {
@@ -692,12 +690,11 @@ namespace svgio
                     double fH( bHeightIsAbsolute ? getHeight().solveNonPercentage(*this) : 0.0);
                     if (bWidthIsAbsolute && bHeightIsAbsolute)
                     {
-                        xGeneratedBox.reset(new basegfx::B2DRange(0.0, 0.0, fW, fH));
-                        return xGeneratedBox.get();
+                        return &basegfx::B2DRange(0.0, 0.0, fW, fH);
                     }
                     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


More information about the Libreoffice-commits mailing list