summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-05-15 22:52:48 +0900
committerTomaž Vajngerl <quikee@gmail.com>2022-05-16 17:09:51 +0200
commitc9711f2ff2ee40f9e3928325ac1ba7c47da158ad (patch)
tree4a114928068f9cd1044b02f7298d2b38d15d7d3b
parentbasegfx: move ImplB2DPolyPolygon inside basegfx namespace (diff)
downloadcore-c9711f2ff2ee40f9e3928325ac1ba7c47da158ad.tar.gz
core-c9711f2ff2ee40f9e3928325ac1ba7c47da158ad.zip
basegfx: remove CoordinateData2D class and use B2DPoint directly
For some reason B2DPolygon used a CoordinateData2D class that derived from basegfx::B2DPoint with no added functionallity that is used in practice (just an explicit method transform instead of using an operator*=). This class has been removed and replaced with B2DPoint instead. Also removed was the typdef CoordinateData2DVector and calls to the std::vector's iterator (begin, end) have been simplified with "auto". Change-Id: I0d187ded05a8e22de36a8e17523e87871aab912c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134378 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx55
1 files changed, 17 insertions, 38 deletions
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 3c85a2666d25..8a4136666eaa 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -28,34 +28,13 @@
#include <memory>
#include <vector>
-namespace {
-
-struct CoordinateData2D : public basegfx::B2DPoint
+namespace
{
-public:
- CoordinateData2D() {}
-
- explicit CoordinateData2D(const basegfx::B2DPoint& rData)
- : B2DPoint(rData)
- {}
-
- CoordinateData2D& operator=(const basegfx::B2DPoint& rData)
- {
- B2DPoint::operator=(rData);
- return *this;
- }
-
- void transform(const basegfx::B2DHomMatrix& rMatrix)
- {
- *this *= rMatrix;
- }
-};
class CoordinateDataArray2D
{
- typedef std::vector< CoordinateData2D > CoordinateData2DVector;
-
- CoordinateData2DVector maVector;
+private:
+ std::vector<basegfx::B2DPoint> maVector;
public:
explicit CoordinateDataArray2D(sal_uInt32 nCount)
@@ -93,17 +72,17 @@ public:
maVector.reserve(nCount);
}
- void append(const CoordinateData2D& rValue)
+ void append(const basegfx::B2DPoint& rValue)
{
maVector.push_back(rValue);
}
- void insert(sal_uInt32 nIndex, const CoordinateData2D& rValue, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 nCount)
{
if(nCount)
{
// add nCount copies of rValue
- CoordinateData2DVector::iterator aIndex(maVector.begin());
+ auto aIndex = maVector.begin();
aIndex += nIndex;
maVector.insert(aIndex, nCount, rValue);
}
@@ -116,10 +95,10 @@ public:
if(nCount)
{
// insert data
- CoordinateData2DVector::iterator aIndex(maVector.begin());
+ auto aIndex = maVector.begin();
aIndex += nIndex;
- CoordinateData2DVector::const_iterator aStart(rSource.maVector.begin());
- CoordinateData2DVector::const_iterator aEnd(rSource.maVector.end());
+ auto aStart = rSource.maVector.cbegin();
+ auto aEnd = rSource.maVector.cend();
maVector.insert(aIndex, aStart, aEnd);
}
}
@@ -129,9 +108,9 @@ public:
if(nCount)
{
// remove point data
- CoordinateData2DVector::iterator aStart(maVector.begin());
+ auto aStart = maVector.begin();
aStart += nIndex;
- const CoordinateData2DVector::iterator aEnd(aStart + nCount);
+ const auto aEnd = aStart + nCount;
maVector.erase(aStart, aEnd);
}
}
@@ -144,8 +123,8 @@ public:
// to keep the same point at index 0, just flip all points except the
// first one when closed
const sal_uInt32 nHalfSize(bIsClosed ? (maVector.size() - 1) >> 1 : maVector.size() >> 1);
- CoordinateData2DVector::iterator aStart(bIsClosed ? maVector.begin() + 1 : maVector.begin());
- CoordinateData2DVector::iterator aEnd(maVector.end() - 1);
+ auto aStart = bIsClosed ? maVector.begin() + 1 : maVector.begin();
+ auto aEnd = maVector.end() - 1;
for(sal_uInt32 a(0); a < nHalfSize; a++)
{
@@ -188,9 +167,9 @@ public:
void transform(const basegfx::B2DHomMatrix& rMatrix)
{
- for (auto & elem : maVector)
+ for (auto& point : maVector)
{
- elem.transform(rMatrix);
+ point *= rMatrix;
}
}
};
@@ -713,7 +692,7 @@ public:
void append(const basegfx::B2DPoint& rPoint)
{
mpBufferedData.reset(); // TODO: is this needed?
- const CoordinateData2D aCoordinate(rPoint);
+ const auto aCoordinate = rPoint;
maPoints.append(aCoordinate);
if(moControlVector)
@@ -728,7 +707,7 @@ public:
if(nCount)
{
mpBufferedData.reset();
- CoordinateData2D aCoordinate(rPoint);
+ auto aCoordinate = rPoint;
maPoints.insert(nIndex, aCoordinate, nCount);
if(moControlVector)