[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - drawinglayer/source emfio/qa svgio/qa

2022-06-15 Thread Bartosz Kosiorek (via logerrit)
 drawinglayer/source/tools/emfpbrush.cxx   |   
12 ++
 drawinglayer/source/tools/emfphelperdata.cxx  |   
55 ++
 drawinglayer/source/tools/primitive2dxmldump.cxx  |   
42 ++-
 emfio/qa/cppunit/emf/EmfImportTest.cxx|   
24 
 emfio/qa/cppunit/emf/data/TestEmfPlusBrushPathGradientWithBlendColors.emf 
|binary
 svgio/qa/cppunit/SvgImportTest.cxx|   
14 ++
 6 files changed, 99 insertions(+), 48 deletions(-)

New commits:
commit 8419e2909aef8916111e4dce9c0a070464a06e66
Author: Bartosz Kosiorek 
AuthorDate: Sun Jun 12 21:51:52 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jun 15 08:41:31 2022 +0200

tdf#131506 tdf#143031 EMF+ Fix displaying PathGradient fill

With previous implementation, the EMF+ import is calculating
gradient positions wrongly. It is causing warning:

  SvgGradientHelper got invalid SvgGradientEntries outside [0.0 .. 1.0]

and the gradient was not displayed at all.
This patch fixes that and gradient is displayed correctly

Change-Id: I6229c516165436d0c7ae187d9eb69b5494da396f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135607
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 
(cherry picked from commit 7b12c659842eb53b96dd98ecea65c6071506dfbb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135746
Reviewed-by: Xisco Fauli 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135858

diff --git a/drawinglayer/source/tools/emfpbrush.cxx 
b/drawinglayer/source/tools/emfpbrush.cxx
index 4acc311345a8..493b6eafc613 100644
--- a/drawinglayer/source/tools/emfpbrush.cxx
+++ b/drawinglayer/source/tools/emfpbrush.cxx
@@ -187,6 +187,12 @@ namespace emfplushelper
 SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse brush 
transformation: " << brush_transformation);
 }
 
+// BrushDataPresetColors and BrushDataBlendFactorsH
+if ((additionalFlags & 0x04) && (additionalFlags & 0x08))
+{
+SAL_WARN("drawinglayer.emf", "EMF+\t Brush must not 
contain both BrushDataPresetColors and BrushDataBlendFactorsH");
+return;
+}
 if (additionalFlags & 0x08)
 {
 s.ReadInt32(blendPoints);
@@ -268,6 +274,12 @@ namespace emfplushelper
 hasTransformation = true;
 SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse brush 
transformation: " << brush_transformation);
 }
+// BrushDataPresetColors and BrushDataBlendFactorsH
+if ((additionalFlags & 0x04) && (additionalFlags & 0x08))
+{
+SAL_WARN("drawinglayer.emf", "EMF+\t Brush must not 
contain both BrushDataPresetColors and BrushDataBlendFactorsH");
+return;
+}
 
 if (additionalFlags & 0x08)
 {
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx 
b/drawinglayer/source/tools/emfphelperdata.cxx
index 7a64f8ad4dac..df3c4293a87f 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -784,21 +784,12 @@ namespace emfplushelper
 // store the blendpoints in the vector
 for (int i = 0; i < brush->blendPoints; i++)
 {
-double aBlendPoint;
+const double aBlendPoint = brush->blendPositions[i];
 basegfx::BColor aColor;
-if (brush->type == BrushTypeLinearGradient)
-{
-aBlendPoint = brush->blendPositions [i];
-}
-else
-{
-// seems like SvgRadialGradientPrimitive2D needs 
doubled, inverted radius
-aBlendPoint = 2. * ( 1. - brush->blendPositions 
[i] );
-}
-aColor.setGreen( aStartColor.getGreen() + 
brush->blendFactors[i] * ( aEndColor.getGreen() - aStartColor.getGreen() ) );
-aColor.setBlue ( aStartColor.getBlue()  + 
brush->blendFactors[i] * ( aEndColor.getBlue() - aStartColor.getBlue() ) );
-aColor.setRed  ( aStartColor.getRed()   + 
brush->blendFactors[i] * ( aEndColor.getRed() - aStartColor.getRed() ) );
-const double aAlpha = brush->solidColor.GetAlpha() + 
brush->blendFactors[i] * ( brush->secondColor.GetAlpha() - 
brush->solidColor.GetAlpha() );
+aColor.setGreen(aStartColor.getGreen() + 
brush->blendFactors[i] * (aEndColor.getGreen() - aStartColor.getGreen()));
+

[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - drawinglayer/source emfio/qa

2022-04-23 Thread Bartosz Kosiorek (via logerrit)
 drawinglayer/source/tools/emfphelperdata.cxx  |   10 ++-
 drawinglayer/source/tools/emfphelperdata.hxx  |5 +
 drawinglayer/source/tools/primitive2dxmldump.cxx  |2 
 emfio/qa/cppunit/emf/EmfImportTest.cxx|   46 --
 emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf |binary
 5 files changed, 40 insertions(+), 23 deletions(-)

New commits:
commit f3a984d98c1e5f7319996e2d0523057a1004b81b
Author: Bartosz Kosiorek 
AuthorDate: Fri Apr 22 16:46:39 2022 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Sat Apr 23 15:25:42 2022 +0200

tdf#55058 tdf#143875 EMF+ Don't change line weight while rotating

Previously when TranfromationMatrix was used with rotation,
the line weight and dashed line shapes were changed.
In worst case if angle was larger than 90 degrees,
the lines just disappear.

This patch fixes that. The line looks exactly after rotation
(with TranfromationMatrix).

The tests were updated (added some additional rotation),
to prove that now it is working correctly.

Change-Id: Ic2382fa8d1b711a6bf06c94b2d0b9da9e7d396f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133329
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 
(cherry picked from commit abe3a06c45c0803a5c8bcf16e0e586fd72781c93)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133285
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/drawinglayer/source/tools/emfphelperdata.cxx 
b/drawinglayer/source/tools/emfphelperdata.cxx
index 79ced761e8a2..7a64f8ad4dac 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -442,6 +442,10 @@ namespace emfplushelper
 maMapTransform *= 
basegfx::utils::createScaleTranslateB2DHomMatrix(100.0 * mnMmX / mnPixX, 100.0 
* mnMmY / mnPixY,

double(-mnFrameLeft), double(-mnFrameTop));
 maMapTransform *= maBaseTransform;
+
+// Used only for performance optimization, to do not calculate it 
every line draw
+mdExtractedXScale = std::hypot(maMapTransform.a(), maMapTransform.b());
+mdExtractedYScale = std::hypot(maMapTransform.c(), maMapTransform.d());
 }
 
 ::basegfx::B2DPoint EmfPlusHelperData::Map(double ix, double iy) const
@@ -517,7 +521,7 @@ namespace emfplushelper
 SAL_WARN_IF(pen->startCap != pen->endCap, "drawinglayer.emf", 
"emf+ pen uses different start and end cap");
 }
 
-const double transformedPenWidth = maMapTransform.get(0, 0) * 
pen->penWidth;
+const double transformedPenWidth = mdExtractedYScale * pen->penWidth;
 drawinglayer::attribute::LineAttribute 
lineAttribute(pen->GetColor().getBColor(),
  
transformedPenWidth,
  
pen->GetLineJoinType(),
@@ -529,7 +533,7 @@ namespace emfplushelper
 new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
 polygon,
 lineAttribute,
-pen->GetStrokeAttribute(maMapTransform.get(1, 1;
+pen->GetStrokeAttribute(mdExtractedXScale)));
 }
 else
 {
@@ -537,7 +541,7 @@ namespace emfplushelper
 new 
drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
 polygon,
 lineAttribute,
-pen->GetStrokeAttribute(maMapTransform.get(1, 
1;
+pen->GetStrokeAttribute(mdExtractedXScale)));
 
 mrTargetHolders.Current().append(
 new 
drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
diff --git a/drawinglayer/source/tools/emfphelperdata.hxx 
b/drawinglayer/source/tools/emfphelperdata.hxx
index cf3474b5b1a7..3d8244b6f208 100644
--- a/drawinglayer/source/tools/emfphelperdata.hxx
+++ b/drawinglayer/source/tools/emfphelperdata.hxx
@@ -210,6 +210,11 @@ namespace emfplushelper
 GraphicStateMap mGSStack;
 GraphicStateMap mGSContainerStack;
 
+/* Performance optimizators */
+/* Extracted Scale values from Transformation Matrix */
+double mdExtractedXScale;
+double mdExtractedYScale;
+
 /// data holders
 wmfemfhelper::TargetHolders&mrTargetHolders;
 wmfemfhelper::PropertyHolders&  mrPropertyHolders;
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index a1fddf900543..27a8adf1b5e3 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -143,7 +143,7 @@ void writeStrokeAttribute(::tools::XmlWriter& rWriter,
 OUString sDotDash;
 for (double