[Libreoffice-commits] core.git: basegfx/source include/basegfx

2023-11-03 Thread Ankit_Jaipuriar (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx  |5 -
 basegfx/source/polygon/b3dpolygon.cxx  |5 -
 include/basegfx/polygon/b2dpolygon.hxx |1 -
 include/basegfx/polygon/b3dpolygon.hxx |1 -
 4 files changed, 12 deletions(-)

New commits:
commit 47e06b18ede70f3496bc7da97e1761fe1dbf629c
Author: Ankit_Jaipuriar 
AuthorDate: Tue Oct 10 19:33:31 2023 +0530
Commit: Ilmari Lauhakangas 
CommitDate: Fri Nov 3 07:48:19 2023 +0100

tdf#157664 Drop operator !=, where respective operator == is defined

Change-Id: I88b25dd676fc57303978e3d5e875af129240b676
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157762
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas 
Reviewed-by: Ilmari Lauhakangas 

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index ed5954bf0cf7..cf7309d20dd3 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1116,11 +1116,6 @@ namespace basegfx
 return ((*mpPolygon) == (*rPolygon.mpPolygon));
 }
 
-bool B2DPolygon::operator!=(const B2DPolygon& rPolygon) const
-{
-return !(*this == rPolygon);
-}
-
 sal_uInt32 B2DPolygon::count() const
 {
 return mpPolygon->count();
diff --git a/basegfx/source/polygon/b3dpolygon.cxx 
b/basegfx/source/polygon/b3dpolygon.cxx
index c1ee4b08345a..ebd9e3f4f7ea 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -1413,11 +1413,6 @@ namespace basegfx
 return (*mpPolygon == *rPolygon.mpPolygon);
 }
 
-bool B3DPolygon::operator!=(const B3DPolygon& rPolygon) const
-{
-return !(*this == rPolygon);
-}
-
 sal_uInt32 B3DPolygon::count() const
 {
 return mpPolygon->count();
diff --git a/include/basegfx/polygon/b2dpolygon.hxx 
b/include/basegfx/polygon/b2dpolygon.hxx
index 435ebf419cba..c63bda845d96 100644
--- a/include/basegfx/polygon/b2dpolygon.hxx
+++ b/include/basegfx/polygon/b2dpolygon.hxx
@@ -72,7 +72,6 @@ namespace basegfx
 
 /// compare operators
 bool operator==(const B2DPolygon& rPolygon) const;
-bool operator!=(const B2DPolygon& rPolygon) const;
 
 /// member count
 sal_uInt32 count() const;
diff --git a/include/basegfx/polygon/b3dpolygon.hxx 
b/include/basegfx/polygon/b3dpolygon.hxx
index ea9ea2fdedcf..13f8ed293f59 100644
--- a/include/basegfx/polygon/b3dpolygon.hxx
+++ b/include/basegfx/polygon/b3dpolygon.hxx
@@ -58,7 +58,6 @@ namespace basegfx
 
 // compare operators
 bool operator==(const B3DPolygon& rPolygon) const;
-bool operator!=(const B3DPolygon& rPolygon) const;
 
 // member count
 sal_uInt32 count() const;


[Libreoffice-commits] core.git: basegfx/source include/basegfx

2023-10-08 Thread Mike Kaganski (via logerrit)
 basegfx/source/point/b2dpoint.cxx|   12 +++
 basegfx/source/point/b3dpoint.cxx|   30 +-
 basegfx/source/vector/b2dvector.cxx  |   38 +++
 basegfx/source/vector/b3dvector.cxx  |   18 +--
 include/basegfx/color/bcolor.hxx |   44 +--
 include/basegfx/point/b2dpoint.hxx   |   12 +++
 include/basegfx/point/b3dpoint.hxx   |   18 +--
 include/basegfx/tuple/Tuple2D.hxx|   49 +++---
 include/basegfx/tuple/Tuple3D.hxx|   56 +--
 include/basegfx/tuple/b2dtuple.hxx   |2 -
 include/basegfx/tuple/b3dtuple.hxx   |   52 
 include/basegfx/vector/b2dvector.hxx |   16 +-
 include/basegfx/vector/b3dvector.hxx |   30 +-
 13 files changed, 177 insertions(+), 200 deletions(-)

New commits:
commit 347112fbd89ebd2a244052f14e085c9d3c90838d
Author: Mike Kaganski 
AuthorDate: Sun Oct 8 13:14:39 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Oct 8 18:53:00 2023 +0200

Drop temporary aliases from Tuple2D and Tuple3D

Change-Id: I091b68bbeee74452a3d6a03711cfc482b7a78e1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157685
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basegfx/source/point/b2dpoint.cxx 
b/basegfx/source/point/b2dpoint.cxx
index 1d7f75158526..d12c3dd04c4f 100644
--- a/basegfx/source/point/b2dpoint.cxx
+++ b/basegfx/source/point/b2dpoint.cxx
@@ -26,16 +26,16 @@ namespace basegfx
 B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat )
 {
 double fTempX(
-rMat.get(0, 0) * mfX +
-rMat.get(0, 1) * mfY +
+rMat.get(0, 0) * mnX +
+rMat.get(0, 1) * mnY +
 rMat.get(0, 2));
 double fTempY(
-rMat.get(1, 0) * mfX +
-rMat.get(1, 1) * mfY +
+rMat.get(1, 0) * mnX +
+rMat.get(1, 1) * mnY +
 rMat.get(1, 2));
 
-mfX = fTempX;
-mfY = fTempY;
+mnX = fTempX;
+mnY = fTempY;
 
 return *this;
 }
diff --git a/basegfx/source/point/b3dpoint.cxx 
b/basegfx/source/point/b3dpoint.cxx
index ff70b501ed7a..7d2d4cf4a22b 100644
--- a/basegfx/source/point/b3dpoint.cxx
+++ b/basegfx/source/point/b3dpoint.cxx
@@ -26,28 +26,28 @@ namespace basegfx
 B3DPoint& B3DPoint::operator*=( const ::basegfx::B3DHomMatrix& rMat )
 {
 double fTempX(
-rMat.get(0, 0) * mfX +
-rMat.get(0, 1) * mfY +
-rMat.get(0, 2) * mfZ +
+rMat.get(0, 0) * mnX +
+rMat.get(0, 1) * mnY +
+rMat.get(0, 2) * mnZ +
 rMat.get(0, 3));
 double fTempY(
-rMat.get(1, 0) * mfX +
-rMat.get(1, 1) * mfY +
-rMat.get(1, 2) * mfZ +
+rMat.get(1, 0) * mnX +
+rMat.get(1, 1) * mnY +
+rMat.get(1, 2) * mnZ +
 rMat.get(1, 3));
 double fTempZ(
-rMat.get(2, 0) * mfX +
-rMat.get(2, 1) * mfY +
-rMat.get(2, 2) * mfZ +
+rMat.get(2, 0) * mnX +
+rMat.get(2, 1) * mnY +
+rMat.get(2, 2) * mnZ +
 rMat.get(2, 3));
 
 if(!rMat.isLastLineDefault())
 {
 const double fOne(1.0);
 const double fTempM(
-rMat.get(3, 0) * mfX +
-rMat.get(3, 1) * mfY +
-rMat.get(3, 2) * mfZ +
+rMat.get(3, 0) * mnX +
+rMat.get(3, 1) * mnY +
+rMat.get(3, 2) * mnZ +
 rMat.get(3, 3));
 
 if(!fTools::equalZero(fTempM) && !fTools::equal(fOne, fTempM))
@@ -58,9 +58,9 @@ namespace basegfx
 }
 }
 
-mfX = fTempX;
-mfY = fTempY;
-mfZ = fTempZ;
+mnX = fTempX;
+mnY = fTempY;
+mnZ = fTempZ;
 
 return *this;
 }
diff --git a/basegfx/source/vector/b2dvector.cxx 
b/basegfx/source/vector/b2dvector.cxx
index d0fcebb62eac..85ec6ca81116 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -29,8 +29,8 @@ namespace basegfx
 
 if(fTools::equalZero(fLen))
 {
-mfX = 0.0;
-mfY = 0.0;
+mnX = 0.0;
+mnY = 0.0;
 }
 else
 {
@@ -42,8 +42,8 @@ namespace basegfx
 
 if(!fTools::equalZero(fLen))
 {
-mfX /= fLen;
-mfY /= fLen;
+mnX /= fLen;
+mnY /= fLen;
 }
 }
 }
@@ -53,22 +53,22 @@ namespace basegfx
 
 double B2DVector::getLength() const
 {
-if(fTools::equalZero(mfX))
+if(fTools::equalZero(mnX))
 {
-return fabs(mfY);
+return fabs(mnY);
 }
-else 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2023-09-13 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygontools.cxx  |   51 +---
 include/basegfx/polygon/b2dpolygontools.hxx |2 -
 2 files changed, 40 insertions(+), 13 deletions(-)

New commits:
commit 9f4ccc63346b26d8d774b22124da0842ef18e0bc
Author: Noel Grandin 
AuthorDate: Wed Sep 13 14:27:02 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Sep 13 15:42:37 2023 +0200

tdf#156995 speed up dragging complex group objects

These shaves 20% of the time of the construction of the "drag view"
object. Of course, it is still heinously slow.

Change-Id: I4c6ee2d7e0cc2030a9966a281d2fdbe7f6859289
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156896
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 04a22df578a6..56b286403671 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)
+double getLength(const B2DPolygon& rCandidate, bool 
bApproximateBezierLength)
 {
 double fRetval(0.0);
 const sal_uInt32 nPointCount(rCandidate.count());
@@ -486,18 +486,45 @@ namespace basegfx::utils
 
 if(rCandidate.areControlPointsUsed())
 {
-B2DCubicBezier aEdge;
-aEdge.setStartPoint(rCandidate.getB2DPoint(0));
+if (bApproximateBezierLength)
+{
+B2DPoint aStartPoint = rCandidate.getB2DPoint(0);
 
-for(sal_uInt32 a(0); a < nEdgeCount; a++)
+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;
+}
+
+}
+else
 {
-const sal_uInt32 nNextIndex((a + 1) % nPointCount);
-
aEdge.setControlPointA(rCandidate.getNextControlPoint(a));
-
aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex));
-aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex));
+B2DCubicBezier aEdge;
+aEdge.setStartPoint(rCandidate.getB2DPoint(0));
 
-fRetval += aEdge.getLength();
-aEdge.setStartPoint(aEdge.getEndPoint());
+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));
+
+fRetval += aEdge.getLength();
+aEdge.setStartPoint(aEdge.getEndPoint());
+}
 }
 }
 else
@@ -1236,9 +1263,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(65535.0 * 2.0);
+static const double fNumberOfAllowedSnippets(100.0 * 2.0);
 const double fAllowedLength((fNumberOfAllowedSnippets * 
fDotDashLength) / double(rDotDashArray.size()));
-const 

[Libreoffice-commits] core.git: basegfx/source include/basegfx slideshow/source

2023-08-24 Thread Regina Henschel (via logerrit)
 basegfx/source/polygon/b2dpolygontools.cxx  |  100 
 include/basegfx/polygon/b2dpolygontools.hxx |   19 +
 slideshow/source/engine/slideshowimpl.cxx   |   38 +++---
 3 files changed, 144 insertions(+), 13 deletions(-)

New commits:
commit 44c0f2da567b49ef8a539958a834f1bc841c2003
Author: Regina Henschel 
AuthorDate: Thu Aug 17 19:30:56 2023 +0200
Commit: Regina Henschel 
CommitDate: Thu Aug 24 17:54:46 2023 +0200

tdf#112687 Simplify polylines from slideshow annotations

Drawing with 'mouse as pen' in a slideshow creates hundreds of points.
By commit 631964a2ce1da3fbbeb53a5550c0e6728ba644aa they are at least
already combines to a polyline. The patch here now reduces the amount
of points in such polyline to a reasonable number. If at some point the
drawings in the slideshow are improved, this can be removed.

The reduction is performed using the Douglas-Peucker algorithm. I have
added the method to b2dpolygontools because I think it could be useful in
other contexts.

Change-Id: I9224ec3546d4442da8bc348aea8ce7b88fcc46dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155811
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 900ab735a1e0..04a22df578a6 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -18,6 +18,7 @@
  */
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -3574,6 +3575,105 @@ namespace basegfx::utils
 }
 }
 
