summaryrefslogtreecommitdiffstats
path: root/basegfx/source/polygon/b2dpolygontools.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:03:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:09:28 +0000
commit97ac77f067910fa5e8206d75160fa63546a9358d (patch)
treee6fa64b43e8150ef65578afa4f1f40f3e19f7fa3 /basegfx/source/polygon/b2dpolygontools.cxx
parentReleasing progress-linux version 4:24.2.2-3~progress7.99u1. (diff)
downloadlibreoffice-97ac77f067910fa5e8206d75160fa63546a9358d.tar.xz
libreoffice-97ac77f067910fa5e8206d75160fa63546a9358d.zip
Merging upstream version 4:24.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx51
1 files changed, 12 insertions, 39 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index b3f43669dd..d33c752008 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -475,7 +475,7 @@ namespace basegfx::utils
return fRetval;
}
- double getLength(const B2DPolygon& rCandidate, bool bApproximateBezierLength)
+ double getLength(const B2DPolygon& rCandidate)
{
double fRetval(0.0);
const sal_uInt32 nPointCount(rCandidate.count());
@@ -486,45 +486,18 @@ namespace basegfx::utils
if(rCandidate.areControlPointsUsed())
{
- if (bApproximateBezierLength)
- {
- B2DPoint aStartPoint = rCandidate.getB2DPoint(0);
-
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
- {
- // An approximate length of a cubic Bezier curve is the average
- // of its chord length and the sum of the lengths of its control net sides.
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
- const B2DPoint& aControlPoint1 = rCandidate.getNextControlPoint(a);
- const B2DPoint& aControlPoint2 = rCandidate.getPrevControlPoint(nNextIndex);
- const B2DPoint& aEndPoint = rCandidate.getB2DPoint(nNextIndex);
-
- double chord_length = B2DVector(aEndPoint - aStartPoint).getLength();
- double control_net_length = B2DVector(aStartPoint - aControlPoint1).getLength()
- + B2DVector(aControlPoint2 - aControlPoint1).getLength()
- + B2DVector(aEndPoint - aControlPoint2).getLength();
- double approximate_arc_length = (control_net_length + chord_length) / 2;
-
- fRetval += approximate_arc_length;
- aStartPoint = aEndPoint;
- }
+ B2DCubicBezier aEdge;
+ aEdge.setStartPoint(rCandidate.getB2DPoint(0));
- }
- else
+ for(sal_uInt32 a(0); a < nEdgeCount; a++)
{
- B2DCubicBezier aEdge;
- aEdge.setStartPoint(rCandidate.getB2DPoint(0));
-
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
- {
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
- aEdge.setControlPointA(rCandidate.getNextControlPoint(a));
- aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex));
- aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex));
+ const sal_uInt32 nNextIndex((a + 1) % nPointCount);
+ aEdge.setControlPointA(rCandidate.getNextControlPoint(a));
+ aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex));
+ aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex));
- fRetval += aEdge.getLength();
- aEdge.setStartPoint(aEdge.getEndPoint());
- }
+ fRetval += aEdge.getLength();
+ aEdge.setStartPoint(aEdge.getEndPoint());
}
}
else
@@ -1259,9 +1232,9 @@ namespace basegfx::utils
// precalculate maximal acceptable length of candidate polygon assuming
// we want to create a maximum of fNumberOfAllowedSnippets. For
// fNumberOfAllowedSnippets use ca. 65536, double due to line & gap.
- static const double fNumberOfAllowedSnippets(100.0 * 2.0);
+ static const double fNumberOfAllowedSnippets(65535.0 * 2.0);
const double fAllowedLength((fNumberOfAllowedSnippets * fDotDashLength) / double(rDotDashArray.size()));
- const double fCandidateLength(basegfx::utils::getLength(rCandidate, /*bApproximateBezierLength*/true));
+ const double fCandidateLength(basegfx::utils::getLength(rCandidate));
std::vector<double> aDotDashArray(rDotDashArray);
if(fCandidateLength > fAllowedLength)