summaryrefslogtreecommitdiff
path: root/basegfx/source/polygon
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-09-13 13:02:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-13 15:05:56 +0200
commit6c7c7bcdbd3e47cad5c6b94e1ed1c5314dbdbf6b (patch)
tree4ab84fa839582aa6922450429d15f3b10cec74a5 /basegfx/source/polygon
parent5979076a14098f6887b61e937cfc9059ff7f2506 (diff)
loplugin:cow_wrapper
check the classes that use o3tl::cow_wrapper so that they don't unnecessarity trigger copies Change-Id: I545e627598217f3e61ba2c384adb8d4f8b404829 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122030 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basegfx/source/polygon')
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx52
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx16
-rw-r--r--basegfx/source/polygon/b3dpolygon.cxx34
-rw-r--r--basegfx/source/polygon/b3dpolypolygon.cxx10
4 files changed, 56 insertions, 56 deletions
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index e8f6d947c7d2..7276208cd326 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1177,9 +1177,9 @@ namespace basegfx
void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->getPoint(nIndex) != rValue)
+ if(std::as_const(*mpPolygon).getPoint(nIndex) != rValue)
{
mpPolygon->setPoint(nIndex, rValue);
}
@@ -1192,7 +1192,7 @@ namespace basegfx
void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPoint& rPoint, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
+ OSL_ENSURE(nIndex <= std::as_const(*mpPolygon).count(), "B2DPolygon Insert outside range (!)");
if(nCount)
{
@@ -1204,7 +1204,7 @@ namespace basegfx
{
if(nCount)
{
- mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, nCount);
}
}
@@ -1243,10 +1243,10 @@ namespace basegfx
void B2DPolygon::setPrevControlPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- const basegfx::B2DVector aNewVector(rValue - mpPolygon->getPoint(nIndex));
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
+ const basegfx::B2DVector aNewVector(rValue - std::as_const(*mpPolygon).getPoint(nIndex));
- if(mpPolygon->getPrevControlVector(nIndex) != aNewVector)
+ if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != aNewVector)
{
mpPolygon->setPrevControlVector(nIndex, aNewVector);
}
@@ -1254,10 +1254,10 @@ namespace basegfx
void B2DPolygon::setNextControlPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- const basegfx::B2DVector aNewVector(rValue - mpPolygon->getPoint(nIndex));
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
+ const basegfx::B2DVector aNewVector(rValue - std::as_const(*mpPolygon).getPoint(nIndex));
- if(mpPolygon->getNextControlVector(nIndex) != aNewVector)
+ if(std::as_const(*mpPolygon).getNextControlVector(nIndex) != aNewVector)
{
mpPolygon->setNextControlVector(nIndex, aNewVector);
}
@@ -1265,12 +1265,12 @@ namespace basegfx
void B2DPolygon::setControlPoints(sal_uInt32 nIndex, const basegfx::B2DPoint& rPrev, const basegfx::B2DPoint& rNext)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- const B2DPoint aPoint(mpPolygon->getPoint(nIndex));
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
+ const B2DPoint aPoint(std::as_const(*mpPolygon).getPoint(nIndex));
const basegfx::B2DVector aNewPrev(rPrev - aPoint);
const basegfx::B2DVector aNewNext(rNext - aPoint);
- if(mpPolygon->getPrevControlVector(nIndex) != aNewPrev || mpPolygon->getNextControlVector(nIndex) != aNewNext)
+ if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != aNewPrev || std::as_const(*mpPolygon).getNextControlVector(nIndex) != aNewNext)
{
mpPolygon->setControlVectors(nIndex, aNewPrev, aNewNext);
}
@@ -1278,9 +1278,9 @@ namespace basegfx
void B2DPolygon::resetPrevControlPoint(sal_uInt32 nIndex)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->areControlPointsUsed() && !mpPolygon->getPrevControlVector(nIndex).equalZero())
+ if(std::as_const(*mpPolygon).areControlPointsUsed() && !std::as_const(*mpPolygon).getPrevControlVector(nIndex).equalZero())
{
mpPolygon->setPrevControlVector(nIndex, B2DVector::getEmptyVector());
}
@@ -1288,9 +1288,9 @@ namespace basegfx
void B2DPolygon::resetNextControlPoint(sal_uInt32 nIndex)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->areControlPointsUsed() && !mpPolygon->getNextControlVector(nIndex).equalZero())
+ if(std::as_const(*mpPolygon).areControlPointsUsed() && !std::as_const(*mpPolygon).getNextControlVector(nIndex).equalZero())
{
mpPolygon->setNextControlVector(nIndex, B2DVector::getEmptyVector());
}
@@ -1298,7 +1298,7 @@ namespace basegfx
void B2DPolygon::resetControlPoints()
{
- if(mpPolygon->areControlPointsUsed())
+ if(std::as_const(*mpPolygon).areControlPointsUsed())
{
mpPolygon->resetControlVectors();
}
@@ -1309,12 +1309,12 @@ namespace basegfx
const B2DPoint& rPrevControlPoint,
const B2DPoint& rPoint)
{
- const B2DVector aNewNextVector(mpPolygon->count() ? B2DVector(rNextControlPoint - mpPolygon->getPoint(mpPolygon->count() - 1)) : B2DVector::getEmptyVector());
+ const B2DVector aNewNextVector(std::as_const(*mpPolygon).count() ? B2DVector(rNextControlPoint - std::as_const(*mpPolygon).getPoint(std::as_const(*mpPolygon).count() - 1)) : B2DVector::getEmptyVector());
const B2DVector aNewPrevVector(rPrevControlPoint - rPoint);
if(aNewNextVector.equalZero() && aNewPrevVector.equalZero())
{
- mpPolygon->insert(mpPolygon->count(), rPoint, 1);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, 1);
}
else
{
@@ -1324,7 +1324,7 @@ namespace basegfx
void B2DPolygon::appendQuadraticBezierSegment(const B2DPoint& rControlPoint, const B2DPoint& rPoint)
{
- if (mpPolygon->count() == 0)
+ if (std::as_const(*mpPolygon).count() == 0)
{
mpPolygon->append(rPoint);
const double nX((rControlPoint.getX() * 2.0 + rPoint.getX()) / 3.0);
@@ -1333,7 +1333,7 @@ namespace basegfx
}
else
{
- const B2DPoint aPreviousPoint(mpPolygon->getPoint(mpPolygon->count() - 1));
+ const B2DPoint aPreviousPoint(std::as_const(*mpPolygon).getPoint(std::as_const(*mpPolygon).count() - 1));
const double nX1((rControlPoint.getX() * 2.0 + aPreviousPoint.getX()) / 3.0);
const double nY1((rControlPoint.getY() * 2.0 + aPreviousPoint.getY()) / 3.0);
@@ -1436,19 +1436,19 @@ namespace basegfx
if(nIndex == 0 && nCount == rPoly.count())
{
- mpPolygon->insert(mpPolygon->count(), *rPoly.mpPolygon);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), *rPoly.mpPolygon);
}
else
{
OSL_ENSURE(nIndex + nCount <= rPoly.mpPolygon->count(), "B2DPolygon Append outside range (!)");
ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
- mpPolygon->insert(mpPolygon->count(), aTempPoly);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), aTempPoly);
}
}
void B2DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B2DPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolygon).count(), "B2DPolygon Remove outside range (!)");
if(nCount)
{
@@ -1498,7 +1498,7 @@ namespace basegfx
void B2DPolygon::transform(const B2DHomMatrix& rMatrix)
{
- if(mpPolygon->count() && !rMatrix.isIdentity())
+ if(std::as_const(*mpPolygon).count() && !rMatrix.isIdentity())
{
mpPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index 78b3b7085303..34ff30877ea8 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -249,7 +249,7 @@ namespace basegfx
void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon)
{
- OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B2DPolyPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon access outside range (!)");
if(getB2DPolygon(nIndex) != rPolygon)
mpPolyPolygon->setB2DPolygon(nIndex, rPolygon);
@@ -272,7 +272,7 @@ namespace basegfx
void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
+ OSL_ENSURE(nIndex <= std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon Insert outside range (!)");
if(nCount)
mpPolyPolygon->insert(nIndex, rPolygon, nCount);
@@ -281,7 +281,7 @@ namespace basegfx
void B2DPolyPolygon::append(const B2DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount);
+ mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolygon, nCount);
}
B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const
@@ -310,7 +310,7 @@ namespace basegfx
void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon)
{
- OSL_ENSURE(nIndex <= mpPolyPolygon->count(), "B2DPolyPolygon Insert outside range (!)");
+ OSL_ENSURE(nIndex <= std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon Insert outside range (!)");
if(rPolyPolygon.count())
mpPolyPolygon->insert(nIndex, rPolyPolygon);
@@ -319,12 +319,12 @@ namespace basegfx
void B2DPolyPolygon::append(const B2DPolyPolygon& rPolyPolygon)
{
if(rPolyPolygon.count())
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon);
+ mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolyPolygon);
}
void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B2DPolyPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon Remove outside range (!)");
if(nCount)
mpPolyPolygon->remove(nIndex, nCount);
@@ -360,7 +360,7 @@ namespace basegfx
void B2DPolyPolygon::flip()
{
- if(mpPolyPolygon->count())
+ if(std::as_const(*mpPolyPolygon).count())
{
mpPolyPolygon->flip();
}
@@ -389,7 +389,7 @@ namespace basegfx
void B2DPolyPolygon::transform(const B2DHomMatrix& rMatrix)
{
- if(mpPolyPolygon->count() && !rMatrix.isIdentity())
+ if(std::as_const(*mpPolyPolygon).count() && !rMatrix.isIdentity())
{
mpPolyPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx
index 364f9f8c0e1d..dac943c79049 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -1431,7 +1431,7 @@ namespace basegfx
void B3DPolygon::setB3DPoint(sal_uInt32 nIndex, const basegfx::B3DPoint& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
if(getB3DPoint(nIndex) != rValue)
mpPolygon->setPoint(nIndex, rValue);
@@ -1446,9 +1446,9 @@ namespace basegfx
void B3DPolygon::setBColor(sal_uInt32 nIndex, const BColor& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
- if(mpPolygon->getBColor(nIndex) != rValue)
+ if(std::as_const(*mpPolygon).getBColor(nIndex) != rValue)
mpPolygon->setBColor(nIndex, rValue);
}
@@ -1459,7 +1459,7 @@ namespace basegfx
void B3DPolygon::clearBColors()
{
- if(mpPolygon->areBColorsUsed())
+ if(std::as_const(*mpPolygon).areBColorsUsed())
mpPolygon->clearBColors();
}
@@ -1477,15 +1477,15 @@ namespace basegfx
void B3DPolygon::setNormal(sal_uInt32 nIndex, const B3DVector& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
- if(mpPolygon->getNormal(nIndex) != rValue)
+ if(std::as_const(*mpPolygon).getNormal(nIndex) != rValue)
mpPolygon->setNormal(nIndex, rValue);
}
void B3DPolygon::transformNormals(const B3DHomMatrix& rMatrix)
{
- if(mpPolygon->areNormalsUsed() && !rMatrix.isIdentity())
+ if(std::as_const(*mpPolygon).areNormalsUsed() && !rMatrix.isIdentity())
mpPolygon->transformNormals(rMatrix);
}
@@ -1496,7 +1496,7 @@ namespace basegfx
void B3DPolygon::clearNormals()
{
- if(mpPolygon->areNormalsUsed())
+ if(std::as_const(*mpPolygon).areNormalsUsed())
mpPolygon->clearNormals();
}
@@ -1509,15 +1509,15 @@ namespace basegfx
void B3DPolygon::setTextureCoordinate(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
- if(mpPolygon->getTextureCoordinate(nIndex) != rValue)
+ if(std::as_const(*mpPolygon).getTextureCoordinate(nIndex) != rValue)
mpPolygon->setTextureCoordinate(nIndex, rValue);
}
void B3DPolygon::transformTextureCoordinates(const B2DHomMatrix& rMatrix)
{
- if(mpPolygon->areTextureCoordinatesUsed() && !rMatrix.isIdentity())
+ if(std::as_const(*mpPolygon).areTextureCoordinatesUsed() && !rMatrix.isIdentity())
mpPolygon->transformTextureCoordinates(rMatrix);
}
@@ -1528,14 +1528,14 @@ namespace basegfx
void B3DPolygon::clearTextureCoordinates()
{
- if(mpPolygon->areTextureCoordinatesUsed())
+ if(std::as_const(*mpPolygon).areTextureCoordinatesUsed())
mpPolygon->clearTextureCoordinates();
}
void B3DPolygon::append(const basegfx::B3DPoint& rPoint, sal_uInt32 nCount)
{
if(nCount)
- mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, nCount);
}
void B3DPolygon::append(const B3DPolygon& rPoly, sal_uInt32 nIndex, sal_uInt32 nCount)
@@ -1550,19 +1550,19 @@ namespace basegfx
if(nIndex == 0 && nCount == rPoly.count())
{
- mpPolygon->insert(mpPolygon->count(), *rPoly.mpPolygon);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), *rPoly.mpPolygon);
}
else
{
OSL_ENSURE(nIndex + nCount <= rPoly.mpPolygon->count(), "B3DPolygon Append outside range (!)");
ImplB3DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
- mpPolygon->insert(mpPolygon->count(), aTempPoly);
+ mpPolygon->insert(std::as_const(*mpPolygon).count(), aTempPoly);
}
}
void B3DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= mpPolygon->count(), "B3DPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolygon).count(), "B3DPolygon Remove outside range (!)");
if(nCount)
mpPolygon->remove(nIndex, nCount);
@@ -1606,7 +1606,7 @@ namespace basegfx
void B3DPolygon::transform(const basegfx::B3DHomMatrix& rMatrix)
{
- if(mpPolygon->count() && !rMatrix.isIdentity())
+ if(std::as_const(*mpPolygon).count() && !rMatrix.isIdentity())
{
mpPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx
index 97ed39c87718..4104d2fc29fe 100644
--- a/basegfx/source/polygon/b3dpolypolygon.cxx
+++ b/basegfx/source/polygon/b3dpolypolygon.cxx
@@ -241,7 +241,7 @@ namespace basegfx
void B3DPolyPolygon::setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon)
{
- OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B3DPolyPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(*mpPolyPolygon).count(), "B3DPolyPolygon access outside range (!)");
if(getB3DPolygon(nIndex) != rPolygon)
mpPolyPolygon->setB3DPolygon(nIndex, rPolygon);
@@ -319,18 +319,18 @@ namespace basegfx
void B3DPolyPolygon::append(const B3DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolygon, nCount);
+ mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolygon, nCount);
}
void B3DPolyPolygon::append(const B3DPolyPolygon& rPolyPolygon)
{
if(rPolyPolygon.count())
- mpPolyPolygon->insert(mpPolyPolygon->count(), rPolyPolygon);
+ mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolyPolygon);
}
void B3DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= mpPolyPolygon->count(), "B3DPolyPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolyPolygon).count(), "B3DPolyPolygon Remove outside range (!)");
if(nCount)
mpPolyPolygon->remove(nIndex, nCount);
@@ -369,7 +369,7 @@ namespace basegfx
void B3DPolyPolygon::transform(const B3DHomMatrix& rMatrix)
{
- if(mpPolyPolygon->count() && !rMatrix.isIdentity())
+ if(std::as_const(*mpPolyPolygon).count() && !rMatrix.isIdentity())
{
mpPolyPolygon->transform(rMatrix);
}