loplugin:constantparam in basegfx

Change-Id: Ieabdd6f8d76cfc2ed75f2ec618def6591a9adc93
Reviewed-on: https://gerrit.libreoffice.org/44130
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2017-10-31 15:43:39 +02:00
parent 1a284d1f98
commit 094542511f
10 changed files with 36 additions and 97 deletions

View File

@@ -113,8 +113,7 @@ namespace basegfx
const B2DPoint& rfEB, // edge on B const B2DPoint& rfEB, // edge on B
const B2DPoint& rfPB, // end point const B2DPoint& rfPB, // end point
B2DPolygon& rTarget, // target polygon B2DPolygon& rTarget, // target polygon
const double& rfAngleBound, // angle bound in [0.0 .. 2PI] const double& rfAngleBound) // angle bound in [0.0 .. 2PI]
bool bAllowUnsharpen) // #i37443# allow the criteria to get unsharp in recursions
{ {
sal_uInt16 nMaxRecursionDepth(8); sal_uInt16 nMaxRecursionDepth(8);
const B2DVector aLeft(rfEA - rfPA); const B2DVector aLeft(rfEA - rfPA);
@@ -231,7 +230,7 @@ namespace basegfx
} }
else else
{ {
ImpSubDivAngle(rfPA, aS1L, aS2L, aS3C, rTarget, rfAngleBound, bAllowUnsharpen, nMaxRecursionDepth); ImpSubDivAngle(rfPA, aS1L, aS2L, aS3C, rTarget, rfAngleBound, true/*bAllowUnsharpen*/, nMaxRecursionDepth);
} }
// right // right
@@ -241,7 +240,7 @@ namespace basegfx
} }
else else
{ {
ImpSubDivAngle(aS3C, aS2R, aS1R, rfPB, rTarget, rfAngleBound, bAllowUnsharpen, nMaxRecursionDepth); ImpSubDivAngle(aS3C, aS2R, aS1R, rfPB, rTarget, rfAngleBound, true/*bAllowUnsharpen*/, nMaxRecursionDepth);
} }
} }
} }
@@ -551,7 +550,7 @@ namespace basegfx
if(isBezier()) if(isBezier())
{ {
// use support method #i37443# and allow unsharpen the criteria // use support method #i37443# and allow unsharpen the criteria
ImpSubDivAngleStart(maStartPoint, maControlPointA, maControlPointB, maEndPoint, rTarget, fAngleBound * F_PI180, true/*bAllowUnsharpen*/); ImpSubDivAngleStart(maStartPoint, maControlPointA, maControlPointB, maEndPoint, rTarget, fAngleBound * F_PI180);
} }
else else
{ {

View File

@@ -36,22 +36,20 @@ namespace basegfx
const sal_Int32 nLen); const sal_Int32 nLen);
inline bool isOnNumberChar(const sal_Unicode aChar, inline bool isOnNumberChar(const sal_Unicode aChar,
bool bSignAllowed, bool bSignAllowed)
bool bDotAllowed)
{ {
const bool bPredicate( (u'0' <= aChar && u'9' >= aChar) const bool bPredicate( (u'0' <= aChar && u'9' >= aChar)
|| (bSignAllowed && u'+' == aChar) || (bSignAllowed && u'+' == aChar)
|| (bSignAllowed && u'-' == aChar) || (bSignAllowed && u'-' == aChar)
|| (bDotAllowed && u'.' == aChar)); || (u'.' == aChar));
return bPredicate; return bPredicate;
} }
inline bool isOnNumberChar(const OUString& rStr, inline bool isOnNumberChar(const OUString& rStr,
const sal_Int32 nPos, const sal_Int32 nPos)
bool bSignAllowed = true)
{ {
return isOnNumberChar(rStr[nPos], bSignAllowed, true); return isOnNumberChar(rStr[nPos], true/*bSignAllowed*/);
} }
bool getDoubleChar(double& o_fRetval, bool getDoubleChar(double& o_fRetval,

View File

@@ -231,7 +231,7 @@ namespace basegfx
return fabs(getSignedArea(rCandidate)); return fabs(getSignedArea(rCandidate));
} }
void applyLineDashing(const B2DPolyPolygon& rCandidate, const std::vector<double>& rDotDashArray, B2DPolyPolygon* pLineTarget, B2DPolyPolygon* pGapTarget, double fFullDashDotLen) void applyLineDashing(const B2DPolyPolygon& rCandidate, const std::vector<double>& rDotDashArray, B2DPolyPolygon* pLineTarget, double fFullDashDotLen)
{ {
if(fFullDashDotLen == 0.0 && rDotDashArray.size()) if(fFullDashDotLen == 0.0 && rDotDashArray.size())
{ {
@@ -241,7 +241,7 @@ namespace basegfx
if(rCandidate.count() && fFullDashDotLen > 0.0) if(rCandidate.count() && fFullDashDotLen > 0.0)
{ {
B2DPolyPolygon aLineTarget, aGapTarget; B2DPolyPolygon aLineTarget;
for(sal_uInt32 a(0); a < rCandidate.count(); a++) for(sal_uInt32 a(0); a < rCandidate.count(); a++)
{ {
@@ -251,18 +251,13 @@ namespace basegfx
aCandidate, aCandidate,
rDotDashArray, rDotDashArray,
pLineTarget ? &aLineTarget : nullptr, pLineTarget ? &aLineTarget : nullptr,
pGapTarget ? &aGapTarget : nullptr, nullptr,
fFullDashDotLen); fFullDashDotLen);
if(pLineTarget) if(pLineTarget)
{ {
pLineTarget->append(aLineTarget); pLineTarget->append(aLineTarget);
} }
if(pGapTarget)
{
pGapTarget->append(aGapTarget);
}
} }
} }
} }
@@ -596,8 +591,7 @@ namespace basegfx
// converters for css::drawing::PointSequence // converters for css::drawing::PointSequence
B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon( B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon(
const css::drawing::PointSequenceSequence& rPointSequenceSequenceSource, const css::drawing::PointSequenceSequence& rPointSequenceSequenceSource)
bool bCheckClosed)
{ {
B2DPolyPolygon aRetval; B2DPolyPolygon aRetval;
const css::drawing::PointSequence* pPointSequence = rPointSequenceSequenceSource.getConstArray(); const css::drawing::PointSequence* pPointSequence = rPointSequenceSequenceSource.getConstArray();
@@ -605,7 +599,7 @@ namespace basegfx
for(;pPointSequence != pPointSeqEnd; pPointSequence++) for(;pPointSequence != pPointSeqEnd; pPointSequence++)
{ {
const B2DPolygon aNewPolygon = UnoPointSequenceToB2DPolygon(*pPointSequence, bCheckClosed); const B2DPolygon aNewPolygon = UnoPointSequenceToB2DPolygon(*pPointSequence, true/*bCheckClosed*/);
aRetval.append(aNewPolygon); aRetval.append(aNewPolygon);
} }
@@ -640,8 +634,7 @@ namespace basegfx
// converters for css::drawing::PolyPolygonBezierCoords (curved polygons) // converters for css::drawing::PolyPolygonBezierCoords (curved polygons)
B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon( B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
const css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource, const css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource)
bool bCheckClosed)
{ {
B2DPolyPolygon aRetval; B2DPolyPolygon aRetval;
const sal_uInt32 nSequenceCount((sal_uInt32)rPolyPolygonBezierCoordsSource.Coordinates.getLength()); const sal_uInt32 nSequenceCount((sal_uInt32)rPolyPolygonBezierCoordsSource.Coordinates.getLength());
@@ -658,7 +651,7 @@ namespace basegfx
const B2DPolygon aNewPolygon(UnoPolygonBezierCoordsToB2DPolygon( const B2DPolygon aNewPolygon(UnoPolygonBezierCoordsToB2DPolygon(
*pPointSequence, *pPointSequence,
*pFlagSequence, *pFlagSequence,
bCheckClosed)); true/*bCheckClosed*/));
pPointSequence++; pPointSequence++;
pFlagSequence++; pFlagSequence++;

View File

@@ -94,7 +94,7 @@ namespace basegfx
return fRetval; return fRetval;
} }
void applyLineDashing(const B3DPolygon& rCandidate, const std::vector<double>& rDotDashArray, B3DPolyPolygon* pLineTarget, B3DPolyPolygon* pGapTarget, double fDotDashLength) void applyLineDashing(const B3DPolygon& rCandidate, const std::vector<double>& rDotDashArray, B3DPolyPolygon* pLineTarget, double fDotDashLength)
{ {
const sal_uInt32 nPointCount(rCandidate.count()); const sal_uInt32 nPointCount(rCandidate.count());
const sal_uInt32 nDotDashCount(rDotDashArray.size()); const sal_uInt32 nDotDashCount(rDotDashArray.size());
@@ -104,7 +104,7 @@ namespace basegfx
fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0); fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0);
} }
if(fTools::more(fDotDashLength, 0.0) && (pLineTarget || pGapTarget) && nPointCount) if(fTools::more(fDotDashLength, 0.0) && pLineTarget && nPointCount)
{ {
// clear targets // clear targets
if(pLineTarget) if(pLineTarget)
@@ -112,11 +112,6 @@ namespace basegfx
pLineTarget->clear(); pLineTarget->clear();
} }
if(pGapTarget)
{
pGapTarget->clear();
}
// prepare current edge's start // prepare current edge's start
B3DPoint aCurrentPoint(rCandidate.getB3DPoint(0)); B3DPoint aCurrentPoint(rCandidate.getB3DPoint(0));
const sal_uInt32 nEdgeCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1); const sal_uInt32 nEdgeCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1);
@@ -142,9 +137,8 @@ namespace basegfx
{ {
// new split is inside edge, create and append snippet [fLastDotDashMovingLength, fDotDashMovingLength] // new split is inside edge, create and append snippet [fLastDotDashMovingLength, fDotDashMovingLength]
const bool bHandleLine(bIsLine && pLineTarget); const bool bHandleLine(bIsLine && pLineTarget);
const bool bHandleGap(!bIsLine && pGapTarget);
if(bHandleLine || bHandleGap) if(bHandleLine)
{ {
if(!aSnippet.count()) if(!aSnippet.count())
{ {
@@ -157,10 +151,6 @@ namespace basegfx
{ {
pLineTarget->append(aSnippet); pLineTarget->append(aSnippet);
} }
else
{
pGapTarget->append(aSnippet);
}
aSnippet.clear(); aSnippet.clear();
} }
@@ -173,9 +163,8 @@ namespace basegfx
// append snippet [fLastDotDashMovingLength, fEdgeLength] // append snippet [fLastDotDashMovingLength, fEdgeLength]
const bool bHandleLine(bIsLine && pLineTarget); const bool bHandleLine(bIsLine && pLineTarget);
const bool bHandleGap(!bIsLine && pGapTarget);
if(bHandleLine || bHandleGap) if(bHandleLine)
{ {
if(!aSnippet.count()) if(!aSnippet.count())
{ {
@@ -200,10 +189,6 @@ namespace basegfx
{ {
pLineTarget->append(aSnippet); pLineTarget->append(aSnippet);
} }
else if(!bIsLine && pGapTarget)
{
pGapTarget->append(aSnippet);
}
} }
// check if start and end polygon may be merged // check if start and end polygon may be merged
@@ -228,28 +213,6 @@ namespace basegfx
} }
} }
} }
if(pGapTarget)
{
const sal_uInt32 nCount(pGapTarget->count());
if(nCount > 1)
{
// these polygons were created above, there exists none with less than two points,
// thus dircet point access below is allowed
const B3DPolygon aFirst(pGapTarget->getB3DPolygon(0));
B3DPolygon aLast(pGapTarget->getB3DPolygon(nCount - 1));
if(aFirst.getB3DPoint(0).equal(aLast.getB3DPoint(aLast.count() - 1)))
{
// start of first and end of last are the same -> merge them
aLast.append(aFirst);
aLast.removeDoublePoints();
pGapTarget->setB3DPolygon(0, aLast);
pGapTarget->remove(nCount - 1);
}
}
}
} }
else else
{ {
@@ -258,11 +221,6 @@ namespace basegfx
{ {
pLineTarget->append(rCandidate); pLineTarget->append(rCandidate);
} }
if(pGapTarget)
{
pGapTarget->append(rCandidate);
}
} }
} }
@@ -676,7 +634,7 @@ namespace basegfx
} }
} }
bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithPoints) bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint)
{ {
const sal_uInt32 nPointCount(rCandidate.count()); const sal_uInt32 nPointCount(rCandidate.count());
@@ -689,7 +647,7 @@ namespace basegfx
{ {
const B3DPoint aNextPoint(rCandidate.getB3DPoint((a + 1) % nPointCount)); const B3DPoint aNextPoint(rCandidate.getB3DPoint((a + 1) % nPointCount));
if(isPointOnLine(aCurrentPoint, aNextPoint, rPoint, bWithPoints)) if(isPointOnLine(aCurrentPoint, aNextPoint, rPoint, true/*bWithPoints*/))
{ {
return true; return true;
} }
@@ -697,7 +655,7 @@ namespace basegfx
aCurrentPoint = aNextPoint; aCurrentPoint = aNextPoint;
} }
} }
else if(nPointCount && bWithPoints) else if(nPointCount)
{ {
return rPoint.equal(rCandidate.getB3DPoint(0)); return rPoint.equal(rCandidate.getB3DPoint(0));
} }

