[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 chart2/import_setup.mk chart2/Library_chartcontroller.mk chart2/qa chart2/source docmodel/Library_docmodel.mk docmodel/source include/basegfx include/doc

2023-08-21 Thread Tomaž Vajngerl (via logerrit)
 basegfx/source/tools/bgradient.cxx  |  167 -
 chart2/Library_chartcontroller.mk   |3 
 chart2/import_setup.mk  |1 
 chart2/qa/extras/chart2import.cxx   |5 
 chart2/source/controller/main/ChartController_Tools.cxx |4 
 docmodel/Library_docmodel.mk|2 
 docmodel/source/uno/UnoGradientTools.cxx|  200 
 include/basegfx/utils/bgradient.hxx |   22 -
 include/docmodel/uno/UnoGradientTools.hxx   |   33 ++
 oox/qa/unit/drawingml.cxx   |4 
 oox/qa/unit/shape.cxx   |   23 +
 oox/source/drawingml/fillproperties.cxx |5 
 oox/source/drawingml/fontworkhelpers.cxx|5 
 oox/source/export/chartexport.cxx   |   13 -
 oox/source/export/drawingml.cxx |   12 
 sd/CppunitTest_sd_misc_tests.mk |1 
 sd/export_setup.mk  |1 
 sd/qa/unit/export-tests-ooxml1.cxx  |7 
 sd/qa/unit/export-tests-ooxml2.cxx  |4 
 sd/qa/unit/export-tests-ooxml3.cxx  |7 
 sd/qa/unit/import-tests.cxx |1 
 sd/qa/unit/import-tests2.cxx|1 
 sd/qa/unit/misc-tests.cxx   |6 
 svx/source/unodraw/XPropertyTable.cxx   |   24 -
 svx/source/xoutdev/xattr.cxx|   17 -
 sw/CppunitTest_sw_odfexport.mk  |1 
 sw/qa/extras/odfexport/odfexport.cxx|5 
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx   |5 
 sw/qa/extras/rtfexport/rtfexport.cxx|5 
 sw/rtfexport_setup.mk   |1 
 xmloff/source/style/GradientStyle.cxx   |3 
 xmloff/source/style/TransGradientStyle.cxx  |3 
 32 files changed, 329 insertions(+), 262 deletions(-)

New commits:
commit 242bb3fdda5be165bd00701518df47cc1276438f
Author: Tomaž Vajngerl 
AuthorDate: Wed Aug 9 13:27:49 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Aug 21 09:27:12 2023 +0200

move BGradient to awt::Gradient2 UNO conversion into docmodel

This is needed because the module dependencies are an issues if
the conversion is done in basegfx. The bigger issue will come when
the ComplexColor conversion will be done as basegfx can't depend on
docmodel because of circular dependencies.

The BGradient is also more suitable for docmodel anyway as the
previously it was part of the model and is not a basic (gfx)
type - however this doesn't move the whole BGradient into docmodel
yet.

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

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index 7b62a19c9ad6..86e1812d21ac 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -68,41 +68,6 @@ basegfx::BGradient lcl_buildGradientFromStringMap(StringMap& 
rMap)
 
 namespace basegfx
 {
-void BColorStops::setColorStopSequence(const css::awt::ColorStopSequence& 
rColorStops)
-{
-const sal_Int32 nLen(rColorStops.getLength());
-
-if (0 != nLen)
-{
-// we have ColorStops
-reserve(nLen);
-const css::awt::ColorStop* 
pSourceColorStop(rColorStops.getConstArray());
-
-for (sal_Int32 a(0); a < nLen; a++, pSourceColorStop++)
-{
-emplace_back(pSourceColorStop->StopOffset,
- BColor(pSourceColorStop->StopColor.Red, 
pSourceColorStop->StopColor.Green,
-pSourceColorStop->StopColor.Blue));
-}
-}
-}
-
-BColorStops::BColorStops(const css::awt::ColorStopSequence& rColorStops)
-{
-setColorStopSequence(rColorStops);
-}
-
-BColorStops::BColorStops(const css::uno::Any& rVal)
-{
-if (rVal.has())
-{
-// we can use awt::ColorStopSequence
-css::awt::ColorStopSequence aColorStopSequence;
-rVal >>= aColorStopSequence;
-setColorStopSequence(aColorStopSequence);
-}
-}
-
 // constructor with two colors to explicitly create a
 // BColorStops for a single StartColor @0.0 & EndColor @1.0
 BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd)
@@ -498,28 +463,6 @@ bool BColorStops::checkPenultimate() const
 return true;
 }
 
-/* Tooling method to fill a awt::ColorStopSequence with
-the data from the given ColorStops. This is used in
-UNO API implementations.
-*/
-css::awt::ColorStopSequence BColorStops::getAsColorStopSequence() const
-{
-

[Libreoffice-commits] core.git: basegfx/source compilerplugins/clang emfio/source sd/source toolkit/source vcl/source

2023-07-21 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dsvgpolypolygon.cxx|4 ++--
 compilerplugins/clang/redundantcast.cxx |9 +
 compilerplugins/clang/test/redundantcast.cxx|   12 
 emfio/source/reader/mtftools.cxx|2 +-
 sd/source/ui/dlg/animobjs.cxx   |2 +-
 sd/source/ui/dlg/titledockwin.cxx   |2 +-
 toolkit/source/controls/table/gridtablerenderer.cxx |2 +-
 vcl/source/window/window.cxx|2 +-
 8 files changed, 28 insertions(+), 7 deletions(-)

New commits:
commit 1f2ff4a0a31c7919bc6d4e0ac63024252f0bd889
Author: Noel Grandin 
AuthorDate: Thu Jul 20 15:55:59 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Jul 21 11:05:05 2023 +0200

loplugin:redundantcast small improvement

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

diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx 
b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index 6bb34614c6ae..fe4f646eb3ba 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -272,7 +272,7 @@ namespace basegfx::utils
 
 // get first control point. It's the reflection of 
the PrevControlPoint
 // of the last point. If not existent, use current 
point (see SVG)
-B2DPoint aPrevControl(B2DPoint(nLastX, nLastY));
+B2DPoint aPrevControl(nLastX, nLastY);
 const sal_uInt32 nIndex(aCurrPoly.count() - 1);
 
 if(aCurrPoly.areControlPointsUsed() && 
aCurrPoly.isPrevControlPointUsed(nIndex))
@@ -421,7 +421,7 @@ namespace basegfx::utils
 
 // get first control point. It's the reflection of 
the PrevControlPoint
 // of the last point. If not existent, use current 
point (see SVG)
-B2DPoint aPrevControl(B2DPoint(nLastX, nLastY));
+B2DPoint aPrevControl(nLastX, nLastY);
 const sal_uInt32 nIndex(aCurrPoly.count() - 1);
 const B2DPoint 
aPrevPoint(aCurrPoly.getB2DPoint(nIndex));
 
diff --git a/compilerplugins/clang/redundantcast.cxx 
b/compilerplugins/clang/redundantcast.cxx
index 80485e0e9bd6..eea609005228 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -373,6 +373,15 @@ bool RedundantCast::VisitVarDecl(VarDecl const * varDecl) {
 if (!varDecl->getInit())
 return true;
 visitAssign(varDecl->getType(), varDecl->getInit());
+if (varDecl->getInitStyle() != VarDecl::CInit
+&& isa(varDecl->getInit())
+&& 
!compiler.getSourceManager().isMacroBodyExpansion(varDecl->getInit()->getBeginLoc()))
+{
+report(
+DiagnosticsEngine::Warning, "redundant functional cast",
+varDecl->getBeginLoc())
+<< varDecl->getSourceRange();
+}
 return true;
 }
 
diff --git a/compilerplugins/clang/test/redundantcast.cxx 
b/compilerplugins/clang/test/redundantcast.cxx
index 0c1087ab32af..f3573d0ad20d 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -473,6 +473,18 @@ void testSalIntTypes() {
 (void) static_cast(n); // doesn't warn either
 }
 
+void testFunctionalCast2() {
+struct S1 { S1(int, int, int, int) {} };
+
+// expected-error@+1 {{redundant functional cast [loplugin:redundantcast]}}
+S1 aTitleBarBox(S1(0, 0, 0, 0));
+(void)aTitleBarBox;
+
+// no warning expected
+#define S1_COL S1(0,0,0,0)
+S1 aTest2(S1_COL);
+}
+
 int main() {
 testConstCast();
 testStaticCast();
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index f2446e1864de..0ba13d49727a 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -256,7 +256,7 @@ namespace emfio
 
 aFont.SetOrientation( 
Degree10(static_cast(rFont.lfEscapement)) );
 
-Size aFontSize( Size( rFont.lfWidth, rFont.lfHeight ) );
+Size aFontSize( rFont.lfWidth, rFont.lfHeight );
 if ( rFont.lfHeight > 0 )
 {
 // #i117968# VirtualDevice is not thread safe, but filter is used 
in multithreading
diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index 9abb892e037c..0174855e1825 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -516,7 +516,7 @@ void AnimationWindow::UpdateControl(bool const 
bDisableCtrls)
 ScopedVclPtrInstance< VirtualDevice > pVD;
 ::tools::Rectangle   aObjRect( pObject->GetCurrentBoundRect() 
);
 SizeaObjSize( aObjRect.GetSize() );
-Point  

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

2023-07-13 Thread Tomaž Vajngerl (via logerrit)
 basegfx/source/tools/canvastools.cxx   |   12 -
 canvas/source/cairo/cairo_canvasbitmap.cxx |4 
 canvas/source/cairo/cairo_canvashelper.cxx |   12 -
 canvas/source/cairo/cairo_devicehelper.cxx |   10 -
 canvas/source/cairo/cairo_spritecanvashelper.cxx   |   28 +--
 canvas/source/cairo/cairo_spritedevicehelper.cxx   |6 
 canvas/source/directx/dx_9rm.cxx   |   92 
--
 canvas/source/directx/dx_bitmap.cxx|   18 -
 canvas/source/directx/dx_bitmap.hxx|   10 -
 canvas/source/directx/dx_bitmapcanvashelper.cxx|1 
 canvas/source/directx/dx_canvasbitmap.cxx  |   42 ++--
 canvas/source/directx/dx_canvascustomsprite.cxx|2 
 canvas/source/directx/dx_canvashelper.cxx  |4 
 canvas/source/directx/dx_ibitmap.hxx   |2 
 canvas/source/directx/dx_rendermodule.hxx  |2 
 canvas/source/directx/dx_spritedevicehelper.cxx|2 
 canvas/source/directx/dx_surfacebitmap.cxx |   52 ++---
 canvas/source/directx/dx_surfacebitmap.hxx |8 
 canvas/source/directx/dx_textlayout_drawhelper.cxx |4 
 canvas/source/tools/page.cxx   |   11 -
 canvas/source/tools/page.hxx   |3 
 canvas/source/tools/pagemanager.cxx|7 
 canvas/source/tools/surface.cxx|   36 +--
 canvas/source/tools/surfaceproxy.cxx   |   16 -
 canvas/source/tools/surfacerect.hxx|   16 -
 include/basegfx/tuple/Size2D.hxx   |2 
 include/basegfx/utils/canvastools.hxx  |5 
 include/basegfx/vector/b2dsize.hxx |   12 +
 include/basegfx/vector/b2isize.hxx |   38 +++-
 include/vcl/outdev.hxx |2 
 slideshow/source/engine/slide/slideimpl.cxx|   11 -
 slideshow/source/engine/slideshowimpl.cxx  |5 
 slideshow/source/engine/tools.cxx  |8 
 slideshow/source/engine/transitions/combtransition.cxx |4 
 slideshow/source/engine/transitions/slidechangebase.cxx|   20 +-
 slideshow/source/engine/transitions/slidetransitionfactory.cxx |6 
 slideshow/source/inc/tools.hxx |2 
 37 files changed, 271 insertions(+), 244 deletions(-)

New commits:
commit f896bbcffeccd27248f908d2628d03dddf83ea94
Author: Tomaž Vajngerl 
AuthorDate: Wed Sep 21 12:17:00 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jul 13 13:19:00 2023 +0200

basegfx: replace typedef with a class B2ISize based on Size2D

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

diff --git a/basegfx/source/tools/canvastools.cxx 
b/basegfx/source/tools/canvastools.cxx
index d388356199a2..70f4787710ad 100644
--- a/basegfx/source/tools/canvastools.cxx
+++ b/basegfx/source/tools/canvastools.cxx
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -427,16 +428,15 @@ namespace basegfx::unotools
 rRect.Z2);
 }
 
-geometry::IntegerSize2D integerSize2DFromB2ISize( const 
::basegfx::B2IVector& rSize )
+geometry::IntegerSize2D integerSize2DFromB2ISize( const 
::basegfx::B2ISize& rSize )
 {
-return geometry::IntegerSize2D( rSize.getX(),
-rSize.getY() );
+return geometry::IntegerSize2D( rSize.getWidth(),
+rSize.getHeight() );
 }
 
-::basegfx::B2IVector b2ISizeFromIntegerSize2D( const 
geometry::IntegerSize2D& rSize )
+basegfx::B2ISize b2ISizeFromIntegerSize2D( const 
geometry::IntegerSize2D& rSize )
 {
-return ::basegfx::B2IVector( rSize.Width,
- rSize.Height );
+return basegfx::B2ISize(rSize.Width, rSize.Height);
 }
 
 ::basegfx::B2IRange b2IRectangleFromIntegerRectangle2D( const 
geometry::IntegerRectangle2D& rRectangle )
diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx 
b/canvas/source/cairo/cairo_canvasbitmap.cxx
index ebf4f26c5321..9f18be80824a 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.cxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.cxx
@@ -48,7 +48,7 @@ namespace cairocanvas
 
 SAL_INFO(
 "canvas.cairo",
-"bitmap size: " << rSize.getX() << "x" << 

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

2023-07-10 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   40 +++---
 basegfx/test/BColorModifierTest.cxx |   88 +---
 include/basegfx/color/bcolormodifier.hxx|6 -
 svgio/inc/svgtools.hxx  |3 
 svgio/source/svgreader/svgfecolormatrixnode.cxx |4 -
 svgio/source/svgreader/svgtools.cxx |   26 +--
 6 files changed, 92 insertions(+), 75 deletions(-)

New commits:
commit fa61e8b220aa1f34b022b9af485f0209b2cb25d1
Author: Xisco Fauli 
AuthorDate: Mon Jul 10 11:52:30 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 10 13:52:56 2023 +0200

tdf#99562: Do not ignore last column from matrix

Change-Id: I1dff65963e2c414d1771a1592159930150c513e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154241
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 4d3f277c6cc5..75c06f5cb8f3 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -155,23 +155,41 @@ namespace basegfx
 return false;
 }
 
-return maMatrix == pCompare->maMatrix;
+return maVector == pCompare->maVector;
 }
 
 ::basegfx::BColor BColorModifier_matrix::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
 {
-basegfx::B3DHomMatrix aColorMatrix;
-aColorMatrix.set(0, 0, aSourceColor.getRed());
-aColorMatrix.set(1, 0, aSourceColor.getGreen());
-aColorMatrix.set(2, 0, aSourceColor.getBlue());
-aColorMatrix.set(3, 0, 1.0);
-// TODO: add support for alpha
+if (maVector.size() != 20)
+return aSourceColor;
+
+const double aRed = maVector[0] * aSourceColor.getRed()
++ maVector[1] * aSourceColor.getGreen()
++ maVector[2] * aSourceColor.getBlue()
++ maVector[3] * 1.0
++ maVector[4];
+const double aGreen = maVector[5] * aSourceColor.getRed()
++ maVector[6] * aSourceColor.getGreen()
++ maVector[7] * aSourceColor.getBlue()
++ maVector[8] * 1.0
++ maVector[9];
+const double aBlue = maVector[10] * aSourceColor.getRed()
++ maVector[11] * aSourceColor.getGreen()
++ maVector[12] * aSourceColor.getBlue()
++ maVector[13] * 1.0
++ maVector[14];
+/*TODO: add support for alpha
+const double aAlpha = maVector[15] * aSourceColor.getRed()
++ maVector[16] * aSourceColor.getGreen()
++ maVector[17] * aSourceColor.getBlue()
++ maVector[18] * 1.0
++ maVector[19]);
+*/
 
-aColorMatrix = maMatrix * aColorMatrix;
 return ::basegfx::BColor(
-std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
-std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
-std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
+std::clamp(aRed, 0.0, 1.0),
+std::clamp(aGreen, 0.0, 1.0),
+std::clamp(aBlue, 0.0, 1.0));
 }
 
 OUString BColorModifier_matrix::getModifierName() const
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 237f6a982266..4a84c3662a6b 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -272,26 +272,15 @@ public:
 void testMatrix()
 {
 // green matrix
-basegfx::B3DHomMatrix aMatrix;
-aMatrix.set(0, 0, 0.0);
-aMatrix.set(0, 1, 0.0);
-aMatrix.set(0, 2, 0.0);
-aMatrix.set(0, 3, 0.0);
-aMatrix.set(1, 0, 1.0);
-aMatrix.set(1, 1, 1.0);
-aMatrix.set(1, 2, 1.0);
-aMatrix.set(1, 3, 1.0);
-aMatrix.set(2, 0, 0.0);
-aMatrix.set(2, 1, 0.0);
-aMatrix.set(2, 2, 0.0);
-aMatrix.set(2, 3, 0.0);
-aMatrix.set(3, 0, 0.0);
-aMatrix.set(3, 1, 0.0);
-aMatrix.set(3, 2, 0.0);
-aMatrix.set(3, 3, 1.0);
+// clang-format off
+std::vector aVector = {0.0, 0.0, 0.0, 0.0, 0.0,
+   1.0, 1.0, 1.0, 1.0, 0.0,
+   0.0, 0.0, 0.0, 0.0, 0.0,
+   0.0, 0.0, 0.0, 1.0, 0.0};
+// clang-format on
 
 const basegfx::BColorModifierSharedPtr aBColorModifier
-= std::make_shared(aMatrix);
+= std::make_shared(aVector);
 
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maWhite));
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGray));
@@ -310,32 +299,54 @@ public:
 CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
 
 const basegfx::BColorModifierSharedPtr aBColorModifier2
-= std::make_shared(aMatrix);
+= std::make_shared(aVector);
+

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

2023-07-07 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |6 +-
 basegfx/test/BColorModifierTest.cxx |   17 ++---
 2 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 22e46544eebe027654bb4ecfc42e8d8ebb41ec48
Author: Xisco Fauli 
AuthorDate: Fri Jul 7 14:44:00 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 7 17:50:28 2023 +0200

related: tdf#155735: clamp RGB values

So when a green matrix is used, everything becomes green.
Also set alpha to 1.0 so at least a green matrix on black returns
green and not black

Change-Id: I9104c7511545fb244750b066bb1e996b6ce229f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154167
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 9c9a196bb7f8..4d3f277c6cc5 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -164,10 +164,14 @@ namespace basegfx
 aColorMatrix.set(0, 0, aSourceColor.getRed());
 aColorMatrix.set(1, 0, aSourceColor.getGreen());
 aColorMatrix.set(2, 0, aSourceColor.getBlue());
+aColorMatrix.set(3, 0, 1.0);
 // TODO: add support for alpha
 
 aColorMatrix = maMatrix * aColorMatrix;
-return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 
0), aColorMatrix.get(2, 0));
+return ::basegfx::BColor(
+std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
 }
 
 OUString BColorModifier_matrix::getModifierName() const
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 3a08958018da..237f6a982266 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -293,21 +293,16 @@ public:
 const basegfx::BColorModifierSharedPtr aBColorModifier
 = std::make_shared(aMatrix);
 
-BColor aExpectedWhite(0.0, 3.0, 0.0);
-CPPUNIT_ASSERT_EQUAL(aExpectedWhite, 
aBColorModifier->getModifiedColor(maWhite));
-BColor aExpectedGray(0.0, 1.5, 0.0);
-CPPUNIT_ASSERT_EQUAL(aExpectedGray, 
aBColorModifier->getModifiedColor(maGray));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maWhite));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maBlack));
 
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maRed));
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGreen));
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maBlue));
-BColor aExpectedYellow(0.0, 2.0, 0.0);
-CPPUNIT_ASSERT_EQUAL(aExpectedYellow, 
aBColorModifier->getModifiedColor(maYellow));
-BColor aExpectedMagenta = aExpectedYellow;
-CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, 
aBColorModifier->getModifiedColor(maMagenta));
-BColor aExpectedCyan = aExpectedYellow;
-CPPUNIT_ASSERT_EQUAL(aExpectedCyan, 
aBColorModifier->getModifiedColor(maCyan));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maYellow));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maMagenta));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maCyan));
 
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
 const basegfx::BColorModifierSharedPtr aBColorModifierInvert


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

2023-07-04 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dlinegeometry.cxx|   23 ++-
 comphelper/source/property/propmultiplex2.cxx |   10 +++---
 include/basegfx/polygon/b2dlinegeometry.hxx   |3 +--
 include/comphelper/propmultiplex2.hxx |4 +---
 include/svx/svdotable.hxx |2 +-
 oox/source/drawingml/shape.cxx|2 +-
 svx/source/table/svdotable.cxx|4 ++--
 7 files changed, 15 insertions(+), 33 deletions(-)

New commits:
commit 203476b6676505acafd1c41561800afd9316a0f6
Author: Noel Grandin 
AuthorDate: Tue Jul 4 16:12:19 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 4 20:19:06 2023 +0200

loplugin:constantparam

Change-Id: Iee554baae7239c9bf0ac35cab6ff235a88dc29a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153973
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx 
b/basegfx/source/polygon/b2dlinegeometry.cxx
index 6dda8f9e7e1f..37c7cfc172d2 100644
--- a/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -848,8 +848,7 @@ namespace basegfx
 css::drawing::LineCap eCap,
 double fMaxAllowedAngle,
 double fMaxPartOfEdge,
-double fMiterMinimumAngle,
-basegfx::triangulator::B2DTriangleVector* pTriangles)
+double fMiterMinimumAngle)
 {
 if(fMaxAllowedAngle > M_PI_2)
 {
@@ -959,7 +958,7 @@ namespace basegfx
 fHalfLineWidth,
 eJoin,
 fMiterMinimumAngle,
-pTriangles));
+nullptr));
 }
 else if(aOrientation == 
B2VectorOrientation::Negative)
 {
@@ -976,7 +975,7 @@ namespace basegfx
 fHalfLineWidth,
 eJoin,
 fMiterMinimumAngle,
-pTriangles));
+nullptr));
 }
 }
 
@@ -995,7 +994,7 @@ namespace basegfx
 bLast && eCap == 
css::drawing::LineCap_ROUND,
 bFirst && eCap == 
css::drawing::LineCap_SQUARE,
 bLast && eCap == 
css::drawing::LineCap_SQUARE,
-pTriangles));
+nullptr));
 }
 else
 {
@@ -1007,7 +1006,7 @@ namespace basegfx
 false,
 false,
 false,
-pTriangles));
+nullptr));
 }
 
 // prepare next step
@@ -1030,17 +1029,7 @@ namespace basegfx
 aCandidate.getB2DPoint(0),
 fHalfLineWidth));
 
-if(nullptr != pTriangles)
-{
-const basegfx::triangulator::B2DTriangleVector aResult(
-basegfx::triangulator::triangulate(
-aCircle));
-pTriangles->insert(pTriangles->end(), aResult.begin(), 
aResult.end());
-}
-else
-{
-aRetval.append(aCircle);
-}
+aRetval.append(aCircle);
 }
 
 return aRetval;
diff --git a/comphelper/source/property/propmultiplex2.cxx 
b/comphelper/source/property/propmultiplex2.cxx
index 16c06c3bc1f9..b9d7719c4e1d 100644
--- a/comphelper/source/property/propmultiplex2.cxx
+++ b/comphelper/source/property/propmultiplex2.cxx
@@ -51,14 +51,12 @@ void 
OPropertyChangeListener2::setAdapter(std::unique_lock& /*rGuard
 OPropertyChangeMultiplexer2::OPropertyChangeMultiplexer2(std::mutex& rMutex,
  
std::unique_lock& rGuard,
  
OPropertyChangeListener2* _pListener,
- const 
Reference& _rxSet,
- bool _bAutoReleaseSet)
+ const 
Reference& _rxSet)
 : m_rMutex(rMutex)
 , m_xSet(_rxSet)
 , m_pListener(_pListener)
 , m_nLockCount(0)
 , m_bListening(false)
-, m_bAutoSetRelease(_bAutoReleaseSet)
 {
 m_pListener->setAdapter(rGuard, this);
 }
@@ -84,8 +82,7 @@ 

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

2023-06-26 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx  |   19 ---
 basegfx/test/BColorModifierTest.cxx  |   27 
 include/basegfx/color/bcolormodifier.hxx |   20 
 svgio/inc/svgfecolormatrixnode.hxx   |2 -
 svgio/inc/svgfegaussianblurnode.hxx  |2 -
 svgio/inc/svgfilternode.hxx  |6 ---
 svgio/qa/cppunit/SvgImportTest.cxx   |3 -
 svgio/qa/cppunit/data/filterFeGaussianBlur.svg   |2 -
 svgio/source/svgreader/svgfecolormatrixnode.cxx  |   21 -
 svgio/source/svgreader/svgfegaussianblurnode.cxx |   37 ++-
 10 files changed, 6 insertions(+), 133 deletions(-)

New commits:
commit 9951ffedd6941234447b9655fbc49ed6ca4cc64c
Author: Xisco Fauli 
AuthorDate: Mon Jun 26 22:16:12 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jun 26 23:15:03 2023 +0200

Revert "tdf#132246, tdf#155735: Add support for SourceAlpha"

This reverts commit 75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c.

it was incomplete.
While at it, do not parse 'in' attribute for now, so only
in="SourceGraphic" is used.
Implementing the 'in' attribute is not trivial

Change-Id: I66c721c1144638f5e3759e0aa3a1c2c062499a90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153627
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 1ed19a4003eb..9c9a196bb7f8 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -69,25 +69,6 @@ namespace basegfx
 return "invert";
 }
 
-BColorModifier_alpha::~BColorModifier_alpha()
-{
-}
-
-bool BColorModifier_alpha::operator==(const BColorModifier& rCompare) const
-{
-return dynamic_cast< const BColorModifier_alpha* >() != 
nullptr;
-}
-
-::basegfx::BColor BColorModifier_alpha::getModifiedColor(const 
::basegfx::BColor& /*aSourceColor*/) const
-{
-return ::basegfx::BColor(0.0, 0.0, 0.0);
-}
-
-OUString BColorModifier_alpha::getModifierName() const
-{
-return "alpha";
-}
-
 BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha()
 {
 }
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 5ada0a33ddf9..3a08958018da 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -389,32 +389,6 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
-void testAlpha()
-{
-const basegfx::BColorModifierSharedPtr aBColorModifier
-= std::make_shared();
-
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maWhite));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGray));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
-
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maRed));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGreen));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlue));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maYellow));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maMagenta));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maCyan));
-
-CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
-const basegfx::BColorModifierSharedPtr aBColorModifierInvert
-= std::make_shared();
-CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
-
-const basegfx::BColorModifierSharedPtr aBColorModifier2
-= std::make_shared();
-CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
-}
-
 CPPUNIT_TEST_SUITE(bcolormodifier);
 CPPUNIT_TEST(testGray);
 CPPUNIT_TEST(testInvert);
@@ -426,7 +400,6 @@ public:
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testIdentityMatrix);
 CPPUNIT_TEST(testBlackAndWhite);
