summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-03-26 13:35:53 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-03-27 09:23:13 +0100
commite3d3581b327fd201d77f63a71fad52a52b53842f (patch)
tree591b9b2f8a3ed85253e386e4c80226ec76d181cd
parentea3d61886a2b420b985bed162c28b94698283c76 (diff)
tdf#159805 Printing line style dotted lines (horizontal) turns into dashes.
I could not find a good place to distinguish between the dragging visualisation (where we could safely use approximation), and the non-dragging case, so just revert. Revert commit 9f4ccc63346b26d8d774b22124da0842ef18e0bc Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Wed Sep 13 14:27:02 2023 +0200 tdf#156995 speed up dragging complex group objects Change-Id: I2ba52f07ea7299643c0f145459038e368a17dea8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165332 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit fc5d84681d5d898b56171a9622294ecb23623bfd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165320 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx51
-rw-r--r--include/basegfx/polygon/b2dpolygontools.hxx2
2 files changed, 13 insertions, 40 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index b3f43669ddf4..d33c752008b4 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)
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx
index d21d0bb63bfe..a29d1fd06a52 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -113,7 +113,7 @@ namespace basegfx::utils
BASEGFX_DLLPUBLIC double getEdgeLength(const B2DPolygon& rCandidate, sal_uInt32 nIndex);
/** get length of polygon */
- BASEGFX_DLLPUBLIC double getLength(const B2DPolygon& rCandidate, bool bApproximateBezierLength = false);
+ BASEGFX_DLLPUBLIC double getLength(const B2DPolygon& rCandidate);
// get position on polygon for absolute given distance. If
// length is given, it is assumed the correct polygon length, if 0.0 it is calculated