[Libreoffice-commits] core.git: drawinglayer/source emfio/inc emfio/qa emfio/source vcl/qa

2022-05-09 Thread Bartosz Kosiorek (via logerrit)
 drawinglayer/source/tools/wmfemfhelper.cxx |   11 -
 emfio/inc/mtftools.hxx |   79 +++-
 emfio/qa/cppunit/emf/EmfImportTest.cxx |   19 +++
 emfio/qa/cppunit/wmf/data/TestLineTo.wmf   |binary
 emfio/source/reader/emfreader.cxx  |  180 ++---
 emfio/source/reader/wmfreader.cxx  |   65 --
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   12 -
 7 files changed, 120 insertions(+), 246 deletions(-)

New commits:
commit 32cb4e4fe55e662d2e515e9a6facabffe3684754
Author: Bartosz Kosiorek 
AuthorDate: Fri Apr 29 13:36:10 2022 +0200
Commit: Bartosz Kosiorek 
CommitDate: Mon May 9 11:08:25 2022 +0200

tdf#89331 EMF/WMF Fix holes in lines created with LINETO

If the lines are created with MOVETO, LINETO, LINETO...
then Line Join NONE is applied. As a result the charts are looks ugly,
with the holes inside it.
For example:
https://bugs.documentfoundation.org/attachment.cgi?id=179962
and
https://bugs.documentfoundation.org/attachment.cgi?id=179837

Additinally commit changed default line join style to miter,
as during experimenting with MS Paint and MS Word,
it appear that default Join Style is PS_JOIN_MITER and
Line Cap is Flat/Butter.

The PDF export tests has been updated, as there is less number
of PDF object after using joiners.
The size of the exported tdf145873.pptx to PDF,
was slighltly decreased from 22.8kB to 22.0KB

Change-Id: I131cc3c5e90f827d67d2360eb18167eed6315abb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133624
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 

diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx 
b/drawinglayer/source/tools/wmfemfhelper.cxx
index 592e67bab9a5..1f5b8a10fcf2 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -1548,7 +1548,6 @@ namespace wmfemfhelper
 }
 else
 {
-
aLineInfo.SetLineJoin(basegfx::B2DLineJoin::NONE); // It were lines; force to 
NONE
 createLinePrimitive(aLinePolygon, 
aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current());
 aLinePolygon.clear();
 aLineInfo = pA->GetLineInfo();
@@ -1563,16 +1562,14 @@ namespace wmfemfhelper
 aLinePolygon.append(aEnd);
 }
 
-nAction++; if(nAction < nCount) pAction = 
rMetaFile.GetAction(nAction);
+nAction++;
+if (nAction < nCount)
+pAction = rMetaFile.GetAction(nAction);
 }
 
 nAction--;
-
-if(aLinePolygon.count())
-{
-aLineInfo.SetLineJoin(basegfx::B2DLineJoin::NONE); 
// It were lines; force to NONE
+if (aLinePolygon.count())
 createLinePrimitive(aLinePolygon, aLineInfo, 
rTargetHolders.Current(), rPropertyHolders.Current());
-}
 }
 
 break;
diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx
index 0290c487c574..997f2287f010 100644
--- a/emfio/inc/mtftools.hxx
+++ b/emfio/inc/mtftools.hxx
@@ -204,8 +204,6 @@ namespace emfio
 enum PenStyle : sal_uInt32
 {
 PS_COSMETIC  = 0x,
-PS_ENDCAP_ROUND  = 0x,
-PS_JOIN_ROUND= 0x,
 PS_SOLID = 0x,
 PS_DASH  = 0x0001,
 PS_DOT   = 0x0002,
@@ -216,12 +214,17 @@ namespace emfio
 PS_USERSTYLE = 0x0007,
 PS_ALTERNATE = 0x0008,
 PS_STYLE_MASK= 0x000F,
+
+PS_ENDCAP_ROUND  = 0x,
 PS_ENDCAP_SQUARE = 0x0100,
 PS_ENDCAP_FLAT   = 0x0200,
 PS_ENDCAP_STYLE_MASK = 0x0F00,
+
+PS_JOIN_ROUND= 0x,
 PS_JOIN_BEVEL= 0x1000,
 PS_JOIN_MITER= 0x2000,
 PS_JOIN_STYLE_MASK   = 0xF000,
+
 PS_GEOMETRIC = 0x0001
 };
 
@@ -461,11 +464,75 @@ namespace emfio
 , bTransparent(bTrans)
 {}
 
-WinMtfLineStyle(const Color& rColor, const LineInfo& rStyle, bool 
bTrans)
+WinMtfLineStyle(const Color& rColor, const sal_uInt32 nStyle, const 
sal_Int32 nPenWidth)
 : aLineColor(rColor)