-CPPUNIT_TEST(testAlpha);
 CPPUNIT_TEST_SUITE_END();
 };
 
diff --git a/include/basegfx/color/bcolormodifier.hxx 
b/include/basegfx/color/bcolormodifier.hxx
index 37c6a5b9e2f3..6eb40b67e9d7 100644
--- a/include/basegfx/color/bcolormodifier.hxx
+++ b/include/basegfx/color/bcolormodifier.hxx
@@ -126,26 +126,6 @@ namespace basegfx
 SAL_DLLPRIVATE virtual OUString getModifierName() const override;
 };
 
-/**
- * convert to alpha
-*/
-class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColorModifier_alpha final : 
public BColorModifier
-{
-public:
-BColorModifier_alpha()
-{
-}
-
-virtual ~BColorModifier_alpha() override;
-
-// compare operator
-SAL_DLLPRIVATE virtual bool operator==(const BColorModifier& rCompare) 

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

2023-06-25 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |1 +
 basegfx/test/BColorModifierTest.cxx |   11 +++
 2 files changed, 12 insertions(+)

New commits:
commit 99b1459dbbe5faa47b5fc9b4ed767932d46a02cb
Author: Xisco Fauli 
AuthorDate: Sun Jun 25 19:45:33 2023 +0200
Commit: Xisco Fauli 
CommitDate: Sun Jun 25 23:05:34 2023 +0200

tdf#155735: use 4x4 matrices in tests

Change-Id: I7258443036eb89e7a67fce2a683f3212972a7395
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153565
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 52f34a69f205..1ed19a4003eb 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -183,6 +183,7 @@ namespace basegfx
 aColorMatrix.set(0, 0, aSourceColor.getRed());
 aColorMatrix.set(1, 0, aSourceColor.getGreen());
 aColorMatrix.set(2, 0, aSourceColor.getBlue());
+// TODO: add support for alpha
 
 aColorMatrix = maMatrix * aColorMatrix;
 return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 
0), aColorMatrix.get(2, 0));
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 5a4b941e1c44..5ada0a33ddf9 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -285,6 +285,10 @@ public:
 aMatrix.set(2, 1, 0.0);
 aMatrix.set(2, 2, 0.0);
 aMatrix.set(2, 3, 0.0);
+aMatrix.set(3, 0, 0.0);
+aMatrix.set(3, 1, 0.0);
+aMatrix.set(3, 2, 0.0);
+aMatrix.set(3, 3, 1.0);
 
 const basegfx::BColorModifierSharedPtr aBColorModifier
 = std::make_shared(aMatrix);
@@ -321,12 +325,19 @@ public:
 aMatrix.set(0, 0, 1.0);
 aMatrix.set(0, 1, 0.0);
 aMatrix.set(0, 2, 0.0);
+aMatrix.set(0, 3, 0.0);
 aMatrix.set(1, 0, 0.0);
 aMatrix.set(1, 1, 1.0);
 aMatrix.set(1, 2, 0.0);
+aMatrix.set(1, 3, 0.0);
 aMatrix.set(2, 0, 0.0);
 aMatrix.set(2, 1, 0.0);
 aMatrix.set(2, 2, 1.0);
+aMatrix.set(2, 3, 0.0);
+aMatrix.set(3, 0, 0.0);
+aMatrix.set(3, 1, 0.0);
+aMatrix.set(3, 2, 0.0);
+aMatrix.set(3, 3, 1.0);
 
 const basegfx::BColorModifierSharedPtr aBColorModifier
 = std::make_shared(aMatrix);


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

2023-06-24 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx  |   19 
 basegfx/test/BColorModifierTest.cxx  |   27 +++
 include/basegfx/color/bcolormodifier.hxx |   20 +
 svgio/inc/svgfecolormatrixnode.hxx   |2 +
 svgio/inc/svgfegaussianblurnode.hxx  |   14 ---
 svgio/inc/svgfilternode.hxx  |6 +
 svgio/qa/cppunit/SvgImportTest.cxx   |3 +-
 svgio/qa/cppunit/data/filterFeGaussianBlur.svg   |2 -
 svgio/source/svgreader/svgfecolormatrixnode.cxx  |   21 +
 svgio/source/svgreader/svgfegaussianblurnode.cxx |   18 +--
 10 files changed, 115 insertions(+), 17 deletions(-)

New commits:
commit 75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c
Author: Xisco Fauli 
AuthorDate: Sat Jun 24 11:17:16 2023 +0200
Commit: Xisco Fauli 
CommitDate: Sat Jun 24 12:33:12 2023 +0200

tdf#132246, tdf#155735: Add support for SourceAlpha

Change-Id: I8feae2447b17e15113ca45fe46c0d68cb6b6ab71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153550
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 829b0abda659..52f34a69f205 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -69,6 +69,25 @@ namespace basegfx
 return "invert";
 }
 
+BColorModifier_alpha::~BColorModifier_alpha()
+{
+}
+
+bool BColorModifier_alpha::operator==(const BColorModifier& rCompare) const
+{
+return dynamic_cast< const BColorModifier_alpha* >() != 
nullptr;
+}
+
+::basegfx::BColor BColorModifier_alpha::getModifiedColor(const 
::basegfx::BColor& /*aSourceColor*/) const
+{
+return ::basegfx::BColor(0.0, 0.0, 0.0);
+}
+
+OUString BColorModifier_alpha::getModifierName() const
+{
+return "alpha";
+}
+
 BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha()
 {
 }
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 6be160ce43ae..5a4b941e1c44 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -378,6 +378,32 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
+void testAlpha()
+{
+const basegfx::BColorModifierSharedPtr aBColorModifier
+= std::make_shared();
+
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maWhite));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maRed));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGreen));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlue));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maYellow));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maMagenta));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maCyan));
+
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
+const basegfx::BColorModifierSharedPtr aBColorModifierInvert
+= std::make_shared();
+CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
+
+const basegfx::BColorModifierSharedPtr aBColorModifier2
+= std::make_shared();
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
+}
+
 CPPUNIT_TEST_SUITE(bcolormodifier);
 CPPUNIT_TEST(testGray);
 CPPUNIT_TEST(testInvert);
@@ -389,6 +415,7 @@ public:
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testIdentityMatrix);
 CPPUNIT_TEST(testBlackAndWhite);
+CPPUNIT_TEST(testAlpha);
 CPPUNIT_TEST_SUITE_END();
 };
 
diff --git a/include/basegfx/color/bcolormodifier.hxx 
b/include/basegfx/color/bcolormodifier.hxx
index 6eb40b67e9d7..37c6a5b9e2f3 100644
--- a/include/basegfx/color/bcolormodifier.hxx
+++ b/include/basegfx/color/bcolormodifier.hxx
@@ -126,6 +126,26 @@ namespace basegfx
 SAL_DLLPRIVATE virtual OUString getModifierName() const override;
 };
 
+/**
+ * convert to alpha
+*/
+class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColorModifier_alpha final : 
public BColorModifier
+{
+public:
+BColorModifier_alpha()
+{
+}
+
+virtual ~BColorModifier_alpha() override;
+
+// compare operator
+SAL_DLLPRIVATE virtual bool operator==(const BColorModifier& rCompare) 
const override;
+
+// compute modified color
+SAL_DLLPRIVATE virtual ::basegfx::BColor getModifiedColor(const 
::basegfx::BColor& aSourceColor) const override;
+SAL_DLLPRIVATE virtual OUString 

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

2023-06-22 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   32 +
 basegfx/test/BColorModifierTest.cxx |   85 
 include/basegfx/color/bcolormodifier.hxx|   28 +++
 svgio/inc/svgfecolormatrixnode.hxx  |3 
 svgio/inc/svgtools.hxx  |2 
 svgio/qa/cppunit/SvgImportTest.cxx  |8 +-
 svgio/source/svgreader/svgfecolormatrixnode.cxx |   13 +++
 svgio/source/svgreader/svgtools.cxx |   34 +
 8 files changed, 200 insertions(+), 5 deletions(-)

New commits:
commit e121f7b37c48b6d843dfdd1d774d2a40567c46c7
Author: Xisco Fauli 
AuthorDate: Fri Jun 16 11:50:57 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 22 17:19:27 2023 +0200

tdf#155735: Add support for matrix type

Change-Id: Icc172c5f47731ddcf0beca64c72c2022313e74a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153177
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 8d6f99a3faf5..829b0abda659 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -142,6 +142,38 @@ namespace basegfx
 return "interpolate";
 }
 
+BColorModifier_matrix::~BColorModifier_matrix()
+{
+}
+
+bool BColorModifier_matrix::operator==(const BColorModifier& rCompare) 
const
+{
+const BColorModifier_matrix* pCompare = dynamic_cast< const 
BColorModifier_matrix* >();
+
+if(!pCompare)
+{
+return false;
+}
+
+return maMatrix == pCompare->maMatrix;
+}
+
+::basegfx::BColor BColorModifier_matrix::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
+{
+basegfx::B3DHomMatrix aColorMatrix;
+aColorMatrix.set(0, 0, aSourceColor.getRed());
+aColorMatrix.set(1, 0, aSourceColor.getGreen());
+aColorMatrix.set(2, 0, aSourceColor.getBlue());
+
+aColorMatrix = maMatrix * aColorMatrix;
+return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 
0), aColorMatrix.get(2, 0));
+}
+
+OUString BColorModifier_matrix::getModifierName() const
+{
+return "matrix";
+}
+
 BColorModifier_saturate::BColorModifier_saturate(double fValue)
 {
 maSatMatrix.set(0, 0, 0.213 + 0.787 * fValue);
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index d6e0648d2c17..17b6a0c22257 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -269,6 +269,89 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
+void testMatrix()
+{
+// green matrix
+basegfx::B3DHomMatrix aMatrix;
+aMatrix.set(0, 0, 0.0);
+aMatrix.set(0, 1, 0.0);
+aMatrix.set(0, 2, 0.0);
+aMatrix.set(0, 3, 0.0);
+aMatrix.set(1, 0, 1.0);
+aMatrix.set(1, 1, 1.0);
+aMatrix.set(1, 2, 1.0);
+aMatrix.set(1, 3, 1.0);
+aMatrix.set(2, 0, 0.0);
+aMatrix.set(2, 1, 0.0);
+aMatrix.set(2, 2, 0.0);
+aMatrix.set(2, 3, 0.0);
+
+const basegfx::BColorModifierSharedPtr aBColorModifier
+= std::make_shared(aMatrix);
+
+BColor aExpectedWhite(0.0, 3.0, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedWhite, 
aBColorModifier->getModifiedColor(maWhite));
+BColor aExpectedGray(0.0, 1.5, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedGray, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maRed));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGreen));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maBlue));
+BColor aExpectedYellow(0.0, 2.0, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedYellow, 
aBColorModifier->getModifiedColor(maYellow));
+BColor aExpectedMagenta = aExpectedYellow;
+CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, 
aBColorModifier->getModifiedColor(maMagenta));
+BColor aExpectedCyan = aExpectedYellow;
+CPPUNIT_ASSERT_EQUAL(aExpectedCyan, 
aBColorModifier->getModifiedColor(maCyan));
+
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
+const basegfx::BColorModifierSharedPtr aBColorModifierInvert
+= std::make_shared();
+CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
+
+const basegfx::BColorModifierSharedPtr aBColorModifier2
+= std::make_shared(aMatrix);
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
+}
+
+void testIdentityMatrix()
+{
+basegfx::B3DHomMatrix aMatrix;
+aMatrix.set(0, 0, 1.0);
+aMatrix.set(0, 1, 0.0);
+aMatrix.set(0, 2, 

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

2023-06-22 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   51 
 basegfx/test/BColorModifierTest.cxx |   33 +++
 include/basegfx/color/bcolormodifier.hxx|   25 +++
 svgio/inc/svgfecolormatrixnode.hxx  |3 -
 svgio/qa/cppunit/SvgImportTest.cxx  |4 -
 svgio/source/svgreader/svgfecolormatrixnode.cxx |   27 
 6 files changed, 132 insertions(+), 11 deletions(-)

New commits:
commit a62513e1e80e39f9928e9e1815a84761403a4f2b
Author: Xisco Fauli 
AuthorDate: Thu Jun 15 12:19:39 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 22 08:23:53 2023 +0200

tdf#155735: Add support for hueRotate type

Change-Id: I9c7ada2908c0739708fbc9e28ac58430350da7a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153112
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 480af66e7588..8d6f99a3faf5 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -187,6 +187,57 @@ namespace basegfx
 return "saturate";
 }
 
+BColorModifier_hueRotate::BColorModifier_hueRotate(double fRad)
+{
+const double fCos = cos(fRad);
+const double fSin = sin(fRad);
+
+maHueMatrix.set(0, 0, 0.213 + fCos * 0.787 - fSin * 0.213);
+maHueMatrix.set(0, 1, 0.715 - fCos * 0.715 - fSin * 0.715);
+maHueMatrix.set(0, 2, 0.072 - fCos * 0.072 + fSin * 0.928);
+maHueMatrix.set(1, 0, 0.213 - fCos * 0.213 + fSin * 0.143);
+maHueMatrix.set(1, 1, 0.715 + fCos * 0.285 + fSin * 0.140);
+maHueMatrix.set(1, 2, 0.072 - fCos * 0.072 - fSin * 0.283);
+maHueMatrix.set(2, 0, 0.213 - fCos * 0.213 - fSin * 0.787);
+maHueMatrix.set(2, 1, 0.715 - fCos * 0.715 + fSin * 0.715);
+maHueMatrix.set(2, 2, 0.072 + fCos * 0.928 + fSin * 0.072);
+}
+
+BColorModifier_hueRotate::~BColorModifier_hueRotate()
+{
+}
+
+bool BColorModifier_hueRotate::operator==(const BColorModifier& rCompare) 
const
+{
+const BColorModifier_hueRotate* pCompare = dynamic_cast< const 
BColorModifier_hueRotate* >();
+
+if(!pCompare)
+{
+return false;
+}
+
+return maHueMatrix == pCompare->maHueMatrix;
+}
+
+::basegfx::BColor BColorModifier_hueRotate::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
+{
+basegfx::B3DHomMatrix aColorMatrix;
+aColorMatrix.set(0, 0, aSourceColor.getRed());
+aColorMatrix.set(1, 0, aSourceColor.getGreen());
+aColorMatrix.set(2, 0, aSourceColor.getBlue());
+
+aColorMatrix = maHueMatrix * aColorMatrix;
+return ::basegfx::BColor(
+std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
+}
+
+OUString BColorModifier_hueRotate::getModifierName() const
+{
+return "hueRotate";
+}
+
 BColorModifier_black_and_white::~BColorModifier_black_and_white()
 {
 }
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 053540018206..d6e0648d2c17 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -237,6 +237,38 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
+void testHueRotate()
+{
+const basegfx::BColorModifierSharedPtr aBColorModifier
+= 
std::make_shared(basegfx::deg2rad(180.0));
+
+CPPUNIT_ASSERT_EQUAL(maWhite, 
aBColorModifier->getModifiedColor(maWhite));
+CPPUNIT_ASSERT_EQUAL(maGray, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+
+BColor aExpectedRed(0.0, 0.426, 0.426);
+CPPUNIT_ASSERT_EQUAL(aExpectedRed, 
aBColorModifier->getModifiedColor(maRed));
+BColor aExpectedGreen(1.0, 0.43, 1.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedGreen, 
aBColorModifier->getModifiedColor(maGreen));
+BColor aExpectedBlue(0.144, 0.144, 0);
+CPPUNIT_ASSERT_EQUAL(aExpectedBlue, 
aBColorModifier->getModifiedColor(maBlue));
+BColor aExpectedYellow(0.856, 0.856, 1.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedYellow, 
aBColorModifier->getModifiedColor(maYellow));
+BColor aExpectedMagenta(0.0, 0.57, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, 
aBColorModifier->getModifiedColor(maMagenta));
+BColor aExpectedCyan(1.0, 0.574, 0.574);
+CPPUNIT_ASSERT_EQUAL(aExpectedCyan, 
aBColorModifier->getModifiedColor(maCyan));
+
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
+const basegfx::BColorModifierSharedPtr aBColorModifierInvert
+= std::make_shared();
+

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

2023-06-16 Thread Regina Henschel (via logerrit)
 basegfx/source/tools/bgradient.cxx  |   14 
 oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp |  637 
 oox/qa/unit/mcgr.cxx|   25 
 oox/source/export/drawingml.cxx |   10 
 4 files changed, 679 insertions(+), 7 deletions(-)

New commits:
commit 2b1b2a758cc4666c6cf6b14773281dfe1f30
Author: Regina Henschel 
AuthorDate: Thu Jun 15 22:18:34 2023 +0200
Commit: Regina Henschel 
CommitDate: Fri Jun 16 10:35:23 2023 +0200

tdf#155852 same method for StepCount in OOXML as in rendering

Rendering of stepped gradients uses a method that doesn't take the
color from a cut point, but before or after respectively. For example,
for StepCount 4, the colors at relative positions 0, 1/3, 2/3 and 1
are used. So sections are 'start color', '1/3 color', '2/3 color' and
'end color'. The output to OOXML now uses the same method. That way
rendering in a produced pptx-file is the same as in the original
odp-file. Since OOXML has nothing similar to StepCount, it is an export
only problem.

A second problem comes from the cuddle with StepCount in Gradient
struct in API and FillStepCount in shape property set. The
draw:gradient-stop-count attribute in ODF belongs to the graphic style
of the shape. The gradient definition itself in the 
element has nothing about step count. When a file is opened, it can be
that the StepCount component in the Gradient struct still has the
default value 0, but the FillStepCount property has the correct value
of the shape.

The Gradient struct in the API should not have a component StepCount
to be compatible with ODF. But the API is published and changing that
struct is far-reaching in the code. So the fix here is not a general
solution but solves the problem for export to OOXML by reading the
FillStepCount property while exporting.

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

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index d46530074787..7b62a19c9ad6 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -746,7 +746,6 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount)
 // the same color as the previous one ended
 aNewColorStops.push_back(*aColorL);
 }
-
 if (!basegfx::fTools::equalZero(fDelta))
 {
 // create in-between steps, always two at the same position to
@@ -757,20 +756,21 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount)
 if (rStartColor != rEndColor)
 {
 // get relative single-step width
-const double fSingleStep(1.0 / 
static_cast(nStepCount));
+// tdf155852 Use same method for the color as in rendering.
+const double fSingleStep(1.0 / static_cast(nStepCount 
- 1));
+const double fOffsetStep(fDelta / 
static_cast(nStepCount));
 
 for (sal_uInt16 a(1); a < nStepCount; a++)
 {
-// calculate position since being used twice
-const double fPosition(fStart
-   + (fDelta * (static_cast(a) 
* fSingleStep)));
+// calculate stop position since being used twice
+const double fPosition(fStart + fOffsetStep * 
static_cast(a));
 
-// add start color of sub-segment
+// add end color of previous sub-segment
 aNewColorStops.emplace_back(
 fPosition, basegfx::interpolate(rStartColor, rEndColor,
 static_cast(a 
- 1) * fSingleStep));
 
-// add end color of sub-segment
+// add start color of current sub-segment
 aNewColorStops.emplace_back(
 fPosition, basegfx::interpolate(rStartColor, rEndColor,
 static_cast(a) 
* fSingleStep));
diff --git a/oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp 
b/oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp
new file mode 100644
index ..309cb3b0b1b9
--- /dev/null
+++ b/oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp
@@ -0,0 +1,637 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 

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

2023-06-14 Thread Regina Henschel (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |2 
 oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp |  642 
++
 oox/qa/unit/mcgr.cxx|   10 
 3 files changed, 654 insertions(+)

New commits:
commit f3f64c77585d0c3c01c0d960f4959e18e9668c30
Author: Regina Henschel 
AuthorDate: Wed Jun 14 15:53:19 2023 +0200
Commit: Caolán McNamara 
CommitDate: Wed Jun 14 21:29:50 2023 +0200

tdf155825 result same size in synchronize gradients

While synchronizing color and transparency gradients two new sequences
are generated. In case the last offsets where different, the remaining
stops where not copied to the new sequence and thus they had different
sizes which triggered an assert in oox/source/export/drawingml.cxx.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index f79895bc8b8b..8f3e8ae83c06 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -441,6 +441,7 @@ namespace basegfx
 {
 const double fColorOff(aCurrColor->getStopOffset());
 aNewAlpha.emplace_back(fColorOff, 
rAlphaStops.getInterpolatedBColor(fColorOff, 0, aAlphaStopRange));
+aNewColor.emplace_back(fColorOff, 
aCurrColor->getStopColor());
 bRealChange = true;
 aCurrColor++;
 }
@@ -448,6 +449,7 @@ namespace basegfx
 {
 const double fAlphaOff(aCurrAlpha->getStopOffset());
 aNewColor.emplace_back(fAlphaOff, 
rColorStops.getInterpolatedBColor(fAlphaOff, 0, aColorStopRange));
+aNewAlpha.emplace_back(fAlphaOff, 
aCurrAlpha->getStopColor());
 bRealChange = true;
 aCurrAlpha++;
 }
diff --git a/oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp 
b/oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp
new file mode 100644
index ..97b39689d51d
--- /dev/null
+++ b/oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp
@@ -0,0 +1,642 @@
+
+
+http://openoffice.org/2004/office; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xforms="http://www.w3.org/2002/xforms; 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns
 :css3t="http://www.w3.org/TR/css3-text/; 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" 
xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" 
xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.presentation">
+ 
2023-06-14T00:44:04.1630024x16impressPT3M3S3B2020/24.2.0.0.alpha0$Windows_X86_64
 
LibreOffice_project/0028c2311ca14669ca530cd4db422cd3cf9438caRegina
 

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

2023-06-14 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx  |   74 +++
 drawinglayer/source/tools/primitive2dxmldump.cxx |   12 ++-
 include/basegfx/color/bcolormodifier.hxx |   40 
 svgio/inc/svgfecolormatrixnode.hxx   |6 +
 svgio/inc/svgtoken.hxx   |1 
 svgio/qa/cppunit/SvgImportTest.cxx   |   21 +-
 svgio/qa/cppunit/data/filterSaturate.svg |   11 +++
 svgio/source/svgreader/svgfecolormatrixnode.cxx  |   29 -
 svgio/source/svgreader/svgtoken.cxx  |2 
 9 files changed, 183 insertions(+), 13 deletions(-)

New commits:
commit 41bf4139cab36984cff514bfdd6b1b13576746a3
Author: Xisco Fauli 
AuthorDate: Wed Jun 14 12:39:06 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jun 14 21:08:17 2023 +0200

tdf#155735: Add support for saturate type

Add getModifierName to BColorModifier class so when
can assert which modifier is being used

Change-Id: I2bc2a36470a449df4dc84a8440f232149c1f8278
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153048
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index f27ffcc9aaf0..2067257015b4 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -45,6 +45,11 @@ namespace basegfx
 return ::basegfx::BColor(fLuminance, fLuminance, fLuminance);
 }
 
+OUString BColorModifier_gray::getModifierName() const
+{
+return "gray";
+}
+
 BColorModifier_invert::~BColorModifier_invert()
 {
 }
@@ -59,6 +64,11 @@ namespace basegfx
 return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - 
aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue());
 }
 
+OUString BColorModifier_invert::getModifierName() const
+{
+return "invert";
+}
+
 BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha()
 {
 }
@@ -75,6 +85,11 @@ namespace basegfx
 return ::basegfx::BColor(fAlpha, fAlpha, fAlpha);
 }
 
+OUString BColorModifier_luminance_to_alpha::getModifierName() const
+{
+return "luminance_to_alpha";
+}
+
 BColorModifier_replace::~BColorModifier_replace()
 {
 }
@@ -96,6 +111,11 @@ namespace basegfx
 return maBColor;
 }
 
+OUString BColorModifier_replace::getModifierName() const
+{
+return "replace";
+}
+
 BColorModifier_interpolate::~BColorModifier_interpolate()
 {
 }
@@ -117,6 +137,40 @@ namespace basegfx
 return interpolate(maBColor, aSourceColor, mfValue);
 }
 
+OUString BColorModifier_interpolate::getModifierName() const
+{
+return "interpolate";
+}
+
+BColorModifier_saturate::~BColorModifier_saturate()
+{
+}
+
+bool BColorModifier_saturate::operator==(const BColorModifier& rCompare) 
const
+{
+const BColorModifier_saturate* pCompare = dynamic_cast< const 
BColorModifier_saturate* >();
+
+if(!pCompare)
+{
+return false;
+}
+
+return mfValue == pCompare->mfValue;
+}
+
+::basegfx::BColor BColorModifier_saturate::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
+{
+return basegfx::BColor(
+(0.213 + 0.787 * mfValue) * aSourceColor.getRed() + (0.715 - 0.715 
* mfValue) * aSourceColor.getGreen() + (0.072 - 0.072 * mfValue) * 
aSourceColor.getBlue(),
+(0.213 - 0.213 * mfValue) * aSourceColor.getRed() + (0.715 + 0.285 
* mfValue) * aSourceColor.getGreen() + (0.072 - 0.072 * mfValue) * 
aSourceColor.getBlue(),
+(0.213 - 0.213 * mfValue) * aSourceColor.getRed() + (0.715 - 0.715 
* mfValue) * aSourceColor.getGreen() + (0.072 + 0.928 * mfValue) * 
aSourceColor.getBlue());
+}
+
+OUString BColorModifier_saturate::getModifierName() const
+{
+return "saturate";
+}
+
 BColorModifier_black_and_white::~BColorModifier_black_and_white()
 {
 }
@@ -147,6 +201,11 @@ namespace basegfx
 }
 }
 
+OUString BColorModifier_black_and_white::getModifierName() const
+{
+return "black_and_white";
+}
+
 BColorModifier_gamma::BColorModifier_gamma(double fValue)
 :   mfValue(fValue),
 mfInvValue(fValue),
@@ -193,6 +252,11 @@ namespace basegfx
 }
 }
 
+OUString BColorModifier_gamma::getModifierName() const
+{
+return "gamma";
+}
+
 
BColorModifier_RGBLuminanceContrast::BColorModifier_RGBLuminanceContrast(double 
fRed, double fGreen, double fBlue, double fLuminance, double fContrast)
 :   mfRed(std::clamp(fRed, -1.0, 1.0)),
 mfGreen(std::clamp(fGreen, -1.0, 1.0)),
@@ -270,6 +334,11 @@ namespace basegfx
 }
 }
 
+OUString BColorModifier_RGBLuminanceContrast::getModifierName() const
+{
+return "RGBLuminanceContrast";
+}
+
 

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

2023-06-13 Thread buldi (via logerrit)
 basegfx/source/polygon/b2dpolygonclipper.cxx  |   16 +++
 basegfx/source/polygon/b2dpolygoncutandtouch.cxx  |6 --
 basegfx/source/polygon/b2dpolygontriangulator.cxx |9 +---
 basegfx/source/polygon/b2dpolypolygoncutter.cxx   |   46 +++---
 basegfx/source/polygon/b3dpolypolygontools.cxx|   27 +---
 5 files changed, 41 insertions(+), 63 deletions(-)

New commits:
commit 65a20a85c20ddc87d66445657404a46041bcf6e1
Author: buldi 
AuthorDate: Mon Mar 13 23:09:18 2023 +0100
Commit: Hossein 
CommitDate: Tue Jun 13 09:23:54 2023 +0200

tdf#145538 Refactor to use range-based for-loop

