[Libreoffice-commits] core.git: 2 commits - emfio/qa emfio/source vcl/qa vcl/skia vcl/source
emfio/qa/cppunit/wmf/data/EOF.wmf |binary emfio/qa/cppunit/wmf/wmfimporttest.cxx | 27 +++ emfio/source/reader/wmfreader.cxx | 24 vcl/qa/cppunit/pdfexport/pdfexport.cxx |8 vcl/skia/salbmp.cxx|1 + vcl/source/bitmap/alpha.cxx|7 ++- 6 files changed, 50 insertions(+), 17 deletions(-) New commits: commit c75cac85230d3899fe9f5f5086c117e4e1e5d330 Author: Bartosz Kosiorek AuthorDate: Sat Jun 17 02:57:42 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Sun Oct 29 11:18:33 2023 +0100 tdf#155887 WMF Fix displaying images with size of EOF other that 3 The size of W_META_EOF (record indicates the end of the WMF metafile) could be different than 3 (e.g. 6). The MS Office is allowing different sizes of EOF, and just properly finalizine parsing WMF file, and display its content. Original bug report: https://bz.apache.org/ooo/show_bug.cgi?id=42090 Change-Id: I21b72615c7f45fdca145e6240c6451d7d264d238 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153204 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/wmf/data/EOF.wmf b/emfio/qa/cppunit/wmf/data/EOF.wmf new file mode 100644 index ..5e6af7850546 Binary files /dev/null and b/emfio/qa/cppunit/wmf/data/EOF.wmf differ diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx index a42e7f0dd7c3..84154f47d046 100644 --- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx +++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx @@ -45,6 +45,7 @@ public: { } +void testEOFWmf(); void testNonPlaceableWmf(); void testTdf88163NonPlaceableWmf(); void testTdf88163PlaceableWmf(); @@ -63,6 +64,7 @@ public: void testStockObject(); CPPUNIT_TEST_SUITE(WmfTest); +CPPUNIT_TEST(testEOFWmf); CPPUNIT_TEST(testNonPlaceableWmf); CPPUNIT_TEST(testTdf88163NonPlaceableWmf); CPPUNIT_TEST(testTdf88163PlaceableWmf); @@ -82,6 +84,31 @@ public: CPPUNIT_TEST_SUITE_END(); }; +void WmfTest::testEOFWmf() +{ +// tdf#155887 Test META_EOF with size different than 3 +// It should be properly displayed as MS Office do +SvFileStream aFileStream(getFullUrl(u"EOF.wmf"), StreamMode::READ); +GDIMetaFile aGDIMetaFile; +ReadWindowMetafile(aFileStream, aGDIMetaFile); + +MetafileXmlDump dumper; +xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + +CPPUNIT_ASSERT(pDoc); +assertXPath(pDoc, "/metafile/push", 2); +assertXPath(pDoc, "/metafile/push[2]", "flags", "PushClipRegion"); +assertXPath(pDoc, "/metafile/push[2]/fillcolor", 2); +assertXPath(pDoc, "/metafile/push[2]/fillcolor[1]", "color", "#00"); +assertXPath(pDoc, "/metafile/push[2]/fillcolor[2]", "color", "#d0d0d0"); +assertXPath(pDoc, "/metafile/push[2]/linecolor", 60); +assertXPath(pDoc, "/metafile/push[2]/polyline", 209); +assertXPath(pDoc, "/metafile/push[2]/polyline[1]/point", 5); +assertXPath(pDoc, "/metafile/push[2]/polyline[1]/point[3]", "x", "16906"); +assertXPath(pDoc, "/metafile/push[2]/polyline[1]/point[3]", "y", "12673"); +assertXPath(pDoc, "/metafile/push[2]/textarray", 307); +} + void WmfTest::testNonPlaceableWmf() { SvFileStream aFileStream(getFullUrl(u"visio_import_source.wmf"), StreamMode::READ); diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index fd954e960c49..b419fb3e5745 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -156,6 +156,7 @@ namespace #else switch( nRecType ) { +case W_META_EOF: return "W_META_EOF"; case W_META_SETBKCOLOR: return "META_SETBKCOLOR"; case W_META_SETBKMODE: return "META_SETBKMODE"; case W_META_SETMAPMODE: return "META_SETMAPMODE"; @@ -1523,10 +1524,10 @@ namespace emfio // changing mnUnitsPerInch as a tool to scale wmf mnUnitsPerInch *= fRatio; -SAL_INFO("emfio", "Placeable bounds " -" left: " << aPlaceableBound.Left() << " top: " << aPlaceableBound.Top() -<< " right: " << aPlaceableBound.Right() << " bottom: " << aPlaceableBound.Bottom()); } +SAL_INFO("emfio", "Placeable bounds " + " left: " << aPlaceableBound.Left() << " top: " << aPlaceableBound.Top() << +
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/emfphelperdata.cxx | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) New commits: commit 4a4e8a7aa2c9631f199014c125a1a926d327a005 Author: Bartosz Kosiorek AuthorDate: Sat Oct 28 21:55:59 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Sat Oct 28 14:06:28 2023 +0200 Fix variable names according to documentation Change-Id: I8a5b675a124b3f229ec71fc56aae27038aeedeb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158558 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index b5b7d911476f..26b7563fec80 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1076,14 +1076,15 @@ namespace emfplushelper { case EmfPlusRecordTypeHeader: { -sal_uInt32 header, version; +sal_uInt32 version, emfPlusFlags; +SAL_INFO("drawinglayer.emf", "EMF+\tDual: " << ((flags & 1) ? "true" : "false")); - rMS.ReadUInt32(header).ReadUInt32(version).ReadUInt32(mnHDPI).ReadUInt32(mnVDPI); -SAL_INFO("drawinglayer.emf", "EMF+\tHeader: 0x" << std::hex << header); -SAL_INFO("drawinglayer.emf", "EMF+\tVersion: " << std::dec << version); + rMS.ReadUInt32(version).ReadUInt32(emfPlusFlags).ReadUInt32(mnHDPI).ReadUInt32(mnVDPI); +SAL_INFO("drawinglayer.emf", "EMF+\tVersion: 0x" << std::hex << version); +SAL_INFO("drawinglayer.emf", "EMF+\tEmf+ Flags: 0x" << emfPlusFlags << std::dec); +SAL_INFO("drawinglayer.emf", "EMF+\tMetafile was recorded with a reference device context for " << ((emfPlusFlags & 1) ? "video display" : "printer")); SAL_INFO("drawinglayer.emf", "EMF+\tHorizontal DPI: " << mnHDPI); SAL_INFO("drawinglayer.emf", "EMF+\tVertical DPI: " << mnVDPI); -SAL_INFO("drawinglayer.emf", "EMF+\tDual: " << ((flags & 1) ? "true" : "false")); break; } case EmfPlusRecordTypeEndOfFile:
[Libreoffice-commits] core.git: emfio/source vcl/qa
emfio/source/reader/wmfreader.cxx| 470 ++- vcl/qa/cppunit/graphicfilter/data/README | 19 - 2 files changed, 297 insertions(+), 192 deletions(-) New commits: commit 00e02dd832988ec3e7f37569c932ed66e1eb6efd Author: Bartosz Kosiorek AuthorDate: Tue Jun 20 16:45:38 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Sat Oct 28 11:06:40 2023 +0200 tdf#155887 Add individual WMF records validation In previous implementation, there was no proper validation of the records, by it's size. This commit adds validation of the WMF records. It would allow to interrupt reading, if wrong record found and play only records until it it correct. It will allow to mimic the behaviour of MS Office: If the wrong record is detected, the image is displayed till the wrong record. Currently in LibreOffice, if wrong record is found whole read is interrupted. Change-Id: I0c82deabcec7a416ca44540e693822f1986437eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153351 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index cfb15cd31eac..fd954e960c49 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -286,54 +286,71 @@ namespace emfio void WmfReader::ReadRecordParams( sal_uInt32 nRecordSize, sal_uInt16 nFunc ) { +bool bRecordOk = true; SAL_INFO("emfio", "\t" << record_type_name(nFunc)); -switch( nFunc ) +switch(nFunc) { case W_META_SETBKCOLOR: { -SetBkColor( ReadColor() ); +if (nRecordSize != 5) +bRecordOk = false; +SetBkColor(ReadColor()); } break; case W_META_SETBKMODE: { +// It could have Reserved values. Both 4 and 5 sizes are allowed +if ((nRecordSize != 4) && (nRecordSize != 5)) +bRecordOk = false; sal_uInt16 nDat = 0; mpInputStream->ReadUInt16( nDat ); SetBkMode( static_cast(nDat) ); } break; -// !!! case W_META_SETMAPMODE: { -sal_Int16 nMapMode = 0; -mpInputStream->ReadInt16( nMapMode ); -SetMapMode( static_cast(nMapMode) ); +if (nRecordSize != 4) +bRecordOk = false; +sal_uInt16 nMapMode = 0; +mpInputStream->ReadUInt16(nMapMode); +SetMapMode(static_cast(nMapMode)); } break; case W_META_SETROP2: { +// It could have Reserved values. Both 4 and 5 sizes are allowed +if ((nRecordSize != 4) && (nRecordSize != 5)) +bRecordOk = false; sal_uInt16 nROP2 = 0; -mpInputStream->ReadUInt16( nROP2 ); -SetRasterOp( static_cast(nROP2) ); +mpInputStream->ReadUInt16(nROP2); +SetRasterOp(static_cast(nROP2)); +mpInputStream->SeekRel(2); // reserved data } break; case W_META_SETTEXTCOLOR: { +if (nRecordSize != 5) +bRecordOk = false; SetTextColor( ReadColor() ); } break; case W_META_SETWINDOWORG: { +if (nRecordSize != 5) +bRecordOk = false; SetWinOrg( ReadYX() ); } break; case W_META_SETWINDOWEXT: { +if (nRecordSize != 5) +bRecordOk = false; short nWidth = 0, nHeight = 0; mpInputStream->ReadInt16( nHeight ).ReadInt16( nWidth ); SetWinExt( Size( nWidth, nHeight ) ); @@ -342,6 +359,8 @@ namespace emfio case W_META_OFFSETWINDOWORG: { +if (nRecordSize != 5) +bRecordOk = false; short nXAdd = 0, nYAdd = 0; mpInputStream->ReadInt16( nYAdd ).ReadInt16( nXAdd ); SetWinOrgOffset( nXAdd, nYAdd ); @@ -350,6 +369,8 @@ namespace emfio case W_META_SCALEWINDOWEXT: { +if (nRecordSize != 7) +bRecordOk = false; short nXNum = 0, nXDenom = 0, nYNum = 0, nYDenom = 0; mpInputStream->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); if (!nYDenom || !nXDenom) @@ -363,10 +384,16 @@ namespace emfio case W_META_SETVIEWPORTORG: case W
[Libreoffice-commits] core.git: helpcontent2
helpcontent2 |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit aa1ab7d3b7646ee5d5ee879b5faaecf620969958 Author: Bartosz Kosiorek AuthorDate: Sun Sep 10 23:10:15 2023 +0200 Commit: Gerrit Code Review CommitDate: Sun Sep 10 23:10:15 2023 +0200 Update git submodules * Update helpcontent2 from branch 'master' to bb07bc0599affc52cebc346ddc330fb61b496462 - tdf#154872 Add Poisson distribution entry to documentation Change-Id: I50d715f5ceb10e4560ee639f89c84752ecf65aae Reviewed-on: https://gerrit.libreoffice.org/c/help/+/156806 Tested-by: Jenkins Reviewed-by: Olivier Hallot diff --git a/helpcontent2 b/helpcontent2 index f419319c17c6..bb07bc0599af 16 --- a/helpcontent2 +++ b/helpcontent2 @@ -1 +1 @@ -Subproject commit f419319c17c61a5fbd36e1bdd1a6b281283ac421 +Subproject commit bb07bc0599affc52cebc346ddc330fb61b496462
[Libreoffice-commits] help.git: source/text
source/text/scalc/01/02140700.xhp | 11 +++ 1 file changed, 11 insertions(+) New commits: commit bb07bc0599affc52cebc346ddc330fb61b496462 Author: Bartosz Kosiorek AuthorDate: Sun Sep 10 22:10:31 2023 +0200 Commit: Olivier Hallot CommitDate: Sun Sep 10 23:10:15 2023 +0200 tdf#154872 Add Poisson distribution entry to documentation Change-Id: I50d715f5ceb10e4560ee639f89c84752ecf65aae Reviewed-on: https://gerrit.libreoffice.org/c/help/+/156806 Tested-by: Jenkins Reviewed-by: Olivier Hallot diff --git a/source/text/scalc/01/02140700.xhp b/source/text/scalc/01/02140700.xhp index a948801fa9..e3d66a88ad 100644 --- a/source/text/scalc/01/02140700.xhp +++ b/source/text/scalc/01/02140700.xhp @@ -176,6 +176,17 @@ + + +Poisson + + + + +Mean: The mean of the Poisson distribution. + + + Options Enable custom seed
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - drawinglayer/source emfio/qa
dev/null |binary drawinglayer/source/tools/emfppath.cxx | 42 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 263 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawCurve.emf |binary emfio/qa/cppunit/emf/data/TestEmfPlusFillClosedCurve.emf |binary 5 files changed, 143 insertions(+), 162 deletions(-) New commits: commit 0e4e10f54dc4218b1a2c8f740173aa3a5d13ad0a Author: Bartosz Kosiorek AuthorDate: Sat Jun 10 18:13:50 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Wed Jun 14 15:14:46 2023 +0200 tdf#143877 Fix failing tests caused by floating point precision Due to different imlementation of floating-point unit (FPU), on different CPU platforms, the floating point numbers could could be different. https://stackoverflow.com/questions/64036879/differing-floating-point-calculation-results-between-x86-64-and-armv8-2-a https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/ With this path I have changed the tested images, to use floating point numbers which are easily represented by floating numbers (multiplied/divided by 2), like: - change tension to values: 0.125, 0.25, 0.5, 1.0, 1.5 ... - change position of curve to of control points to 256.0, 384.0 512.0 Previous values was hard to represent by floating numbers, for example tension: - 0.4 has been written as 0.39976158142 - 0.1 has been written as 0.09994039535 More information: https://observablehq.com/@benaubin/floating-point Additionally the precision of numbers were increased to double. Change-Id: I5725c1f2f474d0c00821edaa9bb2102cb172093f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152838 Reviewed-by: Stephan Bergmann Tested-by: Bartosz Kosiorek (cherry picked from commit 731ab48c4e7b2fb2ad012d60c44b373bb07a9f4e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152984 Tested-by: Jenkins Tested-by: René Engelhard Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfppath.cxx b/drawinglayer/source/tools/emfppath.cxx index bd5b2d357b0f..e7c4a5512c76 100644 --- a/drawinglayer/source/tools/emfppath.cxx +++ b/drawinglayer/source/tools/emfppath.cxx @@ -34,7 +34,12 @@ namespace namespace emfplushelper { -typedef float matrix [4][4]; +typedef double matrix [4][4]; + +constexpr sal_uInt32 nDetails = 8; +constexpr double alpha[nDetails] += { 1. / nDetails, 2. / nDetails, 3. / nDetails, 4. / nDetails, +5. / nDetails, 6. / nDetails, 7. / nDetails, 8. / nDetails }; // see 2.2.2.21 EmfPlusInteger7 // 2.2.2.22 EmfPlusInteger15 @@ -232,21 +237,20 @@ namespace emfplushelper m[0][2] = tension - 2.; m[1][0] = 2. * tension; m[1][1] = tension - 3.; -m[1][2] = 3. - 2 * tension; +m[1][2] = 3. - 2. * tension; m[3][1] = 1.; m[0][3] = m[2][2] = tension; m[0][0] = m[1][3] = m[2][0] = -tension; m[2][1] = m[2][3] = m[3][0] = m[3][2] = m[3][3] = 0.; } -static float calculateSplineCoefficients(float p0, float p1, float p2, float p3, float alpha, matrix m) +static double calculateSplineCoefficients(float p0, float p1, float p2, float p3, sal_uInt32 step, matrix m) { -float a, b, c, d; -a = m[0][0] * p0 + m[0][1] * p1 + m[0][2] * p2 + m[0][3] * p3; -b = m[1][0] * p0 + m[1][1] * p1 + m[1][2] * p2 + m[1][3] * p3; -c = m[2][0] * p0 + m[2][2] * p2; -d = p1; -return (d + alpha * (c + alpha * (b + alpha * a))); +double a = m[0][0] * p0 + m[0][1] * p1 + m[0][2] * p2 + m[0][3] * p3; +double b = m[1][0] * p0 + m[1][1] * p1 + m[1][2] * p2 + m[1][3] * p3; +double c = m[2][0] * p0 + m[2][2] * p2; +double d = p1; +return (d + alpha[step] * (c + alpha[step] * (b + alpha[step] * a))); } ::basegfx::B2DPolyPolygon& EMFPPath::GetCardinalSpline(EmfPlusHelperData const& rR, float fTension, @@ -254,11 +258,7 @@ namespace emfplushelper { ::basegfx::B2DPolygon polygon; matrix mat; -float x, y; -constexpr sal_uInt32 nDetails = 8; -constexpr float alpha[nDetails] -= { 1. / nDetails, 2. / nDetails, 3. / nDetails, 4. / nDetails, -5. / nDetails, 6. / nDetails, 7. / nDetails, 8. / nDetails }; +double x, y; if (aNumSegments >= nPoints) aNumSegments = nPoints - 1; GetCardinalMatrix(fTension, mat); @@ -274,9 +274,9 @@ namespace emfplushelper for (sal_uInt32 s = 0; s < nDetails; s++) { x = calculateSplineCoefficients(xPoints[i - 3], xPoints[i - 2], xPoints[i - 1], -xPoints[i],
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
dev/null |binary drawinglayer/source/tools/emfppath.cxx | 42 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 263 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawCurve.emf |binary emfio/qa/cppunit/emf/data/TestEmfPlusFillClosedCurve.emf |binary 5 files changed, 143 insertions(+), 162 deletions(-) New commits: commit cbb215aa20783523555185c83875ea5d5b94535b Author: Bartosz Kosiorek AuthorDate: Sat Jun 10 18:13:50 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jun 13 12:59:33 2023 +0200 tdf#143877 Fix failing tests caused by floating point precision Due to different imlementation of floating-point unit (FPU), on different CPU platforms, the floating point numbers could could be different. https://stackoverflow.com/questions/64036879/differing-floating-point-calculation-results-between-x86-64-and-armv8-2-a https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/ With this path I have changed the tested images, to use floating point numbers which are easily represented by floating numbers (multiplied/divided by 2), like: - change tension to values: 0.125, 0.25, 0.5, 1.0, 1.5 ... - change position of curve to of control points to 256.0, 384.0 512.0 Previous values was hard to represent by floating numbers, for example tension: - 0.4 has been written as 0.39976158142 - 0.1 has been written as 0.09994039535 More information: https://observablehq.com/@benaubin/floating-point Additionally the precision of numbers were increased to double. Change-Id: I5725c1f2f474d0c00821edaa9bb2102cb172093f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152838 Reviewed-by: Stephan Bergmann Tested-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfppath.cxx b/drawinglayer/source/tools/emfppath.cxx index bd5b2d357b0f..e7c4a5512c76 100644 --- a/drawinglayer/source/tools/emfppath.cxx +++ b/drawinglayer/source/tools/emfppath.cxx @@ -34,7 +34,12 @@ namespace namespace emfplushelper { -typedef float matrix [4][4]; +typedef double matrix [4][4]; + +constexpr sal_uInt32 nDetails = 8; +constexpr double alpha[nDetails] += { 1. / nDetails, 2. / nDetails, 3. / nDetails, 4. / nDetails, +5. / nDetails, 6. / nDetails, 7. / nDetails, 8. / nDetails }; // see 2.2.2.21 EmfPlusInteger7 // 2.2.2.22 EmfPlusInteger15 @@ -232,21 +237,20 @@ namespace emfplushelper m[0][2] = tension - 2.; m[1][0] = 2. * tension; m[1][1] = tension - 3.; -m[1][2] = 3. - 2 * tension; +m[1][2] = 3. - 2. * tension; m[3][1] = 1.; m[0][3] = m[2][2] = tension; m[0][0] = m[1][3] = m[2][0] = -tension; m[2][1] = m[2][3] = m[3][0] = m[3][2] = m[3][3] = 0.; } -static float calculateSplineCoefficients(float p0, float p1, float p2, float p3, float alpha, matrix m) +static double calculateSplineCoefficients(float p0, float p1, float p2, float p3, sal_uInt32 step, matrix m) { -float a, b, c, d; -a = m[0][0] * p0 + m[0][1] * p1 + m[0][2] * p2 + m[0][3] * p3; -b = m[1][0] * p0 + m[1][1] * p1 + m[1][2] * p2 + m[1][3] * p3; -c = m[2][0] * p0 + m[2][2] * p2; -d = p1; -return (d + alpha * (c + alpha * (b + alpha * a))); +double a = m[0][0] * p0 + m[0][1] * p1 + m[0][2] * p2 + m[0][3] * p3; +double b = m[1][0] * p0 + m[1][1] * p1 + m[1][2] * p2 + m[1][3] * p3; +double c = m[2][0] * p0 + m[2][2] * p2; +double d = p1; +return (d + alpha[step] * (c + alpha[step] * (b + alpha[step] * a))); } ::basegfx::B2DPolyPolygon& EMFPPath::GetCardinalSpline(EmfPlusHelperData const& rR, float fTension, @@ -254,11 +258,7 @@ namespace emfplushelper { ::basegfx::B2DPolygon polygon; matrix mat; -float x, y; -constexpr sal_uInt32 nDetails = 8; -constexpr float alpha[nDetails] -= { 1. / nDetails, 2. / nDetails, 3. / nDetails, 4. / nDetails, -5. / nDetails, 6. / nDetails, 7. / nDetails, 8. / nDetails }; +double x, y; if (aNumSegments >= nPoints) aNumSegments = nPoints - 1; GetCardinalMatrix(fTension, mat); @@ -274,9 +274,9 @@ namespace emfplushelper for (sal_uInt32 s = 0; s < nDetails; s++) { x = calculateSplineCoefficients(xPoints[i - 3], xPoints[i - 2], xPoints[i - 1], -xPoints[i], alpha[s], mat); +xPoints[i], s, mat); y = calculateSplineCoefficients(yPoints[i - 3], yPoints[i - 2], yPoints[i - 1], -yPoints[i],
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 56 ++- drawinglayer/source/tools/emfphelperdata.hxx |2 drawinglayer/source/tools/emfppath.cxx | 126 ++- drawinglayer/source/tools/emfppath.hxx |5 emfio/qa/cppunit/emf/EmfImportTest.cxx | 186 +-- emfio/qa/cppunit/emf/data/TestEmfPlusFillClosedCurve.emf |binary emfio/qa/cppunit/emf/data/TestEmfPlusRecordTypeDrawCurve.emf |binary 7 files changed, 318 insertions(+), 57 deletions(-) New commits: commit 62d5a612f1a3c8180c0e5059e8e05e0bedc9629b Author: Bartosz Kosiorek AuthorDate: Thu Jun 1 21:16:06 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Jun 2 15:25:52 2023 +0200 tdf#143877 EMF+ Implement EmfPlusDrawCurve with cardinal spline Change-Id: I98d30b2a8ba63fdddc08668f453c5f0feeb452db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152288 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152552 diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 94c4c32f026f..03b270228628 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -81,6 +81,8 @@ namespace emfplushelper case EmfPlusRecordTypeFillPolygon: return "EmfPlusRecordTypeFillPolygon"; case EmfPlusRecordTypeDrawLines: return "EmfPlusRecordTypeDrawLines"; case EmfPlusRecordTypeFillClosedCurve: return "EmfPlusRecordTypeFillClosedCurve"; +case EmfPlusRecordTypeDrawClosedCurve: return "EmfPlusRecordTypeDrawClosedCurve"; +case EmfPlusRecordTypeDrawCurve: return "EmfPlusRecordTypeDrawCurve"; case EmfPlusRecordTypeFillEllipse: return "EmfPlusRecordTypeFillEllipse"; case EmfPlusRecordTypeDrawEllipse: return "EmfPlusRecordTypeDrawEllipse"; case EmfPlusRecordTypeFillPie: return "EmfPlusRecordTypeFillPie"; @@ -90,7 +92,6 @@ namespace emfplushelper case EmfPlusRecordTypeFillPath: return "EmfPlusRecordTypeFillPath"; case EmfPlusRecordTypeDrawPath: return "EmfPlusRecordTypeDrawPath"; case EmfPlusRecordTypeDrawBeziers: return "EmfPlusRecordTypeDrawBeziers"; -case EmfPlusRecordTypeDrawClosedCurve: return "EmfPlusRecordTypeDrawClosedCurve"; case EmfPlusRecordTypeDrawImage: return "EmfPlusRecordTypeDrawImage"; case EmfPlusRecordTypeDrawImagePoints: return "EmfPlusRecordTypeDrawImagePoints"; case EmfPlusRecordTypeDrawString: return "EmfPlusRecordTypeDrawString"; @@ -1383,6 +1384,30 @@ namespace emfplushelper EMFPPlusDrawPolygon(::basegfx::B2DPolyPolygon(aPolygon), flags & 0xff); break; } +case EmfPlusRecordTypeDrawCurve: +{ +sal_uInt32 aOffset, aNumSegments, points; +float aTension; +rMS.ReadFloat(aTension); +rMS.ReadUInt32(aOffset); +rMS.ReadUInt32(aNumSegments); +rMS.ReadUInt32(points); +SAL_WARN("drawinglayer.emf", +"EMF+\t Tension: " << aTension << " Offset: " << aOffset + << " NumSegments: " << aNumSegments + << " Points: " << points); + +EMFPPath path(points, true); +path.Read(rMS, flags); + +if (points >= 2) +EMFPPlusDrawPolygon( +path.GetCardinalSpline(*this, aTension, aOffset, aNumSegments), +flags & 0xff); +else +SAL_WARN("drawinglayer.emf", "Not enough number of points"); +break; +} case EmfPlusRecordTypeDrawClosedCurve: case EmfPlusRecordTypeFillClosedCurve: { @@ -1392,28 +1417,29 @@ namespace emfplushelper if (type == EmfPlusRecordTypeFillClosedCurve) { rMS.ReadUInt32(brushIndexOrColor); -SAL_INFO("drawinglayer.emf", +SAL_INFO( +"drawinglaye
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 56 ++- drawinglayer/source/tools/emfphelperdata.hxx |2 drawinglayer/source/tools/emfppath.cxx | 126 ++- drawinglayer/source/tools/emfppath.hxx |5 emfio/qa/cppunit/emf/EmfImportTest.cxx | 184 +-- emfio/qa/cppunit/emf/data/TestEmfPlusFillClosedCurve.emf |binary emfio/qa/cppunit/emf/data/TestEmfPlusRecordTypeDrawCurve.emf |binary 7 files changed, 316 insertions(+), 57 deletions(-) New commits: commit 0b5c0d9e9d6c71d3531a7e1020af1753a50e873e Author: Bartosz Kosiorek AuthorDate: Thu Jun 1 21:16:06 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Jun 1 21:17:06 2023 +0200 tdf#143877 EMF+ Implement EmfPlusDrawCurve with cardinal spline Change-Id: I98d30b2a8ba63fdddc08668f453c5f0feeb452db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152288 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 879d40b925d5..b5b7d911476f 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -81,6 +81,8 @@ namespace emfplushelper case EmfPlusRecordTypeFillPolygon: return "EmfPlusRecordTypeFillPolygon"; case EmfPlusRecordTypeDrawLines: return "EmfPlusRecordTypeDrawLines"; case EmfPlusRecordTypeFillClosedCurve: return "EmfPlusRecordTypeFillClosedCurve"; +case EmfPlusRecordTypeDrawClosedCurve: return "EmfPlusRecordTypeDrawClosedCurve"; +case EmfPlusRecordTypeDrawCurve: return "EmfPlusRecordTypeDrawCurve"; case EmfPlusRecordTypeFillEllipse: return "EmfPlusRecordTypeFillEllipse"; case EmfPlusRecordTypeDrawEllipse: return "EmfPlusRecordTypeDrawEllipse"; case EmfPlusRecordTypeFillPie: return "EmfPlusRecordTypeFillPie"; @@ -90,7 +92,6 @@ namespace emfplushelper case EmfPlusRecordTypeFillPath: return "EmfPlusRecordTypeFillPath"; case EmfPlusRecordTypeDrawPath: return "EmfPlusRecordTypeDrawPath"; case EmfPlusRecordTypeDrawBeziers: return "EmfPlusRecordTypeDrawBeziers"; -case EmfPlusRecordTypeDrawClosedCurve: return "EmfPlusRecordTypeDrawClosedCurve"; case EmfPlusRecordTypeDrawImage: return "EmfPlusRecordTypeDrawImage"; case EmfPlusRecordTypeDrawImagePoints: return "EmfPlusRecordTypeDrawImagePoints"; case EmfPlusRecordTypeDrawString: return "EmfPlusRecordTypeDrawString"; @@ -1374,6 +1375,30 @@ namespace emfplushelper EMFPPlusDrawPolygon(::basegfx::B2DPolyPolygon(aPolygon), flags & 0xff); break; } +case EmfPlusRecordTypeDrawCurve: +{ +sal_uInt32 aOffset, aNumSegments, points; +float aTension; +rMS.ReadFloat(aTension); +rMS.ReadUInt32(aOffset); +rMS.ReadUInt32(aNumSegments); +rMS.ReadUInt32(points); +SAL_WARN("drawinglayer.emf", +"EMF+\t Tension: " << aTension << " Offset: " << aOffset + << " NumSegments: " << aNumSegments + << " Points: " << points); + +EMFPPath path(points, true); +path.Read(rMS, flags); + +if (points >= 2) +EMFPPlusDrawPolygon( +path.GetCardinalSpline(*this, aTension, aOffset, aNumSegments), +flags & 0xff); +else +SAL_WARN("drawinglayer.emf", "Not enough number of points"); +break; +} case EmfPlusRecordTypeDrawClosedCurve: case EmfPlusRecordTypeFillClosedCurve: { @@ -1383,28 +1408,29 @@ namespace emfplushelper if (type == EmfPlusRecordTypeFillClosedCurve) { rMS.ReadUInt32(brushIndexOrColor); -SAL_INFO("drawinglayer.emf", +SAL_INFO( +"drawinglayer.emf", "EMF+\t Fill Mode: " << (flags
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |4 - emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf |binary emfio/qa/cppunit/wmf/wmfimporttest.cxx | 91 + emfio/source/reader/mtftools.cxx | 10 +- 4 files changed, 99 insertions(+), 6 deletions(-) New commits: commit a2dcaacbdf9c29c89200c9905da4687e71d74ade Author: Bartosz Kosiorek AuthorDate: Wed May 10 22:30:20 2023 +0200 Commit: Xisco Fauli CommitDate: Mon May 15 11:00:29 2023 +0200 EMF Fix text aligning for EMR_SETTEXTALIGN for wrong values. Change-Id: I4d67eb7112d2295185905eac52ebab022a1beb78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151670 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 717bdd06a7ac1a2a266f36a43d7f1e695559d056) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151772 Reviewed-by: Xisco Fauli diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index f7a318f39d55..d2cbcf01c6e6 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -180,7 +180,9 @@ namespace emfio TA_RIGHT_CENTER = (TA_RIGHT | TA_CENTER), TA_TOP = 0x, TA_BOTTOM = 0x0008, -TA_BASELINE = 0x0018, +// In [MS-WMF] 2.1.2.3, TA_BASELINE value is wrong. +// It is 0x0018 and it should be 0x0010. +TA_BASELINE = 0x0010, TA_RTLREADING = 0x0100 }; diff --git a/emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf b/emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf new file mode 100644 index ..9a3ad46f1d32 Binary files /dev/null and b/emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf differ diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx index c5b2ddbc3205..6e79756e386b 100644 --- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx +++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx @@ -48,6 +48,7 @@ public: void testNonPlaceableWmf(); void testTdf88163NonPlaceableWmf(); void testTdf88163PlaceableWmf(); +void testSetTextAlignWmf(); void testSine(); void testEmfProblem(); void testEmfLineStyles(); @@ -63,6 +64,7 @@ public: CPPUNIT_TEST(testNonPlaceableWmf); CPPUNIT_TEST(testTdf88163NonPlaceableWmf); CPPUNIT_TEST(testTdf88163PlaceableWmf); +CPPUNIT_TEST(testSetTextAlignWmf); CPPUNIT_TEST(testSine); CPPUNIT_TEST(testEmfProblem); CPPUNIT_TEST(testEmfLineStyles); @@ -180,6 +182,95 @@ void WmfTest::testTdf88163PlaceableWmf() assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "y", "390"); } +void WmfTest::testSetTextAlignWmf() +{ +OUString fileName(u"TestSetTextAlign.wmf"); +SvFileStream aFileStream(getFullUrl(fileName), StreamMode::READ); +GDIMetaFile aGDIMetaFile; +ReadWindowMetafile(aFileStream, aGDIMetaFile); + +MetafileXmlDump dumper; + +xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + +CPPUNIT_ASSERT(pDoc); + +assertXPath(pDoc, "/metafile", "height", "20999"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[2]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "x", "11642"); +assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "y", "212"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[2]/text", "textalignment:default"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[3]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "x", "12700"); +assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "y", "212"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[3]/text", "textalignment:0x00"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[4]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[4]", "x", "11999"); +assertXPath(pDoc, "/metafile/push[2]/textarray[4]", "y", "423"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[4]/text", "textalignment:0x02"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[5]", "align", "top"); +// Fails without the fix: Expected: 11999, Actual: 12350 +assertXPath(pDoc, "/metafile/push[2]/textarray[5]", "x", "11999"); +assertXPath(pDoc, "/metafile/push[2]/textarray[5]", "y", "635"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[5]/text", "textalignment:0x04"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[6]", "align", "top"); +
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |4 - emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf |binary emfio/qa/cppunit/wmf/wmfimporttest.cxx | 91 + emfio/source/reader/mtftools.cxx | 10 +- 4 files changed, 99 insertions(+), 6 deletions(-) New commits: commit 717bdd06a7ac1a2a266f36a43d7f1e695559d056 Author: Bartosz Kosiorek AuthorDate: Wed May 10 22:30:20 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Fri May 12 22:42:00 2023 +0200 EMF Fix text aligning for EMR_SETTEXTALIGN for wrong values. Change-Id: I4d67eb7112d2295185905eac52ebab022a1beb78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151670 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index b2237736869b..f5638af59ecb 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -178,7 +178,9 @@ namespace emfio TA_RIGHT_CENTER = (TA_RIGHT | TA_CENTER), TA_TOP = 0x, TA_BOTTOM = 0x0008, -TA_BASELINE = 0x0018, +// In [MS-WMF] 2.1.2.3, TA_BASELINE value is wrong. +// It is 0x0018 and it should be 0x0010. +TA_BASELINE = 0x0010, TA_RTLREADING = 0x0100 }; diff --git a/emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf b/emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf new file mode 100644 index ..9a3ad46f1d32 Binary files /dev/null and b/emfio/qa/cppunit/wmf/data/TestSetTextAlign.wmf differ diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx index 48e47fb0fd36..780933da58d7 100644 --- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx +++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx @@ -48,6 +48,7 @@ public: void testNonPlaceableWmf(); void testTdf88163NonPlaceableWmf(); void testTdf88163PlaceableWmf(); +void testSetTextAlignWmf(); void testSine(); void testEmfProblem(); void testEmfLineStyles(); @@ -65,6 +66,7 @@ public: CPPUNIT_TEST(testNonPlaceableWmf); CPPUNIT_TEST(testTdf88163NonPlaceableWmf); CPPUNIT_TEST(testTdf88163PlaceableWmf); +CPPUNIT_TEST(testSetTextAlignWmf); CPPUNIT_TEST(testSine); CPPUNIT_TEST(testEmfProblem); CPPUNIT_TEST(testEmfLineStyles); @@ -184,6 +186,95 @@ void WmfTest::testTdf88163PlaceableWmf() assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "y", "390"); } +void WmfTest::testSetTextAlignWmf() +{ +OUString fileName(u"TestSetTextAlign.wmf"); +SvFileStream aFileStream(getFullUrl(fileName), StreamMode::READ); +GDIMetaFile aGDIMetaFile; +ReadWindowMetafile(aFileStream, aGDIMetaFile); + +MetafileXmlDump dumper; + +xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + +CPPUNIT_ASSERT(pDoc); + +assertXPath(pDoc, "/metafile", "height", "20999"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[2]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "x", "11642"); +assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "y", "212"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[2]/text", "textalignment:default"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[3]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "x", "12700"); +assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "y", "212"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[3]/text", "textalignment:0x00"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[4]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[4]", "x", "11999"); +assertXPath(pDoc, "/metafile/push[2]/textarray[4]", "y", "423"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[4]/text", "textalignment:0x02"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[5]", "align", "top"); +// Fails without the fix: Expected: 11999, Actual: 12350 +assertXPath(pDoc, "/metafile/push[2]/textarray[5]", "x", "11999"); +assertXPath(pDoc, "/metafile/push[2]/textarray[5]", "y", "635"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[5]/text", "textalignment:0x04"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[6]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[6]", "x", "12350"); +assertXPath(pDoc, "/metafile/push[2]/textarray[6]", "y
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx| 24 +++ emfio/qa/cppunit/emf/data/TestEmfPolydraw.emf |binary emfio/source/reader/emfreader.cxx | 88 +- emfio/source/reader/mtftools.cxx |6 + 4 files changed, 115 insertions(+), 3 deletions(-) New commits: commit ba0bf0ab2c24d309e8a938cec26daa41eba9c8cf Author: Bartosz Kosiorek AuthorDate: Mon Mar 21 20:20:02 2022 +0100 Commit: Bartosz Kosiorek CommitDate: Wed May 10 16:45:47 2023 +0200 tdf#142249 EMF Implement EMR_POLYDRAW record The EMR_POLYDRAW record specifies a set of line segments and Bezier curves. Change-Id: I93d846d2fbb7a60b0565668a17ee092da30ef21c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151424 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 5f8ad7e18044..ba0a8050f24e 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -891,6 +891,30 @@ CPPUNIT_TEST_FIXTURE(Test, testPolylinetoCloseStroke) assertXPath(pDocument, aXPathPrefix + "polygonhairline[2]", "color", "#00"); } +CPPUNIT_TEST_FIXTURE(Test, testEmfPolydraw) +{ +// tdf#142249 EMF import with records: POLYDRAW, CREATEPEN. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEmfPolydraw.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); +CPPUNIT_ASSERT(pDocument); + +assertXPath(pDocument, aXPathPrefix + "polygonhairline", 2); +assertXPath(pDocument, aXPathPrefix + "polygonhairline[1]", "color", "#00"); +assertXPathContent(pDocument, aXPathPrefix + "polygonhairline[1]/polygon", + "2000,200 3000,200 3000,1000"); +assertXPath(pDocument, aXPathPrefix + "polygonhairline[2]", "color", "#00"); +assertXPathContent(pDocument, aXPathPrefix + "polygonhairline[2]/polygon", + "3000,2000 3000,2000 4000,2000 3000,3000"); + +assertXPath(pDocument, aXPathPrefix + "polygonstroke", 1); +assertXPathContent(pDocument, aXPathPrefix + "polygonstroke[1]/polygon", + "50,50 50,50 1000,1000 1000,1000 2000,2500 2000,1000"); +assertXPath(pDocument, aXPathPrefix + "polygonstroke[1]/line", "color", "#ff"); +assertXPath(pDocument, aXPathPrefix + "polygonstroke[1]/stroke", "dotDashArray", "30 10 "); +} + CPPUNIT_TEST_FIXTURE(Test, testEmfPlusBrushPathGradientWithBlendColors) { // tdf#131506 EMF+ records: FillRects, Brush with PathGradient and BlendColor, FillRects diff --git a/emfio/qa/cppunit/emf/data/TestEmfPolydraw.emf b/emfio/qa/cppunit/emf/data/TestEmfPolydraw.emf new file mode 100644 index ..962b163bf363 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestEmfPolydraw.emf differ diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index af676e7de669..ee848097b84f 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -175,6 +175,16 @@ constexpr sal_Int32 ARCDIRECTION_CLOCKWISE = 0x0002; namespace { +/* [MS-EMF] - v20210625 - page 41 */ +/* 2.1.26 Point Enumeration */ +enum EMFPointTypes +{ +PT_CLOSEFIGURE = 0x01, +PT_LINETO = 0x02, +PT_BEZIERTO = 0x04, +PT_MOVETO = 0x06 +}; + const char * record_type_name(sal_uInt32 nRecType) { @@ -932,6 +942,83 @@ namespace emfio DrawPolyLine(ReadPolygonWithSkip(true, nNextPos), true, mbRecordPath); break; +case EMR_POLYDRAW: +{ +sal_uInt32 nPointsCount, nBezierCount = 0; +std::vector aPoints; +sal_Int32 nX, nY; +bool wrongFile = false; +unsigned char nPointType; +std::vector aPointTypes; +mpInputStream->ReadInt32(nX32) +.ReadInt32(nY32) +.ReadInt32(nx32) +.ReadInt32(ny32) +.ReadUInt32(nPointsCount); + +aPoints.reserve(nPointsCount); +for (sal_uInt32 i = 0; i < nPointsCount && mpInputStream->good(); i++) +{ +*mpInputStream >> nX >> nY; +aPoints.push_back(Point(nX, nY)); +} +aPointT
[Libreoffice-commits] core.git: sc/inc sc/source sc/uiconfig
sc/inc/strings.hrc |3 sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx | 32 +++--- sc/uiconfig/scalc/ui/randomnumbergenerator.ui |1 3 files changed, 28 insertions(+), 8 deletions(-) New commits: commit 793cc7d2ef5967af90a6810e597e1e12bd42777c Author: Bartosz Kosiorek AuthorDate: Fri May 5 20:15:19 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Sat May 6 03:54:25 2023 +0200 tdf#154872 Add Poisson distribution to Random Number Generators Change-Id: I325a76423a98a405dfb0f69fbd89eb9253c36390 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151439 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index e860263424be..6c85b3d617da 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -266,9 +266,10 @@ #define STR_DISTRIBUTION_CAUCHY NC_("STR_DISTRIBUTION_CAUCHY", "Cauchy") #define STR_DISTRIBUTION_BERNOULLI NC_("STR_DISTRIBUTION_BERNOULLI", "Bernoulli") #define STR_DISTRIBUTION_BINOMIAL NC_("STR_DISTRIBUTION_BINOMIAL", "Binomial") -#define STR_DISTRIBUTION_NEGATIVE_BINOMIAL NC_("STR_DISTRIBUTION_NEGATIVE_BINOMIAL", "Negative Binomial") #define STR_DISTRIBUTION_CHI_SQUARED NC_("STR_DISTRIBUTION_CHI_SQUARED", "Chi Squared") #define STR_DISTRIBUTION_GEOMETRIC NC_("STR_DISTRIBUTION_GEOMETRIC", "Geometric") +#define STR_DISTRIBUTION_NEGATIVE_BINOMIAL NC_("STR_DISTRIBUTION_NEGATIVE_BINOMIAL", "Negative Binomial") +#define STR_DISTRIBUTION_POISSON NC_("STR_DISTRIBUTION_POISSON", "Poisson") #define STR_RNG_PARAMETER_MINIMUM NC_("STR_RNG_PARAMETER_MINIMUM", "Minimum") #define STR_RNG_PARAMETER_MAXIMUM NC_("STR_RNG_PARAMETER_MAXIMUM", "Maximum") #define STR_RNG_PARAMETER_MEAN NC_("STR_RNG_PARAMETER_MEAN", "Mean") diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx index 91b43cbe0433..2490ebf47301 100644 --- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx @@ -36,6 +36,7 @@ const sal_Int64 DIST_CHI_SQUARED = 5; const sal_Int64 DIST_GEOMETRIC = 6; const sal_Int64 DIST_NEGATIVE_BINOMIAL = 7; const sal_Int64 DIST_UNIFORM_INTEGER = 8; +const sal_Int64 DIST_POISSON = 9; const sal_Int64 PRECISION = 1; const sal_Int64 DIGITS = 4; @@ -225,13 +226,6 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers() GenerateNumbers(rng, STR_DISTRIBUTION_BINOMIAL, aDecimalPlaces); break; } -case DIST_NEGATIVE_BINOMIAL: -{ -std::negative_binomial_distribution<> distribution(parameterInteger2, parameter1); -auto rng = std::bind(distribution, seed); -GenerateNumbers(rng, STR_DISTRIBUTION_NEGATIVE_BINOMIAL, aDecimalPlaces); -break; -} case DIST_CHI_SQUARED: { std::chi_squared_distribution<> distribution(parameter1); @@ -246,6 +240,20 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers() GenerateNumbers(rng, STR_DISTRIBUTION_GEOMETRIC, aDecimalPlaces); break; } +case DIST_NEGATIVE_BINOMIAL: +{ +std::negative_binomial_distribution<> distribution(parameterInteger2, parameter1); +auto rng = std::bind(distribution, seed); +GenerateNumbers(rng, STR_DISTRIBUTION_NEGATIVE_BINOMIAL, aDecimalPlaces); +break; +} +case DIST_POISSON: +{ +std::poisson_distribution<> distribution(parameter1); +auto rng = std::bind(distribution, seed); +GenerateNumbers(rng, STR_DISTRIBUTION_POISSON, aDecimalPlaces); +break; +} } } @@ -476,6 +484,16 @@ IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, DistributionChanged, weld::ComboB mxParameter2Value->hide(); break; } +case DIST_POISSON: +{ +mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_MEAN)); +mxParameter1Value->set_value(PRECISION); +mxParameter1Value->set_increments(1000, 1); +mxParameter1Value->set_min(1000); +mxParameter2Text->hide(); +mxParameter2Value->hide(); +break; +} } } diff --git a/sc/uiconfig/scalc/ui/randomn
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4-7' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 27 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 30 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawBeziers.emf |binary 3 files changed, 44 insertions(+), 13 deletions(-) New commits: commit cd94594b24c48602a1eef6af8d98cbf5a6467e3a Author: Bartosz Kosiorek AuthorDate: Sun Apr 23 01:37:20 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Apr 27 21:40:45 2023 +0200 tdf#154789 EMF+ Performance boost of the EmfPlusRecordTypeDrawBeziers There is several benefits of such performance optimization: 1. We are drawing single curve instead of hundreds of small curves. In the loop we are creating single Polygon and outside of the loop we are invoking EMFPPlusDrawPolygon drawing method only once. As https://bugs.documentfoundation.org/attachment.cgi?id=186725 image is using single EmfPlusRecordTypeDrawBeziers EMF+ record with hundreds of curves, with using single EMFPPlusDrawPolygon call, there is no lnger need for individual line creation (e.g. line color, weight, line caps, line joints, line dashes, etc.) - The PDF export performance without optimizations of the https://bugs.documentfoundation.org/attachment.cgi?id=186725: time ./instdir/program/soffice --headless --convert-to "pdf:writer_pdf_Export" --outdir ~ ~/Pobrane/problem.docx real 24m18,471s user 2m56,004s sys 1m37,816 - The PDF export performance with optimizations: real 0m37,527s user 0m37,004s sys 0m0,531s - With Libreoffice 7.5.2 from Ubuntu 22.04, the conversion was crashed. 2. The PDF export for document: https://bugs.documentfoundation.org/attachment.cgi?id=186725 was not working correctly for me. The original image is containing chart. Without optimization, the exported chart was empty. Current export is working correctly, and graph is visible. 3. The standard opening of the document from https://bugs.documentfoundation.org/attachment.cgi?id=186725 is now much faster. The zooming in, move image operations are also noticible faster. 4. Implementation is according to [MS-EMFPLUS] documentation of the EmfPlusDrawBeziers, which states: "The ending coordinate of one Bezier curve is the starting coordinate of the next. The control points are used for producing the Bezier effect." Change-Id: Ic77d4c20a462587bb5da4a4df757e30c5ca04fc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150821 Tested-by: Jenkins Reviewed-by: Noel Grandin Reviewed-by: Bartosz Kosiorek (cherry picked from commit ce008fa9d8f2752bdfeaeff763aafc774a4b4fb2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150789 Reviewed-by: Ilmari Lauhakangas Reviewed-by: Xisco Fauli (cherry picked from commit a30b9314fb011736ccd12c8d3d29514c172a5b17) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151029 Tested-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 542259568cd0..aaa9b1bf79d5 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1343,11 +1343,15 @@ namespace emfplushelper rMS.ReadUInt32(aCount); SAL_INFO("drawinglayer.emf", "EMF+\t DrawBeziers slot: " << (flags & 0xff)); SAL_INFO("drawinglayer.emf", "EMF+\t Number of points: " << aCount); -SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16..."); +SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", +"EMF+\t Bezier Draw not support number of points other than 4, 7, " +"10, 13, 16..."); if (aCount < 4) { -SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less than 4 points. Number of points: " << aCount); +SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less " + "than 4 points. Number of points: " + << aCount); break; } @@ -1355,29 +1359,26 @@ namespace emfplushelper // We ne
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/emfphelperdata.cxx | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) New commits: commit b79a5cdcf0b98fef4b5bfeb380efcea322e9a51a Author: Bartosz Kosiorek AuthorDate: Thu Apr 27 15:05:03 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Apr 27 21:17:15 2023 +0200 EMF+ tdf#103859 Optimize EmfPlusFillRects and EmfPlusDrawRects Change-Id: Iac96cf2d4291646fb69cc87c471d2f68ed905d69 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151102 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index a1e9b3b7adce..879d40b925d5 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1255,7 +1255,9 @@ namespace emfplushelper { // Silent MSVC warning C4701: potentially uninitialized local variable 'brushIndexOrColor' used sal_uInt32 brushIndexOrColor = 999; -sal_Int32 rectangles; +::basegfx::B2DPolyPolygon polyPolygon; +sal_uInt32 rectangles; +float x, y, width, height; const bool isColor = (flags & 0x8000); ::basegfx::B2DPolygon polygon; @@ -1270,11 +1272,9 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t DrawRects"); } -rMS.ReadInt32(rectangles); - -for (int i = 0; i < rectangles; i++) +rMS.ReadUInt32(rectangles); +for (sal_uInt32 i = 0; i < rectangles; i++) { -float x, y, width, height; ReadRectangle(rMS, x, y, width, height, bool(flags & 0x4000)); polygon.clear(); polygon.append(Map(x, y)); @@ -1284,13 +1284,12 @@ namespace emfplushelper polygon.setClosed(true); SAL_INFO("drawinglayer.emf", "EMF+\t\t rectangle: " << x << ", "<< y << " " << width << "x" << height); - -::basegfx::B2DPolyPolygon polyPolygon(polygon); -if (type == EmfPlusRecordTypeFillRects) -EMFPPlusFillPolygon(polyPolygon, isColor, brushIndexOrColor); -else -EMFPPlusDrawPolygon(polyPolygon, flags & 0xff); +polyPolygon.append(polygon); } +if (type == EmfPlusRecordTypeFillRects) +EMFPPlusFillPolygon(polyPolygon, isColor, brushIndexOrColor); +else +EMFPPlusDrawPolygon(polyPolygon, flags & 0xff); break; } case EmfPlusRecordTypeFillPolygon:
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 27 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 30 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawBeziers.emf |binary 3 files changed, 44 insertions(+), 13 deletions(-) New commits: commit 168dc9075d7be4d7da5f5e1ee602751f84dbd254 Author: Bartosz Kosiorek AuthorDate: Sun Apr 23 01:37:20 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Apr 27 09:22:25 2023 +0200 tdf#154789 EMF+ Performance boost of the EmfPlusRecordTypeDrawBeziers There is several benefits of such performance optimization: 1. We are drawing single curve instead of hundreds of small curves. In the loop we are creating single Polygon and outside of the loop we are invoking EMFPPlusDrawPolygon drawing method only once. As https://bugs.documentfoundation.org/attachment.cgi?id=186725 image is using single EmfPlusRecordTypeDrawBeziers EMF+ record with hundreds of curves, with using single EMFPPlusDrawPolygon call, there is no lnger need for individual line creation (e.g. line color, weight, line caps, line joints, line dashes, etc.) - The PDF export performance without optimizations of the https://bugs.documentfoundation.org/attachment.cgi?id=186725: time ./instdir/program/soffice --headless --convert-to "pdf:writer_pdf_Export" --outdir ~ ~/Pobrane/problem.docx real 24m18,471s user 2m56,004s sys 1m37,816 - The PDF export performance with optimizations: real 0m37,527s user 0m37,004s sys 0m0,531s - With Libreoffice 7.5.2 from Ubuntu 22.04, the conversion was crashed. 2. The PDF export for document: https://bugs.documentfoundation.org/attachment.cgi?id=186725 was not working correctly for me. The original image is containing chart. Without optimization, the exported chart was empty. Current export is working correctly, and graph is visible. 3. The standard opening of the document from https://bugs.documentfoundation.org/attachment.cgi?id=186725 is now much faster. The zooming in, move image operations are also noticible faster. 4. Implementation is according to [MS-EMFPLUS] documentation of the EmfPlusDrawBeziers, which states: "The ending coordinate of one Bezier curve is the starting coordinate of the next. The control points are used for producing the Bezier effect." Change-Id: Ic77d4c20a462587bb5da4a4df757e30c5ca04fc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150821 Tested-by: Jenkins Reviewed-by: Noel Grandin Reviewed-by: Bartosz Kosiorek (cherry picked from commit ce008fa9d8f2752bdfeaeff763aafc774a4b4fb2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150789 Reviewed-by: Ilmari Lauhakangas Reviewed-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 542259568cd0..aaa9b1bf79d5 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1343,11 +1343,15 @@ namespace emfplushelper rMS.ReadUInt32(aCount); SAL_INFO("drawinglayer.emf", "EMF+\t DrawBeziers slot: " << (flags & 0xff)); SAL_INFO("drawinglayer.emf", "EMF+\t Number of points: " << aCount); -SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16..."); +SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", +"EMF+\t Bezier Draw not support number of points other than 4, 7, " +"10, 13, 16..."); if (aCount < 4) { -SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less than 4 points. Number of points: " << aCount); +SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less " + "than 4 points. Number of points: " + << aCount); break; } @@ -1355,29 +1359,26 @@ namespace emfplushelper // We need to add first starting point aStartPoint = Map(x1, y1); aPolygon.append(aStartPoint); - +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5-3' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 27 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 30 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawBeziers.emf |binary 3 files changed, 44 insertions(+), 13 deletions(-) New commits: commit b1ed265975407aea9eda568049be4d68301276af Author: Bartosz Kosiorek AuthorDate: Sun Apr 23 01:37:20 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Apr 26 13:24:58 2023 +0200 tdf#154789 EMF+ Performance boost of the EmfPlusRecordTypeDrawBeziers There is several benefits of such performance optimization: 1. We are drawing single curve instead of hundreds of small curves. In the loop we are creating single Polygon and outside of the loop we are invoking EMFPPlusDrawPolygon drawing method only once. As https://bugs.documentfoundation.org/attachment.cgi?id=186725 image is using single EmfPlusRecordTypeDrawBeziers EMF+ record with hundreds of curves, with using single EMFPPlusDrawPolygon call, there is no lnger need for individual line creation (e.g. line color, weight, line caps, line joints, line dashes, etc.) - The PDF export performance without optimizations of the https://bugs.documentfoundation.org/attachment.cgi?id=186725: time ./instdir/program/soffice --headless --convert-to "pdf:writer_pdf_Export" --outdir ~ ~/Pobrane/problem.docx real 24m18,471s user 2m56,004s sys 1m37,816 - The PDF export performance with optimizations: real 0m37,527s user 0m37,004s sys 0m0,531s - With Libreoffice 7.5.2 from Ubuntu 22.04, the conversion was crashed. 2. The PDF export for document: https://bugs.documentfoundation.org/attachment.cgi?id=186725 was not working correctly for me. The original image is containing chart. Without optimization, the exported chart was empty. Current export is working correctly, and graph is visible. 3. The standard opening of the document from https://bugs.documentfoundation.org/attachment.cgi?id=186725 is now much faster. The zooming in, move image operations are also noticible faster. 4. Implementation is according to [MS-EMFPLUS] documentation of the EmfPlusDrawBeziers, which states: "The ending coordinate of one Bezier curve is the starting coordinate of the next. The control points are used for producing the Bezier effect." Change-Id: Ic77d4c20a462587bb5da4a4df757e30c5ca04fc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150821 Tested-by: Jenkins Reviewed-by: Noel Grandin Reviewed-by: Bartosz Kosiorek (cherry picked from commit ce008fa9d8f2752bdfeaeff763aafc774a4b4fb2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150788 Reviewed-by: Xisco Fauli (cherry picked from commit 1328e2b7eb5251162834d7c0f953c6334686e95e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150911 Tested-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index b8a3abb2bac1..94c4c32f026f 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1345,11 +1345,15 @@ namespace emfplushelper rMS.ReadUInt32(aCount); SAL_INFO("drawinglayer.emf", "EMF+\t DrawBeziers slot: " << (flags & 0xff)); SAL_INFO("drawinglayer.emf", "EMF+\t Number of points: " << aCount); -SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16..."); +SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", +"EMF+\t Bezier Draw not support number of points other than 4, 7, " +"10, 13, 16..."); if (aCount < 4) { -SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less than 4 points. Number of points: " << aCount); +SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less " + "than 4 points. Number of points: " + << aCount); break; } @@ -1357,29 +1361,26 @@ namespace emfplushelper // We need to add first starting point aStartPoint = Map(x
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 27 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 30 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawBeziers.emf |binary 3 files changed, 44 insertions(+), 13 deletions(-) New commits: commit 1328e2b7eb5251162834d7c0f953c6334686e95e Author: Bartosz Kosiorek AuthorDate: Sun Apr 23 01:37:20 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Apr 24 09:59:19 2023 +0200 tdf#154789 EMF+ Performance boost of the EmfPlusRecordTypeDrawBeziers There is several benefits of such performance optimization: 1. We are drawing single curve instead of hundreds of small curves. In the loop we are creating single Polygon and outside of the loop we are invoking EMFPPlusDrawPolygon drawing method only once. As https://bugs.documentfoundation.org/attachment.cgi?id=186725 image is using single EmfPlusRecordTypeDrawBeziers EMF+ record with hundreds of curves, with using single EMFPPlusDrawPolygon call, there is no lnger need for individual line creation (e.g. line color, weight, line caps, line joints, line dashes, etc.) - The PDF export performance without optimizations of the https://bugs.documentfoundation.org/attachment.cgi?id=186725: time ./instdir/program/soffice --headless --convert-to "pdf:writer_pdf_Export" --outdir ~ ~/Pobrane/problem.docx real 24m18,471s user 2m56,004s sys 1m37,816 - The PDF export performance with optimizations: real 0m37,527s user 0m37,004s sys 0m0,531s - With Libreoffice 7.5.2 from Ubuntu 22.04, the conversion was crashed. 2. The PDF export for document: https://bugs.documentfoundation.org/attachment.cgi?id=186725 was not working correctly for me. The original image is containing chart. Without optimization, the exported chart was empty. Current export is working correctly, and graph is visible. 3. The standard opening of the document from https://bugs.documentfoundation.org/attachment.cgi?id=186725 is now much faster. The zooming in, move image operations are also noticible faster. 4. Implementation is according to [MS-EMFPLUS] documentation of the EmfPlusDrawBeziers, which states: "The ending coordinate of one Bezier curve is the starting coordinate of the next. The control points are used for producing the Bezier effect." Change-Id: Ic77d4c20a462587bb5da4a4df757e30c5ca04fc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150821 Tested-by: Jenkins Reviewed-by: Noel Grandin Reviewed-by: Bartosz Kosiorek (cherry picked from commit ce008fa9d8f2752bdfeaeff763aafc774a4b4fb2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150788 Reviewed-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index b8a3abb2bac1..94c4c32f026f 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1345,11 +1345,15 @@ namespace emfplushelper rMS.ReadUInt32(aCount); SAL_INFO("drawinglayer.emf", "EMF+\t DrawBeziers slot: " << (flags & 0xff)); SAL_INFO("drawinglayer.emf", "EMF+\t Number of points: " << aCount); -SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16..."); +SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", +"EMF+\t Bezier Draw not support number of points other than 4, 7, " +"10, 13, 16..."); if (aCount < 4) { -SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less than 4 points. Number of points: " << aCount); +SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less " + "than 4 points. Number of points: " + << aCount); break; } @@ -1357,29 +1361,26 @@ namespace emfplushelper // We need to add first starting point aStartPoint = Map(x1, y1); aPolygon.append(aStartPoint); - +SAL_INFO("drawinglayer.emf", + "E
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/emfphelperdata.cxx | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) New commits: commit 12e23067fd0acad3e06df50cefaa0a2cd73df3b5 Author: Bartosz Kosiorek AuthorDate: Mon Apr 24 05:08:00 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Mon Apr 24 08:24:09 2023 +0200 EMF+ Minor optimization and clean up code of DrawBeziers Change-Id: Id560b3d3a6182270853fd05a6f2d1e44452c0013 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150894 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 94c4c32f026f..a1e9b3b7adce 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1340,7 +1340,6 @@ namespace emfplushelper { sal_uInt32 aCount; float x1, y1, x2, y2, x3, y3, x4, y4; -::basegfx::B2DPoint aStartPoint, aControlPointA, aControlPointB, aEndPoint; ::basegfx::B2DPolygon aPolygon; rMS.ReadUInt32(aCount); SAL_INFO("drawinglayer.emf", "EMF+\t DrawBeziers slot: " << (flags & 0xff)); @@ -1359,8 +1358,7 @@ namespace emfplushelper ReadPoint(rMS, x1, y1, flags); // We need to add first starting point -aStartPoint = Map(x1, y1); -aPolygon.append(aStartPoint); +aPolygon.append(Map(x1, y1)); SAL_INFO("drawinglayer.emf", "EMF+\t Bezier starting point: " << x1 << "," << y1); for (sal_uInt32 i = 4; i <= aCount; i += 3) @@ -1372,13 +1370,7 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t Bezier points: " << x2 << "," << y2 << " " << x3 << "," << y3 << " " << x4 << "," << y4); - -aControlPointA = Map(x2, y2); -aControlPointB = Map(x3, y3); -aEndPoint = Map(x4, y4); -aPolygon.appendBezierSegment(aControlPointA, aControlPointB, aEndPoint); -// The ending coordinate of one Bezier curve is the starting coordinate of the next. -aStartPoint = aEndPoint; +aPolygon.appendBezierSegment(Map(x2, y2), Map(x3, y3), Map(x4, y4)); } EMFPPlusDrawPolygon(::basegfx::B2DPolyPolygon(aPolygon), flags & 0xff); break;
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 27 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 28 +++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawBeziers.emf |binary 3 files changed, 42 insertions(+), 13 deletions(-) New commits: commit ce008fa9d8f2752bdfeaeff763aafc774a4b4fb2 Author: Bartosz Kosiorek AuthorDate: Sun Apr 23 01:37:20 2023 +0200 Commit: Bartosz Kosiorek CommitDate: Sun Apr 23 17:42:21 2023 +0200 tdf#154789 EMF+ Performance boost of the EmfPlusRecordTypeDrawBeziers There is several benefits of such performance optimization: 1. We are drawing single curve instead of hundreds of small curves. In the loop we are creating single Polygon and outside of the loop we are invoking EMFPPlusDrawPolygon drawing method only once. As https://bugs.documentfoundation.org/attachment.cgi?id=186725 image is using single EmfPlusRecordTypeDrawBeziers EMF+ record with hundreds of curves, with using single EMFPPlusDrawPolygon call, there is no lnger need for individual line creation (e.g. line color, weight, line caps, line joints, line dashes, etc.) - The PDF export performance without optimizations of the https://bugs.documentfoundation.org/attachment.cgi?id=186725: time ./instdir/program/soffice --headless --convert-to "pdf:writer_pdf_Export" --outdir ~ ~/Pobrane/problem.docx real 24m18,471s user 2m56,004s sys 1m37,816 - The PDF export performance with optimizations: real 0m37,527s user 0m37,004s sys 0m0,531s - With Libreoffice 7.5.2 from Ubuntu 22.04, the conversion was crashed. 2. The PDF export for document: https://bugs.documentfoundation.org/attachment.cgi?id=186725 was not working correctly for me. The original image is containing chart. Without optimization, the exported chart was empty. Current export is working correctly, and graph is visible. 3. The standard opening of the document from https://bugs.documentfoundation.org/attachment.cgi?id=186725 is now much faster. The zooming in, move image operations are also noticible faster. Change-Id: Ic77d4c20a462587bb5da4a4df757e30c5ca04fc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150821 Tested-by: Jenkins Reviewed-by: Noel Grandin Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index b8a3abb2bac1..94c4c32f026f 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1345,11 +1345,15 @@ namespace emfplushelper rMS.ReadUInt32(aCount); SAL_INFO("drawinglayer.emf", "EMF+\t DrawBeziers slot: " << (flags & 0xff)); SAL_INFO("drawinglayer.emf", "EMF+\t Number of points: " << aCount); -SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16..."); +SAL_WARN_IF((aCount - 1) % 3 != 0, "drawinglayer.emf", +"EMF+\t Bezier Draw not support number of points other than 4, 7, " +"10, 13, 16..."); if (aCount < 4) { -SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less than 4 points. Number of points: " << aCount); +SAL_WARN("drawinglayer.emf", "EMF+\t Bezier Draw does not support less " + "than 4 points. Number of points: " + << aCount); break; } @@ -1357,29 +1361,26 @@ namespace emfplushelper // We need to add first starting point aStartPoint = Map(x1, y1); aPolygon.append(aStartPoint); - +SAL_INFO("drawinglayer.emf", + "EMF+\t Bezier starting point: " << x1 << "," << y1); for (sal_uInt32 i = 4; i <= aCount; i += 3) { ReadPoint(rMS, x2, y2, flags); ReadPoint(rMS, x3, y3, flags); ReadPoint(rMS, x4, y4, flags); -SAL_INFO("drawinglayer.emf", "EMF+
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 45 ++--- emfio/source/reader/emfreader.cxx | 25 +++--- emfio/source/reader/mtftools.cxx |4 +- 3 files changed, 43 insertions(+), 31 deletions(-) New commits: commit 78ca5b0421562a6204a561d390ac8a8692411421 Author: Bartosz Kosiorek AuthorDate: Fri Feb 3 22:55:54 2023 +0100 Commit: Xisco Fauli CommitDate: Mon Feb 13 10:43:47 2023 + tdf#142018 Properly create Pen width if style is COSMETIC Change-Id: I6453058c4af352a3b0e14cbccbc1a67c73cd1426 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146551 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit bbdbe8ea2ef176ef6f08b30b3c18876c2c4f0c22) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146808 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 75f2b9001a08..e858fd7afc4d 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -180,14 +180,19 @@ void Test::testPolyPolygon() assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 116); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 44); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - "2574,13194 2574,1129 17877,1129 17877,13194"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff"); - + "2574,13194 2574,1129"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "0"); +assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", + "2574,1129 2574,1129"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", - "8674,13194 8674,1129"); + "8674,1129 8674,1129"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "width", "0"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 28); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[6]", "width", "459"); @@ -1547,7 +1552,7 @@ void Test::TestRoundRect() void Test::TestCreatePen() { // Check import of EMF image with records: RESTOREDC, SAVEDC, MOVETOEX, LINETO, POLYLINE16, EXTTEXTOUTW with DxBuffer -// The CREATEPEN record is used with PS_COSMETIC line style, which sometimes will be displayed as solid hairline +// The CREATEPEN record is used with PS_COSMETIC line style, and in this case width must be set to 0 Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestCreatePen.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -1556,29 +1561,29 @@ void Test::TestCreatePen() assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h31250v18192h-31250z"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 748); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 3); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - "27875,16523 27875,1453"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "6"); + "17898,5693 20172,5693"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#008000"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", - "27975,16453 27875,16453&
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 45 ++--- emfio/source/reader/emfreader.cxx | 25 +++--- emfio/source/reader/mtftools.cxx |4 +- 3 files changed, 43 insertions(+), 31 deletions(-) New commits: commit bbdbe8ea2ef176ef6f08b30b3c18876c2c4f0c22 Author: Bartosz Kosiorek AuthorDate: Fri Feb 3 22:55:54 2023 +0100 Commit: Bartosz Kosiorek CommitDate: Sat Feb 11 21:24:18 2023 + tdf#142018 Properly create Pen width if style is COSMETIC Change-Id: I6453058c4af352a3b0e14cbccbc1a67c73cd1426 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146551 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 75f2b9001a08..e858fd7afc4d 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -180,14 +180,19 @@ void Test::testPolyPolygon() assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 116); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 44); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - "2574,13194 2574,1129 17877,1129 17877,13194"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff"); - + "2574,13194 2574,1129"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "0"); +assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", + "2574,1129 2574,1129"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", - "8674,13194 8674,1129"); + "8674,1129 8674,1129"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "width", "0"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 28); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[6]", "width", "459"); @@ -1547,7 +1552,7 @@ void Test::TestRoundRect() void Test::TestCreatePen() { // Check import of EMF image with records: RESTOREDC, SAVEDC, MOVETOEX, LINETO, POLYLINE16, EXTTEXTOUTW with DxBuffer -// The CREATEPEN record is used with PS_COSMETIC line style, which sometimes will be displayed as solid hairline +// The CREATEPEN record is used with PS_COSMETIC line style, and in this case width must be set to 0 Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestCreatePen.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -1556,29 +1561,29 @@ void Test::TestCreatePen() assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h31250v18192h-31250z"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 748); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 3); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - "27875,16523 27875,1453"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "6"); + "17898,5693 20172,5693"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#008000"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", - "27975,16453 27875,16453"); -assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", "#ff"); -assertXPath(pDocument, aX
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - lotuswordpro/qa lotuswordpro/source
lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp |binary lotuswordpro/qa/cppunit/import_test.cxx | 102 ++ lotuswordpro/source/filter/lwpbulletstylemgr.cxx | 20 +- 3 files changed, 114 insertions(+), 8 deletions(-) New commits: commit 55a360860e9c5c608326656a7cf56a0b86f2f7c7 Author: Bartosz Kosiorek AuthorDate: Fri Jul 15 22:46:03 2022 +0200 Commit: Xisco Fauli CommitDate: Tue Jul 26 14:58:04 2022 +0200 tdf33787 lotuswordpro: fix increments of ordered bullets With previous implementation there was an bug which causing missing incrementing ordered bullets. For example: A. Lettered bullet uppercase 1 (A. ) A. Lettered bullet uppercase 2 (B. ) A. Lettered bullet uppercase 3 (C. ) This patch is fixing that, and increments is working correctly: A. Lettered bullet uppercase 1 (A. ) B. Lettered bullet uppercase 2 (B. ) C. Lettered bullet uppercase 3 (C. ) It is also make sure that nested and skipped bullets are working correctly: 1) Numbered bullet w/ bracket one (1) ) Skipped bullet 2) Numbered bullet w/ bracket two (2) ) a) Lettered bullet w/ bracket lowercase 1 (a) ) b) Lettered bullet w/ bracket lowercase 2 (b) ) Change-Id: I1d1ad9ee549039077b418756efefb10bacfa1ddd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137112 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit a0bcd1d187a4e56a9fa600462842004545b6be9c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137423 Reviewed-by: Xisco Fauli diff --git a/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp new file mode 100644 index ..12febcd60d55 Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp differ diff --git a/lotuswordpro/qa/cppunit/import_test.cxx b/lotuswordpro/qa/cppunit/import_test.cxx index fe2128f72ab5..7411a16ab8bd 100644 --- a/lotuswordpro/qa/cppunit/import_test.cxx +++ b/lotuswordpro/qa/cppunit/import_test.cxx @@ -53,6 +53,108 @@ void LotusWordProTest::tearDown() constexpr OUStringLiteral DATA_DIRECTORY = u"/lotuswordpro/qa/cppunit/data/"; +CPPUNIT_TEST_FIXTURE(LotusWordProTest, testtdf33787OrderedBullets) +{ +// Test if ordered bullets are incrementing correclty: +// A. Lettered bullet uppercase 1 (A.) +// B. Lettered bullet uppercase 2 (B.) +// C. Lettered bullet uppercase 3 (C.) +// It is also make sure that nested and skipped bullets are working correctly: +// 1) Numbered bullet w/ bracket one (1)) +//Skipped bullet +// 2) Numbered bullet w/ bracket two (2)) +// a) Lettered bullet w/ bracket lowercase 1 (a)) +// b) Lettered bullet w/ bracket lowercase 2 (b)) +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf33787-ordered-bullets.lwp"; +getComponent() = loadFromDesktop(aURL); +uno::Reference textDocument(getComponent(), uno::UNO_QUERY); +uno::Reference xParaEnumAccess(textDocument->getText(), + uno::UNO_QUERY); +uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); + +uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); +OUString aListLabelString; +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Make sure the list start from 1. +CPPUNIT_ASSERT_EQUAL(OUString("1."), aListLabelString); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Without the accompanying fix in place, this test would have failed, the list label was "1.". +CPPUNIT_ASSERT_EQUAL(OUString("2."), aListLabelString); + +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Without the accompanying fix in place, this test would have failed, the list label was "1.". +CPPUNIT_ASSERT_EQUAL(OUString("3."), aListLabelString); + +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Make sure the list start from i. +CPPUNIT_ASSERT_EQUAL(OUString("i."), aListLabelString); + +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Without the accompanying fix in place, this t
[Libreoffice-commits] core.git: lotuswordpro/qa lotuswordpro/source
lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp |binary lotuswordpro/qa/cppunit/import_test.cxx | 102 ++ lotuswordpro/source/filter/lwpbulletstylemgr.cxx | 20 +- 3 files changed, 114 insertions(+), 8 deletions(-) New commits: commit a0bcd1d187a4e56a9fa600462842004545b6be9c Author: Bartosz Kosiorek AuthorDate: Fri Jul 15 22:46:03 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Jul 21 09:11:31 2022 +0200 tdf33787 lotuswordpro: fix increments of ordered bullets With previous implementation there was an bug which causing missing incrementing ordered bullets. For example: A. Lettered bullet uppercase 1 (A. ) A. Lettered bullet uppercase 2 (B. ) A. Lettered bullet uppercase 3 (C. ) This patch is fixing that, and increments is working correctly: A. Lettered bullet uppercase 1 (A. ) B. Lettered bullet uppercase 2 (B. ) C. Lettered bullet uppercase 3 (C. ) It is also make sure that nested and skipped bullets are working correctly: 1) Numbered bullet w/ bracket one (1) ) Skipped bullet 2) Numbered bullet w/ bracket two (2) ) a) Lettered bullet w/ bracket lowercase 1 (a) ) b) Lettered bullet w/ bracket lowercase 2 (b) ) Change-Id: I1d1ad9ee549039077b418756efefb10bacfa1ddd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137112 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp new file mode 100644 index ..12febcd60d55 Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp differ diff --git a/lotuswordpro/qa/cppunit/import_test.cxx b/lotuswordpro/qa/cppunit/import_test.cxx index fe2128f72ab5..7411a16ab8bd 100644 --- a/lotuswordpro/qa/cppunit/import_test.cxx +++ b/lotuswordpro/qa/cppunit/import_test.cxx @@ -53,6 +53,108 @@ void LotusWordProTest::tearDown() constexpr OUStringLiteral DATA_DIRECTORY = u"/lotuswordpro/qa/cppunit/data/"; +CPPUNIT_TEST_FIXTURE(LotusWordProTest, testtdf33787OrderedBullets) +{ +// Test if ordered bullets are incrementing correclty: +// A. Lettered bullet uppercase 1 (A.) +// B. Lettered bullet uppercase 2 (B.) +// C. Lettered bullet uppercase 3 (C.) +// It is also make sure that nested and skipped bullets are working correctly: +// 1) Numbered bullet w/ bracket one (1)) +//Skipped bullet +// 2) Numbered bullet w/ bracket two (2)) +// a) Lettered bullet w/ bracket lowercase 1 (a)) +// b) Lettered bullet w/ bracket lowercase 2 (b)) +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf33787-ordered-bullets.lwp"; +getComponent() = loadFromDesktop(aURL); +uno::Reference textDocument(getComponent(), uno::UNO_QUERY); +uno::Reference xParaEnumAccess(textDocument->getText(), + uno::UNO_QUERY); +uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); + +uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); +OUString aListLabelString; +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Make sure the list start from 1. +CPPUNIT_ASSERT_EQUAL(OUString("1."), aListLabelString); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Without the accompanying fix in place, this test would have failed, the list label was "1.". +CPPUNIT_ASSERT_EQUAL(OUString("2."), aListLabelString); + +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Without the accompanying fix in place, this test would have failed, the list label was "1.". +CPPUNIT_ASSERT_EQUAL(OUString("3."), aListLabelString); + +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Make sure the list start from i. +CPPUNIT_ASSERT_EQUAL(OUString("i."), aListLabelString); + +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +xPara->getPropertyValue("ListLabelString") >>= aListLabelString; +// Without the accompanying fix in place, this test would have failed, the list label was "i.". +CPPUNIT_ASSERT_EQUAL(OUString("ii."), aListLabelString); + +xP
[Libreoffice-commits] core.git: lotuswordpro/README.md lotuswordpro/source
lotuswordpro/README.md | 20 lotuswordpro/source/filter/LotusWordProImportFilter.cxx |6 ++-- lotuswordpro/source/filter/lwp9reader.cxx |5 3 files changed, 19 insertions(+), 12 deletions(-) New commits: commit 7bb911d11813136935ac8a0bbe6dcbe211a24853 Author: Bartosz Kosiorek AuthorDate: Thu Jul 14 00:22:06 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Jul 14 10:32:23 2022 +0200 tdf#112626 lotuswordpro: switch to constexpr and update documentation Change-Id: I566c22285978f7b31961d105d02d99d0696908b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137041 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/lotuswordpro/README.md b/lotuswordpro/README.md index fc58c3fe439c..5642c6de157d 100644 --- a/lotuswordpro/README.md +++ b/lotuswordpro/README.md @@ -2,20 +2,22 @@ ## Description -The import is not direct, but via an intermediate format: StarOffice -XML, the predecessor of ODF (yes, the code is old). The entry point to -the filter is class LotusWordProImportFilter (refer to Source code +> :warning: **Import Filter supports only Lotus Word Pro 97 and next versions** + +The import is not direct, but via an intermediate format: [StarOffice XML](http://xml.openoffice.org/xml_specification_draft.pdf), +the predecessor of ODF (yes, the code is old). The entry point to +the filter is class `LotusWordProImportFilter` (refer to Source code section), but that just hooks up the necessary machinery for processing StarOffice XML produced by the filter. The real fun starts in function `ReadWordproFile()` (`source/filter/lwpfilter.cxx`); this function -initializes the parser (class `Lwp9Reader`) and the SAX XML handler that -produces the output (class `XFSaxStream`). The Lwp9Reader class then does +initializes the parser (class `Lwp9Reader`) and the [SAX XML](https://en.wikipedia.org/wiki/Simple_API_for_XML) handler that +produces the output (class `XFSaxStream`). The `Lwp9Reader` class then does the actual parsing. -If the module is built with debug level greater than 0, it is possible -to examine the intermediate XML: set environment variable -`DBG_LWPIMPORT_DIR=` to an existing directory and, on opening an lwp -document, a file named `lwpimport.xml` will be created in that directory. +If the module is built with debug level greater than `0`, it is possible +to examine the intermediate XML: set [environment variable](https://en.wikipedia.org/wiki/Environment_variable) +`DBG_LWPIMPORT_DIR=` to an existing directory. During opening an `.lwp` +document, a file named `lwpimport.xml` will be created in `DBG_LWPIMPORT_DIR` directory. ## Source Code diff --git a/lotuswordpro/source/filter/LotusWordProImportFilter.cxx b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx index d85e8c700d92..50211fd929c7 100644 --- a/lotuswordpro/source/filter/LotusWordProImportFilter.cxx +++ b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx @@ -149,8 +149,8 @@ private: } #endif -// W o r d P r o -const sal_Int8 header[] = { 0x57, 0x6f, 0x72, 0x64, 0x50, 0x72, 0x6f }; +//W o r d P r o +constexpr sal_Int8 header[] = { 0x57, 0x6f, 0x72, 0x64, 0x50, 0x72, 0x6f }; bool LotusWordProImportFilter::importImpl( const Sequence< css::beans::PropertyValue >& aDescriptor ) { @@ -255,7 +255,7 @@ OUString SAL_CALL LotusWordProImportFilter::detect( css::uno::Sequence< Property } Sequence< ::sal_Int8 > aData; -sal_Int32 nLen = SAL_N_ELEMENTS( header ); +constexpr sal_Int32 nLen = SAL_N_ELEMENTS( header ); if ( ( nLen != xInputStream->readBytes( aData, nLen ) ) || ( memcmp( static_cast(header), static_cast(aData.getConstArray()), nLen ) != 0 ) ) sTypeName.clear(); diff --git a/lotuswordpro/source/filter/lwp9reader.cxx b/lotuswordpro/source/filter/lwp9reader.cxx index 7340adb042b2..dfcadf541fad 100644 --- a/lotuswordpro/source/filter/lwp9reader.cxx +++ b/lotuswordpro/source/filter/lwp9reader.cxx @@ -62,6 +62,7 @@ #include #include #include +#include Lwp9Reader::Lwp9Reader(LwpSvStream* pInputStream, IXFStream* pStream) : m_pDocStream(pInputStream) @@ -88,7 +89,11 @@ bool Lwp9Reader::Read() bRet = ParseDocument(); } else +{ +SAL_WARN("lwp", "Only Lotus Word Pro 97 (version 11) and later is supported."); +SAL_WARN("lwp", "You are trying to open version: " << LwpFileHeader::m_nFileRevision); bRet = false; +} } catch (...) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfpcustomlinecap.cxx| 26 +- drawinglayer/source/tools/emfpcustomlinecap.hxx|2 drawinglayer/source/tools/emfphelperdata.cxx | 113 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 26 ++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawPathWithCustomCap.emf |binary 5 files changed, 61 insertions(+), 106 deletions(-) New commits: commit ba806269c998b96842bcf0986095f22ab99a686a Author: Bartosz Kosiorek AuthorDate: Thu Jun 16 02:47:23 2022 +0200 Commit: Xisco Fauli CommitDate: Mon Jun 27 16:40:26 2022 +0200 tdf#142770 tdf#143031 EMF+ Implement CustomLineCap Change-Id: I9fae1d259ecdca37a1babac8a8a0e503b2dc0118 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135960 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 5b21b65572610df88986e700b81f1156aff14f65) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136463 Reviewed-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfpcustomlinecap.cxx b/drawinglayer/source/tools/emfpcustomlinecap.cxx index 49cc912ed33c..e457a36cc2c4 100644 --- a/drawinglayer/source/tools/emfpcustomlinecap.cxx +++ b/drawinglayer/source/tools/emfpcustomlinecap.cxx @@ -21,6 +21,7 @@ #include "emfpcustomlinecap.hxx" #include "emfppath.hxx" #include "emfppen.hxx" +#include using namespace ::com::sun::star; using namespace ::basegfx; @@ -39,6 +40,7 @@ namespace emfplushelper , strokeEndCap(0) , strokeJoin(0) , miterLimit(0.0) +, widthScale(0.0) , mbIsFilled(false) { } @@ -57,6 +59,8 @@ namespace emfplushelper EMFPPath path(pathPoints); path.Read(s, pathFlags); polygon = path.GetPolygon(rR, false); +// rotate polygon by 180 degrees +polygon.transform(basegfx::utils::createRotateB2DHomMatrix(M_PI)); mbIsFilled = bFill; } @@ -71,7 +75,6 @@ namespace emfplushelper { sal_uInt32 customLineCapDataFlags, baseCap; float baseInset; -float widthScale; float fillHotSpotX, fillHotSpotY, strokeHotSpotX, strokeHotSpotY; s.ReadUInt32(customLineCapDataFlags).ReadUInt32(baseCap).ReadFloat(baseInset) @@ -82,11 +85,6 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex << customLineCapDataFlags); SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseCap: 0x" << std::hex << baseCap); SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseInset: " << baseInset); -SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap); -SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap); -SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeJoin: 0x" << std::hex << strokeJoin); -SAL_INFO("drawinglayer.emf", "EMF+\t\tmiterLimit: " << miterLimit); -SAL_INFO("drawinglayer.emf", "EMF+\t\twidthScale: " << widthScale); if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath) { @@ -103,16 +101,20 @@ namespace emfplushelper // TODO only reads the data, does not use them [I've had // no test document to be able to implement it] -sal_Int32 width, height, middleInset, fillState, lineStartCap; -sal_Int32 lineEndCap, lineJoin, widthScale; -float fillHotSpotX, fillHotSpotY, lineHotSpotX, lineHotSpotY; +sal_Int32 fillState; +float width, height, middleInset, unusedHotSpot; - s.ReadInt32(width).ReadInt32(height).ReadInt32(middleInset).ReadInt32(fillState).ReadInt32(lineStartCap) - .ReadInt32(lineEndCap).ReadInt32(lineJoin).ReadFloat(miterLimit).ReadInt32(widthScale) - .ReadFloat(fillHotSpotX).ReadFloat(fillHotSpotY).ReadFloat(lineHotSpotX).ReadFloat(lineHotSpotY); + s.ReadFloat(width).ReadFloat(height).ReadFloat(middleInset).ReadInt32(fillState).ReadUInt32(strokeStartCap) + .ReadUInt32(strokeEndCap).ReadUInt32(strokeJoin).ReadFloat(miterLimit).ReadFloat(widthScale) + .ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot); SAL_INFO("drawinglayer.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)"); } +SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap); +SAL_INFO("drawinglay
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfpcustomlinecap.cxx| 26 +- drawinglayer/source/tools/emfpcustomlinecap.hxx|2 drawinglayer/source/tools/emfphelperdata.cxx | 113 +- emfio/qa/cppunit/emf/EmfImportTest.cxx | 26 ++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawPathWithCustomCap.emf |binary 5 files changed, 61 insertions(+), 106 deletions(-) New commits: commit 5b21b65572610df88986e700b81f1156aff14f65 Author: Bartosz Kosiorek AuthorDate: Thu Jun 16 02:47:23 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Mon Jun 27 10:24:13 2022 +0200 tdf#142770 tdf#143031 EMF+ Implement CustomLineCap Change-Id: I9fae1d259ecdca37a1babac8a8a0e503b2dc0118 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135960 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfpcustomlinecap.cxx b/drawinglayer/source/tools/emfpcustomlinecap.cxx index 49cc912ed33c..e457a36cc2c4 100644 --- a/drawinglayer/source/tools/emfpcustomlinecap.cxx +++ b/drawinglayer/source/tools/emfpcustomlinecap.cxx @@ -21,6 +21,7 @@ #include "emfpcustomlinecap.hxx" #include "emfppath.hxx" #include "emfppen.hxx" +#include using namespace ::com::sun::star; using namespace ::basegfx; @@ -39,6 +40,7 @@ namespace emfplushelper , strokeEndCap(0) , strokeJoin(0) , miterLimit(0.0) +, widthScale(0.0) , mbIsFilled(false) { } @@ -57,6 +59,8 @@ namespace emfplushelper EMFPPath path(pathPoints); path.Read(s, pathFlags); polygon = path.GetPolygon(rR, false); +// rotate polygon by 180 degrees +polygon.transform(basegfx::utils::createRotateB2DHomMatrix(M_PI)); mbIsFilled = bFill; } @@ -71,7 +75,6 @@ namespace emfplushelper { sal_uInt32 customLineCapDataFlags, baseCap; float baseInset; -float widthScale; float fillHotSpotX, fillHotSpotY, strokeHotSpotX, strokeHotSpotY; s.ReadUInt32(customLineCapDataFlags).ReadUInt32(baseCap).ReadFloat(baseInset) @@ -82,11 +85,6 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex << customLineCapDataFlags); SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseCap: 0x" << std::hex << baseCap); SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseInset: " << baseInset); -SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap); -SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap); -SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeJoin: 0x" << std::hex << strokeJoin); -SAL_INFO("drawinglayer.emf", "EMF+\t\tmiterLimit: " << miterLimit); -SAL_INFO("drawinglayer.emf", "EMF+\t\twidthScale: " << widthScale); if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath) { @@ -103,16 +101,20 @@ namespace emfplushelper // TODO only reads the data, does not use them [I've had // no test document to be able to implement it] -sal_Int32 width, height, middleInset, fillState, lineStartCap; -sal_Int32 lineEndCap, lineJoin, widthScale; -float fillHotSpotX, fillHotSpotY, lineHotSpotX, lineHotSpotY; +sal_Int32 fillState; +float width, height, middleInset, unusedHotSpot; - s.ReadInt32(width).ReadInt32(height).ReadInt32(middleInset).ReadInt32(fillState).ReadInt32(lineStartCap) - .ReadInt32(lineEndCap).ReadInt32(lineJoin).ReadFloat(miterLimit).ReadInt32(widthScale) - .ReadFloat(fillHotSpotX).ReadFloat(fillHotSpotY).ReadFloat(lineHotSpotX).ReadFloat(lineHotSpotY); + s.ReadFloat(width).ReadFloat(height).ReadFloat(middleInset).ReadInt32(fillState).ReadUInt32(strokeStartCap) + .ReadUInt32(strokeEndCap).ReadUInt32(strokeJoin).ReadFloat(miterLimit).ReadFloat(widthScale) + .ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot); SAL_INFO("drawinglayer.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)"); } +SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap); +SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap); +SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeJoin
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - drawinglayer/source emfio/qa svgio/qa
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() -
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - drawinglayer/source emfio/qa svgio/qa
drawinglayer/source/tools/emfpbrush.cxx | 12 ++ drawinglayer/source/tools/emfphelperdata.cxx | 55 ++ drawinglayer/source/tools/primitive2dxmldump.cxx | 42 ++- emfio/qa/cppunit/emf/EmfImportTest.cxx| 23 emfio/qa/cppunit/emf/data/TestEmfPlusBrushPathGradientWithBlendColors.emf |binary svgio/qa/cppunit/SvgImportTest.cxx| 14 ++ 6 files changed, 98 insertions(+), 48 deletions(-) New commits: commit a1d4093bf44058c1d956717404817cb82a830521 Author: Bartosz Kosiorek AuthorDate: Sun Jun 12 21:51:52 2022 +0200 Commit: Xisco Fauli CommitDate: Wed Jun 15 06:29:19 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 diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx index 7d6204a5da9e..c79b0ded0748 100644 --- a/drawinglayer/source/tools/emfpbrush.cxx +++ b/drawinglayer/source/tools/emfpbrush.cxx @@ -182,6 +182,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) // BrushDataBlendFactorsH { s.ReadUInt32(blendPoints); @@ -250,6 +256,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) // BrushDataBlendFactorsH { diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index d76e8f358c9d..94a50fc05cea 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -880,21 +880,12 @@ namespace emfplushelper // store the blendpoints in the vector for (sal_uInt32 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(aS
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa svgio/qa
drawinglayer/source/tools/emfpbrush.cxx | 12 ++ drawinglayer/source/tools/emfphelperdata.cxx | 55 ++ drawinglayer/source/tools/primitive2dxmldump.cxx | 42 ++- emfio/qa/cppunit/emf/EmfImportTest.cxx| 23 emfio/qa/cppunit/emf/data/TestEmfPlusBrushPathGradientWithBlendColors.emf |binary svgio/qa/cppunit/SvgImportTest.cxx| 14 ++ 6 files changed, 98 insertions(+), 48 deletions(-) New commits: commit 7b12c659842eb53b96dd98ecea65c6071506dfbb Author: Bartosz Kosiorek AuthorDate: Sun Jun 12 21:51:52 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jun 14 10:30:32 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 diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx index 7d6204a5da9e..c79b0ded0748 100644 --- a/drawinglayer/source/tools/emfpbrush.cxx +++ b/drawinglayer/source/tools/emfpbrush.cxx @@ -182,6 +182,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) // BrushDataBlendFactorsH { s.ReadUInt32(blendPoints); @@ -250,6 +256,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) // BrushDataBlendFactorsH { diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index d76e8f358c9d..94a50fc05cea 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -880,21 +880,12 @@ namespace emfplushelper // store the blendpoints in the vector for (sal_uInt32 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())); +aColor.setBlue (aStartColor.g
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/emfphelperdata.cxx |2 drawinglayer/source/tools/emfppen.cxx| 100 --- drawinglayer/source/tools/emfppen.hxx|3 3 files changed, 33 insertions(+), 72 deletions(-) New commits: commit 3d077ff9327ba591cbe2c663b0e93706857b6133 Author: Bartosz Kosiorek AuthorDate: Wed May 11 18:04:48 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Mon May 16 17:27:24 2022 +0200 EMF+ Simplify and optimize the code Change-Id: Iae7e83253cfe7c0545d2381d83a2e69cb4b80e5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134376 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 231e86e7c767..d76e8f358c9d 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -597,7 +597,7 @@ namespace emfplushelper const double transformedPenWidth = mdExtractedYScale * pen->penWidth; drawinglayer::attribute::LineAttribute lineAttribute( -pen->GetColor().getBColor(), transformedPenWidth, pen->GetLineJoinType(), +pen->GetColor().getBColor(), transformedPenWidth, pen->maLineJoin, css::drawing::LineCap_BUTT, //TODO implement PenDataDashedLineCap support here pen->fMiterMinimumAngle); diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx index ec073d56ea59..adfee3bd3706 100644 --- a/drawinglayer/source/tools/emfppen.cxx +++ b/drawinglayer/source/tools/emfppen.cxx @@ -30,26 +30,6 @@ using namespace ::basegfx; namespace emfplushelper { -namespace { - -enum EmfPlusPenData -{ -PenDataTransform= 0x0001, -PenDataStartCap = 0x0002, -PenDataEndCap = 0x0004, -PenDataJoin = 0x0008, -PenDataMiterLimit = 0x0010, -PenDataLineStyle= 0x0020, -PenDataDashedLineCap= 0x0040, -PenDataDashedLineOffset = 0x0080, -PenDataDashedLine = 0x0100, -PenDataAlignment= 0x0200, -PenDataCompoundLine = 0x0400, -PenDataCustomStartCap = 0x0800, -PenDataCustomEndCap = 0x1000 -}; - -} EMFPPen::EMFPPen() : penDataFlags(0) @@ -57,7 +37,7 @@ namespace emfplushelper , penWidth(0.0) , startCap(0) , endCap(0) -, lineJoin(0) +, maLineJoin(basegfx::B2DLineJoin::Miter) , fMiterMinimumAngle(basegfx::deg2rad(5.0)) , dashStyle(0) , dashCap(0) @@ -137,18 +117,6 @@ namespace emfplushelper return ""; } -static OUString LineJoinTypeToString(sal_uInt32 jointype) -{ -switch (jointype) -{ -case LineJoinTypeMiter: return "LineJoinTypeMiter"; -case LineJoinTypeBevel: return "LineJoinTypeBevel"; -case LineJoinTypeRound: return "LineJoinTypeRound"; -case LineJoinTypeMiterClipped: return "LineJoinTypeMiterClipped"; -} -return ""; -} - static OUString DashedLineCapTypeToString(sal_uInt32 dashedlinecaptype) { switch (dashedlinecaptype) @@ -173,25 +141,6 @@ namespace emfplushelper return ""; } -basegfx::B2DLineJoin EMFPPen::GetLineJoinType() const -{ -if (penDataFlags & EmfPlusPenDataJoin) // additional line join information -{ -switch (lineJoin) -{ -case EmfPlusLineJoinTypeMiter: // fall-through -case EmfPlusLineJoinTypeMiterClipped: -return basegfx::B2DLineJoin::Miter; -case EmfPlusLineJoinTypeBevel: -return basegfx::B2DLineJoin::Bevel; -case EmfPlusLineJoinTypeRound: -return basegfx::B2DLineJoin::Round; -} -} -// If nothing set, then miter applied with no limit -return basegfx::B2DLineJoin::Miter; -} - drawinglayer::attribute::StrokeAttribute EMFPPen::GetStrokeAttribute(const double aTransformation) const { @@ -233,6 +182,7 @@ namespace emfplushelper void EMFPPen::Read(SvStream& s, EmfPlusHelperData const & rR) { +sal_Int32 lineJoin = EmfPlusLineJoinTypeMiter; sal_uInt32 graphicsVersion, penType; s.ReadUInt32(graphicsVersion).ReadUInt32(penType).ReadUInt32(penDataFlags).ReadUInt32(penUnit).ReadFloat(penWidth); SAL_INFO("drawinglayer.emf", "EMF+\t\tGraphics version: 0x" << std::hex << graphicsVersion); @@ -248,13 +198,13 @@ namespace emfplushelper : 0.05f; // 0.05f is taken from old EMF+ implementation (case o
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 64 +++ drawinglayer/source/tools/emfphelperdata.hxx |4 emfio/qa/cppunit/emf/EmfImportTest.cxx | 48 +++ emfio/qa/cppunit/emf/data/TestEmfPlusFillClosedCurve.emf |binary 4 files changed, 98 insertions(+), 18 deletions(-) New commits: commit 2156c1090d318b4d28bc14537754bea73507d501 Author: Bartosz Kosiorek AuthorDate: Sun May 15 00:09:44 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Mon May 16 17:26:20 2022 +0200 tdf#143876 EMF+ Add DrawClosedCurve and FillClosedCurve support With this commit EmfPlusDrawClosedCurve and EmfPlusFillClosedCurve support was added. There is still missing Filling Mode (it is always set to Even Odd Alternate: https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule ) and Tension support for spline bends. The graphics is displayed as Tension=0. A value of Tension=0 specifies that the spline is a sequence of straight lines. As the value increases, the curve becomes more rounded. For more information, see [SPLINE77] and [PETZOLD]. Change-Id: Ibccfd584e3d55cd0ca8a29da9f450916d56705d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134333 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 0734dad6d6ea..231e86e7c767 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -80,6 +80,7 @@ namespace emfplushelper case EmfPlusRecordTypeDrawRects: return "EmfPlusRecordTypeDrawRects"; case EmfPlusRecordTypeFillPolygon: return "EmfPlusRecordTypeFillPolygon"; case EmfPlusRecordTypeDrawLines: return "EmfPlusRecordTypeDrawLines"; +case EmfPlusRecordTypeFillClosedCurve: return "EmfPlusRecordTypeFillClosedCurve"; case EmfPlusRecordTypeFillEllipse: return "EmfPlusRecordTypeFillEllipse"; case EmfPlusRecordTypeDrawEllipse: return "EmfPlusRecordTypeDrawEllipse"; case EmfPlusRecordTypeFillPie: return "EmfPlusRecordTypeFillPie"; @@ -89,6 +90,7 @@ namespace emfplushelper case EmfPlusRecordTypeFillPath: return "EmfPlusRecordTypeFillPath"; case EmfPlusRecordTypeDrawPath: return "EmfPlusRecordTypeDrawPath"; case EmfPlusRecordTypeDrawBeziers: return "EmfPlusRecordTypeDrawBeziers"; +case EmfPlusRecordTypeDrawClosedCurve: return "EmfPlusRecordTypeDrawClosedCurve"; case EmfPlusRecordTypeDrawImage: return "EmfPlusRecordTypeDrawImage"; case EmfPlusRecordTypeDrawImagePoints: return "EmfPlusRecordTypeDrawImagePoints"; case EmfPlusRecordTypeDrawString: return "EmfPlusRecordTypeDrawString"; @@ -610,8 +612,11 @@ namespace emfplushelper if (pen->GetColor().IsTransparent()) { drawinglayer::primitive2d::Primitive2DContainer aContainer; -if ((pen->penDataFlags & EmfPlusPenDataStartCap) -|| (pen->penDataFlags & EmfPlusPenDataEndCap)) +if (aStart.isDefault() && aEnd.isDefault()) + aContainer.append(drawinglayer::primitive2d::Primitive2DReference( +new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( +polygon, lineAttribute, pen->GetStrokeAttribute(mdExtractedXScale; +else { aContainer.resize(polygon.count()); for (sal_uInt32 i = 0; i < polygon.count(); i++) @@ -620,18 +625,17 @@ namespace emfplushelper polygon.getB2DPolygon(i), lineAttribute, pen->GetStrokeAttribute(mdExtractedXScale), aStart, aEnd)); } -else - aContainer.append(drawinglayer::primitive2d::Primitive2DReference( -new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( -polygon, lineAttribute, pen->GetStrokeAttribute(mdExtractedXScale; mrTargetHolders.Current().append( new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( std::move(aContainer), (255 - pen->GetColor().GetAlpha()) / 255.0)); } else { -if ((pen->penDataFlags & EmfPlusPenDataStartCap) -|| (pen->penDataFlags & EmfPlusPenDataEndCap)) +if (aStart.isDefault() && aEnd.isDefault()) +mrTargetHolders.Current().append( +new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( +polygon, lineAttribute, pen->GetS
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx|4 drawinglayer/source/tools/emfppen.cxx | 23 +++- drawinglayer/source/tools/emfppen.hxx |2 drawinglayer/source/tools/primitive2dxmldump.cxx|5 + emfio/qa/cppunit/emf/EmfImportTest.cxx | 50 ++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawPathWithMiterLimit.emf |binary 6 files changed, 76 insertions(+), 8 deletions(-) New commits: commit e709ebe42ad06974b822366e4eea1a6c2ee61e10 Author: Bartosz Kosiorek AuthorDate: Wed May 11 12:54:48 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Fri May 13 13:49:18 2022 +0200 tdf#142261 EMF+ Add support for Miter Limit With this commit the Miter is properly implemented, according to [EMF-PLUS] documentation: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-emfplus/5ef071f3-f503-4f16-b027-7c4bcf2d1d81 The formula for stroke miter limit is described here: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit Change-Id: Ida87063cc045460e61ffae118f64cf133c810dbf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134164 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index c5b282998d71..4d0db58c026b 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -596,8 +596,8 @@ namespace emfplushelper const double transformedPenWidth = mdExtractedYScale * pen->penWidth; drawinglayer::attribute::LineAttribute lineAttribute( pen->GetColor().getBColor(), transformedPenWidth, pen->GetLineJoinType(), -css::drawing::LineCap_BUTT, -basegfx::deg2rad(15.0)); // TODO Add MiterLimit support +css::drawing::LineCap_BUTT, //TODO implement PenDataDashedLineCap supportr here +pen->fMiterMinimumAngle); drawinglayer::attribute::LineStartEndAttribute aStart; if (pen->penDataFlags & EmfPlusPenDataStartCap) diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx index b0408f8d0e80..ec073d56ea59 100644 --- a/drawinglayer/source/tools/emfppen.cxx +++ b/drawinglayer/source/tools/emfppen.cxx @@ -58,7 +58,7 @@ namespace emfplushelper , startCap(0) , endCap(0) , lineJoin(0) -, miterLimit(0.0) +, fMiterMinimumAngle(basegfx::deg2rad(5.0)) , dashStyle(0) , dashCap(0) , dashOffset(0.0) @@ -286,13 +286,26 @@ namespace emfplushelper if (penDataFlags & PenDataMiterLimit) { +float miterLimit; s.ReadFloat(miterLimit); -SAL_WARN("drawinglayer.emf", "EMF+\t\tTODO PenDataMiterLimit: " << std::dec << miterLimit); + +// EMF+ JoinTypeMiterClipped is working as our B2DLineJoin::Miter +// For EMF+ LineJoinTypeMiter we are simulating it by changing angle +if (lineJoin == EmfPlusLineJoinTypeMiter) +miterLimit = 3.0 * miterLimit; +// asin angle must be in range [-1, 1] +if (abs(miterLimit) > 1.0) +fMiterMinimumAngle = 2.0 * asin(1.0 / miterLimit); +else +// enable miter limit for all angles +fMiterMinimumAngle = basegfx::deg2rad(180.0); +SAL_INFO("drawinglayer.emf", + "EMF+\t\t MiterLimit: " << std::dec << miterLimit + << ", Miter minimum angle (rad): " << fMiterMinimumAngle); } else -{ -miterLimit = 0; -} +fMiterMinimumAngle = basegfx::deg2rad(5.0); + if (penDataFlags & PenDataLineStyle) { diff --git a/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx index cad849e4f278..6a7929f332f8 100644 --- a/drawinglayer/source/tools/emfppen.hxx +++ b/drawinglayer/source/tools/emfppen.hxx @@ -105,7 +105,7 @@ namespace emfplushelper sal_Int32 startCap; sal_Int32 endCap; sal_Int32 lineJoin; -float miterLimit; +double fMiterMinimumAngle; sal_Int32 dashStyle; sal_Int32 dashCap; float dashOffset; diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 886ffbf7fdd3..4e35d599876f 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -167,8 +167,12 @@ void writeLineAttribute(::tools::XmlWriter& rWriter, rWriter.attribute("linejoin", "Bevel"); break;
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 144 ++ drawinglayer/source/tools/emfphelperdata.hxx |4 drawinglayer/source/tools/emfppen.cxx | 17 - drawinglayer/source/tools/emfppen.hxx |1 drawinglayer/source/tools/primitive2dxmldump.cxx | 44 emfio/qa/cppunit/emf/EmfImportTest.cxx| 116 +-- emfio/qa/cppunit/emf/data/TestDrawLine.emf|binary emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithCaps.emf |binary 8 files changed, 260 insertions(+), 66 deletions(-) New commits: commit 1440ab87386bb5d1ad3634082577bf27f279e066 Author: Bartosz Kosiorek AuthorDate: Sun Apr 24 02:29:59 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Mon May 9 20:50:37 2022 +0200 tdf#143875 tdf#55058 EMF+ Add support for individual line endings EMF+ is allowing different caps and arrows on both ends It is not possible to implement that with css::drawing::LineCap, as it is set line endings on both line start and line end. Additionally when the Dash Pattern is used, the css::drawing::LineCap is also applied there. To resolve that limitation, the Cap needs to be implemented independetly by using PolygonStrokeArrowPrimitive2D, and the css::drawing::LineCap inside drawinglayer::attribute::LineAttribute always set to css::drawing::LineCap_BUTT Change-Id: I4be76e2dbefcb34154a1404c3b57dc4b7f7ada85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133299 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index c405a4c4876b..c5b282998d71 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -29,6 +29,7 @@ #include "emfpstringformat.hxx" #include #include +#include #include #include #include @@ -519,7 +520,72 @@ namespace emfplushelper } } -void EmfPlusHelperData::EMFPPlusDrawPolygon(const ::basegfx::B2DPolyPolygon& polygon, sal_uInt32 penIndex) +drawinglayer::attribute::LineStartEndAttribute +EmfPlusHelperData::CreateLineEnd(const sal_Int32 aCap, const float aPenWidth) const +{ +const double pw = mdExtractedYScale * aPenWidth; +if (aCap == LineCapTypeSquare) +{ +basegfx::B2DPolygon aCapPolygon( +{ {-1.0, -1.0}, {1.0, -1.0}, {1.0, 1.0}, {-1.0, 1.0} }); +aCapPolygon.setClosed(true); +return drawinglayer::attribute::LineStartEndAttribute( +pw, basegfx::B2DPolyPolygon(aCapPolygon), true); +} +else if (aCap == LineCapTypeRound) +{ +basegfx::B2DPolygon aCapPolygon( +{ {-1.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {0.9236, -0.3827}, + {0.7071, -0.7071}, {0.3827, -0.9236}, {0.0, -1.0}, {-0.3827, -0.9236}, + {-0.7071, -0.7071}, {-0.9236, -0.3827}, {-1.0, 0.0} }); +aCapPolygon.setClosed(true); +return drawinglayer::attribute::LineStartEndAttribute( +pw, basegfx::B2DPolyPolygon(aCapPolygon), true); +} +else if (aCap == LineCapTypeTriangle) +{ +basegfx::B2DPolygon aCapPolygon( +{ {-1.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {0.0, -1.0}, {-1.0, 0.0} }); +aCapPolygon.setClosed(true); +return drawinglayer::attribute::LineStartEndAttribute( +pw, basegfx::B2DPolyPolygon(aCapPolygon), true); +} +else if (aCap == LineCapTypeSquareAnchor) +{ +basegfx::B2DPolygon aCapPolygon( +{ {-1.0, -1.0}, {1.0, -1.0}, {1.0, 1.0}, {-1.0, 1.0} }); +aCapPolygon.setClosed(true); +return drawinglayer::attribute::LineStartEndAttribute( +1.5 * pw, basegfx::B2DPolyPolygon(aCapPolygon), true); +} +else if (aCap == LineCapTypeRoundAnchor) +{ +const basegfx::B2DPolygon aCapPolygon += ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 1.0, 1.0); +return drawinglayer::attribute::LineStartEndAttribute( +2.0 * pw, basegfx::B2DPolyPolygon(aCapPolygon), true); +} +else if (aCap == LineCapTypeDiamondAnchor) +{ +basegfx::B2DPolygon aCapPolygon({ {0.0, -1.0}, {1.0, 0.0}, {0.5, 0.5}, + {0.5, 1.0}, {-0.5, 1.0}, {-0.5, 0.5}, + {-1.0, 0.0} }); +aCapPolygon.setClosed(true); +return drawinglayer::attribute::LineStartEndAttribute( +2.0 * pw, basegfx::B2DPolyPolygon(aCapPolygon), true); +} +else if (aCap == LineCapTypeArrowAnchor) +{ +basegfx::B2DPolygon aCapPolygo
[Libreoffice-commits] core.git: drawinglayer/source emfio/inc emfio/qa emfio/source vcl/qa
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
[Libreoffice-commits] core.git: filter/source
filter/source/msfilter/msdffimp.cxx | 96 +++- 1 file changed, 63 insertions(+), 33 deletions(-) New commits: commit 8c9e6d3a99df641f9c395c65f7b48225b8775baa Author: Bartosz Kosiorek AuthorDate: Wed Apr 27 20:17:37 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Apr 28 20:40:09 2022 +0200 Add initial support OfficeArtBlip TIFF format Additionally the magic number were replaced with enum Change-Id: I7d825ec84ff5cd5ff315ee37613e3b84cb6f0567 Change-Id: Ic33022a0e225099f2397dd300f4792055184fd10 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133526 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 7fae12fc40ea..7c036227e8b8 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -171,6 +171,18 @@ static sal_uInt32 nMSOleObjCntr = 0; constexpr OUStringLiteral MSO_OLE_Obj = u"MSO_OLE_Obj"; namespace { +/* Office File Formats - 2.2.23 */ +enum class OfficeArtBlipRecInstance : sal_uInt32 +{ +EMF = 0x3D4, // defined in section 2.2.24. +WMF = 0x216, // defined in section 2.2.25. +PICT = 0x542, // as defined in section 2.2.26. +JPEG_RGB = 0x46A, // defined in section 2.2.27. +JPEG_CMYK = 0x6E2, // defined in section 2.2.27. +PNG = 0x6E0, // defined in section 2.2.28. +DIB = 0x7A8, // defined in section 2.2.29. +TIFF = 0x6E4 // defined in section 2.2.30. +}; struct SvxMSDffBLIPInfo { @@ -6479,40 +6491,42 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool boolbMtfBLIP = false; boolbZCodecCompression = false; // now position it exactly at the beginning of the embedded graphic -sal_uLong nSkip = ( nInst & 0x0001 ) ? 32 : 16; - -switch( nInst & 0xFFFE ) +sal_uLong nSkip = (nInst & 0x0001) ? 32 : 16; +const OfficeArtBlipRecInstance aRecInstanse = OfficeArtBlipRecInstance(nInst & 0xFFFE); +switch (aRecInstanse) { -case 0x216 :// Metafile header then compressed WMF -case 0x3D4 :// Metafile header then compressed EMF -case 0x542 :// Metafile hd. then compressed PICT +case OfficeArtBlipRecInstance::EMF: +case OfficeArtBlipRecInstance::WMF: +case OfficeArtBlipRecInstance::PICT: { -rBLIPStream.SeekRel( nSkip + 20 ); +rBLIPStream.SeekRel(nSkip + 20); -// read in size of metafile in EMUS +// read in size of metafile in English Metric Units (EMUs) sal_Int32 width(0), height(0); -rBLIPStream.ReadInt32( width ).ReadInt32( height ); -aMtfSize100.setWidth( width ); -aMtfSize100.setHeight( height ); +rBLIPStream.ReadInt32(width).ReadInt32(height); +aMtfSize100.setWidth(width); +aMtfSize100.setHeight(height); +// 1 EMU = 1/360,000 of a centimeter // scale to 1/100mm -aMtfSize100.setWidth( aMtfSize100.Width() / 360 ); -aMtfSize100.setHeight( aMtfSize100.Height() / 360 ); +aMtfSize100.setWidth(aMtfSize100.Width() / 360); +aMtfSize100.setHeight(aMtfSize100.Height() / 360); -if ( pVisArea ) // seem that we currently are skipping the visarea position -*pVisArea = tools::Rectangle( Point(), aMtfSize100 ); +if (pVisArea) // seem that we currently are skipping the visarea position +*pVisArea = tools::Rectangle(Point(), aMtfSize100); // skip rest of header nSkip = 6; bMtfBLIP = bZCodecCompression = true; } break; -case 0x46A :// One byte tag then JPEG (= JFIF) data -case 0x6E0 :// One byte tag then PNG data -case 0x6E2 :// One byte tag then JPEG in CMYK color space -case 0x7A8 : -nSkip += 1; // One byte tag then DIB data -break; +case OfficeArtBlipRecInstance::JPEG_RGB: +case OfficeArtBlipRecInstance::JPEG_CMYK: +case OfficeArtBlipRecInstance::PNG: +case OfficeArtBlipRecInstance::DIB: +case OfficeArtBlipRecInstance::TIFF: +nSkip += 1; // Skip one byte tag +break; } rBLIPStream.SeekRel( nSkip ); @@ -6535,18 +6549,34 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool // extract graphics from ole storage into "dbggfxNNN.*" static sal_Int32 nGrfCount; -OUStrin
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 16 commits - basic/source compilerplugins/clang drawinglayer/source emfio/qa fpicker/source oox/source sd/qa sfx2/source svx/qa svx
basic/source/inc/rtlproto.hxx |1 basic/source/runtime/methods.cxx | 19 +++ basic/source/runtime/stdobj.cxx |7 + compilerplugins/clang/redundantfcast.cxx |3 drawinglayer/source/tools/emfpcustomlinecap.cxx |9 - drawinglayer/source/tools/emfpcustomlinecap.hxx |2 drawinglayer/source/tools/emfphelperdata.cxx | 68 ++-- drawinglayer/source/tools/emfphelperdata.hxx |5 drawinglayer/source/tools/emfppen.cxx | 70 ++-- drawinglayer/source/tools/emfppen.hxx |5 drawinglayer/source/tools/primitive2dxmldump.cxx | 32 +++-- emfio/qa/cppunit/emf/EmfImportTest.cxx| 44 +++- emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf |binary fpicker/source/office/autocmpledit.cxx| 25 fpicker/source/office/autocmpledit.hxx|2 oox/source/drawingml/textcharacterproperties.cxx |6 + sd/qa/uitest/impress_tests/tdf148620.py | 77 ++ sd/qa/unit/data/pptx/tdf148685.pptx |binary sd/qa/unit/import-tests2.cxx | 43 +++ sfx2/source/appl/newhelp.cxx |1 sfx2/source/view/viewfrm.cxx |3 svx/qa/unit/svdraw.cxx|3 svx/source/svdraw/sdrhittesthelper.cxx|7 - sw/source/core/doc/docbm.cxx |5 sw/source/core/inc/layfrm.hxx |1 sw/source/core/layout/findfrm.cxx | 21 +++ sw/source/core/layout/pagechg.cxx |2 ucb/CppunitTest_ucb_webdav_core.mk|1 ucb/Library_ucpdav1.mk|1 ucb/source/ucp/webdav-curl/CurlSession.cxx|7 - ucb/source/ucp/webdav-curl/webdavcontent.cxx |8 + ucb/source/ucp/webdav-curl/webdavresponseparser.cxx | 22 +++- vcl/inc/qt5/QtInstance.hxx|6 + vcl/inc/qt5/QtWidget.hxx |8 + vcl/qt5/QtInstance.cxx|7 + vcl/qt5/QtWidget.cxx | 55 +- vcl/unx/gtk3/gtkinst.cxx |2 37 files changed, 462 insertions(+), 116 deletions(-) New commits: commit c6fab8b3c25de948372f13e1faf59f71724bff6b Author: Bartosz Kosiorek AuthorDate: Fri Apr 22 16:46:39 2022 +0200 Commit: Andras Timar CommitDate: Mon Apr 25 11:13:56 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;
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/emfpbrush.cxx | 71 +++ drawinglayer/source/tools/emfpbrush.hxx |6 +- drawinglayer/source/tools/emfphelperdata.cxx |4 - drawinglayer/source/tools/emfppen.cxx| 27 +++--- drawinglayer/source/tools/emfppen.hxx|4 - 5 files changed, 35 insertions(+), 77 deletions(-) New commits: commit 8202df1815ed692df371e6d07a3b0f29a329f6ed Author: Bartosz Kosiorek AuthorDate: Fri Apr 22 18:26:49 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Sun Apr 24 13:01:05 2022 +0200 tdf#103859 EMF+ Use variable types according to EMFPLUS documentation With this commit, the types of variable for Brush and Pen were aligned to documentation: [MS-EMFPLUS] - Enhanced Metafile Format Plus Extensions As a side effect the code was simplified a bit Change-Id: Ibabad628d0aaef510f61ee8b3d881c3f024cebef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133327 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx index 4acc311345a8..7d6204a5da9e 100644 --- a/drawinglayer/source/tools/emfpbrush.cxx +++ b/drawinglayer/source/tools/emfpbrush.cxx @@ -113,17 +113,12 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tCenter color: 0x" << std::hex << color << std::dec); s.ReadFloat(firstPointX).ReadFloat(firstPointY); SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tCenter point: " << firstPointX << "," << firstPointY); -s.ReadInt32(surroundColorsNumber); +s.ReadUInt32(surroundColorsNumber); SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\t number of surround colors: " << surroundColorsNumber); -if (surroundColorsNumber<0 || o3tl::make_unsigned(surroundColorsNumber)>SAL_MAX_INT32 / sizeof(::Color)) -{ -surroundColorsNumber = SAL_MAX_INT32 / sizeof(::Color); -} - surroundColors.reset( new ::Color[surroundColorsNumber] ); -for (int i = 0; i < surroundColorsNumber; i++) +for (sal_uInt32 i = 0; i < surroundColorsNumber; i++) { s.ReadUInt32(color); surroundColors[i] = ::Color(ColorAlpha, (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); @@ -132,7 +127,7 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tSurround color[" << i << "]: 0x" << std::hex << color << std::dec); } -if (additionalFlags & 0x01) +if (additionalFlags & 0x01) // BrushDataPath { sal_Int32 pathLength; @@ -180,60 +175,47 @@ namespace emfplushelper << aBounds.getWidth() << "x" << aBounds.getHeight()); } -if (additionalFlags & 0x02) +if (additionalFlags & 0x02) // BrushDataTransform { EmfPlusHelperData::readXForm(s, brush_transformation); hasTransformation = true; SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse brush transformation: " << brush_transformation); } -if (additionalFlags & 0x08) +if (additionalFlags & 0x08) // BrushDataBlendFactorsH { -s.ReadInt32(blendPoints); +s.ReadUInt32(blendPoints); SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tuse blend, points: " << blendPoints); -if (blendPoints<0 || o3tl::make_unsigned(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float))) -blendPoints = SAL_MAX_INT32 / (2 * sizeof(float)); blendPositions.reset( new float[2 * blendPoints] ); blendFactors = blendPositions.get() + blendPoints; -for (int i = 0; i < blendPoints; i++) +for (sal_uInt32 i = 0; i < blendPoints; i++) { s.ReadFloat(blendPositions[i]); SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tposition[" << i << "]: " << blendPositions[i]); } -for (int i = 0; i < blendPoints; i++) +for (sal_uInt32 i = 0; i < blendPoints; i++)
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - drawinglayer/source emfio/qa
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&
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
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 abe3a06c45c0803a5c8bcf16e0e586fd72781c93 Author: Bartosz Kosiorek AuthorDate: Fri Apr 22 16:46:39 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Apr 22 18:23:21 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 diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 84d848ed2c1a..a7f809373e09 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 @@ -531,7 +535,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(), @@ -543,7 +547,7 @@ namespace emfplushelper new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( polygon, lineAttribute, -pen->GetStrokeAttribute(maMapTransform.get(1, 1; +pen->GetStrokeAttribute(mdExtractedXScale))); } else { @@ -551,7 +555,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 563f7773c3ba..600f666145af 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 61264496ff98..3074ad30690a 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 fDotDash : rStrokeAttribute.getDotDashArray()) { -sDotDash += OUString::number(round(100.0 * fDotDash)) +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - compilerplugins/clang drawinglayer/source emfio/qa svx/qa
compilerplugins/clang/redundantfcast.cxx |3 drawinglayer/source/tools/emfpcustomlinecap.cxx |9 - drawinglayer/source/tools/emfpcustomlinecap.hxx |2 drawinglayer/source/tools/emfphelperdata.cxx | 62 +--- drawinglayer/source/tools/emfppen.cxx | 70 +++--- drawinglayer/source/tools/emfppen.hxx |5 - drawinglayer/source/tools/primitive2dxmldump.cxx | 32 -- emfio/qa/cppunit/emf/EmfImportTest.cxx| 34 ++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf |binary svx/qa/unit/svdraw.cxx|3 10 files changed, 127 insertions(+), 93 deletions(-) New commits: commit 547ac0aa23a25f03a17014cb474eedc1fd88017f Author: Bartosz Kosiorek AuthorDate: Wed Apr 20 19:44:05 2022 +0200 Commit: Xisco Fauli CommitDate: Fri Apr 22 16:13:54 2022 +0200 tdf#55058 tdf#143875 EMF+ Fix display of dashed lines and line joints With previous implementation, empty spaces between dashes were too long. Additionally line joints were not working correctly, after EMF+ reworking: tdf#111486 This commit fixes all these issues and additionally it is covering it with tests. Change-Id: I9404e566d2d7d3405ab817268ad9b1f538c200eb Change-Id: I523f92a928ab592ff175d0d01c1ad1a3bc22e324 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133207 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 80c856336668e35837667323957fa3ad4172f3c0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133152 diff --git a/compilerplugins/clang/redundantfcast.cxx b/compilerplugins/clang/redundantfcast.cxx index 67ff2c56edef..85386eb4ea8e 100644 --- a/compilerplugins/clang/redundantfcast.cxx +++ b/compilerplugins/clang/redundantfcast.cxx @@ -334,6 +334,9 @@ public: // tdf#145203: FIREBIRD cannot create a table if (fn == SRCDIR "/connectivity/source/drivers/firebird/DatabaseMetaData.cxx") return false; +// false positive during using contructor drawinglayer::attribute::StrokeAttribute({ 3 * pw, pw }) +if (fn == SRCDIR "/drawinglayer/source/tools/emfppen.cxx") +return false; return true; } diff --git a/drawinglayer/source/tools/emfpcustomlinecap.cxx b/drawinglayer/source/tools/emfpcustomlinecap.cxx index e24cbcc32cb1..49cc912ed33c 100644 --- a/drawinglayer/source/tools/emfpcustomlinecap.cxx +++ b/drawinglayer/source/tools/emfpcustomlinecap.cxx @@ -43,15 +43,6 @@ namespace emfplushelper { } -void EMFPCustomLineCap::SetAttributes(rendering::StrokeAttributes& aAttributes) -{ -aAttributes.StartCapType = EMFPPen::lcl_convertStrokeCap(strokeStartCap); -aAttributes.EndCapType = EMFPPen::lcl_convertStrokeCap(strokeEndCap); -aAttributes.JoinType = EMFPPen::lcl_convertLineJoinType(strokeJoin); - -aAttributes.MiterLimit = miterLimit; -} - void EMFPCustomLineCap::ReadPath(SvStream& s, EmfPlusHelperData const & rR, bool bFill) { sal_Int32 pathLength; diff --git a/drawinglayer/source/tools/emfpcustomlinecap.hxx b/drawinglayer/source/tools/emfpcustomlinecap.hxx index a42e0ab4ef46..e6202ae98179 100644 --- a/drawinglayer/source/tools/emfpcustomlinecap.hxx +++ b/drawinglayer/source/tools/emfpcustomlinecap.hxx @@ -19,7 +19,6 @@ #pragma once -#include #include "emfphelperdata.hxx" namespace emfplushelper @@ -34,7 +33,6 @@ namespace emfplushelper EMFPCustomLineCap(); -void SetAttributes(com::sun::star::rendering::StrokeAttributes& aAttributes); void ReadPath(SvStream& s, EmfPlusHelperData const & rR, bool bFill); void Read(SvStream& s, EmfPlusHelperData const & rR); }; diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 447686167837..79ced761e8a2 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -509,13 +509,6 @@ namespace emfplushelper if (!(pen && polygon.count())) return; -// we need a line join attribute -basegfx::B2DLineJoin lineJoin = basegfx::B2DLineJoin::Round; -if (pen->penDataFlags & EmfPlusPenDataJoin) // additional line join information -{ -lineJoin = static_cast(EMFPPen::lcl_convertLineJoinType(pen->lineJoin)); -} - // we need a line cap attribute css::drawing::LineCap lineCap = css::drawing::LineCap_BUTT; if (pen->penDataFlags & EmfPlusPenDataStartCap) // additional line cap information @@ -527,57 +520,16 @@ namespace emfplushelper const double transformedPenWidth = maMapTransform.get(0, 0) * pen->penWidth
[Libreoffice-commits] core.git: compilerplugins/clang drawinglayer/source emfio/qa svx/qa
compilerplugins/clang/redundantfcast.cxx |3 drawinglayer/source/tools/emfpcustomlinecap.cxx |9 - drawinglayer/source/tools/emfpcustomlinecap.hxx |2 drawinglayer/source/tools/emfphelperdata.cxx | 62 +--- drawinglayer/source/tools/emfppen.cxx | 70 +++--- drawinglayer/source/tools/emfppen.hxx |5 - drawinglayer/source/tools/primitive2dxmldump.cxx | 32 -- emfio/qa/cppunit/emf/EmfImportTest.cxx| 33 ++ emfio/qa/cppunit/emf/data/TestEmfPlusDrawLineWithDash.emf |binary svx/qa/unit/svdraw.cxx|3 10 files changed, 126 insertions(+), 93 deletions(-) New commits: commit 80c856336668e35837667323957fa3ad4172f3c0 Author: Bartosz Kosiorek AuthorDate: Wed Apr 20 19:44:05 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Apr 21 10:30:26 2022 +0200 tdf#55058 tdf#143875 EMF+ Fix display of dashed lines and line joints With previous implementation, empty spaces between dashes were too long. Additionally line joints were not working correctly, after EMF+ reworking: tdf#111486 This commit fixes all these issues and additionally it is covering it with tests. Change-Id: I9404e566d2d7d3405ab817268ad9b1f538c200eb Change-Id: I523f92a928ab592ff175d0d01c1ad1a3bc22e324 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133207 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/compilerplugins/clang/redundantfcast.cxx b/compilerplugins/clang/redundantfcast.cxx index be9565c9fbe8..1378d9eaf435 100644 --- a/compilerplugins/clang/redundantfcast.cxx +++ b/compilerplugins/clang/redundantfcast.cxx @@ -335,6 +335,9 @@ public: // tdf#145203: FIREBIRD cannot create a table if (fn == SRCDIR "/connectivity/source/drivers/firebird/DatabaseMetaData.cxx") return false; +// false positive during using contructor drawinglayer::attribute::StrokeAttribute({ 3 * pw, pw }) +if (fn == SRCDIR "/drawinglayer/source/tools/emfppen.cxx") +return false; return true; } diff --git a/drawinglayer/source/tools/emfpcustomlinecap.cxx b/drawinglayer/source/tools/emfpcustomlinecap.cxx index e24cbcc32cb1..49cc912ed33c 100644 --- a/drawinglayer/source/tools/emfpcustomlinecap.cxx +++ b/drawinglayer/source/tools/emfpcustomlinecap.cxx @@ -43,15 +43,6 @@ namespace emfplushelper { } -void EMFPCustomLineCap::SetAttributes(rendering::StrokeAttributes& aAttributes) -{ -aAttributes.StartCapType = EMFPPen::lcl_convertStrokeCap(strokeStartCap); -aAttributes.EndCapType = EMFPPen::lcl_convertStrokeCap(strokeEndCap); -aAttributes.JoinType = EMFPPen::lcl_convertLineJoinType(strokeJoin); - -aAttributes.MiterLimit = miterLimit; -} - void EMFPCustomLineCap::ReadPath(SvStream& s, EmfPlusHelperData const & rR, bool bFill) { sal_Int32 pathLength; diff --git a/drawinglayer/source/tools/emfpcustomlinecap.hxx b/drawinglayer/source/tools/emfpcustomlinecap.hxx index a42e0ab4ef46..e6202ae98179 100644 --- a/drawinglayer/source/tools/emfpcustomlinecap.hxx +++ b/drawinglayer/source/tools/emfpcustomlinecap.hxx @@ -19,7 +19,6 @@ #pragma once -#include #include "emfphelperdata.hxx" namespace emfplushelper @@ -34,7 +33,6 @@ namespace emfplushelper EMFPCustomLineCap(); -void SetAttributes(com::sun::star::rendering::StrokeAttributes& aAttributes); void ReadPath(SvStream& s, EmfPlusHelperData const & rR, bool bFill); void Read(SvStream& s, EmfPlusHelperData const & rR); }; diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index e60f8815ef79..84d848ed2c1a 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -523,13 +523,6 @@ namespace emfplushelper if (!(pen && polygon.count())) return; -// we need a line join attribute -basegfx::B2DLineJoin lineJoin = basegfx::B2DLineJoin::Round; -if (pen->penDataFlags & EmfPlusPenDataJoin) // additional line join information -{ -lineJoin = static_cast(EMFPPen::lcl_convertLineJoinType(pen->lineJoin)); -} - // we need a line cap attribute css::drawing::LineCap lineCap = css::drawing::LineCap_BUTT; if (pen->penDataFlags & EmfPlusPenDataStartCap) // additional line cap information @@ -541,57 +534,16 @@ namespace emfplushelper const double transformedPenWidth = maMapTransform.get(0, 0) * pen->penWidth; drawinglayer::attribute::LineAttribute lineAttribute(pen->GetColor().ge
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 180 - drawinglayer/source/tools/emfphelperdata.hxx |3 emfio/qa/cppunit/emf/EmfImportTest.cxx | 66 + emfio/qa/cppunit/emf/data/TestEmfPlusGetDC.emf |binary emfio/qa/cppunit/emf/data/TestEmfPlusSave.emf |binary 5 files changed, 184 insertions(+), 65 deletions(-) New commits: commit f26ba7f7c951164cc8677e55fa73081e16659147 Author: Bartosz Kosiorek AuthorDate: Fri Apr 1 11:43:30 2022 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Apr 1 17:24:07 2022 +0200 tdf#147818 EMF+ Fix restoring clipping states With previous implementation the clipping restoring with EmfPlusRecordTypeRestore was implemented wrongly as it is only taken to account the shape of clipping (state.getClipPolyPolygon) and doesn't take if clipping was even enabled (state.getClipPolyPolygonActive). Additionally the changing states should be made by using method: wmfemfhelper::HandleNewClipRegion() and not directly. The similar implementation was applied also to EmfPlusRecordTypeGetDC. Additionally the clipping for EmfPlusRecordTypeSetClipRect EmfPlusRecordTypeSetClipPath EmfPlusRecordTypeSetClipRegion was fixed, as initially the clipping is disabled (state.getClipPolyPolygonActive) and the clipping shape is empty (state.getClipPolyPolygon). It means that combination other than EmfPlusCombineModeReplace, was not working correctly. With this implementation, if Clipping is disabled, then treat clip combining in special way. Change-Id: I258bda64e8bfdade7f47ffc7518bf04b7340344f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132415 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 447686167837..e60f8815ef79 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -486,18 +486,32 @@ namespace emfplushelper map[ index ] = state; } -void EmfPlusHelperData::GraphicStatePop(GraphicStateMap& map, sal_Int32 index, wmfemfhelper::PropertyHolder& rState) +void EmfPlusHelperData::GraphicStatePop(GraphicStateMap& map, sal_Int32 index) { -GraphicStateMap::iterator iter = map.find( index ); +GraphicStateMap::iterator iter = map.find(index); -if ( iter != map.end() ) +if (iter != map.end()) { wmfemfhelper::PropertyHolder state = iter->second; maWorldTransform = state.getTransformation(); -rState.setClipPolyPolygon( state.getClipPolyPolygon() ); +if (state.getClipPolyPolygonActive()) +{ +SAL_INFO("drawinglayer.emf", +"EMF+\t Restore clipping region to saved in index: " << index); +wmfemfhelper::HandleNewClipRegion(state.getClipPolyPolygon(), mrTargetHolders, + mrPropertyHolders); +} +else +{ +SAL_INFO("drawinglayer.emf", "EMF+\t Disable clipping"); +wmfemfhelper::HandleNewClipRegion(::basegfx::B2DPolyPolygon(), mrTargetHolders, + mrPropertyHolders); +} mappingChanged(); -SAL_INFO("drawinglayer.emf", "EMF+\t\tStack index: " << index << " found, maWorldTransform: " << maWorldTransform); +SAL_INFO("drawinglayer.emf", +"EMF+\t\tStack index: " << index +<< " found, maWorldTransform: " << maWorldTransform); } } @@ -1000,14 +1014,8 @@ namespace emfplushelper } case EmfPlusCombineModeIntersect: { -if (leftPolygon.count()) -{ -aClippedPolyPolygon = basegfx::utils::clipPolyPolygonOnPolyPolygon( -leftPolygon, -rightPolygon, -true, -false); -} +aClippedPolyPolygon = basegfx::utils::clipPolyPolygonOnPolyPolygon( +leftPolygon, rightPolygon, true, false); break; } case EmfPlusCombineModeUnion: @@ -1080,8 +1088,18 @@ namespace emfplushelper if (bIsGetDCProcessing) { -SAL_INFO("drawinglayer.emf", "EMF+\t reset the current clipping region for the world space to infinity."); -wmfemfhelper::HandleNewClipRegion(::basegfx::B2DPolyPolygon(), mrTargetHolders, mrPropertyHolders); +if (aGetDCSt
[Libreoffice-commits] core.git: basegfx/source chart2/source emfio/source
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: Branch 'libreoffice-7-3' - emfio/inc emfio/qa emfio/source include/tools tools/inc tools/source
emfio/inc/mtftools.hxx|4 + emfio/qa/cppunit/emf/EmfImportTest.cxx| 48 ++ emfio/qa/cppunit/emf/data/TestSetArcDirection.emf |binary emfio/source/reader/emfreader.cxx | 16 +-- emfio/source/reader/mtftools.cxx |9 include/tools/poly.hxx|3 - tools/inc/poly.h |2 tools/source/generic/poly.cxx | 41 -- 8 files changed, 104 insertions(+), 19 deletions(-) New commits: commit 6ab0f5a11d88dc40e56eb8210ed9493973d44e27 Author: Bartosz Kosiorek AuthorDate: Mon Mar 7 12:26:03 2022 +0100 Commit: Xisco Fauli CommitDate: Fri Mar 11 12:46:14 2022 +0100 tdf#113066 tdf#142204 EMF Implement SETARCDIRECTION Change-Id: I30206c68ecf1829ba0094e6259b8ed7dc05f2e9a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131103 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 7b28920382d3820344bfc4075bac98f85e838dba) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131206 Reviewed-by: Xisco Fauli diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 8e3ccba65b84..85523ee25cce 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -455,6 +455,7 @@ namespace emfio WinMtfClipPath maClipPath; XForm aXForm; +boolbClockWiseArcDirection; boolbFillStyleSelected; }; @@ -566,6 +567,7 @@ namespace emfio ScaledFontDetectCorrectHelper maScaledFontHelper; boolmbNopMode : 1; +boolmbClockWiseArcDirection : 1; boolmbFillStyleSelected : 1; boolmbClipNeedsUpdate : 1; boolmbComplexClip : 1; @@ -619,6 +621,8 @@ namespace emfio voidSetGfxMode(sal_Int32 nGfxMode) { mnGfxMode = nGfxMode; }; sal_Int32 GetGfxMode() const { return mnGfxMode; }; +voidSetArcDirection(bool bCounterClockWise); +boolIsArcDirectionClockWise() { return mbClockWiseArcDirection; }; voidSetBkMode(BkMode nMode); voidSetBkColor(const Color& rColor); voidSetTextColor(const Color& rColor); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index c5e966e48040..799f8eef9c46 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -61,6 +61,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestEllipseXformIntersectClipRect(); +void TestSetArcDirection(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestExtTextOutOpaqueAndClipTransform(); @@ -103,6 +104,7 @@ public: CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestEllipseXformIntersectClipRect); +CPPUNIT_TEST(TestSetArcDirection); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestExtTextOutOpaqueAndClipTransform); @@ -717,6 +719,52 @@ void Test::TestEllipseXformIntersectClipRect() "3625,320 3625,320"); } +void Test::TestSetArcDirection() +{ +// EMF import test with records: SETARCDIRECTION, ARC, PIE +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestSetArcDirection.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument += dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT(pDocument); + +assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", "color", "#ff"); +assertXPath( +pDocument, aXPathPrefix + "polypolygoncolor/polypolygon", "path", +"m1640 1570-1000-950 50-50 50-50 50-50 50-40 60-40 50-40 60-30 60-40 60-20 60-30 70-20 " +"60-20 70-10 60-20h70l70-10h60 70l70 10 60 10 70 10 70 20 60 20 60 20 70 30 60 30 60 30 50 " +"40 60 40 50 40 50 40 50 50 50 50 50 50 40 60 40 60 40 60 30 60 30 60 30 60 20 70 30 70 10 " +"60 20 70 10 70 10 70 10 70v80 70l-10 70v70l-10 70-20 70-20 70z"); +assertXPath(pDocument, aXPathPrefix + "polygonhairline", 2); +assertXPath(pDocument, aXPathPrefix + "polygonhairline[1]", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "polygonhairline[2]", "color", "#00"); +
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source include/tools tools/inc tools/source
emfio/inc/mtftools.hxx|4 + emfio/qa/cppunit/emf/EmfImportTest.cxx| 48 ++ emfio/qa/cppunit/emf/data/TestSetArcDirection.emf |binary emfio/source/reader/emfreader.cxx | 16 +-- emfio/source/reader/mtftools.cxx |9 include/tools/poly.hxx|3 - tools/inc/poly.h |2 tools/source/generic/poly.cxx | 41 -- 8 files changed, 104 insertions(+), 19 deletions(-) New commits: commit 7b28920382d3820344bfc4075bac98f85e838dba Author: Bartosz Kosiorek AuthorDate: Mon Mar 7 12:26:03 2022 +0100 Commit: Bartosz Kosiorek CommitDate: Thu Mar 10 21:19:59 2022 +0100 tdf#113066 tdf#142204 EMF Implement SETARCDIRECTION Change-Id: I30206c68ecf1829ba0094e6259b8ed7dc05f2e9a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131103 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 84a012f183d6..d258a9250b91 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -454,6 +454,7 @@ namespace emfio WinMtfClipPath maClipPath; XForm aXForm; +boolbClockWiseArcDirection; boolbFillStyleSelected; }; @@ -565,6 +566,7 @@ namespace emfio ScaledFontDetectCorrectHelper maScaledFontHelper; boolmbNopMode : 1; +boolmbClockWiseArcDirection : 1; boolmbFillStyleSelected : 1; boolmbClipNeedsUpdate : 1; boolmbComplexClip : 1; @@ -618,6 +620,8 @@ namespace emfio voidSetGfxMode(sal_Int32 nGfxMode) { mnGfxMode = nGfxMode; }; sal_Int32 GetGfxMode() const { return mnGfxMode; }; +voidSetArcDirection(bool bCounterClockWise); +boolIsArcDirectionClockWise() { return mbClockWiseArcDirection; }; voidSetBkMode(BkMode nMode); voidSetBkColor(const Color& rColor); voidSetTextColor(const Color& rColor); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index c9c2bcb94219..fce8961a849a 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -60,6 +60,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestEllipseXformIntersectClipRect(); +void TestSetArcDirection(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestExtTextOutOpaqueAndClipTransform(); @@ -102,6 +103,7 @@ public: CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestEllipseXformIntersectClipRect); +CPPUNIT_TEST(TestSetArcDirection); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestExtTextOutOpaqueAndClipTransform); @@ -700,6 +702,52 @@ void Test::TestEllipseXformIntersectClipRect() "3625,320 3625,320"); } +void Test::TestSetArcDirection() +{ +// EMF import test with records: SETARCDIRECTION, ARC, PIE +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestSetArcDirection.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); +CPPUNIT_ASSERT(pDocument); + +assertXPath(pDocument, aXPathPrefix + "polypolygoncolor", "color", "#ff"); +assertXPath( +pDocument, aXPathPrefix + "polypolygoncolor/polypolygon", "path", +"m1640 1570-1000-950 50-50 50-50 50-50 50-40 60-40 50-40 60-30 60-40 60-20 60-30 70-20 " +"60-20 70-10 60-20h70l70-10h60 70l70 10 60 10 70 10 70 20 60 20 60 20 70 30 60 30 60 30 50 " +"40 60 40 50 40 50 40 50 50 50 50 50 50 40 60 40 60 40 60 30 60 30 60 30 60 20 70 30 70 10 " +"60 20 70 10 70 10 70 10 70v80 70l-10 70v70l-10 70-20 70-20 70z"); +assertXPath(pDocument, aXPathPrefix + "polygonhairline", 2); +assertXPath(pDocument, aXPathPrefix + "polygonhairline[1]", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "polygonhairline[2]", "color", "#00"); +assertXPath(pDocument, aXPathPrefix + "polygonhairline", 2); +assertXPathContent( +pDocument, aXPathPrefix + "polygonhairline[1]/polygon&qu
[Libreoffice-commits] core.git: sc/qa solenv/clang-format
sc/qa/unit/subsequent_export-test.cxx | 1788 +- solenv/clang-format/excludelist |1 2 files changed, 1106 insertions(+), 683 deletions(-) New commits: commit 341f923b5e487fa596e369d2ad17daaea909d9ec Author: Bartosz Kosiorek AuthorDate: Thu Aug 19 06:32:26 2021 -0400 Commit: Bartosz Kosiorek CommitDate: Fri Aug 20 16:02:06 2021 +0200 Enable automatic code style formatting for subsequent_export-test.cxx As subsequent_export-test.cxx code style is following the recommended code style (except too long lines and minor formattings), the code is used only for testing and it is rarely modified (mainly adding new test cases), I decided to enable automatic code formatting. It is one step closer to migrate to common code style. Change-Id: Iaa6c243fab45c37cb01672633717577651916c3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120706 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index e1d3f78bb93b..aa2a12f69d33 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -84,6 +84,7 @@ class ScExportTest : public ScBootstrapFixture, public XmlTestTools { protected: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; + public: ScExportTest(); @@ -166,12 +167,12 @@ public: void testSharedFormulaExportXLSX(); void testSharedFormulaStringResultExportXLSX(); -void testFunctionsExcel2010( sal_uLong nFormatType ); +void testFunctionsExcel2010(sal_uLong nFormatType); void testFunctionsExcel2010XLSX(); void testFunctionsExcel2010XLS(); void testFunctionsExcel2010ODS(); -void testCeilingFloor( sal_uLong nFormatType ); +void testCeilingFloor(sal_uLong nFormatType); void testCeilingFloorXLSX(); void testCeilingFloorODSToXLSX(); void testCeilingFloorXLS(); @@ -313,7 +314,7 @@ public: CPPUNIT_TEST_SUITE_END(); private: -void testExcelCellBorders( sal_uLong nFormatType ); +void testExcelCellBorders(sal_uLong nFormatType); uno::Reference m_xCalcComponent; }; @@ -326,21 +327,20 @@ void ScExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) void ScExportTest::test() { -ScDocShell* pShell = new ScDocShell( -SfxModelFlags::EMBEDDED_OBJECT | -SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | -SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); +ScDocShell* pShell += new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS + | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); pShell->DoInitNew(); ScDocument& rDoc = pShell->GetDocument(); -rDoc.SetValue(0,0,0, 1.0); +rDoc.SetValue(0, 0, 0, 1.0); ScDocShellRef xDocSh = saveAndReload(pShell, FORMAT_ODS); CPPUNIT_ASSERT(xDocSh.is()); ScDocument& rLoadedDoc = xDocSh->GetDocument(); -double aVal = rLoadedDoc.GetValue(0,0,0); +double aVal = rLoadedDoc.GetValue(0, 0, 0); ASSERT_DOUBLES_EQUAL(aVal, 1.0); xDocSh->DoClose(); } @@ -376,7 +376,8 @@ void ScExportTest::testTdf139167() ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); CPPUNIT_ASSERT(xDocSh.is()); -std::shared_ptr pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); +std::shared_ptr pXPathFile += ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); xmlDocUniquePtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml"); CPPUNIT_ASSERT(pDoc); @@ -395,7 +396,8 @@ void ScExportTest::testTdf113271() ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); CPPUNIT_ASSERT(xDocSh.is()); -std::shared_ptr pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); +std::shared_ptr pXPathFile += ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); xmlDocUniquePtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml"); CPPUNIT_ASSERT(pDoc); @@ -418,19 +420,27 @@ void ScExportTest::testTdf139394() ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); CPPUNIT_ASSERT(xDocSh.is()); -std::shared_ptr pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); -xmlDocUniquePtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); +std::shared_ptr pXPathFile += ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); +xmlDocUniquePtr pDoc += XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); CPPUNIT_ASSERT(pDoc); -assertXPathContent(pDoc, - "/x:worksheet/x:extLst/x:ext/x14:conditionalFormattings/x14:conditionalF
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - drawinglayer/source
drawinglayer/source/tools/emfphelperdata.cxx | 171 ++- 1 file changed, 91 insertions(+), 80 deletions(-) New commits: commit 5ee7cb39238a420f1b2ffc83d5b2dc79e0ee3875 Author: Bartosz Kosiorek AuthorDate: Sat Jul 3 21:55:33 2021 +0200 Commit: Xisco Fauli CommitDate: Wed Jul 14 09:52:57 2021 +0200 EMF+ tdf#142941 Fixes SrcRect implementation in DrawImage record Change-Id: Ice82518d50c50fa6eff8bbcc111fcf287d34d77c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118363 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 3adfb2d35bb34157ce0d1344f2a28b40360728a5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118810 diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 7a2007da07ba..164237b043e3 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1434,21 +1434,30 @@ namespace emfplushelper sal_uInt32 imageAttributesId; sal_Int32 sourceUnit; rMS.ReadUInt32(imageAttributesId).ReadInt32(sourceUnit); -SAL_INFO("drawinglayer.emf", "EMF+\t " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " image attributes Id: " << imageAttributesId << " source unit: " << sourceUnit); +SAL_INFO("drawinglayer.emf", +"EMF+\t " << (type == EmfPlusRecordTypeDrawImage ? "DrawImage" + : "DrawImagePoints") +<< " image attributes Id: " << imageAttributesId +<< " source unit: " << sourceUnit); SAL_INFO("drawinglayer.emf", "EMF+\t TODO: use image attributes"); -// For DrawImage and DrawImagePoints, source unit of measurement type must be 1 pixel +// Source unit of measurement type must be 1 pixel if (sourceUnit == UnitTypePixel && maEMFPObjects[flags & 0xff]) { -EMFPImage& image = *static_cast(maEMFPObjects[flags & 0xff].get()); +EMFPImage& image += *static_cast(maEMFPObjects[flags & 0xff].get()); float sx, sy, sw, sh; ReadRectangle(rMS, sx, sy, sw, sh); ::tools::Rectangle aSource(Point(sx, sy), Size(sw + 1, sh + 1)); -SAL_INFO("drawinglayer.emf", "EMF+\t " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " source rectangle: " << sx << "," << sy << " " << sw << "x" << sh); -::basegfx::B2DPoint aDstPoint; -::basegfx::B2DSize aDstSize; - +SAL_INFO("drawinglayer.emf", +"EMF+\t " +<< (type == EmfPlusRecordTypeDrawImage ? "DrawImage" + : "DrawImagePoints") +<< " source rectangle: " << sx << "," << sy << " " << sw << "x" +<< sh); + +float dx(0.), dy(0.), dw(0.), dh(0.); double fShearX = 0.0; double fShearY = 0.0; if (type == EmfPlusRecordTypeDrawImagePoints) @@ -1457,108 +1466,110 @@ namespace emfplushelper rMS.ReadUInt32(aCount); // Number of points used by DrawImagePoints. Exactly 3 points must be specified. -if(aCount == 3) -{ -float x1, y1, x2, y2, x3, y3; - -ReadPoint(rMS, x1, y1, flags); // upper-left point -ReadPoint(rMS, x2, y2, flags); // upper-right -ReadPoint(rMS, x3, y3, flags); // lower-left - -SAL_INFO("drawinglayer.emf", -
[Libreoffice-commits] core.git: emfio/qa solenv/clang-format
emfio/qa/cppunit/emf/EmfImportTest.cxx | 1026 ++--- solenv/clang-format/excludelist|1 2 files changed, 577 insertions(+), 450 deletions(-) New commits: commit 91082e711db486069313260707954ea6da931634 Author: Bartosz Kosiorek AuthorDate: Tue Jul 13 20:01:53 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jul 13 22:49:04 2021 +0200 Enable automatic code style formatting for EmfImportTest.cxx As EmfImportTest.cxx code style is follow the recommended code style (except too long lines), the code is used only for testing and it is rarely modified, I decided to enable automatic code formatting. It is one step closed to migrate to common code style. Change-Id: I1b7f980b9e68e121ba981b8a8222daa31424ac53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118864 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 8aa1a9dc9b55..1d5d68cf28f8 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -33,7 +33,6 @@ namespace { - using namespace css; using namespace css::uno; using namespace css::io; @@ -142,7 +141,7 @@ Primitive2DSequence Test::parseEmf(std::u16string_view aSource) { const Reference xEmfParser = EmfTools::create(m_xContext); -OUString aUrl = m_directories.getURLFromSrc(aSource); +OUString aUrl = m_directories.getURLFromSrc(aSource); OUString aPath = m_directories.getPathFromSrc(aSource); SvFileStream aFileStream(aUrl, StreamMode::READ); @@ -153,7 +152,7 @@ Primitive2DSequence Test::parseEmf(std::u16string_view aSource) Sequence aData(pBuffer.get(), nSize + 1); Reference aInputStream(new comphelper::SequenceInputStream(aData)); -css::uno::Sequence< css::beans::PropertyValue > aEmptyValues; +css::uno::Sequence aEmptyValues; return xEmfParser->getDecomposition(aInputStream, aPath, aEmptyValues); } @@ -163,22 +162,27 @@ void Test::testPolyPolygon() Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/fdo79679-2.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; -xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +xmlDocUniquePtr pDocument += dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); -CPPUNIT_ASSERT (pDocument); +CPPUNIT_ASSERT(pDocument); // Chart axis assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h19746v14817h-19746z"); assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor", 2); assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[1]", "color", "#ff"); -assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19781v14852h-19781z"); -assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[1]/polypolygon", "path", +"m0 0h19781v14852h-19781z"); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", +"m2574 13194v-12065h15303v12065z"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 116); -assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", "2574,13194 2574,1129 17877,1129 17877,13194"); +assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", + "2574,13194 2574,1129 17877,1129 17877,13194"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff"); -assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", "8674,13194 8674,1129"); +assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", + "8674,13194 8674,1129"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "color", "#00"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 28); @@ -190,7 +194,6 @@ void Test::testPolyPolygon() assertXPath(pDocument, aXPathPrefix + "mask/pointarray[1]", "color", "#00"); assertXPath(pDocument, aXPathPrefix + "mask/pointarray[1]/point", "x", "2574"); assertXPath(pDocument, aXPathPrefix + "mask/pointar
[Libreoffice-commits] core.git: emfio/qa
emfio/qa/cppunit/emf/EmfImportTest.cxx | 699 - 1 file changed, 350 insertions(+), 349 deletions(-) New commits: commit c6447960ce86e9c57eaff79ab44a5c442abe5448 Author: Bartosz Kosiorek AuthorDate: Tue Jul 13 19:59:35 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jul 13 21:41:55 2021 +0200 Decrease line length of EmfImportTest.cxx by introducing const string Change-Id: Ie30d0246d6ca54821f00fe516ab67f803ef0d804 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118863 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index f894c2d9a666..8aa1a9dc9b55 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -44,6 +44,7 @@ using drawinglayer::primitive2d::Primitive2DContainer; class Test : public test::BootstrapFixture, public XmlTestTools, public unotest::MacrosTest { uno::Reference mxComponent; +const OString aXPathPrefix = "/primitive2D/metafile/transform/"; void testPolyPolygon(); void TestDrawImagePointsTypeBitmap(); @@ -167,28 +168,28 @@ void Test::testPolyPolygon() CPPUNIT_ASSERT (pDocument); // Chart axis -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h19746v14817h-19746z"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ff"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19781v14852h-19781z"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); - -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 116); -assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", "2574,13194 2574,1129 17877,1129 17877,13194"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "color", "#ff"); - -assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[10]/polygon", "8674,13194 8674,1129"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[10]/line", "color", "#00"); - -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion", 28); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[6]", "width", "459"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[6]", "x", "9908"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[6]", "text", "0.5"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[6]", "fontcolor", "#00"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray", 98); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray[1]", "color", "#00"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray[1]/point", "x", "2574"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/pointarray[1]/point", "y", "1129"); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h19746v14817h-19746z"); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor", 2); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[1]", "color", "#ff"); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19781v14852h-19781z"); +assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); + +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 116); +assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", "2574,13194 2574,1129 17877,1129 17877,13194"); +assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff"); + +assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", "867
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/emfphelperdata.cxx | 171 ++- 1 file changed, 91 insertions(+), 80 deletions(-) New commits: commit 3adfb2d35bb34157ce0d1344f2a28b40360728a5 Author: Bartosz Kosiorek AuthorDate: Sat Jul 3 21:55:33 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jul 13 21:03:49 2021 +0200 EMF+ tdf#142941 Fixes SrcRect implementation in DrawImage record Change-Id: Ice82518d50c50fa6eff8bbcc111fcf287d34d77c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118363 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 2568cedb453a..d00284509979 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1432,21 +1432,30 @@ namespace emfplushelper sal_uInt32 imageAttributesId; sal_Int32 sourceUnit; rMS.ReadUInt32(imageAttributesId).ReadInt32(sourceUnit); -SAL_INFO("drawinglayer.emf", "EMF+\t " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " image attributes Id: " << imageAttributesId << " source unit: " << sourceUnit); +SAL_INFO("drawinglayer.emf", +"EMF+\t " << (type == EmfPlusRecordTypeDrawImage ? "DrawImage" + : "DrawImagePoints") +<< " image attributes Id: " << imageAttributesId +<< " source unit: " << sourceUnit); SAL_INFO("drawinglayer.emf", "EMF+\t TODO: use image attributes"); -// For DrawImage and DrawImagePoints, source unit of measurement type must be 1 pixel +// Source unit of measurement type must be 1 pixel if (sourceUnit == UnitTypePixel && maEMFPObjects[flags & 0xff]) { -EMFPImage& image = *static_cast(maEMFPObjects[flags & 0xff].get()); +EMFPImage& image += *static_cast(maEMFPObjects[flags & 0xff].get()); float sx, sy, sw, sh; ReadRectangle(rMS, sx, sy, sw, sh); ::tools::Rectangle aSource(Point(sx, sy), Size(sw + 1, sh + 1)); -SAL_INFO("drawinglayer.emf", "EMF+\t " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " source rectangle: " << sx << "," << sy << " " << sw << "x" << sh); -::basegfx::B2DPoint aDstPoint; -::basegfx::B2DSize aDstSize; - +SAL_INFO("drawinglayer.emf", +"EMF+\t " +<< (type == EmfPlusRecordTypeDrawImage ? "DrawImage" + : "DrawImagePoints") +<< " source rectangle: " << sx << "," << sy << " " << sw << "x" +<< sh); + +float dx(0.), dy(0.), dw(0.), dh(0.); double fShearX = 0.0; double fShearY = 0.0; if (type == EmfPlusRecordTypeDrawImagePoints) @@ -1455,108 +1464,110 @@ namespace emfplushelper rMS.ReadUInt32(aCount); // Number of points used by DrawImagePoints. Exactly 3 points must be specified. -if(aCount == 3) -{ -float x1, y1, x2, y2, x3, y3; - -ReadPoint(rMS, x1, y1, flags); // upper-left point -ReadPoint(rMS, x2, y2, flags); // upper-right -ReadPoint(rMS, x3, y3, flags); // lower-left - -SAL_INFO("drawinglayer.emf", - "EMF+\t destination points: " << x1 << ",&
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx| 44 ++-- emfio/qa/cppunit/emf/EmfImportTest.cxx | 34 + emfio/qa/cppunit/emf/data/TestDrawImagePointsTypeBitmap.emf |binary 3 files changed, 73 insertions(+), 5 deletions(-) New commits: commit 032b00382f654962ec787029b3a887f9efbd2a3d Author: Bartosz Kosiorek AuthorDate: Tue Jun 22 14:36:15 2021 +0200 Commit: Xisco Fauli CommitDate: Wed Jul 7 22:00:24 2021 +0200 EMF+ tdf#142941 Fixes for SrcRect in DrawImagePoints The SrcRect could be specified outside of source bitmap. In such cases the Destination bitmap should be displayed as shifted (eg. if position is negative), and scaled properly. Change-Id: Ied6d339703999faaae061802ef6a28e190d5a176 Change-Id: Ia9772ced282684c2c94a261d97d30b53921d6171 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118345 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 4992780d2bc996c111b333549314d72f6891308d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118304 Reviewed-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 23ceb6487d66..7a2007da07ba 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1443,7 +1443,8 @@ namespace emfplushelper EMFPImage& image = *static_cast(maEMFPObjects[flags & 0xff].get()); float sx, sy, sw, sh; ReadRectangle(rMS, sx, sy, sw, sh); -::tools::Rectangle aSource(Point(sx, sy), Size(sw, sh)); + +::tools::Rectangle aSource(Point(sx, sy), Size(sw + 1, sh + 1)); SAL_INFO("drawinglayer.emf", "EMF+\t " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " source rectangle: " << sx << "," << sy << " " << sw << "x" << sh); ::basegfx::B2DPoint aDstPoint; ::basegfx::B2DSize aDstSize; @@ -1464,10 +1465,43 @@ namespace emfplushelper ReadPoint(rMS, x2, y2, flags); // upper-right ReadPoint(rMS, x3, y3, flags); // lower-left -SAL_INFO("drawinglayer.emf", "EMF+\t destination points: P1:" << x1 << "," << y1 << " P2:" << x2 << "," << y2 << " P3:" << x3 << "," << y3); - -aDstPoint = ::basegfx::B2DPoint(x1, y1); -aDstSize = ::basegfx::B2DSize(x2 - x1, y3 - y1); +SAL_INFO("drawinglayer.emf", + "EMF+\t destination points: " << x1 << "," << y1 << " " + << x2 << "," << y2 << " " + << x3 << "," << y3); +float xDstShift = x1; +float yDstShift = y2; +float xDstSize = x2 - x1; +float yDstSize = y3 - y1; +if (image.type == ImageDataTypeBitmap) +{ +const Size aSize(image.graphic.GetBitmapEx().GetSizePixel()); +if (sx < 0) +{ +// If src position is negative then we need shift image to right +xDstShift = xDstShift + ((-sx) / sw) * (x2 - x1); +if (sx + sw <= aSize.Width()) +xDstSize = ((sw + sx) / sw) * xDstSize; +else +xDstSize = (aSize.Width() / sw) * xDstSize; +} +else if (sx + sw > aSize.Width()) +// If the src image is smaller that what we want to cut, then we need to scale down +xDstSize = ((aSize.Width() - sx) / sw) * xDstSize; + +i
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx| 44 ++-- emfio/qa/cppunit/emf/EmfImportTest.cxx | 34 + emfio/qa/cppunit/emf/data/TestDrawImagePointsTypeBitmap.emf |binary 3 files changed, 73 insertions(+), 5 deletions(-) New commits: commit 4992780d2bc996c111b333549314d72f6891308d Author: Bartosz Kosiorek AuthorDate: Tue Jun 22 14:36:15 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Sat Jul 3 14:59:06 2021 +0200 EMF+ tdf#142941 Fixes for SrcRect in DrawImagePoints The SrcRect could be specified outside of source bitmap. In such cases the Destination bitmap should be displayed as shifted (eg. if position is negative), and scaled properly. Change-Id: Ied6d339703999faaae061802ef6a28e190d5a176 Change-Id: Ia9772ced282684c2c94a261d97d30b53921d6171 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118345 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index dff19563002d..2568cedb453a 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1441,7 +1441,8 @@ namespace emfplushelper EMFPImage& image = *static_cast(maEMFPObjects[flags & 0xff].get()); float sx, sy, sw, sh; ReadRectangle(rMS, sx, sy, sw, sh); -::tools::Rectangle aSource(Point(sx, sy), Size(sw, sh)); + +::tools::Rectangle aSource(Point(sx, sy), Size(sw + 1, sh + 1)); SAL_INFO("drawinglayer.emf", "EMF+\t " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " source rectangle: " << sx << "," << sy << " " << sw << "x" << sh); ::basegfx::B2DPoint aDstPoint; ::basegfx::B2DSize aDstSize; @@ -1462,10 +1463,43 @@ namespace emfplushelper ReadPoint(rMS, x2, y2, flags); // upper-right ReadPoint(rMS, x3, y3, flags); // lower-left -SAL_INFO("drawinglayer.emf", "EMF+\t destination points: P1:" << x1 << "," << y1 << " P2:" << x2 << "," << y2 << " P3:" << x3 << "," << y3); - -aDstPoint = ::basegfx::B2DPoint(x1, y1); -aDstSize = ::basegfx::B2DSize(x2 - x1, y3 - y1); +SAL_INFO("drawinglayer.emf", + "EMF+\t destination points: " << x1 << "," << y1 << " " + << x2 << "," << y2 << " " + << x3 << "," << y3); +float xDstShift = x1; +float yDstShift = y2; +float xDstSize = x2 - x1; +float yDstSize = y3 - y1; +if (image.type == ImageDataTypeBitmap) +{ +const Size aSize(image.graphic.GetBitmapEx().GetSizePixel()); +if (sx < 0) +{ +// If src position is negative then we need shift image to right +xDstShift = xDstShift + ((-sx) / sw) * (x2 - x1); +if (sx + sw <= aSize.Width()) +xDstSize = ((sw + sx) / sw) * xDstSize; +else +xDstSize = (aSize.Width() / sw) * xDstSize; +} +else if (sx + sw > aSize.Width()) +// If the src image is smaller that what we want to cut, then we need to scale down +xDstSize = ((aSize.Width() - sx) / sw) * xDstSize; + +if (sy < 0) +{ +yDstShift = yDstShift + ((-sy) / sh) * (y3 - y1);
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 44 ++ drawinglayer/source/tools/emfpstringformat.cxx|8 - emfio/qa/cppunit/emf/EmfImportTest.cxx| 92 ++ emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf |binary 4 files changed, 122 insertions(+), 22 deletions(-) New commits: commit b19b08e51163e949ba4aa656196ebb554ca879a2 Author: Bartosz Kosiorek AuthorDate: Thu Jun 24 18:58:39 2021 +0200 Commit: Xisco Fauli CommitDate: Fri Jul 2 12:50:29 2021 +0200 EMF+ tdf#142995 tdf#142997 tdf#143076 Add alignment support for DrawString With this commit, real size of the text is used to make proper horizontal alignment. Additionally vertical alignment is added and fix for Center alignment was applied Change-Id: I17d9fd7de7f00f5e69f99c5b09061eb6059be67e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117794 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 574dc1e8ff6ea4214fefd91216fca5146a4ff13e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118257 Reviewed-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index e756b16ff70f..23ceb6487d66 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1568,25 +1569,35 @@ namespace emfplushelper css::lang::Locale locale; double stringAlignmentHorizontalOffset = 0.0; +double stringAlignmentVerticalOffset = font->emSize; if (stringFormat) { -SAL_WARN_IF(stringFormat->DirectionRightToLeft(), "drawinglayer.emf", "EMF+\t DrawString Alignment TODO For a right-to-left layout rectangle, the origin should be at the upper right."); +LanguageTag aLanguageTag(static_cast(stringFormat->language)); +locale = aLanguageTag.getLocale(); +drawinglayer::primitive2d::TextLayouterDevice aTextLayouter; + +aTextLayouter.setFontAttribute(fontAttribute, font->emSize, +font->emSize, locale); + +double fTextWidth = aTextLayouter.getTextWidth(text, 0, stringLength); +SAL_WARN_IF(stringFormat->DirectionRightToLeft(), "drawinglayer.emf", +"EMF+\t DrawString Alignment TODO For a right-to-left layout rectangle, the origin should be at the upper right."); if (stringFormat->stringAlignment == StringAlignmentNear) -// Alignment is to the left side of the layout rectangle (lx, ly, lw, lh) -{ +// Alignment is to the left side of the layout rectangle (lx, ly, lw, lh) stringAlignmentHorizontalOffset = stringFormat->leadingMargin * font->emSize; -} else if (stringFormat->stringAlignment == StringAlignmentCenter) -// Alignment is centered between the origin and extent of the layout rectangle -{ -stringAlignmentHorizontalOffset = 0.5 * lw + stringFormat->leadingMargin * font->emSize - 0.3 * font->emSize * stringLength; -} else if (stringFormat->stringAlignment == StringAlignmentFar) -// Alignment is to the right side of the layout rectangle -{ -stringAlignmentHorizontalOffset = lw - stringFormat->trailingMargin * font->emSize - 0.6 * font->emSize * stringLength; -} - -LanguageTag aLanguageTag(static_cast< LanguageType >(stringFormat->language)); -locale = aLanguageTag.getLocale(); +else if (stringFormat->stringAlignment == StringAlignmentCenter) +// Alignment is centered between the origin and extent of the layout rectangle +stringAlignmentHorizontalOffset = 0.5 * lw + (stringFormat->leadingMargin - stringFormat->trailingMargin) * font->emSize - 0.5 * fTextWidth; +else if (stringFormat->stringAlignment == StringAlignmentFar) +// Alignment is to the right side of the layout rectangle +stringAlignmentHorizontalOffset = lw - stringFormat->trailin
[Libreoffice-commits] core.git: drawinglayer/source solenv/clang-format
drawinglayer/source/tools/primitive2dxmldump.cxx | 193 +-- solenv/clang-format/excludelist |1 2 files changed, 117 insertions(+), 77 deletions(-) New commits: commit 09218e0d4a0727bbf385f80c538da9e76e89dbc4 Author: Bartosz Kosiorek AuthorDate: Fri Jul 2 00:33:01 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Jul 2 04:08:15 2021 +0200 Fix code style for primitive2dxmldump.cxx Because the primitive2dxmldump.cxx file has already code style similar to desired (76 lines out of 631 need mofication), with this commit I enabled clang-format on drawinglayer/source/tools/primitive2dxmldump.cxx It will allow to keep the same code style in all LO components. Change-Id: I76fbd704ab51fd685bf400d71d24a7abe48049d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118247 Tested-by: Bartosz Kosiorek Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 4b0c47f41da0..d48115baafa6 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -46,10 +46,8 @@ using namespace drawinglayer::primitive2d; namespace drawinglayer { - namespace { - const size_t constMaxActionType = 513; OUString convertColorToString(const basegfx::BColor& rColor) @@ -60,15 +58,15 @@ OUString convertColorToString(const basegfx::BColor& rColor) void writeMatrix(::tools::XmlWriter& rWriter, const basegfx::B2DHomMatrix& rMatrix) { -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)); +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)); } void writePolyPolygon(::tools::XmlWriter& rWriter, const basegfx::B2DPolyPolygon& rB2DPolyPolygon) @@ -83,12 +81,12 @@ void writePolyPolygon(::tools::XmlWriter& rWriter, const basegfx::B2DPolyPolygon rWriter.attributeDouble("maxy", aB2DRange.getMaxY()); rWriter.attribute("path", basegfx::utils::exportToSvgD(rB2DPolyPolygon, true, true, false)); -for (basegfx::B2DPolygon const & rPolygon : rB2DPolyPolygon) +for (basegfx::B2DPolygon const& rPolygon : rB2DPolyPolygon) { rWriter.startElement("polygon"); -for (sal_uInt32 i = 0; i (xPrimitive2DReference.get()); +drawinglayer::primitive2d::Primitive2DReference xPrimitive2DReference += rPrimitive2DSequence[i]; +const BasePrimitive2D* pBasePrimitive += dynamic_cast(xPrimitive2DReference.get()); if (!pBasePrimitive) continue; sal_uInt32 nId = pBasePrimitive->getPrimitive2DID(); @@ -224,7 +226,8 @@ void Primitive2dXmlDump::decomposeAndWrite( { case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D: { -const BitmapPrimitive2D& rBitmapPrimitive2D = dynamic_cast(*pBasePrimitive); +const BitmapPrimitive2D& rBitmapPrimitive2D += dynamic_cast(*pBasePrimitive); rWriter.startElement("bitmap"); writeMatrix(rWriter, rBitmapPrimitive2D.getTransform()); @@ -233,16 +236,15 @@ void Primitive2dXmlDump::decomposeAndWrite( rWriter.attribute("height", rSizePixel.getHeight()); rWriter.attribute("width", rSizePixel.getWidth()); -rWriter.attribute("checksum", OString(std::to_string( aBitmapEx.GetChecksum() ))); +rWriter.attribute("checksum", OString(std::to_string(aBitmapEx.GetChecksum(; -for (tools::Long y=0; y(*pBasePrimitive); +const HiddenGeometryPrimitive2D& rHiddenGeometryPrimitive2D += dynamic_cast(*pBasePrimitive); rWriter.startElement("hiddengeometry"); decomposeAndWrite(rHiddenGeometryPrimitive2D.getChildren(), rWriter)
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa
drawinglayer/source/tools/emfphelperdata.cxx | 44 ++ drawinglayer/source/tools/emfpstringformat.cxx|8 - emfio/qa/cppunit/emf/EmfImportTest.cxx| 92 ++ emfio/qa/cppunit/emf/data/TestDrawStringAlign.emf |binary 4 files changed, 122 insertions(+), 22 deletions(-) New commits: commit 574dc1e8ff6ea4214fefd91216fca5146a4ff13e Author: Bartosz Kosiorek AuthorDate: Thu Jun 24 18:58:39 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Jul 1 23:50:31 2021 +0200 EMF+ tdf#142995 tdf#142997 tdf#143076 Add alignment support for DrawString With this commit, real size of the text is used to make proper horizontal alignment. Additionally vertical alignment is added and fix for Center alignment was applied Change-Id: I17d9fd7de7f00f5e69f99c5b09061eb6059be67e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117794 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index b052c1551d69..dff19563002d 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1566,25 +1567,35 @@ namespace emfplushelper css::lang::Locale locale; double stringAlignmentHorizontalOffset = 0.0; +double stringAlignmentVerticalOffset = font->emSize; if (stringFormat) { -SAL_WARN_IF(stringFormat->DirectionRightToLeft(), "drawinglayer.emf", "EMF+\t DrawString Alignment TODO For a right-to-left layout rectangle, the origin should be at the upper right."); +LanguageTag aLanguageTag(static_cast(stringFormat->language)); +locale = aLanguageTag.getLocale(); +drawinglayer::primitive2d::TextLayouterDevice aTextLayouter; + +aTextLayouter.setFontAttribute(fontAttribute, font->emSize, +font->emSize, locale); + +double fTextWidth = aTextLayouter.getTextWidth(text, 0, stringLength); +SAL_WARN_IF(stringFormat->DirectionRightToLeft(), "drawinglayer.emf", +"EMF+\t DrawString Alignment TODO For a right-to-left layout rectangle, the origin should be at the upper right."); if (stringFormat->stringAlignment == StringAlignmentNear) -// Alignment is to the left side of the layout rectangle (lx, ly, lw, lh) -{ +// Alignment is to the left side of the layout rectangle (lx, ly, lw, lh) stringAlignmentHorizontalOffset = stringFormat->leadingMargin * font->emSize; -} else if (stringFormat->stringAlignment == StringAlignmentCenter) -// Alignment is centered between the origin and extent of the layout rectangle -{ -stringAlignmentHorizontalOffset = 0.5 * lw + stringFormat->leadingMargin * font->emSize - 0.3 * font->emSize * stringLength; -} else if (stringFormat->stringAlignment == StringAlignmentFar) -// Alignment is to the right side of the layout rectangle -{ -stringAlignmentHorizontalOffset = lw - stringFormat->trailingMargin * font->emSize - 0.6 * font->emSize * stringLength; -} - -LanguageTag aLanguageTag(static_cast< LanguageType >(stringFormat->language)); -locale = aLanguageTag.getLocale(); +else if (stringFormat->stringAlignment == StringAlignmentCenter) +// Alignment is centered between the origin and extent of the layout rectangle +stringAlignmentHorizontalOffset = 0.5 * lw + (stringFormat->leadingMargin - stringFormat->trailingMargin) * font->emSize - 0.5 * fTextWidth; +else if (stringFormat->stringAlignment == StringAlignmentFar) +// Alignment is to the right side of the layout rectangle +stringAlignmentHorizontalOffset = lw - stringFormat->trailingMargin * font->emSize - fTextWidth; + +if (stringFormat->lineAlign == StringAlignmentNear) +stringAli
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - drawinglayer/source emfio/qa svgio/qa svx/qa
drawinglayer/source/tools/emfphelperdata.cxx | 267 -- drawinglayer/source/tools/primitive2dxmldump.cxx | 82 +++-- emfio/qa/cppunit/emf/EmfImportTest.cxx| 46 ++- emfio/qa/cppunit/emf/data/TestDrawStringWithBrush.emf |binary svgio/qa/cppunit/SvgImportTest.cxx|4 svx/qa/unit/sdr.cxx |8 svx/qa/unit/svdraw.cxx|6 7 files changed, 216 insertions(+), 197 deletions(-) New commits: commit 1eb828add814108d63ea61e38d948a0337fc4ee6 Author: Bartosz Kosiorek AuthorDate: Wed Jun 23 16:55:21 2021 +0200 Commit: Xisco Fauli CommitDate: Thu Jun 24 10:30:30 2021 +0200 EMF+ tdf#142975 Add brush support to DrawString record Change-Id: Icfcb4199dcd755fb20e14a8166571b6d6e763f2e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117671 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 9e8c35cc3f1f5e1c08afd46e0d0fbc07f1ff21f9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117721 Reviewed-by: Xisco Fauli diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 1f3143112320..e756b16ff70f 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -457,12 +457,14 @@ namespace emfplushelper color = Color(ColorAlpha, (brushIndexOrColor >> 24), (brushIndexOrColor >> 16) & 0xff, (brushIndexOrColor >> 8) & 0xff, brushIndexOrColor & 0xff); } -else // we use a pen +else // we use a brush { -const EMFPPen* pen = static_cast(maEMFPObjects[brushIndexOrColor & 0xff].get()); -if (pen) +const EMFPBrush* brush = static_cast(maEMFPObjects[brushIndexOrColor & 0xff].get()); +if (brush) { -color = pen->GetColor(); +color = brush->GetColor(); +if (brush->type != BrushTypeSolidColor) +SAL_WARN("drawinglayer.emf", "EMF+\t\t TODO Brush other than solid color is not supported"); } } return color; @@ -1527,161 +1529,152 @@ namespace emfplushelper } case EmfPlusRecordTypeDrawString: { -sal_uInt32 brushId; -sal_uInt32 formatId; -sal_uInt32 stringLength; +sal_uInt32 brushId, formatId, stringLength; rMS.ReadUInt32(brushId).ReadUInt32(formatId).ReadUInt32(stringLength); SAL_INFO("drawinglayer.emf", "EMF+\t FontId: " << OUString::number(flags & 0xFF)); SAL_INFO("drawinglayer.emf", "EMF+\t BrushId: " << BrushIDToString(flags, brushId)); SAL_INFO("drawinglayer.emf", "EMF+\t FormatId: " << formatId); SAL_INFO("drawinglayer.emf", "EMF+\t Length: " << stringLength); -if (flags & 0x8000) +// read the layout rectangle +float lx, ly, lw, lh; + rMS.ReadFloat(lx).ReadFloat(ly).ReadFloat(lw).ReadFloat(lh); + +SAL_INFO("drawinglayer.emf", "EMF+\t DrawString layoutRect: " << lx << "," << ly << " - " << lw << "x" << lh); +// parse the string +const OUString text = read_uInt16s_ToOUString(rMS, stringLength); +SAL_INFO("drawinglayer.emf", "EMF+\t DrawString string: " << text); +// get the stringFormat from the Object table ( this is OPTIONAL and may be nullptr ) +const EMFPStringFormat *stringFormat = dynamic_cast(maEMFPObjects[formatId & 0xff].get()); +// get the font from the flags +const EMFPFont *font = static_cast< EMFPFont* >( maEMFPObjects[flags & 0xff].get() ); +if (!font) { -// read the layout rectangle -float lx, ly, lw, lh; - rMS.ReadFloat(lx).ReadFloat(ly).ReadFloat(lw).ReadFloat(lh); - -SAL_INFO("drawinglayer.emf", "EMF+\t DrawString layoutRect: " << lx << "," << ly << " - " << lw << "x" << lh); -// parse the string -
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa svgio/qa svx/qa
drawinglayer/source/tools/emfphelperdata.cxx | 267 -- drawinglayer/source/tools/primitive2dxmldump.cxx | 82 +++-- emfio/qa/cppunit/emf/EmfImportTest.cxx| 46 ++- emfio/qa/cppunit/emf/data/TestDrawStringWithBrush.emf |binary svgio/qa/cppunit/SvgImportTest.cxx|4 svx/qa/unit/sdr.cxx |8 svx/qa/unit/svdraw.cxx|6 7 files changed, 216 insertions(+), 197 deletions(-) New commits: commit 9e8c35cc3f1f5e1c08afd46e0d0fbc07f1ff21f9 Author: Bartosz Kosiorek AuthorDate: Wed Jun 23 16:55:21 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Wed Jun 23 18:24:38 2021 +0200 EMF+ tdf#142975 Add brush support to DrawString record Change-Id: Icfcb4199dcd755fb20e14a8166571b6d6e763f2e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117671 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index b56e51000211..b052c1551d69 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -456,12 +456,14 @@ namespace emfplushelper color = Color(ColorAlpha, (brushIndexOrColor >> 24), (brushIndexOrColor >> 16) & 0xff, (brushIndexOrColor >> 8) & 0xff, brushIndexOrColor & 0xff); } -else // we use a pen +else // we use a brush { -const EMFPPen* pen = static_cast(maEMFPObjects[brushIndexOrColor & 0xff].get()); -if (pen) +const EMFPBrush* brush = static_cast(maEMFPObjects[brushIndexOrColor & 0xff].get()); +if (brush) { -color = pen->GetColor(); +color = brush->GetColor(); +if (brush->type != BrushTypeSolidColor) +SAL_WARN("drawinglayer.emf", "EMF+\t\t TODO Brush other than solid color is not supported"); } } return color; @@ -1525,161 +1527,152 @@ namespace emfplushelper } case EmfPlusRecordTypeDrawString: { -sal_uInt32 brushId; -sal_uInt32 formatId; -sal_uInt32 stringLength; +sal_uInt32 brushId, formatId, stringLength; rMS.ReadUInt32(brushId).ReadUInt32(formatId).ReadUInt32(stringLength); SAL_INFO("drawinglayer.emf", "EMF+\t FontId: " << OUString::number(flags & 0xFF)); SAL_INFO("drawinglayer.emf", "EMF+\t BrushId: " << BrushIDToString(flags, brushId)); SAL_INFO("drawinglayer.emf", "EMF+\t FormatId: " << formatId); SAL_INFO("drawinglayer.emf", "EMF+\t Length: " << stringLength); -if (flags & 0x8000) +// read the layout rectangle +float lx, ly, lw, lh; + rMS.ReadFloat(lx).ReadFloat(ly).ReadFloat(lw).ReadFloat(lh); + +SAL_INFO("drawinglayer.emf", "EMF+\t DrawString layoutRect: " << lx << "," << ly << " - " << lw << "x" << lh); +// parse the string +const OUString text = read_uInt16s_ToOUString(rMS, stringLength); +SAL_INFO("drawinglayer.emf", "EMF+\t DrawString string: " << text); +// get the stringFormat from the Object table ( this is OPTIONAL and may be nullptr ) +const EMFPStringFormat *stringFormat = dynamic_cast(maEMFPObjects[formatId & 0xff].get()); +// get the font from the flags +const EMFPFont *font = static_cast< EMFPFont* >( maEMFPObjects[flags & 0xff].get() ); +if (!font) { -// read the layout rectangle -float lx, ly, lw, lh; - rMS.ReadFloat(lx).ReadFloat(ly).ReadFloat(lw).ReadFloat(lh); - -SAL_INFO("drawinglayer.emf", "EMF+\t DrawString layoutRect: " << lx << "," << ly << " - " << lw << "x" << lh); -// parse the string -const OUString text = read_uInt16s_ToOUString(rMS, stringLength); -SAL_INFO("drawinglayer.emf"
[Libreoffice-commits] core.git: emfio/source
emfio/source/reader/emfreader.cxx | 165 ++ 1 file changed, 82 insertions(+), 83 deletions(-) New commits: commit e48463e81c7eb9a3938128b642d153917fcbbdae Author: Bartosz Kosiorek AuthorDate: Fri Jun 18 13:03:09 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Jun 18 19:11:37 2021 +0200 Resolves: ofz#34920 allow displaying only one text string Change-Id: I8bc4ed015dfad4fd99ca8cfce7fca0e7b411edf3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117443 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 4ad77dd3fb32..1b9e8ec34326 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1826,112 +1826,111 @@ namespace emfio { mpInputStream->ReadUInt32( ncStrings ); SAL_INFO("emfio", "\t\t Number of Text objects: " << ncStrings); +if ( ncStrings == 0 ) +break; } -for (sal_uInt32 nStringNo = 0; nStringNo < ncStrings && mpInputStream->good(); ++nStringNo) +mpInputStream->ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadUInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions ); +SAL_INFO("emfio", "\t\tReference: (" << ptlReferenceX << ", " << ptlReferenceY << ")"); + +mpInputStream->ReadInt32( nLeftRect ).ReadInt32( nTopRect ).ReadInt32( nRightRect ).ReadInt32( nBottomRect ); +const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect ); +const BkMode mnBkModeBackup = mnBkMode; +if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background +mnBkMode = BkMode::Transparent; +else if ( nOptions & ETO_OPAQUE ) +DrawRectWithBGColor( aRect ); +mpInputStream->ReadUInt32( offDx ); + +ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; +if ( nOptions & ETO_RTLREADING ) +nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft; +SetTextLayoutMode( nTextLayoutMode ); +SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "emfio", "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" ); + +Point aPos( ptlReferenceX, ptlReferenceY ); +bool bOffStringSane = nOffString <= mnEndPos - nCurPos; +if ( bOffStringSane ) { -mpInputStream->ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadUInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions ); -SAL_INFO("emfio", "\t\tReference: (" << ptlReferenceX << ", " << ptlReferenceY << ")"); - -mpInputStream->ReadInt32( nLeftRect ).ReadInt32( nTopRect ).ReadInt32( nRightRect ).ReadInt32( nBottomRect ); -const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect ); -const BkMode mnBkModeBackup = mnBkMode; -if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background -mnBkMode = BkMode::Transparent; -else if ( nOptions & ETO_OPAQUE ) -DrawRectWithBGColor( aRect ); -mpInputStream->ReadUInt32( offDx ); - -ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; -if ( nOptions & ETO_RTLREADING ) -nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft; -SetTextLayoutMode( nTextLayoutMode ); -SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "emfio", "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" ); - -Point aPos( ptlReferenceX, ptlReferenceY ); -bool bOffStringSane = nOffString <= mnEndPos - nCurPos; -if ( bOffStringSane ) +mpInputStream->Seek( nCurPos + nOffString ); +
[Libreoffice-commits] core.git: drawinglayer/source emfio/source
drawinglayer/source/tools/emfphelperdata.cxx | 22 --- drawinglayer/source/tools/emfppath.cxx | 31 +-- drawinglayer/source/tools/emfppath.hxx |4 +-- emfio/source/reader/wmfreader.cxx| 10 ++-- 4 files changed, 34 insertions(+), 33 deletions(-) New commits: commit befa3f75fd7bf5ef35741d099ab18e94f10e4e1d Author: Bartosz Kosiorek AuthorDate: Mon Jun 14 12:50:19 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Jun 17 18:24:57 2021 +0200 EMF+ WMF Update the variable names and add additional TODO warnings Change-Id: I78b05fe3c293494195bdd37c3030147b1f21228e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117148 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 1f3143112320..b56e51000211 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -281,16 +281,15 @@ namespace emfplushelper } case EmfPlusObjectTypePath: { -sal_uInt32 header, pathFlags; -sal_Int32 points; - - rObjectStream.ReadUInt32(header).ReadInt32(points).ReadUInt32(pathFlags); -SAL_INFO("drawinglayer.emf", "EMF+\t\tHeader: 0x" << std::hex << header); -SAL_INFO("drawinglayer.emf", "EMF+\t\tPoints: " << std::dec << points); -SAL_INFO("drawinglayer.emf", "EMF+\t\tAdditional flags: 0x" << std::hex << pathFlags << std::dec); -EMFPPath *path = new EMFPPath(points); +sal_uInt32 aVersion, aPathPointCount, aPathPointFlags; + + rObjectStream.ReadUInt32(aVersion).ReadUInt32(aPathPointCount).ReadUInt32(aPathPointFlags); +SAL_INFO("drawinglayer.emf", "EMF+\t\tVersion: 0x" << std::hex << aVersion); +SAL_INFO("drawinglayer.emf", "EMF+\t\tNumber of points: " << std::dec << aPathPointCount); +SAL_INFO("drawinglayer.emf", "EMF+\t\tPath point flags: 0x" << std::hex << aPathPointFlags << std::dec); +EMFPPath *path = new EMFPPath(aPathPointCount); maEMFPObjects[index].reset(path); -path->Read(rObjectStream, pathFlags); +path->Read(rObjectStream, aPathPointFlags); break; } case EmfPlusObjectTypeRegion: @@ -1336,11 +1335,10 @@ namespace emfplushelper case EmfPlusRecordTypeFillPolygon: { const sal_uInt8 index = flags & 0xff; -sal_uInt32 brushIndexOrColor; -sal_Int32 points; +sal_uInt32 brushIndexOrColor, points; rMS.ReadUInt32(brushIndexOrColor); -rMS.ReadInt32(points); +rMS.ReadUInt32(points); SAL_INFO("drawinglayer.emf", "EMF+\t FillPolygon in slot: " << index << " points: " << points); SAL_INFO("drawinglayer.emf", "EMF+\t " << ((flags & 0x8000) ? "Color" : "Brush index") << " : 0x" << std::hex << brushIndexOrColor << std::dec); diff --git a/drawinglayer/source/tools/emfppath.cxx b/drawinglayer/source/tools/emfppath.cxx index bfb92e0bd4a7..4da379004fba 100644 --- a/drawinglayer/source/tools/emfppath.cxx +++ b/drawinglayer/source/tools/emfppath.cxx @@ -58,11 +58,11 @@ namespace emfplushelper return static_cast(nRet); } -EMFPPath::EMFPPath (sal_Int32 _nPoints, bool bLines) +EMFPPath::EMFPPath (sal_uInt32 _nPoints, bool bLines) { -if (_nPoints<0 || o3tl::make_unsigned(_nPoints)>SAL_MAX_INT32 / (2 * sizeof(float))) +if (_nPoints > SAL_MAX_UINT32 / (2 * sizeof(float))) { -_nPoints = SAL_MAX_INT32 / (2 * sizeof(float)); +_nPoints = SAL_MAX_UINT32 / (2 * sizeof(float)); } nPoints = _nPoints; @@ -78,7 +78,7 @@ namespace emfplushelper void EMFPPath::Read (SvStream& s, sal_uInt32 pathFlags) { -for (int i = 0; i < nPoints; i ++) +for (sal_uInt32 i = 0; i < nPoints; i ++) { if (pathFlags & 0x800) { @@ -89,7 +89,7 @@ namespace emfplushelper sal_Int32 y = GetEmfPlusInteger(s); pPoints [i*2] = x; pPoints [i*2 + 1] = y; -SAL_INFO("drawinglayer.emf", "EMF+\t\t\tEmfPlusPointR [x,y]: "
[Libreoffice-commits] core.git: emfio/source
emfio/source/reader/emfreader.cxx |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit 8d3e7b2f5836106eac5172d8f4868bb540d652e6 Author: Bartosz Kosiorek AuthorDate: Fri Jun 11 13:50:29 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Jun 11 18:41:02 2021 +0200 EMF tdf#59814 tdf#142567 Align RestoreDC record with MSO implementation Some of WMF and EMF behaviours are undocumented. In that case, we are implementing the behaviour, observed in MS Office or MS Paint. With this commit the behaviour of import EMF RestoreDC records, will be the same as for MS Paint and MS Office. Change-Id: I73b65d14018f2667ffd59daf16ecc6d7ce9c1870 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117052 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index ac56c64db026..04f591a7eb9a 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1101,8 +1101,10 @@ namespace emfio sal_Int32 nSavedDC; mpInputStream->ReadInt32( nSavedDC ); SAL_INFO( "emfio", "\t\t SavedDC Index: " << nSavedDC ); -if ( nSavedDC < 0 ) // For EMF values above -1 is ignored +if ( nSavedDC < 0 ) Pop( nSavedDC ); +else +Pop( -1 ); // For RestoreDC values above -1, treat as get last element } break; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |2 emfio/qa/cppunit/emf/EmfImportTest.cxx | 59 emfio/qa/cppunit/emf/data/TestRestoreDC.emf |binary emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf |binary emfio/source/reader/emfreader.cxx |6 ++ emfio/source/reader/mtftools.cxx| 21 - emfio/source/reader/wmfreader.cxx |5 +- 7 files changed, 87 insertions(+), 6 deletions(-) New commits: commit cabb9f5c8e22a23a453559636d9c9b3c2b0a5984 Author: Bartosz Kosiorek AuthorDate: Fri Jun 11 22:25:42 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri Jun 11 12:31:59 2021 +0200 WMF/EMF tdf#59814 tdf#142567 Fix RestoreDC record With previous implementation, the RestoreDC index argument was skipped, and always the last entry was taken. With this commit the support for reading SaveDC by specific index was added. The SaveDC/RestoreDC index support was added for both EMF and WMF, according to [MS-WMF] and [MS-EMF] documentation. Change-Id: I9b8a1a41462ae01de25ac3c85e453bcd80e05537 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117033 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index cffe5e4fa511..456f2349cbf9 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -614,7 +614,7 @@ namespace emfio voidModifyWorldTransform(const XForm& rXForm, sal_uInt32 nMode); voidPush(); -voidPop(); +voidPop( const sal_Int32 nSavedDC = -1 ); WMFRasterOp SetRasterOp(WMFRasterOp nRasterOp); voidStrokeAndFillPath(bool bStroke, bool bFill); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 8c56190203b0..1383b5fdfc03 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -65,10 +65,13 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestBitBltStretchBltWMF(); void TestExtTextOutOpaqueAndClipWMF(); void TestPaletteWMF(); +void TestRestoreDCWMF(); void TestRoundrectWMF(); void TestStretchDIBWMF(); void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); + +void TestRestoreDC(); void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -101,10 +104,12 @@ public: CPPUNIT_TEST(TestBitBltStretchBltWMF); CPPUNIT_TEST(TestExtTextOutOpaqueAndClipWMF); CPPUNIT_TEST(TestPaletteWMF); +CPPUNIT_TEST(TestRestoreDCWMF); CPPUNIT_TEST(TestRoundrectWMF); CPPUNIT_TEST(TestStretchDIBWMF); CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); +CPPUNIT_TEST(TestRestoreDC); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); @@ -699,6 +704,7 @@ void Test::TestExtTextOutOpaqueAndClipWMF() #endif } + void Test::TestPaletteWMF() { // WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE. @@ -735,6 +741,40 @@ void Test::TestPaletteWMF() "width", "132"); } +void Test::TestRestoreDCWMF() +{ +// WMF records: RESTOREDC, SAVEDC, CREATEBRUSHINDIRECT, RECTANGLE. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRestoreDC.wmf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 3); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", +"color", "#ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", +"path", "m238 2884h1640v1110h-1640z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]", +"color", "#00"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]/polygon", + "238,2884 1878,2884 1878,3994 238,3994"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]", +"color", "#ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]/polypolygon", +"path", "m238 238h1640v1110h-1640z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]",
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source
emfio/source/reader/emfreader.cxx | 33 - 1 file changed, 20 insertions(+), 13 deletions(-) New commits: commit b20b7339f1786d27fec3787f3567c234757d3959 Author: Bartosz Kosiorek AuthorDate: Thu Jun 10 15:54:38 2021 +0200 Commit: Xisco Fauli CommitDate: Fri Jun 11 11:05:36 2021 +0200 EMF tdf#142745 Improve performance of FILLRGN, PAINTRGN, EXTSELECTCLIPRGN With previous implementation, during reading of rectangles the optimizations were made after reading every single rectangle. This was causing performance issues, with many rectangles (eg. 2500 rectangles). With this commit, the optimization is made after reading all rectangles. It is improving performance of FILLRGN, PAINTRGN and EXTSELECTCLIPRGN records. Change-Id: I1b8b844efddd08e9bf6f6726c3fdf213a629883f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116996 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117022 diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 2ef29fd98dcc..144cab9f0021 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -16,7 +16,8 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include +#include #include #include #include @@ -327,7 +328,7 @@ SvStream& operator>>(SvStream& rInStream, BLENDFUNCTION& rBlendFun) return rInStream; } -bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen ) +bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen ) { if (nLen < 32) // 32 bytes - Size of RegionDataHeader return false; @@ -348,7 +349,7 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt3 if (!rStream.good() || nCountRects == 0 || nType != RDH_RECTANGLES) return false; -SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); +SAL_INFO("emfio", "\t\tBounds Left: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); nLen -= 32; @@ -364,11 +365,12 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt3 rStream.ReadInt32(nTop); rStream.ReadInt32(nRight); rStream.ReadInt32(nBottom); - -SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); -tools::PolyPolygon aPolyPolyOr1(tools::Polygon(tools::Rectangle(nLeft, nTop, nRight, nBottom))); -rPolyPoly.GetUnion(aPolyPolyOr1, rPolyPoly); +rPolyPoly.append( basegfx::utils::createPolygonFromRect( ::basegfx::B2DRectangle( nLeft, nTop, nRight, nBottom ) ) ); +SAL_INFO("emfio", "\t\t" << i << " Left: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); } +rPolyPoly = basegfx::utils::solveCrossovers(rPolyPoly); +rPolyPoly = basegfx::utils::stripNeutralPolygons(rPolyPoly); +rPolyPoly = basegfx::utils::stripDispensablePolygons(rPolyPoly); return true; } @@ -1453,10 +1455,11 @@ namespace emfio } else { -tools::PolyPolygon aPolyPoly; +basegfx::B2DPolyPolygon aPolyPoly; if (cbRgnData) ImplReadRegion(aPolyPoly, *mpInputStream, nRemainingRecSize); -SetClipPath(aPolyPoly, nClippingMode, false); +const tools::PolyPolygon aPolyPolygon(aPolyPoly); +SetClipPath(aPolyPolygon, nClippingMode, false); } } } @@ -1934,7 +1937,7 @@ namespace emfio else { sal_uInt32 nRgnDataSize; -tools::PolyPolygon aPolyPoly; +basegfx::B2DPolyPolygon aPolyPoly; mpInputStream->SeekRel(16); // RectL bounds mpInputStream->ReadUInt32( nRgnDataSize
[Libreoffice-commits] core.git: emfio/source
emfio/source/reader/emfreader.cxx | 39 +++--- 1 file changed, 20 insertions(+), 19 deletions(-) New commits: commit 363b98b268f317e7f2f9af392085856b938fb5f9 Author: Bartosz Kosiorek AuthorDate: Thu Jun 10 15:54:38 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu Jun 10 18:49:52 2021 +0200 EMF tdf#142745 Improve performance of FILLRGN, PAINTRGN, EXTSELECTCLIPRGN With previous implementation, during reading of rectangles the optimizations were made after reading every single rectangle. This was causing performance issues, with many rectangles (eg. 2500 rectangles). With this commit, the optimization is made after reading all rectangles. It is improving performance of FILLRGN, PAINTRGN and EXTSELECTCLIPRGN records. Change-Id: I1b8b844efddd08e9bf6f6726c3fdf213a629883f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116996 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index dc5941493058..064a8b0334c9 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -16,7 +16,8 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include +#include #include #include #include @@ -329,7 +330,7 @@ SvStream& operator>>(SvStream& rInStream, BLENDFUNCTION& rBlendFun) return rInStream; } -bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen ) +bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen ) { if (nLen < 32) // 32 bytes - Size of RegionDataHeader return false; @@ -350,7 +351,7 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt3 if (!rStream.good() || nCountRects == 0 || nType != RDH_RECTANGLES) return false; -SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); +SAL_INFO("emfio", "\t\tBounds Left: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); nLen -= 32; @@ -360,23 +361,18 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt3 if (nLen < nSize) return false; -bool bIsFuzzing = utl::ConfigManager::IsFuzzing(); - for (sal_uInt32 i = 0; i < nCountRects; ++i) { rStream.ReadInt32(nLeft); rStream.ReadInt32(nTop); rStream.ReadInt32(nRight); rStream.ReadInt32(nBottom); - -SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); - -if (bIsFuzzing && i) // GetUnion is super slow, when fuzzing skip after first rect -continue; - -tools::PolyPolygon aPolyPolyOr1(tools::Polygon(tools::Rectangle(nLeft, nTop, nRight, nBottom))); -rPolyPoly.GetUnion(aPolyPolyOr1, rPolyPoly); +rPolyPoly.append( basegfx::utils::createPolygonFromRect( ::basegfx::B2DRectangle( nLeft, nTop, nRight, nBottom ) ) ); +SAL_INFO("emfio", "\t\t" << i << " Left: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); } +rPolyPoly = basegfx::utils::solveCrossovers(rPolyPoly); +rPolyPoly = basegfx::utils::stripNeutralPolygons(rPolyPoly); +rPolyPoly = basegfx::utils::stripDispensablePolygons(rPolyPoly); return true; } @@ -1461,10 +1457,11 @@ namespace emfio } else { -tools::PolyPolygon aPolyPoly; +basegfx::B2DPolyPolygon aPolyPoly; if (cbRgnData) ImplReadRegion(aPolyPoly, *mpInputStream, nRemainingRecSize); -SetClipPath(aPolyPoly, nClippingMode, false); +const tools::PolyPolygon aPolyPolygon(aPolyPoly); +SetClipPath(aPolyPolygon, nClippingMode, false); } } } @@ -1968,7 +1965,7 @@ namespace emfio else { sal_uInt32 nRgnDataSize; -tools::PolyPolygon aPo
[Libreoffice-commits] core.git: drawinglayer/source emfio/qa emfio/source include/vcl vcl/source
drawinglayer/source/tools/primitive2dxmldump.cxx | 16 ++ emfio/qa/cppunit/emf/EmfImportTest.cxx | 82 + emfio/qa/cppunit/wmf/data/TestBitBltStretchBlt.wmf |binary emfio/source/reader/wmfreader.cxx | 124 +++-- include/vcl/BitmapTools.hxx|2 vcl/source/bitmap/BitmapTools.cxx | 15 +- 6 files changed, 151 insertions(+), 88 deletions(-) New commits: commit 01ded1e6d362dbcd7148334c6965d6ad00981d4a Author: Bartosz Kosiorek AuthorDate: Tue Jun 8 23:07:28 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Wed Jun 9 20:19:27 2021 +0200 WMF tdf#55058 tdf#142722 Add implementation of BitBlt and StretchBlt With previous implementation, only BitBlt record with 1 bit color depth was supported and StretchBlt was not implemented at all. With this commit the support for 1 bit, 24 bit and 32 bit, for both BitBlt and StretchBlt were added. Change-Id: I061b2beae8c2f143ddff9c8c8bb64bf52f4cf502 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116873 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 295c13fde6e9..9ed0e796fb01 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -228,8 +228,22 @@ void Primitive2dXmlDump::decomposeAndWrite( rWriter.attribute("height", rSizePixel.getHeight()); rWriter.attribute("width", rSizePixel.getWidth()); -rWriter.attribute("checksum", aBitmapEx.GetChecksum()); +rWriter.attribute("checksum", OString(std::to_string( aBitmapEx.GetChecksum() ))); +for (tools::Long y=0; y(aSequence)); CPPUNIT_ASSERT (pDocument); - assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion", 2); assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[1]", "text", "No_rect- DLP-"); @@ -576,6 +577,73 @@ void Test::TestExtTextOutOpaqueAndClipTransform() "fontcolor", "#00"); } +void Test::TestBitBltStretchBltWMF() +{ +// tdf#55058 tdf#142722 WMF records: BITBLT, STRETCHBLT. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestBitBltStretchBlt.wmf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"xy11", "508"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"xy12", "0"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"xy13", "711"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"xy21", "0"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"xy22", "508"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"xy23", "508"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"height", "10"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"width", "10"); +#if !defined(MACOSX) && !defined(_WIN32) // TODO Bitmap display needs to be aligned for macOS and Windows +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]", +"checksum", "747141214295528493"); +#endif +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]/data", +10); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]/data[1]", +"row", "00,00,00,00,00,00,00,00,00,00"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]/data[4]", +"row", "00,ff,00,ff,00,ff,00,ff,00,ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap[1]/data[5]", +"row", "ff,00,ff,ff,00,00,00,ff,ff,00&quo
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 22 - emfio/source/reader/wmfreader.cxx | 73 +++-- 2 files changed, 45 insertions(+), 50 deletions(-) New commits: commit b6a30a9db00f92eec7387a577321d65d47ff4af5 Author: Bartosz Kosiorek AuthorDate: Tue Jun 8 12:28:48 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jun 8 22:40:01 2021 +0200 WMF tdf#142625 Refactor Bitmap records, to better handle missing features Change-Id: If3334158e6e0ef9bc3aa33656ad0ee45cf460dbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116827 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 2ad512d0bac1..d949240a40b5 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -696,25 +696,25 @@ void Test::TestStretchDIBWMF() xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); CPPUNIT_ASSERT (pDocument); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "xy11", "12065"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "xy12", "0"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", -"xy13", "3598"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", +"xy13", "0"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "xy21", "0"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "xy22", "12065"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", -"xy23", "3598"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", +"xy23", "0"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "height", "10"); -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "width", "10"); #if !defined(MACOSX) // TODO DIB display needs to be fixed for macOS -assertXPath(pDocument, "/primitive2D/metafile/transform/bitmap", +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/bitmap", "checksum", "275245357"); #endif } diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 73d059aa5df3..65c2cff1f465 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -803,14 +803,14 @@ namespace emfio case W_META_BITBLT: { -// 0-3 : nRasterOperation #93454# +// 0-3 : nRasterOperation#93454# // 4-5 : y offset of source bitmap // 6-7 : x offset of source bitmap -// 8-9 : used height of source bitmap -// 10-11 : used width of source bitmap +// 8-9 : height of source and destination bitmap +// 10-11 : width of source and destination bitmap // 12-13 : destination position y (in pixel) // 14-15 : destination position x (in pixel) -// 16-17 : don't know +// 16-17 : bitmap type // 18-19 : Width Bitmap in Pixel // 20-21 : Height Bitmap in Pixel // 22-23 : bytes per scanline @@ -818,26 +818,31 @@ namespace emfio // 25: bitcount sal_uInt32 nRasterOperation = 0; -sal_uInt16 nYSrc = 0, nXSrc = 0, nSye = 0, nSxe = 0, nBitmapType = 0, nWidth = 0, nHeight = 0, nBytesPerScan = 0; +sal_Int16 nYSrc = 0, nXSrc = 0, nSye = 0, nSxe = 0, nBitmapType = 0, nWidth = 0, nHeight = 0, nBytesPerScan = 0; sal_uInt8 nPlanes, nBitCount; +const bool bNoSourceBitmap = ( nRecordSize == ( static_cast< sal_uInt32 >( nFunc ) >> 8 ) + 3 ); mpInputStream->ReadUInt32( nRasterOpera
[Libreoffice-commits] core.git: emfio/source vcl/source
emfio/source/reader/wmfreader.cxx | 41 ++ vcl/source/bitmap/dibtools.cxx|2 - 2 files changed, 34 insertions(+), 9 deletions(-) New commits: commit 6bebaddb39849422dffa16316c543fc69305f31a Author: Bartosz Kosiorek AuthorDate: Sun Jun 6 21:32:47 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Mon Jun 7 13:36:57 2021 +0200 WMF tdf#142625 Continue read records if unimlemented features found Most of DIB records (DIBCREATEPATTERNBRUSH, STRETCHDIB) are implemented partially. If the unimplemted feature are inside WMF, then the whole reading steam is interrupted and nothing is displayed. With this commit if DIB record used missing feature, then the warning is displayed, and the displaying continue. The fix allows for displaying WMF image from tdf#55058 Change-Id: I6cc88d41486c52a2b1a6ec0b89166460a78ce7d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116763 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 7cd98315adef..73d059aa5df3 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -825,7 +825,7 @@ namespace emfio SAL_WARN("emfio", "\t\t Raster operation: 0x" << std::hex << nRasterOperation << std::dec); if ( nRecordSize == ( ( static_cast< sal_uInt32 >( nFunc ) >> 8 ) + 3 ) ) { -SAL_WARN("emfio", "\t\t TODO The Bitmap record detected without Bitmap. This case in not supported. Please fill a bug."); +SAL_WARN("emfio", "\t\t TODO The unsupported Bitmap record (without embedded source Bitmap). Please fill a bug."); break; } mpInputStream->ReadUInt16( nYSrc ).ReadUInt16( nXSrc ).ReadUInt16( nSye ).ReadUInt16( nSxe ); @@ -893,7 +893,7 @@ namespace emfio if ( nRecordSize == ( ( static_cast< sal_uInt32 >( nFunc ) >> 8 ) + 3 ) ) { -SAL_WARN("emfio", "\t\t TODO The Bitmap record detected without Bitmap. This case in not supported. Please fill a bug."); +SAL_WARN("emfio", "\t\t TODO The unsupported Bitmap record (without embedded source Bitmap). Please fill a bug."); break; } if( nFunc == W_META_STRETCHDIB ) @@ -922,8 +922,25 @@ namespace emfio { tools::Rectangle aDestRect( ReadYX(), aDestSize ); if ( nRasterOperation != PATCOPY ) -ReadDIB(aBmp, *mpInputStream, false); - +{ +// tdf#142625 Read the DIBHeader and check if bitmap is supported +// If bitmap is not supported don't run ReadDIB, as it will interrupt image processing +const auto nOldPos(mpInputStream->Tell()); +sal_uInt32 nHeaderSize; +sal_uInt16 nBitCount; +mpInputStream->ReadUInt32( nHeaderSize ); +if ( nHeaderSize == 0xC ) // BitmapCoreHeader +mpInputStream->SeekRel( 6 ); // skip Width (16), Height (16), Planes (16) +else +mpInputStream->SeekRel( 10 ); // skip Width (32), Height (32), Planes (16) +mpInputStream->ReadUInt16( nBitCount ); +if ( nBitCount == 0 ) // TODO Undefined BitCount (JPEG/PNG), which are not supported +break; +mpInputStream->Seek(nOldPos); + +if ( !ReadDIB( aBmp, *mpInputStream, false ) ) +SAL_WARN( "emfio", "\tTODO Read DIB failed. Interrupting processing whole image. Please report bug report." ); +} // test if it is sensible to crop if ( nSrcHeight && nSrcWidth && ( nXSrc + nSrcWidth <= aBmp.GetSizePixel().Width() ) && @@ -932,6 +949,7 @@ namespace emfio tools::Rectangle aCropRect( Point( nXSrc, nYSrc ), Size( nSrcWidth, nSrcHeight ) ); aBmp.Crop( aCropRect ); } + maBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nRasterOperation)); } } @@ -942,11 +960,18 @@ namespace emfio { Bitmap aBmp; sal_uInt3
[Libreoffice-commits] core.git: drawinglayer/source emfio/inc emfio/qa emfio/source
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 = pars
[Libreoffice-commits] core.git: emfio/source
emfio/source/reader/wmfreader.cxx |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) New commits: commit ff53b249885d788fa0539a0f7d5a9879d031d2ee Author: Bartosz Kosiorek AuthorDate: Wed Jun 2 17:01:55 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Wed Jun 2 19:40:50 2021 +0200 WMF: add more SAL warnings in case record was not implemented Change-Id: I1d58c4093817403caa5f1112b5d4d5a4e638b799 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116618 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index f14949135ad4..b3998e2e811b 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1125,18 +1125,21 @@ namespace emfio case W_META_CREATEBITMAPINDIRECT: { +SAL_WARN( "emfio", "TODO: W_META_CREATEBITMAPINDIRECT is not implemented. Please fill the bug report" ); CreateObject(); } break; case W_META_CREATEBITMAP: { +SAL_WARN( "emfio", "TODO: W_META_CREATEBITMAP is not implemented. Please fill the bug report" ); CreateObject(); } break; case W_META_CREATEREGION: { +SAL_WARN( "emfio", "TODO: W_META_CREATEREGION is not implemented. Please fill the bug report" ); CreateObject(); } break; @@ -1161,8 +1164,9 @@ namespace emfio case W_META_SELECTCLIPREGION: { -sal_Int16 nObjIndex = 0; -mpInputStream->ReadInt16( nObjIndex ); +sal_uInt16 nObjIndex; +mpInputStream->ReadUInt16( nObjIndex ); +SAL_WARN( "emfio", "TODO: W_META_SELECTCLIPREGION is not implemented. Please fill the bug report" ); if ( !nObjIndex ) { tools::PolyPolygon aEmptyPolyPoly; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/primitive2dxmldump.cxx | 56 +-- 1 file changed, 43 insertions(+), 13 deletions(-) New commits: commit 3afac9467936fb3a5ae314878686c0f66ee7784f Author: Bartosz Kosiorek AuthorDate: Wed Jun 2 16:47:57 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Wed Jun 2 19:39:55 2021 +0200 fix: extend the primitive dump, with information about line cap and joint Change-Id: I5c67d360236ec67c41bc45a9018f0ff0d0ec1d3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116611 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index ade8cfaed89b..24c390c7e0f3 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -84,6 +84,47 @@ void writePolyPolygon(::tools::XmlWriter& rWriter, const basegfx::B2DPolyPolygon rWriter.endElement(); } +void writeLineAttribute(::tools::XmlWriter& rWriter, const drawinglayer::attribute::LineAttribute& rLineAttribute) +{ +rWriter.startElement("line"); +rWriter.attribute("color", convertColorToString(rLineAttribute.getColor())); +rWriter.attribute("width", rLineAttribute.getWidth()); +switch( rLineAttribute.getLineJoin() ) +{ +case basegfx::B2DLineJoin::NONE: +rWriter.attribute("linejoin", "NONE"); +break; +case basegfx::B2DLineJoin::Bevel: +rWriter.attribute("linejoin", "Bevel"); +break; +case basegfx::B2DLineJoin::Miter: +rWriter.attribute("linejoin", "Miter"); +break; +case basegfx::B2DLineJoin::Round: +rWriter.attribute("linejoin", "Round"); +break; +default: +rWriter.attribute("linejoin", "Unknown"); +break; +} +switch( rLineAttribute.getLineCap() ) +{ +case css::drawing::LineCap::LineCap_BUTT: +rWriter.attribute("linecap", "BUTT"); +break; +case css::drawing::LineCap::LineCap_ROUND: +rWriter.attribute("linecap", "ROUND"); +break; +case css::drawing::LineCap::LineCap_SQUARE: +rWriter.attribute("linecap", "SQUARE"); +break; +default: +rWriter.attribute("linecap", "Unknown"); +break; +} +rWriter.endElement(); +} + } // end anonymous namespace Primitive2dXmlDump::Primitive2dXmlDump() : @@ -235,12 +276,7 @@ void Primitive2dXmlDump::decomposeAndWrite( rWriter.content(basegfx::utils::exportToSvgPoints(rPolygonStrokePrimitive2D.getB2DPolygon())); rWriter.endElement(); -rWriter.startElement("line"); -const drawinglayer::attribute::LineAttribute& aLineAttribute = rPolygonStrokePrimitive2D.getLineAttribute(); -rWriter.attribute("color", convertColorToString(aLineAttribute.getColor())); -rWriter.attribute("width", aLineAttribute.getWidth()); - -rWriter.endElement(); +writeLineAttribute(rWriter, rPolygonStrokePrimitive2D.getLineAttribute()); rWriter.startElement("stroke"); const drawinglayer::attribute::StrokeAttribute& aStrokeAttribute = rPolygonStrokePrimitive2D.getStrokeAttribute(); @@ -256,13 +292,7 @@ void Primitive2dXmlDump::decomposeAndWrite( const PolyPolygonStrokePrimitive2D& rPolyPolygonStrokePrimitive2D = dynamic_cast(*pBasePrimitive); rWriter.startElement("polypolygonstroke"); -rWriter.startElement("line"); -const drawinglayer::attribute::LineAttribute& aLineAttribute = rPolyPolygonStrokePrimitive2D.getLineAttribute(); -rWriter.attribute("color", convertColorToString(aLineAttribute.getColor())); -rWriter.attribute("width", aLineAttribute.getWidth()); -//rWriter.attribute("linejoin", aLineAttribute.getLineJoin()); -//rWriter.attribute("linecap", aLineAttribute.getLineCap()); -rWriter.endElement(); +writeLineAttribute(rWriter, rPolyPolygonStrokePrimitive2D.getLineAttribute()); //getStrokeAttribute() ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: emfio/source
emfio/source/reader/emfreader.cxx | 177 +++--- 1 file changed, 92 insertions(+), 85 deletions(-) New commits: commit 82bde77366e8d92a791ca629df02026bfa5efe21 Author: Bartosz Kosiorek AuthorDate: Tue Jun 1 20:09:52 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue Jun 1 23:48:28 2021 +0200 tdf#142566 EMF Add support for EMR_POLYTEXTOUT records With this implementation the support for EMF records: EMR_POLYTEXTOUTA and EMR_POLYTEXTOUTW were added. Change-Id: I39580d051ae73bed88e04a34d97b797b6d468dc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116556 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 79ff9cf04200..106b9a52564f 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1790,14 +1790,17 @@ namespace emfio } break; +case EMR_POLYTEXTOUTA : case EMR_EXTTEXTOUTA : bFlag = true; [[fallthrough]]; +case EMR_POLYTEXTOUTW : case EMR_EXTTEXTOUTW : { sal_Int32 nLeft, nTop, nRight, nBottom; sal_uInt32 nGfxMode; float nXScale, nYScale; +sal_uInt32 ncStrings( 1 ); sal_Int32 ptlReferenceX, ptlReferenceY; sal_uInt32 nLen, nOffString, nOptions, offDx; sal_Int32 nLeftRect, nTopRect, nRightRect, nBottomRect; @@ -1805,112 +1808,118 @@ namespace emfio nCurPos = mpInputStream->Tell() - 8; mpInputStream->ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ) - .ReadUInt32( nGfxMode ).ReadFloat( nXScale ).ReadFloat( nYScale ) - .ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadUInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions ); - + .ReadUInt32( nGfxMode ).ReadFloat( nXScale ).ReadFloat( nYScale ); SAL_INFO("emfio", "\t\tBounds: " << nLeft << ", " << nTop << ", " << nRight << ", " << nBottom); SAL_INFO("emfio", "\t\tiGraphicsMode: 0x" << std::hex << nGfxMode << std::dec); -SAL_INFO("emfio", "\t\texScale: " << nXScale); -SAL_INFO("emfio", "\t\teyScale: " << nYScale); -SAL_INFO("emfio", "\t\tReference: (" << ptlReferenceX << ", " << ptlReferenceY << ")"); - -mpInputStream->ReadInt32( nLeftRect ).ReadInt32( nTopRect ).ReadInt32( nRightRect ).ReadInt32( nBottomRect ); -const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect ); -BkMode mnBkModeBackup = mnBkMode; -if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background -mnBkMode = BkMode::Transparent; -else if ( nOptions & ETO_OPAQUE ) -DrawRectWithBGColor( aRect ); -mpInputStream->ReadUInt32( offDx ); - -ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; -if ( nOptions & ETO_RTLREADING ) -nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft; -SetTextLayoutMode( nTextLayoutMode ); -SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "emfio", "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" ); - -Point aPos( ptlReferenceX, ptlReferenceY ); -bool bOffStringSane = nOffString <= mnEndPos - nCurPos; -if ( bOffStringSane ) +SAL_INFO("emfio", "\t\t Scale: " << nXScale << " x " << nYScale); +if ( ( nRecType == EMR_POLYTEXTOUTA ) || ( nRecType == EMR_POLYTEXTOUTW ) ) +{ +mpInputStream->ReadUInt32( ncStrings ); +SAL_INFO("emfio", "\t\t Number of Text objects: " << ncStrings); +} +for ( sal_uInt32 nStringNo = 0; nStringNo < n
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 18 -- emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf |binary emfio/source/reader/emfreader.cxx |4 +- emfio/source/reader/mtftools.cxx |3 + 4 files changed, 20 insertions(+), 5 deletions(-) New commits: commit f275c4b31f095193b80cb756f8610c16282fb8f4 Author: Bartosz Kosiorek AuthorDate: Sat May 29 21:11:55 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Mon May 31 07:32:44 2021 +0200 tdf#53004 tdf#142495 WMF EMF Always display Text rectangle In previous implementation if BKMode was set to Transparent, then both Background of Text and Rectangle was not drawn. It was wrong, and Rectangle should be always drawn. This commit fix that issue and allows EMF images exported by LTspice to be rendered correctly under LibreOffice. Change-Id: I03801d35d92eb2a3fdc175ca1d5b348a2aa30842 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116394 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 1b134551c7ff..1613fe943e6f 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -519,12 +519,19 @@ void Test::TestExtTextOutOpaqueAndClipTransform() xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); CPPUNIT_ASSERT (pDocument); -assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion", + +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[1]", "text", "No_rect- DLP-"); -assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion", +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[1]", "fontcolor", "#00"); -assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[2]", +"text", "OpaqueTranspa"); +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[2]", +"fontcolor", "#00"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 3); assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", "path", "m966 490-477-275-84 147 476 275z"); assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", @@ -535,6 +542,11 @@ void Test::TestExtTextOutOpaqueAndClipTransform() assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]", "color", "#0080ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[3]/polypolygon", +"path", "m972 1326-476-275-148 257 476 276z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[3]", +"color", "#800080"); + assertXPath(pDocument, "/primitive2D/metafile/transform/group", 3); assertXPath(pDocument, "/primitive2D/metafile/transform/group[1]/polypolygoncolor", "color", "#ff"); diff --git a/emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf b/emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf index 7d59ac3e5bd2..0b7be5ab39ec 100644 Binary files a/emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf and b/emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf differ diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index e6a758175fb5..79ff9cf04200 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1817,9 +1817,9 @@ namespace emfio mpInputStream->ReadInt32( nLeftRect ).ReadInt32( nTopRect ).ReadInt32( nRightRect ).ReadInt32( nBottomRect ); const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect ); BkMode mnBkModeBackup = mnBkMode; -if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle +if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background mnBkMode = BkMode::Transparent; -if ( nOptions & ETO_
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |3 emfio/qa/cppunit/emf/EmfImportTest.cxx | 113 ++ emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf |binary emfio/qa/cppunit/wmf/data/TestExtTextOutOpaqueAndClip.wmf |binary emfio/qa/cppunit/wmf/wmfimporttest.cxx | 18 + emfio/source/reader/emfreader.cxx | 37 ++- emfio/source/reader/mtftools.cxx | 35 +-- emfio/source/reader/wmfreader.cxx | 23 +- 8 files changed, 190 insertions(+), 39 deletions(-) New commits: commit 3a9027609e7ee0c7af457b06426093782ca295a8 Author: Bartosz Kosiorek AuthorDate: Mon May 24 20:05:19 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri May 28 21:47:40 2021 +0200 tdf#53004 tdf#142495 WMF EMF Fix displaying Text with OPAQUE and CLIPPED With OPAQUE option enabled, the rectangle need to be drawn, before drawing text. With CLIPPED option enabled, the text needs to be drawn only inside rectangle. In previous implementation, the rectangle read was skipped and it was not drawn (for OPAQUE). For CLIPPED the rectangle was read but Clip was not applied to text drawing This commit fix that issues, and allow to draw rectangle correctly, with BGColor (background color), and add support for Text Clipping according to [MS-WMF] and [MS-EMF] specification. The fix applied to EMR_EXTTEXTOUTW, EMR_EXTTEXTOUTA and EXTTEXTOUT records Change-Id: I0f6248bb9465e6d5f797cddb53f058afb0815a2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116072 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 0fb99761d386..cffe5e4fa511 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -207,11 +207,13 @@ namespace emfio #define MAC_CHARSET 77 #define BALTIC_CHARSET 186 +#define ETO_OPAQUE 0x0002 #define ETO_CLIPPED 0x0004 /*WINVER >= 0x0400*/ #define ETO_GLYPH_INDEX 0x0010 #define ETO_RTLREADING 0x0080 /*_WIN32_WINNT >= 0x0500*/ +#define ETO_NO_RECT 0x0100 #define ETO_PDY 0x2000 #define DEFAULT_PITCH 0x00 @@ -642,6 +644,7 @@ namespace emfio voidLineTo(const Point& rPoint, bool bRecordPath = false); voidDrawPixel(const Point& rSource, const Color& rColor); voidDrawRect(const tools::Rectangle& rRect, bool bEdge = true); +voidDrawRectWithBGColor(const tools::Rectangle& rRect); voidDrawRoundRect(const tools::Rectangle& rRect, const Size& rSize); voidDrawEllipse(const tools::Rectangle& rRect); voidDrawArc( diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 5de9faa36714..1b134551c7ff 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -60,6 +60,9 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestExtTextOutOpaqueAndClipTransform(); + +void TestExtTextOutOpaqueAndClipWMF(); void TestPaletteWMF(); void TestRoundrectWMF(); void TestPolylinetoCloseStroke(); @@ -91,6 +94,8 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestExtTextOutOpaqueAndClipTransform); +CPPUNIT_TEST(TestExtTextOutOpaqueAndClipWMF); CPPUNIT_TEST(TestPaletteWMF); CPPUNIT_TEST(TestRoundrectWMF); CPPUNIT_TEST(TestPolylinetoCloseStroke); @@ -504,6 +509,114 @@ void Test::TestPolylinetoCloseStroke() "color", "#00"); } + +void Test::TestExtTextOutOpaqueAndClipTransform() +{ +// tdf#142495 EMF records: SETBKCOLOR, SELECTOBJECT, EXTTEXTOUTW, MODIFYWORLDTRANSFORM, CREATEFONTINDIRECT. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestExtTextOutOpaqueAndClipTransform.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion", +"text", "No_rect- DLP-"); +assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion", +&
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1-4' - 2 commits - emfio/qa svtools/source
emfio/qa/cppunit/emf/EmfImportTest.cxx|8 emfio/qa/cppunit/wmf/data/TestPalette.wmf |binary svtools/source/control/valueset.cxx |8 3 files changed, 12 insertions(+), 4 deletions(-) New commits: commit 676ba2babff95da3ac41205bc96d1bf252496d6f Author: Bartosz Kosiorek AuthorDate: Thu May 27 19:38:50 2021 +0200 Commit: Xisco Fauli CommitDate: Fri May 28 11:21:43 2021 +0200 tdf#117957 WMF Replace ellipses with rects to fix tests on arm64 The issue is caused by floating numbers, On x86_64 it is: 338.499728160392-445.269903703769 on arm it is: 338.499728160392-445.26990370377 As in test files, we have two ellipses (which are made from small lines), which points rounds differently on different architectures Change-Id: I44dd5c7b3b13f3b1680d5a3a8348d6f467cb2f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116270 Tested-by: Jenkins Tested-by: René Engelhard Reviewed-by: Xisco Fauli Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116314 Reviewed-by: Bartosz Kosiorek (cherry picked from commit a1168e2c58daf2efde944970472c67c46c2e8c03) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116161 diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 53be54f34c02..2e8523e5d999 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -474,25 +474,25 @@ void Test::TestPalette() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", -"path", "m2433 1216.5c0 213.540351086756-56.2099207528522 423.318631225821-162.98009629623 608.25s-260.338534929591 338.499728160392-445.269903703769 445.26990370377-394.709648913244 162.98009629623-608.25 162.98009629623-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160392-260.338534929591-445.26990370377-445.26990370377-162.980096296231-394.709648913244-162.980096296231-608.25c-2.70117261891301E-013-213.540351086756 56.2099207528519-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.338534929591-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-5.40234523782601E-013 423.318631225821 56.2099207528518 608.25 162.98009629623s338.499728160392 260.338534929591 445.26990370377 445.269903703769c106.770175543379 184.931368774179 162.980096296231 394.709648913244 162.980096296231 608.25z"); +"path", "m0 0h3015v3015h-3015z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#00"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", -"path", "m5079 3862.5c0 213.540351086756-56.2099207528527 423.318631225821-162.980096296231 608.25s-260.33853492959 338.499728160391-445.269903703769 445.269903703769-394.709648913244 162.980096296231-608.25 162.980096296231-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160391-260.33853492959-445.26990370377-445.269903703769-162.980096296231-394.709648913245-162.980096296231-608.2501c-4.54747350886464E-013-213.540351086756 56.2099207528518-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.33853492959-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-4.54747350886464E-013 423.318631225821 56.2099207528522 608.25 162.98009629623s338.499728160392 260.33853492959 445.26990370377 445.269903703769c106.770175543378 184.931368774178 162.980096296231 394.709648913244 162.980096296231 608.25z"); +"path", "m h2698v2698h-2698z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]", "color", "#0080ff"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 2); assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", - "2408,1191 2406,1129 2402,1068 2394,1007 2383,946 2369,886 2352,827 2332,768 2309,711 2284,655 2255,600 2224,547 2190,496 2153,446 2114,398 2073,353 2029,309 1984,268 1936,229 1886,192 1835,158 1782,127 1727,98 1671,73 1614,50 1555,30 1496,13 1436,-1 1375,-12 1314,-20 1253,-24 1191,-26 1191,-26 1129,-24 1068,-20 1007,-12 946,-1 886,13 827,30 768,50 711,73 655,98 600,127 547,158 496,192 446,229 398,268 353,309 309,353 268,398 229,446 192,496 15
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa
emfio/qa/cppunit/emf/EmfImportTest.cxx|8 emfio/qa/cppunit/wmf/data/TestPalette.wmf |binary 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit a1168e2c58daf2efde944970472c67c46c2e8c03 Author: Bartosz Kosiorek AuthorDate: Thu May 27 19:38:50 2021 +0200 Commit: Xisco Fauli CommitDate: Fri May 28 11:19:54 2021 +0200 tdf#117957 WMF Replace ellipses with rects to fix tests on arm64 The issue is caused by floating numbers, On x86_64 it is: 338.499728160392-445.269903703769 on arm it is: 338.499728160392-445.26990370377 As in test files, we have two ellipses (which are made from small lines), which points rounds differently on different architectures Change-Id: I44dd5c7b3b13f3b1680d5a3a8348d6f467cb2f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116270 Tested-by: Jenkins Tested-by: René Engelhard Reviewed-by: Xisco Fauli Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116314 Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index e74bb9ad3725..5f0567fd313b 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -490,25 +490,25 @@ void Test::TestPaletteWMF() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", -"path", "m2433 1216.5c0 213.540351086756-56.2099207528522 423.318631225821-162.98009629623 608.25s-260.338534929591 338.499728160392-445.269903703769 445.26990370377-394.709648913244 162.98009629623-608.25 162.98009629623-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160392-260.338534929591-445.26990370377-445.26990370377-162.980096296231-394.709648913244-162.980096296231-608.25c-2.70117261891301E-013-213.540351086756 56.2099207528519-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.338534929591-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-5.40234523782601E-013 423.318631225821 56.2099207528518 608.25 162.98009629623s338.499728160392 260.338534929591 445.26990370377 445.269903703769c106.770175543379 184.931368774179 162.980096296231 394.709648913244 162.980096296231 608.25z"); +"path", "m0 0h3015v3015h-3015z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#00"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", -"path", "m5079 3862.5c0 213.540351086756-56.2099207528527 423.318631225821-162.980096296231 608.25s-260.33853492959 338.499728160391-445.269903703769 445.269903703769-394.709648913244 162.980096296231-608.25 162.980096296231-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160391-260.33853492959-445.26990370377-445.269903703769-162.980096296231-394.709648913245-162.980096296231-608.2501c-4.54747350886464E-013-213.540351086756 56.2099207528518-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.33853492959-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-4.54747350886464E-013 423.318631225821 56.2099207528522 608.25 162.98009629623s338.499728160392 260.33853492959 445.26990370377 445.269903703769c106.770175543378 184.931368774178 162.980096296231 394.709648913244 162.980096296231 608.25z"); +"path", "m h2698v2698h-2698z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]", "color", "#0080ff"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 2); assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", - "2408,1191 2406,1129 2402,1068 2394,1007 2383,946 2369,886 2352,827 2332,768 2309,711 2284,655 2255,600 2224,547 2190,496 2153,446 2114,398 2073,353 2029,309 1984,268 1936,229 1886,192 1835,158 1782,127 1727,98 1671,73 1614,50 1555,30 1496,13 1436,-1 1375,-12 1314,-20 1253,-24 1191,-26 1191,-26 1129,-24 1068,-20 1007,-12 946,-1 886,13 827,30 768,50 711,73 655,98 600,127 547,158 496,192 446,229 398,268 353,309 309,353 268,398 229,446 192,496 158,547 127,600 98,655 73,711 50,768 30,827 13,886 -1,946 -12,1007 -20,1068 -24,1129 -26,1191 -26,1191 -24,1253 -20,1314 -12,1375 -1,1436 13,1496 30,1555 50,1614 73,1671 98,1727 127,1782 158,1835 1
[Libreoffice-commits] core.git: emfio/qa
emfio/qa/cppunit/emf/EmfImportTest.cxx|4 ++-- emfio/qa/cppunit/wmf/data/TestPalette.wmf |binary 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 9864fbc9d5f532d9aa4742968886b3f94bc44dbc Author: Bartosz Kosiorek AuthorDate: Thu May 27 19:38:50 2021 +0200 Commit: Xisco Fauli CommitDate: Fri May 28 09:33:21 2021 +0200 tdf#117957 WMF Replace ellipses with rects to fix tests on arm64 The issue is caused by floating numbers, On x86_64 it is: 338.499728160392-445.269903703769 on arm it is: 338.499728160392-445.26990370377 As in test files, we have two ellipses (which are made from small lines), which points rounds differently on different architectures Change-Id: I44dd5c7b3b13f3b1680d5a3a8348d6f467cb2f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116270 Tested-by: Jenkins Tested-by: René Engelhard Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index e825dce810da..5de9faa36714 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -520,7 +520,7 @@ void Test::TestPaletteWMF() "color", "#00"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", -"path", "m4920 3571c0 236.798958993862-62.332250797861 469.426085921606-180.731730294792 674.5s-288.694355626813 375.368790208277-493.768269705208 493.768269705208-437.701041006137 180.731730294792-674.5 180.731730294792-469.426085921606-62.332250797861-674.5-180.731730294792-375.368790208277-288.694355626812-493.768269705208-493.768269705207-180.731730294792-437.701041006138-180.731730294792-674.5c-4.54747350886464E-013-236.798958993862 62.332250797861-469.426085921606 180.731730294792-674.5 118.399479496931-205.073914078395 288.694355626812-375.368790208277 493.768269705207-493.768269705208s437.701041006138-180.731730294793 674.5-180.731730294793c236.798958993862-4.54747350886464E-013 469.426085921606 62.3322507978601 674.5 180.731730294791s375.368790208277 288.694355626813 493.768269705208 493.768269705207c118.399479496932 205.073914078394 180.731730294793 437.701041006138 180.731730294793 674.5z"); +"path", "m h2698v2698h-2698z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]", "color", "#0080ff"); @@ -533,7 +533,7 @@ void Test::TestPaletteWMF() "width", "132"); assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/polygon", - "4894,3545 4892,3477 4887,3409 4878,3341 4866,3273 4851,3207 4832,3141 4810,3076 4785,3013 4756,2951 4724,2890 4690,2831 4652,2774 4612,2719 4569,2666 4523,2616 4474,2567 4424,2521 4371,2478 4316,2438 4259,2400 4200,2366 4139,2334 4077,2305 4014,2280 3949,2258 3883,2239 3817,2224 3749,2212 3681,2203 3613,2198 3545,2196 3545,2196 3477,2198 3409,2203 3341,2212 3273,2224 3207,2239 3141,2258 3076,2280 3013,2305 2951,2334 2890,2366 2831,2400 2774,2438 2719,2478 2666,2521 2616,2567 2567,2616 2521,2666 2478,2719 2438,2774 2400,2831 2366,2890 2334,2951 2305,3013 2280,3076 2258,3141 2239,3207 2224,3273 2212,3341 2203,3409 2198,3477 2196,3545 2196,3545 2198,3613 2203,3681 2212,3749 2224,3817 2239,3883 2258,3949 2280,4014 2305,4077 2334,4139 2366,4200 2400,4259 2438,4316 2478,4371 2521,4424 2567,4474 2616,4523 2666,4569 2719,4612 2774,4652 2831,4690 2890,4724 2951,4756 3013,4785 3076,4810 3141,4832 3207,4851 3273,4866 3341,4878 3409,4887 3477,4892 3545,4894 3545,4894 361 3,4892 3681,4887 3749,4878 3817,4866 3883,4851 3949,4832 4014,4810 4077,4785 4139,4756 4200,4724 4259,4690 4316,4652 4371,4612 4424,4569 4474,4523 4523,4474 4569,4424 4612,4371 4652,4316 4690,4259 4724,4200 4756,4139 4785,4077 4810,4014 4832,3949 4851,3883 4866,3817 4878,3749 4887,3681 4892,3613"); + ", 4920, 4920,4920 ,4920"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "color", "#ff"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", diff --git a/emfio/qa/cppunit/wmf/data/TestPalette.wmf b/emfio/qa/cppunit/wmf/data/TestPalette.wmf index 013adeb16de7..079a7f64f496 100644 Binary files a/emfio/qa/cppunit/wmf/data/TestPalette.wmf and b/emfio/qa/cppunit/wmf/data/TestPalette.wmf differ ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: emfio/qa
emfio/qa/cppunit/emf/EmfImportTest.cxx|8 emfio/qa/cppunit/wmf/data/TestPalette.wmf |binary 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit 9cc47eda70025c6bccfad1cfc45d30b7ecd2fc19 Author: Bartosz Kosiorek AuthorDate: Thu May 27 10:45:47 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu May 27 13:09:33 2021 +0200 tdf#117957 WMF Fix failing tests on arm64 So the issue is caused by floating numbers, On x86_64 it is: 338.499728160392-445.269903703769 on arm it is: 338.499728160392-445.26990370377 As in test files, we have two ellipses (which are made from small lines), which points rounds differently on different architectures Change-Id: I10efe80fea0944cf957e949c8c209c94fd588702 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116234 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index b28985a3b165..e825dce810da 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -515,25 +515,25 @@ void Test::TestPaletteWMF() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", -"path", "m2433 1216.5c0 213.540351086756-56.2099207528522 423.318631225821-162.98009629623 608.25s-260.338534929591 338.499728160392-445.269903703769 445.26990370377-394.709648913244 162.98009629623-608.25 162.98009629623-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160392-260.338534929591-445.26990370377-445.26990370377-162.980096296231-394.709648913244-162.980096296231-608.25c-2.70117261891301E-013-213.540351086756 56.2099207528519-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.338534929591-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-5.40234523782601E-013 423.318631225821 56.2099207528518 608.25 162.98009629623s338.499728160392 260.338534929591 445.26990370377 445.269903703769c106.770175543379 184.931368774179 162.980096296231 394.709648913244 162.980096296231 608.25z"); +"path", "m0 0h3015v3015h-3015z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#00"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", -"path", "m5079 3862.5c0 213.540351086756-56.2099207528527 423.318631225821-162.980096296231 608.25s-260.33853492959 338.499728160391-445.269903703769 445.269903703769-394.709648913244 162.980096296231-608.25 162.980096296231-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160391-260.33853492959-445.26990370377-445.269903703769-162.980096296231-394.709648913245-162.980096296231-608.2501c-4.54747350886464E-013-213.540351086756 56.2099207528518-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.33853492959-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-4.54747350886464E-013 423.318631225821 56.2099207528522 608.25 162.98009629623s338.499728160392 260.33853492959 445.26990370377 445.269903703769c106.770175543378 184.931368774178 162.980096296231 394.709648913244 162.980096296231 608.25z"); +"path", "m4920 3571c0 236.798958993862-62.332250797861 469.426085921606-180.731730294792 674.5s-288.694355626813 375.368790208277-493.768269705208 493.768269705208-437.701041006137 180.731730294792-674.5 180.731730294792-469.426085921606-62.332250797861-674.5-180.731730294792-375.368790208277-288.694355626812-493.768269705208-493.768269705207-180.731730294792-437.701041006138-180.731730294792-674.5c-4.54747350886464E-013-236.798958993862 62.332250797861-469.426085921606 180.731730294792-674.5 118.399479496931-205.073914078395 288.694355626812-375.368790208277 493.768269705207-493.768269705208s437.701041006138-180.731730294793 674.5-180.731730294793c236.798958993862-4.54747350886464E-013 469.426085921606 62.3322507978601 674.5 180.731730294791s375.368790208277 288.694355626813 493.768269705208 493.768269705207c118.399479496932 205.073914078394 180.731730294793 437.701041006138 180.731730294793 674.5z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]", "color", "#0080ff"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 2); assertXPathContent(pDocument, "/primitive2D/metafile/tra
[Libreoffice-commits] core.git: emfio/inc emfio/source
emfio/inc/emfreader.hxx |2 +- emfio/source/reader/emfreader.cxx | 17 + 2 files changed, 6 insertions(+), 13 deletions(-) New commits: commit 4f4c5b43f0c69385aa2738cbac7f7c898af1972f Author: Bartosz Kosiorek AuthorDate: Sat May 22 19:19:12 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Sat May 22 20:08:11 2021 +0200 tdf#55007 EMF Allow negatives values for Start Point and End Point With previous inplementation, the ARC, ARCTO, CHORD and PIE records were get Start Point and End Point only with positive values. It was causing display issues. This patch fix that according to [MS-EMF] specification Change-Id: Ie1d90a904e840674380b81af0dfe21260374587d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115994 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/emfreader.hxx b/emfio/inc/emfreader.hxx index e580835fc083..a09ad6fa2c20 100644 --- a/emfio/inc/emfreader.hxx +++ b/emfio/inc/emfreader.hxx @@ -27,7 +27,7 @@ namespace emfio class EmfReader : public MtfTools { private: -sal_Int32 mnRecordCount; +sal_uInt32 mnRecordCount; boolmbRecordPath : 1; boolmbEMFPlus : 1; diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index e9a3afec3f19..9a8784c7e631 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1369,8 +1369,8 @@ namespace emfio case EMR_ARCTO : case EMR_CHORD : { -sal_uInt32 nStartX, nStartY, nEndX, nEndY; -mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); +sal_Int32 nStartX, nStartY, nEndX, nEndY; +mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadInt32( nStartX ).ReadInt32( nStartY ).ReadInt32( nEndX ).ReadInt32( nEndY ); SAL_INFO( "emfio", "\t\t Bounds: " << nX32 << ":" << nY32 << ", " << nx32 << ":" << ny32 << ", Start: " << nStartX << ":" << nStartY << ", End: " << nEndX << ":" << nEndY ); tools::Polygon aPoly( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Arc ); if ( nRecType == EMR_CHORD ) @@ -1382,8 +1382,8 @@ namespace emfio case EMR_PIE : { -sal_uInt32 nStartX, nStartY, nEndX, nEndY; -mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); +sal_Int32 nStartX, nStartY, nEndX, nEndY; +mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadInt32( nStartX ).ReadInt32( nStartY ).ReadInt32( nEndX ).ReadInt32( nEndY ); tools::Polygon aPoly( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Pie ); DrawPolygon( aPoly, mbRecordPath ); } @@ -2153,16 +2153,9 @@ namespace emfio mnEndPos = nActualFileSize; } -mpInputStream->ReadInt32(mnRecordCount); +mpInputStream->ReadUInt32(mnRecordCount); SAL_INFO("emfio", "\tRecords: " << mnRecordCount); -if (mnRecordCount <= 0) -{ -SAL_WARN("emfio", "EMF\t\tEMF Header object shows record counter as <= 0! This shouldn't " -"be possible... indicator of possible file corruption?"); -return false; -} - // the number of "handles", or graphics objects used in the metafile sal_uInt16 nHandlesCount; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 29 emfio/qa/cppunit/wmf/data/TestRoundRect.wmf |binary emfio/source/reader/mtftools.cxx|1 3 files changed, 25 insertions(+), 5 deletions(-) New commits: commit a3bf914602ecc5f49953289ca572825313864ffc Author: Bartosz Kosiorek AuthorDate: Sat May 22 08:04:18 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Sat May 22 13:25:33 2021 +0200 tdf#127145 WMF Fix displaying line width in ROUNDRECT record The EDGE optimization shouldn't be used for curves, otherwise strange issues appearing. Change-Id: Id677fc9002f0f79913ae756f0e456af7c9f7e507 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115984 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit b7c9ce6c86a11c6cacfa190b99052da37c49) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115957 diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 24e2e295e957..e74bb9ad3725 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -57,7 +57,8 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); -void TestPalette(); +void TestPaletteWMF(); +void TestRoundrectWMF(); void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); void TestRoundRect(); @@ -86,7 +87,8 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); -CPPUNIT_TEST(TestPalette); +CPPUNIT_TEST(TestPaletteWMF); +CPPUNIT_TEST(TestRoundrectWMF); CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); @@ -477,8 +479,7 @@ void Test::TestPolylinetoCloseStroke() "color", "#00"); } - -void Test::TestPalette() +void Test::TestPaletteWMF() { // WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE. Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestPalette.wmf"); @@ -514,6 +515,26 @@ void Test::TestPalette() "width", "132"); } +void Test::TestRoundrectWMF() +{ +// WMF records: ROUNDRECT, SETBKCOLOR, CREATEBRUSHINDIRECT +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRoundRect.wmf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", +"color", "#ff"); + +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", + "2865,661 2865,653 2865,645 2865,637 2865,621 2865,613 2865,605 2857,597 2857,589 2857,582 2857,566 2857,558 2849,550 2849,542 2849,534 2841,526 2841,518 2841,510 2833,502 2833,494 2825,486 2825,478 2817,470 2817,462 2809,454 2809,446 2801,438 2801,430 2793,422 2793,422 2785,414 2777,406 2777,398 2769,390 2761,390 2761,382 2753,374 2745,374 2737,366 2737,366 2729,358 2721,350 2714,350 2714,343 2706,343 2698,343 2690,335 2682,335 2682,335 2674,327 2666,327 2658,327 2650,327 2642,319 2634,319 2634,319 2626,319 2618,319 2610,319 573,319 565,319 557,319 549,319 549,319 541,319 533,327 525,327 517,327 509,327 501,335 501,335 493,335 485,343 477,343 469,343 469,350 462,350 454,358 446,366 446,366 438,374 430,374 422,382 422,390 414,390 406,398 406,406 398,414 390,422 390,422 382,430 382,438 374,446 374,454 366,462 366,470 358,478 358,486 350,494 350,502 342,510 342,518 342,526 334,534 334,542 334,550 326,558 326,566 326,582 326,589 326,597 318,605 318,613 318,621 31 8,637 318,645 318,653 318,661 318,1673 318,1681 318,1689 318,1697 318,1713 318,1721 318,1729 326,1737 326,1745 326,1752 326,1768 326,1776 334,1784 334,1792 334,1800 342,1808 342,1816 342,1824 350,1832 350,1840 358,1848 358,1856 366,1864 366,1872 374,1880 374,1888 382,1896 382,1904 390,1912 390,1912 398,1920 406,1928 406,1936 414,1944 422,1944 422,1952 430,1960 438,1960 446,1968 446,1968 454,1976 462,1984 469,1984 469,1991 477,1991 485,1991 493,1999 501,1999 501,1999 509,2007 517,2007 525,2007 533,2007 541,2015 549,2015 549,2015 557,2015 565,2015 573,2015 2610,2015 2618,2015 2626,2015 2634,2015 2634,2015 2642,2015 2650,2007 2658,2007 2666,2007 2674,2007 2682,1999 2682,1999 2690,1999 2698,1991 2706,1991 2714,1991 2714,1984 2721,1984 2729,1976 2737,1968 2737,1968 2745,1960 2753,1960 2761,1952 2761,1944 2769,1
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 29 emfio/qa/cppunit/wmf/data/TestRoundRect.wmf |binary emfio/source/reader/mtftools.cxx|1 3 files changed, 25 insertions(+), 5 deletions(-) New commits: commit b7c9ce6c86a11c6cacfa190b99052da37c49 Author: Bartosz Kosiorek AuthorDate: Sat May 22 08:04:18 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Sat May 22 10:02:56 2021 +0200 tdf#127145 WMF Fix displaying line width in ROUNDRECT record The EDGE optimization shouldn't be used for curves, otherwise strange issues appearing. Change-Id: Id677fc9002f0f79913ae756f0e456af7c9f7e507 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115984 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index bca5cbc161e3..b28985a3b165 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -60,7 +60,8 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); -void TestPalette(); +void TestPaletteWMF(); +void TestRoundrectWMF(); void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); void TestRoundRect(); @@ -90,7 +91,8 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); -CPPUNIT_TEST(TestPalette); +CPPUNIT_TEST(TestPaletteWMF); +CPPUNIT_TEST(TestRoundrectWMF); CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); @@ -502,8 +504,7 @@ void Test::TestPolylinetoCloseStroke() "color", "#00"); } - -void Test::TestPalette() +void Test::TestPaletteWMF() { // WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE. Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestPalette.wmf"); @@ -539,6 +540,26 @@ void Test::TestPalette() "width", "132"); } +void Test::TestRoundrectWMF() +{ +// WMF records: ROUNDRECT, SETBKCOLOR, CREATEBRUSHINDIRECT +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestRoundRect.wmf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", +"color", "#ff"); + +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", + "2865,661 2865,653 2865,645 2865,637 2865,621 2865,613 2865,605 2857,597 2857,589 2857,582 2857,566 2857,558 2849,550 2849,542 2849,534 2841,526 2841,518 2841,510 2833,502 2833,494 2825,486 2825,478 2817,470 2817,462 2809,454 2809,446 2801,438 2801,430 2793,422 2793,422 2785,414 2777,406 2777,398 2769,390 2761,390 2761,382 2753,374 2745,374 2737,366 2737,366 2729,358 2721,350 2714,350 2714,343 2706,343 2698,343 2690,335 2682,335 2682,335 2674,327 2666,327 2658,327 2650,327 2642,319 2634,319 2634,319 2626,319 2618,319 2610,319 573,319 565,319 557,319 549,319 549,319 541,319 533,327 525,327 517,327 509,327 501,335 501,335 493,335 485,343 477,343 469,343 469,350 462,350 454,358 446,366 446,366 438,374 430,374 422,382 422,390 414,390 406,398 406,406 398,414 390,422 390,422 382,430 382,438 374,446 374,454 366,462 366,470 358,478 358,486 350,494 350,502 342,510 342,518 342,526 334,534 334,542 334,550 326,558 326,566 326,582 326,589 326,597 318,605 318,613 318,621 31 8,637 318,645 318,653 318,661 318,1673 318,1681 318,1689 318,1697 318,1713 318,1721 318,1729 326,1737 326,1745 326,1752 326,1768 326,1776 334,1784 334,1792 334,1800 342,1808 342,1816 342,1824 350,1832 350,1840 358,1848 358,1856 366,1864 366,1872 374,1880 374,1888 382,1896 382,1904 390,1912 390,1912 398,1920 406,1928 406,1936 414,1944 422,1944 422,1952 430,1960 438,1960 446,1968 446,1968 454,1976 462,1984 469,1984 469,1991 477,1991 485,1991 493,1999 501,1999 501,1999 509,2007 517,2007 525,2007 533,2007 541,2015 549,2015 549,2015 557,2015 565,2015 573,2015 2610,2015 2618,2015 2626,2015 2634,2015 2634,2015 2642,2015 2650,2007 2658,2007 2666,2007 2674,2007 2682,1999 2682,1999 2690,1999 2698,1991 2706,1991 2714,1991 2714,1984 2721,1984 2729,1976 2737,1968 2737,1968 2745,1960 2753,1960 2761,1952 2761,1944 2769,1944 2777,1936 2777,1928 2785,1920 2793,1912 2793,1912 2801,1904 2801,1896 2809,1888 2809,1880 2817,1872 2817,1864 2825,1856 2825,1848 2833,18
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - 12 commits - cui/uiconfig dbaccess/source emfio/qa extras/source filter/source include/oox include/xmloff oox/qa oox/source reportde
cui/uiconfig/ui/textanimtabpage.ui | 15 dbaccess/source/filter/xml/xmlExport.cxx |6 emfio/qa/cppunit/emf/EmfImportTest.cxx | 15 emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf |binary extras/source/autocorr/lang/ko/DocumentList.xml|1 filter/source/xslt/odf2xhtml/export/xhtml/body.xsl | 128 ++--- include/oox/drawingml/shape.hxx|4 include/xmloff/xmlexppr.hxx|3 include/xmloff/xmluconv.hxx|9 oox/qa/unit/data/tdf141463_GroupTransform.pptx |binary oox/qa/unit/shape.cxx | 55 ++ oox/source/drawingml/shape.cxx | 234 ++ reportdesign/source/filter/xml/xmlExport.cxx |8 sc/source/filter/xml/xmlexprt.cxx | 20 sfx2/source/doc/objstor.cxx| 13 solenv/flatpak-manifest.in |6 sw/inc/unosett.hxx |5 sw/qa/extras/htmlexport/xhtmlexport.cxx| 16 sw/qa/extras/odfexport/data/tdf118637.odt |binary sw/qa/extras/unowriter/unowriter.cxx | 33 + sw/source/core/unocore/unosett.cxx | 22 sw/source/filter/xml/xmliteme.cxx |3 sw/source/filter/xml/xmlitemi.cxx |3 sw/source/uibase/config/StoredChapterNumbering.cxx |2 sw/source/uibase/shells/tabsh.cxx |8 tools/source/generic/poly.cxx |9 vcl/unx/gtk3/gtk3gtkinst.cxx |3 xmloff/source/chart/PropertyMaps.cxx |6 xmloff/source/chart/SchXMLExport.cxx | 101 ++-- xmloff/source/chart/SchXMLTools.cxx|3 xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx|6 xmloff/source/core/xmlexp.cxx | 46 + xmloff/source/core/xmlimp.cxx |3 xmloff/source/core/xmluconv.cxx| 21 xmloff/source/draw/sdxmlexp.cxx|2 xmloff/source/draw/shapeexport.cxx |4 xmloff/source/forms/layerexport.cxx|2 xmloff/source/style/XMLPageExport.cxx |6 xmloff/source/style/chrlohdl.cxx | 10 xmloff/source/style/styleexp.cxx |4 xmloff/source/style/xmlexppr.cxx |9 xmloff/source/table/XMLTableExport.cxx |6 xmloff/source/text/txtparae.cxx|8 43 files changed, 559 insertions(+), 299 deletions(-) New commits: commit 3c1121fad94e82b2d4e047dd2a3a80d996240fa0 Author: Bartosz Kosiorek AuthorDate: Tue May 18 17:36:21 2021 +0200 Commit: Andras Timar CommitDate: Fri May 21 13:31:51 2021 +0200 tdf#55007 tdf#142263 tdf#142268 EMF Properly display ARC and CHORD With previous implementation the ARC, ARCTO and CHORD were not displayed if the corners of rectangle was switched. With this patch the shapes are always displayed correctly. Change-Id: Ie8ac7af812298c0b96c3b5af417117784f128ce1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115757 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 39369c6e67dffe04acc4abb678c1a94526237fd8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115524 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 53be54f34c02..24e2e295e957 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -51,6 +51,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestArcInsideWronglyDefinedRectangle(); void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestEllipseXformIntersectClipRect(); @@ -79,6 +80,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa tools/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 15 ++ emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf |binary tools/source/generic/poly.cxx |9 -- 3 files changed, 21 insertions(+), 3 deletions(-) New commits: commit 71edc1d1af9691f7b5067579f22d3d8677c1608c Author: Bartosz Kosiorek AuthorDate: Tue May 18 17:36:21 2021 +0200 Commit: Xisco Fauli CommitDate: Fri May 21 10:19:55 2021 +0200 tdf#55007 tdf#142263 tdf#142268 EMF Properly display ARC and CHORD With previous implementation the ARC, ARCTO and CHORD were not displayed if the corners of rectangle was switched. With this patch the shapes are always displayed correctly. Change-Id: Ie8ac7af812298c0b96c3b5af417117784f128ce1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115757 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 39369c6e67dffe04acc4abb678c1a94526237fd8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115524 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 53be54f34c02..24e2e295e957 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -51,6 +51,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestArcInsideWronglyDefinedRectangle(); void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestEllipseXformIntersectClipRect(); @@ -79,6 +80,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestArcInsideWronglyDefinedRectangle); CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestEllipseXformIntersectClipRect); @@ -358,6 +360,19 @@ void Test::TestChordWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 382,598 361,643 385,710 430,731 654,725 919,628"); } +void Test::TestArcInsideWronglyDefinedRectangle() +{ +// tdf#142268 EMF import test with records: ARC +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline", "color", "#00"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline/polygon", "1630,1450 1650,1470 1850,1540 1990,1540 2040,1530 2190,1470 2270,1410 2330,1350 2390,1260 2430,1160 2430,1140 2440,1090 2450,1060 2450,950 2440,930 2430,880 2430,850 2420,820 2360,710 2310,650 2250,590 2110,510 1980,480 1870,480 1770,500 1670,540 1650,560 1630,570 1600,580 1540,640 1460,740 1450,770"); +} + void Test::TestEllipseWithSelectClipPath() { // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE diff --git a/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf b/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf new file mode 100644 index ..3a785fba6cac Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf differ diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index f4631dfb1d86..8b4727782350 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -230,11 +230,14 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c const tools::Long nWidth = rBound.GetWidth(); const tools::Long nHeight = rBound.GetHeight(); -if( ( nWidth > 1 ) && ( nHeight > 1 ) ) +if( ( nWidth != 0 ) && ( nHeight != 0 ) ) { const Point aCenter( rBound.Center() ); -const tools::Long nRadX = aCenter.X() - rBound.Left(); -const tools::Long nRadY = aCenter.Y() - rBound.Top(); +// tdf#142268 Get Top Left corner of rectangle (the rectangle is not always correctly created) +const auto aBoundLeft = rBound.Left() < aCenter.X() ? rBound.Left() : rBound.Right(); +const auto aBoundTop = rBound.Top() < aCenter.Y() ? rBound.Top() : rBound.Bottom(); +const tools::Long nRadX = aCenter.X() - aBoundLeft; +const tools::Long nRadY = aCenter.Y() - aBoundTop; sal_uInt16
[Libreoffice-commits] core.git: emfio/qa emfio/source tools/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 47 --- emfio/qa/cppunit/emf/data/TestArcStartPointEqualEndPoint.emf |binary emfio/source/reader/emfreader.cxx| 19 tools/source/generic/poly.cxx|6 - 4 files changed, 40 insertions(+), 32 deletions(-) New commits: commit fb5247bf587518eaa01cf5d54dceddf73827d740 Author: Bartosz Kosiorek AuthorDate: Thu May 20 23:27:45 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri May 21 07:30:28 2021 +0200 tdf#55007 tdf#142263 tdf#142268 EMF ARC, PIE, CHORD allow to draw circle In Metafile specification, if Start Point is the same as End Point, then the full circle should be drawn. Unfortunately with previous implementation, if Start Point is the same as End Point, nothing is drawn. This patch fixes that and removed EDGES optimizations, which causes display issues. Change-Id: I16a1b98f10378d57bed59696db6cc9f228044292 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115891 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 64c7effa1baa..bca5cbc161e3 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestArcStartPointEqualEndPoint(); void TestArcInsideWronglyDefinedRectangle(); void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); @@ -82,6 +83,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestArcStartPointEqualEndPoint); CPPUNIT_TEST(TestArcInsideWronglyDefinedRectangle); CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); @@ -357,9 +359,28 @@ void Test::TestChordWithModifyWorldTransform() xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); CPPUNIT_ASSERT (pDocument); -assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", "color", "#ff"); -assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", "path", "m590 448-154 93-54 57-21 45 24 67 45 21 224-6 265-97z"); -assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 382,598 361,643 385,710 430,731 654,725 919,628"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", +"color", "#ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", +"path", "m590 448-21 45-66 24-34 12-33 12-21 45-33 12 12 33-33 12 12 33 12 34 33-12 12 33 34-12 33-12 45 21 33-12 33-12 46 21 66-25 33-12 66-24 34-12 66-24z"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", + "590,448 569,493 503,517 469,529 436,541 415,586 382,598 394,631 361,643 361,643 373,676 373,676 385,710 418,698 430,731 464,719 497,707 542,728 575,716 608,704 654,725 720,700 753,688 819,664 853,652 919,628"); +} + +void Test::TestArcStartPointEqualEndPoint() +{ +// i73608 EMF import test where StartPoint == EndPoint. It should draw full circle +// Records: SETMAPMODE, SETWINDOWEXTEX, SETWINDOWORGEX, EXTSELECTCLIPRGN, INTERSECTCLIPRECT, MOVETOEX, ARC +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcStartPointEqualEndPoint.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polygonhairline", +"color", "#00"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polygonhairline/polygon", + "11886,23133 11970,23223 12051,23316 12131,23410 12208,23506 12282,23604 12354,23704 12424,23805 12491,23909 12556,24014 12618,24120 12677,24228 12734,24337 12788,24448 12839,24560 12888,24673 12933,24788 12976,24903 13016,25020 13053,25137 13087,25256 13119,25375 13147,25495 13172,25615 13195,25736 13214,25858 13230,25980 13244,26103 13254,26225 13261,26348 13266,26472 13267,26595 13265,26718 132
[Libreoffice-commits] core.git: emfio/qa tools/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 15 ++ emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf |binary tools/source/generic/poly.cxx |9 -- 3 files changed, 21 insertions(+), 3 deletions(-) New commits: commit 39369c6e67dffe04acc4abb678c1a94526237fd8 Author: Bartosz Kosiorek AuthorDate: Tue May 18 17:36:21 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue May 18 20:42:27 2021 +0200 tdf#55007 tdf#142263 tdf#142268 EMF Properly display ARC and CHORD With previous implementation the ARC, ARCTO and CHORD were not displayed if the corners of rectangle was switched. With this patch the shapes are always displayed correctly. Change-Id: Ie8ac7af812298c0b96c3b5af417117784f128ce1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115757 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index fceb43b30215..64c7effa1baa 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestArcInsideWronglyDefinedRectangle(); void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestEllipseXformIntersectClipRect(); @@ -81,6 +82,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestArcInsideWronglyDefinedRectangle); CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestEllipseXformIntersectClipRect); @@ -360,6 +362,19 @@ void Test::TestChordWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 382,598 361,643 385,710 430,731 654,725 919,628"); } +void Test::TestArcInsideWronglyDefinedRectangle() +{ +// tdf#142268 EMF import test with records: ARC +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline", "color", "#00"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline/polygon", "1630,1460 1800,1530 1850,1540 1980,1540 2030,1530 2170,1470 2220,1440 2330,1330 2380,1240 2420,1140 2430,1060 2430,950 2420,930 2410,870 2410,850 2380,770 2290,640 2120,520 2090,510 2070,510 2040,500 2020,490 1970,480 1860,480 1760,500 1670,540 1600,580 1520,660 1510,680 1480,720 1460,740 1450,760"); +} + void Test::TestEllipseWithSelectClipPath() { // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE diff --git a/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf b/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf new file mode 100644 index ..3a785fba6cac Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf differ diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 292247478aac..88a534660894 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -230,11 +230,14 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c const auto nWidth = rBound.GetWidth(); const auto nHeight = rBound.GetHeight(); -if( ( nWidth > 1 ) && ( nHeight > 1 ) ) +if( ( nWidth != 0 ) && ( nHeight != 0 ) ) { const Point aCenter( rBound.Center() ); -const auto nRadX = o3tl::saturating_sub(aCenter.X(), rBound.Left()); -const auto nRadY = o3tl::saturating_sub(aCenter.Y(), rBound.Top()); +// tdf#142268 Get Top Left corner of rectangle (the rectangle is not always correctly created) +const auto aBoundLeft = rBound.Left() < aCenter.X() ? rBound.Left() : rBound.Right(); +const auto aBoundTop = rBound.Top() < aCenter.Y() ? rBound.Top() : rBound.Bottom(); +const auto nRadX = o3tl::saturating_sub(aCenter.X(), aBoundLeft); +const auto nRadY = o3tl::saturating_sub(aCenter.Y(), aBoundTop); sal_uInt16 nPoints; tools::Long nRadXY; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx| 17 + emfio/qa/cppunit/emf/EmfImportTest.cxx| 39 ++ emfio/qa/cppunit/wmf/data/TestPalette.wmf |binary emfio/source/reader/mtftools.cxx | 27 ++-- emfio/source/reader/wmfreader.cxx | 19 +- 5 files changed, 97 insertions(+), 5 deletions(-) New commits: commit acf9f22475fa1d35ccbf3576a1d3da9ac8aea1a2 Author: Bartosz Kosiorek AuthorDate: Thu May 13 22:04:56 2021 +0200 Commit: Xisco Fauli CommitDate: Sat May 15 18:15:16 2021 +0200 tdf#117957 WMF Add support for selecting colors from palette Change-Id: I8f995dab566d9fae79d87fe13741b8ea9658b408 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112998 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit e923f752a3adfe1a941dcbc2fdffc626a569d59e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115520 Reviewed-by: Xisco Fauli diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 22c0cef99364..eb793baca415 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -363,6 +363,22 @@ namespace emfio } }; + +struct WinMtfPalette final : GDIObj +{ +std::vector< Color > aPaletteColors; + +WinMtfPalette() +: aPaletteColors(std::vector< Color >{}) +{} + +WinMtfPalette(const std::vector< Color > rPaletteColors) +: aPaletteColors(rPaletteColors) +{} + +}; + + struct WinMtfLineStyle final : GDIObj { Color aLineColor; @@ -494,6 +510,7 @@ namespace emfio WinMtfFillStyle maLatestFillStyle; WinMtfFillStyle maFillStyle; WinMtfFillStyle maNopFillStyle; +WinMtfPalette maPalette; vcl::Font maLatestFont; vcl::Font maFont; diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index fcdf2509f3a9..53be54f34c02 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -56,6 +56,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestPalette(); void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); void TestRoundRect(); @@ -83,6 +84,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestPalette); CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); @@ -460,6 +462,43 @@ void Test::TestPolylinetoCloseStroke() "color", "#00"); } + +void Test::TestPalette() +{ +// WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestPalette.wmf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", +"path", "m2433 1216.5c0 213.540351086756-56.2099207528522 423.318631225821-162.98009629623 608.25s-260.338534929591 338.499728160392-445.269903703769 445.26990370377-394.709648913244 162.98009629623-608.25 162.98009629623-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160392-260.338534929591-445.26990370377-445.26990370377-162.980096296231-394.709648913244-162.980096296231-608.25c-2.70117261891301E-013-213.540351086756 56.2099207528519-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.338534929591-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-5.40234523782601E-013 423.318631225821 56.2099207528518 608.25 162.98009629623s338.499728160392 260.338534929591 445.26990370377 445.269903703769c106.770175543379 184.931368774179 162.980096296231 394.709648913244 162.980096296231 608.25z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", +"color", "#00"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", +"path", "m5079 3862.5c0 213.540351086756-56.2099207528527 423.318631225821-162.98009
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx| 17 + emfio/qa/cppunit/emf/EmfImportTest.cxx| 39 ++ emfio/qa/cppunit/wmf/data/TestPalette.wmf |binary emfio/source/reader/mtftools.cxx | 27 ++-- emfio/source/reader/wmfreader.cxx | 19 +- 5 files changed, 97 insertions(+), 5 deletions(-) New commits: commit e923f752a3adfe1a941dcbc2fdffc626a569d59e Author: Bartosz Kosiorek AuthorDate: Thu May 13 22:04:56 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Sat May 15 16:53:08 2021 +0200 tdf#117957 WMF Add support for selecting colors from palette Change-Id: I8f995dab566d9fae79d87fe13741b8ea9658b408 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112998 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index c79bdae4c4d7..0fb99761d386 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -366,6 +366,22 @@ namespace emfio } }; + +struct WinMtfPalette final : GDIObj +{ +std::vector< Color > aPaletteColors; + +WinMtfPalette() +: aPaletteColors(std::vector< Color >{}) +{} + +WinMtfPalette(const std::vector< Color > rPaletteColors) +: aPaletteColors(rPaletteColors) +{} + +}; + + struct WinMtfLineStyle final : GDIObj { Color aLineColor; @@ -497,6 +513,7 @@ namespace emfio WinMtfFillStyle maLatestFillStyle; WinMtfFillStyle maFillStyle; WinMtfFillStyle maNopFillStyle; +WinMtfPalette maPalette; vcl::Font maLatestFont; vcl::Font maFont; diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index be9a8a741fb2..fceb43b30215 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -58,6 +58,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestPalette(); void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); void TestRoundRect(); @@ -85,6 +86,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestPalette); CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); @@ -462,6 +464,43 @@ void Test::TestPolylinetoCloseStroke() "color", "#00"); } + +void Test::TestPalette() +{ +// WMF import with records: CREATEPALETTE, SELECTOBJECT, CREATEPENINDIRECT, CREATEBRUSHINDIRECT, ELLIPSE. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/wmf/data/TestPalette.wmf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", +"path", "m2433 1216.5c0 213.540351086756-56.2099207528522 423.318631225821-162.98009629623 608.25s-260.338534929591 338.499728160392-445.269903703769 445.26990370377-394.709648913244 162.98009629623-608.25 162.98009629623-423.318631225821-56.2099207528518-608.25-162.98009629623-338.499728160392-260.338534929591-445.26990370377-445.26990370377-162.980096296231-394.709648913244-162.980096296231-608.25c-2.70117261891301E-013-213.540351086756 56.2099207528519-423.318631225821 162.98009629623-608.25 106.770175543378-184.931368774179 260.338534929591-338.499728160392 445.269903703769-445.26990370377s394.709648913244-162.980096296231 608.25-162.980096296231c213.540351086756-5.40234523782601E-013 423.318631225821 56.2099207528518 608.25 162.98009629623s338.499728160392 260.338534929591 445.26990370377 445.269903703769c106.770175543379 184.931368774179 162.980096296231 394.709648913244 162.980096296231 608.25z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", +"color", "#00"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", +"path", "m5079 3862.5c0 213.540351086756-56.2099207528527 423.318631225821-162.980096296231 608.25s-260.33853492959 338.499728160391-445.269903703769 445.269903703769-394.709648913244 162.980096296231-608.25 162.980096296231-423.318631225
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 22 emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf |binary emfio/source/reader/mtftools.cxx| 12 +--- 3 files changed, 30 insertions(+), 4 deletions(-) New commits: commit c0e6031e173c2c0efe0715af9fd8dd205c74a030 Author: Bartosz Kosiorek AuthorDate: Thu May 13 20:11:19 2021 +0200 Commit: Xisco Fauli CommitDate: Fri May 14 09:11:37 2021 +0200 tdf#142014 Fix displaying strokes when line width is 0 Change-Id: I80e05ff2f24f5da2f5c124c0ee1b302a1c8226ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115570 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 699295ca7cab3a4f4e801a14496f202c05d18899) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115514 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 4629005984ed..fcdf2509f3a9 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -56,6 +56,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); void TestRoundRect(); void TestCreatePen(); @@ -82,6 +83,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); @@ -438,6 +440,26 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#00"); } +void Test::TestPolylinetoCloseStroke() +{ +// EMF import with records: BEGINPATH, ARC, ENDPATH, STROKEPATH, EXTCREATEPEN. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline", 2); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]/polygon", + "1080,150 810,230 570,340 370,490 290,570 170,750 130,840 100,980 100,1080 140,1270 160,1320 210,1410 400,1620 500,1690"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]", +"color", "#00"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]/polygon", + "1760,1120 1500,1180 1350,1240 1230,1310 1210,1330 1120,1440 1110,1460 1100,1510 1100,1580 1140,1670 1170,1710 1190,1730"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]", +"color", "#00"); +} + void Test::TestPolyLineWidth() { // EMF import with records: CREATEPEN, ROUNDRECT. diff --git a/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf b/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf new file mode 100644 index ..e89e92272943 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index bdae896a0e4e..989970c9cb8b 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1305,11 +1305,15 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaPopAction() ); } // tdf#142014 By default the stroke is made with hairline. If width is bigger, we need to use PolyLineAction -if ( bStroke && ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) ) +if ( bStroke ) { -sal_uInt16 i, nCount = maPathObj.Count(); -for ( i = 0; i < nCount; i++ ) -mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) ); +// bFill is drawing hairstyle line. So we need to to draw it only when the width is different than 0 +if ( !bFill || maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) +{ +sal_uInt16 i, nCount = maPathObj.Count(); +for ( i = 0; i < nCount; i++ ) +mpGDIMetaFile->AddAction( new MetaPolyLineA
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 22 emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf |binary emfio/source/reader/mtftools.cxx| 12 +--- 3 files changed, 30 insertions(+), 4 deletions(-) New commits: commit 699295ca7cab3a4f4e801a14496f202c05d18899 Author: Bartosz Kosiorek AuthorDate: Thu May 13 20:11:19 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu May 13 22:00:05 2021 +0200 tdf#142014 Fix displaying strokes when line width is 0 Change-Id: I80e05ff2f24f5da2f5c124c0ee1b302a1c8226ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115570 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 9e53b261a544..be9a8a741fb2 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -58,6 +58,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestPolylinetoCloseStroke(); void TestPolyLineWidth(); void TestRoundRect(); void TestCreatePen(); @@ -84,6 +85,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestPolylinetoCloseStroke); CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); @@ -440,6 +442,26 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#00"); } +void Test::TestPolylinetoCloseStroke() +{ +// EMF import with records: BEGINPATH, ARC, ENDPATH, STROKEPATH, EXTCREATEPEN. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline", 2); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]/polygon", + "1080,150 810,230 570,340 370,490 290,570 170,750 130,840 100,980 100,1080 140,1270 160,1320 210,1410 400,1620 500,1690"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[1]", +"color", "#00"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]/polygon", + "1760,1120 1500,1180 1350,1240 1230,1310 1210,1330 1120,1440 1110,1460 1100,1510 1100,1580 1140,1670 1170,1710 1190,1730"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonhairline[2]", +"color", "#00"); +} + void Test::TestPolyLineWidth() { // EMF import with records: CREATEPEN, ROUNDRECT. diff --git a/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf b/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf new file mode 100644 index ..e89e92272943 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestPolylinetoCloseStroke.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 2d9fe3601ebd..011ff4647a11 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1323,11 +1323,15 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaPopAction() ); } // tdf#142014 By default the stroke is made with hairline. If width is bigger, we need to use PolyLineAction -if ( bStroke && ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) ) +if ( bStroke ) { -sal_uInt16 i, nCount = maPathObj.Count(); -for ( i = 0; i < nCount; i++ ) -mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) ); +// bFill is drawing hairstyle line. So we need to to draw it only when the width is different than 0 +if ( !bFill || maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) +{ +sal_uInt16 i, nCount = maPathObj.Count(); +for ( i = 0; i < nCount; i++ ) +mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) ); +} } ClearPath(); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf |binary emfio/source/reader/mtftools.cxx| 10 +- 3 files changed, 33 insertions(+), 1 deletion(-) New commits: commit 3ffc0afce0f26900a4e1d9feed2c21108e1ed41b Author: Bartosz Kosiorek AuthorDate: Wed May 12 19:03:59 2021 +0200 Commit: Xisco Fauli CommitDate: Wed May 12 22:23:58 2021 +0200 tdf#112603 tdf#142014 tdf#142139 WMF/EMF Fix line width Previosly line width was always 1, and changing width do not affect line. Change-Id: I462096b915e053fa089e85860f124466b650558a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115497 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit b5ece3fbc7f878846298fd9196e5a30ba50e0dc2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115512 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 52fab033941a..4629005984ed 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -56,6 +56,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestPolyLineWidth(); void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -81,6 +82,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); @@ -436,6 +438,28 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#00"); } +void Test::TestPolyLineWidth() +{ +// EMF import with records: CREATEPEN, ROUNDRECT. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", +"path", "m530 529 1236-176-707 352z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", +"color", "#00"); + +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", + "530,529 530,529 1766,353 1059,705"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line", +"color", "#00"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line", +"width", "71"); +} + void Test::TestRoundRect() { // EMF import with records: CREATEPEN, ROUNDRECT. diff --git a/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf b/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf new file mode 100644 index ..792694fa8c99 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index d54e0ff763ae..bdae896a0e4e 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1304,7 +1304,8 @@ namespace emfio if ( !bStroke ) mpGDIMetaFile->AddAction( new MetaPopAction() ); } -else +// tdf#142014 By default the stroke is made with hairline. If width is bigger, we need to use PolyLineAction +if ( bStroke && ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) ) { sal_uInt16 i, nCount = maPathObj.Count(); for ( i = 0; i < nCount; i++ ) @@ -1390,6 +1391,13 @@ namespace emfio UpdateLineStyle(); UpdateFillStyle(); mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), std::abs( ImplMap( rSize ).Width() ), std::abs( ImplMap( rSize ).Height() ) ) ); +// tdf#142139 Wrong line width during WMF import +if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) +{ +tools::Polygon aRoundRectPoly( rRect, rSize.Width(), rSize.Height() ); +aRoundRectPoly.Optimize( PolyOptimizeFlags::EDGES ); +mpGDIMetaFile->AddAction( new MetaPolyLineAction( ImplMap( aRoundRect
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf |binary emfio/source/reader/mtftools.cxx| 10 +- 3 files changed, 33 insertions(+), 1 deletion(-) New commits: commit b5ece3fbc7f878846298fd9196e5a30ba50e0dc2 Author: Bartosz Kosiorek AuthorDate: Wed May 12 19:03:59 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Wed May 12 20:32:27 2021 +0200 tdf#112603 tdf#142014 tdf#142139 WMF/EMF Fix line width Previosly line width was always 1, and changing width do not affect line. Change-Id: I462096b915e053fa089e85860f124466b650558a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115497 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 78e613e2eafa..9e53b261a544 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -58,6 +58,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestPolyLineWidth(); void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -83,6 +84,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestPolyLineWidth); CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); @@ -438,6 +440,28 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#00"); } +void Test::TestPolyLineWidth() +{ +// EMF import with records: CREATEPEN, ROUNDRECT. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", +"path", "m530 529 1236-176-707 352z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", +"color", "#00"); + +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", + "530,529 530,529 1766,353 1059,705"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line", +"color", "#00"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke/line", +"width", "71"); +} + void Test::TestRoundRect() { // EMF import with records: CREATEPEN, ROUNDRECT. diff --git a/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf b/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf new file mode 100644 index ..792694fa8c99 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestPolyLineWidth.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 2b1c1d406d1b..2d9fe3601ebd 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1322,7 +1322,8 @@ namespace emfio if ( !bStroke ) mpGDIMetaFile->AddAction( new MetaPopAction() ); } -else +// tdf#142014 By default the stroke is made with hairline. If width is bigger, we need to use PolyLineAction +if ( bStroke && ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) ) { sal_uInt16 i, nCount = maPathObj.Count(); for ( i = 0; i < nCount; i++ ) @@ -1408,6 +1409,13 @@ namespace emfio UpdateLineStyle(); UpdateFillStyle(); mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), std::abs( ImplMap( rSize ).Width() ), std::abs( ImplMap( rSize ).Height() ) ) ); +// tdf#142139 Wrong line width during WMF import +if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LineStyle::Dash ) ) +{ +tools::Polygon aRoundRectPoly( rRect, rSize.Width(), rSize.Height() ); +aRoundRectPoly.Optimize( PolyOptimizeFlags::EDGES ); +mpGDIMetaFile->AddAction( new MetaPolyLineAction( ImplMap( aRoundRectPoly ), maLineStyle.aLineInfo ) ); +} } void MtfTools::DrawEllipse( const tools::Rectangle& rRect ) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 36 +++- emfio/qa/cppunit/emf/data/TestRoundRect.emf |binary emfio/source/reader/emfreader.cxx |5 ++- 3 files changed, 38 insertions(+), 3 deletions(-) New commits: commit 2a416c0c4a1635af8be5b1167fd1f06bdc4a2466 Author: Bartosz Kosiorek AuthorDate: Tue May 11 17:24:20 2021 +0200 Commit: Xisco Fauli CommitDate: Tue May 11 22:34:34 2021 +0200 tdf#141982 tdf#142139 Add rotation and line width support to ROUNDRECT With this commit the ROUNDRECT is able to change line width and transformation (including rotation) is supported. Change-Id: Ic303a74adf0fd0dd452353f250a13140603d492e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115429 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit f11ed681df15728abe6a0b6b7b1612f190aa1707) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115282 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 8dc864fb657e..52fab033941a 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -56,6 +56,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -80,6 +81,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); CPPUNIT_TEST_SUITE_END(); @@ -414,7 +416,7 @@ void Test::TestDrawPolyLine16WithClip() void Test::TestFillRegion() { -// Check import of EMF image with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used. +// EMF import with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used. Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestFillRegion.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -434,6 +436,38 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#00"); } +void Test::TestRoundRect() +{ +// EMF import with records: CREATEPEN, ROUNDRECT. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRoundRect.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", +"path", "m100 100h4000v2000h-4000z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", +"color", "#ff"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke", 2); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", + "100,100 4100,100 4100,2100 100,2100"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/line", +"color", "#ff"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]/polypolygon", +"path", "m4090 2650-10-50-10-30-50-90-100-110-20-10-30-20-20-20-30-20-90-40-100-30-170-30h-2730l-140 20-130 40-90 40-30 20-20 20-30 20-20 10-100 110-50 90-10 30-10 50v1090l10 50 10 30 50 90 100 110 20 10 30 20 20 20 30 20 90 40 100 30 170 30h2730l140-20 130-40 90-40 30-20 20-20 30-20 20-10 100-110 50-90 10-30 10-50z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]", +"color", "#ff"); + +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/polygon", + "4090,2650 4080,2600 4070,2570 4020,2480 3920,2370 3900,2360 3870,2340 3850,2320 3820,2300 3730,2260 3630,2230 3460,2200 730,2200 590,2220 460,2260 370,2300 340,2320 320,2340 290,2360 270,2370 170,2480 120,2570 110,2600 100,2650 100,3740 110,3790 120,3820 170,3910 270,4020 290,4030 320,4050 340,4070 370,4090 460,4130 560,4160 730,4190 3460,4190 3600,4170 3730,4130 3820,4090 3850,4070 3870,4050 3900,4030 3920,
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 36 +++- emfio/qa/cppunit/emf/data/TestRoundRect.emf |binary emfio/source/reader/emfreader.cxx |5 ++- 3 files changed, 38 insertions(+), 3 deletions(-) New commits: commit f11ed681df15728abe6a0b6b7b1612f190aa1707 Author: Bartosz Kosiorek AuthorDate: Tue May 11 17:24:20 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Tue May 11 18:38:08 2021 +0200 tdf#141982 tdf#142139 Add rotation and line width support to ROUNDRECT With this commit the ROUNDRECT is able to change line width and transformation (including rotation) is supported. Change-Id: Ic303a74adf0fd0dd452353f250a13140603d492e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115429 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index e5b1f3f54114..78e613e2eafa 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -58,6 +58,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); +void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -82,6 +83,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); +CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); CPPUNIT_TEST_SUITE_END(); @@ -416,7 +418,7 @@ void Test::TestDrawPolyLine16WithClip() void Test::TestFillRegion() { -// Check import of EMF image with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used. +// EMF import with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used. Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestFillRegion.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -436,6 +438,38 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#00"); } +void Test::TestRoundRect() +{ +// EMF import with records: CREATEPEN, ROUNDRECT. +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRoundRect.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 2); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", +"path", "m100 100h4000v2000h-4000z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", +"color", "#ff"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke", 2); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", + "100,100 4100,100 4100,2100 100,2100"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/line", +"color", "#ff"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]/polypolygon", +"path", "m4090 2650-10-50-10-30-50-90-100-110-20-10-30-20-20-20-30-20-90-40-100-30-170-30h-2730l-140 20-130 40-90 40-30 20-20 20-30 20-20 10-100 110-50 90-10 30-10 50v1090l10 50 10 30 50 90 100 110 20 10 30 20 20 20 30 20 90 40 100 30 170 30h2730l140-20 130-40 90-40 30-20 20-20 30-20 20-10 100-110 50-90 10-30 10-50z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]", +"color", "#ff"); + +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/polygon", + "4090,2650 4080,2600 4070,2570 4020,2480 3920,2370 3900,2360 3870,2340 3850,2320 3820,2300 3730,2260 3630,2230 3460,2200 730,2200 590,2220 460,2260 370,2300 340,2320 320,2340 290,2360 270,2370 170,2480 120,2570 110,2600 100,2650 100,3740 110,3790 120,3820 170,3910 270,4020 290,4030 320,4050 340,4070 370,4090 460,4130 560,4160 730,4190 3460,4190 3600,4170 3730,4130 3820,4090 3850,4070 3870,4050 3900,4030 3920,4020 4020,3910 4070,3820 4080,3790 4090,3740"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/line", +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |6 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 17 + emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf |binary emfio/source/reader/mtftools.cxx| 34 +++--- 4 files changed, 45 insertions(+), 12 deletions(-) New commits: commit a67a30227ef32ab9fc3026bb19e48d4447df25d1 Author: Bartosz Kosiorek AuthorDate: Tue May 4 16:08:35 2021 +0200 Commit: Xisco Fauli CommitDate: Mon May 10 10:10:23 2021 +0200 tdf#55058 tdf#141982 EMF: Add rotation support for INTERSECTCLIPRECT record With this commit the rotation support was added for INTERSECTCLIPRECT. Before that change rotation was not applied to these CLIP rectangles. Change-Id: I3da66790e0aeeaaeeb28d2fc30780cba8dbda390 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115102 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 1ef26ffe39618a745d3367310565e7eeb184a4c2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115207 Reviewed-by: Xisco Fauli diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 286442767d3a..22c0cef99364 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -273,9 +273,9 @@ namespace emfio public: WinMtfClipPath() : maClip() {}; -voidsetClipPath(const tools::PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode); -voidintersectClipRect(const tools::Rectangle& rRect); -voidexcludeClipRect(const tools::Rectangle& rRect); +voidsetClipPath(const basegfx::B2DPolyPolygon&, sal_Int32 nClippingMode); +voidintersectClip(const basegfx::B2DPolyPolygon& rPolyPolygon); +voidexcludeClip(const basegfx::B2DPolyPolygon& rPolyPolygon); voidmoveClipRegion(const Size& rSize); voidsetDefaultClipPath(); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 1f1976c0a2a3..8dc864fb657e 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestRectangleWithModifyWorldTransform(); void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); +void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -76,6 +77,7 @@ public: CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); +CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -368,6 +370,21 @@ void Test::TestEllipseWithSelectClipPath() assertXPathContent(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke[1]/polygon", "353,353 2825,353 2825,1410 353,1410"); } +void Test::TestEllipseXformIntersectClipRect() +{ +// EMF import test with records: EXTCREATEPEN, CREATEBRUSHINDIRECT, MODIFYWORLDTRANSFORM, INTERSECTCLIPRECT, ELLIPSE +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h3000v2000h-3000z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polypolygon", "path", "m370 152 1128-409 592 1623-1128 410z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polypolygoncolor/polypolygon", "path", "m3565 155-58-55-205-150-90-42-124-30-392-45-368 21-211 39-598 217-187 105-21 46-121 81-66 24-87 69-272 287-75 102-42 90-61 247-9 79 97 265 57 54 205 150 91 42 124 31 392 45 112-3 467-58 597-217 187-105 296-220 271-286 76-103 42-90 60-247 9-78z"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polygonstroke/polygon", "3565,155 3507,100 3302,-50 3212,-92 3088,-122 2696,-167 2328,-146 2117,-107 1519,110 1332,215 1311,261 1190,342 1124,366 1037,435 765,722 690,824 648,914 587,1161 578,1240 675,1505 732,1559 937,1709 1028,1751 1152,1782 1544,1827 1656,1824 2123,1766 2720,1549 2907,1444 3203,1224 3474,938 3550,835 3592,745 3652,498 3661,420"); +} + void Test::TestDrawPolyLine1
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |6 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 17 + emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf |binary emfio/source/reader/mtftools.cxx| 34 +++--- 4 files changed, 45 insertions(+), 12 deletions(-) New commits: commit 1ef26ffe39618a745d3367310565e7eeb184a4c2 Author: Bartosz Kosiorek AuthorDate: Tue May 4 16:08:35 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Fri May 7 21:02:22 2021 +0200 tdf#55058 tdf#141982 EMF: Add rotation support for INTERSECTCLIPRECT record With this commit the rotation support was added for INTERSECTCLIPRECT. Before that change rotation was not applied to these CLIP rectangles. Change-Id: I3da66790e0aeeaaeeb28d2fc30780cba8dbda390 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115102 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index cd2484606f07..c79bdae4c4d7 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -273,9 +273,9 @@ namespace emfio public: WinMtfClipPath() : maClip() {}; -voidsetClipPath(const tools::PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode); -voidintersectClipRect(const tools::Rectangle& rRect); -voidexcludeClipRect(const tools::Rectangle& rRect); +voidsetClipPath(const basegfx::B2DPolyPolygon&, sal_Int32 nClippingMode); +voidintersectClip(const basegfx::B2DPolyPolygon& rPolyPolygon); +voidexcludeClip(const basegfx::B2DPolyPolygon& rPolyPolygon); voidmoveClipRegion(const Size& rSize); voidsetDefaultClipPath(); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 83b42a3020d0..e5b1f3f54114 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -55,6 +55,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestRectangleWithModifyWorldTransform(); void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); +void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -78,6 +79,7 @@ public: CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); +CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -370,6 +372,21 @@ void Test::TestEllipseWithSelectClipPath() assertXPathContent(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke[1]/polygon", "353,353 2825,353 2825,1410 353,1410"); } +void Test::TestEllipseXformIntersectClipRect() +{ +// EMF import test with records: EXTCREATEPEN, CREATEBRUSHINDIRECT, MODIFYWORLDTRANSFORM, INTERSECTCLIPRECT, ELLIPSE +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h3000v2000h-3000z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polypolygon", "path", "m370 152 1128-409 592 1623-1128 410z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polypolygoncolor/polypolygon", "path", "m3565 155-58-55-205-150-90-42-124-30-392-45-368 21-211 39-598 217-187 105-21 46-121 81-66 24-87 69-272 287-75 102-42 90-61 247-9 79 97 265 57 54 205 150 91 42 124 31 392 45 112-3 467-58 597-217 187-105 296-220 271-286 76-103 42-90 60-247 9-78z"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group/mask/polygonstroke/polygon", "3565,155 3507,100 3302,-50 3212,-92 3088,-122 2696,-167 2328,-146 2117,-107 1519,110 1332,215 1311,261 1190,342 1124,366 1037,435 765,722 690,824 648,914 587,1161 578,1240 675,1505 732,1559 937,1709 1028,1751 1152,1782 1544,1827 1656,1824 2123,1766 2720,1549 2907,1444 3203,1224 3474,938 3550,835 3592,745 3652,498 3661,420"); +} + void Test::TestDrawPolyLine16WithClip() { // Check import of EMF image with records: diff --git a/emfio/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf b/emfio
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 16 emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf |binary emfio/source/reader/emfreader.cxx | 36 -- 3 files changed, 33 insertions(+), 19 deletions(-) New commits: commit 6eac9d960f2bb5dae54ef6ca8e7c659e8c79d011 Author: Bartosz Kosiorek AuthorDate: Thu May 6 17:43:57 2021 +0200 Commit: Xisco Fauli CommitDate: Thu May 6 22:21:10 2021 +0200 tdf#55058 tdf#141982 EMF: Add rotation support for ARC, ARCTO, CHORD, PIE Change-Id: I5d9b76f0ddd2b7f12604f472986dd95976a8b04d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115185 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 6bf2239a189423d087b2536dd7054b21df58ddc4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115198 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 095ff57f4c0b..1f1976c0a2a3 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -51,6 +51,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); @@ -73,6 +74,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); @@ -332,6 +334,20 @@ void Test::TestRectangleWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 2313,1556 1395,1028"); } +void Test::TestChordWithModifyWorldTransform() +{ +// EMF import test with records: CHORD, MODIFYWORLDTRANSFORM, EXTCREATEPEN, SELECTOBJECT +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", "color", "#ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", "path", "m590 448-154 93-54 57-21 45 24 67 45 21 224-6 265-97z"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 382,598 361,643 385,710 430,731 654,725 919,628"); +} + void Test::TestEllipseWithSelectClipPath() { // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE diff --git a/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf b/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf new file mode 100644 index ..991a1f802fae Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf differ diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 4691eff85410..9375da294180 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1351,18 +1351,17 @@ namespace emfio break; case EMR_ARC : -{ -sal_uInt32 nStartX, nStartY, nEndX, nEndY; -mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); -DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); -} -break; - +case EMR_ARCTO : case EMR_CHORD : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); -DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); +tools::Polygon aPoly( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Arc ); +
[Libreoffice-commits] core.git: 2 commits - emfio/qa emfio/source svx/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 16 emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf |binary emfio/source/reader/emfreader.cxx | 36 -- svx/source/svdraw/svdedxv.cxx | 15 +--- 4 files changed, 38 insertions(+), 29 deletions(-) New commits: commit 6bf2239a189423d087b2536dd7054b21df58ddc4 Author: Bartosz Kosiorek AuthorDate: Thu May 6 17:43:57 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu May 6 20:59:19 2021 +0200 tdf#55058 tdf#141982 EMF: Add rotation support for ARC, ARCTO, CHORD, PIE Change-Id: I5d9b76f0ddd2b7f12604f472986dd95976a8b04d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115185 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 3b08f7fe7d21..83b42a3020d0 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestChordWithModifyWorldTransform(); void TestEllipseWithSelectClipPath(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); @@ -75,6 +76,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestChordWithModifyWorldTransform); CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); @@ -334,6 +336,20 @@ void Test::TestRectangleWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 2313,1556 1395,1028"); } +void Test::TestChordWithModifyWorldTransform() +{ +// EMF import test with records: CHORD, MODIFYWORLDTRANSFORM, EXTCREATEPEN, SELECTOBJECT +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", "color", "#ff"); +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor/polypolygon", "path", "m590 448-154 93-54 57-21 45 24 67 45 21 224-6 265-97z"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 382,598 361,643 385,710 430,731 654,725 919,628"); +} + void Test::TestEllipseWithSelectClipPath() { // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE diff --git a/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf b/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf new file mode 100644 index ..991a1f802fae Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf differ diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 3f1945bf35a5..96c935a0c74c 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1367,18 +1367,17 @@ namespace emfio break; case EMR_ARC : -{ -sal_uInt32 nStartX, nStartY, nEndX, nEndY; -mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); -DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); -} -break; - +case EMR_ARCTO : case EMR_CHORD : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); -DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); +tools::Polygon aPoly( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Arc ); +aPoly.Optimize( PolyOptimizeFlags::EDGES );
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 +++- emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf |binary emfio/source/reader/emfreader.cxx |8 +++- 3 files changed, 29 insertions(+), 3 deletions(-) New commits: commit eb1ec67f9a479148044f3869afe461e0f4533f22 Author: Bartosz Kosiorek AuthorDate: Tue May 4 13:37:40 2021 +0200 Commit: Xisco Fauli CommitDate: Thu May 6 18:03:33 2021 +0200 tdf#142004 tdf#141982 EMF Import: Add rotation and path support for EMR_ELLIPSE Previous implementation of EMR_ELLIPSE, doesn't support rotation and EMR_ELLIPSE was not work with EMR_BEGINPATH, EMR_ENDPATH and EMR_ABORTPATH The EMR_BEGINPATH opens path bracket construction. Once path bracket construction is open, an application can begin specifying records to define the points that lie in the path. Path bracket construction MUST be closed by an EMR_ABORTPATH or EMR_ENDPATH record. With this patch all these issue was resolved for EMR_ELLIPSE Change-Id: I6d352e0ff0326dd788d43272bf1330fa6c777df4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115101 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 761fdaf26dc9ed7cd0d25a7630576e7800813e2f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115194 Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 2ab03251f54e..095ff57f4c0b 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -51,6 +51,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestEllipseWithSelectClipPath(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -72,6 +73,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -312,7 +314,6 @@ void Test::TestEnglishMapMode() assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[3]/polygon", "12699,1058 16933,1058 16933,2118 15346,2118 15346,6349 14287,6349 14287,2118 12699,2118"); } - void Test::TestRectangleWithModifyWorldTransform() { // Check import of EMF image with records: EXTCREATEPEN, SELECTOBJECT, MODIFYWORLDTRANSFORM, RECTANGLE @@ -331,6 +332,26 @@ void Test::TestRectangleWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 2313,1556 1395,1028"); } +void Test::TestEllipseWithSelectClipPath() +{ +// EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygon", 1); +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygon[1]", "path", "m2790 705-106-106-106-70-318-106-424-70h-706l-35 35-247 35h-142l-318 106-105 70-106 106v141l106 106 105 70 318 106 424 71h706l424-71 318-106 106-70 106-106"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor", 1); +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]", "color", "#00"); +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]/polypolygon[1]", "path", "m353 353h2472v1057h-2472z"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke", 1); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke[1]/polygon", "353,353 2825,353 2825,1410 353,1410"); +} + void Test::TestDrawPolyLine16WithClip() { // Check import of EMF image with records: @@ -356,7 +377,6 @@ void Test::TestDrawPolyLine16WithClip() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polypolygon", "path", "m2646 0v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323v-1322"); assertXPathContent(pDocument
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 +++- emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf |binary emfio/source/reader/emfreader.cxx |8 +++- 3 files changed, 29 insertions(+), 3 deletions(-) New commits: commit 761fdaf26dc9ed7cd0d25a7630576e7800813e2f Author: Bartosz Kosiorek AuthorDate: Tue May 4 13:37:40 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu May 6 12:12:40 2021 +0200 tdf#142004 tdf#141982 EMF Import: Add rotation and path support for EMR_ELLIPSE Previous implementation of EMR_ELLIPSE, doesn't support rotation and EMR_ELLIPSE was not work with EMR_BEGINPATH, EMR_ENDPATH and EMR_ABORTPATH The EMR_BEGINPATH opens path bracket construction. Once path bracket construction is open, an application can begin specifying records to define the points that lie in the path. Path bracket construction MUST be closed by an EMR_ABORTPATH or EMR_ENDPATH record. With this patch all these issue was resolved for EMR_ELLIPSE Change-Id: I6d352e0ff0326dd788d43272bf1330fa6c777df4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115101 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index aa62dcd4b00b..3b08f7fe7d21 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); +void TestEllipseWithSelectClipPath(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -74,6 +75,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); +CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -314,7 +316,6 @@ void Test::TestEnglishMapMode() assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[3]/polygon", "12699,1058 16933,1058 16933,2118 15346,2118 15346,6349 14287,6349 14287,2118 12699,2118"); } - void Test::TestRectangleWithModifyWorldTransform() { // Check import of EMF image with records: EXTCREATEPEN, SELECTOBJECT, MODIFYWORLDTRANSFORM, RECTANGLE @@ -333,6 +334,26 @@ void Test::TestRectangleWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 2313,1556 1395,1028"); } +void Test::TestEllipseWithSelectClipPath() +{ +// EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); + +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygon", 1); +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygon[1]", "path", "m2790 705-106-106-106-70-318-106-424-70h-706l-35 35-247 35h-142l-318 106-105 70-106 106v141l106 106 105 70 318 106 424 71h706l424-71 318-106 106-70 106-106"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor", 1); +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]", "color", "#00"); +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]/polypolygon[1]", "path", "m353 353h2472v1057h-2472z"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke", 1); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke[1]/polygon", "353,353 2825,353 2825,1410 353,1410"); +} + void Test::TestDrawPolyLine16WithClip() { // Check import of EMF image with records: @@ -358,7 +379,6 @@ void Test::TestDrawPolyLine16WithClip() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polypolygon", "path", "m2646 0v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323v-1322"); assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polygonstroke/polygon", "0,793 3969,4230"); - } void Test::TestFillRegion() diff
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 25 -- emfio/qa/cppunit/emf/data/TestRectangleWithModifyWorldTransform.emf |binary emfio/source/reader/emfreader.cxx |9 +++ 3 files changed, 30 insertions(+), 4 deletions(-) New commits: commit d08f1242ab3775c5f22d5624b91572c54d3fec81 Author: Bartosz Kosiorek AuthorDate: Tue May 4 16:49:25 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Thu May 6 08:59:50 2021 +0200 tdf#55058 tdf#141982 EMF: Add rotation and path support for RECTANGLE record Previous implementation of EMR_RECTANGLE, doesn't support rotation and EMR_RECTANGLE was not work with EMR_BEGINPATH, EMR_ENDPATH and EMR_ABORTPATH The EMR_BEGINPATH opens path bracket construction. Once path bracket construction is open, an application can begin specifying records to define the points that lie in the path. Path bracket construction MUST be closed by an EMR_ABORTPATH or EMR_ENDPATH record. With this patch all these issue was resolved for EMR_RECTANGLE Change-Id: Ic51442df8905e47c92eed811cc776762c9752af2 Change-Id: I111f183e509f03c0b276a038680f61156b37b235 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115065 Tested-by: Jenkins Tested-by: Xisco Fauli Reviewed-by: Bartosz Kosiorek Reviewed-by: Xisco Fauli (cherry picked from commit 24e71494d7d1a68b2cb5f5d34083ab02009e0982) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115079 diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 51c0cc115987..2ab03251f54e 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -50,6 +50,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestLinearGradient(); void TestTextMapMode(); void TestEnglishMapMode(); +void TestRectangleWithModifyWorldTransform(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -70,6 +71,7 @@ public: CPPUNIT_TEST(TestLinearGradient); CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); +CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -125,7 +127,7 @@ void Test::testPolyPolygon() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h19746v14817h-19746z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ff"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19780v14851h-19780z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19781v14852h-19781z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 116); @@ -292,7 +294,7 @@ void Test::TestEnglishMapMode() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 3); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ad"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m-1-1h29699v21005h-29699z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m-1-1h29700v21001h-29700z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m1058 7937v5293h3175v-1059h-2118v-4234z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[3]/polypolygon", "path", "m12699 1058h4234v1060h-1587v4231h-1059v-4231h-1588z"); @@ -305,11 +307,28 @@ void Test::TestEnglishMapMode() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "height", "424"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 3); -assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon", "-1,-1 29698,-1 29698,21004 -1,21004"); +assertXPathContent(pDocument, &quo
[Libreoffice-commits] core.git: emfio/qa emfio/source
emfio/qa/cppunit/emf/EmfImportTest.cxx | 25 -- emfio/qa/cppunit/emf/data/TestRectangleWithModifyWorldTransform.emf |binary emfio/source/reader/emfreader.cxx |9 +++ 3 files changed, 30 insertions(+), 4 deletions(-) New commits: commit 24e71494d7d1a68b2cb5f5d34083ab02009e0982 Author: Bartosz Kosiorek AuthorDate: Tue May 4 16:49:25 2021 +0200 Commit: Bartosz Kosiorek CommitDate: Wed May 5 10:24:01 2021 +0200 tdf#55058 tdf#141982 EMF: Add rotation and path support for RECTANGLE record Previous implementation of EMR_RECTANGLE, doesn't support rotation and EMR_RECTANGLE was not work with EMR_BEGINPATH, EMR_ENDPATH and EMR_ABORTPATH The EMR_BEGINPATH opens path bracket construction. Once path bracket construction is open, an application can begin specifying records to define the points that lie in the path. Path bracket construction MUST be closed by an EMR_ABORTPATH or EMR_ENDPATH record. With this patch all these issue was resolved for EMR_RECTANGLE Change-Id: Ic51442df8905e47c92eed811cc776762c9752af2 Change-Id: I111f183e509f03c0b276a038680f61156b37b235 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115065 Tested-by: Jenkins Tested-by: Xisco Fauli Reviewed-by: Bartosz Kosiorek Reviewed-by: Xisco Fauli diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 590b0e6beac1..aa62dcd4b00b 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -52,6 +52,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestLinearGradient(); void TestTextMapMode(); void TestEnglishMapMode(); +void TestRectangleWithModifyWorldTransform(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -72,6 +73,7 @@ public: CPPUNIT_TEST(TestLinearGradient); CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); +CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -127,7 +129,7 @@ void Test::testPolyPolygon() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h19746v14817h-19746z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 2); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ff"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19780v14851h-19780z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m0 0h19781v14852h-19781z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 116); @@ -294,7 +296,7 @@ void Test::TestEnglishMapMode() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor", 3); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#ad"); -assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m-1-1h29699v21005h-29699z"); +assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon", "path", "m-1-1h29700v21001h-29700z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[2]/polypolygon", "path", "m1058 7937v5293h3175v-1059h-2118v-4234z"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygoncolor[3]/polypolygon", "path", "m12699 1058h4234v1060h-1587v4231h-1059v-4231h-1588z"); @@ -307,11 +309,28 @@ void Test::TestEnglishMapMode() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "height", "424"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 3); -assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon", "-1,-1 29698,-1 29698,21004 -1,21004"); +assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon", "-1,-1 29699,-1 29699,21000 -1,21000"); assertXPa