+B2DPolygon createSimplifiedPolygon(const B2DPolygon& rCandidate, const double 
fTolerance)
+{
+const sal_uInt32 nPointCount(rCandidate.count());
+if (nPointCount < 3 || rCandidate.areControlPointsUsed())
+return rCandidate;
+
+// The solution does not use recursion directly, since this could lead to 
a stack overflow if
+// nPointCount is very large. Instead, an own stack is used. This does not 
contain points, but
+// pairs of low and high index of a range in rCandidate. A parallel 
boolean vector is used to note
+// whether a point of rCandidate belongs to the output polygon or not.
+std::vector bIsKeptVec(nPointCount, false);
+bIsKeptVec[0] = true;
+bIsKeptVec[nPointCount - 1] = true;
+sal_uInt32 nKept = 2;
+std::stack> aUnfinishedRangesStack;
+
+// The RDP algorithm draws a straight line from the first point to the 
last point of a range.
+// Then, from the inner points of the range, the point that has the 
largest distance to the line
+// is determined. If the distance is greater than the tolerance, this 
point is kept and the lower
+// and upper sub-segments of the range are treated in the same way. If the 
distance is smaller
+// than the tolerance, none of the inner points will be kept.
+sal_uInt32 nLowIndex = 0;
+sal_uInt32 nHighIndex = nPointCount - 1;
+bool bContinue = true;
+do
+{
+bContinue = false;
+if (nHighIndex - nLowIndex < 2) // maximal two points, range is 
finished.
+{
+// continue with sibling upper range if any
+if (!aUnfinishedRangesStack.empty())
+{
+std::pair aIndexPair = 
aUnfinishedRangesStack.top();
+aUnfinishedRangesStack.pop();
+nLowIndex = aIndexPair.first;
+nHighIndex = aIndexPair.second;
+bContinue = true;
+}
+}
+else // the range needs examine the max distance
+{
+// Get maximal distance of inner points of the range to the 
straight line from start to
+// end point of the range.
+// For calculation of the distance we use the Hesse normal form of 
the straight line.
+B2DPoint aLowPoint = rCandidate.getB2DPoint(nLowIndex);
+B2DPoint aHighPoint = rCandidate.getB2DPoint(nHighIndex);
+B2DVector aNormalVec
+= basegfx::getNormalizedPerpendicular(B2DVector(aHighPoint) - 
B2DVector(aLowPoint));
+double fLineOriginDistance = 
aNormalVec.scalar(B2DVector(aLowPoint));
+double fMaxDist = 0;
+sal_uInt32 nMaxPointIndex = nLowIndex;
+for (sal_uInt32 i = nLowIndex + 1; i < nHighIndex; i++)
+{
+double fDistance
+= aNormalVec.scalar(B2DVector(rCandidate.getB2DPoint(i))) 
- fLineOriginDistance;
+if (std::fabs(fDistance) > fMaxDist)
+{
+fMaxDist = std::fabs(fDistance);
+nMaxPointIndex = i;
+}
+}
+
+if (fMaxDist >= fTolerance)
+{
+// We need to divide the current range into two sub ranges.
+bIsKeptVec[nMaxPointIndex] = true;
+nKept++;
+// 

[Libreoffice-commits] core.git: basegfx/source include/basegfx oox/source

2023-05-26 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/bgradient.cxx  |  206 +++-
 basegfx/source/tools/gradienttools.cxx  |   97 ---
 include/basegfx/utils/bgradient.hxx |   29 +++-
 include/basegfx/utils/gradienttools.hxx |   11 +
 oox/source/drawingml/fillproperties.cxx |   98 ++-
 5 files changed, 306 insertions(+), 135 deletions(-)

New commits:
commit c2bea1bedd2ee8bc4007fd23c6cb839a692297a7
Author: Armin Le Grand (allotropia) 
AuthorDate: Wed May 24 12:31:48 2023 +0200
Commit: Armin Le Grand 
CommitDate: Fri May 26 10:08:52 2023 +0200

MCGR: Border restoration support

Due to tdf#155362 I added code to be able in case we
would need it to convert a BGradient using added
tooling from having offsets in the GradientSteps
and no border to adapted GradientSteps and border.

This is preferrable due to our GradientStyle_RECT
(and GradientStyle_ELLIPTICAL too) use that 'non-
linear' paint aka move-two-pixels-inside, someone
else called it 'frame-paint'. This does not bode
well with the border being applied 'linear' at the
same time (argh). Thus - while in principle all is
correct when re-importing a GradientStyle_RECT
with a border after export to pptx, it looks
slightly better ('correcter') wen doing so. That is
because when being able to and restoring a border
at least that border part *is* applied linearly.

I took the chance to further apply tooling, move
it to classes involved and instead of awt::Gradient2
use more basegfx::BGradient since it can and does
host tooling. This is also a preparation to be
able to adapt (restore) border in case of turn-
around in ODF where the importing instance is before
MCGR existance and has to handle Start/EndColor.

Needed to take more care with using BGradient instead
of awt::Gradient2 for initialization, also better
dividing/organization of tooling, already preparation
to use for other purposes.

Change-Id: I2d3a4240a5ac6fff9211b46642ee80366dc09e3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152194
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index 52aa721f36a6..b7ee0780a2cc 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -563,6 +563,100 @@ void BColorStops::reverseColorStops()
 candidate = BColorStop(1.0 - candidate.getStopOffset(), 
candidate.getStopColor());
 }
 
+// createSpaceAtStart creates fOffset space at start by
+// translating/scaling all entries to the right
+void BColorStops::createSpaceAtStart(double fOffset)
+{
+// nothing to do if empty
+if (empty())
+return;
+
+// correct offset to [0.0 .. 1.0]
+fOffset = std::max(std::min(1.0, fOffset), 0.0);
+
+// nothing to do if 0.0 == offset
+if (basegfx::fTools::equalZero(fOffset))
+return;
+
+BColorStops aNewStops;
+
+for (const auto& candidate : *this)
+{
+aNewStops.emplace_back(fOffset + (candidate.getStopOffset() * (1.0 - 
fOffset)),
+   candidate.getStopColor());
+}
+
+*this = aNewStops;
+}
+
+// removeSpaceAtStart removes fOffset space from start by
+// translating/scaling entries more or equal to fOffset
+// to the left. Entries less than fOffset will be removed
+void BColorStops::removeSpaceAtStart(double fOffset)
+{
+// nothing to do if empty
+if (empty())
+return;
+
+// correct factor to [0.0 .. 1.0]
+fOffset = std::max(std::min(1.0, fOffset), 0.0);
+
+// nothing to do if fOffset == 0.0
+if (basegfx::fTools::equalZero(fOffset))
+return;
+
+BColorStops aNewStops;
+const double fMul(basegfx::fTools::equal(fOffset, 1.0) ? 1.0 : 1.0 / (1.0 
- fOffset));
+
+for (const auto& candidate : *this)
+{
+if (basegfx::fTools::moreOrEqual(candidate.getStopOffset(), fOffset))
+{
+aNewStops.emplace_back((candidate.getStopOffset() - fOffset) * 
fMul,
+   candidate.getStopColor());
+}
+}
+
+*this = aNewStops;
+}
+
+// try to detect if an empty/no-color-change area exists
+// at the start and return offset to it. Returns 0.0 if not.
+double BColorStops::detectPossibleOffsetAtStart() const
+{
+BColor aSingleColor;
+const bool bSingleColor(isSingleColor(aSingleColor));
+
+// no useful offset for single color
+if (bSingleColor)
+return 0.0;
+
+// here we know that we have at least two colors, so we have a
+// color change. Find colors left and right of that first color change
+BColorStops::const_iterator aColorR(begin());
+BColorStops::const_iterator aColorL(aColorR++);
+
+// aColorR would 1st get equal to end(), so no need to also check aColorL
+// for end(). Loop as long as same color. Since we *have* a color change
+// not 

[Libreoffice-commits] core.git: basegfx/source include/basegfx include/oox oox/source svx/source

2023-05-19 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/bgradient.cxx  |   42 +
 basegfx/source/tools/gradienttools.cxx  |   57 +
 include/basegfx/utils/bgradient.hxx |6 +
 include/basegfx/utils/gradienttools.hxx |7 -
 include/oox/export/drawingml.hxx|9 +-
 oox/source/export/chartexport.cxx   |   47 ---
 oox/source/export/drawingml.cxx |  136 ++--
 svx/source/unodraw/XPropertyTable.cxx   |   23 -
 svx/source/xoutdev/xattr.cxx|   62 --
 9 files changed, 128 insertions(+), 261 deletions(-)

New commits:
commit 428b8a8d23e473fecf2916591615ff38611b93c9
Author: Armin Le Grand (allotropia) 
AuthorDate: Tue May 16 15:59:42 2023 +0200
Commit: Armin Le Grand 
CommitDate: Fri May 19 10:09:11 2023 +0200

MCGR: Adaptions to WriteGradientFill and BGradient

Added code to make WriteGradientFill directly use the
available BGradient implementation. The goal is to
never directly work on awt::Gradient2, but use
BGradient & it's tooling methods.

Added constructors and tooling to BGradient and
BColorStops to make that easier (single line
conversions between uno::Any, basesgfx classes
and awt:: incarnations). Directly handle uno::Any
and awt:: classes, changed stuff to make use of
this.

Change-Id: I083a323b9efee8ca4f3becb2966aac0a294b9a60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151842
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index 134fda548ece..52aa721f36a6 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -94,10 +94,12 @@ BColorStops::BColorStops(const css::awt::ColorStopSequence& 
rColorStops)
 
 BColorStops::BColorStops(const css::uno::Any& rVal)
 {
-css::awt::Gradient2 aGradient2;
-if (rVal >>= aGradient2)
+if (rVal.has())
 {
-setColorStopSequence(aGradient2.ColorStops);
+// we can use awt::ColorStopSequence
+css::awt::ColorStopSequence aColorStopSequence;
+rVal >>= aColorStopSequence;
+setColorStopSequence(aColorStopSequence);
 }
 }
 
@@ -627,7 +629,7 @@ BGradient::BGradient(const basegfx::BColorStops& 
rColorStops, css::awt::Gradient
 SetColorStops(aColorStops);
 }
 
-BGradient::BGradient(const css::awt::Gradient2& rGradient2)
+void BGradient::setGradient2(const css::awt::Gradient2& rGradient2)
 {
 // set values
 SetGradientStyle(rGradient2.Style);
@@ -640,10 +642,24 @@ BGradient::BGradient(const css::awt::Gradient2& 
rGradient2)
 SetSteps(rGradient2.StepCount);
 
 // set ColorStops
-aColorStops = BColorStops(rGradient2.ColorStops);
-aColorStops.sortAndCorrect();
+if (rGradient2.ColorStops.hasElements())
+{
+// if we have a awt::ColorStopSequence, use it
+aColorStops = BColorStops(rGradient2.ColorStops);
+aColorStops.sortAndCorrect();
+}
+else
+{
+// if not, for compatibility, use StartColor/EndColor
+aColorStops = BColorStops{
+BColorStop(0.0, 
ColorToBColorConverter(rGradient2.StartColor).getBColor()),
+BColorStop(1.0, 
ColorToBColorConverter(rGradient2.EndColor).getBColor())
+};
+}
 }
 
+BGradient::BGradient(const css::awt::Gradient2& rGradient2) { 
setGradient2(rGradient2); }
+
 BGradient::BGradient(const css::uno::Any& rVal)
 : BGradient()
 {
@@ -653,19 +669,7 @@ BGradient::BGradient(const css::uno::Any& rVal)
 css::awt::Gradient2 aGradient2;
 rVal >>= aGradient2;
 
-// set values
-SetGradientStyle(aGradient2.Style);
-SetAngle(Degree10(aGradient2.Angle));
-SetBorder(aGradient2.Border);
-SetXOffset(aGradient2.XOffset);
-SetYOffset(aGradient2.YOffset);
-SetStartIntens(aGradient2.StartIntensity);
-SetEndIntens(aGradient2.EndIntensity);
-SetSteps(aGradient2.StepCount);
-
-// set ColorStops
-aColorStops = BColorStops(aGradient2.ColorStops);
-aColorStops.sortAndCorrect();
+setGradient2(aGradient2);
 }
 else if (rVal.has())
 {
diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index c778a5237676..d7b1bb167613 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -265,47 +265,6 @@ namespace basegfx
 
 namespace utils
 {
-/// Tooling method to fill awt::Gradient2 from data contained in the 
given Any
-bool fillGradient2FromAny(css::awt::Gradient2& rGradient, const 
css::uno::Any& rVal)
-{
-bool bRetval(false);
-
-if (rVal.has< css::awt::Gradient2 >())
-{
-// we can use awt::Gradient2 directly
-bRetval = (rVal >>= rGradient);
-}
-else if (rVal.has< css::awt::Gradient >())
-{

[Libreoffice-commits] core.git: basegfx/source include/basegfx solenv/clang-format

2023-05-15 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrix.cxx   |   92 +--
 basegfx/source/matrix/b3dhommatrix.cxx   |2 
 include/basegfx/matrix/b2dhommatrix.hxx  |   27 ---
 include/basegfx/matrix/hommatrixtemplate.hxx |3 
 solenv/clang-format/excludelist  |2 
 5 files changed, 51 insertions(+), 75 deletions(-)

New commits:
commit 83650c82b56f496cd165981aa34edef9d5547697
Author: Noel Grandin 
AuthorDate: Mon May 15 15:28:34 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue May 16 07:57:51 2023 +0200

tdf#63130 make B2DHomMatrix a flat object

instead of using COW for its data.
This takes the load time from 1m29 to 1m12

Also fix a bug in
ImplHomMatrixTemplate::operator=
which never triggered before because the usage
of o3tl::cow_wrapper means it very seldom gets used.

Change-Id: Ib0a7bdddf6c014f583e06d15e8dce5025e67e4a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151793
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index 9811304d..565be5c68b1c 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -18,7 +18,7 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -26,73 +26,50 @@
 
 namespace basegfx
 {
-typedef ::basegfx::internal::ImplHomMatrixTemplate< 3 > 
Impl2DHomMatrix_Base;
-class Impl2DHomMatrix : public Impl2DHomMatrix_Base
-{
-};
-
-static o3tl::cow_wrapper DEFAULT;
-
-B2DHomMatrix::B2DHomMatrix() : mpImpl(DEFAULT) {}
-
-B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix&) = default;
-
-B2DHomMatrix::B2DHomMatrix(B2DHomMatrix&&) = default;
-
-B2DHomMatrix::~B2DHomMatrix() = default;
 
 B2DHomMatrix::B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, 
double f_1x0, double f_1x1, double f_1x2)
 {
-mpImpl->set(0, 0, f_0x0);
-mpImpl->set(0, 1, f_0x1);
-mpImpl->set(0, 2, f_0x2);
-mpImpl->set(1, 0, f_1x0);
-mpImpl->set(1, 1, f_1x1);
-mpImpl->set(1, 2, f_1x2);
-}
-
-B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix&) = default;
-
-B2DHomMatrix& B2DHomMatrix::operator=(B2DHomMatrix&&) = default;
-
-double B2DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const
-{
-return mpImpl->get(nRow, nColumn);
+maImpl.set(0, 0, f_0x0);
+maImpl.set(0, 1, f_0x1);
+maImpl.set(0, 2, f_0x2);
+maImpl.set(1, 0, f_1x0);
+maImpl.set(1, 1, f_1x1);
+maImpl.set(1, 2, f_1x2);
 }
 
 void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
 {
-mpImpl->set(nRow, nColumn, fValue);
+maImpl.set(nRow, nColumn, fValue);
 }
 
 void B2DHomMatrix::set3x2(double f_0x0, double f_0x1, double f_0x2, double 
f_1x0, double f_1x1, double f_1x2)
 {
-mpImpl->set(0, 0, f_0x0);
-mpImpl->set(0, 1, f_0x1);
-mpImpl->set(0, 2, f_0x2);
-mpImpl->set(1, 0, f_1x0);
-mpImpl->set(1, 1, f_1x1);
-mpImpl->set(1, 2, f_1x2);
+maImpl.set(0, 0, f_0x0);
+maImpl.set(0, 1, f_0x1);
+maImpl.set(0, 2, f_0x2);
+maImpl.set(1, 0, f_1x0);
+maImpl.set(1, 1, f_1x1);
+maImpl.set(1, 2, f_1x2);
 }
 
 bool B2DHomMatrix::isLastLineDefault() const
 {
-return mpImpl->isLastLineDefault();
+return maImpl.isLastLineDefault();
 }
 
 bool B2DHomMatrix::isIdentity() const
 {
-return mpImpl.same_object(DEFAULT) || mpImpl->isIdentity();
+return maImpl.isIdentity();
 }
 
 void B2DHomMatrix::identity()
 {
-*mpImpl = Impl2DHomMatrix();
+maImpl = Impl2DHomMatrix();
 }
 
 bool B2DHomMatrix::isInvertible() const
 {
-return mpImpl->isInvertible();
+return maImpl.isInvertible();
 }
 
 bool B2DHomMatrix::invert()
@@ -102,13 +79,13 @@ namespace basegfx
 return true;
 }
 
-Impl2DHomMatrix aWork(*mpImpl);
-sal_uInt16* pIndex = static_cast(alloca( 
sizeof(sal_uInt16) * Impl2DHomMatrix_Base::getEdgeLength() ));
+Impl2DHomMatrix aWork(maImpl);
+sal_uInt16* pIndex = static_cast(alloca( 
sizeof(sal_uInt16) * Impl2DHomMatrix::getEdgeLength() ));
 sal_Int16 nParity;
 
 if(aWork.ludcmp(pIndex, nParity))
 {
-mpImpl->doInvert(aWork, pIndex);
+maImpl.doInvert(aWork, pIndex);
 return true;
 }
 
@@ -117,13 +94,13 @@ namespace basegfx
 
 B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)
 {
-mpImpl->doAddMatrix(*rMat.mpImpl);
+maImpl.doAddMatrix(rMat.maImpl);
 return *this;
 }
 
 B2DHomMatrix& B2DHomMatrix::operator-=(const B2DHomMatrix& rMat)
 {
-mpImpl->doSubMatrix(*rMat.mpImpl);
+

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2023-04-14 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |4 ++--
 include/basegfx/utils/gradienttools.hxx |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit ac9cdc995bc0f8f43ec2c4ad2e509b440f5b1b68
Author: Andrea Gelmini 
AuthorDate: Fri Apr 14 12:10:36 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Apr 14 14:24:39 2023 +0200

Fix typos

Change-Id: I2b087d0f97c675cfedd4e2e78c7f827df4605fb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150407
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 46d8fc7ca216..1d701e4b8248 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -273,9 +273,9 @@ namespace basegfx
  this is the case) and return with empty ColorStops
- It will blend ColorStops to Intensity if StartIntensity/
  EndIntensity != 100 is set in awt::Gradient2, so applying
- that value(s) to the gadient directly
+ that value(s) to the gradient directly
- It will adapt to Border if Border != 0 is set at the
- given awt::Gradient2, so applying that value to the gadient
+ given awt::Gradient2, so applying that value to the gradient
  directly
 */
 void prepareColorStops(
diff --git a/include/basegfx/utils/gradienttools.hxx 
b/include/basegfx/utils/gradienttools.hxx
index 4e78ad2ff960..419a31b86a1b 100644
--- a/include/basegfx/utils/gradienttools.hxx
+++ b/include/basegfx/utils/gradienttools.hxx
@@ -223,9 +223,9 @@ namespace basegfx
  this is the case) and return with empty ColorStops
- It will blend ColorStops to Intensity if StartIntensity/
  EndIntensity != 100 is set in awt::Gradient2, so applying
- that value(s) to the gadient directly
+ that value(s) to the gradient directly
- It will adapt to Border if Border != 0 is set at the
- given awt::Gradient2, so applying that value to the gadient
+ given awt::Gradient2, so applying that value to the gradient
  directly
 */
 BASEGFX_DLLPUBLIC void prepareColorStops(


[Libreoffice-commits] core.git: basegfx/source include/basegfx include/oox oox/source

2023-04-14 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |  260 ++-
 include/basegfx/utils/gradienttools.hxx |   49 
 include/oox/export/drawingml.hxx|   27 +-
 oox/source/drawingml/fillproperties.cxx |   31 ++
 oox/source/export/chartexport.cxx   |   75 --
 oox/source/export/drawingml.cxx |  361 +---
 6 files changed, 684 insertions(+), 119 deletions(-)

New commits:
commit 70684ab604c5fb32a16614c708f986671dd2da3c
Author: Armin Le Grand (allotropia) 
AuthorDate: Thu Apr 13 12:13:19 2023 +0200
Commit: Armin Le Grand 
CommitDate: Fri Apr 14 11:56:46 2023 +0200

MCGR: Adaptions to oox export

This is a 1st version and might need more fine-tuning,
so it is still 'hidden' behind the MCGR_TEST env var
being set (as the import is, too).
Still, when used, it can now import a MCGR with
transparence and export it again. I will now do extended
testing/experimenting, fine-tuning where needed and
prepare final change/drive forward.
The current state in master should not be changed as
long as the mentioned env var is not set, but this
will need to be checked, too, due to changes to the
export api in oox.
Corrected an error in GetAlphaFromTransparenceGradient
method(s), css::rendering::RGBColor is [0.0 .. 1.0]
Corercted an error in WriteSolidFill where transparence
gradient gets checked. This should really check if
TrGr is used, but only checks for 'empty/unused'
color instead (assuming COL_BLACK is 'unused').
All usages of GetAlphaFromTransparenceGradient should
be checked and adapted.
Change-Id: If59d7a06b9207e2efe9e71f3f8ddeca4476408f3

Change-Id: If97f8abdd0e1597aa1fd865b7e884e06a22b71f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150391
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index ca315f33f973..46d8fc7ca216 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -264,6 +264,237 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to extract data from given awt::Gradient2
+   to ColorStops, doing some corrections, partitally based
+   on given SingleColor.
+   This will do quite some preparations for the gradient
+   as follows:
+   - It will check for single color (resetting rSingleColor when
+ this is the case) and return with empty ColorStops
+   - It will blend ColorStops to Intensity if StartIntensity/
+ EndIntensity != 100 is set in awt::Gradient2, so applying
+ that value(s) to the gadient directly
+   - It will adapt to Border if Border != 0 is set at the
+ given awt::Gradient2, so applying that value to the gadient
+ directly
+*/
+void prepareColorStops(
+const com::sun::star::awt::Gradient2& rGradient,
+ColorStops& rColorStops,
+BColor& rSingleColor)
+{
+fillColorStopsFromGradient2(rColorStops, rGradient);
+
+if (isSingleColor(rColorStops, rSingleColor))
+{
+// when single color, preserve value in rSingleColor
+// and clear the ColorStops, done.
+rColorStops.clear();
+return;
+}
+
+if (rGradient.StartIntensity != 100 || rGradient.EndIntensity != 
100)
+{
+// apply 'old' blend stuff, blend against black
+blendColorStopsToIntensity(
+rColorStops,
+rGradient.StartIntensity * 0.01,
+rGradient.EndIntensity * 0.01,
+basegfx::BColor()); // COL_BLACK
+
+// can lead to single color (e.g. both zero, so all black),
+// so check again
+if (isSingleColor(rColorStops, rSingleColor))
+{
+rColorStops.clear();
+return;
+}
+}
+
+if (rGradient.Border != 0)
+{
+// apply Border if set
+// NOTE: no new start node is added. If this is needed,
+//   do that in the caller
+const double fFactor(rGradient.Border * 0.01);
+ColorStops aNewStops;
+
+for (const auto& candidate : rColorStops)
+{
+aNewStops.emplace_back(candidate.getStopOffset() * 
fFactor, candidate.getStopColor());
+}
+
+rColorStops = aNewStops;
+}
+}
+
+/* Tooling method to synchronize the given ColorStops.
+   The intention is that a color GradientStops and an
+   alpha/transparence GradientStops gets synchronized
+   for export.
+ 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2023-04-03 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |2 +-
 include/basegfx/utils/gradienttools.hxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit c2cc3e696e27f3ab218c56e90065f5c102ae50b6
Author: Andrea Gelmini 
AuthorDate: Mon Apr 3 20:12:21 2023 +0200
Commit: Julien Nabet 
CommitDate: Mon Apr 3 20:32:21 2023 +0200

Fix typo

Change-Id: I49fe9dbdc11291c02be1dd5e41171a987d896008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149997
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index d1b5874e5b77..dc6e4dc3f66a 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -270,7 +270,7 @@ namespace basegfx
The intensity values fStartIntensity, fEndIntensity are
in the range of [0.0 .. 1.0] and describe how much the
blend is supposed to be done at the start color position
-   and the end color position resprectively, where 0.0 means
+   and the end color position respectively, where 0.0 means
to fully use the given BlendColor, 1.0 means to not change
the existing color in the ColorStop.
Every color entry in the given ColorStop is blended
diff --git a/include/basegfx/utils/gradienttools.hxx 
b/include/basegfx/utils/gradienttools.hxx
index dfa1f35b38c4..ea1802c291f8 100644
--- a/include/basegfx/utils/gradienttools.hxx
+++ b/include/basegfx/utils/gradienttools.hxx
@@ -202,7 +202,7 @@ namespace basegfx
The intensity values fStartIntensity, fEndIntensity are
in the range of [0.0 .. 1.0] and describe how much the
blend is supposed to be done at the start color position
-   and the end color position resprectively, where 0.0 means
+   and the end color position respectively, where 0.0 means
to fully use the given BlendColor, 1.0 means to not change
the existing color in the ColorStop.
Every color entry in the given ColorStop is blended


[Libreoffice-commits] core.git: basegfx/source include/basegfx svx/source

2023-04-03 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx |   38 +
 include/basegfx/utils/gradienttools.hxx|   15 +++
 svx/source/sdr/primitive2d/sdrattributecreator.cxx |   45 +
 3 files changed, 81 insertions(+), 17 deletions(-)

New commits:
commit 64007cb308ead90ba6ffa2963c5de8ef89cec5ce
Author: Armin Le Grand (allotropia) 
AuthorDate: Mon Apr 3 12:09:16 2023 +0200
Commit: Armin Le Grand 
CommitDate: Mon Apr 3 17:16:48 2023 +0200

MCGR: Unify Gradient intensity handling in tooling

Moved the Gradient intensity handling to tooling since
it is also needed for TransparencyGradients. Added
missing use of GradientStepCount for transparency.

Change-Id: I63ae6683fa0131be7faadc8572e19f5c43bf27e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149957
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 49cf831da262..d1b5874e5b77 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -264,6 +264,44 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to linearly blend the Colors contained in
+   a given ColorStop vector against a given Color using the
+   given intensity values.
+   The intensity values fStartIntensity, fEndIntensity are
+   in the range of [0.0 .. 1.0] and describe how much the
+   blend is supposed to be done at the start color position
+   and the end color position resprectively, where 0.0 means
+   to fully use the given BlendColor, 1.0 means to not change
+   the existing color in the ColorStop.
+   Every color entry in the given ColorStop is blended
+   relative to it's StopPosition, interpolating the
+   given intensities with the range [0.0 .. 1.0] to do so.
+*/
+void blendColorStopsToIntensity(ColorStops& rColorStops, double 
fStartIntensity, double fEndIntensity, const basegfx::BColor& rBlendColor)
+{
+// no entries, done
+if (rColorStops.empty())
+return;
+
+// correct intensities (maybe assert when input was wrong)
+fStartIntensity = std::max(std::min(1.0, fStartIntensity), 0.0);
+fEndIntensity = std::max(std::min(1.0, fEndIntensity), 0.0);
+
+// all 100%, no real blend, done
+if (basegfx::fTools::equal(fStartIntensity, 1.0) && 
basegfx::fTools::equal(fEndIntensity, 1.0))
+return;
+
+// blend relative to StopOffset position
+for (auto& candidate : rColorStops)
+{
+const double fOffset(candidate.getStopOffset());
+const double fIntensity((fStartIntensity * (1.0 - fOffset)) + 
(fEndIntensity * fOffset));
+candidate = basegfx::ColorStop(
+fOffset,
+basegfx::interpolate(rBlendColor, 
candidate.getStopColor(), fIntensity));
+}
+}
+
 /* Tooling method to check if a ColorStop vector is defined
by a single color. It returns true if this is the case.
If true is returned, rSingleColor contains that single
diff --git a/include/basegfx/utils/gradienttools.hxx 
b/include/basegfx/utils/gradienttools.hxx
index c7123bc81db3..dfa1f35b38c4 100644
--- a/include/basegfx/utils/gradienttools.hxx
+++ b/include/basegfx/utils/gradienttools.hxx
@@ -196,6 +196,21 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to linearly blend the Colors contained in
+   a given ColorStop vector against a given Color using the
+   given intensity values.
+   The intensity values fStartIntensity, fEndIntensity are
+   in the range of [0.0 .. 1.0] and describe how much the
+   blend is supposed to be done at the start color position
+   and the end color position resprectively, where 0.0 means
+   to fully use the given BlendColor, 1.0 means to not change
+   the existing color in the ColorStop.
+   Every color entry in the given ColorStop is blended
+   relative to it's StopPosition, interpolating the
+   given intensities with the range [0.0 .. 1.0] to do so.
+*/
+BASEGFX_DLLPUBLIC void blendColorStopsToIntensity(ColorStops& 
rColorStops, double fStartIntensity, double fEndIntensity, const 
basegfx::BColor& rBlendColor);
+
 /* Tooling method to check if a ColorStop vector is defined
by a single color. It returns true if this is the case.
If true is returned, rSingleColor contains that single
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx 
b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 813c9884bc9b..89493e4d5a45 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx

[Libreoffice-commits] core.git: basegfx/source include/basegfx include/oox oox/source svx/source

2023-04-02 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx |   32 ++
 include/basegfx/utils/gradienttools.hxx|9 +
 include/oox/helper/modelobjecthelper.hxx   |3 
 oox/source/drawingml/fillproperties.cxx|  110 -
 oox/source/drawingml/shapepropertymap.cxx  |   16 ++-
 oox/source/helper/modelobjecthelper.cxx|   12 ++
 svx/source/sdr/primitive2d/sdrattributecreator.cxx |   21 +---
 7 files changed, 184 insertions(+), 19 deletions(-)

New commits:
commit ce86e5b4a8d54eb55fdde7756ad6fde6e6967d55
Author: Armin Le Grand (allotropia) 
AuthorDate: Wed Mar 29 11:04:27 2023 +0200
Commit: Armin Le Grand 
CommitDate: Sun Apr 2 13:19:27 2023 +0200

MCGR: 1st additions to OOXML MCGR import

This change provides 1st changes to get Gradients with
muti color stops imported from MSO in the oox import
filter. It supports currently multiple ColorStops and
transparency. Also 'border'(s) should work, but
-remember- this is work in progress.

Since it is work in progress it is currently and
temporaily secured by ENV VAR "MCGR_TEST=0", so when
not using this the master version will not be touched
at all.

The number defines various ColorStop tests, 0 for none,
but some changes are active, e.g. MSO import. You may
try 1 or 16 to see all your Gradients hard replaced by
something using that feature.
I will take care fo cleaning this up again when the
feature progresses/gets complete.

Change-Id: I92e10d8cd5150733741a6def20a542abf97bd903
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149682
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index a98eeddf641c..49cf831da262 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -264,6 +264,38 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to check if a ColorStop vector is defined
+   by a single color. It returns true if this is the case.
+   If true is returned, rSingleColor contains that single
+   color for convenience.
+   NOTE: If no ColorStop is defined, a fallback to BColor-default
+ (which is black) and true will be returned
+*/
+bool isSingleColor(const ColorStops& rColorStops, BColor& rSingleColor)
+{
+if (rColorStops.empty())
+{
+rSingleColor = BColor();
+return true;
+}
+
+if (1 == rColorStops.size())
+{
+rSingleColor = rColorStops.front().getStopColor();
+return true;
+}
+
+rSingleColor = rColorStops.front().getStopColor();
+
+for (auto const& rCandidate : rColorStops)
+{
+if (rCandidate.getStopColor() != rSingleColor)
+return false;
+}
+
+return true;
+}
+
 /* Tooling method to reverse ColorStops, including offsets.
When also mirroring offsets a valid sort keeps valid.
 */
diff --git a/include/basegfx/utils/gradienttools.hxx 
b/include/basegfx/utils/gradienttools.hxx
index 33f87717528b..c7123bc81db3 100644
--- a/include/basegfx/utils/gradienttools.hxx
+++ b/include/basegfx/utils/gradienttools.hxx
@@ -196,6 +196,15 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to check if a ColorStop vector is defined
+   by a single color. It returns true if this is the case.
+   If true is returned, rSingleColor contains that single
+   color for convenience.
+   NOTE: If no ColorStop is defined, a fallback to BColor-default
+ (which is black) and true will be returned
+*/
+BASEGFX_DLLPUBLIC bool isSingleColor(const ColorStops& rColorStops, 
BColor& rSingleColor);
+
 /* Tooling method to reverse ColorStops, including offsets.
When also mirroring offsets a valid sort keeps valid.
 */
diff --git a/include/oox/helper/modelobjecthelper.hxx 
b/include/oox/helper/modelobjecthelper.hxx
index 9aba2538fdc4..6d4b1fea1925 100644
--- a/include/oox/helper/modelobjecthelper.hxx
+++ b/include/oox/helper/modelobjecthelper.hxx
@@ -28,6 +28,7 @@
 
 namespace com::sun::star {
 namespace awt { struct Gradient;
+struct Gradient2;
 class XBitmap; }
 namespace graphic { class XGraphic; }
 namespace container { class XNameContainer; }
@@ -102,8 +103,10 @@ public:
 
 /** Inserts a new named fill gradient, returns the gradient name, based on
 an internal constant name with a new unused index appended. */
+OUString insertFillGradient( const css::awt::Gradient2& rGradient );
 OUString insertFillGradient( const css::awt::Gradient& 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-12-22 Thread Stephan Bergmann (via logerrit)
 basegfx/source/tools/canvastools.cxx |3 ++-
 basegfx/source/tools/unopolypolygon.cxx  |   12 +++-
 include/basegfx/utils/unopolypolygon.hxx |8 +++-
 3 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit d6a70bb641b96e8e5616448c2378131ed62658b4
Author: Stephan Bergmann 
AuthorDate: Thu Dec 1 08:48:48 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Dec 22 12:21:37 2022 +

loplugin:unocast (basegfx::unotools::UnoPolyPolygon)

(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)

Change-Id: I166d8f31a13a98caf0bb7a3b5025a9d942808096
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144746
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basegfx/source/tools/canvastools.cxx 
b/basegfx/source/tools/canvastools.cxx
index d388356199a2..1f65e89b182b 100644
--- a/basegfx/source/tools/canvastools.cxx
+++ b/basegfx/source/tools/canvastools.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -251,7 +252,7 @@ namespace basegfx::unotools
 ::basegfx::B2DPolyPolygon b2DPolyPolygonFromXPolyPolygon2D( const 
uno::Reference< rendering::XPolyPolygon2D >& xPoly )
 {
 ::basegfx::unotools::UnoPolyPolygon* pPolyImpl =
-dynamic_cast< ::basegfx::unotools::UnoPolyPolygon* >( 
xPoly.get() );
+comphelper::getFromUnoTunnel< 
::basegfx::unotools::UnoPolyPolygon >( xPoly );
 
 if( pPolyImpl )
 {
diff --git a/basegfx/source/tools/unopolypolygon.cxx 
b/basegfx/source/tools/unopolypolygon.cxx
index 0c3b59abac9b..099cbee5eb75 100644
--- a/basegfx/source/tools/unopolypolygon.cxx
+++ b/basegfx/source/tools/unopolypolygon.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -60,7 +61,7 @@ namespace basegfx::unotools
 }
 
 B2DPolyPolygonaSrcPoly;
-const UnoPolyPolygon* pSrc( dynamic_cast< UnoPolyPolygon* 
>(polyPolygon.get()) );
+const UnoPolyPolygon* pSrc( comphelper::getFromUnoTunnel< 
UnoPolyPolygon >(polyPolygon) );
 
 // try to extract polygon data from interface. First,
 // check whether it's the same implementation object,
@@ -434,6 +435,15 @@ namespace basegfx::unotools
 return { "com.sun.star.rendering.PolyPolygon2D" };
 }
 
+sal_Int64 UnoPolyPolygon::getSomething(css::uno::Sequence const 
& aIdentifier) {
+return comphelper::getSomethingImpl(aIdentifier, this);
+}
+
+css::uno::Sequence const & UnoPolyPolygon::getUnoTunnelId() {
+static comphelper::UnoIdInit const id;
+return id.getSeq();
+}
+
 B2DPolyPolygon UnoPolyPolygon::getPolyPolygon() const
 {
 std::unique_lock const guard( m_aMutex );
diff --git a/include/basegfx/utils/unopolypolygon.hxx 
b/include/basegfx/utils/unopolypolygon.hxx
index 48788b074ede..4392f798c6ce 100644
--- a/include/basegfx/utils/unopolypolygon.hxx
+++ b/include/basegfx/utils/unopolypolygon.hxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,7 +35,8 @@ namespace basegfx::unotools
 typedef comphelper::WeakComponentImplHelper<
 css::rendering::XLinePolyPolygon2D,
 css::rendering::XBezierPolyPolygon2D,
-css::lang::XServiceInfo > UnoPolyPolygonBase;
+css::lang::XServiceInfo,
+css::lang::XUnoTunnel > UnoPolyPolygonBase;
 
 class BASEGFX_DLLPUBLIC UnoPolyPolygon
 : public UnoPolyPolygonBase
@@ -68,6 +70,10 @@ namespace basegfx::unotools
 SAL_DLLPRIVATE virtual sal_Bool SAL_CALL supportsService( const 
OUString& ServiceName ) override;
 SAL_DLLPRIVATE virtual css::uno::Sequence< OUString > SAL_CALL 
getSupportedServiceNames() override;
 
+SAL_DLLPRIVATE sal_Int64 SAL_CALL getSomething(
+css::uno::Sequence const & aIdentifier) override;
+static SAL_DLLPRIVATE css::uno::Sequence const & 
getUnoTunnelId();
+
 SAL_DLLPRIVATE B2DPolyPolygon getPolyPolygon() const;
 
 protected:


[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-09-17 Thread Mike Kaganski (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx |  270 --
 basegfx/source/polygon/b2dpolypolygon.cxx |  121 +
 include/basegfx/polygon/b2dpolygon.hxx|3 
 3 files changed, 163 insertions(+), 231 deletions(-)

New commits:
commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4
Author: Mike Kaganski 
AuthorDate: Sat Sep 17 21:02:44 2022 +0300
Commit: Mike Kaganski 
CommitDate: Sat Sep 17 21:50:38 2022 +0200

Simplify b2d(poly)polygon implementation

Most size checks should be only done in the outer object; implementations
inside cow_wrapper only assert correctness. All const_cast and as_const
are replaced with correct const method calls (and, where needed, mutable
members).

Change-Id: I69e9f72086d07257ebd5cefaff7f214e198b901e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140106
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index 8a413eaa..03957c8710a3 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -17,7 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -59,11 +60,13 @@ public:
 
 const basegfx::B2DPoint& getCoordinate(sal_uInt32 nIndex) const
 {
+assert(nIndex < maVector.size());
 return maVector[nIndex];
 }
 
 void setCoordinate(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue)
 {
+assert(nIndex < maVector.size());
 maVector[nIndex] = rValue;
 }
 
@@ -79,46 +82,34 @@ public:
 
 void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 
nCount)
 {
-if(nCount)
-{
-// add nCount copies of rValue
-auto aIndex = maVector.begin();
-aIndex += nIndex;
-maVector.insert(aIndex, nCount, rValue);
-}
+assert(nIndex <= maVector.size());
+// add nCount copies of rValue
+maVector.insert(maVector.begin() + nIndex, nCount, rValue);
 }
 
 void insert(sal_uInt32 nIndex, const CoordinateDataArray2D& rSource)
 {
-const sal_uInt32 nCount(rSource.maVector.size());
-
-if(nCount)
-{
-// insert data
-auto aIndex = maVector.begin();
-aIndex += nIndex;
-auto aStart = rSource.maVector.cbegin();
-auto aEnd = rSource.maVector.cend();
-maVector.insert(aIndex, aStart, aEnd);
-}
+assert(nIndex <= maVector.size());
+// insert data
+auto aIndex = maVector.begin();
+aIndex += nIndex;
+auto aStart = rSource.maVector.cbegin();
+auto aEnd = rSource.maVector.cend();
+maVector.insert(aIndex, aStart, aEnd);
 }
 
 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
 {
-if(nCount)
-{
-// remove point data
-auto aStart = maVector.begin();
-aStart += nIndex;
-const auto aEnd = aStart + nCount;
-maVector.erase(aStart, aEnd);
-}
+assert(nIndex + nCount <= maVector.size());
+// remove point data
+const auto aStart = maVector.begin() + nIndex;
+const auto aEnd = aStart + nCount;
+maVector.erase(aStart, aEnd);
 }
 
 void flip(bool bIsClosed)
 {
-if(maVector.size() <= 1)
-return;
+assert(maVector.size() > 1);
 
 // to keep the same point at index 0, just flip all points except the
 // first one when closed
@@ -231,10 +222,9 @@ public:
 ControlVectorArray2D(const ControlVectorArray2D& rOriginal, sal_uInt32 
nIndex, sal_uInt32 nCount)
 :   mnUsedVectors(0)
 {
-ControlVectorPair2DVector::const_iterator 
aStart(rOriginal.maVector.begin());
-aStart += nIndex;
-ControlVectorPair2DVector::const_iterator aEnd(aStart);
-aEnd += nCount;
+assert(nIndex + nCount <= rOriginal.maVector.size());
+auto aStart(rOriginal.maVector.begin() + nIndex);
+auto aEnd(aStart + nCount);
 maVector.reserve(nCount);
 
 for(; aStart != aEnd; ++aStart)
@@ -261,6 +251,7 @@ public:
 
 const basegfx::B2DVector& getPrevVector(sal_uInt32 nIndex) const
 {
+assert(nIndex < maVector.size());
 return maVector[nIndex].getPrevVector();
 }
 
@@ -293,6 +284,7 @@ public:
 
 const basegfx::B2DVector& getNextVector(sal_uInt32 nIndex) const
 {
+assert(nIndex < maVector.size());
 return maVector[nIndex].getNextVector();
 }
 
@@ -336,13 +328,10 @@ public:
 
 void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, 
sal_uInt32 nCount)
 {
-if(!nCount)
-return;
+assert(nIndex <= maVector.size());
 
 // add nCount copies of rValue
-

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-09-10 Thread Tomaž Vajngerl (via logerrit)
 basegfx/source/point/b2dpoint.cxx|7 -
 basegfx/source/vector/b2dvector.cxx  |7 -
 include/basegfx/point/b2dpoint.hxx   |9 +-
 include/basegfx/tuple/Tuple2D.hxx|   48 +--
 include/basegfx/tuple/b2dtuple.hxx   |   32 ++-
 include/basegfx/vector/b2dvector.hxx |   11 +---
 6 files changed, 59 insertions(+), 55 deletions(-)

New commits:
commit c2d3f4be406b3bef8e89b17b781cb7e827a0fe3d
Author: Tomaž Vajngerl 
AuthorDate: Tue Sep 6 19:37:20 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat Sep 10 08:45:51 2022 +0200

basegfx: simplify Tuple2D, B2DPoint, B2DVector, B2DTuple

Change-Id: I97e41fc62288ec4ee5805747fd3a3a6e019cfb57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139681
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/basegfx/source/point/b2dpoint.cxx 
b/basegfx/source/point/b2dpoint.cxx
index 0dc18b513db1..02e6711ac44c 100644
--- a/basegfx/source/point/b2dpoint.cxx
+++ b/basegfx/source/point/b2dpoint.cxx
@@ -23,13 +23,6 @@
 
 namespace basegfx
 {
-B2DPoint& B2DPoint::operator=( const ::basegfx::B2DTuple& rPoint )
-{
-mfX = rPoint.getX();
-mfY = rPoint.getY();
-return *this;
-}
-
 B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat )
 {
 double fTempX(
diff --git a/basegfx/source/vector/b2dvector.cxx 
b/basegfx/source/vector/b2dvector.cxx
index 1ad51a9b5a4c..d0fcebb62eac 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -51,13 +51,6 @@ namespace basegfx
 return *this;
 }
 
-B2DVector& B2DVector::operator=( const B2DTuple& rVec )
-{
-mfX = rVec.getX();
-mfY = rVec.getY();
-return *this;
-}
-
 double B2DVector::getLength() const
 {
 if(fTools::equalZero(mfX))
diff --git a/include/basegfx/point/b2dpoint.hxx 
b/include/basegfx/point/b2dpoint.hxx
index d2f77aa493a3..3bd6af90af9c 100644
--- a/include/basegfx/point/b2dpoint.hxx
+++ b/include/basegfx/point/b2dpoint.hxx
@@ -73,7 +73,7 @@ namespace basegfx
 /** constructor with tuple to allow copy-constructing
 from B2DTuple-based classes
 */
-B2DPoint(const ::basegfx::B2DTuple& rTuple)
+B2DPoint(Tuple2D const& rTuple)
 :   B2DTuple(rTuple)
 {}
 
@@ -98,7 +98,12 @@ namespace basegfx
 /** assignment operator to allow assigning the results
 of B2DTuple calculations
 */
-BASEGFX_DLLPUBLIC B2DPoint& operator=( const ::basegfx::B2DTuple& 
rPoint );
+BASEGFX_DLLPUBLIC B2DPoint& operator=(Tuple2D& rPoint)
+{
+mfX = rPoint.getX();
+mfY = rPoint.getY();
+return *this;
+}
 
 /** Transform point by given transformation matrix.
 
diff --git a/include/basegfx/tuple/Tuple2D.hxx 
b/include/basegfx/tuple/Tuple2D.hxx
index 44d546df6a30..8bc53fe9b88d 100644
--- a/include/basegfx/tuple/Tuple2D.hxx
+++ b/include/basegfx/tuple/Tuple2D.hxx
@@ -105,53 +105,85 @@ public:
 
 // operator overrides
 
-Tuple2D& operator+=(const Tuple2D& rTup)
+Tuple2D& operator+=(const Tuple2D& rTup)
 {
 mfX += rTup.mfX;
 mfY += rTup.mfY;
 return *this;
 }
 
-Tuple2D& operator-=(const Tuple2D& rTup)
+Tuple2D& operator-=(const Tuple2D& rTup)
 {
 mfX -= rTup.mfX;
 mfY -= rTup.mfY;
 return *this;
 }
 
-Tuple2D& operator/=(const Tuple2D& rTup)
+Tuple2D& operator/=(const Tuple2D& rTup)
 {
 mfX /= rTup.mfX;
 mfY /= rTup.mfY;
 return *this;
 }
 
-Tuple2D& operator*=(const Tuple2D& rTup)
+Tuple2D& operator*=(const Tuple2D& rTup)
 {
 mfX *= rTup.mfX;
 mfY *= rTup.mfY;
 return *this;
 }
 
-Tuple2D& operator*=(TYPE t)
+Tuple2D& operator*=(TYPE t)
 {
 mfX *= t;
 mfY *= t;
 return *this;
 }
 
-Tuple2D& operator/=(TYPE t)
+Tuple2D& operator/=(TYPE t)
 {
 mfX /= t;
 mfY /= t;
 return *this;
 }
 
-bool operator==(const Tuple2D& rTup) const { return mfX == rTup.mfX && mfY 
== rTup.mfY; }
+bool operator==(const Tuple2D& rTup) const { return mfX == rTup.mfX 
&& mfY == rTup.mfY; }
 
-bool operator!=(const Tuple2D& rTup) const { return !(*this == rTup); }
+bool operator!=(const Tuple2D& rTup) const { return !(*this == 
rTup); }
 };
 
+template 
+inline Tuple2D operator-(const Tuple2D& rTupA, const 
Tuple2D& rTupB)
+{
+Tuple2D aNew(rTupA);
+aNew -= rTupB;
+return aNew;
+}
+
+template 
+inline Tuple2D operator+(const Tuple2D& rTupA, const 
Tuple2D& rTupB)
+{
+Tuple2D aNew(rTupA);
+aNew += rTupB;
+return aNew;
+}
+
+template 
+inline Tuple2D operator*(const Tuple2D& rTupA, const 
Tuple2D& rTupB)
+{
+Tuple2D aNew(rTupA);
+aNew *= rTupB;
+return aNew;
+}
+
+template 

[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/source

2022-07-17 Thread Caolán McNamara (via logerrit)
 basegfx/source/curve/b2dcubicbezier.cxx |4 ++--
 basegfx/source/polygon/b2dpolygontools.cxx  |4 ++--
 basegfx/source/polygon/b2dpolypolygontools.cxx  |4 ++--
 include/basegfx/curve/b2dcubicbezier.hxx|5 -
 include/basegfx/polygon/b2dpolygontools.hxx |2 +-
 include/basegfx/polygon/b2dpolypolygontools.hxx |2 +-
 vcl/source/outdev/line.cxx  |4 +++-
 7 files changed, 15 insertions(+), 10 deletions(-)

New commits:
commit 8ab54ac42ca2516c333a49fb23f6d27196122c22
Author: Caolán McNamara 
AuthorDate: Sun Jul 17 15:26:16 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Jul 17 17:23:44 2022 +0200

ofz#48585 Out-of-memory

Change-Id: If6bb603cc78863df88d5630b4bd5b1198b4050de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137148
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/basegfx/source/curve/b2dcubicbezier.cxx 
b/basegfx/source/curve/b2dcubicbezier.cxx
index 6528e1492a32..d33cd82b194d 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -610,12 +610,12 @@ namespace basegfx
 }
 
 // adaptive subdivide by distance
-void B2DCubicBezier::adaptiveSubdivideByDistance(B2DPolygon& rTarget, 
double fDistanceBound) const
+void B2DCubicBezier::adaptiveSubdivideByDistance(B2DPolygon& rTarget, 
double fDistanceBound, int nRecurseLimit) const
 {
 if(isBezier())
 {
 ImpSubDivDistance(maStartPoint, maControlPointA, maControlPointB, 
maEndPoint, rTarget,
-fDistanceBound * fDistanceBound, 
std::numeric_limits::max(), 30);
+fDistanceBound * fDistanceBound, 
std::numeric_limits::max(), nRecurseLimit);
 }
 else
 {
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 4b8550546e5c..03f5299ca505 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -157,7 +157,7 @@ namespace basegfx::utils
 return rCandidate.getContinuityInPoint(nIndex);
 }
 
-B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, 
double fDistanceBound)
+B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, 
double fDistanceBound, int nRecurseLimit)
 {
 if(rCandidate.areControlPointsUsed())
 {
@@ -213,7 +213,7 @@ namespace basegfx::utils
 }
 
 // call adaptive subdivide which adds edges to 
aRetval accordingly
-aBezier.adaptiveSubdivideByDistance(aRetval, 
fBound);
+aBezier.adaptiveSubdivideByDistance(aRetval, 
fBound, nRecurseLimit);
 }
 else
 {
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx 
b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 3f8f51c52404..faf734f6e79e 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -113,7 +113,7 @@ namespace basegfx::utils
 return rCandidate;
 }
 
-B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& 
rCandidate, double fDistanceBound)
+B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& 
rCandidate, double fDistanceBound, int nRecurseLimit)
 {
 if(rCandidate.areControlPointsUsed())
 {
@@ -123,7 +123,7 @@ namespace basegfx::utils
 {
 if(rPolygon.areControlPointsUsed())
 {
-
aRetval.append(utils::adaptiveSubdivideByDistance(rPolygon, fDistanceBound));
+
aRetval.append(utils::adaptiveSubdivideByDistance(rPolygon, fDistanceBound, 
nRecurseLimit));
 }
 else
 {
diff --git a/include/basegfx/curve/b2dcubicbezier.hxx 
b/include/basegfx/curve/b2dcubicbezier.hxx
index 4d8d9406e930..fe81ed523d97 100644
--- a/include/basegfx/curve/b2dcubicbezier.hxx
+++ b/include/basegfx/curve/b2dcubicbezier.hxx
@@ -143,8 +143,11 @@ namespace basegfx
 @param fDistanceBound
 Bound on the maximal distance of the approximation to the
 true curve.
+
+@param nRecurseLimit
+Bound on recursion for the bezier case.
 */
-void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double 
fDistanceBound) const;
+void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double 
fDistanceBound, int nRecurseLimit = 30) const;
 
 // get point at given relative position
 B2DPoint interpolatePoint(double t) const;
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx 
b/include/basegfx/polygon/b2dpolygontools.hxx
index 8f3ef342f3bc..d5aa092ed9cb 100644
--- 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-07-14 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolypolygon.cxx  |2 +-
 basegfx/source/tools/unopolypolygon.cxx|7 +--
 include/basegfx/polygon/b2dpolypolygon.hxx |2 +-
 3 files changed, 3 insertions(+), 8 deletions(-)

New commits:
commit 1aaf5d44dceecc13a3bc8e08c13d0b2ba278c462
Author: Noel Grandin 
AuthorDate: Thu Jul 14 14:33:09 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Jul 14 19:11:22 2022 +0200

make B2DPolyPolygon thread-safe

which is cheaper than copying it when querying from UnoPolyPolygon

Change-Id: If4661dfdff7e277d5ef25a8f0c937e549f8be9f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137080
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index a283828f661c..ad24ffa0b87c 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -205,7 +205,7 @@ public:
 }
 };
 
-static o3tl::cow_wrapper DEFAULT;
+static o3tl::cow_wrapper DEFAULT;
 
 B2DPolyPolygon::B2DPolyPolygon() :
 mpPolyPolygon(DEFAULT) {}
diff --git a/basegfx/source/tools/unopolypolygon.cxx 
b/basegfx/source/tools/unopolypolygon.cxx
index 76341e6ea532..0c3b59abac9b 100644
--- a/basegfx/source/tools/unopolypolygon.cxx
+++ b/basegfx/source/tools/unopolypolygon.cxx
@@ -38,8 +38,6 @@ namespace basegfx::unotools
 maPolyPoly(std::move( aPolyPoly )),
 meFillRule( rendering::FillRule_EVEN_ODD )
 {
-// or else races will haunt us.
-maPolyPoly.makeUnique();
 }
 
 void SAL_CALL UnoPolyPolygon::addPolyPolygon(
@@ -440,10 +438,7 @@ namespace basegfx::unotools
 {
 std::unique_lock const guard( m_aMutex );
 
-// detach result from us
-B2DPolyPolygon aRet( maPolyPoly );
-aRet.makeUnique();
-return aRet;
+return maPolyPoly;
 }
 
 }
diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx 
b/include/basegfx/polygon/b2dpolypolygon.hxx
index 474c0cbdb40f..68f1b0d6a619 100644
--- a/include/basegfx/polygon/b2dpolypolygon.hxx
+++ b/include/basegfx/polygon/b2dpolypolygon.hxx
@@ -36,7 +36,7 @@ namespace basegfx
 class BASEGFX_DLLPUBLIC B2DPolyPolygon
 {
 private:
-o3tl::cow_wrapper mpPolyPolygon;
+o3tl::cow_wrapper mpPolyPolygon;
 
 public:
 B2DPolyPolygon();


[Libreoffice-commits] core.git: basegfx/source include/basegfx sc/inc sc/source sd/source svx/source sw/source

2022-07-13 Thread Chris Sherlock (via logerrit)
 basegfx/source/tools/zoomtools.cxx |   16 
 include/basegfx/utils/zoomtools.hxx|5 ++---
 sc/inc/global.hxx  |4 ++--
 sc/source/ui/view/prevwsh.cxx  |   10 +-
 sc/source/ui/view/tabview.cxx  |8 
 sc/source/ui/view/tabvwsh3.cxx |8 
 sd/source/ui/view/viewshel.cxx |8 
 svx/source/stbctrls/zoomsliderctrl.cxx |4 ++--
 sw/source/uibase/uiview/view2.cxx  |2 +-
 sw/source/uibase/uiview/viewport.cxx   |6 +++---
 10 files changed, 35 insertions(+), 36 deletions(-)

New commits:
commit ac2a6ee9618e377806e529ed641f67e88684f7e7
Author: Chris Sherlock 
AuthorDate: Mon Jun 13 17:20:15 2022 +1000
Commit: Thorsten Behrens 
CommitDate: Wed Jul 13 18:54:28 2022 +0200

basegfx: zoomIn() and zoomOut() should be sal_uInt16

All zoom functions use sal_uInt16 values. For some reason, basegfx used
long when zoomIn and zoomOut were created in 2012 (see commit
315d2ddc16: "optimized zoom to use more common intervals"), this then
got mass converted to tools::Long in commit 387a88fa25: "use tools::Long
in basegfx..chart2".

So fix is to change zoomIn/Out() to use sal_uInt16.

Change-Id: I2a56d6f58e14f77aeb8741d332fe9bc282eb969f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135715
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

diff --git a/basegfx/source/tools/zoomtools.cxx 
b/basegfx/source/tools/zoomtools.cxx
index 4fedb8ee848c..dd4c7a6cbbd3 100644
--- a/basegfx/source/tools/zoomtools.cxx
+++ b/basegfx/source/tools/zoomtools.cxx
@@ -26,7 +26,7 @@ const double ZOOM_FACTOR = 1.12246205;
 * @param nCurrent current value
 * @param nMultiple multiple against which the current value is rounded
 */
-static tools::Long roundMultiple(tools::Long nCurrent, int nMultiple)
+static sal_uInt16 roundMultiple(sal_uInt16 nCurrent, int nMultiple)
 {
 // round zoom to a multiple of nMultiple
 return (( nCurrent + nMultiple / 2 ) - ( nCurrent + nMultiple / 2 ) % 
nMultiple);
@@ -39,10 +39,10 @@ static tools::Long roundMultiple(tools::Long nCurrent, int 
nMultiple)
 *
 * @param nCurrent current zoom factor
 */
-static tools::Long roundZoom(double nCurrent)
+static sal_uInt16 roundZoom(double nCurrent)
 {
 // convert nCurrent properly to int
-tools::Long nNew = nCurrent + 0.5;
+sal_uInt16 nNew = nCurrent + 0.5;
 
 // round to more common numbers above 50
 if (nNew > 1000) {
@@ -66,7 +66,7 @@ static tools::Long roundZoom(double nCurrent)
 * @param nPrevious previous zoom factor
 * @param nStep step which shouldn't be skipped
 */
-static tools::Long enforceStep(tools::Long nCurrent, tools::Long nPrevious, 
int nStep)
+static sal_uInt16 enforceStep(sal_uInt16 nCurrent, sal_uInt16 nPrevious, 
unsigned int nStep)
 {
 if ((( nCurrent > nStep ) && ( nPrevious < nStep ))
 || (( nCurrent < nStep ) && ( nPrevious > nStep )))
@@ -80,9 +80,9 @@ static tools::Long enforceStep(tools::Long nCurrent, 
tools::Long nPrevious, int
 *
 * @param nCurrent current zoom factor
 */
-tools::Long zoomIn(tools::Long nCurrent)
+sal_uInt16 zoomIn(sal_uInt16 nCurrent)
 {
-tools::Long nNew = roundZoom( nCurrent * ZOOM_FACTOR );
+sal_uInt16 nNew = roundZoom( nCurrent * ZOOM_FACTOR );
 // make sure some values are not skipped
 nNew = enforceStep(nNew, nCurrent, 200);
 nNew = enforceStep(nNew, nCurrent, 100);
@@ -97,9 +97,9 @@ tools::Long zoomIn(tools::Long nCurrent)
 *
 * @param nCurrent current zoom factor
 */
-tools::Long zoomOut(tools::Long nCurrent)
+sal_uInt16 zoomOut(sal_uInt16 nCurrent)
 {
-tools::Long nNew = roundZoom( nCurrent / ZOOM_FACTOR );
+sal_uInt16 nNew = roundZoom( nCurrent / ZOOM_FACTOR );
 // make sure some values are not skipped
 nNew = enforceStep(nNew, nCurrent, 200);
 nNew = enforceStep(nNew, nCurrent, 100);
diff --git a/include/basegfx/utils/zoomtools.hxx 
b/include/basegfx/utils/zoomtools.hxx
index 242c10e6dafc..16a36448af49 100644
--- a/include/basegfx/utils/zoomtools.hxx
+++ b/include/basegfx/utils/zoomtools.hxx
@@ -10,14 +10,13 @@
 #pragma once
 
 #include 
-#include 
 
 namespace basegfx::zoomtools
 {
 /** This namespace provides functions for optimized geometric zooming
 */
-BASEGFX_DLLPUBLIC tools::Long zoomOut(tools::Long nCurrent);
-BASEGFX_DLLPUBLIC tools::Long zoomIn(tools::Long nCurrent);
+BASEGFX_DLLPUBLIC sal_uInt16 zoomOut(sal_uInt16 nCurrent);
+BASEGFX_DLLPUBLIC sal_uInt16 zoomIn(sal_uInt16 nCurrent);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 47b93c845296..8401ca4c6f7e 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -75,8 +75,8 @@ const sal_Unicode CHAR_NNBSP= 0x202F; //NARROW NO-BREAK 
SPACE
 #define MINDOUBLE   1.7e-307
 #define MAXDOUBLE   1.7e307
 
-#define MINZOOM 20
-#define MAXZOOM 400
+const sal_uInt16 MINZOOM = 20;
+const sal_uInt16 MAXZOOM = 400;
 
 const 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-07-04 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolypolygon.cxx  |   11 +++
 basegfx/source/polygon/b2dpolypolygontools.cxx |1 +
 include/basegfx/polygon/b2dpolypolygon.hxx |1 +
 3 files changed, 13 insertions(+)

New commits:
commit f1e15482bcf6bf65dc611e19cbd2479ef141
Author: Noel Grandin 
AuthorDate: Fri Jul 1 14:03:22 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon Jul 4 21:04:30 2022 +0200

tdf#137544 reserve space in polypolygon

Change-Id: Ic8dc5b7479c1353487bac883fc0e704356e90798
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136802
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index 4a81a82c4c71..a283828f661c 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -108,6 +108,11 @@ public:
 }
 }
 
+void reserve(sal_uInt32 nCount)
+{
+maPolygons.reserve(nCount);
+}
+
 void insert(sal_uInt32 nIndex, const basegfx::B2DPolyPolygon& rPolyPolygon)
 {
 // add nCount polygons from rPolyPolygon
@@ -288,6 +293,12 @@ public:
 mpPolyPolygon->insert(std::as_const(mpPolyPolygon)->count(), 
rPolygon, nCount);
 }
 
+void B2DPolyPolygon::reserve(sal_uInt32 nCount)
+{
+if(nCount)
+mpPolyPolygon->reserve(nCount);
+}
+
 B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const
 {
 B2DPolyPolygon aRetval;
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx 
b/basegfx/source/polygon/b2dpolypolygontools.cxx
index b49de907d45c..3f8f51c52404 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -553,6 +553,7 @@ namespace basegfx::utils
 const css::drawing::PointSequenceSequence& 
rPointSequenceSequenceSource)
 {
 B2DPolyPolygon aRetval;
+aRetval.reserve(rPointSequenceSequenceSource.getLength());
 const css::drawing::PointSequence* pPointSequence = 
rPointSequenceSequenceSource.getConstArray();
 const css::drawing::PointSequence* pPointSeqEnd = pPointSequence + 
rPointSequenceSequenceSource.getLength();
 
diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx 
b/include/basegfx/polygon/b2dpolypolygon.hxx
index f1420edef79a..474c0cbdb40f 100644
--- a/include/basegfx/polygon/b2dpolypolygon.hxx
+++ b/include/basegfx/polygon/b2dpolypolygon.hxx
@@ -68,6 +68,7 @@ namespace basegfx
 // insert/append single polygon
 void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 
nCount = 1);
 void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
+void reserve(sal_uInt32 nCount);
 
 /** Default adaptive subdivision access
 


[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-05-27 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolypolygoncutter.cxx |5 +++--
 basegfx/source/tools/b2dclipstate.cxx   |5 +++--
 basegfx/source/tools/unopolypolygon.cxx |5 +++--
 include/basegfx/DrawCommands.hxx|5 +++--
 include/basegfx/matrix/b2dhommatrixtools.hxx|5 +++--
 include/basegfx/utils/gradienttools.hxx |5 +++--
 include/basegfx/utils/unopolypolygon.hxx|2 +-
 7 files changed, 19 insertions(+), 13 deletions(-)

New commits:
commit b3c965ccaa896b12b33ff5b7ccea0eb20d560116
Author: Noel Grandin 
AuthorDate: Fri May 27 16:36:42 2022 +0200
Commit: Noel Grandin 
CommitDate: Fri May 27 18:20:07 2022 +0200

clang-tidy modernize-pass-by-value in basegfx

Change-Id: I1ec34b2f0e9869a82894795f1d6351189ae92d9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135043
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx 
b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index ddec57374649..b548939f3eed 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -513,8 +514,8 @@ namespace basegfx
 impSolve();
 }
 
-explicit solver(const B2DPolyPolygon& rOriginal, size_t* 
pPointLimit = nullptr)
-:   maOriginal(rOriginal),
+explicit solver(B2DPolyPolygon aOriginal, size_t* pPointLimit = 
nullptr)
+:   maOriginal(std::move(aOriginal)),
 mbIsCurve(false),
 mbChanged(false)
 {
diff --git a/basegfx/source/tools/b2dclipstate.cxx 
b/basegfx/source/tools/b2dclipstate.cxx
index 7b8309e0de1c..126235699b4b 100644
--- a/basegfx/source/tools/b2dclipstate.cxx
+++ b/basegfx/source/tools/b2dclipstate.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 
 namespace basegfx::utils
@@ -39,8 +40,8 @@ namespace basegfx::utils
 mePendingOps(UNION)
 {}
 
-explicit ImplB2DClipState( const B2DPolyPolygon& rPoly ) :
-maClipPoly(rPoly),
+explicit ImplB2DClipState( B2DPolyPolygon aPoly ) :
+maClipPoly(std::move(aPoly)),
 mePendingOps(UNION)
 {}
 
diff --git a/basegfx/source/tools/unopolypolygon.cxx 
b/basegfx/source/tools/unopolypolygon.cxx
index ce61a5d3451b..76341e6ea532 100644
--- a/basegfx/source/tools/unopolypolygon.cxx
+++ b/basegfx/source/tools/unopolypolygon.cxx
@@ -28,13 +28,14 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 
 namespace basegfx::unotools
 {
-UnoPolyPolygon::UnoPolyPolygon( const B2DPolyPolygon& rPolyPoly ) :
-maPolyPoly( rPolyPoly ),
+UnoPolyPolygon::UnoPolyPolygon( B2DPolyPolygon aPolyPoly ) :
+maPolyPoly(std::move( aPolyPoly )),
 meFillRule( rendering::FillRule_EVEN_ODD )
 {
 // or else races will haunt us.
diff --git a/include/basegfx/DrawCommands.hxx b/include/basegfx/DrawCommands.hxx
index fef43689b4a9..14d3ad2459cf 100644
--- a/include/basegfx/DrawCommands.hxx
+++ b/include/basegfx/DrawCommands.hxx
@@ -11,6 +11,7 @@
 #define INCLUDED_BASEGFX_DRAWCOMMANDS_H
 
 #include 
+#include 
 #include 
 
 #include 
@@ -141,9 +142,9 @@ public:
 std::shared_ptr mpStrokeColor;
 std::shared_ptr mpFillGradient;
 
-DrawPath(basegfx::B2DPolyPolygon const& rPolyPolygon)
+DrawPath(basegfx::B2DPolyPolygon aPolyPolygon)
 : DrawBase(DrawCommandType::Path)
-, maPolyPolygon(rPolyPolygon)
+, maPolyPolygon(std::move(aPolyPolygon))
 , mnStrokeWidth(1.0)
 , mnOpacity(1.0)
 {
diff --git a/include/basegfx/matrix/b2dhommatrixtools.hxx 
b/include/basegfx/matrix/b2dhommatrixtools.hxx
index 10a0fe0df717..9b81f33d2a44 100644
--- a/include/basegfx/matrix/b2dhommatrixtools.hxx
+++ b/include/basegfx/matrix/b2dhommatrixtools.hxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace basegfx { class B2DRange; }
@@ -197,8 +198,8 @@ namespace basegfx::utils
 }
 
 public:
-B2DHomMatrixBufferedOnDemandDecompose(const B2DHomMatrix& 
rB2DHomMatrix = B2DHomMatrix())
-:   maB2DHomMatrix(rB2DHomMatrix),
+B2DHomMatrixBufferedOnDemandDecompose(B2DHomMatrix aB2DHomMatrix = 
B2DHomMatrix())
+:   maB2DHomMatrix(std::move(aB2DHomMatrix)),
 mfRotate(0.0),
 mfShearX(0.0),
 mbDecomposed(false)
diff --git a/include/basegfx/utils/gradienttools.hxx 
b/include/basegfx/utils/gradienttools.hxx
index e3d816394b54..03892122b54b 100644
--- a/include/basegfx/utils/gradienttools.hxx
+++ b/include/basegfx/utils/gradienttools.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace basegfx { class B2DRange; }
@@ -72,10 +73,10 @@ namespace basegfx
 }
 
  

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2022-05-16 Thread Tomaž Vajngerl (via logerrit)
 basegfx/source/polygon/b2dpolypolygon.cxx  |6 +++---
 include/basegfx/polygon/b2dpolypolygon.hxx |   11 ++-
 2 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit ed6d83dfbc590b9782a0699f53bc36f548ae3ec2
Author: Tomaž Vajngerl 
AuthorDate: Sun May 15 22:45:59 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon May 16 17:09:22 2022 +0200

basegfx: move ImplB2DPolyPolygon inside basegfx namespace

also remove unneeded typedef

Change-Id: I24fd31ff9da579260f1889ed87065f95dcfd1e23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134377
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index 4fd12bde4a10..4a81a82c4c71 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -27,6 +27,9 @@
 #include 
 #include 
 
+namespace basegfx
+{
+
 class ImplB2DPolyPolygon
 {
 basegfx::B2DPolygonVector   maPolygons;
@@ -197,9 +200,6 @@ public:
 }
 };
 
-namespace basegfx
-{
-
 static o3tl::cow_wrapper DEFAULT;
 
 B2DPolyPolygon::B2DPolyPolygon() :
diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx 
b/include/basegfx/polygon/b2dpolypolygon.hxx
index 010815c8784e..f1420edef79a 100644
--- a/include/basegfx/polygon/b2dpolypolygon.hxx
+++ b/include/basegfx/polygon/b2dpolypolygon.hxx
@@ -28,22 +28,15 @@
 #include 
 #include 
 
-class ImplB2DPolyPolygon;
-
 namespace basegfx
 {
 class B2DHomMatrix;
-}
+class ImplB2DPolyPolygon;
 
-namespace basegfx
-{
 class BASEGFX_DLLPUBLIC B2DPolyPolygon
 {
-public:
-typedef o3tl::cow_wrapper< ImplB2DPolyPolygon > ImplType;
-
 private:
-ImplTypempPolyPolygon;
+o3tl::cow_wrapper mpPolyPolygon;
 
 public:
 B2DPolyPolygon();


[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/source

2022-03-21 Thread Caolán McNamara (via logerrit)
 basegfx/source/polygon/b2dpolygonclipper.cxx  |   13 ++--
 basegfx/source/polygon/b2dpolygoncutandtouch.cxx  |   35 ++
 basegfx/source/polygon/b2dpolypolygoncutter.cxx   |8 ++---
 include/basegfx/polygon/b2dpolygonclipper.hxx |3 +
 include/basegfx/polygon/b2dpolygoncutandtouch.hxx |4 +-
 include/basegfx/polygon/b2dpolypolygoncutter.hxx  |3 +
 vcl/source/gdi/region.cxx |5 ++-
 7 files changed, 54 insertions(+), 17 deletions(-)

New commits:
commit f4474b2967f9c7b3b82239c6e9c66850964c6e8b
Author: Caolán McNamara 
AuthorDate: Mon Mar 21 15:33:06 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 21 17:35:37 2022 +0100

ofz#45878 add a way to set some limit on hugely complex clips

Change-Id: I6bbf7c6068560e3bb656560fb5c6cc2ed72cecd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131907
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx 
b/basegfx/source/polygon/b2dpolygonclipper.cxx
index 246d5a10ab84..69eba2c84fa7 100644
--- a/basegfx/source/polygon/b2dpolygonclipper.cxx
+++ b/basegfx/source/polygon/b2dpolygonclipper.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace basegfx::utils
 {
@@ -330,7 +331,8 @@ namespace basegfx::utils
 return aRetval;
 }
 
-B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& 
rCandidate, const B2DPolyPolygon& rClip, bool bInside, bool bStroke)
+B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& 
rCandidate, const B2DPolyPolygon& rClip,
+bool bInside, bool 
bStroke, size_t* pPointLimit)
 {
 B2DPolyPolygon aRetval;
 
@@ -471,7 +473,14 @@ namespace basegfx::utils
 
 
 // prepare 2nd source polygon in same way
-B2DPolyPolygon aMergePolyPolygonB = 
solveCrossovers(rCandidate);
+B2DPolyPolygon aMergePolyPolygonB = 
solveCrossovers(rCandidate, pPointLimit);
+
+if (pPointLimit && !*pPointLimit)
+{
+SAL_WARN("basegfx", "clipPolyPolygonOnPolyPolygon hit 
point limit");
+return aRetval;
+}
+
 aMergePolyPolygonB = 
stripNeutralPolygons(aMergePolyPolygonB);
 aMergePolyPolygonB = 
correctOrientations(aMergePolyPolygonB);
 
diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx 
b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
index 99a73ca82bc3..d5ab5887da61 100644
--- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
+++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -203,7 +204,7 @@ namespace basegfx
 
 // predefines for calls to this methods before method implementation
 
-void findCuts(const B2DPolygon& rCandidate, temporaryPointVector& 
rTempPoints);
+void findCuts(const B2DPolygon& rCandidate, temporaryPointVector& 
rTempPoints, size_t* pPointLimit = nullptr);
 void findTouches(const B2DPolygon& rEdgePolygon, const B2DPolygon& 
rPointPolygon, temporaryPointVector& rTempPoints);
 void findCuts(const B2DPolygon& rCandidateA, const B2DPolygon& 
rCandidateB, temporaryPointVector& rTempPointsA, temporaryPointVector& 
rTempPointsB);
 
@@ -487,7 +488,7 @@ namespace basegfx
 }
 }
 
-void findCuts(const B2DPolygon& rCandidate, temporaryPointVector& 
rTempPoints)
+void findCuts(const B2DPolygon& rCandidate, temporaryPointVector& 
rTempPoints, size_t* pPointLimit)
 {
 // find out if there are edges with intersections (self-cuts). If 
yes, add
 // entries to rTempPoints accordingly
@@ -588,6 +589,9 @@ namespace basegfx
 findEdgeCutsTwoEdges(aCurrA, aNextA, aCurrB, 
aNextB, a, b, rTempPoints, rTempPoints);
 }
 
+if (pPointLimit && rTempPoints.size() > *pPointLimit)
+break;
+
 // prepare next step
 aCurrB = aNextB;
 }
@@ -596,6 +600,14 @@ namespace basegfx
 aCurrA = aNextA;
 }
 }
+
+if (pPointLimit)
+{
+if (rTempPoints.size() > *pPointLimit)
+*pPointLimit = 0;
+else
+*pPointLimit -= rTempPoints.size();
+}
 }
 
 } // end of anonymous namespace
@@ -841,14 +853,19 @@ namespace basegfx
 namespace basegfx::utils
 {
 
-B2DPolygon addPointsAtCutsAndTouches(const B2DPolygon& rCandidate)
+B2DPolygon addPointsAtCutsAndTouches(const B2DPolygon& rCandidate, 
size_t* pPointLimit)
 {
 

[Libreoffice-commits] core.git: basegfx/source include/basegfx svgio/source vcl/skia

2021-11-12 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolypolygoncutter.cxx  |   74 ++-
 include/basegfx/polygon/b2dpolypolygoncutter.hxx |2 
 svgio/source/svgreader/svgclippathnode.cxx   |2 
 svgio/source/svgreader/svgstyleattributes.cxx|4 -
 vcl/skia/gdiimpl.cxx |4 -
 5 files changed, 41 insertions(+), 45 deletions(-)

New commits:
commit b2247f86e42c05991165834ff5d63731b0da2b3b
Author: Noel Grandin 
AuthorDate: Fri Nov 12 11:46:21 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Nov 12 12:11:36 2021 +0100

improve mergeToSinglePolyPolygon

spotted by llunak.

No need to take param by &&, since mergeToSinglePol does not
actually need to modify it.

Also flatten it a little.

Change-Id: I2f5ade347db756e21ecb0a88c3935805268f5072
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125086
Reviewed-by: Luboš Luňák 
Tested-by: Jenkins

diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx 
b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index 9d3cd7b450df..ac1e10660607 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -1067,81 +1067,77 @@ namespace basegfx::utils
 }
 }
 
-B2DPolyPolygon mergeToSinglePolyPolygon(B2DPolyPolygonVector&& rInput)
+B2DPolyPolygon mergeToSinglePolyPolygon(const B2DPolyPolygonVector& 
rInput)
 {
-B2DPolyPolygonVector aInput(std::move(rInput));
+if(rInput.empty())
+return B2DPolyPolygon();
 
 // first step: prepareForPolygonOperation and simple merge of 
non-overlapping
 // PolyPolygons for speedup; this is possible for the wanted 
OR-operation
-if(!aInput.empty())
+B2DPolyPolygonVector aResult;
+aResult.reserve(rInput.size());
+
+for(const basegfx::B2DPolyPolygon & a : rInput)
 {
-B2DPolyPolygonVector aResult;
-aResult.reserve(aInput.size());
+const basegfx::B2DPolyPolygon 
aCandidate(prepareForPolygonOperation(a));
 
-for(const basegfx::B2DPolyPolygon & a : aInput)
+if(!aResult.empty())
 {
-const basegfx::B2DPolyPolygon 
aCandidate(prepareForPolygonOperation(a));
+const B2DRange aCandidateRange(aCandidate.getB2DRange());
+bool bCouldMergeSimple(false);
 
-if(!aResult.empty())
+for(auto & b: aResult)
 {
-const B2DRange 
aCandidateRange(aCandidate.getB2DRange());
-bool bCouldMergeSimple(false);
-
-for(auto & b: aResult)
-{
-basegfx::B2DPolyPolygon aTarget(b);
-const B2DRange aTargetRange(aTarget.getB2DRange());
-
-if(!aCandidateRange.overlaps(aTargetRange))
-{
-aTarget.append(aCandidate);
-b = aTarget;
-bCouldMergeSimple = true;
-break;
-}
-}
+basegfx::B2DPolyPolygon aTarget(b);
+const B2DRange aTargetRange(aTarget.getB2DRange());
 
-if(!bCouldMergeSimple)
+if(!aCandidateRange.overlaps(aTargetRange))
 {
-aResult.push_back(aCandidate);
+aTarget.append(aCandidate);
+b = aTarget;
+bCouldMergeSimple = true;
+break;
 }
 }
-else
+
+if(!bCouldMergeSimple)
 {
 aResult.push_back(aCandidate);
 }
 }
-
-aInput = aResult;
+else
+{
+aResult.push_back(aCandidate);
+}
 }
 
 // second step: melt pairwise to a single PolyPolygon
-while(aInput.size() > 1)
+while(aResult.size() > 1)
 {
-B2DPolyPolygonVector aResult;
-aResult.reserve((aInput.size() / 2) + 1);
+B2DPolyPolygonVector aResult2;
+aResult2.reserve((aResult.size() / 2) + 1);
 
-for(size_t a(0); a < aInput.size(); a += 2)
+for(size_t a(0); a < aResult.size(); a += 2)
 {
-if(a + 1 < aInput.size())
+if(a + 1 < aResult.size())
 {
 // a pair for processing
-

[Libreoffice-commits] core.git: basegfx/source include/basegfx slideshow/source

2021-10-06 Thread Noel Grandin (via logerrit)
 basegfx/source/tools/keystoplerp.cxx |4 
++--
 include/basegfx/utils/keystoplerp.hxx|2 +-
 slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit e0117eff7f16277e7d6df18be60a6d6138b8611c
Author: Noel Grandin 
AuthorDate: Wed Oct 6 15:53:21 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Oct 6 19:37:44 2021 +0200

loplugin:moveparam in basegfx

Change-Id: I68d0de099641ae5b2ae92f46e86bdf4a43c468a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123141
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/tools/keystoplerp.cxx 
b/basegfx/source/tools/keystoplerp.cxx
index 0610dd19c228..e5d0d76304e2 100644
--- a/basegfx/source/tools/keystoplerp.cxx
+++ b/basegfx/source/tools/keystoplerp.cxx
@@ -42,8 +42,8 @@ static void validateInput(const std::vector& 
rKeyStops)
 
 namespace basegfx::utils
 {
-KeyStopLerp::KeyStopLerp( const std::vector& rKeyStops ) :
-maKeyStops(rKeyStops),
+KeyStopLerp::KeyStopLerp( std::vector&& rKeyStops ) :
+maKeyStops(std::move(rKeyStops)),
 mnLastIndex(0)
 {
 validateInput(maKeyStops);
diff --git a/include/basegfx/utils/keystoplerp.hxx 
b/include/basegfx/utils/keystoplerp.hxx
index 302020ac337e..f8a821e7a58f 100644
--- a/include/basegfx/utils/keystoplerp.hxx
+++ b/include/basegfx/utils/keystoplerp.hxx
@@ -53,7 +53,7 @@ namespace basegfx::utils
 need key stop lerping in the first place). All
 elements must be of monotonically increasing value.
  */
-explicit KeyStopLerp( const std::vector& rKeyStops );
+explicit KeyStopLerp( std::vector&& rKeyStops );
 
 /** Create lerper with given sequence of stops
 
diff --git 
a/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx 
b/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx
index 38d3590da3b6..db25d2dd4333 100644
--- a/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx
+++ b/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx
@@ -28,7 +28,7 @@ namespace slideshow::internal
 {
 ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase( const 
ActivityParameters& rParms ) :
 SimpleContinuousActivityBase( rParms ),
-maLerper( rParms.maDiscreteTimes )
+maLerper( std::vector(rParms.maDiscreteTimes) )
 {
 ENSURE_OR_THROW( rParms.maDiscreteTimes.size() > 1,
   
"ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times 
vector must have two entries or more" );


[Libreoffice-commits] core.git: basegfx/source include/basegfx svx/source

2021-06-16 Thread Tomaž Vajngerl (via logerrit)
 basegfx/source/color/bcolortools.cxx|2 -
 include/basegfx/numeric/ftools.hxx  |   33 
 svx/source/svdraw/svdotextdecomposition.cxx |4 +--
 3 files changed, 23 insertions(+), 16 deletions(-)

New commits:
commit e838c1b9e9031de742deeff763c06b1d39f399ef
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 14 20:11:34 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 16 10:47:27 2021 +0200

basegfx: use namespace for "ftools", make sure input is FP number

Don't use empty class with static methods for ftools, but just
use namespace instead. Also make sure it works with any floating
point numbers (float and double) and don't allow input if it is
anything else than a floating point number

Change-Id: I94b964291b3999d38ae13afe6ddfdbe6d891d410
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117154
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/basegfx/source/color/bcolortools.cxx 
b/basegfx/source/color/bcolortools.cxx
index 727b9c781774..160b48328966 100644
--- a/basegfx/source/color/bcolortools.cxx
+++ b/basegfx/source/color/bcolortools.cxx
@@ -152,7 +152,7 @@ namespace basegfx::utils
 }
 else
 {
-if( fTools::equal(h,360) )
+if( fTools::equal(h, 360.0) )
 h = 0; // 360 degrees is equivalent to 0 degrees
 
 h /= 60.0;
diff --git a/include/basegfx/numeric/ftools.hxx 
b/include/basegfx/numeric/ftools.hxx
index 54a8436f86a5..b72f069cb875 100644
--- a/include/basegfx/numeric/ftools.hxx
+++ b/include/basegfx/numeric/ftools.hxx
@@ -166,60 +166,67 @@ namespace basegfx
  */
 BASEGFX_DLLPUBLIC double normalizeToRange(double v, const double fRange);
 
-class BASEGFX_DLLPUBLIC fTools
+namespace fTools
 {
-public:
 /// Get threshold value for equalZero and friends
-static double getSmallValue() { return 0.1f; }
+inline double getSmallValue() { return 0.1f; }
 
 /// Compare against small value
-static bool equalZero(const double& rfVal)
+template ::value, bool>::type = false>
+inline bool equalZero(const T& rfVal)
 {
 return (fabs(rfVal) <= getSmallValue());
 }
 
 /// Compare against given small value
-static bool equalZero(const double& rfVal, const double& rfSmallValue)
+template ::value, bool>::type = false>
+inline bool equalZero(const T& rfVal, const T& rfSmallValue)
 {
 return (fabs(rfVal) <= rfSmallValue);
 }
 
-static bool equal(const double& rfValA, const double& rfValB)
+template ::value, bool>::type = false>
+inline bool equal(T const& rfValA, T const& rfValB)
 {
 // changed to approxEqual usage for better numerical correctness
 return rtl_math_approxEqual(rfValA, rfValB);
 }
 
-static bool equal(const double& rfValA, const double& rfValB, const 
double& rfSmallValue)
+template ::value, bool>::type = false>
+inline bool equal(const T& rfValA, const T& rfValB, const T& 
rfSmallValue)
 {
 return (fabs(rfValA - rfValB) <= rfSmallValue);
 }
 
-static bool less(const double& rfValA, const double& rfValB)
+template ::value, bool>::type = false>
+inline bool less(const T& rfValA, const T& rfValB)
 {
 return (rfValA < rfValB && !equal(rfValA, rfValB));
 }
 
-static bool lessOrEqual(const double& rfValA, const double& rfValB)
+template ::value, bool>::type = false>
+inline bool lessOrEqual(const T& rfValA, const T& rfValB)
 {
 return (rfValA < rfValB || equal(rfValA, rfValB));
 }
 
-static bool more(const double& rfValA, const double& rfValB)
+template ::value, bool>::type = false>
+inline bool more(const T& rfValA, const T& rfValB)
 {
 return (rfValA > rfValB && !equal(rfValA, rfValB));
 }
 
-static bool moreOrEqual(const double& rfValA, const double& rfValB)
+template ::value, bool>::type = false>
+inline bool moreOrEqual(const T& rfValA, const T& rfValB)
 {
 return (rfValA > rfValB || equal(rfValA, rfValB));
 }
 
-static bool betweenOrEqualEither(const double& rfValA, const double& 
rfValB, const double& rfValC)
+template ::value, bool>::type = false>
+inline bool betweenOrEqualEither(const T& rfValA, const T& rfValB, 
const T& rfValC)
 {
 return (rfValA > rfValB && rfValA < rfValC) || equal(rfValA, 
rfValB) || equal(rfValA, rfValC);
 }
-
 };
 } // end of namespace basegfx
 
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx 
b/svx/source/svdraw/svdotextdecomposition.cxx
index c2d5cd2301c8..c6f3bbdb8193 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2020-06-30 Thread Stephan Bergmann (via logerrit)
 basegfx/source/curve/b2dcubicbezier.cxx |2 +-
 include/basegfx/utils/rectcliptools.hxx |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 65269c27177003f18bec5c645f7498c8a3884ecc
Author: Stephan Bergmann 
AuthorDate: Tue Jun 30 15:23:15 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Jun 30 18:29:32 2020 +0200

Upcoming improved loplugin:staticanonymous -> redundantstatic: basegfx

Change-Id: I66b7e0fd74c7ce57cd2859e189caadb84be4d541
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97521
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basegfx/source/curve/b2dcubicbezier.cxx 
b/basegfx/source/curve/b2dcubicbezier.cxx
index 4fd2e33fe299..046f0cf30e17 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -30,7 +30,7 @@
 // #i37443#
 #define FACTOR_FOR_UNSHARPEN(1.6)
 #ifdef DBG_UTIL
-static const double fMultFactUnsharpen = FACTOR_FOR_UNSHARPEN;
+const double fMultFactUnsharpen = FACTOR_FOR_UNSHARPEN;
 #endif
 
 namespace basegfx
diff --git a/include/basegfx/utils/rectcliptools.hxx 
b/include/basegfx/utils/rectcliptools.hxx
index b1354a6cac87..af6be75bfc90 100644
--- a/include/basegfx/utils/rectcliptools.hxx
+++ b/include/basegfx/utils/rectcliptools.hxx
@@ -27,10 +27,10 @@ namespace basegfx::utils
 {
 namespace RectClipFlags
 {
-static const sal_uInt32 LEFT   = sal_Int32(0x01);
-static const sal_uInt32 RIGHT  = sal_Int32(0x02);
-static const sal_uInt32 TOP= sal_Int32(0x04);
-static const sal_uInt32 BOTTOM = sal_Int32(0x08);
+const sal_uInt32 LEFT   = sal_Int32(0x01);
+const sal_uInt32 RIGHT  = sal_Int32(0x02);
+const sal_uInt32 TOP= sal_Int32(0x04);
+const sal_uInt32 BOTTOM = sal_Int32(0x08);
 }
 
 /** Calc clip mask for Cohen-Sutherland rectangle clip
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basegfx/source include/basegfx

2020-02-14 Thread Armin Le Grand (via logerrit)
 basegfx/source/polygon/b2dpolygontools.cxx  |   36 +++
 basegfx/source/polygon/b3dpolygontools.cxx  |  255 +++-
 include/basegfx/polygon/b2dpolygontools.hxx |2 
 include/basegfx/polygon/b3dpolygontools.hxx |   12 +
 4 files changed, 216 insertions(+), 89 deletions(-)

New commits:
commit 62ac8333999c661432adb0a18245a399daa89dcb
Author: Armin Le Grand 
AuthorDate: Fri Feb 14 16:47:14 2020 +0100
Commit: Armin Le Grand 
CommitDate: Fri Feb 14 19:19:49 2020 +0100

tdf#130655 callback interface for 3D and secure dash

Added same interface for 3D but just for lines, it uses no
gaps. Added the security mechanism mentioned in the task
in comment (2) to 2D and 3D

Change-Id: I5da303c01562088682d95ee4f294c99e1f17bf6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88728
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 68d1120bc2cb..c194a38dc9d2 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -16,6 +16,8 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
+#include 
+#include 
 
 #include 
 #include 
@@ -32,8 +34,6 @@
 #include 
 #include 
 
-#include 
-
 // #i37443#
 #define ANGLE_BOUND_START_VALUE (2.25)
 #define ANGLE_BOUND_MINIMUM_VALUE   (0.1)
@@ -1231,6 +1231,32 @@ namespace basegfx::utils
 return;
 }
 
+// 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 double fNumberOfAllowedSnippets(65535.0 * 2.0);
+const double fAllowedLength((fNumberOfAllowedSnippets * 
fDotDashLength) / double(rDotDashArray.size()));
+const double 
fCandidateLength(basegfx::utils::getLength(rCandidate));
+std::vector aDotDashArray(rDotDashArray);
+
+if(fCandidateLength > fAllowedLength)
+{
+// we would produce more than fNumberOfAllowedSnippets, so
+// adapt aDotDashArray to exactly produce assumed number. Also
+// assert this to let the caller know about it.
+// If this asserts: Please think about checking your 
DotDashArray
+// before calling this function or evtl. use the callback 
version
+// to *not* produce that much of data. Even then, you may still
+// think about producing too much runtime (!)
+assert(true && "applyLineDashing: potentially too expensive to 
do the requested dismantle - please consider stretched LineDash pattern (!)");
+
+// calculate correcting factor, apply to aDotDashArray and 
fDotDashLength
+// to enlarge these as needed
+const double fFactor(fCandidateLength / fAllowedLength);
+std::for_each(aDotDashArray.begin(), aDotDashArray.end(), 
[](double ){ f *= fFactor; });
+fDotDashLength *= fFactor;
+}
+
 // prepare current edge's start
 B2DCubicBezier aCurrentEdge;
 const bool bIsClosed(rCandidate.isClosed());
@@ -1240,7 +1266,7 @@ namespace basegfx::utils
 // prepare DotDashArray iteration and the line/gap switching bool
 sal_uInt32 nDotDashIndex(0);
 bool bIsLine(true);
-double fDotDashMovingLength(rDotDashArray[0]);
+double fDotDashMovingLength(aDotDashArray[0]);
 B2DPolygon aSnippet;
 
 // remember 1st and last snippets to try to merge after execution
@@ -1303,7 +1329,7 @@ namespace basegfx::utils
 
 // prepare next DotDashArray step and flip 
line/gap flag
 fLastDotDashMovingLength = fDotDashMovingLength;
-fDotDashMovingLength += 
rDotDashArray[(++nDotDashIndex) % nDotDashCount];
+fDotDashMovingLength += 
aDotDashArray[(++nDotDashIndex) % nDotDashCount];
 bIsLine = !bIsLine;
 }
 
@@ -1367,7 +1393,7 @@ namespace basegfx::utils
 
 // prepare next DotDashArray step and flip 
line/gap flag
 fLastDotDashMovingLength = fDotDashMovingLength;
-fDotDashMovingLength += 
rDotDashArray[(++nDotDashIndex) % nDotDashCount];
+fDotDashMovingLength += 
aDotDashArray[(++nDotDashIndex) % nDotDashCount];
 bIsLine = !bIsLine;
 }
 
diff --git a/basegfx/source/polygon/b3dpolygontools.cxx 
b/basegfx/source/polygon/b3dpolygontools.cxx
index 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2020-02-14 Thread Armin Le Grand (Collabora) (via logerrit)
 basegfx/source/polygon/b2dpolygontools.cxx  |  419 
 include/basegfx/polygon/b2dpolygontools.hxx |   24 +
 2 files changed, 263 insertions(+), 180 deletions(-)

New commits:
commit 0dc4fddb9c76a3f4682eca4059b42a079e74e735
Author: Armin Le Grand (Collabora) 
AuthorDate: Fri Feb 14 12:32:42 2020 +0100
Commit: Armin Le Grand 
CommitDate: Fri Feb 14 16:44:26 2020 +0100

tdf#130655 added callback interface to ::applyLineDashing

This version of the tooling method allows to avoid collecting line
snippets in a return value PolyPolygon. Instead, offer lambda
functions to get callbacks for created snippets. The original
method using a B2DPolyPolygon return value is adapted to already
use this, so serves as example of usage and ensures that only
one identical algorithm is used.

Change-Id: Ie306968a895ad280fc2425fb40b3244769216ba0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88684
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index cf2de34859cd..68d1120bc2cb 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -1110,7 +1110,102 @@ namespace basegfx::utils
 return false;
 }
 
-void applyLineDashing(const B2DPolygon& rCandidate, const 
std::vector& rDotDashArray, B2DPolyPolygon* pLineTarget, 
B2DPolyPolygon* pGapTarget, double fDotDashLength)
+void applyLineDashing(
+const B2DPolygon& rCandidate,
+const std::vector& rDotDashArray,
+B2DPolyPolygon* pLineTarget,
+B2DPolyPolygon* pGapTarget,
+double fDotDashLength)
+{
+// clear targets in any case
+if(pLineTarget)
+{
+pLineTarget->clear();
+}
+
+if(pGapTarget)
+{
+pGapTarget->clear();
+}
+
+// provide callbacks as lambdas
+auto aLineCallback(
+nullptr == pLineTarget
+? std::function()
+: [](const basegfx::B2DPolygon& rSnippet){ 
pLineTarget->append(rSnippet); });
+auto aGapCallback(
+nullptr == pGapTarget
+? std::function()
+: [](const basegfx::B2DPolygon& rSnippet){ 
pGapTarget->append(rSnippet); });
+
+// call version that uses callbacks
+applyLineDashing(
+rCandidate,
+rDotDashArray,
+aLineCallback,
+aGapCallback,
+fDotDashLength);
+}
+
+static void implHandleSnippet(
+const B2DPolygon& rSnippet,
+std::function& 
rTargetCallback,
+B2DPolygon& rFirst,
+B2DPolygon& rLast)
+{
+if(rSnippet.isClosed())
+{
+if(!rFirst.count())
+{
+rFirst = rSnippet;
+}
+else
+{
+if(rLast.count())
+{
+rTargetCallback(rLast);
+}
+
+rLast = rSnippet;
+}
+}
+else
+{
+rTargetCallback(rSnippet);
+}
+}
+
+static void implHandleFirstLast(
+std::function& 
rTargetCallback,
+B2DPolygon& rFirst,
+B2DPolygon& rLast)
+{
+if(rFirst.count() && rLast.count()
+&& rFirst.getB2DPoint(0).equal(rLast.getB2DPoint(rLast.count() 
- 1)))
+{
+// start of first and end of last are the same -> merge them
+rLast.append(rFirst);
+rLast.removeDoublePoints();
+rFirst.clear();
+}
+
+if(rLast.count())
+{
+rTargetCallback(rLast);
+}
+
+if(rFirst.count())
+{
+rTargetCallback(rFirst);
+}
+}
+
+void applyLineDashing(
+const B2DPolygon& rCandidate,
+const std::vector& rDotDashArray,
+std::function 
aLineTargetCallback,
+std::function 
aGapTargetCallback,
+double fDotDashLength)
 {
 const sal_uInt32 nPointCount(rCandidate.count());
 const sal_uInt32 nDotDashCount(rDotDashArray.size());
@@ -1120,244 +1215,210 @@ namespace basegfx::utils
 fDotDashLength = std::accumulate(rDotDashArray.begin(), 
rDotDashArray.end(), 0.0);
 }
 
-if(fTools::more(fDotDashLength, 0.0) && (pLineTarget || 
pGapTarget) && nPointCount)
+if(fTools::lessOrEqual(fDotDashLength, 0.0) || 
(!aLineTargetCallback && !aGapTargetCallback) || !nPointCount)

[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/headless vcl/inc

2020-01-23 Thread Armin Le Grand (via logerrit)
 basegfx/source/tools/systemdependentdata.cxx |   59 ++-
 include/basegfx/polygon/b2dpolygon.hxx   |   10 +
 include/basegfx/polygon/b2dpolypolygon.hxx   |   10 +
 vcl/headless/svpgdi.cxx  |  142 +--
 vcl/inc/win/salbmp.h |   10 +
 5 files changed, 127 insertions(+), 104 deletions(-)

New commits:
commit 2da7a82f6b7a78e1e4b34b0b3c7a27d2b3c47a35
Author: Armin Le Grand 
AuthorDate: Wed Jan 22 17:20:13 2020 +0100
Commit: Armin Le Grand 
CommitDate: Thu Jan 23 17:48:55 2020 +0100

tdf#129845: Better solution using already existing info

Use calculateCombinedHoldCyclesInSeconds() in central
places of system-dependent buffering and the zero value
to early exclude data from buffering. This solves the
problem on all system-dependent usages in a central
place. Also enhanced to roughly allow buffering for
bitmaps unchanged, for polygons starting with ca. 50
coordinate pairs.
Added special treatments to Cairo version to allow
temp buffer objects without copying the path data. This
needed some extra stuff due to Cairo not allowing
to work with it's cr-internal path object directly.

Change-Id: Icd0a0d8091707fe356a82f5c7ec48f36ad44ccde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87199
Reviewed-by: Michael Meeks 
Tested-by: Jenkins

diff --git a/basegfx/source/tools/systemdependentdata.cxx 
b/basegfx/source/tools/systemdependentdata.cxx
index 223b607ffae0..53b1465eaf55 100644
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -77,39 +77,48 @@ namespace basegfx
 if(0 == mnCalculatedCycles)
 {
 const sal_Int64 nBytes(estimateUsageInBytes());
-const sal_uInt32 nSeconds = 60; // HoldCyclesInSeconds
 
-// default is Seconds (minimal is one)
-sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);
-
-if(0 != nBytes)
+// tdf#129845 as indicator for no need to buffer trivial data, 
stay at and
+// return zero. As border, use 450 bytes. For polygons, this means 
to buffer
+// starting with ca. 50 points (GDIPLUS uses 9 bytes per 
coordinate). For
+// Bitmap data this means to more or less always buffer (as it was 
before).
+// For the future, a more sophisticated differentioation may be 
added
+if(nBytes > 450)
 {
-// use sqrt to get some curved shape. With a default of 60s we 
get
-// a single second at 3600 byte. To get close to 10mb, 
multiply by
-// a corresponding scaling factor
-const double fScaleToMB(3600.0 / (1024.0 * 1024.0 * 10.0));
-
-// also use a multiplier to move the start point higher
-const double fMultiplierSeconds(10.0);
+const sal_uInt32 nSeconds = 60; // HoldCyclesInSeconds
 
-// calculate
-nResult = static_cast((fMultiplierSeconds * 
nSeconds) / sqrt(nBytes * fScaleToMB));
+// default is Seconds (minimal is one)
+sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);
 
-// minimal value is 1
-if(nResult < 1)
+if(0 != nBytes)
 {
-nResult = 1;
+// use sqrt to get some curved shape. With a default of 
60s we get
+// a single second at 3600 byte. To get close to 10mb, 
multiply by
+// a corresponding scaling factor
+const double fScaleToMB(3600.0 / (1024.0 * 1024.0 * 10.0));
+
+// also use a multiplier to move the start point higher
+const double fMultiplierSeconds(10.0);
+
+// calculate
+nResult = static_cast((fMultiplierSeconds * 
nSeconds) / sqrt(nBytes * fScaleToMB));
+
+// minimal value is 1
+if(nResult < 1)
+{
+nResult = 1;
+}
+
+// maximal value is nSeconds
+if(nResult > nSeconds)
+{
+nResult = nSeconds;
+}
 }
 
-// maximal value is nSeconds
-if(nResult > nSeconds)
-{
-nResult = nSeconds;
-}
+// set locally (once, on-demand created, non-zero)
+const_cast(this)->mnCalculatedCycles = 
nResult;
 }
-
-// set locally (once, on-demand created, non-zero)
-const_cast(this)->mnCalculatedCycles = 
nResult;
 }
 
 return mnCalculatedCycles;
diff --git a/include/basegfx/polygon/b2dpolygon.hxx 
b/include/basegfx/polygon/b2dpolygon.hxx
index 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2019-12-03 Thread Julien Nabet (via logerrit)
 basegfx/source/range/b2dpolyrange.cxx  |   10 +-
 include/basegfx/range/b2dpolyrange.hxx |2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit f51fddc2e7cfa2a2118610a3fc4b02886544d0a9
Author: Julien Nabet 
AuthorDate: Mon Dec 2 21:04:23 2019 +0100
Commit: Noel Grandin 
CommitDate: Tue Dec 3 12:29:35 2019 +0100

Simplify a bit B2DPolyRange::appendElement (basegfx)

push_back is more optimized than an insert

Change-Id: I8932c4ee61569b5eee3d5dbc5fbfd8eff624d061
Reviewed-on: https://gerrit.libreoffice.org/84276
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/range/b2dpolyrange.cxx 
b/basegfx/source/range/b2dpolyrange.cxx
index f5ead1641d15..21905e408167 100644
--- a/basegfx/source/range/b2dpolyrange.cxx
+++ b/basegfx/source/range/b2dpolyrange.cxx
@@ -52,10 +52,10 @@ namespace basegfx
 return std::make_tuple(maRanges[nIndex], maOrient[nIndex]);
 }
 
-void appendElement(const B2DRange& rRange, B2VectorOrientation 
eOrient, sal_uInt32 nCount)
+void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient)
 {
-maRanges.insert(maRanges.end(), nCount, rRange);
-maOrient.insert(maOrient.end(), nCount, eOrient);
+maRanges.push_back(rRange);
+maOrient.push_back(eOrient);
 maBounds.expand(rRange);
 }
 
@@ -130,9 +130,9 @@ namespace basegfx
 return mpImpl->getElement(nIndex);
 }
 
-void B2DPolyRange::appendElement(const B2DRange& rRange, 
B2VectorOrientation eOrient, sal_uInt32 nCount)
+void B2DPolyRange::appendElement(const B2DRange& rRange, 
B2VectorOrientation eOrient)
 {
-mpImpl->appendElement(rRange, eOrient, nCount );
+mpImpl->appendElement(rRange, eOrient);
 }
 
 void B2DPolyRange::clear()
diff --git a/include/basegfx/range/b2dpolyrange.hxx 
b/include/basegfx/range/b2dpolyrange.hxx
index e6de924057df..e4d68e8a0986 100644
--- a/include/basegfx/range/b2dpolyrange.hxx
+++ b/include/basegfx/range/b2dpolyrange.hxx
@@ -70,7 +70,7 @@ namespace basegfx
 ElementType getElement(sal_uInt32 nIndex) const;
 
 // insert/append a single range
-void appendElement(const B2DRange& rRange, B2VectorOrientation 
eOrient, sal_uInt32 nCount = 1);
+void appendElement(const B2DRange& rRange, B2VectorOrientation 
eOrient);
 
 void clear();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: basegfx/source include/basegfx svx/source

2018-11-16 Thread Libreoffice Gerrit user
 basegfx/source/polygon/b2dpolygontools.cxx|4 +-
 include/basegfx/polygon/b2dpolygontools.hxx   |9 +++-
 svx/source/customshapes/EnhancedCustomShape2d.cxx |   40 ++
 3 files changed, 13 insertions(+), 40 deletions(-)

New commits:
commit c4c1636b5132261e64492de38f252b19b77e69b8
Author: Regina Henschel 
AuthorDate: Wed Nov 14 14:30:49 2018 +0100
Commit: Regina Henschel 
CommitDate: Fri Nov 16 17:45:48 2018 +0100

tdf#121305 Increase accuracy of custom shape circle

The old implementation has used 4 segments and a questionable control
point distance. The patch changes this to use the common
implementation in basegfx. The method in basegfx is extended to allow
to set the start quarter, so that the custom shape circle can get the
same start quarter as it has before. The method descriptions in
basegfx are adapted to the current implementation.

Change-Id: I3a40f81827227ee0037d336bdf3c1ec6fdd64b4b
Reviewed-on: https://gerrit.libreoffice.org/63366
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 5c8eaa5792a6..e0cfcdba1933 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -1768,9 +1768,9 @@ namespace basegfx
 }
 }
 
-B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double 
fRadiusX, double fRadiusY )
+B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double 
fRadiusX, double fRadiusY, sal_uInt32 nStartQuadrant)
 {
-B2DPolygon aRetval(createPolygonFromUnitCircle());
+B2DPolygon aRetval(createPolygonFromUnitCircle(nStartQuadrant));
 const B2DHomMatrix 
aMatrix(createScaleTranslateB2DHomMatrix(fRadiusX, fRadiusY, rCenter.getX(), 
rCenter.getY()));
 
 aRetval.transform(aMatrix);
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx 
b/include/basegfx/polygon/b2dpolygontools.hxx
index 2f5641bb1581..57b9130b4399 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -231,7 +231,7 @@ namespace basegfx
 /** Create a circle polygon with given radius.
 
 This method creates a circle approximation consisting of
-four cubic bezier segments, which approximate the given
+12 cubic bezier segments, which approximate the given
 circle with an error of less than 0.5 percent.
 
 @param rCenter
@@ -260,7 +260,7 @@ namespace basegfx
 /** Create an ellipse polygon with given radii.
 
 This method creates an ellipse approximation consisting of
-four cubic bezier segments, which approximate the given
+12 cubic bezier segments, which approximate the given
 ellipse with an error of less than 0.5 percent.
 
 @param rCenter
@@ -271,8 +271,11 @@ namespace basegfx
 
 @param fRadiusY
 Radius of the ellipse in Y direction
+
+@param nStartQuadrant
+With Y down on screens, 0 = 3 o'clock, 1 = 6 o'clock, 2 = 9 
o'clock, 3 = 12 o'clock
  */
-BASEGFX_DLLPUBLIC B2DPolygon createPolygonFromEllipse( const B2DPoint& 
rCenter, double fRadiusX, double fRadiusY );
+BASEGFX_DLLPUBLIC B2DPolygon createPolygonFromEllipse( const B2DPoint& 
rCenter, double fRadiusX, double fRadiusY, sal_uInt32 nStartQuadrant = 0);
 
 /** Create an unit ellipse polygon with the given angles, from start 
to end
  */
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx 
b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 20e2da61d404..aaeac95f71db 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1688,41 +1688,11 @@ void EnhancedCustomShape2d::CreateSubPath(
 aNewB2DPolygon.append(CreateArc( aRect, Point( 
static_cast(fx1), static_cast(fy1) ), Point( 
static_cast(fx2), static_cast(fy2) ), false));
 }
 else
-{   /* SJ: TODO: this block should be replaced 
sometimes, because the current point
-   is not set correct, it also does not use 
the correct moveto
-   point if ANGLEELLIPSETO was used, but the 
method CreateArc
-   is at the moment not able to draw full 
circles (if startangle is 0
-   and endangle 360 nothing is painted :-( */
-sal_Int32 nXControl = 
static_cast(static_cast(aRect.GetWidth()) * 0.2835 );
-sal_Int32 nYControl = 
static_cast(static_cast(aRect.GetHeight()) * 0.2835 );
-Point aCenter( 

[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/headless vcl/source vcl/unx vcl/win

2018-10-06 Thread Libreoffice Gerrit user
 basegfx/source/tools/systemdependentdata.cxx  |   47 
 include/basegfx/utils/systemdependentdata.hxx |   12 +++
 vcl/headless/svpgdi.cxx   |   18 
 vcl/source/app/svdata.cxx |4 -
 vcl/unx/generic/gdi/gdiimpl.cxx   |   14 +++
 vcl/win/gdi/gdiimpl.cxx   |   96 +++---
 vcl/win/gdi/salbmp.cxx|   88 +++
 7 files changed, 236 insertions(+), 43 deletions(-)

New commits:
commit e650279db77281fe98aaff28e31c2269611c31e4
Author: Armin Le Grand 
AuthorDate: Wed Oct 3 15:55:29 2018 +0200
Commit: Armin Le Grand 
CommitDate: Sat Oct 6 20:31:22 2018 +0200

Support estimateUsageInBytes for SystemDependentData

Change-Id: I6074035ed8f90e452915e9ecffdbe9363375e126
Reviewed-on: https://gerrit.libreoffice.org/61306
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/systemdependentdata.cxx 
b/basegfx/source/tools/systemdependentdata.cxx
index 4153d35f7d55..c727462c7191 100644
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 
 namespace basegfx
 {
@@ -62,7 +63,8 @@ namespace basegfx
 {
 SystemDependentData::SystemDependentData(
 SystemDependentDataManager& rSystemDependentDataManager)
-:   mrSystemDependentDataManager(rSystemDependentDataManager)
+:   mrSystemDependentDataManager(rSystemDependentDataManager),
+mnCalculatedCycles(0)
 {
 }
 
@@ -70,6 +72,49 @@ namespace basegfx
 {
 }
 
+sal_uInt32 SystemDependentData::calculateCombinedHoldCyclesInSeconds() 
const
+{
+if(0 == mnCalculatedCycles)
+{
+const sal_Int64 nBytes(estimateUsageInBytes());
+const sal_uInt32 nSeconds(getHoldCyclesInSeconds());
+
+// default is Seconds (minimal is one)
+sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);
+
+if(0 != nBytes)
+{
+// use sqrt to get some curved shape. With a default of 60s we 
get
+// a single second at 3600 byte. To get close to 10mb, 
multiply by
+// a corresponding scaling factor
+const double fScaleToMB(3600.0 / (1024.0 * 1024.0 * 10.0));
+
+// also use a multiplier to move the start point higer
+const double fMultiplierSeconds(10.0);
+
+// calculate
+nResult = static_cast((fMultiplierSeconds * 
nSeconds) / sqrt(nBytes * fScaleToMB));
+
+// minimal value is 1
+if(nResult < 1)
+{
+nResult = 1;
+}
+
+// maximal value is nSeconds
+if(nResult > nSeconds)
+{
+nResult = nSeconds;
+}
+}
+
+// set locally (once, on-demand created, non-zero)
+const_cast(this)->mnCalculatedCycles = 
nResult < 1 ? 1 : nResult;
+}
+
+return mnCalculatedCycles;
+}
+
 sal_uInt32 SystemDependentData::getHoldCyclesInSeconds() const
 {
 // default implementation returns 60(s)
diff --git a/include/basegfx/utils/systemdependentdata.hxx 
b/include/basegfx/utils/systemdependentdata.hxx
index 920a55043870..d5cc8d645eb6 100644
--- a/include/basegfx/utils/systemdependentdata.hxx
+++ b/include/basegfx/utils/systemdependentdata.hxx
@@ -89,6 +89,12 @@ namespace basegfx
 // a single, globally used one, but not necessarily
 SystemDependentDataManager& mrSystemDependentDataManager;
 
+// Buffered CalculatedCycles, result of estimations using
+// getHoldCyclesInSeconds and estimateUsageInBytes, executed
+// using getHoldCyclesInSeconds. StartValue is 0 to detect
+// not-yet-calculated state
+sal_uInt32  mnCalculatedCycles;
+
 public:
 SystemDependentData(
 SystemDependentDataManager& rSystemDependentDataManager);
@@ -103,6 +109,12 @@ namespace basegfx
 // using getSystemDependentDataManager()
 SystemDependentDataManager& getSystemDependentDataManager() { return 
mrSystemDependentDataManager; }
 
+// Calculate HoldCyclesInSeconds based on using
+// getHoldCyclesInSeconds and estimateUsageInBytes, the
+// result is crated once on-demand and buffered in
+// mnCalculatedCycles
+sal_uInt32 calculateCombinedHoldCyclesInSeconds() const;
+
 // Number of cycles a SystemDependentDataManager should/might
 // hold this instance in seconds - does not have to be used,
 // but should be. Default implementation returns 60(s). Override to
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index b1f622904b5f..e42eb3ed3eaa 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx

[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/headless vcl/source vcl/unx vcl/win

2018-09-21 Thread Libreoffice Gerrit user
 basegfx/source/tools/systemdependentdata.cxx  |   18 +++--
 include/basegfx/utils/systemdependentdata.hxx |   20 ++
 vcl/headless/svpgdi.cxx   |   37 +---
 vcl/source/app/svdata.cxx |4 +-
 vcl/unx/generic/gdi/gdiimpl.cxx   |   48 ++
 vcl/win/gdi/gdiimpl.cxx   |   31 ++--
 6 files changed, 113 insertions(+), 45 deletions(-)

New commits:
commit 80b287ad0322afcbf8f80b0507e212870dcf0f98
Author: Armin Le Grand 
AuthorDate: Fri Sep 21 16:42:01 2018 +0200
Commit: Armin Le Grand 
CommitDate: Fri Sep 21 20:12:09 2018 +0200

Support buffering SystemDependent GraphicData

Started to make the buffering more flexible by adding
virtual methods

virtual sal_uInt32 getHoldCyclesInSeconds() const;
virtual sal_Int64 estimateUsageInBytes() const;

to class SystemDependentData. This will allow to add more
sensitive buffering/caching.
Also fine-tuned Linux-derived classes actively used for buffering
to be more sensitive when and where to reuse the buffered data

Change-Id: Ifc69c318ade0209aff071d76001869d9f4eeb10d
Reviewed-on: https://gerrit.libreoffice.org/60881
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/systemdependentdata.cxx 
b/basegfx/source/tools/systemdependentdata.cxx
index 45f2efba5012..4153d35f7d55 100644
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -61,16 +61,26 @@ namespace basegfx
 namespace basegfx
 {
 SystemDependentData::SystemDependentData(
-SystemDependentDataManager& rSystemDependentDataManager,
-sal_uInt32 nHoldCycles)
-:   mrSystemDependentDataManager(rSystemDependentDataManager),
-mnHoldCycles(nHoldCycles)
+SystemDependentDataManager& rSystemDependentDataManager)
+:   mrSystemDependentDataManager(rSystemDependentDataManager)
 {
 }
 
 SystemDependentData::~SystemDependentData()
 {
 }
+
+sal_uInt32 SystemDependentData::getHoldCyclesInSeconds() const
+{
+// default implementation returns 60(s)
+return 60;
+}
+
+sal_Int64 SystemDependentData::estimateUsageInBytes() const
+{
+// default implementation has no idea
+return 0;
+}
 } // namespace basegfx
 
 namespace basegfx
diff --git a/include/basegfx/utils/systemdependentdata.hxx 
b/include/basegfx/utils/systemdependentdata.hxx
index 6d4a90d10cda..920a55043870 100644
--- a/include/basegfx/utils/systemdependentdata.hxx
+++ b/include/basegfx/utils/systemdependentdata.hxx
@@ -89,14 +89,9 @@ namespace basegfx
 // a single, globally used one, but not necessarily
 SystemDependentDataManager& mrSystemDependentDataManager;
 
-// number of cycles a SystemDependentDataManager should/might
-// hold this instance - does not have to be used, but should be
-sal_uInt32  mnHoldCycles;
-
 public:
 SystemDependentData(
-SystemDependentDataManager& rSystemDependentDataManager,
-sal_uInt32 nHoldCycles = 60);
+SystemDependentDataManager& rSystemDependentDataManager);
 
 // CAUTION! It is VERY important to keep this base class
 // virtual, else typeid(class).hash_code() from derived classes
@@ -108,8 +103,17 @@ namespace basegfx
 // using getSystemDependentDataManager()
 SystemDependentDataManager& getSystemDependentDataManager() { return 
mrSystemDependentDataManager; }
 
-// number of cycles to hold data
-sal_uInt32 getHoldCycles() const { return mnHoldCycles; }
+// Number of cycles a SystemDependentDataManager should/might
+// hold this instance in seconds - does not have to be used,
+// but should be. Default implementation returns 60(s). Override to
+// offer useful data if you want to have better caching.
+virtual sal_uInt32 getHoldCyclesInSeconds() const;
+
+// Size estimation of the entry in bytes - does not have to
+// be used, but should be. Default returns zero what
+// means there is no size estimation available. Override to
+// offer useful data if you want to have better caching.
+virtual sal_Int64 estimateUsageInBytes() const;
 };
 } // end of namespace basegfx
 
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index ea70321ff2fa..e12c7a32c8bd 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1036,27 +1036,36 @@ void SvpSalGraphics::drawLine( long nX1, long nY1, long 
nX2, long nY2 )
 class SystemDependentData_CairoPath : public basegfx::SystemDependentData
 {
 private:
+// the path data itself
 cairo_path_t*   mpCairoPath;
-boolmbPixelSnapHairline;
+
+// all other values the path data  is based on and
+// 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2018-08-31 Thread Libreoffice Gerrit user
 0 files changed

New commits:
commit 6e79acd7238c5e5ab19d0f2c0bbda99b3cfa067c
Author: Andrea Gelmini 
AuthorDate: Fri Aug 31 08:04:42 2018 +0200
Commit: Julien Nabet 
CommitDate: Sat Sep 1 07:43:25 2018 +0200

Removed execution flag on source files

Change-Id: Iec140c37e437ce0b49f07b393498f0804e5b46d8
Reviewed-on: https://gerrit.libreoffice.org/59846
Reviewed-by: Julien Nabet 
Tested-by: Jenkins

diff --git a/basegfx/source/tools/systemdependentdata.cxx 
b/basegfx/source/tools/systemdependentdata.cxx
old mode 100755
new mode 100644
diff --git a/include/basegfx/utils/systemdependentdata.hxx 
b/include/basegfx/utils/systemdependentdata.hxx
old mode 100755
new mode 100644
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basegfx/source include/basegfx

2018-08-14 Thread Libreoffice Gerrit user
 basegfx/source/polygon/b2dsvgpolypolygon.cxx|   96 
 include/basegfx/polygon/b2dpolypolygontools.hxx |9 ++
 2 files changed, 57 insertions(+), 48 deletions(-)

New commits:
commit 071d8aff7cbe38c0522c5a87ee77dd1b0d2da91f
Author: Mark Hung 
AuthorDate: Fri Aug 10 22:15:36 2018 +0800
Commit: Mark Hung 
CommitDate: Tue Aug 14 18:23:14 2018 +0200

tdf#118825 Implement OOXMLMotionPath in exportToSvgD of basegfx.

Powerpoint only allows M,L,C,Z,E,m,l,c,z,e , i.e. V,H,S ( and
their corresponding relative command ) must not be used and
ending E is mandatory. Command and space delimiters also can not
be skipped.

Change-Id: Icad38ec2eed3e49143eb9a03aa56cc178baae99d
Reviewed-on: https://gerrit.libreoffice.org/58848
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx 
b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index a0ff38155a26..2a195641d5f0 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -32,31 +32,28 @@
 namespace
 {
 
-void putCommandChar(OUStringBuffer& rBuffer,sal_Unicode& rLastSVGCommand, 
sal_Unicode aChar, bool bToLower)
+void putCommandChar(OUStringBuffer& rBuffer,sal_Unicode& rLastSVGCommand, 
sal_Unicode aChar, bool bToLower,bool bVerbose)
 {
 const sal_Unicode aCommand = bToLower ? rtl::toAsciiLowerCase(aChar) : 
aChar;
 
-if (rLastSVGCommand != aCommand)
+if (bVerbose && rBuffer.getLength())
+rBuffer.append(' ');
+
+if (bVerbose || rLastSVGCommand != aCommand)
 {
 rBuffer.append(aCommand);
 rLastSVGCommand = aCommand;
 }
 }
 
-void putNumberChar(OUStringBuffer& rStr,double fValue, double fOldValue, bool 
bUseRelativeCoordinates)
+void putNumberChar(OUStringBuffer& rStr,double fValue, double fOldValue, bool 
bUseRelativeCoordinates,bool bVerbose)
 {
 if (bUseRelativeCoordinates)
 fValue -= fOldValue;
 
 const sal_Int32 aLen(rStr.getLength());
-if (aLen)
-{
-if (basegfx::internal::isOnNumberChar(rStr[aLen - 1], false) &&
-fValue >= 0.0 )
-{
-rStr.append(' ');
-}
-}
+if (bVerbose || (aLen && basegfx::internal::isOnNumberChar(rStr[aLen - 1], 
false) && fValue >= 0.0))
+rStr.append(' ');
 
 rStr.append(fValue);
 }
@@ -727,7 +724,8 @@ namespace basegfx
 const B2DPolyPolygon& rPolyPolygon,
 bool bUseRelativeCoordinates,
 bool bDetectQuadraticBeziers,
-bool bHandleRelativeNextPointCompatible)
+bool bHandleRelativeNextPointCompatible,
+bool bOOXMLMotionPath)
 {
 const sal_uInt32 nCount(rPolyPolygon.count());
 OUStringBuffer aResult;
@@ -758,9 +756,9 @@ namespace basegfx
 }
 
 // Write 'moveto' and the 1st coordinates, set 
aLastSVGCommand to 'lineto'
-putCommandChar(aResult, aLastSVGCommand, 'M', 
bUseRelativeCoordinatesForFirstPoint);
-putNumberChar(aResult, aEdgeStart.getX(), 
aCurrentSVGPosition.getX(), bUseRelativeCoordinatesForFirstPoint);
-putNumberChar(aResult, aEdgeStart.getY(), 
aCurrentSVGPosition.getY(), bUseRelativeCoordinatesForFirstPoint);
+putCommandChar(aResult, aLastSVGCommand, 'M', 
bUseRelativeCoordinatesForFirstPoint, bOOXMLMotionPath);
+putNumberChar(aResult, aEdgeStart.getX(), 
aCurrentSVGPosition.getX(), bUseRelativeCoordinatesForFirstPoint, 
bOOXMLMotionPath);
+putNumberChar(aResult, aEdgeStart.getY(), 
aCurrentSVGPosition.getY(), bUseRelativeCoordinatesForFirstPoint, 
bOOXMLMotionPath);
 aLastSVGCommand =  bUseRelativeCoordinatesForFirstPoint ? 
'l' : 'L';
 aCurrentSVGPosition = aEdgeStart;
 
@@ -793,7 +791,7 @@ namespace basegfx
 // That's what is done from our import, so avoid 
exporting it as first statement
 // is necessary.
 const bool bSymmetricAtEdgeStart(
-nIndex != 0
+!bOOXMLMotionPath && nIndex != 0
 && aPolygon.getContinuityInPoint(nIndex) == 
B2VectorContinuity::C2);
 
 if(bDetectQuadraticBeziers)
@@ -815,20 +813,20 @@ namespace basegfx
 // approximately equal, export as quadratic 
bezier
 if(bSymmetricAtEdgeStart)
 {
-putCommandChar(aResult, aLastSVGCommand, 
'T', bUseRelativeCoordinates);
+putCommandChar(aResult, aLastSVGCommand, 
'T', bUseRelativeCoordinates, bOOXMLMotionPath);
 
-putNumberChar(aResult, aEdgeEnd.getX(), 

[Libreoffice-commits] core.git: basegfx/source include/basegfx slideshow/source xmlhelp/source

2017-12-29 Thread Noel Grandin
 basegfx/source/polygon/b3dpolygon.cxx|2 +-
 include/basegfx/polygon/b3dpolygon.hxx   |2 +-
 slideshow/source/engine/animationnodes/animationbasenode.cxx |2 +-
 slideshow/source/engine/animationnodes/animationbasenode.hxx |2 +-
 slideshow/source/engine/opengl/TransitionerImpl.cxx  |2 +-
 slideshow/source/engine/slide/userpaintoverlay.cxx   |2 +-
 slideshow/source/engine/slide/userpaintoverlay.hxx   |2 +-
 slideshow/source/engine/smilfunctionparser.cxx   |4 ++--
 slideshow/source/inc/smilfunctionparser.hxx  |4 ++--
 xmlhelp/source/cxxhelp/provider/urlparameter.cxx |2 +-
 xmlhelp/source/cxxhelp/provider/urlparameter.hxx |2 +-
 11 files changed, 13 insertions(+), 13 deletions(-)

New commits:
commit e21ae87458b0b6e0ad4cc9b41ed02fc8b6a20736
Author: Noel Grandin 
Date:   Fri Dec 29 09:20:44 2017 +0200

loplugin:passstuffbyref improved return in xmlhelp,slideshow

Change-Id: I57e235ecec733f1b5dd03f95f4e022769a369ae2
Reviewed-on: https://gerrit.libreoffice.org/47165
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b3dpolygon.cxx 
b/basegfx/source/polygon/b3dpolygon.cxx
index d28d31c7f2d8..ed564228e0fb 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -1548,7 +1548,7 @@ namespace basegfx
 mpPolygon->clearBColors();
 }
 
-B3DVector B3DPolygon::getNormal() const
+B3DVector const & B3DPolygon::getNormal() const
 {
 return mpPolygon->getNormal();
 }
diff --git a/include/basegfx/polygon/b3dpolygon.hxx 
b/include/basegfx/polygon/b3dpolygon.hxx
index 765762730f20..1d3dd515b757 100644
--- a/include/basegfx/polygon/b3dpolygon.hxx
+++ b/include/basegfx/polygon/b3dpolygon.hxx
@@ -79,7 +79,7 @@ namespace basegfx
 void clearBColors();
 
 // Normals interface
-B3DVector getNormal() const; // plane normal
+B3DVector const & getNormal() const; // plane normal
 B3DVector getNormal(sal_uInt32 nIndex) const; // normal in each point
 void setNormal(sal_uInt32 nIndex, const B3DVector& rValue);
 void transformNormals(const B3DHomMatrix& rMatrix);
diff --git a/slideshow/source/engine/animationnodes/animationbasenode.cxx 
b/slideshow/source/engine/animationnodes/animationbasenode.cxx
index 678c4a51a9ff..6c7eebed0ad1 100644
--- a/slideshow/source/engine/animationnodes/animationbasenode.cxx
+++ b/slideshow/source/engine/animationnodes/animationbasenode.cxx
@@ -465,7 +465,7 @@ AnimationBaseNode::fillCommonParameters() const
 getSlideSize());
 }
 
-AttributableShapeSharedPtr AnimationBaseNode::getShape() const
+AttributableShapeSharedPtr const & AnimationBaseNode::getShape() const
 {
 // any subsetting at all?
 if (mpShapeSubset)
diff --git a/slideshow/source/engine/animationnodes/animationbasenode.hxx 
b/slideshow/source/engine/animationnodes/animationbasenode.hxx
index d2c03a4ec4d3..84b3d5a82b5e 100644
--- a/slideshow/source/engine/animationnodes/animationbasenode.hxx
+++ b/slideshow/source/engine/animationnodes/animationbasenode.hxx
@@ -56,7 +56,7 @@ protected:
 /// Create parameter struct for ActivitiesFactory
 ActivitiesFactory::CommonParameters fillCommonParameters() const;
 ::basegfx::B2DVector const& getSlideSize() const { return 
maSlideSize; }
-AttributableShapeSharedPtr  getShape() const;
+AttributableShapeSharedPtr const &  getShape() const;
 
 private:
 virtual bool hasPendingAnimation() const override;
diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx 
b/slideshow/source/engine/opengl/TransitionerImpl.cxx
index f8018c0275e6..8e21e6768616 100644
--- a/slideshow/source/engine/opengl/TransitionerImpl.cxx
+++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx
@@ -808,7 +808,7 @@ namespace
 }
 };
 
-uno::Reference
+uno::Reference const &
 getOGLColorSpace()
 {
 return OGLColorSpaceHolder::get();
diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx 
b/slideshow/source/engine/slide/userpaintoverlay.cxx
index f1a1789ad8c9..096efe6b1284 100644
--- a/slideshow/source/engine/slide/userpaintoverlay.cxx
+++ b/slideshow/source/engine/slide/userpaintoverlay.cxx
@@ -468,7 +468,7 @@ namespace slideshow
 mrMultiplexer.addUserPaintHandler(mpHandler);
 }
 
-PolyPolygonVector UserPaintOverlay::getPolygons()
+PolyPolygonVector const & UserPaintOverlay::getPolygons()
 {
 return mpHandler->getPolygons();
 }
diff --git a/slideshow/source/engine/slide/userpaintoverlay.hxx 
b/slideshow/source/engine/slide/userpaintoverlay.hxx
index 4c2e16288c88..3dc6fa976a7f 100644
--- a/slideshow/source/engine/slide/userpaintoverlay.hxx
+++ 

[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/qa vcl/source

2017-03-01 Thread Caolán McNamara
 basegfx/source/range/b2dpolyrange.cxx  |   12 +
 basegfx/source/tools/b2dclipstate.cxx  |   13 
++
 include/basegfx/range/b2dpolyrange.hxx |3 ++
 include/basegfx/tools/b2dclipstate.hxx |3 ++
 vcl/qa/cppunit/graphicfilter/data/emf/fail/slow-moveclip-1.emf |binary
 vcl/source/filter/wmf/winmtf.cxx   |9 +-
 6 files changed, 33 insertions(+), 7 deletions(-)

New commits:
commit d9262e19c942f2719bfa7de3a5059e4f6e0039c6
Author: Caolán McNamara 
Date:   Wed Mar 1 10:35:31 2017 +

ofz: timeout loading emf with move clip record

Change-Id: Id5d60f0037873598e1447b063e66e9c29840587c
Reviewed-on: https://gerrit.libreoffice.org/34740
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/basegfx/source/range/b2dpolyrange.cxx 
b/basegfx/source/range/b2dpolyrange.cxx
index 25117cb..3b86f4f 100644
--- a/basegfx/source/range/b2dpolyrange.cxx
+++ b/basegfx/source/range/b2dpolyrange.cxx
@@ -87,6 +87,13 @@ namespace basegfx
 return tools::solveCrossovers(maRanges,maOrient);
 }
 
+void transform(const basegfx::B2DHomMatrix& rTranslate)
+{
+maBounds.transform(rTranslate);
+for (auto  : maRanges)
+a.transform(rTranslate);
+}
+
 private:
 B2DRange maBounds;
 std::vectormaRanges;
@@ -148,6 +155,11 @@ namespace basegfx
 return mpImpl->overlaps(rRange);
 }
 
+void B2DPolyRange::transform(const basegfx::B2DHomMatrix& rTranslate)
+{
+mpImpl->transform(rTranslate);
+}
+
 B2DPolyPolygon B2DPolyRange::solveCrossovers() const
 {
 return mpImpl->solveCrossovers();
diff --git a/basegfx/source/tools/b2dclipstate.cxx 
b/basegfx/source/tools/b2dclipstate.cxx
index db09324..5ce779c 100644
--- a/basegfx/source/tools/b2dclipstate.cxx
+++ b/basegfx/source/tools/b2dclipstate.cxx
@@ -173,6 +173,13 @@ namespace tools
 addPolyPolygon(rPolyPoly,XOR);
 }
 
+void transform(const basegfx::B2DHomMatrix& rTranslate)
+{
+maPendingRanges.transform(rTranslate);
+maPendingPolygons.transform(rTranslate);
+maClipPoly.transform(rTranslate);
+}
+
 B2DPolyPolygon const & getClipPoly() const
 {
 commitPendingRanges();
@@ -481,6 +488,12 @@ namespace tools
 return mpImpl->getClipPoly();
 }
 
+void B2DClipState::transform(const basegfx::B2DHomMatrix& rTranslate)
+{
+return mpImpl->transform(rTranslate);
+}
+
+
 } // end of namespace tools
 } // end of namespace basegfx
 
diff --git a/include/basegfx/range/b2dpolyrange.hxx 
b/include/basegfx/range/b2dpolyrange.hxx
index f3494c1..bfd3630 100644
--- a/include/basegfx/range/b2dpolyrange.hxx
+++ b/include/basegfx/range/b2dpolyrange.hxx
@@ -30,6 +30,7 @@ namespace basegfx
 class B2DTuple;
 class B2DRange;
 class B2DPolyPolygon;
+class B2DHomMatrix;
 class ImplB2DPolyRange;
 
 /** Multiple ranges in one object.
@@ -84,6 +85,8 @@ namespace basegfx
  */
 B2DPolyPolygon solveCrossovers() const;
 
+void transform(const B2DHomMatrix& rTranslate);
+
 private:
 o3tl::cow_wrapper< ImplB2DPolyRange > mpImpl;
 };
diff --git a/include/basegfx/tools/b2dclipstate.hxx 
b/include/basegfx/tools/b2dclipstate.hxx
index dab598e..865bdd7 100644
--- a/include/basegfx/tools/b2dclipstate.hxx
+++ b/include/basegfx/tools/b2dclipstate.hxx
@@ -31,6 +31,7 @@ namespace basegfx
 class B2DPolyRange;
 class B2DPolygon;
 class B2DPolyPolygon;
+class B2DHomMatrix;
 
 namespace tools
 {
@@ -85,6 +86,8 @@ namespace basegfx
 void xorRange(const B2DRange& );
 void xorPolyPolygon(const B2DPolyPolygon& );
 
+void transform(const B2DHomMatrix& );
+
 B2DPolyPolygon getClipPoly() const;
 };
 }
diff --git a/vcl/qa/cppunit/graphicfilter/data/emf/fail/slow-moveclip-1.emf 
b/vcl/qa/cppunit/graphicfilter/data/emf/fail/slow-moveclip-1.emf
new file mode 100644
index 000..ef4c6a0
Binary files /dev/null and 
b/vcl/qa/cppunit/graphicfilter/data/emf/fail/slow-moveclip-1.emf differ
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index d51db44..028495d 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -78,14 +78,9 @@ void WinMtfClipPath::setClipPath( const tools::PolyPolygon& 
rPolyPolygon, sal_In
 
 void WinMtfClipPath::moveClipRegion( const Size& rSize )
 {
-// what a weird concept. emulate, don't want this in B2DClipState
-// API
-basegfx::B2DPolyPolygon aCurrClip=maClip.getClipPoly();
 basegfx::B2DHomMatrix 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2016-07-25 Thread Tomaž Vajngerl
 basegfx/source/polygon/b2dpolygon.cxx  |9 +
 include/basegfx/polygon/b2dpolygon.hxx |2 ++
 2 files changed, 11 insertions(+)

New commits:
commit eb09e512ae8283f52114c29f4a7d481fa82ab372
Author: Tomaž Vajngerl 
Date:   Fri Jul 22 11:08:22 2016 +0200

basegfx: initializer_list from polygon

Change-Id: I2d6cdb7189217e1fadb1ecf4e11cf4dd04043ec6
Reviewed-on: https://gerrit.libreoffice.org/27475
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index 5ad06ea..4274e62 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1105,6 +1105,15 @@ namespace basegfx
 :   mpPolygon(DefaultPolygon::get())
 {}
 
+B2DPolygon::B2DPolygon(std::initializer_list aPoints)
+: mpPolygon(DefaultPolygon::get())
+{
+for (const basegfx::B2DPoint& rPoint : aPoints)
+{
+append(rPoint);
+}
+}
+
 B2DPolygon::B2DPolygon(const B2DPolygon& rPolygon)
 :   mpPolygon(rPolygon.mpPolygon)
 {}
diff --git a/include/basegfx/polygon/b2dpolygon.hxx 
b/include/basegfx/polygon/b2dpolygon.hxx
index 6ef7693..7bdf771 100644
--- a/include/basegfx/polygon/b2dpolygon.hxx
+++ b/include/basegfx/polygon/b2dpolygon.hxx
@@ -55,6 +55,8 @@ namespace basegfx
 B2DPolygon();
 B2DPolygon(const B2DPolygon& rPolygon);
 B2DPolygon(const B2DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 
nCount);
+B2DPolygon(std::initializer_list rPoints);
+
 ~B2DPolygon();
 
 /// assignment operator
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/opengl

2016-05-17 Thread Tomaž Vajngerl
 basegfx/source/polygon/b2dlinegeometry.cxx  |   29 
 basegfx/source/polygon/b2dpolygon.cxx   |2 -
 include/basegfx/polygon/b2dlinegeometry.hxx |5 
 vcl/opengl/gdiimpl.cxx  |4 ---
 4 files changed, 2 insertions(+), 38 deletions(-)

New commits:
commit 37ed508022e0be8b793caa4748cfee634c1c8a9c
Author: Tomaž Vajngerl 
Date:   Mon May 16 22:25:15 2016 +0900

tdf#99130 use subdivision on B2DPolygon, angle based subdivision

Remove the subdivider we used until now as there is a better
way to subdivide a polygon with getDefaultAdaptiveSubdivision,
which in additiona also caches the result. The subdivider used in
getDefaultAdaptiveSubdivision was a limited count based subdivider
so this exchanges that with an angle based one which gives much
better results.

Change-Id: I95c009ccf3d54305df0d8eef177cab0df0a23bea
Reviewed-on: https://gerrit.libreoffice.org/25033
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx 
b/basegfx/source/polygon/b2dlinegeometry.cxx
index 2177ff4..799604f 100644
--- a/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -779,35 +779,6 @@ namespace basegfx
 
 namespace tools
 {
-B2DPolygon polygonSubdivide(const B2DPolygon& rCandidate, double 
fMaxAllowedAngle, double fMaxPartOfEdge)
-{
-if(fMaxAllowedAngle > F_PI2)
-{
-fMaxAllowedAngle = F_PI2;
-}
-else if(fMaxAllowedAngle < 0.01 * F_PI2)
-{
-fMaxAllowedAngle = 0.01 * F_PI2;
-}
-
-if(fMaxPartOfEdge > 1.0)
-{
-fMaxPartOfEdge = 1.0;
-}
-else if(fMaxPartOfEdge < 0.01)
-{
-fMaxPartOfEdge = 0.01;
-}
-
-B2DPolygon aCandidate(rCandidate);
-const double fMaxCos(cos(fMaxAllowedAngle));
-
-aCandidate.removeDoublePoints();
-aCandidate = subdivideToSimple(aCandidate, fMaxCos * fMaxCos, 
fMaxPartOfEdge * fMaxPartOfEdge);
-
-return aCandidate;
-}
-
 B2DPolyPolygon createAreaGeometry(
 const B2DPolygon& rCandidate,
 double fHalfLineWidth,
diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index f46c377..5ad06ea 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -483,7 +483,7 @@ public:
 {
 if(!mpDefaultSubdivision)
 {
-const_cast< ImplBufferedData* 
>(this)->mpDefaultSubdivision.reset(new 
basegfx::B2DPolygon(basegfx::tools::adaptiveSubdivideByCount(rSource, 9)));
+const_cast< ImplBufferedData* 
>(this)->mpDefaultSubdivision.reset(new 
basegfx::B2DPolygon(basegfx::tools::adaptiveSubdivideByAngle(rSource)));
 }
 
 return *mpDefaultSubdivision;
diff --git a/include/basegfx/polygon/b2dlinegeometry.hxx 
b/include/basegfx/polygon/b2dlinegeometry.hxx
index d336456..5aefafb 100644
--- a/include/basegfx/polygon/b2dlinegeometry.hxx
+++ b/include/basegfx/polygon/b2dlinegeometry.hxx
@@ -138,11 +138,6 @@ namespace basegfx
 double fMaxPartOfEdge = 0.4,
 double fMiterMinimumAngle = (15.0 * F_PI180));
 
-BASEGFX_DLLPUBLIC B2DPolygon polygonSubdivide(
-const B2DPolygon& rCandidate,
-double fMaxAllowedAngle = (12.5 * F_PI180),
-double fMaxPartOfEdge = 0.4);
-
 } // end of namespace tools
 } // end of namespace basegfx
 
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 9048344..bba462f 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -2064,9 +2064,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
 basegfx::B2DPolygon aPolygon(rPolygon);
 
 if (aPolygon.areControlPointsUsed())
-aPolygon = basegfx::tools::polygonSubdivide(aPolygon, 5 * F_PI180);
-else
-aPolygon.removeDoublePoints();
+aPolygon = aPolygon.getDefaultAdaptiveSubdivision();
 
 DrawPolyLine(aPolygon, fLineWidth, eLineJoin, eLineCap, 
fMiterMinimumAngle);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/inc vcl/opengl vcl/Package_opengl.mk

2016-02-25 Thread Tomaž Vajngerl
 basegfx/source/polygon/b2dlinegeometry.cxx  |   29 ++
 include/basegfx/polygon/b2dlinegeometry.hxx |6 
 vcl/Package_opengl.mk   |2 
 vcl/inc/opengl/program.hxx  |4 
 vcl/inc/openglgdiimpl.hxx   |4 
 vcl/opengl/gdiimpl.cxx  |  364 
 vcl/opengl/lineFragmentShader.glsl  |   36 ++
 vcl/opengl/lineVertexShader.glsl|   37 ++
 vcl/opengl/program.cxx  |   10 
 9 files changed, 442 insertions(+), 50 deletions(-)

New commits:
commit d18ad8a7fb3257001a5045e11f3f770a48a7fa69
Author: Tomaž Vajngerl 
Date:   Wed Feb 24 00:44:58 2016 +0100

opengl: shader based polyline rendering - fixes tdf#97137 for OGL

Adds native opengl polyline rendering to draw polylines, line joins
and line caps as triangle strips. The vertex shader allows for the
dynamic line width by calculating the correct vertex posiitons,
and the fragment shader is used for anti-aliasing.

Change-Id: If7982c828cae1fae59c57194c8ac77e5ad7f1d26

diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx 
b/basegfx/source/polygon/b2dlinegeometry.cxx
index 5527dd0..33dd570 100644
--- a/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -779,6 +779,35 @@ namespace basegfx
 
 namespace tools
 {
+B2DPolygon polygonSubdivide(const B2DPolygon& rCandidate, double 
fMaxAllowedAngle, double fMaxPartOfEdge)
+{
+if(fMaxAllowedAngle > F_PI2)
+{
+fMaxAllowedAngle = F_PI2;
+}
+else if(fMaxAllowedAngle < 0.01 * F_PI2)
+{
+fMaxAllowedAngle = 0.01 * F_PI2;
+}
+
+if(fMaxPartOfEdge > 1.0)
+{
+fMaxPartOfEdge = 1.0;
+}
+else if(fMaxPartOfEdge < 0.01)
+{
+fMaxPartOfEdge = 0.01;
+}
+
+B2DPolygon aCandidate(rCandidate);
+const double fMaxCos(cos(fMaxAllowedAngle));
+
+aCandidate.removeDoublePoints();
+aCandidate = subdivideToSimple(aCandidate, fMaxCos * fMaxCos, 
fMaxPartOfEdge * fMaxPartOfEdge);
+
+return aCandidate;
+}
+
 B2DPolyPolygon createAreaGeometry(
 const B2DPolygon& rCandidate,
 double fHalfLineWidth,
diff --git a/include/basegfx/polygon/b2dlinegeometry.hxx 
b/include/basegfx/polygon/b2dlinegeometry.hxx
index 77cafdc..d336456 100644
--- a/include/basegfx/polygon/b2dlinegeometry.hxx
+++ b/include/basegfx/polygon/b2dlinegeometry.hxx
@@ -137,6 +137,12 @@ namespace basegfx
 double fMaxAllowedAngle = (12.5 * F_PI180),
 double fMaxPartOfEdge = 0.4,
 double fMiterMinimumAngle = (15.0 * F_PI180));
+
+BASEGFX_DLLPUBLIC B2DPolygon polygonSubdivide(
+const B2DPolygon& rCandidate,
+double fMaxAllowedAngle = (12.5 * F_PI180),
+double fMaxPartOfEdge = 0.4);
+
 } // end of namespace tools
 } // end of namespace basegfx
 
diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk
index b8851df..a0f6e9a 100644
--- a/vcl/Package_opengl.mk
+++ b/vcl/Package_opengl.mk
@@ -21,6 +21,8 @@ $(eval $(call 
gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\
 invert50FragmentShader.glsl \
convolutionFragmentShader.glsl \
linearGradientFragmentShader.glsl \
+   lineFragmentShader.glsl \
+   lineVertexShader.glsl \
maskFragmentShader.glsl \
maskedTextureVertexShader.glsl \
maskedTextureFragmentShader.glsl \
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
index 5de3c1b..780cba7 100644
--- a/vcl/inc/opengl/program.hxx
+++ b/vcl/inc/opengl/program.hxx
@@ -37,6 +37,7 @@ private:
 GLuint  mnTexCoordAttrib;
 GLuint  mnAlphaCoordAttrib;
 GLuint  mnMaskCoordAttrib;
+GLuint  mnNormalAttrib;
 TextureList maTextures;
 boolmbBlending;
 
@@ -59,6 +60,7 @@ public:
 void SetTextureCoord( const GLvoid* pData );
 void SetAlphaCoord( const GLvoid* pData );
 void SetMaskCoord(const GLvoid* pData);
+void SetExtrusionVectors(const GLvoid* pData);
 
 void SetUniform1f( const OString& rName, GLfloat v1 );
 void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 );
@@ -80,7 +82,7 @@ public:
 bool DrawTexture( const OpenGLTexture& rTexture );
 
 protected:
-void SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* 
pData );
+void SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* 
pData, GLint nSize = 2 );
 GLuint GetUniformLocation( const OString& rName );
 };
 
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 3b62900..f3247f9 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2015-05-27 Thread Zsolt Bölöny
 basegfx/source/range/b3drange.cxx  |1 
 include/basegfx/range/b3drange.hxx |1 
 include/basegfx/range/b3irange.hxx |  230 -
 3 files changed, 232 deletions(-)

New commits:
commit 135ced89b2fd2de02aec2132783543242197d945
Author: Zsolt Bölöny bolony.zs...@gmail.com
Date:   Tue May 19 00:16:44 2015 +0200

Remove B3IRange, it's not used anywhere

Change-Id: I19a6835eaab2efba530d30f871f1b4509b683801
Reviewed-on: https://gerrit.libreoffice.org/15812
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/basegfx/source/range/b3drange.cxx 
b/basegfx/source/range/b3drange.cxx
index b07fcb5..f779f18 100644
--- a/basegfx/source/range/b3drange.cxx
+++ b/basegfx/source/range/b3drange.cxx
@@ -18,7 +18,6 @@
  */
 
 #include basegfx/range/b3drange.hxx
-#include basegfx/range/b3irange.hxx
 #include basegfx/numeric/ftools.hxx
 #include basegfx/matrix/b3dhommatrix.hxx
 
diff --git a/include/basegfx/range/b3drange.hxx 
b/include/basegfx/range/b3drange.hxx
index cf96c16..3ce6925 100644
--- a/include/basegfx/range/b3drange.hxx
+++ b/include/basegfx/range/b3drange.hxx
@@ -28,7 +28,6 @@
 
 namespace basegfx
 {
-class B3IRange;
 class B3DHomMatrix;
 
 class B3DRange
diff --git a/include/basegfx/range/b3irange.hxx 
b/include/basegfx/range/b3irange.hxx
deleted file mode 100644
index 5a51571..000
--- a/include/basegfx/range/b3irange.hxx
+++ /dev/null
@@ -1,230 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the License); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_BASEGFX_RANGE_B3IRANGE_HXX
-#define INCLUDED_BASEGFX_RANGE_B3IRANGE_HXX
-
-#include basegfx/point/b3ipoint.hxx
-#include basegfx/point/b3dpoint.hxx
-#include basegfx/tuple/b3ituple.hxx
-#include basegfx/range/basicrange.hxx
-#include basegfx/basegfxdllapi.h
-
-namespace basegfx
-{
-class B3IRange
-{
-typedef ::basegfx::BasicRange sal_Int32, Int32Traits  MyBasicRange;
-
-MyBasicRangemaRangeX;
-MyBasicRangemaRangeY;
-MyBasicRangemaRangeZ;
-
-public:
-B3IRange() {}
-
-explicit B3IRange(const B3ITuple rTuple)
-:   maRangeX(rTuple.getX()),
-maRangeY(rTuple.getY()),
-maRangeZ(rTuple.getZ())
-{
-}
-
-B3IRange(sal_Int32 x1,
- sal_Int32 y1,
- sal_Int32 z1,
- sal_Int32 x2,
- sal_Int32 y2,
- sal_Int32 z2)
-:   maRangeX(x1),
-maRangeY(y1),
-maRangeZ(z1)
-{
-maRangeX.expand(x2);
-maRangeY.expand(y2);
-maRangeZ.expand(z2);
-}
-
-B3IRange(const B3ITuple rTuple1,
- const B3ITuple rTuple2)
-:   maRangeX(rTuple1.getX()),
-maRangeY(rTuple1.getY()),
-maRangeZ(rTuple1.getZ())
-{
-expand(rTuple2);
-}
-
-bool isEmpty() const
-{
-return maRangeX.isEmpty() || maRangeY.isEmpty() || 
maRangeZ.isEmpty();
-}
-
-void reset()
-{
-maRangeX.reset();
-maRangeY.reset();
-maRangeZ.reset();
-}
-
-bool operator==( const B3IRange rRange ) const
-{
-return (maRangeX == rRange.maRangeX
- maRangeY == rRange.maRangeY
- maRangeZ == rRange.maRangeZ);
-}
-
-bool operator!=( const B3IRange rRange ) const
-{
-return (maRangeX != rRange.maRangeX
-|| maRangeY != rRange.maRangeY
-|| maRangeZ != rRange.maRangeZ);
-}
-
-sal_Int32 getMinX() const
-{
-return maRangeX.getMinimum();
-}
-
-sal_Int32 getMinY() const
-{
-return maRangeY.getMinimum();
-}
-
-sal_Int32 getMinZ() const
-{
-return maRangeZ.getMinimum();
-}
-
-sal_Int32 getMaxX() const
-{
-return maRangeX.getMaximum();
-}
-
-sal_Int32 

[Libreoffice-commits] core.git: basegfx/source include/basegfx

2014-09-22 Thread Noel Grandin
 basegfx/source/inc/hommatrixtemplate.hxx |4 ++--
 basegfx/source/vector/b2dvector.cxx  |2 +-
 include/basegfx/color/bcolor.hxx |2 +-
 include/basegfx/point/b2dpoint.hxx   |2 +-
 include/basegfx/point/b3dpoint.hxx   |2 +-
 include/basegfx/vector/b3dvector.hxx |2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 8e58d9d08caecc868b1f4fed78101c7bdb0834ab
Author: Noel Grandin n...@peralex.com
Date:   Thu Sep 18 14:43:52 2014 +0200

loplugin: cstylecast

Change-Id: I8b1f0f6c100b4cf6d45c9e0c0f1e0a38ec081218

diff --git a/basegfx/source/inc/hommatrixtemplate.hxx 
b/basegfx/source/inc/hommatrixtemplate.hxx
index 93c14f2..2e1be87 100644
--- a/basegfx/source/inc/hommatrixtemplate.hxx
+++ b/basegfx/source/inc/hommatrixtemplate.hxx
@@ -100,8 +100,8 @@ namespace basegfx
 }
 
 // reset last line, it equals default
-delete ((ImplHomMatrixTemplate RowSize *)this)-mpLine;
-((ImplHomMatrixTemplate RowSize *)this)-mpLine = 0L;
+delete const_castImplHomMatrixTemplate RowSize 
*(this)-mpLine;
+const_castImplHomMatrixTemplate RowSize *(this)-mpLine = 
0L;
 
 return true;
 }
diff --git a/basegfx/source/vector/b2dvector.cxx 
b/basegfx/source/vector/b2dvector.cxx
index ace0a0a..2a08fab 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -80,7 +80,7 @@ namespace basegfx
 
 const B2DVector B2DVector::getEmptyVector()
 {
-return (const B2DVector) B2DTuple::getEmptyTuple();
+return static_castconst B2DVector( B2DTuple::getEmptyTuple() );
 }
 
 B2DVector B2DVector::operator*=( const B2DHomMatrix rMat )
diff --git a/include/basegfx/color/bcolor.hxx b/include/basegfx/color/bcolor.hxx
index 457409b..2428b19 100644
--- a/include/basegfx/color/bcolor.hxx
+++ b/include/basegfx/color/bcolor.hxx
@@ -208,7 +208,7 @@ namespace basegfx
 
 static const BColor getEmptyBColor()
 {
-return (const BColor) ::basegfx::B3DTuple::getEmptyTuple();
+return static_castconst BColor( 
::basegfx::B3DTuple::getEmptyTuple() );
 }
 
 com::sun::star::uno::Sequence double  colorToDoubleSequence(const 
com::sun::star::uno::Reference com::sun::star::rendering::XGraphicDevice  
/*xGraphicDevice*/) const
diff --git a/include/basegfx/point/b2dpoint.hxx 
b/include/basegfx/point/b2dpoint.hxx
index cee2170..9c5e35a 100644
--- a/include/basegfx/point/b2dpoint.hxx
+++ b/include/basegfx/point/b2dpoint.hxx
@@ -124,7 +124,7 @@ namespace basegfx
 
 static const B2DPoint getEmptyPoint()
 {
-return (const B2DPoint) ::basegfx::B2DTuple::getEmptyTuple();
+return static_castconst B2DPoint( 
::basegfx::B2DTuple::getEmptyTuple() );
 }
 };
 
diff --git a/include/basegfx/point/b3dpoint.hxx 
b/include/basegfx/point/b3dpoint.hxx
index bd45342..7484c7d 100644
--- a/include/basegfx/point/b3dpoint.hxx
+++ b/include/basegfx/point/b3dpoint.hxx
@@ -124,7 +124,7 @@ namespace basegfx
 
 static const B3DPoint getEmptyPoint()
 {
-return (const B3DPoint) ::basegfx::B3DTuple::getEmptyTuple();
+return static_castconst B3DPoint( 
::basegfx::B3DTuple::getEmptyTuple() );
 }
 };
 
diff --git a/include/basegfx/vector/b3dvector.hxx 
b/include/basegfx/vector/b3dvector.hxx
index a3adbef..d7e5229 100644
--- a/include/basegfx/vector/b3dvector.hxx
+++ b/include/basegfx/vector/b3dvector.hxx
@@ -249,7 +249,7 @@ namespace basegfx
 
 static const B3DVector getEmptyVector()
 {
-return (const B3DVector) ::basegfx::B3DTuple::getEmptyTuple();
+return static_castconst B3DVector( 
::basegfx::B3DTuple::getEmptyTuple() );
 }
 };
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basegfx/source include/basegfx

2014-04-22 Thread Tor Lillqvist
 basegfx/source/polygon/b2dpolypolygontools.cxx  |   18 ++
 include/basegfx/polygon/b2dpolypolygontools.hxx |5 +
 2 files changed, 23 insertions(+)

New commits:
commit a26d592dab62842b97d25045ce8f88a9c068dc97
Author: Tor Lillqvist t...@collabora.com
Date:   Wed Apr 23 08:16:01 2014 +0300

Revert Remove unused 
basegfx::tools::containsOnlyHorizontalAndVerticalEdges

Is used in vcl/win/source/gdi/salgdi.cxx.

This reverts commit 34fa29ed4c0fa73d3e07e62cb6ca2577ee115b35.

Conflicts:
unusedcode.easy

Change-Id: I0ee3c2bc0ec5649045ae415b44482f63da360634

diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx 
b/basegfx/source/polygon/b2dpolypolygontools.cxx
index f904d64..35bc6ed 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -497,6 +497,24 @@ namespace basegfx
 return aRetval;
 }
 
+bool containsOnlyHorizontalAndVerticalEdges(const B2DPolyPolygon 
rCandidate)
+{
+if(rCandidate.areControlPointsUsed())
+{
+return false;
+}
+
+for(sal_uInt32 a(0); a  rCandidate.count(); a++)
+{
+
if(!containsOnlyHorizontalAndVerticalEdges(rCandidate.getB2DPolygon(a)))
+{
+return false;
+}
+}
+
+return true;
+}
+
 B2DPolyPolygon createSevenSegmentPolyPolygon(sal_Char nNumber, bool 
bLitSegments)
 {
 // config here
diff --git a/include/basegfx/polygon/b2dpolypolygontools.hxx 
b/include/basegfx/polygon/b2dpolypolygontools.hxx
index c21489a..e92fe5a 100644
--- a/include/basegfx/polygon/b2dpolypolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolypolygontools.hxx
@@ -287,6 +287,11 @@ namespace basegfx
 */
 BASEGFX_DLLPUBLIC B2DPolyPolygon 
snapPointsOfHorizontalOrVerticalEdges(const B2DPolyPolygon rCandidate);
 
+/** returns true if the Polygon only contains horizontal or vertical 
edges
+so that it could be represented by RegionBands
+*/
+BASEGFX_DLLPUBLIC bool containsOnlyHorizontalAndVerticalEdges(const 
B2DPolyPolygon rCandidate);
+
 /// converters for com::sun::star::drawing::PointSequence
 BASEGFX_DLLPUBLIC B2DPolyPolygon 
UnoPointSequenceSequenceToB2DPolyPolygon(
 const com::sun::star::drawing::PointSequenceSequence 
rPointSequenceSequenceSource,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basegfx/source include/basegfx unusedcode.easy

2014-03-04 Thread Noel Grandin
 basegfx/source/polygon/b2dpolygontools.cxx  |   43 
 basegfx/source/polygon/b2dpolypolygontools.cxx  |   18 ++
 basegfx/source/polygon/b3dpolypolygontools.cxx  |7 +++
 include/basegfx/polygon/b2dpolypolygontools.hxx |5 ++
 unusedcode.easy |3 +
 5 files changed, 76 insertions(+)

New commits:
commit 1f6cce7e52c5007457d1a39263efe54ee87e9fab
Author: Noel Grandin n...@peralex.com
Date:   Wed Mar 5 09:33:59 2014 +0200

Revert remove unused code in basegfx

Some of this code is used by Windows.

This reverts commit b96724560f119b1b9ab8b5e1ee1759fd9b2db203.

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index dc511b9..5a3dfcd 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -3134,6 +3134,49 @@ namespace basegfx
 }
 
 
+// comparators with tolerance for 2D Polygons
+
+bool equal(const B2DPolygon rCandidateA, const B2DPolygon 
rCandidateB, const double rfSmallValue)
+{
+const sal_uInt32 nPointCount(rCandidateA.count());
+
+if(nPointCount != rCandidateB.count())
+return false;
+
+const bool bClosed(rCandidateA.isClosed());
+
+if(bClosed != rCandidateB.isClosed())
+return false;
+
+const bool 
bAreControlPointsUsed(rCandidateA.areControlPointsUsed());
+
+if(bAreControlPointsUsed != rCandidateB.areControlPointsUsed())
+return false;
+
+for(sal_uInt32 a(0); a  nPointCount; a++)
+{
+const B2DPoint aPoint(rCandidateA.getB2DPoint(a));
+
+if(!aPoint.equal(rCandidateB.getB2DPoint(a), rfSmallValue))
+return false;
+
+if(bAreControlPointsUsed)
+{
+const basegfx::B2DPoint 
aPrev(rCandidateA.getPrevControlPoint(a));
+
+if(!aPrev.equal(rCandidateB.getPrevControlPoint(a), 
rfSmallValue))
+return false;
+
+const basegfx::B2DPoint 
aNext(rCandidateA.getNextControlPoint(a));
+
+if(!aNext.equal(rCandidateB.getNextControlPoint(a), 
rfSmallValue))
+return false;
+}
+}
+
+return true;
+}
+
 // snap points of horizontal or vertical edges to discrete values
 B2DPolygon snapPointsOfHorizontalOrVerticalEdges(const B2DPolygon 
rCandidate)
 {
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx 
b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 91fb9bd..d7b2b5f 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -497,6 +497,24 @@ namespace basegfx
 return aRetval;
 }
 
+bool containsOnlyHorizontalAndVerticalEdges(const B2DPolyPolygon 
rCandidate)
+{
+if(rCandidate.areControlPointsUsed())
+{
+return false;
+}
+
+for(sal_uInt32 a(0); a  rCandidate.count(); a++)
+{
+
if(!containsOnlyHorizontalAndVerticalEdges(rCandidate.getB2DPolygon(a)))
+{
+return false;
+}
+}
+
+return true;
+}
+
 B2DPolyPolygon createSevenSegmentPolyPolygon(sal_Char nNumber, bool 
bLitSegments)
 {
 // config here
diff --git a/basegfx/source/polygon/b3dpolypolygontools.cxx 
b/basegfx/source/polygon/b3dpolypolygontools.cxx
index 45bcddc..33c0c67 100644
--- a/basegfx/source/polygon/b3dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolypolygontools.cxx
@@ -505,6 +505,13 @@ namespace basegfx
 return true;
 }
 
+bool equal(const B3DPolyPolygon rCandidateA, const B3DPolyPolygon 
rCandidateB)
+{
+const double fSmallValue(fTools::getSmallValue());
+
+return equal(rCandidateA, rCandidateB, fSmallValue);
+}
+
 /// converters for com::sun::star::drawing::PolyPolygonShape3D
 B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon(
 const com::sun::star::drawing::PolyPolygonShape3D 
rPolyPolygonShape3DSource,
diff --git a/include/basegfx/polygon/b2dpolypolygontools.hxx 
b/include/basegfx/polygon/b2dpolypolygontools.hxx
index c21489a..e92fe5a 100644
--- a/include/basegfx/polygon/b2dpolypolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolypolygontools.hxx
@@ -287,6 +287,11 @@ namespace basegfx
 */
 BASEGFX_DLLPUBLIC B2DPolyPolygon 
snapPointsOfHorizontalOrVerticalEdges(const B2DPolyPolygon rCandidate);
 
+/** returns true if the Polygon only contains horizontal or vertical 
edges
+so that it could be represented by RegionBands
+*/
+BASEGFX_DLLPUBLIC bool 

[Libreoffice-commits] core.git: basegfx/source include/basegfx svgio/inc svgio/source

2013-10-11 Thread Armin Le Grand
 basegfx/source/polygon/b2dpolygontools.cxx   |   82 +++
 include/basegfx/polygon/b2dpolygontools.hxx  |8 
 svgio/inc/svgio/svgreader/svgstyleattributes.hxx |8 
 svgio/source/svgreader/svgstyleattributes.cxx|  269 +++
 4 files changed, 230 insertions(+), 137 deletions(-)

New commits:
commit 66c803ebcb4bc164ca5af1cf752aeb645735f186
Author: Armin Le Grand a...@apache.org
Date:   Fri Oct 11 16:57:46 2013 +

Resolves: #i123379# various SVG marker corrections

(cherry picked from commit ff1eee61fc56b06e436735f5e2b133db56de3608)

Conflicts:
basegfx/inc/basegfx/polygon/b2dpolygontools.hxx

Change-Id: I818657573a1e673e312702a4b45e7bb6394250d2

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index de75b15..583fa3e 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -3226,6 +3226,88 @@ namespace basegfx
 return true;
 }
 
+B2DVector getTangentEnteringPoint(const B2DPolygon rCandidate, 
sal_uInt32 nIndex)
+{
+B2DVector aRetval(0.0, 0.0);
+const sal_uInt32 nCount(rCandidate.count());
+
+if(nIndex = nCount)
+{
+// out of range
+return aRetval;
+}
+
+// start immediately at prev point compared to nIndex
+const bool bClosed(rCandidate.isClosed());
+sal_uInt32 nPrev(bClosed ? (nIndex + nCount - 1) % nCount : nIndex 
? nIndex - 1 : nIndex);
+
+if(nPrev == nIndex)
+{
+// no previous, done
+return aRetval;
+}
+
+B2DCubicBezier aSegment;
+
+// go backward in the polygon; if closed, maximal back to start 
index (nIndex); if not closed,
+// until zero. Use nIndex as stop criteria
+while(nPrev != nIndex)
+{
+// get BezierSegment and tangent at the *end* of segment
+rCandidate.getBezierSegment(nPrev, aSegment);
+aRetval = aSegment.getTangent(1.0);
+
+if(!aRetval.equalZero())
+{
+// if we have a tangent, return it
+return aRetval;
+}
+
+// prepare index before checked one
+nPrev = bClosed ? (nPrev + nCount - 1) % nCount : nPrev ? 
nPrev - 1 : nIndex;
+}
+
+return aRetval;
+}
+
+B2DVector getTangentLeavingPoint(const B2DPolygon rCandidate, 
sal_uInt32 nIndex)
+{
+B2DVector aRetval(0.0, 0.0);
+const sal_uInt32 nCount(rCandidate.count());
+
+if(nIndex = nCount)
+{
+// out of range
+return aRetval;
+}
+
+// start at nIndex
+const bool bClosed(rCandidate.isClosed());
+sal_uInt32 nCurrent(nIndex);
+B2DCubicBezier aSegment;
+
+// go forward; if closed, do this until once around and back at 
start index (nIndex); if not
+// closed, until last point (nCount - 1). Use nIndex as stop 
criteria
+do
+{
+// get BezierSegment and tangent at the *beginning* of segment
+rCandidate.getBezierSegment(nCurrent, aSegment);
+aRetval = aSegment.getTangent(0.0);
+
+if(!aRetval.equalZero())
+{
+// if we have a tangent, return it
+return aRetval;
+}
+
+// prepare next index
+nCurrent = bClosed ? (nCurrent + 1) % nCount : nCurrent + 1  
nCount ? nCurrent + 1 : nIndex;
+}
+while(nCurrent != nIndex);
+
+return aRetval;
+}
+
 } // end of namespace tools
 } // end of namespace basegfx
 
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx 
b/include/basegfx/polygon/b2dpolygontools.hxx
index 3be763b..af5559e 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -439,6 +439,14 @@ namespace basegfx
 */
 bool containsOnlyHorizontalAndVerticalEdges(const B2DPolygon 
rCandidate);
 
+/// get the tangent with which the given point is entered seen from 
the previous
+/// polygon path data. Take into account all stuff like closed state, 
zero-length edges and others.
+BASEGFX_DLLPUBLIC B2DVector getTangentEnteringPoint(const B2DPolygon 
rCandidate, sal_uInt32 nIndex);
+
+/// get the tangent with which the given point is left seen from the 
following
+/// polygon path data. Take into account all stuff like closed state, 
zero-length edges and others.
+BASEGFX_DLLPUBLIC B2DVector getTangentLeavingPoint(const B2DPolygon 
rCandidate, sal_uInt32 nIndex);
+
 } //