From 26f46b861d8504033685b2eec4d003eef8109a27 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 21 Dec 2021 13:29:14 +0200 Subject: loplugin:flatten in accessibility..basic Change-Id: If2cc282c2b135d634daf393a082c29049b10a677 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127223 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basegfx/source/inc/hommatrixtemplate.hxx | 28 ++--- basegfx/source/polygon/b2dpolygon.cxx | 53 ++++----- basegfx/source/polygon/b2dpolygontools.cxx | 138 +++++++++++----------- basegfx/source/polygon/b2dpolygontriangulator.cxx | 28 ++--- basegfx/source/polygon/b2dtrapezoid.cxx | 40 +++---- 5 files changed, 139 insertions(+), 148 deletions(-) (limited to 'basegfx') diff --git a/basegfx/source/inc/hommatrixtemplate.hxx b/basegfx/source/inc/hommatrixtemplate.hxx index 44f7cd8027cf..a80df114c3e3 100644 --- a/basegfx/source/inc/hommatrixtemplate.hxx +++ b/basegfx/source/inc/hommatrixtemplate.hxx @@ -174,26 +174,26 @@ namespace basegfx::internal void testLastLine() { - if(mpLine) - { - bool bNecessary(false); + if(!mpLine) + return; - for(sal_uInt16 a(0);!bNecessary && a < RowSize; a++) - { - const double fDefault(implGetDefaultValue((RowSize - 1), a)); - const double fLineValue(mpLine->get(a)); + bool bNecessary(false); - if(!::basegfx::fTools::equal(fDefault, fLineValue)) - { - bNecessary = true; - } - } + for(sal_uInt16 a(0);!bNecessary && a < RowSize; a++) + { + const double fDefault(implGetDefaultValue((RowSize - 1), a)); + const double fLineValue(mpLine->get(a)); - if(!bNecessary) + if(!::basegfx::fTools::equal(fDefault, fLineValue)) { - mpLine.reset(); + bNecessary = true; } } + + if(!bNecessary) + { + mpLine.reset(); + } } // Left-upper decomposition diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 4d2b681911e2..3c85a2666d25 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -664,41 +664,34 @@ public: bool operator==(const ImplB2DPolygon& rCandidate) const { - if(mbIsClosed == rCandidate.mbIsClosed) + if(mbIsClosed != rCandidate.mbIsClosed) + return false; + if(!(maPoints == rCandidate.maPoints)) + return false; + bool bControlVectorsAreEqual(true); + + if(moControlVector) { - if(maPoints == rCandidate.maPoints) + if(rCandidate.moControlVector) { - bool bControlVectorsAreEqual(true); - - if(moControlVector) - { - if(rCandidate.moControlVector) - { - bControlVectorsAreEqual = ((*moControlVector) == (*rCandidate.moControlVector)); - } - else - { - // candidate has no control vector, so it's assumed all unused. - bControlVectorsAreEqual = !moControlVector->isUsed(); - } - } - else - { - if(rCandidate.moControlVector) - { - // we have no control vector, so it's assumed all unused. - bControlVectorsAreEqual = !rCandidate.moControlVector->isUsed(); - } - } - - if(bControlVectorsAreEqual) - { - return true; - } + bControlVectorsAreEqual = ((*moControlVector) == (*rCandidate.moControlVector)); + } + else + { + // candidate has no control vector, so it's assumed all unused. + bControlVectorsAreEqual = !moControlVector->isUsed(); + } + } + else + { + if(rCandidate.moControlVector) + { + // we have no control vector, so it's assumed all unused. + bControlVectorsAreEqual = !rCandidate.moControlVector->isUsed(); } } - return false; + return bControlVectorsAreEqual; } const basegfx::B2DPoint& getPoint(sal_uInt32 nIndex) const diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index d497716e9c31..c6eb3cf5b28b 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -1530,36 +1530,36 @@ namespace basegfx::utils const B2DPolygon& aCandidate(rCandidate.getDefaultAdaptiveSubdivision()); const sal_uInt32 nPointCount(aCandidate.count()); - if(nPointCount) - { - const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1); - B2DPoint aCurrent(aCandidate.getB2DPoint(0)); - - if(nEdgeCount) - { - // edges - for(sal_uInt32 a(0); a < nEdgeCount; a++) - { - const sal_uInt32 nNextIndex((a + 1) % nPointCount); - const B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex)); + if(!nPointCount) + return false; - if(isInEpsilonRange(aCurrent, aNext, rTestPosition, fDistance)) - { - return true; - } + const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1); + B2DPoint aCurrent(aCandidate.getB2DPoint(0)); - // prepare next step - aCurrent = aNext; - } - } - else + if(nEdgeCount) + { + // edges + for(sal_uInt32 a(0); a < nEdgeCount; a++) { - // no edges, but points -> not closed. Check single point. Just - // use isInEpsilonRange with twice the same point, it handles those well - if(isInEpsilonRange(aCurrent, aCurrent, rTestPosition, fDistance)) + const sal_uInt32 nNextIndex((a + 1) % nPointCount); + const B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex)); + + if(isInEpsilonRange(aCurrent, aNext, rTestPosition, fDistance)) { return true; } + + // prepare next step + aCurrent = aNext; + } + } + else + { + // no edges, but points -> not closed. Check single point. Just + // use isInEpsilonRange with twice the same point, it handles those well + if(isInEpsilonRange(aCurrent, aCurrent, rTestPosition, fDistance)) + { + return true; } } @@ -1933,29 +1933,29 @@ namespace basegfx::utils OSL_ENSURE(!rCandidate.areControlPointsUsed(), "hasNeutralPoints: ATM works not for curves (!)"); const sal_uInt32 nPointCount(rCandidate.count()); - if(nPointCount > 2) + if(nPointCount <= 2) + return false; + + B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1)); + B2DPoint aCurrPoint(rCandidate.getB2DPoint(0)); + + for(sal_uInt32 a(0); a < nPointCount; a++) { - B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1)); - B2DPoint aCurrPoint(rCandidate.getB2DPoint(0)); + const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount)); + const B2DVector aPrevVec(aPrevPoint - aCurrPoint); + const B2DVector aNextVec(aNextPoint - aCurrPoint); + const B2VectorOrientation aOrientation(getOrientation(aNextVec, aPrevVec)); - for(sal_uInt32 a(0); a < nPointCount; a++) + if(aOrientation == B2VectorOrientation::Neutral) { - const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount)); - const B2DVector aPrevVec(aPrevPoint - aCurrPoint); - const B2DVector aNextVec(aNextPoint - aCurrPoint); - const B2VectorOrientation aOrientation(getOrientation(aNextVec, aPrevVec)); - - if(aOrientation == B2VectorOrientation::Neutral) - { - // current has neutral orientation - return true; - } - else - { - // prepare next - aPrevPoint = aCurrPoint; - aCurrPoint = aNextPoint; - } + // current has neutral orientation + return true; + } + else + { + // prepare next + aPrevPoint = aCurrPoint; + aCurrPoint = aNextPoint; } } @@ -2015,37 +2015,37 @@ namespace basegfx::utils OSL_ENSURE(!rCandidate.areControlPointsUsed(), "isConvex: ATM works not for curves (!)"); const sal_uInt32 nPointCount(rCandidate.count()); - if(nPointCount > 2) + if(nPointCount <= 2) + return true; + + const B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1)); + B2DPoint aCurrPoint(rCandidate.getB2DPoint(0)); + B2DVector aCurrVec(aPrevPoint - aCurrPoint); + B2VectorOrientation aOrientation(B2VectorOrientation::Neutral); + + for(sal_uInt32 a(0); a < nPointCount; a++) { - const B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1)); - B2DPoint aCurrPoint(rCandidate.getB2DPoint(0)); - B2DVector aCurrVec(aPrevPoint - aCurrPoint); - B2VectorOrientation aOrientation(B2VectorOrientation::Neutral); + const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount)); + const B2DVector aNextVec(aNextPoint - aCurrPoint); + const B2VectorOrientation aCurrentOrientation(getOrientation(aNextVec, aCurrVec)); - for(sal_uInt32 a(0); a < nPointCount; a++) + if(aOrientation == B2VectorOrientation::Neutral) { - const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount)); - const B2DVector aNextVec(aNextPoint - aCurrPoint); - const B2VectorOrientation aCurrentOrientation(getOrientation(aNextVec, aCurrVec)); - - if(aOrientation == B2VectorOrientation::Neutral) - { - // set start value, maybe neutral again - aOrientation = aCurrentOrientation; - } - else + // set start value, maybe neutral again + aOrientation = aCurrentOrientation; + } + else + { + if(aCurrentOrientation != B2VectorOrientation::Neutral && aCurrentOrientation != aOrientation) { - if(aCurrentOrientation != B2VectorOrientation::Neutral && aCurrentOrientation != aOrientation) - { - // different orientations found, that's it - return false; - } + // different orientations found, that's it + return false; } - - // prepare next - aCurrPoint = aNextPoint; - aCurrVec = -aNextVec; } + + // prepare next + aCurrPoint = aNextPoint; + aCurrVec = -aNextVec; } return true; diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx index 880b1b5c310c..5fbd3960e585 100644 --- a/basegfx/source/polygon/b2dpolygontriangulator.cxx +++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx @@ -180,23 +180,23 @@ namespace basegfx bool Triangulator::CheckPointInTriangle(EdgeEntry* pEdgeA, EdgeEntry const * pEdgeB, const B2DPoint& rTestPoint) { // inside triangle or on edge? - if(utils::isPointInTriangle(pEdgeA->getStart(), pEdgeA->getEnd(), pEdgeB->getEnd(), rTestPoint, true)) + if(!utils::isPointInTriangle(pEdgeA->getStart(), pEdgeA->getEnd(), pEdgeB->getEnd(), rTestPoint, true)) + return true; + + // but not on point + if(!rTestPoint.equal(pEdgeA->getEnd()) && !rTestPoint.equal(pEdgeB->getEnd())) { - // but not on point - if(!rTestPoint.equal(pEdgeA->getEnd()) && !rTestPoint.equal(pEdgeB->getEnd())) - { - // found point in triangle -> split triangle inserting two edges - EdgeEntry* pStart = new EdgeEntry(pEdgeA->getStart(), rTestPoint); - EdgeEntry* pEnd = new EdgeEntry(*pStart); - maNewEdgeEntries.emplace_back(pStart); - maNewEdgeEntries.emplace_back(pEnd); + // found point in triangle -> split triangle inserting two edges + EdgeEntry* pStart = new EdgeEntry(pEdgeA->getStart(), rTestPoint); + EdgeEntry* pEnd = new EdgeEntry(*pStart); + maNewEdgeEntries.emplace_back(pStart); + maNewEdgeEntries.emplace_back(pEnd); - pStart->setNext(pEnd); - pEnd->setNext(pEdgeA->getNext()); - pEdgeA->setNext(pStart); + pStart->setNext(pEnd); + pEnd->setNext(pEdgeA->getNext()); + pEdgeA->setNext(pStart); - return false; - } + return false; } return true; diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx index 0bfb8fb5705f..b7991dbf55d4 100644 --- a/basegfx/source/polygon/b2dtrapezoid.cxx +++ b/basegfx/source/polygon/b2dtrapezoid.cxx @@ -395,28 +395,26 @@ namespace basegfx::trapezoidhelper aEdgeB.getStart(), aDeltaB, CutFlagValue::LINE, &fCutA, - &fCutB) != CutFlagValue::NONE) - { - // use a simple metric (length criteria) for choosing the numerically - // better cut - const double fSimpleLengthA(aDeltaA.getX() + aDeltaA.getY()); - const double fSimpleLengthB(aDeltaB.getX() + aDeltaB.getY()); - const bool bAIsLonger(fSimpleLengthA > fSimpleLengthB); - B2DPoint* pNewPoint = bAIsLonger - ? maNewPoints.allocatePoint(aEdgeA.getStart() + (fCutA * aDeltaA)) - : maNewPoints.allocatePoint(aEdgeB.getStart() + (fCutB * aDeltaB)); - - // try to split both edges - bool bRetval = splitEdgeAtGivenPoint(aEdgeA, *pNewPoint, aCurrent); - bRetval |= splitEdgeAtGivenPoint(aEdgeB, *pNewPoint, aCurrent); - - if(!bRetval) - maNewPoints.freeIfLast(pNewPoint); - - return bRetval; - } + &fCutB) == CutFlagValue::NONE) + return false; + + // use a simple metric (length criteria) for choosing the numerically + // better cut + const double fSimpleLengthA(aDeltaA.getX() + aDeltaA.getY()); + const double fSimpleLengthB(aDeltaB.getX() + aDeltaB.getY()); + const bool bAIsLonger(fSimpleLengthA > fSimpleLengthB); + B2DPoint* pNewPoint = bAIsLonger + ? maNewPoints.allocatePoint(aEdgeA.getStart() + (fCutA * aDeltaA)) + : maNewPoints.allocatePoint(aEdgeB.getStart() + (fCutB * aDeltaB)); + + // try to split both edges + bool bRetval = splitEdgeAtGivenPoint(aEdgeA, *pNewPoint, aCurrent); + bRetval |= splitEdgeAtGivenPoint(aEdgeB, *pNewPoint, aCurrent); + + if(!bRetval) + maNewPoints.freeIfLast(pNewPoint); - return false; + return bRetval; } void solveHorizontalEdges(TrDeSimpleEdges& rTrDeSimpleEdges) -- cgit