-, aLineInfo(rStyle)
-, bTransparent(bTrans)
-{}
+{
+// According to documentation: nStyle = PS_COSMETIC = 0x0 - line 
with a width of one logical unit and a style that is a solid 

[Libreoffice-commits] core.git: drawinglayer/source emfio/inc emfio/qa emfio/source

2021-06-05 Thread Bartosz Kosiorek (via logerrit)
 drawinglayer/source/tools/primitive2dxmldump.cxx |   28 +
 emfio/inc/wmfreader.hxx  |2 
 emfio/qa/cppunit/emf/EmfImportTest.cxx   |   34 ++
 emfio/qa/cppunit/wmf/data/TestStretchDIB.wmf |binary
 emfio/source/reader/wmfreader.cxx|  115 +--
 5 files changed, 131 insertions(+), 48 deletions(-)

New commits:
commit 33d2cf7008de79106b5da4bba0241aa14d81d88f
Author: Bartosz Kosiorek 
AuthorDate: Sat Jun 5 19:30:46 2021 +0200
Commit: Bartosz Kosiorek 
CommitDate: Sat Jun 5 20:20:24 2021 +0200

WMF Change the sign of read fields in BITBLT and DIB records

Additionally the names of variables were improved,
and additional checks were added for unsupported cases
Change-Id: Id84ef1218c5c2a40c8d01f2d40857d892badbb9f

Change-Id: I1b8571d0a627827bc1e67c2bfc6c1932d58c5233
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116744
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 

diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index 24c390c7e0f3..295c13fde6e9 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -37,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace drawinglayer::primitive2d;
 
@@ -205,6 +207,32 @@ void Primitive2dXmlDump::decomposeAndWrite(
 
 switch (nId)
 {
+case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D:
+{
+const BitmapPrimitive2D& rBitmapPrimitive2D = 
dynamic_cast(*pBasePrimitive);
+rWriter.startElement("bitmap");
+
+basegfx::B2DHomMatrix const & rMatrix = 
rBitmapPrimitive2D.getTransform();
+rWriter.attribute("xy11", rMatrix.get(0,0));
+rWriter.attribute("xy12", rMatrix.get(0,1));
+rWriter.attribute("xy13", rMatrix.get(0,2));
+rWriter.attribute("xy21", rMatrix.get(1,0));
+rWriter.attribute("xy22", rMatrix.get(1,1));
+rWriter.attribute("xy23", rMatrix.get(1,2));
+rWriter.attribute("xy31", rMatrix.get(2,0));
+rWriter.attribute("xy32", rMatrix.get(2,1));
+rWriter.attribute("xy33", rMatrix.get(2,2));
+
+const BitmapEx 
aBitmapEx(VCLUnoHelper::GetBitmap(rBitmapPrimitive2D.getXBitmap()));
+const Size& rSizePixel(aBitmapEx.GetSizePixel());
+
+rWriter.attribute("height", rSizePixel.getHeight());
+rWriter.attribute("width", rSizePixel.getWidth());
+rWriter.attribute("checksum", aBitmapEx.GetChecksum());
+
+rWriter.endElement();
+}
+break;
 case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D:
 {
 const HiddenGeometryPrimitive2D& rHiddenGeometryPrimitive2D = 
dynamic_cast(*pBasePrimitive);
diff --git a/emfio/inc/wmfreader.hxx b/emfio/inc/wmfreader.hxx
index 9e1059d63760..279f3e4caeee 100644
--- a/emfio/inc/wmfreader.hxx
+++ b/emfio/inc/wmfreader.hxx
@@ -55,7 +55,7 @@ namespace emfio
 boolReadHeader();
 
 // reads parameters of the record with the functionnumber nFunction.
-voidReadRecordParams(sal_uInt16 nFunction);
+voidReadRecordParams(sal_uInt32 nRecordSize, sal_uInt16 
nFunction);
 
 Point   ReadPoint();// reads and converts a 
point (first X then Y)
 Point   ReadYX();   // reads and converts a 
point (first Y then X)
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx 
b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 1613fe943e6f..2ad512d0bac1 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -65,6 +65,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools, public unotest:
 void TestExtTextOutOpaqueAndClipWMF();
 void TestPaletteWMF();
 void TestRoundrectWMF();
+void TestStretchDIBWMF();
 void TestPolylinetoCloseStroke();
 void TestPolyLineWidth();
 void TestRoundRect();
@@ -98,6 +99,7 @@ public:
 CPPUNIT_TEST(TestExtTextOutOpaqueAndClipWMF);
 CPPUNIT_TEST(TestPaletteWMF);
 CPPUNIT_TEST(TestRoundrectWMF);
+CPPUNIT_TEST(TestStretchDIBWMF);
 CPPUNIT_TEST(TestPolylinetoCloseStroke);
 CPPUNIT_TEST(TestPolyLineWidth);
 CPPUNIT_TEST(TestRoundRect);
@@ -685,6 +687,38 @@ void Test::TestRoundrectWMF()
 "width", "143");
 }
 
+void Test::TestStretchDIBWMF()
+{
+// WMF records: STRETCHDIB
+Primitive2DSequence aSequence = 
parseEmf(u"/emfio/qa/cppunit/wmf/data/TestStretchDIB.wmf");
+CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength()));
+drawinglayer::Primitive2dXmlDump dumper;
+