View File

@@ -455,13 +455,13 @@ namespace basegfx
return aRetval; return aRetval;
} }
bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder) bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint)
{ {
const sal_uInt32 nPolygonCount(rCandidate.count()); const sal_uInt32 nPolygonCount(rCandidate.count());
if(nPolygonCount == 1) if(nPolygonCount == 1)
{ {
return isInside(rCandidate.getB3DPolygon(0), rPoint, bWithBorder); return isInside(rCandidate.getB3DPolygon(0), rPoint, false/*bWithBorder*/);
} }
else else
{ {
@@ -470,7 +470,7 @@ namespace basegfx
for(sal_uInt32 a(0); a < nPolygonCount; a++) for(sal_uInt32 a(0); a < nPolygonCount; a++)
{ {
const B3DPolygon aPolygon(rCandidate.getB3DPolygon(a)); const B3DPolygon aPolygon(rCandidate.getB3DPolygon(a));
const bool bInside(isInside(aPolygon, rPoint, bWithBorder)); const bool bInside(isInside(aPolygon, rPoint, false/*bWithBorder*/));
if(bInside) if(bInside)
{ {
@@ -484,8 +484,7 @@ namespace basegfx
/// converters for css::drawing::PolyPolygonShape3D /// converters for css::drawing::PolyPolygonShape3D
B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon( B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon(
const css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource, const css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource)
bool bCheckClosed)
{ {
B3DPolyPolygon aRetval; B3DPolyPolygon aRetval;
const sal_Int32 nOuterSequenceCount(rPolyPolygonShape3DSource.SequenceX.getLength()); const sal_Int32 nOuterSequenceCount(rPolyPolygonShape3DSource.SequenceX.getLength());
@@ -523,10 +522,7 @@ namespace basegfx
// #i101520# correction is needed for imported polygons of old format, // #i101520# correction is needed for imported polygons of old format,
// see callers // see callers
if(bCheckClosed)
{
basegfx::utils::checkClosed(aNewPolygon); basegfx::utils::checkClosed(aNewPolygon);
}
aRetval.append(aNewPolygon); aRetval.append(aNewPolygon);
} }

View File

@@ -170,7 +170,7 @@ namespace basegfx
const sal_Int32 aLen( rStr.getLength() ); const sal_Int32 aLen( rStr.getLength() );
if(aLen) if(aLen)
{ {
if( isOnNumberChar(rStr[aLen - 1], false, true) && if( isOnNumberChar(rStr[aLen - 1], false) &&
fValue >= 0.0 ) fValue >= 0.0 )
{ {
rStr.append( ' ' ); rStr.append( ' ' );

View File

@@ -85,7 +85,7 @@ namespace drawinglayer
else else
{ {
// apply LineStyle // apply LineStyle
basegfx::utils::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, nullptr, getStrokeAttribute().getFullDotDashLen()); basegfx::utils::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, getStrokeAttribute().getFullDotDashLen());
} }
// prepare result // prepare result

View File

@@ -89,7 +89,6 @@ namespace basegfx
const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rCandidate,
const ::std::vector<double>& rDotDashArray, const ::std::vector<double>& rDotDashArray,
B2DPolyPolygon* pLineTarget, B2DPolyPolygon* pLineTarget,
B2DPolyPolygon* pGapTarget = nullptr,
double fFullDashDotLen = 0.0); double fFullDashDotLen = 0.0);
// test if point is inside epsilon-range around the given PolyPolygon. Can be used // test if point is inside epsilon-range around the given PolyPolygon. Can be used
@@ -277,16 +276,14 @@ namespace basegfx
/// converters for css::drawing::PointSequence /// converters for css::drawing::PointSequence
BASEGFX_DLLPUBLIC B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon( BASEGFX_DLLPUBLIC B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon(
const css::drawing::PointSequenceSequence& rPointSequenceSequenceSource, const css::drawing::PointSequenceSequence& rPointSequenceSequenceSource);
bool bCheckClosed = true);
BASEGFX_DLLPUBLIC void B2DPolyPolygonToUnoPointSequenceSequence( BASEGFX_DLLPUBLIC void B2DPolyPolygonToUnoPointSequenceSequence(
const B2DPolyPolygon& rPolyPolygon, const B2DPolyPolygon& rPolyPolygon,
css::drawing::PointSequenceSequence& rPointSequenceSequenceRetval); css::drawing::PointSequenceSequence& rPointSequenceSequenceRetval);
/// converters for css::drawing::PolyPolygonBezierCoords (curved polygons) /// converters for css::drawing::PolyPolygonBezierCoords (curved polygons)
BASEGFX_DLLPUBLIC B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon( BASEGFX_DLLPUBLIC B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
const css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource, const css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource);
bool bCheckClosed = true);
BASEGFX_DLLPUBLIC void B2DPolyPolygonToUnoPolyPolygonBezierCoords( BASEGFX_DLLPUBLIC void B2DPolyPolygonToUnoPolyPolygonBezierCoords(
const B2DPolyPolygon& rPolyPolygon, const B2DPolyPolygon& rPolyPolygon,
css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsRetval); css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsRetval);

View File

@@ -65,7 +65,6 @@ namespace basegfx
const B3DPolygon& rCandidate, const B3DPolygon& rCandidate,
const ::std::vector<double>& rDotDashArray, const ::std::vector<double>& rDotDashArray,
B3DPolyPolygon* pLineTarget, B3DPolyPolygon* pLineTarget,
B3DPolyPolygon* pGapTarget,
double fFullDashDotLen = 0.0); double fFullDashDotLen = 0.0);
/** Create/replace normals for given 3d geometry with default normals from given center to outside. /** Create/replace normals for given 3d geometry with default normals from given center to outside.
@@ -100,7 +99,7 @@ namespace basegfx
// calculates if given point is on given polygon, taking care of the numerical epsilon. Uses // calculates if given point is on given polygon, taking care of the numerical epsilon. Uses
// isPointOnLine internally // isPointOnLine internally
BASEGFX_DLLPUBLIC bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithPoints = true); BASEGFX_DLLPUBLIC bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint);
// helper to get a fCut position between a plane (given with normal and a point) // helper to get a fCut position between a plane (given with normal and a point)
// and a line given by start and end point // and a line given by start and end point

View File

@@ -121,14 +121,13 @@ namespace basegfx
*/ */
BASEGFX_DLLPUBLIC B3DPolyPolygon applyDefaultTextureCoordinatesSphere( const B3DPolyPolygon& rCandidate, const B3DPoint& rCenter, bool bChangeX = true, bool bChangeY = true); BASEGFX_DLLPUBLIC B3DPolyPolygon applyDefaultTextureCoordinatesSphere( const B3DPolyPolygon& rCandidate, const B3DPoint& rCenter, bool bChangeX = true, bool bChangeY = true);
// isInside test for B3DPoint. On border is not inside as long as not true is given // isInside test for B3DPoint. On border is not inside.
// in bWithBorder flag. It is assumed that the orientations of the given polygon are correct. // It is assumed that the orientations of the given polygon are correct.
BASEGFX_DLLPUBLIC bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder = false); BASEGFX_DLLPUBLIC bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint);
/// converters for css::drawing::PolyPolygonShape3D /// converters for css::drawing::PolyPolygonShape3D
BASEGFX_DLLPUBLIC B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon( BASEGFX_DLLPUBLIC B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon(
const css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource, const css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource);
bool bCheckClosed = true);
BASEGFX_DLLPUBLIC void B3DPolyPolygonToUnoPolyPolygonShape3D( BASEGFX_DLLPUBLIC void B3DPolyPolygonToUnoPolyPolygonShape3D(
const B3DPolyPolygon& rPolyPolygonSource, const B3DPolyPolygon& rPolyPolygonSource,
css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DRetval); css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DRetval);