Change-Id: I7c75593fef6d3226011a938349850dc485b763c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148204
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx 
b/basegfx/source/polygon/b2dpolygonclipper.cxx
index e9099b730578..e2f1f060381e 100644
--- a/basegfx/source/polygon/b2dpolygonclipper.cxx
+++ b/basegfx/source/polygon/b2dpolygonclipper.cxx
@@ -162,12 +162,11 @@ namespace basegfx::utils
 
 B2DPolyPolygon clipPolyPolygonOnParallelAxis(const B2DPolyPolygon& 
rCandidate, bool bParallelToXAxis, bool bAboveAxis, double fValueOnOtherAxis, 
bool bStroke)
 {
-const sal_uInt32 nPolygonCount(rCandidate.count());
 B2DPolyPolygon aRetval;
 
-for(sal_uInt32 a(0); a < nPolygonCount; a++)
+for(const auto& rB2DPolygon : rCandidate )
 {
-const B2DPolyPolygon 
aClippedPolyPolygon(clipPolygonOnParallelAxis(rCandidate.getB2DPolygon(a), 
bParallelToXAxis, bAboveAxis, fValueOnOtherAxis, bStroke));
+const B2DPolyPolygon 
aClippedPolyPolygon(clipPolygonOnParallelAxis(rB2DPolygon, bParallelToXAxis, 
bAboveAxis, fValueOnOtherAxis, bStroke));
 
 if(aClippedPolyPolygon.count())
 {
@@ -284,10 +283,9 @@ namespace basegfx::utils
 
 B2DPolyPolygon clipPolyPolygonOnRange(const B2DPolyPolygon& 
rCandidate, const B2DRange& rRange, bool bInside, bool bStroke)
 {
-const sal_uInt32 nPolygonCount(rCandidate.count());
 B2DPolyPolygon aRetval;
 
-if(!nPolygonCount)
+if(!rCandidate.count())
 {
 // source is empty
 return aRetval;
@@ -309,9 +307,9 @@ namespace basegfx::utils
 
 if(bInside)
 {
-for(sal_uInt32 a(0); a < nPolygonCount; a++)
+for( const auto& rClippedPoly : rCandidate)
 {
-const B2DPolyPolygon 
aClippedPolyPolygon(clipPolygonOnRange(rCandidate.getB2DPolygon(a), rRange, 
bInside, bStroke));
+const B2DPolyPolygon 
aClippedPolyPolygon(clipPolygonOnRange(rClippedPoly , rRange, bInside, 
bStroke));
 
 if(aClippedPolyPolygon.count())
 {
@@ -345,10 +343,10 @@ namespace basegfx::utils
 // line clipping, create line snippets by first adding all 
cut points and
 // then marching along the edges and detecting if they are 
inside or outside
 // the clip polygon
-for(sal_uInt32 a(0); a < rCandidate.count(); a++)
+for(const auto& rPolygon : rCandidate)
 {
 // add cuts with clip to polygon, including bezier 
segments
-const B2DPolygon 
aCandidate(addPointsAtCuts(rCandidate.getB2DPolygon(a), rClip));
+const B2DPolygon aCandidate(addPointsAtCuts(rPolygon, 
rClip));
 const sal_uInt32 nPointCount(aCandidate.count());
 const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? 
nPointCount : nPointCount - 1);
 B2DCubicBezier aEdge;
diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx 
b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
index d5ab5887da61..92a0abce6c77 100644
--- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
+++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
@@ -179,14 +179,12 @@ namespace basegfx
 // (as in adaptiveSubdivideByCount) it is now possible to 
calculate back the
 // cut positions in the polygon to relative cut positions on the 
original bezier
 // segment.
-const sal_uInt32 nTempPointCount(rPointVector.size());
 const sal_uInt32 nEdgeCount(rPolygon.count() ? rPolygon.count() - 
1 : 0);
 
-if(nTempPointCount && nEdgeCount)
+if(!rPointVector.empty() && nEdgeCount)
 {
-for(sal_uInt32 a(0); a < nTempPointCount; a++)
+for( const auto& rTempPoint : rPointVector )
 {
-const temporaryPoint& rTempPoint = rPointVector[a];
 const double 
fCutPosInPolygon(static_cast(rTempPoint.getIndex()) + 

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

2023-06-09 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/bgradient.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit cdc015ffd4b2460a9235db72a5411c421ab0e2d4
Author: Andrea Gelmini 
AuthorDate: Fri Jun 9 13:25:36 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Jun 9 17:57:39 2023 +0200

Fix typo

Change-Id: Iaebe55927771985a6b574b2cb9410b0eb75441e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152789
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index 61a58b5e3cdb..d46530074787 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -749,7 +749,7 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount)
 
 if (!basegfx::fTools::equalZero(fDelta))
 {
-// create in-between steps, always two at the same positon to
+// create in-between steps, always two at the same position to
 // define a 'hard' color stop. Get start/end color for the segment
 const basegfx::BColor& rStartColor(aColorL->getStopColor());
 const basegfx::BColor& rEndColor(aColorR->getStopColor());


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

2023-06-09 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/bgradient.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e1dcf9464e56c0eee9f662f82928b3f99ba78217
Author: Andrea Gelmini 
AuthorDate: Fri Jun 9 13:25:06 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Jun 9 17:57:06 2023 +0200

Fix typo

Change-Id: Ib02cc0e9aaf286d8c39523ea352cfeec17a6336f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152788
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index c96cd0b673cb..61a58b5e3cdb 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -681,7 +681,7 @@ bool BColorStops::isSymmetrical() const
 
 void BColorStops::doApplyAxial()
 {
-// preapare new ColorStops
+// prepare new ColorStops
 basegfx::BColorStops aNewColorStops;
 
 // add gradient stops in reverse order, scaled to [0.0 .. 0.5]


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

2023-06-09 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/bgradient.cxx |  137 
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |  188 +---
 filter/source/svg/svgexport.cxx|3 
 filter/source/svg/svgwriter.cxx|  198 +++--
 filter/source/svg/svgwriter.hxx|   10 
 include/basegfx/utils/bgradient.hxx|   17 +
 include/svx/svdxcgv.hxx|6 
 include/vcl/gdimtf.hxx |7 
 include/vcl/metaact.hxx|   11 
 oox/source/export/drawingml.cxx|   56 ---
 svx/source/svdraw/svdxcgv.cxx  |4 
 vcl/source/control/fmtfield.cxx|2 
 vcl/source/filter/svm/SvmReader.cxx|   21 +
 vcl/source/filter/svm/SvmWriter.cxx|   23 +
 vcl/source/gdi/gdimtf.cxx  |9 
 vcl/source/gdi/metaact.cxx |5 
 16 files changed, 523 insertions(+), 174 deletions(-)

New commits:
commit a6e72e2b314e64f3199f3eaf1ecf78157446f6dd
Author: Armin Le Grand (allotropia) 
AuthorDate: Mon Jun 5 17:15:34 2023 +0200
Commit: Armin Le Grand 
CommitDate: Fri Jun 9 10:17:07 2023 +0200

MCGR: tdf#155479 repair gradient SVG export for MCGR

Unfortunately SVG export is based on metafiles and thus there
is (in principle) no way to get the BGradient/ColorStop/MCGR
data transfered as needed. For that, using UNO API to read the
model or using B2DPrimitives would help - as is better for the
export respectively.

Since there is not the time to re-design SVG export I added
this 'compromize' as a fix. It gets the needed data transported
over the metafile (that part is the compromize). It then
exports the MCGR data to SVG (at least - as was already there -
if it's a linear/axial gradient). This happens now with all
Gradient Stops when there is a MCGR gradient. That part is/will
hopefully be re-usable if SVG export  gets redesigned.

I also added a handling for StepCount feature, so when used (in
LO, others do not have that) 'hard' color stops get generated
to make the gradient look identical for SVG export.

Had to make adding of that extra-information in metafiles
dependent on exporting really to SVG. There are 51 cases which
use 'MetaActionType::COMMENT' which would potentially have
to be adapted.

Also added code to solve the problem for TransparencePrimitive2D
at VclMetafileProcessor2D::processTransparencePrimitive2D. This
will now - also only for SVG export - directly create the needed
MetaFloatTransparentAction and add additional MCGR information.
This will be used on SVG export to write a 'Mask' as was done
before. This is now capable of creating fill MCGR-Masks in
the sense that any number of TransparencyStops will be supported.

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

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index b56ef0540d17..c96cd0b673cb 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -679,6 +679,117 @@ bool BColorStops::isSymmetrical() const
 return aIter > aRIter;
 }
 
+void BColorStops::doApplyAxial()
+{
+// preapare new ColorStops
+basegfx::BColorStops aNewColorStops;
+
+// add gradient stops in reverse order, scaled to [0.0 .. 0.5]
+basegfx::BColorStops::const_reverse_iterator aRevCurrColor(rbegin());
+
+while (aRevCurrColor != rend())
+{
+aNewColorStops.emplace_back((1.0 - aRevCurrColor->getStopOffset()) * 
0.5,
+aRevCurrColor->getStopColor());
+aRevCurrColor++;
+}
+
+// prepare non-reverse run
+basegfx::BColorStops::const_iterator aCurrColor(begin());
+
+if (basegfx::fTools::equalZero(aCurrColor->getStopOffset()))
+{
+// Caution: do not add 1st entry again, that would be double since it 
was
+// already added as last element of the inverse run above. But only if
+// the gradient has a start entry for 0.0 aka StartColor, else it is 
correct.
+aCurrColor++;
+}
+
+// add gradient stops in non-reverse order, translated and scaled to [0.5 
.. 1.0]
+while (aCurrColor != end())
+{
+aNewColorStops.emplace_back((aCurrColor->getStopOffset() * 0.5) + 0.5,
+aCurrColor->getStopColor());
+aCurrColor++;
+}
+
+// apply color stops
+*this = aNewColorStops;
+}
+
+void BColorStops::doApplySteps(sal_uInt16 nStepCount)
+{
+// check for zero or invalid steps setting 

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

2023-06-06 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bda52485d63e4cfc58453d9f46bf26c3ea078ed7
Author: Armin Le Grand (allotropia) 
AuthorDate: Tue Jun 6 12:53:42 2023 +0200
Commit: Armin Le Grand 
CommitDate: Tue Jun 6 15:44:32 2023 +0200

MCGR: tdf#155537 correct usage of wrong result in tooling

Change-Id: I8f68ecc7ccaecf84abbcda1bcdd65e2295baaf0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152673
Tested-by: Jenkins
Reviewed-by: Regina Henschel 
Reviewed-by: Armin Le Grand 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 366e0b0840b8..f79895bc8b8b 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -465,7 +465,7 @@ namespace basegfx
 // This should always be the cease and should have been
 // detected as such above, see bNeedToSyncronize
 rColorStops = aNewColor;
-rAlphaStops = aNewColor;
+rAlphaStops = aNewAlpha; // MCGR: tdf#155537 used wrong 
result here
 }
 }
 }


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

2023-06-05 Thread Regina Henschel (via logerrit)
 basegfx/source/tools/bgradient.cxx |   53 

 chart2/qa/extras/chart2geometry.cxx|5 
 include/basegfx/utils/bgradient.hxx|7 +
 xmloff/qa/unit/data/tdf155549_MCGR_AxialGradientCompatible.odt |binary
 xmloff/qa/unit/data/tdf155549_MCGR_AxialTransparencyCompatible.odt |binary
 xmloff/qa/unit/style.cxx   |   63 
++
 xmloff/source/style/GradientStyle.cxx  |5 
 xmloff/source/style/TransGradientStyle.cxx |2 
 8 files changed, 130 insertions(+), 5 deletions(-)

New commits:
commit 6c49886ab46c53398d74610b264e5edb0332a059
Author: Regina Henschel 
AuthorDate: Sat Jun 3 14:56:29 2023 +0200
Commit: Regina Henschel 
CommitDate: Mon Jun 5 17:34:57 2023 +0200

tdf#155549 MCGR: Recreate 'axial' from symmetric 'linear'

When exporting a shape with an axial gradient fill to OOXML, it is
converted to a linear gradient with multiple color stops. Versions
before MCGR had recreated it as axial gradient on import from OOXML.
But now LO is able to handle multiple color stops and so the linear
gradient from OOXML is imported as linear gradient in LO.

When such file is then written as ODF, the multiple color stops are
in elements in extended namespace and versions before MCGR do not
understand them. They show only the first and last color (which are
equal) and the gradient is lost.

With this patch LO converts the linear gradient back to an axial gradient
on export to ODF. The exported axial gradient is rendered in a version
with MCGR same as the linear gradient when opening the OOXML file. The
difference is, that versions without MCGR now render an axial gradient
with two colors.

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

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index b7ee0780a2cc..b56ef0540d17 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -657,6 +657,28 @@ double BColorStops::detectPossibleOffsetAtStart() const
 return aColorL->getStopOffset();
 }
 
+//  checks whether the color stops are symmetrical in color and offset.
+bool BColorStops::isSymmetrical() const
+{
+if (empty())
+return false;
+if (1 == size())
+return basegfx::fTools::equal(0.5, front().getStopOffset());
+
+BColorStops::const_iterator aIter(begin()); // for going forward
+BColorStops::const_iterator aRIter(end()); // for going backward
+--aRIter;
+// We have at least two elements, so aIter <= aRIter fails before 
iterators no longer point to
+// an element.
+while (aIter <= aRIter && 
aIter->getStopColor().equal(aRIter->getStopColor())
+   && basegfx::fTools::equal(aIter->getStopOffset(), 1.0 - 
aRIter->getStopOffset()))
+{
+++aIter;
+--aRIter;
+}
+return aIter > aRIter;
+}
+
 std::string BGradient::GradientStyleToString(css::awt::GradientStyle eStyle)
 {
 switch (eStyle)
@@ -917,7 +939,7 @@ void BGradient::tryToRecreateBorder(basegfx::BColorStops* 
pAssociatedTransparenc
 pAssociatedTransparencyStops->removeSpaceAtStart(fOffset);
 
 // ...and create border value
-SetBorder(static_cast(fOffset * 100.0));
+SetBorder(static_cast(std::lround(fOffset * 100.0)));
 }
 
 if (bIsAxial)
@@ -971,6 +993,35 @@ void BGradient::tryToApplyStartEndIntensity()
 SetStartIntens(100);
 SetEndIntens(100);
 }
+
+void BGradient::tryToConvertToAxial()
+{
+if (css::awt::GradientStyle_LINEAR != GetGradientStyle() || 0 != 
GetBorder()
+|| GetColorStops().empty())
+return;
+
+if (!GetColorStops().isSymmetrical())
+return;
+
+SetGradientStyle(css::awt::GradientStyle_AXIAL);
+
+// Stretch the first half of the color stops to double width
+// and collect them in a new color stops vector.
+BColorStops aAxialColorStops;
+aAxialColorStops.reserve(std::ceil(GetColorStops().size() / 2.0));
+BColorStops::const_iterator aIter(GetColorStops().begin());
+while (basegfx::fTools::lessOrEqual(aIter->getStopOffset(), 0.5))
+{
+BColorStop aNextStop(std::clamp((*aIter).getStopOffset() * 2.0, 0.0, 
1.0),
+ (*aIter).getStopColor());
+aAxialColorStops.push_back(aNextStop);
+++aIter;
+}
+// Axial gradients have outmost color as last color stop.
+aAxialColorStops.reverseColorStops();
+
+SetColorStops(aAxialColorStops);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/qa/extras/chart2geometry.cxx 
b/chart2/qa/extras/chart2geometry.cxx
index d52633c80814..f560d46ba054 100644
--- 

[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 basegfx/test chart2/source drawinglayer/source filter/source include/basegfx oox/source svx/source sw/source xmloff/source

2023-05-18 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrix.cxx   |  211 +++
 basegfx/source/point/b2dpoint.cxx|   15 -
 basegfx/source/point/b2ipoint.cxx|   15 -
 basegfx/test/B2DHomMatrixTest.cxx|   54 -
 chart2/source/tools/CommonConverters.cxx |   13 -
 drawinglayer/source/texture/texture.cxx  |   14 -
 drawinglayer/source/tools/primitive2dxmldump.cxx |6 
 filter/source/msfilter/eschesdo.cxx  |7 
 include/basegfx/matrix/b2dhommatrix.hxx  |   60 +++---
 oox/source/drawingml/shape.cxx   |6 
 oox/source/shape/WpsContext.cxx  |7 
 svx/source/unodraw/unoshape.cxx  |   13 -
 sw/source/core/edit/edfcol.cxx   |   13 -
 sw/source/core/unocore/unodraw.cxx   |   13 -
 xmloff/source/draw/shapeexport.cxx   |7 
 xmloff/source/draw/ximpshap.cxx  |6 
 16 files changed, 181 insertions(+), 279 deletions(-)

New commits:
commit fdd06037e0cf902d71270c4bf7a867efc7c9c1f4
Author: Noel Grandin 
AuthorDate: Wed May 17 20:13:03 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu May 18 21:18:06 2023 +0200

improved B2DHomMatrix

since we know that this is a matrix only used for 2D transforms,
we know that the last row of the matrix is always { 0, 0, 1 }.

Therefore, we don't need to store that information, and
we can simplify some of the computations.

Also remove operations like operator+ which are not legal for
such a matrix.

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

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index 4222c7a351c2..e4a9dda9e3c5 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -26,50 +26,56 @@
 
 namespace basegfx
 {
-
-B2DHomMatrix::B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, 
double f_1x0, double f_1x1, double 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);
-}
-
-void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
-{
-maImpl.set(nRow, nColumn, fValue);
-}
+constexpr int RowSize = 3;
 
 void B2DHomMatrix::set3x2(double f_0x0, double f_0x1, double f_0x2, double 
f_1x0, double f_1x1, double 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 maImpl.isLastLineDefault();
+mfValues[0][0] = f_0x0;
+mfValues[0][1] = f_0x1;
+mfValues[0][2] = f_0x2;
+mfValues[1][0] = f_1x0;
+mfValues[1][1] = f_1x1;
+mfValues[1][2] = f_1x2;
 }
 
 bool B2DHomMatrix::isIdentity() const
 {
-return maImpl.isIdentity();
+for(sal_uInt16 a(0); a < RowSize - 1; a++)
+{
+for(sal_uInt16 b(0); b < RowSize; b++)
+{
+const double fDefault(internal::implGetDefaultValue(a, b));
+const double fValueAB(get(a, b));
+
+if(!::basegfx::fTools::equal(fDefault, fValueAB))
+{
+return false;
+}
+}
+}
+
+return true;
 }
 
 void B2DHomMatrix::identity()
 {
-maImpl = Impl2DHomMatrix();
+for(sal_uInt16 a(0); a < RowSize - 1; a++)
+{
+for(sal_uInt16 b(0); b < RowSize; b++)
+mfValues[a][b] = internal::implGetDefaultValue(a, b);
+}
 }
 
 bool B2DHomMatrix::isInvertible() const
 {
-return maImpl.isInvertible();
+double dst[6];
+/* Compute adjoint: */
+computeAdjoint(dst);
+/* Compute determinant: */
+double det = computeDeterminant(dst);
+if (fTools::equalZero(det))
+return false;
+return true;
 }
 
 bool B2DHomMatrix::invert()
@@ -77,85 +83,43 @@ namespace basegfx
 if(isIdentity())
 return true;
 
-
-double dst[9];
+double dst[6];
 
 /* Compute adjoint: */
-
-dst[0] = + get(1, 1) * get(2, 2) - get(1, 2) * get(2, 1);
-dst[1] = - get(0, 1) * get(2, 2) + get(0, 2) * get(2, 1);
-dst[2] = + get(0, 1) * get(1, 2) - get(0, 2) * get(1, 1);
-dst[3] = - get(1, 0) * get(2, 2) + get(1, 2) * get(2, 0);
-dst[4] = + get(0, 0) * get(2, 2) - get(0, 2) * get(2, 0);
-dst[5] = - get(0, 0) * get(1, 2) + get(0, 2) * get(1, 0);
-  

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

2023-05-17 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrix.cxx |   56 ++---
 1 file changed, 45 insertions(+), 11 deletions(-)

New commits:
commit a78a9ea3a5f935bf364f59426b22e9039d2c1784
Author: Noel Grandin 
AuthorDate: Tue May 16 13:02:47 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed May 17 15:26:04 2023 +0200

tdf#63130 use a simpler, SIMD-friendly algorithm for matrix invert

which is 10% faster loading this document

Algorithm copied from 
https://github.com/niswegmann/small-matrix-inverse/blob/master/invert3x3_c.h, 
which is CC0-1.0 licensed.

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

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index 565be5c68b1c..4222c7a351c2 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -75,21 +75,55 @@ namespace basegfx
 bool B2DHomMatrix::invert()
 {
 if(isIdentity())
-{
 return true;
-}
 
-Impl2DHomMatrix aWork(maImpl);
-sal_uInt16* pIndex = static_cast(alloca( 
sizeof(sal_uInt16) * Impl2DHomMatrix::getEdgeLength() ));
-sal_Int16 nParity;
 
-if(aWork.ludcmp(pIndex, nParity))
-{
-maImpl.doInvert(aWork, pIndex);
-return true;
-}
+double dst[9];
+
+/* Compute adjoint: */
 
-return false;
+dst[0] = + get(1, 1) * get(2, 2) - get(1, 2) * get(2, 1);
+dst[1] = - get(0, 1) * get(2, 2) + get(0, 2) * get(2, 1);
+dst[2] = + get(0, 1) * get(1, 2) - get(0, 2) * get(1, 1);
+dst[3] = - get(1, 0) * get(2, 2) + get(1, 2) * get(2, 0);
+dst[4] = + get(0, 0) * get(2, 2) - get(0, 2) * get(2, 0);
+dst[5] = - get(0, 0) * get(1, 2) + get(0, 2) * get(1, 0);
+dst[6] = + get(1, 0) * get(2, 1) - get(1, 1) * get(2, 0);
+dst[7] = - get(0, 0) * get(2, 1) + get(0, 1) * get(2, 0);
+dst[8] = + get(0, 0) * get(1, 1) - get(0, 1) * get(1, 0);
+
+/* Compute determinant: */
+
+double det = get(0, 0) * dst[0] + get(0, 1) * dst[3] + get(0, 2) * 
dst[6];
+if (fTools::equalZero(det))
+return false;
+
+/* Multiply adjoint with reciprocal of determinant: */
+
+det = 1.0 / det;
+
+maImpl.set(0, 0, dst[0] * det);
+maImpl.set(0, 1, dst[1] * det);
+maImpl.set(0, 2, dst[2] * det);
+maImpl.set(1, 0, dst[3] * det);
+maImpl.set(1, 1, dst[4] * det);
+maImpl.set(1, 2, dst[5] * det);
+maImpl.set(2, 0, dst[6] * det);
+maImpl.set(2, 1, dst[7] * det);
+maImpl.set(2, 2, dst[8] * det);
+
+// The above algorithm is very slightly less accurate then the old 
one, so
+// we need to round the last row to make sure that functions like 
decompose
+// still do the same thing with existing data, otherwise testTdf109143
+// in CppunitTest_vcl_pdfexport will fail.
+if (fTools::equalZero(maImpl.get(2, 0)))
+maImpl.set(2, 0, 0);
+if (fTools::equalZero(maImpl.get(2, 1)))
+maImpl.set(2, 1, 0);
+if (fTools::equal(1.0, maImpl.get(2, 2)))
+maImpl.set(2, 2, 1);
+
+return true;
 }
 
 B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)


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

2023-05-16 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/bgradient.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 68655b362f8129f6f3762bf7926690c1a40c9821
Author: Andrea Gelmini 
AuthorDate: Mon May 15 23:44:01 2023 +0200
Commit: Julien Nabet 
CommitDate: Tue May 16 09:47:25 2023 +0200

Fix typo

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

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index f2e7d90190a9..134fda548ece 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -683,7 +683,7 @@ BGradient::BGradient(const css::uno::Any& rVal)
 SetEndIntens(aGradient.EndIntensity);
 SetSteps(aGradient.StepCount);
 
-// complete data by creating ColorStops from fixe Start/EndColor
+// complete data by creating ColorStops from fixed Start/EndColor
 aColorStops = BColorStops{
 BColorStop(0.0, 
ColorToBColorConverter(aGradient.StartColor).getBColor()),
 BColorStop(1.0, 
ColorToBColorConverter(aGradient.EndColor).getBColor())


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

2023-05-16 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/bgradient.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8c76c0538d81a1425caca55c917367492b7cc631
Author: Andrea Gelmini 
AuthorDate: Mon May 15 23:43:29 2023 +0200
Commit: Julien Nabet 
CommitDate: Tue May 16 09:40:44 2023 +0200

Fix typo

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

diff --git a/basegfx/source/tools/bgradient.cxx 
b/basegfx/source/tools/bgradient.cxx
index 7cb1ed85e859..f2e7d90190a9 100644
--- a/basegfx/source/tools/bgradient.cxx
+++ b/basegfx/source/tools/bgradient.cxx
@@ -101,7 +101,7 @@ BColorStops::BColorStops(const css::uno::Any& rVal)
 }
 }
 
-// constuctor with two colors to explicitly create a
+// constructor with two colors to explicitly create a
 // BColorStops for a single StartColor @0.0 & EndColor @1.0
 BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd)
 {


[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 cui/source include/basegfx include/oox include/svx oox/source sd/source svx/source

2023-04-19 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx|   97 +-
 cui/source/inc/cuitabarea.hxx |   12 +
 cui/source/tabpages/tpgradnt.cxx  |   38 +++--
 cui/source/tabpages/tptrans.cxx   |   36 +++--
 include/basegfx/utils/gradienttools.hxx   |5 
 include/oox/export/drawingml.hxx  |5 
 include/svx/sidebar/AreaPropertyPanelBase.hxx |6 
 include/svx/sidebar/AreaTransparencyGradientPopup.hxx |4 
 oox/source/export/chartexport.cxx |6 
 oox/source/export/drawingml.cxx   |   48 --
 sd/source/ui/sidebar/SlideBackground.cxx  |   28 +++-
 sd/source/ui/sidebar/SlideBackground.hxx  |6 
 svx/source/sidebar/area/AreaPropertyPanelBase.cxx |   34 
 svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx |   18 ++
 svx/source/unodraw/XPropertyTable.cxx |   21 ++-
 15 files changed, 272 insertions(+), 92 deletions(-)

New commits:
commit 4409cd197dfb1fab05c0285f3ae17a107c99b77e
Author: Armin Le Grand (allotropia) 
AuthorDate: Tue Apr 18 15:36:35 2023 +0200
Commit: Armin Le Grand 
CommitDate: Wed Apr 19 20:43:45 2023 +0200

MCGR: 2nd corrections/adaptions to MCGR

Adapted handling of 'border' argument from our gradients
for oox export, so that it looks the same.

Also added quite some cases to peserve in-between
GradientStops for current UI implementations to be
able to edit the gradients as usual without losing
the in-between GradientStops.

While we will not be able to modify these, we are
at least able to modify all the other gradient
attributes, including start/endColor.

Done this for TransparencyGradients, too.

Also moved more stuff to the gradient tooling in
basegfx.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index f9e9ad494c4e..372abe08254b 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -264,6 +265,80 @@ namespace basegfx
 
 namespace utils
 {
+/* Internal helper to convert ::Color from tools::color.hxx to BColor
+   without the need to link against tools library. Be on the
+   safe side by using the same union
+*/
+namespace {
+struct ColorToBColorConverter
+{
+union {
+sal_uInt32 mValue;
+struct {
+#ifdef OSL_BIGENDIAN
+sal_uInt8 T;
+sal_uInt8 R;
+sal_uInt8 G;
+sal_uInt8 B;
+#else
+sal_uInt8 B;
+sal_uInt8 G;
+sal_uInt8 R;
+sal_uInt8 T;
+#endif
+};
+};
+
+ColorToBColorConverter(sal_uInt32 nColor) : mValue(nColor) { T=0; }
+BColor getBColor() const
+{
+return BColor(R / 255.0, G / 255.0, B / 255.0);
+}
+};
+}
+
+/// 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 >())
+{
+// 1st get awt::Gradient
+css::awt::Gradient aTmp;
+
+if (rVal >>= aTmp)
+{
+// copy all awt::Gradient data to awt::Gradient2
+rGradient.Style = aTmp.Style;
+rGradient.StartColor = aTmp.StartColor;
+rGradient.EndColor = aTmp.EndColor;
+rGradient.Angle = aTmp.Angle;
+rGradient.Border = aTmp.Border;
+rGradient.XOffset = aTmp.XOffset;
+rGradient.YOffset = aTmp.YOffset;
+rGradient.StartIntensity = aTmp.StartIntensity;
+rGradient.EndIntensity = aTmp.EndIntensity;
+rGradient.StepCount = aTmp.StepCount;
+
+// complete data by creating ColorStops for awt::Gradient2
+fillColorStopSequenceFromColorStops(
+rGradient.ColorStops,
+ColorStops {
+

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

2023-04-14 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 3e8a356f5ca00d875981b0f4279894c569bcc694
Author: Andrea Gelmini 
AuthorDate: Fri Apr 14 12:09:23 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Apr 14 14:27:49 2023 +0200

Fix typos

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 9e1159c46f1b..f9e9ad494c4e 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -332,15 +332,15 @@ namespace basegfx
The intention is that a color GradientStops and an
alpha/transparence GradientStops gets synchronized
for export.
-   Fo the corrections the single values for color and
+   For the corrections the single values for color and
alpha may be used, e.g. when ColorStops is given
and not empty, but AlphaStops is empty, it will get
-   sycronized so that it will have the same number and
+   synchronized so that it will have the same number and
offsets in AlphaStops as in ColorStops, but with
the given SingleAlpha as value.
At return it guarantees that both have the same
number of entries with the same StopOffsets, so
-   that synchonized pair of ColorStops can e.g. be used
+   that synchronized pair of ColorStops can e.g. be used
to export a Gradient with defined/adapted alpha
being 'coupled' indirectly using the
'FillTransparenceGradient' method (at import time).


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

2023-04-14 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d1e97808f54bef3e5e87647d82e37662580b607c
Author: Andrea Gelmini 
AuthorDate: Fri Apr 14 12:06:49 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Apr 14 14:26:41 2023 +0200

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 1d701e4b8248..9e1159c46f1b 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -265,7 +265,7 @@ namespace basegfx
 namespace utils
 {
 /* Tooling method to extract data from given awt::Gradient2
-   to ColorStops, doing some corrections, partitally based
+   to ColorStops, doing some corrections, partially based
on given SingleColor.
This will do quite some preparations for the gradient
as follows:


[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

2023-04-06 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit a6cc4d851f1a061af71e03af4c886638d6a5f3b3
Author: Armin Le Grand (allotropia) 
AuthorDate: Wed Apr 5 10:25:51 2023 +0200
Commit: Armin Le Grand 
CommitDate: Thu Apr 6 10:40:49 2023 +0200

MCGR: Moved color compare in common computation part

The colors of a ColorStopRange can be equal in case of
hit *and* miss, so in both cases. I moved it to the
common computation part. Prev version worked and did
no harm, but unnecessary color interpolations for equal
colors.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 61e3f9b459bc..ca315f33f973 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -686,12 +686,6 @@ namespace basegfx
 if (rColorStops.end() == lowerBound)
 return rColorStops.back().getStopColor();
 
-// when there are just two color steps this cannot happen, but 
when using
-// a range of colors this *may* be used inside the range to 
represent
-// single-colored regions inside a ColorRange. Use that color 
& done
-if (lowerBound->getStopColor() == upperBound->getStopColor())
-return rLastColorStopRange.maColorStart;
-
 // we have lower and upper bound, get colors and offsets
 rLastColorStopRange.maColorStart = lowerBound->getStopColor();
 rLastColorStopRange.maColorEnd = upperBound->getStopColor();
@@ -699,6 +693,11 @@ namespace basegfx
 rLastColorStopRange.mfOffsetEnd = upperBound->getStopOffset();
 }
 
+// when there are just two color steps this cannot happen, but 
when using
+// a range of colors this *may* be used inside the range to 
represent
+// single-colored regions inside a ColorRange. Use that color & 
done
+if (rLastColorStopRange.maColorStart == 
rLastColorStopRange.maColorEnd)
+return rLastColorStopRange.maColorStart;
 
 // calculate number of steps and adapted proportional
 // range for scaler in [0.0 .. 1.0]


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

2023-04-04 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 73d0723c466e63c247d37ec8b9fa0bd8db8766b5
Author: Andrea Gelmini 
AuthorDate: Tue Apr 4 21:16:51 2023 +0200
Commit: Julien Nabet 
CommitDate: Tue Apr 4 21:26:49 2023 +0200

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 7f7d50abeb8c..61e3f9b459bc 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -700,7 +700,7 @@ namespace basegfx
 }
 
 
-// calculate number of steps and adapted proportinal
+// calculate number of steps and adapted proportional
 // range for scaler in [0.0 .. 1.0]
 const double fAdaptedScaler((fScaler - 
rLastColorStopRange.mfOffsetStart) /
 (rLastColorStopRange.mfOffsetEnd - 
rLastColorStopRange.mfOffsetStart));


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

2023-04-04 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7e1138db4e472e0d5de851c724e0048f1a834c08
Author: Andrea Gelmini 
AuthorDate: Tue Apr 4 21:16:39 2023 +0200
Commit: Julien Nabet 
CommitDate: Tue Apr 4 21:26:10 2023 +0200

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index fdc8dd189531..7f7d50abeb8c 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -655,7 +655,7 @@ namespace basegfx
 // or if we can re-use from last time.
 // If this scope is not entered, we do not need the binary search. 
It's
 // only a single buffered entry, and only used when more than three
-// ColorStops exist, but makes a huge difference compared with 
acessing
+// ColorStops exist, but makes a huge difference compared with 
accessing
 // the sorted ColorStop vector each time.
 // NOTE: with this simple change I get very high hit rates, e.g. 
rotating
 //   a donut with gradient test '1' hit rate is at 
0.99909440357755486


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

2023-04-04 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |  100 ++--
 drawinglayer/inc/texture/texture.hxx|4 +
 drawinglayer/source/texture/texture.cxx |   13 ++--
 include/basegfx/utils/gradienttools.hxx |   20 ++
 4 files changed, 87 insertions(+), 50 deletions(-)

New commits:
commit 4b5203ebf4ca5894f4d7dd37a141832df26e8b9a
Author: Armin Le Grand (allotropia) 
AuthorDate: Tue Apr 4 14:57:06 2023 +0200
Commit: Armin Le Grand 
CommitDate: Tue Apr 4 18:55:49 2023 +0200

MCGR: Improve performance for texture-mapped MCGR processing

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index dc6e4dc3f66a..fdc8dd189531 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -607,7 +607,8 @@ namespace basegfx
 BColor modifyBColor(
 const ColorStops& rColorStops,
 double fScaler,
-sal_uInt32 nRequestedSteps)
+sal_uInt32 nRequestedSteps,
+ColorStopRange& rLastColorStopRange)
 {
 // no color at all, done
 if (rColorStops.empty())
@@ -650,56 +651,69 @@ namespace basegfx
 nSteps > 1 ? floor(fScaler * nSteps) / double(nSteps - 1) 
: fScaler);
 }
 
-// access needed spot in sorted array using binary search
-// NOTE: This *seems* slow(er) when developing compared to just
-//   looping/accessing, but that's just due to the extensive
-//   debug test code created by the stl. In a pro version,
-//   all is good/fast as expected
-const auto upperBound(
-std::upper_bound(
-rColorStops.begin(),
-rColorStops.end(),
-ColorStop(fScaler),
-[](const ColorStop& x, const ColorStop& y) { return 
x.getStopOffset() < y.getStopOffset(); }));
-
-// no upper bound, done
-if (rColorStops.end() == upperBound)
-return rColorStops.back().getStopColor();
-
-// lower bound is one entry back
-const auto lowerBound(upperBound - 1);
-
-// no lower bound, done
-if (rColorStops.end() == lowerBound)
-return rColorStops.back().getStopColor();
-
-// we have lower and upper bound, get colors
-const BColor aCStart(lowerBound->getStopColor());
-const BColor aCEnd(upperBound->getStopColor());
+// check if we need to newly populate the needed interpolation data
+// or if we can re-use from last time.
+// If this scope is not entered, we do not need the binary search. 
It's
+// only a single buffered entry, and only used when more than three
+// ColorStops exist, but makes a huge difference compared with 
acessing
+// the sorted ColorStop vector each time.
+// NOTE: with this simple change I get very high hit rates, e.g. 
rotating
+//   a donut with gradient test '1' hit rate is at 
0.99909440357755486
+if (rLastColorStopRange.mfOffsetStart == 
rLastColorStopRange.mfOffsetEnd
+|| fScaler < rLastColorStopRange.mfOffsetStart
+|| fScaler > rLastColorStopRange.mfOffsetEnd)
+{
+// access needed spot in sorted array using binary search
+// NOTE: This *seems* slow(er) when developing compared to just
+//   looping/accessing, but that's just due to the 
extensive
+//   debug test code created by the stl. In a pro version,
+//   all is good/fast as expected
+const auto upperBound(
+std::upper_bound(
+rColorStops.begin(),
+rColorStops.end(),
+ColorStop(fScaler),
+[](const ColorStop& x, const ColorStop& y) { return 
x.getStopOffset() < y.getStopOffset(); }));
+
+// no upper bound, done
+if (rColorStops.end() == upperBound)
+return rColorStops.back().getStopColor();
+
+// lower bound is one entry back, access that
+const auto lowerBound(upperBound - 1);
+
+// no lower bound, done
+if (rColorStops.end() == lowerBound)
+return rColorStops.back().getStopColor();
+
+// when there are just two color steps this cannot happen, but 
when using
+// a range of colors this *may* be used inside the range to 
represent
+// single-colored regions inside a ColorRange. Use that color 
& 

[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 svx/source

2023-03-27 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx |   71 +-
 svx/source/sdr/primitive2d/sdrattributecreator.cxx |  106 +
 2 files changed, 173 insertions(+), 4 deletions(-)

New commits:
commit 13c37d2c0f0a172d2522b255c0416a4ade639b7a
Author: Armin Le Grand (allotropia) 
AuthorDate: Mon Mar 27 12:35:07 2023 +0200
Commit: Armin Le Grand 
CommitDate: Mon Mar 27 12:42:28 2023 +

MCGR: More corrections fo sortAndCorrectColorStops

Handle cases where gradient snippets overlap Start/End-
Color to preverve input information.
Added more test cases to createNewSdrFillAttribute to
check these cases.
All 27 look good, so add this changes.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 3b9fcda25ea1..a98eeddf641c 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -436,16 +436,60 @@ namespace basegfx
 for (size_t read(0); read < rColorStops.size(); read++)
 {
 // get offset of entry at read position
-const double rOff(rColorStops[read].getStopOffset());
+double fOff(rColorStops[read].getStopOffset());
+
+if (basegfx::fTools::less(fOff, 0.0) && read + 1 < 
rColorStops.size())
+{
+// value < 0.0 and we have a next entry. check for 
gradient snippet
+// containing 0.0 resp. StartColor
+const double fOff2(rColorStops[read + 1].getStopOffset());
+
+if (basegfx::fTools::more(fOff2, 0.0))
+{
+// read is the start of a gradient snippet containing 
0.0. Correct
+// entry to StartColor, interpolate to correct 
StartColor
+rColorStops[read] = ColorStop(0.0, 
basegfx::interpolate(
+rColorStops[read].getStopColor(),
+rColorStops[read + 1].getStopColor(),
+(0.0 - fOff) / (fOff2 - fOff)));
+
+// adapt fOff
+fOff = 0.0;
+}
+}
 
 // step over < 0 values, these are outside and will be removed
-if (basegfx::fTools::less(rOff, 0.0))
+if (basegfx::fTools::less(fOff, 0.0))
+{
 continue;
+}
+
+if (basegfx::fTools::less(fOff, 1.0) && read + 1 < 
rColorStops.size())
+{
+// value < 1.0 and we have a next entry. check for 
gradient snippet
+// containing 1.0 resp. EndColor
+const double fOff2(rColorStops[read + 1].getStopOffset());
+
+if (basegfx::fTools::more(fOff2, 1.0))
+{
+// read is the start of a gradient snippet containing 
1.0. Correct
+// next entry to EndColor, interpolate to correct 
EndColor
+rColorStops[read + 1] = ColorStop(1.0, 
basegfx::interpolate(
+rColorStops[read].getStopColor(),
+rColorStops[read + 1].getStopColor(),
+(1.0 - fOff) / (fOff2 - fOff)));
+
+// adapt fOff
+fOff = 1.0;
+}
+}
 
 // step over > 1 values; even break, since all following
 // entries will also be bigger due to being sorted, so done
-if (basegfx::fTools::more(rOff, 1.0))
+if (basegfx::fTools::more(fOff, 1.0))
+{
 break;
+}
 
 // entry is valid value at read position
 // copy if write target is empty (write at start) or when
@@ -467,7 +511,26 @@ namespace basegfx
 // last used position + 1
 if (rColorStops.size() > write)
 {
-rColorStops.resize(write);
+if (0 == write)
+{
+// no valid entries at all, but not empty. This can only 
happen
+// when all entries are below 0.0 or above 1.0 (else a 
gradient
+// snippet spawning over both would have been detected)
+if 
(basegfx::fTools::less(rColorStops.back().getStopOffset(), 0.0))
+{
+// all outside too low, rescue last due to being 
closest to content
+rColorStops = ColorStops { ColorStop(0.0, 
rColorStops.back().getStopColor()) };
+}
+else // if 

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

2023-03-22 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |2 +-
 drawinglayer/source/texture/texture.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 6fc0de7ce23f8faec052c744434006d40a33110a
Author: Andrea Gelmini 
AuthorDate: Tue Mar 21 20:46:59 2023 +0100
Commit: Julien Nabet 
CommitDate: Wed Mar 22 07:01:51 2023 +

Fix typos

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 6055143d5abd..3b9fcda25ea1 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -508,7 +508,7 @@ namespace basegfx
 
 // we need to extend the interpolation to the local
 // range of ColorStops. Despite having two ColorStops
-// these are not necessarily at 0.0 and 1.0, so mabe
+// these are not necessarily at 0.0 and 1.0, so may be
 // not the classical Start/EndColor (what is allowed)
 fScaler = (fScaler - fMin) / (fMax - fMin);
 return basegfx::interpolate(
diff --git a/drawinglayer/source/texture/texture.cxx 
b/drawinglayer/source/texture/texture.cxx
index 136284635e1b..de0f02057b4e 100644
--- a/drawinglayer/source/texture/texture.cxx
+++ b/drawinglayer/source/texture/texture.cxx
@@ -115,7 +115,7 @@ namespace drawinglayer::texture
 return false;
 
 // not needed when the last two ColorStops have different offset, 
then
-// a visible range will be pocessed already
+// a visible range will be processed already
 if (!basegfx::fTools::equal(mnColorStops.back().getStopOffset(), 
penultimate->getStopOffset()))
 return false;
 


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

2023-03-21 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |   76 +++
 drawinglayer/inc/texture/texture.hxx|3 
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   14 +
 drawinglayer/source/texture/texture.cxx |  173 +---
 include/basegfx/utils/gradienttools.hxx |   12 -
 svx/source/sdr/primitive2d/sdrattributecreator.cxx  |   75 ++
 6 files changed, 269 insertions(+), 84 deletions(-)

New commits:
commit 808c5bf66370f78f36e98887db0848ee7e55bb3a
Author: Armin Le Grand (allotropia) 
AuthorDate: Tue Mar 21 13:13:15 2023 +0100
Commit: Armin Le Grand 
CommitDate: Tue Mar 21 15:53:06 2023 +

MCGR: Model data changes for ColorSteps (II)

The biggest change here is to allow multiple ColorStops
with the same Offset. That allows to define gradients
with 'hard' color changes at any place using two
ColorStops with the same Offset and different Colors.
This required quite some adaptions, but works well.

Also removed in this context checking for all Colors
being the same to not mix up things. Also works well.

Also changed the need for having Start/EndColors AKA
ColorStops for 0.0 and 1.0 in place, instead 'imply'
the 1st ColorStop to also define the StartColor and
the last one the EndColor. This allows e.g. Gradient
definitions with two GradientStops at the same
Offset e.g. 0.5 with different colors to already
define a full Gradient.

Also added a tooling method to reverse ColorSteps,
which changes the order and mirrors the Offsets
(what even keeps an existing sort valid).
This is useful e.g. for GradientAxial which is the
only one where for decomposition the Gradient had
to be interpreted 'reverse' since it's defined
from center to edge, but for creating correct filled
polygons to represent this the inverse order had to
be used, creating polygons from edge to center.
This led to 'wild' code for this one of six cases
and prevented unifications with the other cases
(also made your brain flip).
Thus I adapted this now to use the reversed
ColorSteps consequently, and the same principle
loops than the other implementations to make things
easier for the future and to use common tooling.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index d43f7899121a..6055143d5abd 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -264,6 +264,17 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to reverse ColorStops, including offsets.
+   When also mirroring offsets a valid sort keeps valid.
+*/
+void reverseColorStops(ColorStops& rColorStops)
+{
+// can use std::reverse, but also need to adapt offset(s)
+std::reverse(rColorStops.begin(), rColorStops.end());
+for (auto& candidate : rColorStops)
+candidate = ColorStop(1.0 - candidate.getStopOffset(), 
candidate.getStopColor());
+}
+
 /* Tooling method to convert UNO API data to ColorStops
This will try to extract ColorStop data from the given
Any, so if it's of type awt::Gradient2 that data will be
@@ -374,13 +385,8 @@ namespace basegfx
  be removed)
- contains no ColorStops with offset > 1.0 (will
  be removed)
-   - contains no two ColorStops with identical offsets
- (will be removed, 1st one/smallest offset wins
- which is also given by sort tooling)
+   - ColorStops with identical offsets are now allowed
- will be sorted from lowest offset to highest
-   - if all colors are the same, the content will
- be reduced to a single entry with offset 0.0
- (force to StartColor)
 
Some more notes:
- It can happen that the result is empty
@@ -404,8 +410,15 @@ namespace basegfx
 if (1 == rColorStops.size())
 {
 // no gradient at all, but preserve given color
-// and force it to be the StartColor
-rColorStops[0] = ColorStop(0.0, rColorStops[0].getStopColor());
+// evtl. correct offset to be in valid range [0.0 .. 1.0]
+// NOTE: This does not move it to 0.0 or 1.0, it *can* still
+//   be somewhere in-between what is allowed
+rColorStops[0] = ColorStop(
+std::max(0.0, std::min(1.0, 
rColorStops[0].getStopOffset())),
+rColorStops[0].getStopColor());
+
+// done
+return;
 }
 
  

[Libreoffice-commits] core.git: basegfx/source chart2/source cui/source drawinglayer/inc drawinglayer/qa drawinglayer/source filter/source include/basegfx include/drawinglayer include/svx offapi/com o

2023-03-19 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |  191 +++---
 chart2/source/controller/main/ChartController_Tools.cxx |7 
 cui/source/tabpages/tpgradnt.cxx|   32 +
 cui/source/tabpages/tptrans.cxx |   23 -
 drawinglayer/inc/texture/texture.hxx|   16 
 drawinglayer/qa/unit/vclpixelprocessor2d.cxx|8 
 drawinglayer/source/attribute/fillgradientattribute.cxx |   34 -
 drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx |   12 
 drawinglayer/source/primitive3d/textureprimitive3d.cxx  |   10 
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx  |8 
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   12 
 drawinglayer/source/processor3d/defaultprocessor3d.cxx  |   14 
 drawinglayer/source/texture/texture.cxx |  198 +-
 drawinglayer/source/tools/primitive2dxmldump.cxx|   17 
 drawinglayer/source/tools/wmfemfhelper.cxx  |   12 
 filter/source/msfilter/msdffimp.cxx |8 
 filter/source/msfilter/svdfppt.cxx  |6 
 include/basegfx/utils/gradienttools.hxx |  136 ---
 include/drawinglayer/attribute/fillgradientattribute.hxx|   20 -
 include/svx/unomid.hxx  |1 
 include/svx/xgrad.hxx   |   21 -
 offapi/UnoApi_offapi.mk |3 
 offapi/com/sun/star/awt/ColorStop.idl   |   32 +
 offapi/com/sun/star/awt/ColorStopSequence.idl   |   17 
 offapi/com/sun/star/awt/Gradient2.idl   |   26 +
 reportdesign/source/ui/misc/UITools.cxx |4 
 reportdesign/source/ui/report/ReportController.cxx  |3 
 sc/qa/unit/subsequent_filters_test3.cxx |   16 
 sd/qa/unit/uiimpress.cxx|4 
 sd/source/core/drawdoc4.cxx |   49 +-
 sd/source/ui/sidebar/SlideBackground.cxx|   11 
 sd/source/ui/view/drviews9.cxx  |   41 +-
 svx/source/customshapes/EnhancedCustomShape2d.cxx   |   21 -
 svx/source/sdr/attribute/sdrallfillattributeshelper.cxx |8 
 svx/source/sdr/primitive2d/sdrattributecreator.cxx  |  113 ++---
 svx/source/sidebar/area/AreaPropertyPanelBase.cxx   |   21 -
 svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx   |   17 
 svx/source/svdraw/gradtrns.cxx  |   16 
 svx/source/svdraw/svdetc.cxx|4 
 svx/source/svdraw/svdfmtf.cxx   |   17 
 svx/source/svdraw/svdoashp.cxx  |   10 
 svx/source/unodraw/XPropertyTable.cxx   |   11 
 svx/source/unodraw/unobrushitemhelper.cxx   |8 
 svx/source/xoutdev/xattr.cxx|  227 +++-
 svx/source/xoutdev/xpool.cxx|   14 
 svx/source/xoutdev/xtabgrdt.cxx |   25 -
 sw/source/core/unocore/unoframe.cxx |6 
 sw/source/filter/ww8/docxattributeoutput.cxx|4 
 sw/source/filter/ww8/rtfattributeoutput.cxx |8 
 sw/source/uibase/docvw/HeaderFooterWin.cxx  |6 
 sw/source/uibase/docvw/ShadowOverlayObject.cxx  |   21 -
 sw/source/uibase/sidebar/PageStylesPanel.cxx|   11 
 52 files changed, 959 insertions(+), 601 deletions(-)

New commits:
commit 01d0019c851b9e942f9a3b94d6dd554fb1adb40c
Author: Armin Le Grand (allotropia) 
AuthorDate: Mon Mar 13 19:39:34 2023 +0100
Commit: Armin Le Grand 
CommitDate: Sun Mar 19 17:38:38 2023 +

MCGR: Model data changes for ColorSteps

Added tooling replaceStart/EndColor to allow simple
transition for code that does not immediately adapt
to multi color gradients. Also added
createColorStepsFromStartEndColor for the same
purpose.

Adapted XGradient to no longer have Start/EndColor
at all, but only use ColorSteps.

Adapted all usages of XGradient to no longer use
Get/Set/Start/EndColor, but access the ColorSteps
instead.

Replaced quite some XGradient constructors that
used XGradient() as Start/EndColor since this is
already the default.

Adapted ColorBlending to black AKA Start/EndIntens
in XGradient to work now on all ColorSteps in the
required linearly-scaled manner.

UNO API changes:

Added com::sun::star::awt::ColorStep as basic data
element that holds a pair of Offset and Color.

Added com::sun::star::awt::ColorStepSequence to
handle an array of sorted entries.

Added com::sun::star::awt::Gradient2 derived from

[Libreoffice-commits] core.git: basegfx/source sax/source ucb/source vcl/source vcl/unx

2023-03-06 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygontools.cxx|1 -
 basegfx/source/polygon/b3dpolygontools.cxx|1 -
 sax/source/fastparser/fastparser.cxx  |2 +-
 ucb/source/cacher/contentresultsetwrapper.cxx |3 ---
 vcl/source/filter/ipict/ipict.cxx |2 +-
 vcl/source/outdev/bitmapex.cxx|2 --
 vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx |2 +-
 7 files changed, 3 insertions(+), 10 deletions(-)

New commits:
commit 363512d39ba1543b7e91af1d59dadb5378da7649
Author: Noel Grandin 
AuthorDate: Mon Mar 6 15:09:25 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Mar 6 16:48:15 2023 +

clang-tidy dead-store

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

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 03f5299ca505..900ab735a1e0 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -1255,7 +1255,6 @@ namespace basegfx::utils
 // 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
diff --git a/basegfx/source/polygon/b3dpolygontools.cxx 
b/basegfx/source/polygon/b3dpolygontools.cxx
index a1f65bef2f48..3b3779d7460a 100644
--- a/basegfx/source/polygon/b3dpolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolygontools.cxx
@@ -219,7 +219,6 @@ namespace basegfx::utils
 // 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
diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index aae3c1162d47..06e2fb1e3e92 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1565,7 +1565,7 @@ static void NormalizeURI( OUString& rName )
 // try OASIS + W3 URI normalization
 bool bSuccess = NormalizeOasisURN( rName );
 if( ! bSuccess )
-bSuccess = NormalizeW3URI( rName );
+NormalizeW3URI( rName );
 }
 
 constexpr OUStringLiteral XML_URI_W3_PREFIX(u"http://www.w3.org/;);
diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx 
b/ucb/source/cacher/contentresultsetwrapper.cxx
index f6e7c0058a65..72388222f12d 100644
--- a/ucb/source/cacher/contentresultsetwrapper.cxx
+++ b/ucb/source/cacher/contentresultsetwrapper.cxx
@@ -275,10 +275,7 @@ void SAL_CALL ContentResultSetWrapper::dispose()
 }
 
 if (isCleared)
-{
 aGuard.lock();
-isCleared = false;
-}
 if( m_aDisposeEventListeners.getLength(aGuard) )
 {
 EventObject aEvt;
diff --git a/vcl/source/filter/ipict/ipict.cxx 
b/vcl/source/filter/ipict/ipict.cxx
index fcdef08e3592..2d9be6f8cd9c 100644
--- a/vcl/source/filter/ipict/ipict.cxx
+++ b/vcl/source/filter/ipict/ipict.cxx
@@ -783,7 +783,7 @@ sal_uInt64 PictReader::ReadPixMapEtc( BitmapEx , 
bool bBaseAddr, bool bC
 else
 {
 nRowBytes &= 0x3fff;
-nPixelSize = nCmpCount = nCmpSize = 1;
+nPixelSize = nCmpCount = 1;
 nDataSize += 10;
 aPalette.resize(2);
 aPalette[0] = Color(0xff, 0xff, 0xff);
diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx
index 57851f943f51..9935a18bdee6 100644
--- a/vcl/source/outdev/bitmapex.cxx
+++ b/vcl/source/outdev/bitmapex.cxx
@@ -522,8 +522,6 @@ void OutputDevice::DrawTransformedBitmapEx(
 aAlpha.BlendWith( bitmapEx.GetAlphaMask());
 bitmapEx = BitmapEx( bitmapEx.GetBitmap(), aAlpha );
 }
-if(rtl::math::approxEqual( fAlpha, 1.0 ))
-fAlpha = 1.0; // avoid the need for approxEqual in backends
 
 // If the backend's implementation is known to not need any optimizations 
here, pass to it directly.
 // With most backends it's more performant to try to simplify to 
DrawBitmapEx() first.
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx 
b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
index 9afb55f0eb21..36278074c446 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
@@ -1677,7 +1677,7 @@ void SalGtkFilePicker::impl_initialize(GtkWidget* 
pParentWidget, sal_Int16 templ
 GtkFileChooserAction eAction = GTK_FILE_CHOOSER_ACTION_OPEN;
 OString sOpen = getOpenText();
 OString sSave = getSaveText();
-const gchar *first_button_text = sOpen.getStr();
+const gchar *first_button_text;
 
 SolarMutexGuard g;
 


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

2023-03-05 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e540da2caadf4da228ddcc8c704f1f90a147493a
Author: Andrea Gelmini 
AuthorDate: Sun Mar 5 00:57:28 2023 +0100
Commit: Julien Nabet 
CommitDate: Sun Mar 5 08:46:25 2023 +

Fix typo

Change-Id: Iddc3e2a28eb638f52a0560925bdeffddb20d3a86
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148264
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 9f147fd9b357..0bb45ba4d523 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -308,7 +308,7 @@ namespace basegfx
 // equal is defined here by offset (see use operator==)
 std::sort(rColorSteps.begin(), rColorSteps.end());
 
-// preapare status values
+// prepare status values
 bool bSameColorInit(false);
 bool bAllTheSameColor(true);
 basegfx::BColor aFirstColor;


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

2023-03-05 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit abe7425d44a2f367440da2d5d552d781e5511958
Author: Andrea Gelmini 
AuthorDate: Sun Mar 5 00:57:58 2023 +0100
Commit: Julien Nabet 
CommitDate: Sun Mar 5 08:46:05 2023 +

Fix typo

Change-Id: I5b58180d4d048155b927156be1fb6fb22f0e657c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148265
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 5743f71ad980..9f147fd9b357 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -274,7 +274,7 @@ namespace basegfx
  (will be removed, 1st one wins)
- will be sorted from lowest offset to highest
- if all colors are the same, the content will
- be reducved to a single entry with offset 0.0
+ be reduced to a single entry with offset 0.0
  (StartColor)
 
Some more notes:


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

2023-03-04 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx   |  115 ++
 drawinglayer/qa/unit/vclpixelprocessor2d.cxx |5 
 drawinglayer/source/attribute/fillgradientattribute.cxx  |  116 ++-
 drawinglayer/source/primitive3d/textureprimitive3d.cxx   |9 +
 drawinglayer/source/texture/texture.cxx  |   46 ++---
 drawinglayer/source/tools/wmfemfhelper.cxx   |8 -
 include/basegfx/utils/gradienttools.hxx  |   31 +++-
 include/drawinglayer/attribute/fillgradientattribute.hxx |   21 +-
 svx/source/sdr/primitive2d/sdrattributecreator.cxx   |   45 -
 svx/source/xoutdev/xtabgrdt.cxx  |8 -
 sw/source/uibase/docvw/HeaderFooterWin.cxx   |7 
 sw/source/uibase/docvw/ShadowOverlayObject.cxx   |   20 +-
 12 files changed, 264 insertions(+), 167 deletions(-)

New commits:
commit ecae66c41d82fecddd630cfdc144055a069134b0
Author: Armin Le Grand (allotropia) 
AuthorDate: Fri Mar 3 18:03:56 2023 +0100
Commit: Armin Le Grand 
CommitDate: Sat Mar 4 16:32:16 2023 +

MCGR: ColorSteps handling moved to tooling

Due to the fact that handling of a vector GradientSteps
will get used more often with ongoing changes I moved
some handling to tooling, see sortAndCorrectColorSteps.
That method sorts and corrects a vector of ColorSteps
so that only valid entreis remain in a sorted order,
for details please refer to the docu at function
definition. I took the occasion to rearrange that to
work on the single provided vector which is better for
speed & ressources.

Also changed the ColorStep constructor to not
automatically correct constructed entries: While that
is formally correct, it moves an invalid entry to 0.0
or 1.0, thus creating additional wrong Start/EndColor
entries. Those may then 'overlay' the correct entry
when corrections are applied to the vector of entries
which leads to getting the wanted Start/EndColor to be
factically deleted, what is an error.

Also rearranged FillGradientAttribute to now work
initially with ColorSteps, no longer requires the
Start/EndColor, also adapted all usages. This securely
allows start/end and in-between single-color sections
in gradients.

Also needed to re-formulate GradientRect &
GradientElliptical ::appendTransformationsAndColors
method for correct 2D mapping(s) - always incrementing
from the start to end conflicts with the adaption of
the start value for the inner loop mainly because
increment is at start of inner loop (pre-increment).

Corrected errors from clang plugin, but also some
wrong initialiations for basegfx::ColorSteps.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index f35f91f5a79a..5743f71ad980 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -263,6 +263,121 @@ namespace basegfx
 
 namespace utils
 {
+/* Tooling method to guarantee sort and correctness for
+   the given ColorSteps vector.
+   At return, the following conditions are guaranteed:
+   - contains no ColorSteps with offset < 0.0 (will
+ be removed)
+   - contains no ColorSteps with offset > 0.0 (will
+ be removed)
+   - contains no ColorSteps with identical offset
+ (will be removed, 1st one wins)
+   - will be sorted from lowest offset to highest
+   - if all colors are the same, the content will
+ be reducved to a single entry with offset 0.0
+ (StartColor)
+
+   Some more notes:
+   - It can happen that the result is empty
+   - It is allowed to have consecutive entries with
+ the same color, this represents single-color
+ regions inside the gradient
+   - A entry with 0.0 is not required or forced, so
+ no 'StartColor' is required on this level
+   - A entry with 1.0 is not required or forced, so
+ no 'EndColor' is required on this level
+
+   All this is done in one run (sort + O(N)) without
+   creating a copy of the data in any form
+*/
+void sortAndCorrectColorSteps(ColorSteps& rColorSteps)
+{
+// no content, we are done
+if (rColorSteps.empty())
+return;
+
+if (1 == rColorSteps.size())
+{
+// no gradient at all, but preserve given color
+// and force it to be the StartColor
+rColorSteps[0] = ColorStep(0.0, rColorSteps[0].getColor());
+}
+
+// start 

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

2023-02-27 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |   27 ---
 drawinglayer/source/texture/texture.cxx |  253 +++-
 2 files changed, 159 insertions(+), 121 deletions(-)

New commits:
commit 16e728a8a88a7a04acec069512a5268ae89cf420
Author: Armin Le Grand (allotropia) 
AuthorDate: Fri Feb 24 17:34:53 2023 +0100
Commit: Armin Le Grand 
CommitDate: Mon Feb 27 17:43:13 2023 +

MCGR: Adapted other Gradient* to make use of MCGR

Added to make
  GeoTexSvxGradientElliptical
  GeoTexSvxGradientSquare
  GeoTexSvxGradientRect
work using the MCGR. It is still 100%
backward-compatible, so as long as there is no
source using this it will stay invisible - by
purpose.

Tests look good with all three, see the static
variable nUseGradientSteps.

NOTE: GeoTexSvxGradientElliptical still looks not
optimal due to texture back-mapping method
getEllipticalGradientAlpha, see notes in
commit "MCGR: Adapted GradientRadial to make use
of MCGR" ac824594c577ab4880177b3411a25297b1d08074

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 37671374262c..f35f91f5a79a 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -544,13 +544,6 @@ namespace basegfx
 t = 1.0 - std::hypot(aCoor.getX(), aCoor.getY() * 
fAspectRatio);
 }
 
-const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
-
-if(nSteps && t < 1.0)
-{
-return floor(t * nSteps) / double(nSteps - 1);
-}
-
 return t;
 }
 
@@ -571,15 +564,7 @@ namespace basegfx
 return 0.0;
 }
 
-const double t(1.0 - std::max(fAbsX, fAbsY));
-const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
-
-if(nSteps && t < 1.0)
-{
-return floor(t * nSteps) / double(nSteps - 1);
-}
-
-return t;
+return 1.0 - std::max(fAbsX, fAbsY);
 }
 
 double getRectangularGradientAlpha(const B2DPoint& rUV, const 
ODFGradientInfo& rGradInfo)
@@ -643,15 +628,7 @@ namespace basegfx
 fAbsY = ((fAbsY - 1) / fAspectRatio) + 1;
 }
 
-const double t(1.0 - std::max(fAbsX, fAbsY));
-const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
-
-if(nSteps && t < 1.0)
-{
-return floor(t * nSteps) / double(nSteps - 1);
-}
-
-return t;
+return 1.0 - std::max(fAbsX, fAbsY);
 }
 } // namespace utils
 } // namespace basegfx
diff --git a/drawinglayer/source/texture/texture.cxx 
b/drawinglayer/source/texture/texture.cxx
index e3ed2780af4e..22f56f33b8bd 100644
--- a/drawinglayer/source/texture/texture.cxx
+++ b/drawinglayer/source/texture/texture.cxx
@@ -455,60 +455,79 @@ namespace drawinglayer::texture
 std::vector< B2DHomMatrixAndBColor >& rEntries,
 basegfx::BColor& rOuterColor)
 {
-if(mnColorSteps.size() <= 1)
+// no color at all, done
+if (mnColorSteps.empty())
 return;
 
-const basegfx::BColor maStart(mnColorSteps.front().getColor());
-const basegfx::BColor maEnd(mnColorSteps.back().getColor());
-const sal_uInt32 nSteps(basegfx::utils::calculateNumberOfSteps(
-maGradientInfo.getRequestedSteps(), maStart, maEnd));
+// fill in return parameter rOuterColor before returning
+rOuterColor = mnColorSteps.front().getColor();
 
-rOuterColor = maStart;
-double fWidth(1.0);
-double fHeight(1.0);
-double fIncrementX(0.0);
-double fIncrementY(0.0);
+// only one color, done
+if (mnColorSteps.size() < 2)
+return;
 
-if(maGradientInfo.getAspectRatio() > 1.0)
-{
-fIncrementY = fHeight / nSteps;
-fIncrementX = fIncrementY / maGradientInfo.getAspectRatio();
-}
-else
+// need to start with the offsets *outside* of all loops, these 
will
+// get modified non-linear below, now in more than one gradient 
section,
+// but *constantly* over the whole range
+double fAllWidth(0.0);
+double fAllHeight(0.0);
+
+// outer loop over ColorSteps, each is from cs_l to cs_r
+for (auto cs_l(mnColorSteps.begin()), cs_r(cs_l + 1); cs_r != 
mnColorSteps.end(); cs_l++, cs_r++)
 {
-fIncrementX = fWidth / nSteps;
-fIncrementY = fIncrementX * 

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

2023-02-24 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |   10 
 drawinglayer/source/texture/texture.cxx |   67 +---
 2 files changed, 46 insertions(+), 31 deletions(-)

New commits:
commit ae51dfb2379a9e9183afa9a1e5ee4fe4f4f0f7ef
Author: Armin Le Grand (allotropia) 
AuthorDate: Fri Feb 24 10:56:43 2023 +0100
Commit: Armin Le Grand 
CommitDate: Fri Feb 24 16:22:36 2023 +

MCGR: Adapted GradientRadial to make use of MCGR

Added to make GradientRadial work using the MCGR.
It is still 100% backward-compatible, so as long
as there is no source using this it will stay
invisible - by purpose.

Tests look good with this one, see the static
variable nUseGradientSteps.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index b27443898f4e..37671374262c 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -515,15 +515,7 @@ namespace basegfx
 return 0.0;
 }
 
-const double t(1.0 - std::hypot(aCoor.getX(), aCoor.getY()));
-const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
-
-if(nSteps && t < 1.0)
-{
-return floor(t * nSteps) / double(nSteps - 1);
-}
-
-return t;
+return 1.0 - std::hypot(aCoor.getX(), aCoor.getY());
 }
 
 double getEllipticalGradientAlpha(const B2DPoint& rUV, const 
ODFGradientInfo& rGradInfo)
diff --git a/drawinglayer/source/texture/texture.cxx 
b/drawinglayer/source/texture/texture.cxx
index 73110fc8b8fd..44ce9336ac89 100644
--- a/drawinglayer/source/texture/texture.cxx
+++ b/drawinglayer/source/texture/texture.cxx
@@ -367,42 +367,65 @@ namespace drawinglayer::texture
 std::vector< B2DHomMatrixAndBColor >& rEntries,
 basegfx::BColor& rOuterColor)
 {
-if(mnColorSteps.size() <= 1)
+// no color at all, done
+if (mnColorSteps.empty())
 return;
 
-const basegfx::BColor maStart(mnColorSteps.front().getColor());
-const basegfx::BColor maEnd(mnColorSteps.back().getColor());
-const sal_uInt32 nSteps(basegfx::utils::calculateNumberOfSteps(
-maGradientInfo.getRequestedSteps(), maStart, maEnd));
+// fill in return parameter rOuterColor before returning
+rOuterColor = mnColorSteps.front().getColor();
 
-rOuterColor = maStart;
-const double fStepSize(1.0 / nSteps);
-B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+// only one color, done
+if (mnColorSteps.size() < 2)
+return;
 
-for(sal_uInt32 a(1); a < nSteps; a++)
+// outer loop over ColorSteps, each is from cs_l to cs_r
+for (auto cs_l(mnColorSteps.begin()), cs_r(cs_l + 1); cs_r != 
mnColorSteps.end(); cs_l++, cs_r++)
 {
-const double fSize(1.0 - (fStepSize * a));
-aB2DHomMatrixAndBColor.maB2DHomMatrix = 
maGradientInfo.getTextureTransform() * 
basegfx::utils::createScaleB2DHomMatrix(fSize, fSize);
-aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, 
double(a) / double(nSteps - 1));
-rEntries.push_back(aB2DHomMatrixAndBColor);
+// get colors & calculate steps
+const basegfx::BColor aCStart(cs_l->getColor());
+const basegfx::BColor aCEnd(cs_r->getColor());
+const sal_uInt32 nSteps(basegfx::utils::calculateNumberOfSteps(
+maGradientInfo.getRequestedSteps(), aCStart, aCEnd));
+
+// get offsets & calculate StripeWidth
+const double fOffsetStart(cs_l->getOffset());
+const double fOffsetEnd(cs_r->getOffset());
+const double fStripeWidth((fOffsetEnd - fOffsetStart) / 
nSteps);
+
+// get correct start for innner loop (see above)
+const sal_uInt32 nStartInnerLoop(cs_l == mnColorSteps.begin() 
? 1 : 0);
+
+for (sal_uInt32 innerLoop(nStartInnerLoop); innerLoop < 
nSteps; innerLoop++)
+{
+// calculate size/radius
+const double fSize(1.0 - (fOffsetStart + (fStripeWidth * 
innerLoop)));
+
+// set and add at target
+B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+aB2DHomMatrixAndBColor.maB2DHomMatrix = 
maGradientInfo.getTextureTransform() * 
basegfx::utils::createScaleB2DHomMatrix(fSize, fSize);
+aB2DHomMatrixAndBColor.maBColor = interpolate(aCStart, 
aCEnd, double(innerLoop) / double(nSteps - 1));
+

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

2023-02-23 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |   18 
 drawinglayer/source/texture/texture.cxx |  119 +++-
 2 files changed, 73 insertions(+), 64 deletions(-)

New commits:
commit 94cdbfb9316ab3b04327f960fa40aee07abbba91
Author: Armin Le Grand (allotropia) 
AuthorDate: Thu Feb 23 11:22:31 2023 +0100
Commit: Armin Le Grand 
CommitDate: Thu Feb 23 13:06:06 2023 +

MCGR: Adapted GradientAxial to make use of MCGR

Added to make GradientAxial work using the MCGR
as 2nd of six types. This one was complicated
since it uses the gradient(s) 'reversed' when you
look at it, from outside to inside. Had to do
quite some tickeling to get it all work, but
looks good now.

For modifyBColor I Could re-use the started
tooling as planned.

To get the reverse usage working I ended up in
1st adapting the previous usage to make more use
of std::iterator and reverse_iterator to be able
to use the reversed state of the ColorSteps more
'controlled' as if trying to adapt the numerical
indices to the vector (that ended in chaos).

It is still 100% backward-compatible, so as long
as there is no source using this it will stay
invisible - by purpose.

Tests look good with this one, see the static
variable nUseGradientSteps.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 4aa909fcf58c..b27443898f4e 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -467,7 +467,7 @@ namespace basegfx
 {
 const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
 
-// Ignore Y, this is not needed at all for Y-Oriented gradients
+// Ignore X, this is not needed at all for Y-Oriented gradients
 // if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
 // {
 // return 0.0;
@@ -483,13 +483,6 @@ namespace basegfx
 return 1.0; // end value for outside
 }
 
-// const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
-
-// if(nSteps)
-// {
-// return floor(aCoor.getY() * nSteps) / double(nSteps - 1);
-// }
-
 return aCoor.getY();
 }
 
@@ -497,7 +490,7 @@ namespace basegfx
 {
 const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
 
-// Ignore Y, this is not needed at all for Y-Oriented gradients
+// Ignore X, this is not needed at all for Y-Oriented gradients
 //if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
 //{
 //return 0.0;
@@ -510,13 +503,6 @@ namespace basegfx
 return 1.0; // use end value when outside in Y
 }
 
-const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
-
-if(nSteps)
-{
-return floor(fAbsY * nSteps) / double(nSteps - 1);
-}
-
 return fAbsY;
 }
 
diff --git a/drawinglayer/source/texture/texture.cxx 
b/drawinglayer/source/texture/texture.cxx
index 326d3bbe9146..73110fc8b8fd 100644
--- a/drawinglayer/source/texture/texture.cxx
+++ b/drawinglayer/source/texture/texture.cxx
@@ -138,18 +138,13 @@ namespace drawinglayer::texture
 if (mnColorSteps.empty())
 return;
 
-// get start color and also cc to rOuterColor
-basegfx::BColor aCStart(mnColorSteps[0].getColor());
-rOuterColor = aCStart;
+// fill in return parameter rOuterColor before returning
+rOuterColor = mnColorSteps.front().getColor();
 
 // only one color, done
 if (mnColorSteps.size() < 2)
 return;
 
-// here we could check that fOffsetStart == 
mnColorSteps[0].getOffset(),
-// but just assume/correct that StartColor is at 0.0
-double fOffsetStart(0.0 /*mnColorSteps[0].getOffset()*/);
-
 // prepare unit range transform
 basegfx::B2DHomMatrix aPattern;
 
@@ -161,14 +156,19 @@ namespace drawinglayer::texture
 aPattern.scale(mfUnitWidth, 1.0);
 aPattern.translate(mfUnitMinX, 0.0);
 
-for (size_t outerLoop(1); outerLoop < mnColorSteps.size(); 
outerLoop++)
+// outer loop over ColorSteps, each is from cs_l to cs_r
+for (auto cs_l(mnColorSteps.begin()), cs_r(cs_l + 1); cs_r != 
mnColorSteps.end(); cs_l++, cs_r++)
 {
-const basegfx::BColor 
aCEnd(mnColorSteps[outerLoop].getColor());
+// get colors & calculate steps
+const basegfx::BColor aCStart(cs_l->getColor());
+const 

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

2023-02-23 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dtrapezoid.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 29d795b772cb75ee1d12cc6bcd4d905f1c520a79
Author: Noel Grandin 
AuthorDate: Thu Feb 23 08:44:10 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Feb 23 12:48:27 2023 +

avoid div/0 in getCutPointForGivenY

Change-Id: I8e5e5689ee11777938ca7d0268b8e04e77466734
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147496
Reviewed-by: Michael Meeks 
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx 
b/basegfx/source/polygon/b2dtrapezoid.cxx
index b7991dbf55d4..2870c46d8236 100644
--- a/basegfx/source/polygon/b2dtrapezoid.cxx
+++ b/basegfx/source/polygon/b2dtrapezoid.cxx
@@ -174,6 +174,9 @@ namespace basegfx::trapezoidhelper
 // method for cut support
 B2DPoint getCutPointForGivenY(double fGivenY) const
 {
+// avoid div/0
+if (getDeltaY() == 0)
+return B2DPoint(getStart().getX(), fGivenY);
 // Calculate cut point locally (do not use interpolate) since 
it is numerically
 // necessary to guarantee the new, equal Y-coordinate
 const double fFactor((fGivenY - getStart().getY()) / 
getDeltaY());


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

2023-02-22 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b2eb17829a8da7828cdc60f262991aafda84f3ea
Author: Andrea Gelmini 
AuthorDate: Wed Feb 22 14:42:13 2023 +0100
Commit: Julien Nabet 
CommitDate: Wed Feb 22 14:03:12 2023 +

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 605ed4bf8834..4aa909fcf58c 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -282,7 +282,7 @@ namespace basegfx
 
 // special case for the 'classic' case with just two colors:
 // we can optimize that and keep the speed/resources low
-// by avoiding some calculatins and an O(log(N)) array access
+// by avoiding some calculations and an O(log(N)) array access
 if (2 == rColorSteps.size())
 {
 const basegfx::BColor aCStart(rColorSteps.front().getColor());


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

2023-02-22 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a2d61d9ff7cb7e0e0a0cb97d606a3b43a518704e
Author: Andrea Gelmini 
AuthorDate: Wed Feb 22 14:39:52 2023 +0100
Commit: Julien Nabet 
CommitDate: Wed Feb 22 13:56:10 2023 +

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 43cca3f1c7ea..605ed4bf8834 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -281,7 +281,7 @@ namespace basegfx
 return rColorSteps.back().getColor();
 
 // special case for the 'classic' case with just two colors:
-// we can optimize that and keep the speed/ressources low
+// we can optimize that and keep the speed/resources low
 // by avoiding some calculatins and an O(log(N)) array access
 if (2 == rColorSteps.size())
 {


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

2023-02-22 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |  101 +++-
 drawinglayer/source/attribute/fillgradientattribute.cxx |   40 --
 drawinglayer/source/texture/texture.cxx |   95 +--
 include/basegfx/utils/gradienttools.hxx |   23 +++
 svx/source/sdr/primitive2d/sdrattributecreator.cxx  |   94 +-
 5 files changed, 292 insertions(+), 61 deletions(-)

New commits:
commit c4f252035cd71f9a1b226e69095cc9f4e8f19f3e
Author: Armin Le Grand (allotropia) 
AuthorDate: Tue Feb 21 18:35:39 2023 +0100
Commit: Armin Le Grand 
CommitDate: Wed Feb 22 09:13:20 2023 +

MCGR: Adapted GradientLinear to make use of MCGR

Added to make GradientLinear work using the MCGR
as 1st of six types. Had to do quite some tickeling
to get it all work, but looks good.

Five more to go, already started to put some things
to tooling to make re-usable for the other types.

Besides adapting this the main change is that the
adaption of defined step-count (versus automatic)
has to be done in modifyBColor now instead of the
back-mapping methods (e.g. getLinearGradientAlpha).

It is still 100% backward-compatible, so as long
as there is no source using this it will stay
invisible - by purpose.

I started to do quite some tests (and fixes/
adaptions in consequence), see the static variable
nUseGradientSteps. If you want to play with this,
you might set it to '1' instead of '0' and use a
linear gradient on an object.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index b2635b3f09cc..43cca3f1c7ea 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+
+#include 
 #include 
 
 namespace basegfx
@@ -261,6 +263,95 @@ namespace basegfx
 
 namespace utils
 {
+BColor modifyBColor(
+const ColorSteps& rColorSteps,
+double fScaler,
+sal_uInt32 nRequestedSteps)
+{
+// no color at all, done
+if (rColorSteps.empty())
+return BColor();
+
+// outside range -> at start
+if (fScaler <= 0.0)
+return rColorSteps.front().getColor();
+
+// outside range -> at end
+if (fScaler >= 1.0)
+return rColorSteps.back().getColor();
+
+// special case for the 'classic' case with just two colors:
+// we can optimize that and keep the speed/ressources low
+// by avoiding some calculatins and an O(log(N)) array access
+if (2 == rColorSteps.size())
+{
+const basegfx::BColor aCStart(rColorSteps.front().getColor());
+const basegfx::BColor aCEnd(rColorSteps.back().getColor());
+const sal_uInt32 nSteps(
+calculateNumberOfSteps(
+nRequestedSteps,
+aCStart,
+aCEnd));
+
+return basegfx::interpolate(
+aCStart,
+aCEnd,
+nSteps > 1 ? floor(fScaler * nSteps) / double(nSteps - 1) 
: fScaler);
+}
+
+// access needed spot in sorted array using binary search
+// NOTE: This *seems* slow(er) when developing compared to just
+//   looping/accessing, but that's just due to the extensive
+//   debug test code created by the stl. In a pro version,
+//   all is good/fast as expected
+const auto upperBound(
+std::lower_bound(
+rColorSteps.begin(),
+rColorSteps.end(),
+ColorStep(fScaler),
+[](const ColorStep& x, const ColorStep& y) { return 
x.getOffset() < y.getOffset(); }));
+
+// no upper bound, done
+if (rColorSteps.end() == upperBound)
+return rColorSteps.back().getColor();
+
+// lower bound is one entry back
+const auto lowerBound(upperBound - 1);
+
+// no lower bound, done
+if (rColorSteps.end() == lowerBound)
+return rColorSteps.back().getColor();
+
+// we have lower and upper bound, get colors
+const BColor aCStart(lowerBound->getColor());
+const BColor aCEnd(upperBound->getColor());
+
+// when there are just two color steps this cannot happen, but 
when using
+// a range of colors this *may* be used inside the range to 
represent
+// single-colored regions inside a ColorRange. Use that color 

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

2023-02-20 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 71a67048f5eafcf668d1ee6d70c66c04cb323b0f
Author: Andrea Gelmini 
AuthorDate: Mon Feb 20 12:02:30 2023 +0100
Commit: Julien Nabet 
CommitDate: Mon Feb 20 21:16:07 2023 +

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 5af4397eb3cd..b2635b3f09cc 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -464,7 +464,7 @@ namespace basegfx
 // MCGR: Similar to getRectangularGradientAlpha (please
 // see there) we need to use aspect ratio here. Due to
 // initEllipticalGradientInfo using M_SQRT2 to make this
-// gradient look 'nicer' this correciton seems not 100%
+// gradient look 'nicer' this correction seems not 100%
 // correct, but is close enough for now
 if(fAspectRatio > 1.0)
 {


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

2023-02-20 Thread Andrea Gelmini (via logerrit)
 basegfx/source/tools/gradienttools.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 389c6267974a90b9b0e1eaf2a7434ca4aea38f76
Author: Andrea Gelmini 
AuthorDate: Mon Feb 20 12:03:31 2023 +0100
Commit: Julien Nabet 
CommitDate: Mon Feb 20 21:15:45 2023 +

Fix typo

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index b3bb18f918da..5af4397eb3cd 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -530,7 +530,7 @@ namespace basegfx
 return 0.0;
 }
 
-// MCGR: Visualiations using the texturing method for
+// MCGR: Visualizations using the texturing method for
 // displaying gradients (getBackTextureTransform is
 // involved) show wrong results for GradientElliptical
 // and GradientRect, this can be best seen when using


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

2023-02-20 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx |  102 -
 1 file changed, 100 insertions(+), 2 deletions(-)

New commits:
commit ac824594c577ab4880177b3411a25297b1d08074
Author: Armin Le Grand (allotropia) 
AuthorDate: Fri Feb 17 14:05:59 2023 +0100
Commit: Armin Le Grand 
CommitDate: Mon Feb 20 09:18:18 2023 +

MCGR: Correct GradientElliptical & GradientRect

The visualizations when using the texturing methods
modifyBColor/get*GradientAlpha were both not correct
since they did not apply the aspect ratio.

I corrected both where GradientRect is correct, but
GradientElliptical is close and may have small
divergencies.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 3f2480c82e84..b3bb18f918da 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -451,7 +451,38 @@ namespace basegfx
 
 double getEllipticalGradientAlpha(const B2DPoint& rUV, const 
ODFGradientInfo& rGradInfo)
 {
-return getRadialGradientAlpha(rUV, rGradInfo); // only matrix 
setup differs
+const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
+
+if(aCoor.getX() < -1.0 || aCoor.getX() > 1.0 || aCoor.getY() < 
-1.0 || aCoor.getY() > 1.0)
+{
+return 0.0;
+}
+
+double fAspectRatio(rGradInfo.getAspectRatio());
+double t(1.0);
+
+// MCGR: Similar to getRectangularGradientAlpha (please
+// see there) we need to use aspect ratio here. Due to
+// initEllipticalGradientInfo using M_SQRT2 to make this
+// gradient look 'nicer' this correciton seems not 100%
+// correct, but is close enough for now
+if(fAspectRatio > 1.0)
+{
+t = 1.0 - std::hypot(aCoor.getX() / fAspectRatio, 
aCoor.getY());
+}
+else if(fAspectRatio > 0.0)
+{
+t = 1.0 - std::hypot(aCoor.getX(), aCoor.getY() * 
fAspectRatio);
+}
+
+const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
+
+if(nSteps && t < 1.0)
+{
+return floor(t * nSteps) / double(nSteps - 1);
+}
+
+return t;
 }
 
 double getSquareGradientAlpha(const B2DPoint& rUV, const 
ODFGradientInfo& rGradInfo)
@@ -484,7 +515,74 @@ namespace basegfx
 
 double getRectangularGradientAlpha(const B2DPoint& rUV, const 
ODFGradientInfo& rGradInfo)
 {
-return getSquareGradientAlpha(rUV, rGradInfo); // only matrix 
setup differs
+const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
+double fAbsX(fabs(aCoor.getX()));
+
+if(fAbsX >= 1.0)
+{
+return 0.0;
+}
+
+double fAbsY(fabs(aCoor.getY()));
+
+if(fAbsY >= 1.0)
+{
+return 0.0;
+}
+
+// MCGR: Visualiations using the texturing method for
+// displaying gradients (getBackTextureTransform is
+// involved) show wrong results for GradientElliptical
+// and GradientRect, this can be best seen when using
+// less steps, e.g. just four. This thus has influence
+// on cppcanvas (slideshow) and 3D textures, so needs
+// to be corrected.
+// Missing is to use the aspect ratio of the object
+// in this [-1, -1, 1, 1] unified coordinate space
+// after getBackTextureTransform is applied. Optically
+// in the larger direction of the texturing the color
+// step distances are too big *because* we are in that
+// unit range now.
+// To correct that, a kind of 'limo stretching' needs to
+// be applied, adding space around the center
+// proportional to the aspect ratio, so the intuitive
+// idea would be to do
+//
+// fAbsX' = ((fAspectRatio - 1) + fAbsX) / fAspectRatio
+//
+// which scales from the center. This does not work, and
+// after some thoughts it's clear why: It's not the
+// position that needs to be moved (this cannot be
+// changed), but the position *before* that scale has
+// to be determined to get the correct, shifted color
+// for the already 'new' position. Thus, turn around
+// the expression as
+//
+// fAbsX' * fAspectRatio = fAspectRatio - 1 + fAbsX
+// fAbsX' * fAspectRatio - fAspectRatio + 1 = fAbsX
+// fAbsX = (fAbsX' - 1) 

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

2023-02-15 Thread Armin Le Grand (allotropia) (via logerrit)
 basegfx/source/tools/gradienttools.cxx  |   30 +
 drawinglayer/inc/texture/texture.hxx|   38 -
 drawinglayer/source/attribute/fillgradientattribute.cxx |  122 +++--
 drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx |   53 --
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx  |1 
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |1 
 drawinglayer/source/processor3d/defaultprocessor3d.cxx  |   55 --
 drawinglayer/source/texture/texture.cxx |  265 +++-
 drawinglayer/source/tools/primitive2dxmldump.cxx|1 
 drawinglayer/source/tools/wmfemfhelper.cxx  |1 
 include/basegfx/utils/gradienttools.hxx |  115 -
 include/drawinglayer/attribute/fillgradientattribute.hxx|   68 ---
 svx/source/sdr/attribute/sdrallfillattributeshelper.cxx |1 
 svx/source/sdr/primitive2d/sdrattributecreator.cxx  |   13 
 14 files changed, 437 insertions(+), 327 deletions(-)

New commits:
commit ea1d3d11ca113042a99effc168da834894005370
Author: Armin Le Grand (allotropia) 
AuthorDate: Wed Feb 15 10:45:10 2023 +0100
Commit: Armin Le Grand 
CommitDate: Wed Feb 15 14:46:11 2023 +

MCGR: Add GradientSteps to GeoTexSvxGradient

Move GradientSteps data to GeoTexSvxGradient and adapt
interfaces. Also move tooling to more isolated place
in gradienttools in basegfx.

Keep everything still compatible, the work will be now
to adapt all six different derivations of
GeoTexSvxGradient to make use of the evtl. given
GradientSteps.

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

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index c6e716510432..3f2480c82e84 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -29,7 +29,7 @@ namespace basegfx
 {
 return getTextureTransform() == rODFGradientInfo.getTextureTransform()
 && getAspectRatio() == rODFGradientInfo.getAspectRatio()
-&& getSteps() == rODFGradientInfo.getSteps();
+&& getRequestedSteps() == rODFGradientInfo.getRequestedSteps();
 }
 
 const B2DHomMatrix& ODFGradientInfo::getBackTextureTransform() const
@@ -261,6 +261,26 @@ namespace basegfx
 
 namespace utils
 {
+sal_uInt32 calculateNumberOfSteps(
+sal_uInt32 nRequestedSteps,
+const BColor& rStart,
+const BColor& rEnd)
+{
+const sal_uInt32 
nMaxSteps(sal_uInt32((rStart.getMaximumDistance(rEnd) * 127.5) + 0.5));
+
+if (0 == nRequestedSteps)
+{
+nRequestedSteps = nMaxSteps;
+}
+
+if(nRequestedSteps > nMaxSteps)
+{
+nRequestedSteps = nMaxSteps;
+}
+
+return std::max(sal_uInt32(1), nRequestedSteps);
+}
+
 ODFGradientInfo createLinearODFGradientInfo(
 const B2DRange& rTargetArea,
 sal_uInt32 nSteps,
@@ -372,7 +392,7 @@ namespace basegfx
 return 1.0; // end value for outside
 }
 
-const sal_uInt32 nSteps(rGradInfo.getSteps());
+const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
 
 if(nSteps)
 {
@@ -399,7 +419,7 @@ namespace basegfx
 return 1.0; // use end value when outside in Y
 }
 
-const sal_uInt32 nSteps(rGradInfo.getSteps());
+const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
 
 if(nSteps)
 {
@@ -419,7 +439,7 @@ namespace basegfx
 }
 
 const double t(1.0 - std::hypot(aCoor.getX(), aCoor.getY()));
-const sal_uInt32 nSteps(rGradInfo.getSteps());
+const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
 
 if(nSteps && t < 1.0)
 {
@@ -452,7 +472,7 @@ namespace basegfx
 }
 
 const double t(1.0 - std::max(fAbsX, fAbsY));
-const sal_uInt32 nSteps(rGradInfo.getSteps());
+const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
 
 if(nSteps && t < 1.0)
 {
diff --git a/drawinglayer/inc/texture/texture.hxx 
b/drawinglayer/inc/texture/texture.hxx
index 9cfb2d6d56f7..567a24417f51 100644
--- a/drawinglayer/inc/texture/texture.hxx
+++ b/drawinglayer/inc/texture/texture.hxx
@@ -56,15 +56,15 @@ namespace drawinglayer::texture
 protected:
 basegfx::ODFGradientInfomaGradientInfo;
 basegfx::B2DRange   maDefinitionRange;
-basegfx::BColor maStart;
-basegfx::BColor maEnd;
+sal_uInt32

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

2023-01-25 Thread Caolán McNamara (via logerrit)
 basegfx/source/polygon/b2dpolygonclipper.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit df470d9658c202a990b9c75e2a8d6e3fd7a06dfd
Author: Caolán McNamara 
AuthorDate: Wed Jan 25 19:42:37 2023 +
Commit: Caolán McNamara 
CommitDate: Wed Jan 25 20:39:08 2023 +

ofz#54437 Timeout

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

diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx 
b/basegfx/source/polygon/b2dpolygonclipper.cxx
index 69eba2c84fa7..e9099b730578 100644
--- a/basegfx/source/polygon/b2dpolygonclipper.cxx
+++ b/basegfx/source/polygon/b2dpolygonclipper.cxx
@@ -489,7 +489,7 @@ namespace basegfx::utils
 // be solved again, they were solved in the preparation.
 aRetval.append(aMergePolyPolygonA);
 aRetval.append(aMergePolyPolygonB);
-aRetval = solveCrossovers(aRetval);
+aRetval = solveCrossovers(aRetval, pPointLimit);
 
 // now remove neutral polygons (closed, but no area). In a 
last
 // step throw away all polygons which have a depth of less 
than 1


[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

2022-12-21 Thread Caolán McNamara (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   20 
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 2ce749a428d1df2c659ecfdaf2e151dd07d3f1b3
Author: Caolán McNamara 
AuthorDate: Wed Dec 21 14:23:10 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Dec 21 23:59:31 2022 +

cid#1517814 Calling risky function

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

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index bd6157f373d5..f27ffcc9aaf0 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -18,10 +18,10 @@
  */
 
 #include 
-
 #include 
-
+#include 
 #include 
+#include 
 
 namespace basegfx
 {
@@ -304,17 +304,21 @@ namespace basegfx
 if(1.0 <= mfRandomPart)
 {
 // full randomized color
-const double fMul(1.0 / RAND_MAX);
-return basegfx::BColor(rand() * fMul, rand() * fMul, rand() * 
fMul);
+return basegfx::BColor(
+comphelper::rng::uniform_real_distribution(0.0, 
nextafter(1.0, DBL_MAX)),
+comphelper::rng::uniform_real_distribution(0.0, 
nextafter(1.0, DBL_MAX)),
+comphelper::rng::uniform_real_distribution(0.0, 
nextafter(1.0, DBL_MAX)));
 }
 
 // mixed color
 const double fMulA(1.0 - mfRandomPart);
-const double fMulB(mfRandomPart / RAND_MAX);
 return basegfx::BColor(
-aSourceColor.getRed() * fMulA + rand() * fMulB,
-aSourceColor.getGreen() * fMulA + rand() * fMulB,
-aSourceColor.getBlue() * fMulA + rand() * fMulB);
+aSourceColor.getRed() * fMulA +
+comphelper::rng::uniform_real_distribution(0.0, 
nextafter(mfRandomPart, DBL_MAX)),
+aSourceColor.getGreen() * fMulA +
+comphelper::rng::uniform_real_distribution(0.0, 
nextafter(mfRandomPart, DBL_MAX)),
+aSourceColor.getBlue() * fMulA +
+comphelper::rng::uniform_real_distribution(0.0, 
nextafter(mfRandomPart, DBL_MAX)));
 }
 
 ::basegfx::BColor BColorModifierStack::getModifiedColor(const 
::basegfx::BColor& rSource) const


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

2022-10-30 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 24a2c65e7ea15166061d96352164b51c5ffd9fa8
Author: Noel Grandin 
AuthorDate: Sun Oct 30 08:01:00 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun Oct 30 11:26:39 2022 +0100

tdf#126788 use singleton to avoid initial allocation

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

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index b0171ef000e2..ed5954bf0cf7 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1075,7 +1075,10 @@ public:
 
 namespace basegfx
 {
-B2DPolygon::B2DPolygon() = default;
+static o3tl::cow_wrapper DEFAULT;
+
+B2DPolygon::B2DPolygon()
+: mpPolygon(DEFAULT) {}
 
 B2DPolygon::B2DPolygon(std::initializer_list aPoints)
 {


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

2022-09-21 Thread Mike Kaganski (via logerrit)
 basegfx/source/polygon/b2dpolypolygon.cxx |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

New commits:
commit 4e738b824d825717b7c6b895d816dcac1adf08e1
Author: Mike Kaganski 
AuthorDate: Wed Sep 21 15:28:12 2022 +0300
Commit: Mike Kaganski 
CommitDate: Wed Sep 21 17:06:05 2022 +0200

basegfx: remove global ImplB2DPolyPolygon

Similar to commit 7e911e9cd469d30369c213aa529675b3f7c4f0e8
  Author Michael Stahl 
  Date   Fri Aug 25 20:51:22 2017 +0200
basegfx: remove global ImplB2DPolygon

There shouldn't be allocations of the objects just to destroy them
without populating with data (it there are, they should be optimized
away); and for any reasonable use, defaulting to a shared instance
means that there is an unnecessary refcount increase and decrease
aside from inevitable allocation of the unique instance.

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

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index 1889ddae4220..547634dc4dad 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -211,10 +211,7 @@ public:
 }
 };
 
-static o3tl::cow_wrapper DEFAULT;
-
-B2DPolyPolygon::B2DPolyPolygon() :
-mpPolyPolygon(DEFAULT) {}
+B2DPolyPolygon::B2DPolyPolygon() = default;
 
 B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon&) = default;
 
@@ -301,9 +298,7 @@ public:
 B2DPolyPolygon aRetval;
 if (count())
 {
-// Avoid CoW overhead for the local variable
-// But detach from shared static DEFAULT
-ImplB2DPolyPolygon& dest = aRetval.mpPolyPolygon.make_unique();
+ImplB2DPolyPolygon& dest = *aRetval.mpPolyPolygon;
 dest.reserve(count());
 
 for (sal_uInt32 a(0); a < count(); a++)


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

2022-09-20 Thread Mike Kaganski (via logerrit)
 basegfx/source/polygon/b2dpolypolygon.cxx |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit e4a72aa946b6c41a91dc6e74634093a83b9c22bd
Author: Mike Kaganski 
AuthorDate: Tue Sep 20 18:28:36 2022 +0300
Commit: Mike Kaganski 
CommitDate: Tue Sep 20 21:20:08 2022 +0200

tdf#151056: avoid modifying the static shared DEFAULT instance

This was a thinko in commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4
  Simplify b2d(poly)polygon implementation

This led to exponential growth of elements in each next polypolygon
created from scratch, that immediately manifested with the complex
SVG logo shown on the backing window.
And finally, there's no const_cast/as_const left in the file :)

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

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index 6ce3b398a1fb..1889ddae4220 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -299,13 +299,17 @@ public:
 B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const
 {
 B2DPolyPolygon aRetval;
-// Avoid CoW overhead for the local variable
-auto dest = 
const_cast(std::as_const(aRetval).mpPolyPolygon.get());
-dest->reserve(count());
-
-for(sal_uInt32 a(0); a < count(); a++)
+if (count())
 {
-dest->append(getB2DPolygon(a).getDefaultAdaptiveSubdivision(), 1);
+// Avoid CoW overhead for the local variable
+// But detach from shared static DEFAULT
+ImplB2DPolyPolygon& dest = aRetval.mpPolyPolygon.make_unique();
+dest.reserve(count());
+
+for (sal_uInt32 a(0); a < count(); a++)
+{
+dest.append(getB2DPolygon(a).getDefaultAdaptiveSubdivision(), 
1);
+}
 }
 
 return aRetval;


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

2022-09-20 Thread Mike Kaganski (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx |9 +
 basegfx/source/polygon/b2dpolypolygon.cxx |2 ++
 2 files changed, 11 insertions(+)

New commits:
commit c8649af8d0353e2fba2e472f0ace50f5bd8167b2
Author: Mike Kaganski 
AuthorDate: Tue Sep 20 11:16:17 2022 +0300
Commit: Mike Kaganski 
CommitDate: Tue Sep 20 17:26:54 2022 +0200

Assert that cow_wrapped objects aren't called to do nothing

An omission from commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4
  Simplify b2d(poly)polygon implementation

Change-Id: Ib0b10e06baf91888f0e9797e670e0626f512af15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140229
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index 03957c8710a3..b0171ef000e2 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -82,6 +82,7 @@ public:
 
 void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 
nCount)
 {
+assert(nCount > 0);
 assert(nIndex <= maVector.size());
 // add nCount copies of rValue
 maVector.insert(maVector.begin() + nIndex, nCount, rValue);
@@ -89,6 +90,7 @@ public:
 
 void insert(sal_uInt32 nIndex, const CoordinateDataArray2D& rSource)
 {
+assert(rSource.maVector.size() > 0);
 assert(nIndex <= maVector.size());
 // insert data
 auto aIndex = maVector.begin();
@@ -100,6 +102,7 @@ public:
 
 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
 {
+assert(nCount > 0);
 assert(nIndex + nCount <= maVector.size());
 // remove point data
 const auto aStart = maVector.begin() + nIndex;
@@ -328,6 +331,7 @@ public:
 
 void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, 
sal_uInt32 nCount)
 {
+assert(nCount > 0);
 assert(nIndex <= maVector.size());
 
 // add nCount copies of rValue
@@ -342,6 +346,7 @@ public:
 
 void insert(sal_uInt32 nIndex, const ControlVectorArray2D& rSource)
 {
+assert(rSource.maVector.size() > 0);
 assert(nIndex <= maVector.size());
 
 // insert data
@@ -362,6 +367,7 @@ public:
 
 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
 {
+assert(nCount > 0);
 assert(nIndex + nCount <= maVector.size());
 
 const ControlVectorPair2DVector::iterator 
aDeleteStart(maVector.begin() + nIndex);
@@ -689,6 +695,7 @@ public:
 
 void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 
nCount)
 {
+assert(nCount > 0);
 mpBufferedData.reset();
 auto aCoordinate = rPoint;
 maPoints.insert(nIndex, aCoordinate, nCount);
@@ -804,6 +811,7 @@ public:
 
 void append(const ImplB2DPolygon& rSource)
 {
+assert(rSource.maPoints.count() > 0);
 const sal_uInt32 nIndex = count();
 
 mpBufferedData.reset();
@@ -828,6 +836,7 @@ public:
 
 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
 {
+assert(nCount > 0);
 mpBufferedData.reset();
 maPoints.remove(nIndex, nCount);
 
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index dc8f0f53e98c..6ce3b398a1fb 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -102,6 +102,7 @@ public:
 
 void insert(sal_uInt32 nIndex, const basegfx::B2DPolygon& rPolygon, 
sal_uInt32 nCount)
 {
+assert(nCount > 0);
 assert(nIndex <= maPolygons.size());
 // add nCount copies of rPolygon
 maPolygons.insert(maPolygons.begin() + nIndex, nCount, rPolygon);
@@ -131,6 +132,7 @@ public:
 
 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
 {
+assert(nCount > 0);
 assert(nIndex + nCount <= maPolygons.size());
 // remove polygon data
 auto aStart(maPolygons.begin() + nIndex);


[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

2022-09-15 Thread Radhey Parekh (via logerrit)
 basegfx/source/workbench/gauss.hxx |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

New commits:
commit 51a780a26e4fbf339d4136ff0c7d75e01d6fad08
Author: Radhey Parekh 
AuthorDate: Thu Sep 15 15:37:50 2022 +0200
Commit: Hossein 
CommitDate: Thu Sep 15 18:07:06 2022 +0200

tdf#148251 Use std::swap() instead of using temporary values

Change-Id: Ifdf59f4957428efdc56009947f8c87f6b6351603
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139273
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/basegfx/source/workbench/gauss.hxx 
b/basegfx/source/workbench/gauss.hxx
index 3605c1cac9bd..4ef050ccbc52 100644
--- a/basegfx/source/workbench/gauss.hxx
+++ b/basegfx/source/workbench/gauss.hxx
@@ -47,8 +47,6 @@ bool eliminate( Matrix& matrix,
 int cols,
 const BaseType& minPivot)
 {
-BaseTypetemp;
-
 /* i, j, k *must* be signed, when looping like: j>=0 ! */
 /* eliminate below main diagonal */
 for(int i=0; i

[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

2022-09-01 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrix.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 153b51da381ba21d46a3d42c939080272818797c
Author: Noel Grandin 
AuthorDate: Mon Aug 22 11:21:50 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Sep 1 19:31:07 2022 +0200

reduce cost of B2DHomMatrix::isIdentity

often the matrix is still default

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

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index c21a4dceeccd..9811304d 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -82,7 +82,7 @@ namespace basegfx
 
 bool B2DHomMatrix::isIdentity() const
 {
-return mpImpl->isIdentity();
+return mpImpl.same_object(DEFAULT) || mpImpl->isIdentity();
 }
 
 void B2DHomMatrix::identity()


[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

2022-07-01 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrix.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 78fece3619e986ae0e4a41594965af83214f7da8
Author: Noel Grandin 
AuthorDate: Thu Jun 30 12:49:09 2022 +0200
Commit: Noel Grandin 
CommitDate: Fri Jul 1 11:01:15 2022 +0200

small optimisation

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

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index f3d2622db27a..c21a4dceeccd 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -103,12 +103,12 @@ namespace basegfx
 }
 
 Impl2DHomMatrix aWork(*mpImpl);
-std::unique_ptr pIndex( new 
sal_uInt16[Impl2DHomMatrix_Base::getEdgeLength()] );
+sal_uInt16* pIndex = static_cast(alloca( 
sizeof(sal_uInt16) * Impl2DHomMatrix_Base::getEdgeLength() ));
 sal_Int16 nParity;
 
-if(aWork.ludcmp(pIndex.get(), nParity))
+if(aWork.ludcmp(pIndex, nParity))
 {
-mpImpl->doInvert(aWork, pIndex.get());
+mpImpl->doInvert(aWork, pIndex);
 return true;
 }
 


[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

2022-05-16 Thread Tomaž Vajngerl (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx |   55 ++
 1 file changed, 17 insertions(+), 38 deletions(-)

New commits:
commit c9711f2ff2ee40f9e3928325ac1ba7c47da158ad
Author: Tomaž Vajngerl 
AuthorDate: Sun May 15 22:52:48 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon May 16 17:09:51 2022 +0200

basegfx: remove CoordinateData2D class and use B2DPoint directly

For some reason B2DPolygon used a CoordinateData2D class that
derived from basegfx::B2DPoint with no added functionallity that
is used in practice (just an explicit method transform instead of
using an operator*=). This class has been removed and replaced
with B2DPoint instead.

Also removed was the typdef CoordinateData2DVector and calls to
the std::vector's iterator (begin, end) have been simplified with
"auto".

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

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index 3c85a2666d25..8a413eaa 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -28,34 +28,13 @@
 #include 
 #include 
 
-namespace {
-
-struct CoordinateData2D : public basegfx::B2DPoint
+namespace
 {
-public:
-CoordinateData2D() {}
-
-explicit CoordinateData2D(const basegfx::B2DPoint& rData)
-:   B2DPoint(rData)
-{}
-
-CoordinateData2D& operator=(const basegfx::B2DPoint& rData)
-{
-B2DPoint::operator=(rData);
-return *this;
-}
-
-void transform(const basegfx::B2DHomMatrix& rMatrix)
-{
-*this *= rMatrix;
-}
-};
 
 class CoordinateDataArray2D
 {
-typedef std::vector< CoordinateData2D > CoordinateData2DVector;
-
-CoordinateData2DVector  maVector;
+private:
+std::vector maVector;
 
 public:
 explicit CoordinateDataArray2D(sal_uInt32 nCount)
@@ -93,17 +72,17 @@ public:
 maVector.reserve(nCount);
 }
 
-void append(const CoordinateData2D& rValue)
+void append(const basegfx::B2DPoint& rValue)
 {
 maVector.push_back(rValue);
 }
 
-void insert(sal_uInt32 nIndex, const CoordinateData2D& rValue, sal_uInt32 
nCount)
+void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 
nCount)
 {
 if(nCount)
 {
 // add nCount copies of rValue
-CoordinateData2DVector::iterator aIndex(maVector.begin());
+auto aIndex = maVector.begin();
 aIndex += nIndex;
 maVector.insert(aIndex, nCount, rValue);
 }
@@ -116,10 +95,10 @@ public:
 if(nCount)
 {
 // insert data
-CoordinateData2DVector::iterator aIndex(maVector.begin());
+auto aIndex = maVector.begin();
 aIndex += nIndex;
-CoordinateData2DVector::const_iterator 
aStart(rSource.maVector.begin());
-CoordinateData2DVector::const_iterator 
aEnd(rSource.maVector.end());
+auto aStart = rSource.maVector.cbegin();
+auto aEnd = rSource.maVector.cend();
 maVector.insert(aIndex, aStart, aEnd);
 }
 }
@@ -129,9 +108,9 @@ public:
 if(nCount)
 {
 // remove point data
-CoordinateData2DVector::iterator aStart(maVector.begin());
+auto aStart = maVector.begin();
 aStart += nIndex;
-const CoordinateData2DVector::iterator aEnd(aStart + nCount);
+const auto aEnd = aStart + nCount;
 maVector.erase(aStart, aEnd);
 }
 }
@@ -144,8 +123,8 @@ public:
 // to keep the same point at index 0, just flip all points except the
 // first one when closed
 const sal_uInt32 nHalfSize(bIsClosed ? (maVector.size() - 1) >> 1 : 
maVector.size() >> 1);
-CoordinateData2DVector::iterator aStart(bIsClosed ? maVector.begin() + 
1 : maVector.begin());
-CoordinateData2DVector::iterator aEnd(maVector.end() - 1);
+auto aStart = bIsClosed ? maVector.begin() + 1 : maVector.begin();
+auto aEnd = maVector.end() - 1;
 
 for(sal_uInt32 a(0); a < nHalfSize; a++)
 {
@@ -188,9 +167,9 @@ public:
 
 void transform(const basegfx::B2DHomMatrix& rMatrix)
 {
-for (auto & elem : maVector)
+for (auto& point : maVector)
 {
-elem.transform(rMatrix);
+point *= rMatrix;
 }
 }
 };
@@ -713,7 +692,7 @@ public:
 void append(const basegfx::B2DPoint& rPoint)
 {
 mpBufferedData.reset(); // TODO: is this needed?
-const CoordinateData2D aCoordinate(rPoint);
+const auto aCoordinate = rPoint;
 maPoints.append(aCoordinate);
 
 if(moControlVector)
@@ -728,7 +707,7 @@ public:
 if(nCount)
 {
 

[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

2022-05-07 Thread Caolán McNamara (via logerrit)
 basegfx/source/tools/systemdependentdata.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 441889318ff3bd1340e5c3d8afd868db948f1535
Author: Caolán McNamara 
AuthorDate: Sat May 7 20:22:56 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 7 22:53:21 2022 +0200

ofz#46070 Out-of-memory

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

diff --git a/basegfx/source/tools/systemdependentdata.cxx 
b/basegfx/source/tools/systemdependentdata.cxx
index 6bf80413d12b..0d64d9982cef 100644
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -37,6 +37,10 @@ namespace basegfx
 
 sal_uInt32 SystemDependentData::calculateCombinedHoldCyclesInSeconds() 
const
 {
+#if ENABLE_FUZZERS
+return 0;
+#endif
+
 if(0 == mnCalculatedCycles)
 {
 const sal_Int64 nBytes(estimateUsageInBytes());
@@ -49,11 +53,7 @@ namespace basegfx
 if(nBytes > 450)
 {
 // HoldCyclesInSeconds
-#if !ENABLE_FUZZERS
 const sal_uInt32 nSeconds = 60;
-#else
-const sal_uInt32 nSeconds = 1;
-#endif
 
 // default is Seconds (minimal is one)
 sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);


[Libreoffice-commits] core.git: basegfx/source basic/source chart2/source connectivity/source include/rtl include/sax include/unotools include/xmloff oox/source sal/qa sax/source sc/source sd/source s

2022-04-27 Thread Noel Grandin (via logerrit)
 basegfx/source/tools/stringconversiontools.cxx |2 
 basic/source/sbx/sbxscan.cxx   |5 -
 chart2/source/inc/CommonFunctors.hxx   |2 
 connectivity/source/drivers/dbase/DTable.cxx   |2 
 include/rtl/math.hxx   |   38 +
 include/sax/tools/converter.hxx|9 +++
 include/unotools/localedatawrapper.hxx |4 -
 include/xmloff/xmluconv.hxx|3 +
 oox/source/ppt/timenodelistcontext.cxx |2 
 oox/source/vml/vmlformatting.cxx   |4 -
 sal/qa/rtl/math/test-rtl-math.cxx  |   70 -
 sax/source/tools/converter.cxx |   35 
 sc/source/core/tool/stringutil.cxx |   10 +--
 sc/source/filter/oox/condformatbuffer.cxx  |7 +-
 sd/source/filter/ppt/pptinanimations.cxx   |2 
 svgio/source/svgreader/svgtools.cxx|2 
 svl/source/numbers/zforfind.cxx|2 
 sw/source/core/doc/docsort.cxx |2 
 sw/source/core/inc/docsort.hxx |2 
 unotools/source/i18n/localedatawrapper.cxx |   17 +-
 vcl/inc/strhelper.hxx  |4 -
 xmloff/source/core/xmluconv.cxx|   27 ++---
 22 files changed, 168 insertions(+), 83 deletions(-)

New commits:
commit d506ff97c25b5f433aa25d8b373f1a732af493d1
Author: Noel Grandin 
AuthorDate: Tue Apr 26 17:47:18 2022 +0200
Commit: Noel Grandin 
CommitDate: Wed Apr 27 12:19:55 2022 +0200

add string_view wrappers for rtl::math::stringToDouble

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

diff --git a/basegfx/source/tools/stringconversiontools.cxx 
b/basegfx/source/tools/stringconversiontools.cxx
index d6a702faa687..3a671ae539f0 100644
--- a/basegfx/source/tools/stringconversiontools.cxx
+++ b/basegfx/source/tools/stringconversiontools.cxx
@@ -110,7 +110,7 @@ namespace basegfx::internal
 if(sNumberString.getLength())
 {
 rtl_math_ConversionStatus eStatus;
-o_fRetval = ::rtl::math::stringToDouble( 
sNumberString.makeStringAndClear(),
+o_fRetval = ::rtl::math::stringToDouble( sNumberString,
 '.',
 ',',
  );
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index ae6d50b9cfdf..82080df4a62a 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -172,11 +172,10 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
 if( decsep > 1 || exp > 1 )
 bRes = false;
 
-OUString aBufStr( aBuf.makeStringAndClear());
 rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
 sal_Int32 nParseEnd = 0;
-nVal = rtl::math::stringToDouble( aBufStr, cIntntlDecSep, 
cIntntlGrpSep, ,  );
-if( eStatus != rtl_math_ConversionStatus_Ok || nParseEnd != 
aBufStr.getLength() )
+nVal = rtl::math::stringToDouble( aBuf, cIntntlDecSep, cIntntlGrpSep, 
,  );
+if( eStatus != rtl_math_ConversionStatus_Ok || nParseEnd != 
aBuf.getLength() )
 bRes = false;
 
 if( !decsep && !exp )
diff --git a/chart2/source/inc/CommonFunctors.hxx 
b/chart2/source/inc/CommonFunctors.hxx
index 0340c82b692e..4abdcc168ae6 100644
--- a/chart2/source/inc/CommonFunctors.hxx
+++ b/chart2/source/inc/CommonFunctors.hxx
@@ -91,7 +91,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString
  */
 struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble
 {
-double operator() ( const OUString & rStr )
+double operator() ( std::u16string_view rStr )
 {
 rtl_math_ConversionStatus eConversionStatus;
 double fResult = ::rtl::math::stringToDouble( rStr, '.', ',', & 
eConversionStatus );
diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index eedba74a57cd..c157e795e72b 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -1648,7 +1648,7 @@ Reference 
ODbaseTable::isUniqueByColumnName(sal_Int32 _nColumnPos)
 return Reference();
 }
 
-static double toDouble(const OString& rString)
+static double toDouble(std::string_view rString)
 {
 return ::rtl::math::stringToDouble( rString, '.', ',' );
 }
diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx
index 7da30df6832b..661ddf1d131d 100644
--- a/include/rtl/math.hxx
+++ b/include/rtl/math.hxx
@@ -173,6 +173,23 @@ inline void doubleToUStringBuffer( rtl::OUStringBuffer& 
rBuffer, double fValue,
 
 /** A wrapper around rtl_math_stringToDouble.
  */
+#ifdef LIBO_INTERNAL_ONLY
+inline double 

[Libreoffice-commits] core.git: basegfx/source comphelper/source cppuhelper/source hwpfilter/source include/basegfx package/source sot/source ucbhelper/source unotools/source vcl/inc vcl/source

2022-04-26 Thread Stephan Bergmann (via logerrit)
 basegfx/source/tools/unopolypolygon.cxx|8 
 comphelper/source/container/IndexedPropertyValuesContainer.cxx |3 ++-
 comphelper/source/container/interfacecontainer2.cxx|3 ++-
 comphelper/source/misc/accessiblekeybindinghelper.cxx  |3 ++-
 cppuhelper/source/interfacecontainer.cxx   |3 ++-
 hwpfilter/source/hcode.cxx |5 +++--
 include/basegfx/utils/unopolypolygon.hxx   |3 ++-
 package/source/zipapi/ZipFile.cxx  |3 ++-
 sot/source/sdstor/stgcache.cxx |3 ++-
 sot/source/sdstor/stgcache.hxx |3 ++-
 ucbhelper/source/provider/propertyvalueset.cxx |5 +++--
 unotools/source/i18n/localedatawrapper.cxx |3 ++-
 vcl/inc/pdf/pdfwriter_impl.hxx |2 +-
 vcl/source/control/ctrl.cxx|3 ++-
 vcl/source/control/roadmap.cxx |3 ++-
 vcl/source/window/printdlg.cxx |3 ++-
 16 files changed, 35 insertions(+), 21 deletions(-)

New commits:
commit bdff0bb77b57def835fcaed3bded7519e69dc896
Author: Stephan Bergmann 
AuthorDate: Tue Apr 26 15:08:36 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Apr 26 17:04:01 2022 +0200

Use o3tl::make_unsigned in some places

...where a signed and an unsigned value are compared, and the signed value 
has
just been proven to be non-negative here

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

diff --git a/basegfx/source/tools/unopolypolygon.cxx 
b/basegfx/source/tools/unopolypolygon.cxx
index 48b3372d5526..ce61a5d3451b 100644
--- a/basegfx/source/tools/unopolypolygon.cxx
+++ b/basegfx/source/tools/unopolypolygon.cxx
@@ -229,7 +229,7 @@ namespace basegfx::unotools
 
 const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
 
-if( nPointIndex < 0 || nPointIndex >= 
static_cast(rPoly.count()) )
+if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= 
rPoly.count() )
 throw lang::IndexOutOfBoundsException();
 
 return unotools::point2DFromB2DPoint( rPoly.getB2DPoint( nPointIndex ) 
);
@@ -246,7 +246,7 @@ namespace basegfx::unotools
 
 B2DPolygon aPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
 
-if( nPointIndex < 0 || nPointIndex >= 
static_cast(aPoly.count()) )
+if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= 
aPoly.count() )
 throw lang::IndexOutOfBoundsException();
 
 aPoly.setB2DPoint( nPointIndex,
@@ -297,7 +297,7 @@ namespace basegfx::unotools
 const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
 const sal_uInt32  nPointCount(rPoly.count());
 
-if( nPointIndex < 0 || nPointIndex >= 
static_cast(nPointCount) )
+if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= nPointCount 
)
 throw lang::IndexOutOfBoundsException();
 
 const B2DPoint& rPt( rPoly.getB2DPoint( nPointIndex ) );
@@ -323,7 +323,7 @@ namespace basegfx::unotools
 B2DPolygon aPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
 const sal_uInt32 nPointCount(aPoly.count());
 
-if( nPointIndex < 0 || nPointIndex >= 
static_cast(nPointCount) )
+if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= nPointCount 
)
 throw lang::IndexOutOfBoundsException();
 
 aPoly.setB2DPoint( nPointIndex,
diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx 
b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
index c0086061b033..08b46518bebf 100644
--- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx
+++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -89,7 +90,7 @@ void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( 
sal_Int32 nIndex, c
 
 void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex )
 {
-if ((nIndex >= sal_Int32(maProperties.size())) || (nIndex < 0))
+if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= maProperties.size()))
 throw lang::IndexOutOfBoundsException();
 
 maProperties.erase(maProperties.begin() + nIndex);
diff --git a/comphelper/source/container/interfacecontainer2.cxx 
b/comphelper/source/container/interfacecontainer2.cxx
index 0881ccbe44cf..9acff0a7f761 100644
--- a/comphelper/source/container/interfacecontainer2.cxx
+++ b/comphelper/source/container/interfacecontainer2.cxx
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -103,7 +104,7 @@ void 

[Libreoffice-commits] core.git: basegfx/source comphelper/source filter/source include/basegfx include/comphelper include/sfx2 include/tools l10ntools/inc l10ntools/source reportdesign/source sfx2/sou

2022-04-10 Thread Noel Grandin (via logerrit)
 basegfx/source/inc/stringconversiontools.hxx  |2 
 basegfx/source/polygon/b2dsvgpolypolygon.cxx  |8 -
 basegfx/source/tools/stringconversiontools.cxx|   19 ++--
 comphelper/source/misc/accessibletexthelper.cxx   |4 
 comphelper/source/misc/docpasswordhelper.cxx  |6 -
 comphelper/source/misc/mimeconfighelper.cxx   |8 -
 comphelper/source/misc/storagehelper.cxx  |   17 +--
 filter/source/xsltdialog/xmlfilterjar.cxx |4 
 include/basegfx/polygon/b2dpolygontools.hxx   |2 
 include/basegfx/polygon/b2dpolypolygontools.hxx   |2 
 include/comphelper/accessibletexthelper.hxx   |2 
 include/comphelper/docpasswordhelper.hxx  |3 
 include/comphelper/mimeconfighelper.hxx   |2 
 include/comphelper/storagehelper.hxx  |2 
 include/sfx2/docfile.hxx  |2 
 include/tools/Guid.hxx|6 -
 l10ntools/inc/cfgmerge.hxx|2 
 l10ntools/inc/helper.hxx  |8 -
 l10ntools/inc/po.hxx  |2 
 l10ntools/source/cfgmerge.cxx |4 
 l10ntools/source/helper.cxx   |   46 
+-
 l10ntools/source/po.cxx   |   26 ++---
 reportdesign/source/core/sdr/ReportDrawPage.cxx   |2 
 sfx2/source/doc/docfile.cxx   |4 
 slideshow/source/engine/animationfactory.cxx  |2 
 stoc/source/uriproc/UriReferenceFactory.cxx   |   14 +--
 stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx |   19 ++--
 ucb/source/ucp/package/pkguri.cxx |4 
 unoidl/source/sourceprovider-parser.y |9 +
 unoidl/source/sourcetreeprovider.cxx  |8 -
 unoidl/source/unoidlprovider.cxx  |   12 +-
 31 files changed, 128 insertions(+), 123 deletions(-)

New commits:
commit b24a4d255d31233c48152e6e1ce992a693cdaeae
Author: Noel Grandin 
AuthorDate: Sun Apr 10 15:36:21 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun Apr 10 20:15:16 2022 +0200

use more string_view

found by tweaking the loplugin:stringview and making it whitelist
getLength

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

diff --git a/basegfx/source/inc/stringconversiontools.hxx 
b/basegfx/source/inc/stringconversiontools.hxx
index fdf2f83e0f4e..797697d203ac 100644
--- a/basegfx/source/inc/stringconversiontools.hxx
+++ b/basegfx/source/inc/stringconversiontools.hxx
@@ -51,7 +51,7 @@ namespace basegfx::internal
 
 bool importDoubleAndSpaces(double&  o_fRetval,
sal_Int32&   io_rPos,
-   const OUString&  rStr,
+   std::u16string_view  rStr,
const sal_Int32  nLen );
 
 bool importFlagAndSpaces(sal_Int32&  o_nRetval,
diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx 
b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index 323fff14c024..aa0fedb2ddf2 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -74,12 +74,12 @@ namespace basegfx::utils
 
 bool importFromSvgD(
 B2DPolyPolygon& o_rPolyPolygon,
-const OUString& rSvgDStatement,
+std::u16string_view rSvgDStatement,
 bool bHandleRelativeNextPointCompatible,
 PointIndexSet* pHelpPointIndexSet)
 {
 o_rPolyPolygon.clear();
-const sal_Int32 nLen(rSvgDStatement.getLength());
+const sal_Int32 nLen(rSvgDStatement.size());
 sal_Int32 nPos(0);
 double nLastX( 0.0 );
 double nLastY( 0.0 );
@@ -664,10 +664,10 @@ namespace basegfx::utils
 }
 
 bool importFromSvgPoints( B2DPolygon&o_rPoly,
-  const OUString& rSvgPointsAttribute )
+  std::u16string_view rSvgPointsAttribute )
 {
 o_rPoly.clear();
-const sal_Int32 nLen(rSvgPointsAttribute.getLength());
+const sal_Int32 nLen(rSvgPointsAttribute.size());
 sal_Int32 nPos(0);
 double nX, nY;
 
diff --git a/basegfx/source/tools/stringconversiontools.cxx 

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

2022-03-30 Thread Caolán McNamara (via logerrit)
 basegfx/source/tools/systemdependentdata.cxx |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 84f5a7f5c714ed57e9ff7e0a2231425e52d3f4b8
Author: Caolán McNamara 
AuthorDate: Tue Mar 29 21:01:59 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Mar 30 09:40:20 2022 +0200

ofz#46070 Out-of-memory

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

diff --git a/basegfx/source/tools/systemdependentdata.cxx 
b/basegfx/source/tools/systemdependentdata.cxx
index 106124f57389..6bf80413d12b 100644
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 
 namespace basegfx
@@ -47,7 +48,12 @@ namespace basegfx
 // For the future, a more sophisticated differentiation may be 
added
 if(nBytes > 450)
 {
-const sal_uInt32 nSeconds = 60; // HoldCyclesInSeconds
+// HoldCyclesInSeconds
+#if !ENABLE_FUZZERS
+const sal_uInt32 nSeconds = 60;
+#else
+const sal_uInt32 nSeconds = 1;
+#endif
 
 // default is Seconds (minimal is one)
 sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);


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

2022-03-29 Thread Bartosz Kosiorek (via logerrit)
 basegfx/source/workbench/bezierclip.cxx  |2 +-
 chart2/source/view/charttypes/PieChart.cxx   |8 +++-
 chart2/source/view/charttypes/VSeriesPlotter.cxx |3 ++-
 emfio/source/reader/mtftools.cxx |2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)

New commits:
commit a2d49b680cd026c3d64683f6ee3ba97e9834a7f7
Author: Bartosz Kosiorek 
AuthorDate: Mon Mar 28 15:38:48 2022 +0200
Commit: Mike Kaganski 
CommitDate: Tue Mar 29 09:17:42 2022 +0200

tdf#147906 change sqrt(a * a + b * b) occurences to std::hypot(a, b)

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

diff --git a/basegfx/source/workbench/bezierclip.cxx 
b/basegfx/source/workbench/bezierclip.cxx
index 7c939f9b..676f239efd10 100644
--- a/basegfx/source/workbench/bezierclip.cxx
+++ b/basegfx/source/workbench/bezierclip.cxx
@@ -87,7 +87,7 @@ void Impl_calcFatLine( FatLine& line, const Bezier& c )
 line.b = (c.p0.x - c.p3.x);
 
 // normalize
-const double len( sqrt( line.a*line.a + line.b*line.b ) );
+const double len(std::hypot(line.a, line.b));
 if( !tolZero(len) )
 {
 line.a /= len;
diff --git a/chart2/source/view/charttypes/PieChart.cxx 
b/chart2/source/view/charttypes/PieChart.cxx
index cf1bfde1c294..cde47b9912fc 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -512,8 +512,7 @@ void PieChart::createTextLabelShape(
 {
 //when the line is very short compared to the page size don't 
create one
 ::basegfx::B2DVector aLength(nX1 - nX2, nY1 - nY2);
-double fPageDiagonaleLength = sqrt(double(nPageWidth) * 
double(nPageWidth)
-   + double(nPageHeight) * 
double(nPageHeight));
+double fPageDiagonaleLength = std::hypot(nPageWidth, 
nPageHeight);
 if ((aLength.getLength() / fPageDiagonaleLength) >= 0.01)
 {
 drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, 
{nX2, nY2} } };
@@ -1235,7 +1234,7 @@ void PieChart::rearrangeLabelToAvoidOverlapIfRequested( 
const awt::Size& rPageSi
 if(!bMoveableFound)
 return;
 
-double fPageDiagonaleLength = sqrt( 
double(rPageSize.Width)*double(rPageSize.Width) + 
double(rPageSize.Height)*double(rPageSize.Height) );
+double fPageDiagonaleLength = std::hypot(rPageSize.Width, 
rPageSize.Height);
 if( fPageDiagonaleLength == 0.0 )
 return;
 
@@ -1475,8 +1474,7 @@ bool 
PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
 
 // compute the length of the diagonal vector d,
 // that is the distance between P and F
-double fSquaredDistancePF = fDistancePM * fDistancePM + 
fOrthogonalEdgeLength * fOrthogonalEdgeLength;
-double fDistancePF = sqrt( fSquaredDistancePF );
+double fDistancePF = std::hypot(fDistancePM, fOrthogonalEdgeLength);
 
 SAL_INFO( "chart2.pie.label.bestfit.inside",
   "  width = " << fLabelWidth );
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 50bff922f861..8e5e9d5bf9af 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -720,7 +720,8 @@ rtl::Reference 
VSeriesPlotter::createDataLabel( const rtl::Referen
 
 //when the line is very short compared to the page size 
don't create one
 ::basegfx::B2DVector aLength(nX1 - nX2, nY1 - nY2);
-double fPageDiagonaleLength = 
sqrt(double(m_aPageReferenceSize.Width)*double(m_aPageReferenceSize.Width) + 
double(m_aPageReferenceSize.Height)*double(m_aPageReferenceSize.Height));
+double fPageDiagonaleLength
+= std::hypot(m_aPageReferenceSize.Width, 
m_aPageReferenceSize.Height);
 if ((aLength.getLength() / fPageDiagonaleLength) >= 0.01)
 {
 drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, 
{nX2, nY2} } };
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 5117411fc54f..b4973f6e51ab 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -1740,7 +1740,7 @@ namespace emfio
 double fY = aP2.Y();
 if ( fX )
 {
-double fOrientation = basegfx::rad2deg( acos( fX / sqrt( fX * 
fX + fY * fY ) ) );
+double fOrientation = basegfx::rad2deg(acos(fX / 
std::hypot(fX, fY)));
 if ( fY > 0 )
 fOrientation = 360 - fOrientation;
 fOrientation += 90;


[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

2022-03-18 Thread Gautham Krishnan (via logerrit)
 basegfx/source/tools/gradienttools.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 67fcd8f268fd04ca2012470af2257b394b77b8fc
Author: Gautham Krishnan 
AuthorDate: Sat Mar 12 21:16:59 2022 +0530
Commit: Hossein 
CommitDate: Fri Mar 18 18:46:00 2022 +0100

tdf#147906 used std::hypot for Pythagorean addition

Change-Id: I9bf10374af93cd22e429a112937aaa8828126523
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131504
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index b4f1f6222f52..c6e716510432 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -136,7 +136,7 @@ namespace basegfx
 // add object expansion
 if(bCircular)
 {
-const double fOriginalDiag(sqrt((fTargetSizeX * fTargetSizeX) + 
(fTargetSizeY * fTargetSizeY)));
+const double fOriginalDiag(std::hypot(fTargetSizeX, fTargetSizeY));
 
 fTargetOffsetX -= (fOriginalDiag - fTargetSizeX) / 2.0;
 fTargetOffsetY -= (fOriginalDiag - fTargetSizeY) / 2.0;
@@ -418,7 +418,7 @@ namespace basegfx
 return 0.0;
 }
 
-const double t(1.0 - sqrt(aCoor.getX() * aCoor.getX() + 
aCoor.getY() * aCoor.getY()));
+const double t(1.0 - std::hypot(aCoor.getX(), aCoor.getY()));
 const sal_uInt32 nSteps(rGradInfo.getSteps());
 
 if(nSteps && t < 1.0)


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

2022-03-15 Thread Hossein (via logerrit)
 basegfx/source/workbench/Makefile   |   13 --
 basegfx/source/workbench/bezierclip.cxx |  186 
 2 files changed, 95 insertions(+), 104 deletions(-)

New commits:
commit 59cb2aa7908e1a7079a6fb692465b1bbe4321e2b
Author: Hossein 
AuthorDate: Thu Dec 16 07:59:33 2021 +0100
Commit: Hossein 
CommitDate: Tue Mar 15 13:03:08 2022 +0100

Update basegfx workbench

* Update Makefile
  + Remove obsolete 'test' rule
  + Fix include
* Add needed headers, std:: where needed
* Add newlines in the print

One can run the workbench simply by invoking:

make

inside 'basegfx/source/workbench' and then

./bezierclip

Change-Id: I1055260a801d3a95c102a92004874000efb6871c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126903
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/basegfx/source/workbench/Makefile 
b/basegfx/source/workbench/Makefile
index 21dfc1400d11..6218141da1c8 100644
--- a/basegfx/source/workbench/Makefile
+++ b/basegfx/source/workbench/Makefile
@@ -16,19 +16,8 @@
 #   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 #
 
-# Testbuild
-
-#test : bezierclip.cxx convexhull.cxx
-#  g++ -Wall -g \
-#  -I. -I. -I../inc -I./inc -I./unx/inc -I./unxlngi4/inc -I. 
-I/develop4/update/SRX644/unxlngi4/inc.m4/stl 
-I/develop4/update/SRX644/unxlngi4/inc.m4/external 
-I/develop4/update/SRX644/unxlngi4/inc.m4 
-I/develop4/update/SRX644/src.m4/solenv/unxlngi4/inc  
-I/net/grande/develop6/update/dev/gcc_3.0.1_linux_libc2.11_turbolinux/include 
-I/develop4/update/SRX644/src.m4/solenv/inc 
-I/develop4/update/SRX644/unxlngi4/inc.m4/stl 
-I/net/grande.germany/develop6/update/dev/gcc_3.0.1_linux_libc2.11_turbolinux/redhat60/usr/include
 
-I/net/grande.germany/develop6/update/dev/gcc_3.0.1_linux_libc2.11_turbolinux/redhat60/usr/include/X11
 -I/develop4/update/SRX644/src.m4/res 
-I/net/grande/develop6/update/dev/Linux_JDK_1.4.0/include 
-I/net/grande/develop6/update/dev/Linux_JDK_1.4.0/include/linux -I. -I./res -I. 
\
-#  -include preinclude.h -D_USE_NAMESPACE -DGLIBC=2 -D_USE_NAMESPACE=1 
-D_DEBUG_RUNTIME \
-#  bezierclip.cxx convexhull.cxx -o bezierclip
-
 prog : bezierclip.cxx convexhull.cxx
-   g++ -Wall -g bezierclip.cxx convexhull.cxx -o bezierclip
-
-test : testconvexhull.cxx
-   g++ -Wall -g testconvexhull.cxx -o testhull
+   g++ -I. -Wall -g bezierclip.cxx convexhull.cxx -o bezierclip
 
 .cxx.o:
g++ -c $(LOCALDEFINES) $(CCFLAGS) $<
diff --git a/basegfx/source/workbench/bezierclip.cxx 
b/basegfx/source/workbench/bezierclip.cxx
index 1f16ed37c05c..7c939f9b 100644
--- a/basegfx/source/workbench/bezierclip.cxx
+++ b/basegfx/source/workbench/bezierclip.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -287,9 +289,9 @@ bool Impl_calcSafeParams_clip( double&  t1,
 
 Polygon2D convHull( convexHull( poly ) );
 
-cout << "# convex hull testing" << endl
+std::cout << "# convex hull testing" << std::endl
  << "plot [t=0:1] ";
-cout << " bez("
+std::cout << " bez("
  << poly[0].x << ","
  << poly[1].x << ","
  << poly[2].x << ","
@@ -303,22 +305,22 @@ bool Impl_calcSafeParams_clip( double&  t1,
  << t1 << ", t, "
  << t2 << ", t, "
  << "'-' using ($1):($2) title \"control polygon\" with lp, "
- << "'-' using ($1):($2) title \"convex hull\" with lp" << endl;
+ << "'-' using ($1):($2) title \"convex hull\" with lp" << std::endl;
 
 unsigned int k;
 for( k=0; k void Impl_applySafeRanges_rec( 
std::back_insert_iterato
 // tangency, and justifies to return a single intersection
 // point. Otherwise, inside/outside test might fail here.
 
-for( int i=0; i

[Libreoffice-commits] core.git: basegfx/source drawinglayer/source stoc/test sw/source testtools/source vcl/source

2022-02-15 Thread Kunal Pawar (via logerrit)
 basegfx/source/tools/gradienttools.cxx |9 +
 drawinglayer/source/processor2d/vclprocessor2d.cxx |4 ++--
 stoc/test/testiadapter.cxx |3 ++-
 stoc/test/testintrosp.cxx  |3 ++-
 sw/source/core/bastyp/calc.cxx |2 +-
 testtools/source/bridgetest/bridgetest.cxx |   10 ++
 testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx |9 +
 vcl/source/gdi/gradient.cxx|5 +++--
 8 files changed, 26 insertions(+), 19 deletions(-)

New commits:
commit 49746f40b06eaf1f61bb54454408a06a49d73c5e
Author: Kunal Pawar 
AuthorDate: Thu Feb 10 13:20:06 2022 +0530
Commit: Hossein 
CommitDate: Tue Feb 15 21:00:18 2022 +0100

tdf#145759 Use symbolic constants instead of magic numerical constants

1.4142... -> M_SQRT2
0.4142... -> M_SQRT2 - 1
3.1415... -> M_PI
2.7182... -> M_E

Change-Id: If5b19aa38d9902b1a4b717f89f18bdf2f73a47cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129745
Tested-by: Hossein 
Reviewed-by: Hossein 

diff --git a/basegfx/source/tools/gradienttools.cxx 
b/basegfx/source/tools/gradienttools.cxx
index 3605d8fe0be0..b4f1f6222f52 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace basegfx
 {
@@ -144,10 +145,10 @@ namespace basegfx
 }
 else
 {
-fTargetOffsetX -= (0.4142 / 2.0 ) * fTargetSizeX;
-fTargetOffsetY -= (0.4142 / 2.0 ) * fTargetSizeY;
-fTargetSizeX = 1.4142 * fTargetSizeX;
-fTargetSizeY = 1.4142 * fTargetSizeY;
+fTargetOffsetX -= ((M_SQRT2 - 1) / 2.0 ) * fTargetSizeX;
+fTargetOffsetY -= ((M_SQRT2 - 1) / 2.0 ) * fTargetSizeY;
+fTargetSizeX = M_SQRT2 * fTargetSizeX;
+fTargetSizeY = M_SQRT2 * fTargetSizeY;
 }
 
 const double fHalfBorder((1.0 - fBorder) * 0.5);
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 04258b288277..da34cd558a81 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -1291,7 +1291,7 @@ void VclProcessor2D::RenderSvgLinearAtomPrimitive2D(
 const basegfx::B2DVector aDiscreteVector(
 getViewInformation2D().getInverseObjectToViewTransformation()
 * basegfx::B2DVector(1.0, 1.0));
-const double fDiscreteUnit(aDiscreteVector.getLength() * (1.0 / 
1.414213562373));
+const double fDiscreteUnit(aDiscreteVector.getLength() * (1.0 / M_SQRT2));
 
 // use color distance and discrete lengths to calculate step count
 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, 
fDelta, fDiscreteUnit));
@@ -1335,7 +1335,7 @@ void VclProcessor2D::RenderSvgRadialAtomPrimitive2D(
 const basegfx::B2DVector aDiscreteVector(
 getViewInformation2D().getInverseObjectToViewTransformation()
 * basegfx::B2DVector(1.0, 1.0));
-const double fDiscreteUnit(aDiscreteVector.getLength() * (1.0 / 
1.414213562373));
+const double fDiscreteUnit(aDiscreteVector.getLength() * (1.0 / M_SQRT2));
 
 // use color distance and discrete lengths to calculate step count
 const sal_uInt32 nSteps(
diff --git a/stoc/test/testiadapter.cxx b/stoc/test/testiadapter.cxx
index 1525032d2af3..d9fd9560c13a 100644
--- a/stoc/test/testiadapter.cxx
+++ b/stoc/test/testiadapter.cxx
@@ -37,6 +37,7 @@
 #include 
 
 #include 
+#include 
 
 
 using namespace test;
@@ -749,7 +750,7 @@ sal_Bool performTest( const Reference & xLBT )
 sal_True, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
 SAL_CONST_INT64(0x123456789abcdef0),
 SAL_CONST_UINT64(0xfedcba9876543210),
-(float)17.0815, 3.1415926359, TestEnum_LOLA, 
OUString("dumdidum"), xI,
+(float)17.0815, M_PI, TestEnum_LOLA, OUString("dumdidum"), xI,
 Any( , cppu::UnoType::get()) );
 
 OSL_ENSURE( aData.Any == xI, "### unexpected any!" );
diff --git a/stoc/test/testintrosp.cxx b/stoc/test/testintrosp.cxx
index e33ee178e3e9..0b56c8564ef9 100644
--- a/stoc/test/testintrosp.cxx
+++ b/stoc/test/testintrosp.cxx
@@ -40,6 +40,7 @@
 
 #include 
 #include 
+#include 
 
 using namespace cppu;
 using namespace ModuleA;
@@ -454,7 +455,7 @@ void ImplIntroTest::Init()
 
 //XInterfaceRef Source;
 Any Value;
-Value <<= 2.718281828459;
+Value <<= M_E;
 m_aSecondStruct.Value = Value;
 //XIdlClassRef ListenerType;
 m_aSecondStruct.State = PropertyState_DIRECT_VALUE;
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 7ea6de6cb00c..3ba77ed08a2d 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -324,7 +324,7 @@ 

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

2021-12-20 Thread Stephan Bergmann (via logerrit)
 basegfx/source/polygon/b2dpolypolygon.cxx |4 
 basegfx/source/polygon/b3dpolygon.cxx |1 +
 basegfx/source/polygon/b3dpolypolygon.cxx |1 +
 3 files changed, 6 insertions(+)

New commits:
commit e86734315c24d030f6cd9e8914c743a44ba35bd6
Author: Stephan Bergmann 
AuthorDate: Mon Dec 20 16:47:02 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Mon Dec 20 20:10:04 2021 +0100

Missing inlcude (for std::as_const)

(presumably since 807f238f12e0774fabf507a17ca0ba9204d47833 "Recheck
include/[e-r]* with IWYU")

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

diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index 13724164ff2f..4fd12bde4a10 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
+
+#include 
+
 #include 
 #include 
 #include 
diff --git a/basegfx/source/polygon/b3dpolygon.cxx 
b/basegfx/source/polygon/b3dpolygon.cxx
index a14b9f3887b8..c1ee4b08345a 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx 
b/basegfx/source/polygon/b3dpolypolygon.cxx
index e7334af42874..017906eef5b8 100644
--- a/basegfx/source/polygon/b3dpolypolygon.cxx
+++ b/basegfx/source/polygon/b3dpolypolygon.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 class ImplB3DPolyPolygon


[Libreoffice-commits] core.git: basegfx/source compilerplugins/clang svx/source vcl/source

2021-12-07 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx  |   52 +++
 basegfx/source/polygon/b2dpolypolygon.cxx  |   16 +++
 basegfx/source/polygon/b3dpolygon.cxx  |   34 +++
 basegfx/source/polygon/b3dpolypolygon.cxx  |   10 ++--
 compilerplugins/clang/cow_wrapper.cxx  |   65 +
 compilerplugins/clang/test/cow_wrapper.cxx |   11 
 svx/source/xoutdev/_xpoly.cxx  |   10 ++--
 vcl/source/font/font.cxx   |6 +-
 8 files changed, 124 insertions(+), 80 deletions(-)

New commits:
commit 5de20e45e48f7654d288f26f768fabddad133bfd
Author: Noel Grandin 
AuthorDate: Tue Dec 7 14:37:56 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Dec 7 17:46:23 2021 +0100

improve loplugin:cow_wrapper

to find my previous attempt at this, which only obscured the problem

 I'm such an idiot
 I changed a whole bunch of code to avoid calling const
methods on a non-const object
 from p->foo() to std::as_const(*p).foo()
 can you spot the mistake?
 Is this a job interview question? :D
 noelgrandin: you did the opposite, now you always call const
member functions, while you wanted to always call non-const member
functions?
 more like a "why didn't the smart people on this channel
tell me I was an idiot" :-)
 in this case, we have o3tl::cow_wrapper, which overrides
operator* and operator->
 ah, and by the time you would add/remove the const,
cow_wrapper already did the expensive task of copying based on
const/non-const
 exactly
 heh

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

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index a1d50321e8e9..4d2b681911e2 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1177,9 +1177,9 @@ namespace basegfx
 
 void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
 {
-OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
+OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon 
access outside range (!)");
 
-if(std::as_const(*mpPolygon).getPoint(nIndex) != rValue)
+if(std::as_const(mpPolygon)->getPoint(nIndex) != rValue)
 {
 mpPolygon->setPoint(nIndex, rValue);
 }
@@ -1192,7 +1192,7 @@ namespace basegfx
 
 void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPoint& rPoint, 
sal_uInt32 nCount)
 {
-OSL_ENSURE(nIndex <= std::as_const(*mpPolygon).count(), "B2DPolygon 
Insert outside range (!)");
+OSL_ENSURE(nIndex <= std::as_const(mpPolygon)->count(), "B2DPolygon 
Insert outside range (!)");
 
 if(nCount)
 {
@@ -1204,7 +1204,7 @@ namespace basegfx
 {
 if(nCount)
 {
-mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, 
nCount);
+mpPolygon->insert(std::as_const(mpPolygon)->count(), rPoint, 
nCount);
 }
 }
 
@@ -1243,10 +1243,10 @@ namespace basegfx
 
 void B2DPolygon::setPrevControlPoint(sal_uInt32 nIndex, const B2DPoint& 
rValue)
 {
-OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
-const basegfx::B2DVector aNewVector(rValue - 
std::as_const(*mpPolygon).getPoint(nIndex));
+OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon 
access outside range (!)");
+const basegfx::B2DVector aNewVector(rValue - 
std::as_const(mpPolygon)->getPoint(nIndex));
 
-if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != 
aNewVector)
+if(std::as_const(mpPolygon)->getPrevControlVector(nIndex) != 
aNewVector)
 {
 mpPolygon->setPrevControlVector(nIndex, aNewVector);
 }
@@ -1254,10 +1254,10 @@ namespace basegfx
 
 void B2DPolygon::setNextControlPoint(sal_uInt32 nIndex, const B2DPoint& 
rValue)
 {
-OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
-const basegfx::B2DVector aNewVector(rValue - 
std::as_const(*mpPolygon).getPoint(nIndex));
+OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon 
access outside range (!)");
+const basegfx::B2DVector aNewVector(rValue - 
std::as_const(mpPolygon)->getPoint(nIndex));
 
-if(std::as_const(*mpPolygon).getNextControlVector(nIndex) != 
aNewVector)
+if(std::as_const(mpPolygon)->getNextControlVector(nIndex) != 
aNewVector)
 {
 mpPolygon->setNextControlVector(nIndex, aNewVector);
 }
@@ -1265,12 +1265,12 @@ namespace basegfx
 
 void B2DPolygon::setControlPoints(sal_uInt32 nIndex, const 
basegfx::B2DPoint& rPrev, const basegfx::B2DPoint& rNext)
 {
-

[Libreoffice-commits] core.git: basegfx/source bin/find-can-be-private-symbols.functions.results bin/find-can-be-private-symbols.py config_host/config_options.h.in include/basegfx include/basic includ

2021-12-01 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrixtools.cxx   |2 
 bin/find-can-be-private-symbols.functions.results |23470 ++
 bin/find-can-be-private-symbols.py|  119 
 config_host/config_options.h.in   |5 
 include/basegfx/color/bcolormodifier.hxx  |   30 
 include/basegfx/curve/b2dcubicbezier.hxx  |   18 
 include/basegfx/matrix/b2dhommatrixtools.hxx  |4 
 include/basegfx/polygon/b2dpolygonclipper.hxx |2 
 include/basegfx/polygon/b2dpolygoncutandtouch.hxx |8 
 include/basegfx/polygon/b2dpolygontools.hxx   |6 
 include/basegfx/polygon/b2dtrapezoid.hxx  |4 
 include/basegfx/polygon/b3dpolygontools.hxx   |8 
 include/basegfx/polygon/b3dpolypolygontools.hxx   |6 
 include/basegfx/raster/rasterconvert3d.hxx|   10 
 include/basegfx/utils/canvastools.hxx |   12 
 include/basegfx/utils/unopolypolygon.hxx  |   40 
 include/basic/basmgr.hxx  |   17 
 include/basic/sbmod.hxx   |   68 
 include/svx/ParseContext.hxx  |8 
 include/svx/sidebar/ValueSetWithTextControl.hxx   |4 
 include/svx/svxdllapi.h   |1 
 include/tools/stream.hxx  |   17 
 include/unotools/fontdefs.hxx |2 
 include/vcl/BitmapReadAccess.hxx  |9 
 include/vcl/dndhelp.hxx   |4 
 include/vcl/settings.hxx  |   11 
 include/vcl/unohelp.hxx   |2 
 include/vcl/weldutils.hxx |   65 
 include/xmloff/animationexport.hxx|2 
 include/xmloff/controlpropertyhdl.hxx |   18 
 include/xmloff/formlayerexport.hxx|   12 
 include/xmloff/formlayerimport.hxx|   14 
 include/xmloff/xmltoken.hxx   |2 
 include/xmlreader/pad.hxx |2 
 include/xmlscript/xmldlg_imexp.hxx|2 
 o3tl/qa/test-string_view.cxx  |1 
 sc/inc/cellsuno.hxx   |5 
 svx/source/inc/fmexch.hxx |6 
 vcl/source/bitmap/bitmappalette.cxx   |7 
 writerfilter/source/dmapper/ConversionHelper.hxx  |4 
 writerperfect/inc/DirectoryStream.hxx |   11 
 writerperfect/inc/DocumentHandler.hxx |   11 
 writerperfect/inc/WPXSvInputStream.hxx|   11 
 43 files changed, 23769 insertions(+), 291 deletions(-)

New commits:
commit e10e5c15cc51d3b2a5e4b699c5f381aa92a17c4e
Author: Noel Grandin 
AuthorDate: Fri Nov 5 11:24:13 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Dec 1 12:13:59 2021 +0100

improve the script for reducing symbol exports

And apply some of the results

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

diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx 
b/basegfx/source/matrix/b2dhommatrixtools.cxx
index 50f4e36ab30b..7fb6bbe0cb84 100644
--- a/basegfx/source/matrix/b2dhommatrixtools.cxx
+++ b/basegfx/source/matrix/b2dhommatrixtools.cxx
@@ -355,7 +355,7 @@ namespace basegfx::utils
 return aRetval;
 }
 
-BASEGFX_DLLPUBLIC B2DHomMatrix 
createRotateAroundCenterKeepAspectRatioStayInsideRange(
+B2DHomMatrix createRotateAroundCenterKeepAspectRatioStayInsideRange(
 const basegfx::B2DRange& rTargetRange,
 double fRotate)
 {
diff --git a/bin/find-can-be-private-symbols.functions.results 
b/bin/find-can-be-private-symbols.functions.results
index e69de29bb2d1..be8116b9ff90 100644
--- a/bin/find-can-be-private-symbols.functions.results
+++ b/bin/find-can-be-private-symbols.functions.results
@@ -0,0 +1,23470 @@
+ATOB_AsciiToData@@NSS_3.2
+ATOB_AsciiToData_Util@@NSSUTIL_3.12
+ATOB_ConvertAsciiToItem@@NSS_3.2
+ATOB_ConvertAsciiToItem_Util@@NSSUTIL_3.12
+AllSettings::CopyData()
+AllSettings::Update(AllSettingsFlags, AllSettings const&)
+AllSettings::operator!=(AllSettings const&) const
+AllSettings::operator==(AllSettings const&) const
+AlphaMask::AlphaMask(AlphaMask const&)
+AlphaMask::AlphaMask(AlphaMask&&)
+AlphaMask::operator=(Bitmap const&)
+Animation::Adjust(short, short, short, short, short, double, bool)
+Animation::Clear()
+Animation::Convert(BmpConversion)
+Animation::Draw(OutputDevice&, Point const&) const
+Animation::Draw(OutputDevice&, Point const&, Size const&) const
+Animation::GetChecksum() const
+Animation::GetSizeBytes() const
+Animation::IsTransparent() const
+Animation::Mirror(BmpMirrorFlags)
+Animation::ResetLoopCount()
+Animation::Start(OutputDevice&, Point const&, Size const&, long, OutputDevice*)
+Animation::Stop(OutputDevice const*, long)
+Animation::operator=(Animation const&)

[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 compilerplugins/clang solenv/CompilerTest_compilerplugins_clang.mk svx/source vcl/source

2021-09-13 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx|   52 +++
 basegfx/source/polygon/b2dpolypolygon.cxx|   16 ++--
 basegfx/source/polygon/b3dpolygon.cxx|   34 +-
 basegfx/source/polygon/b3dpolypolygon.cxx|   10 +--
 compilerplugins/clang/cow_wrapper.cxx|   88 +++
 compilerplugins/clang/test/cow_wrapper.cxx   |   33 ++
 solenv/CompilerTest_compilerplugins_clang.mk |1 
 svx/source/xoutdev/_xpoly.cxx|   10 +--
 vcl/source/font/font.cxx |6 -
 9 files changed, 186 insertions(+), 64 deletions(-)

New commits:
commit 6c7c7bcdbd3e47cad5c6b94e1ed1c5314dbdbf6b
Author: Noel Grandin 
AuthorDate: Mon Sep 13 13:02:14 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Sep 13 15:05:56 2021 +0200

loplugin:cow_wrapper

check the classes that use o3tl::cow_wrapper so that they
don't unnecessarity trigger copies

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

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index e8f6d947c7d2..7276208cd326 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1177,9 +1177,9 @@ namespace basegfx
 
 void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
 {
-OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside 
range (!)");
+OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
 
-if(mpPolygon->getPoint(nIndex) != rValue)
+if(std::as_const(*mpPolygon).getPoint(nIndex) != rValue)
 {
 mpPolygon->setPoint(nIndex, rValue);
 }
@@ -1192,7 +1192,7 @@ namespace basegfx
 
 void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPoint& rPoint, 
sal_uInt32 nCount)
 {
-OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside 
range (!)");
+OSL_ENSURE(nIndex <= std::as_const(*mpPolygon).count(), "B2DPolygon 
Insert outside range (!)");
 
 if(nCount)
 {
@@ -1204,7 +1204,7 @@ namespace basegfx
 {
 if(nCount)
 {
-mpPolygon->insert(mpPolygon->count(), rPoint, nCount);
+mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, 
nCount);
 }
 }
 
@@ -1243,10 +1243,10 @@ namespace basegfx
 
 void B2DPolygon::setPrevControlPoint(sal_uInt32 nIndex, const B2DPoint& 
rValue)
 {
-OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside 
range (!)");
-const basegfx::B2DVector aNewVector(rValue - 
mpPolygon->getPoint(nIndex));
+OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
+const basegfx::B2DVector aNewVector(rValue - 
std::as_const(*mpPolygon).getPoint(nIndex));
 
-if(mpPolygon->getPrevControlVector(nIndex) != aNewVector)
+if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != 
aNewVector)
 {
 mpPolygon->setPrevControlVector(nIndex, aNewVector);
 }
@@ -1254,10 +1254,10 @@ namespace basegfx
 
 void B2DPolygon::setNextControlPoint(sal_uInt32 nIndex, const B2DPoint& 
rValue)
 {
-OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside 
range (!)");
-const basegfx::B2DVector aNewVector(rValue - 
mpPolygon->getPoint(nIndex));
+OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
+const basegfx::B2DVector aNewVector(rValue - 
std::as_const(*mpPolygon).getPoint(nIndex));
 
-if(mpPolygon->getNextControlVector(nIndex) != aNewVector)
+if(std::as_const(*mpPolygon).getNextControlVector(nIndex) != 
aNewVector)
 {
 mpPolygon->setNextControlVector(nIndex, aNewVector);
 }
@@ -1265,12 +1265,12 @@ namespace basegfx
 
 void B2DPolygon::setControlPoints(sal_uInt32 nIndex, const 
basegfx::B2DPoint& rPrev, const basegfx::B2DPoint& rNext)
 {
-OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside 
range (!)");
-const B2DPoint aPoint(mpPolygon->getPoint(nIndex));
+OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon 
access outside range (!)");
+const B2DPoint aPoint(std::as_const(*mpPolygon).getPoint(nIndex));
 const basegfx::B2DVector aNewPrev(rPrev - aPoint);
 const basegfx::B2DVector aNewNext(rNext - aPoint);
 
-if(mpPolygon->getPrevControlVector(nIndex) != aNewPrev || 
mpPolygon->getNextControlVector(nIndex) != aNewNext)
+if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != aNewPrev 
|| std::as_const(*mpPolygon).getNextControlVector(nIndex) != aNewNext)
 {
 mpPolygon->setControlVectors(nIndex, aNewPrev, aNewNext);
 }
@@ -1278,9 

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

2021-09-08 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygon.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 70cd6cac6c1fe2f13702d8ab539d56ebae93683b
Author: Noel Grandin 
AuthorDate: Wed Sep 8 09:26:30 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Sep 8 10:29:25 2021 +0200

no need to allocate this separately

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

diff --git a/basegfx/source/polygon/b2dpolygon.cxx 
b/basegfx/source/polygon/b2dpolygon.cxx
index 2baa16225227..e8f6d947c7d2 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -463,7 +463,7 @@ private:
 std::optional< basegfx::B2DPolygon >  mpDefaultSubdivision;
 
 // Possibility to hold the last B2DRange calculation
-std::unique_ptr< basegfx::B2DRange >mpB2DRange;
+mutable std::optional< basegfx::B2DRange > moB2DRange;
 
 public:
 ImplBufferedData()
@@ -482,7 +482,7 @@ public:
 
 const basegfx::B2DRange& getB2DRange(const basegfx::B2DPolygon& rSource) 
const
 {
-if(!mpB2DRange)
+if(!moB2DRange)
 {
 basegfx::B2DRange aNewRange;
 const sal_uInt32 nPointCount(rSource.count());
@@ -542,10 +542,10 @@ public:
 }
 }
 
-const_cast< ImplBufferedData* >(this)->mpB2DRange.reset(new 
basegfx::B2DRange(aNewRange));
+moB2DRange = aNewRange;
 }
 
-return *mpB2DRange;
+return *moB2DRange;
 }
 };
 


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

2021-08-17 Thread Noel Grandin (via logerrit)
 basegfx/source/matrix/b2dhommatrix.cxx|4 +++-
 basegfx/source/polygon/b2dpolypolygon.cxx |5 -
 2 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 889df64fbb9534491b76140d63b4340091c763e4
Author: Noel Grandin 
AuthorDate: Tue Aug 17 13:39:03 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Aug 17 22:40:07 2021 +0200

reduce alloc costs for some basegfx objects (tdf#105575)

we can use a default object for the default constructo case, and
remove one malloc for each default constructed object

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

diff --git a/basegfx/source/matrix/b2dhommatrix.cxx 
b/basegfx/source/matrix/b2dhommatrix.cxx
index 89088e8ebdbf..badda594c9de 100644
--- a/basegfx/source/matrix/b2dhommatrix.cxx
+++ b/basegfx/source/matrix/b2dhommatrix.cxx
@@ -31,7 +31,9 @@ namespace basegfx
 {
 };
 
-B2DHomMatrix::B2DHomMatrix() = default;
+static o3tl::cow_wrapper DEFAULT;
+
+B2DHomMatrix::B2DHomMatrix() : mpImpl(DEFAULT) {}
 
 B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix&) = default;
 
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx 
b/basegfx/source/polygon/b2dpolypolygon.cxx
index dcd6133abc4a..36c221eeb106 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -200,7 +200,10 @@ public:
 namespace basegfx
 {
 
-B2DPolyPolygon::B2DPolyPolygon() = default;
+static o3tl::cow_wrapper DEFAULT;
+
+B2DPolyPolygon::B2DPolyPolygon() :
+mpPolyPolygon(DEFAULT) {}
 
 B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon&) = default;
 


[Libreoffice-commits] core.git: basegfx/source chart2/source connectivity/source desktop/source editeng/source sc/source sd/source sfx2/source sot/source svx/source

2021-07-31 Thread Noel Grandin (via logerrit)
 basegfx/source/polygon/b2dpolygontools.cxx |2 +-
 chart2/source/view/main/ChartView.cxx  |2 +-
 connectivity/source/drivers/firebird/Clob.cxx  |6 +++---
 desktop/source/lib/init.cxx|2 +-
 editeng/source/editeng/editeng.cxx |4 ++--
 sc/source/filter/excel/excel.cxx   |2 +-
 sd/source/filter/sdpptwrp.cxx  |2 +-
 sfx2/source/doc/doctemplates.cxx   |2 +-
 sot/source/sdstor/ucbstorage.cxx   |6 +++---
 sot/source/unoolestorage/xolesimplestorage.cxx |2 +-
 svx/source/unodraw/unoshap3.cxx|   12 ++--
 11 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit 9ae4f8b5bf70a693ffb60ceac4f9625cf15b1181
Author: Noel Grandin 
AuthorDate: Sat Jul 31 14:31:49 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Jul 31 19:16:06 2021 +0200

getArray->getConstArray

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

diff --git a/basegfx/source/polygon/b2dpolygontools.cxx 
b/basegfx/source/polygon/b2dpolygontools.cxx
index 12401ac9756a..6e78aed363e1 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -3305,7 +3305,7 @@ namespace basegfx::utils
 // copy first point if closed
 if(bIsClosed)
 {
-*pSequence = *rPointSequenceRetval.getArray();
+*pSequence = *rPointSequenceRetval.getConstArray();
 }
 }
 else
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 85caad7560e2..4d393fde9725 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2714,7 +2714,7 @@ void SAL_CALL ChartView::setPropertyValue( const 
OUString& rPropertyName
 throw lang::IllegalArgumentException( "Property 'ZoomFactors' 
requires value of type Sequence< PropertyValue >", nullptr, 0 );
 
 sal_Int32 nFilterArgs = aZoomFactors.getLength();
-beans::PropertyValue* pDataValues = aZoomFactors.getArray();
+const beans::PropertyValue* pDataValues = aZoomFactors.getConstArray();
 while( nFilterArgs-- )
 {
 if ( pDataValues->Name == "ScaleXNumerator" )
diff --git a/connectivity/source/drivers/firebird/Clob.cxx 
b/connectivity/source/drivers/firebird/Clob.cxx
index 358451738003..3ed83a9b19d2 100644
--- a/connectivity/source/drivers/firebird/Clob.cxx
+++ b/connectivity/source/drivers/firebird/Clob.cxx
@@ -58,7 +58,7 @@ sal_Int64 SAL_CALL Clob::length()
 {
 uno::Sequence < sal_Int8 > aSegmentBytes;
 bLastSegmRead = m_aBlob->readOneSegment( aSegmentBytes );
-OUString sSegment ( reinterpret_cast< char *>( 
aSegmentBytes.getArray() ),
+OUString sSegment ( reinterpret_cast< const char *>( 
aSegmentBytes.getConstArray() ),
 aSegmentBytes.getLength(),
 RTL_TEXTENCODING_UTF8 );
 
@@ -90,7 +90,7 @@ OUString SAL_CALL Clob::getSubString(sal_Int64 nPosition,
 if( bLastRead )
 throw lang::IllegalArgumentException("nPosition out of range", 
*this, 0);
 
-OUString sSegment ( reinterpret_cast< char *>( 
aSegmentBytes.getArray() ),
+OUString sSegment ( reinterpret_cast< const char *>( 
aSegmentBytes.getConstArray() ),
 aSegmentBytes.getLength(),
 RTL_TEXTENCODING_UTF8 );
 sal_Int32 nStrLen = sSegment.getLength();
@@ -112,7 +112,7 @@ OUString SAL_CALL Clob::getSubString(sal_Int64 nPosition,
 uno::Sequence < sal_Int8 > aSegmentBytes;
 bool bLastRead = m_aBlob->readOneSegment( aSegmentBytes );
 
-OUString sSegment ( reinterpret_cast< char *>( 
aSegmentBytes.getArray() ),
+OUString sSegment ( reinterpret_cast< const char *>( 
aSegmentBytes.getConstArray() ),
 aSegmentBytes.getLength(),
 RTL_TEXTENCODING_UTF8 );
 sal_Int32 nStrLen = sSegment.getLength();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 434b2bda81fa..54edeaa831f1 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4315,7 +4315,7 @@ static bool getFromTransferrable(
 {
 uno::Sequence aSequence;
 aAny >>= aSequence;
-aRet = OString(reinterpret_cast(aSequence.getArray()), 
aSequence.getLength());
+aRet = OString(reinterpret_cast(aSequence.getConstArray()), aSequence.getLength());
 }
 
 return true;
diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 9159f9b7169c..abc9f64a9b04 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1344,7 

  1   2   3   >