summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorthb <thb@openoffice.org>2009-10-16 22:58:23 +0200
committerthb <thb@openoffice.org>2009-10-16 22:58:23 +0200
commit42c0c069b71db77b3a0f1617dac3c569df798625 (patch)
tree82d1cc56cc8e60aca8f11a790219fb9d6125ca12 /basegfx
parentd3356548cf6aa4c53cb4c17395df82e8bbdea88f (diff)
#i105939# Decided returning by const ref was a bad idea, coupling-
and in terms of unwanted side effects (think vector re-allocating the mem). Fixed iterator-to-ptr conversion for obvious oversights.
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolygon.hxx6
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx2
-rw-r--r--basegfx/inc/basegfx/range/b2dpolyrange.hxx2
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx24
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx20
-rw-r--r--basegfx/source/range/b2dpolyrange.cxx20
6 files changed, 55 insertions, 19 deletions
diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
index fb33a7d9b1fe..91544220f6ae 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
@@ -83,7 +83,7 @@ namespace basegfx
sal_uInt32 count() const;
/// Coordinate interface
- const basegfx::B2DPoint& getB2DPoint(sal_uInt32 nIndex) const;
+ basegfx::B2DPoint getB2DPoint(sal_uInt32 nIndex) const;
void setB2DPoint(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue);
/// Coordinate insert/append
@@ -201,7 +201,7 @@ namespace basegfx
@return
The outer range of the bezier curve/polygon
*/
- const B2DRange& getB2DRange() const;
+ B2DRange getB2DRange() const;
/** insert other 2D polygons
@@ -262,7 +262,7 @@ namespace basegfx
/// apply transformation given in matrix form
void transform(const basegfx::B2DHomMatrix& rMatrix);
- // point iterators
+ // point iterators (same iterator validity conditions as for vector)
const B2DPoint* begin() const;
const B2DPoint* end() const;
B2DPoint* begin();
diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
index 7b8119c5e43f..cff356de6d02 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
@@ -129,7 +129,7 @@ namespace basegfx
// apply transformation given in matrix form to the polygon
void transform(const basegfx::B2DHomMatrix& rMatrix);
- // polygon iterators
+ // polygon iterators (same iterator validity conditions as for vector)
const B2DPolygon* begin() const;
const B2DPolygon* end() const;
B2DPolygon* begin();
diff --git a/basegfx/inc/basegfx/range/b2dpolyrange.hxx b/basegfx/inc/basegfx/range/b2dpolyrange.hxx
index bd10bc15b7b5..2202869dc921 100644
--- a/basegfx/inc/basegfx/range/b2dpolyrange.hxx
+++ b/basegfx/inc/basegfx/range/b2dpolyrange.hxx
@@ -131,7 +131,7 @@ namespace basegfx
*/
B2DPolyPolygon solveCrossovers() const;
- // element iterators
+ // element iterators (same iterator validity conditions as for vector)
const B2DRange* begin() const;
const B2DRange* end() const;
B2DRange* begin();
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index ccf45d31cbbc..0f70c7efafda 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -210,22 +210,34 @@ public:
const basegfx::B2DPoint* begin() const
{
- return &maVector.front();
+ if(maVector.empty())
+ return 0;
+ else
+ return &maVector.front();
}
const basegfx::B2DPoint* end() const
{
- return &maVector[maVector.size()];
+ if(maVector.empty())
+ return 0;
+ else
+ return (&maVector.back())+1;
}
basegfx::B2DPoint* begin()
{
- return &maVector.front();
+ if(maVector.empty())
+ return 0;
+ else
+ return &maVector.front();
}
basegfx::B2DPoint* end()
{
- return &maVector[maVector.size()];
+ if(maVector.empty())
+ return 0;
+ else
+ return (&maVector.back())+1;
}
};
@@ -1201,7 +1213,7 @@ namespace basegfx
return mpPolygon->count();
}
- const B2DPoint& B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const
+ B2DPoint B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const
{
OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
@@ -1460,7 +1472,7 @@ namespace basegfx
return mpPolygon->getDefaultAdaptiveSubdivision(*this);
}
- const B2DRange& B2DPolygon::getB2DRange() const
+ B2DRange B2DPolygon::getB2DRange() const
{
return mpPolygon->getB2DRange(*this);
}
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index af63bbccf8d4..2acc1a31a369 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -169,22 +169,34 @@ public:
const basegfx::B2DPolygon* begin() const
{
- return &maPolygons.front();
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &maPolygons.front();
}
const basegfx::B2DPolygon* end() const
{
- return &maPolygons[maPolygons.size()];
+ if(maPolygons.empty())
+ return 0;
+ else
+ return (&maPolygons.back())+1;
}
basegfx::B2DPolygon* begin()
{
- return &maPolygons.front();
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &maPolygons.front();
}
basegfx::B2DPolygon* end()
{
- return &maPolygons[maPolygons.size()];
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &(maPolygons.back())+1;
}
};
diff --git a/basegfx/source/range/b2dpolyrange.cxx b/basegfx/source/range/b2dpolyrange.cxx
index d35af8f5dd0c..e212e083ef55 100644
--- a/basegfx/source/range/b2dpolyrange.cxx
+++ b/basegfx/source/range/b2dpolyrange.cxx
@@ -229,22 +229,34 @@ namespace basegfx
const B2DRange* begin() const
{
- return &maRanges.front();
+ if(maRanges.empty())
+ return 0;
+ else
+ return &maRanges.front();
}
const B2DRange* end() const
{
- return &maRanges[maRanges.size()];
+ if(maRanges.empty())
+ return 0;
+ else
+ return (&maRanges.back())+1;
}
B2DRange* begin()
{
- return &maRanges.front();
+ if(maRanges.empty())
+ return 0;
+ else
+ return &maRanges.front();
}
B2DRange* end()
{
- return &maRanges[maRanges.size()];
+ if(maRanges.empty())
+ return 0;
+ else
+ return (&maRanges.back())+1;
}
private: