[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", "847"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[6]/text", "textalignment:0x06"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[7]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[7]", "x", "12700"); +assertXPath(pDoc, "/metafile/push[2]/textarray[7]", "y", "1058"); +assertXPathContent(pDoc, "/metafile/push[2]/textarray[7]/text", "textalignment:0x08"); + +assertXPath(pDoc, "/metafile/push[2]/textalign[8]", "align", "top"); +assertXPath(pDoc, "/metafile/push[2]/textarray[8]", "x", "11999"); +assertXPath(pDoc,
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |1 + emfio/qa/cppunit/emf/EmfImportTest.cxx | 20 emfio/qa/cppunit/emf/data/TestNegativeWinOrg.emf |binary emfio/source/reader/emfreader.cxx| 12 4 files changed, 29 insertions(+), 4 deletions(-) New commits: commit b9eaed7a4c484dde0b5c61b34b4beb60a101f661 Author: Paris Oplopoios AuthorDate: Tue Nov 1 14:25:38 2022 +0200 Commit: Miklos Vajna CommitDate: Tue Nov 8 10:50:30 2022 +0100 tdf#151844 Make EMR_EXTSELECTCLIPRGN factor in WinOrg coordinates EMR_EXTSELECTCLIPRGN would not factor in WinOrg coordinates which would give the clip box wrong coordinates causing some graphics to look chopped in the wrong way. Change-Id: I4f9a1b1c27fc276d188d0d865991795dab48dce5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142110 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 997f2287f010..b4fd6394c69b 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -731,6 +731,7 @@ namespace emfio voidScaleDevExt(double fX, double fY); voidSetWinOrg(const Point& rPoint, bool bIsEMF = false); +Point GetWinOrg() { return Point(mnWinOrgX, mnWinOrgY); } voidSetWinOrgOffset(sal_Int32 nX, sal_Int32 nY); voidSetWinExt(const Size& rSize, bool bIsEMF = false); voidScaleWinExt(double fX, double fY); diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 99adda32e834..75f2b9001a08 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -69,6 +69,7 @@ class Test : public UnoApiXmlTest void TestEmfPlusDrawPathWithMiterLimit(); void TestEmfPlusFillClosedCurve(); void TestExtTextOutOpaqueAndClipTransform(); +void TestNegativeWinOrg(); void TestBitBltStretchBltWMF(); void TestExtTextOutOpaqueAndClipWMF(); @@ -122,6 +123,7 @@ public: CPPUNIT_TEST(TestEmfPlusDrawPathWithMiterLimit); CPPUNIT_TEST(TestEmfPlusFillClosedCurve); CPPUNIT_TEST(TestExtTextOutOpaqueAndClipTransform); +CPPUNIT_TEST(TestNegativeWinOrg); CPPUNIT_TEST(TestBitBltStretchBltWMF); CPPUNIT_TEST(TestExtTextOutOpaqueAndClipWMF); @@ -1203,6 +1205,24 @@ void Test::TestExtTextOutOpaqueAndClipTransform() "#00"); } +void Test::TestNegativeWinOrg() +{ +Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestNegativeWinOrg.emf"); +CPPUNIT_ASSERT_EQUAL(1, static_cast(aSequence.getLength())); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); +CPPUNIT_ASSERT(pDocument); + +// The crop box (EMR_EXTSELECTCLIPRGN) would not factor in WinOrg coordinates +// and be lower and more to the right than it actually is which would cut the +// text in the emf above in half. +assertXPath(pDocument, aXPathPrefix + "mask/group[1]/mask/polypolygon", 1); +assertXPath(pDocument, aXPathPrefix + "mask/group[1]/mask/polypolygon", "minx", "0"); +assertXPath(pDocument, aXPathPrefix + "mask/group[1]/mask/polypolygon", "miny", "272"); +assertXPath(pDocument, aXPathPrefix + "mask/group[1]/mask/polypolygon", "maxx", "6800"); +assertXPath(pDocument, aXPathPrefix + "mask/group[1]/mask/polypolygon", "maxy", "644"); +} + void Test::TestBitBltStretchBltWMF() { // tdf#55058 tdf#142722 WMF records: BITBLT, STRETCHBLT. diff --git a/emfio/qa/cppunit/emf/data/TestNegativeWinOrg.emf b/emfio/qa/cppunit/emf/data/TestNegativeWinOrg.emf new file mode 100644 index ..d428f4caff11 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestNegativeWinOrg.emf differ diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 7baa7c8ed949..207d8373e309 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -332,7 +332,7 @@ SvStream& operator>>(SvStream& rInStream, BLENDFUNCTION& rBlendFun) return rInStream; } -bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen ) +bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen, Point aWinOrg ) { if (nLen < 32) // 32 bytes - Size of RegionDataHeader return false; @@ -369,6 +369,10 @@ bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, sal_ rStream.ReadInt32(nTop); rStream.ReadInt32(nRight); rStream.ReadInt32(nBottom); +nLeft += aWinOrg.X(); +nRight += aWinOrg.X(); +nTop += aWinOrg.Y(); +nBottom += aWinOrg.Y(); rPolyPoly.append( basegfx::utils::createPolygonFromRect( ::basegfx::B2DRectangle( nLeft,
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/wmfreader.hxx |1 + emfio/qa/cppunit/wmf/data/TestBigPPI.wmf |binary emfio/qa/cppunit/wmf/wmfimporttest.cxx | 23 +++ emfio/source/reader/wmfreader.cxx| 24 4 files changed, 44 insertions(+), 4 deletions(-) New commits: commit a03a47bb0791d88fedb2650bca412c28469b0b27 Author: Paris Oplopoios AuthorDate: Wed Oct 19 16:57:11 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Oct 24 18:24:48 2022 +0200 tdf#150888 Scale down PPI if it would result in a tiny image The reason for the blurry document in tdf#150888 is that the image is tiny. PPI is 2540 in that image but when using the window bounding box (96, 81) this results in a very small image that the .odt then scales up which makes it blurry. Apart from that, when opening the extracted .wmf in Draw it's also very small, around 0.04" squared. Because MM_ANISOTROPICs definition allows for arbritrary scaling, when an image would be smaller than an inch squared the PPI is scaled down to either the images width or height. This makes the extracted WMF match the size of competitor office suites and fix the blur bug without breaking past tests. Change-Id: I11eab879848d9308f818708a91fd9eb91fc65200 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141533 Tested-by: Jenkins Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/emfio/inc/wmfreader.hxx b/emfio/inc/wmfreader.hxx index f7788d53651c..5c6979550ef4 100644 --- a/emfio/inc/wmfreader.hxx +++ b/emfio/inc/wmfreader.hxx @@ -33,6 +33,7 @@ namespace emfio private: sal_uInt16 mnUnitsPerInch; sal_uInt32 mnRecSize; +boolmbPlaceable; // embedded EMF data std::optional> mpEMFStream; diff --git a/emfio/qa/cppunit/wmf/data/TestBigPPI.wmf b/emfio/qa/cppunit/wmf/data/TestBigPPI.wmf new file mode 100644 index ..e120af2790db Binary files /dev/null and b/emfio/qa/cppunit/wmf/data/TestBigPPI.wmf differ diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx index a85876e03a7d..c5b2ddbc3205 100644 --- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx +++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx @@ -52,6 +52,7 @@ public: void testEmfProblem(); void testEmfLineStyles(); void testWorldTransformFontSize(); +void testBigPPI(); void testTdf93750(); void testTdf99402(); void testTdf39894(); @@ -66,6 +67,7 @@ public: CPPUNIT_TEST(testEmfProblem); CPPUNIT_TEST(testEmfLineStyles); CPPUNIT_TEST(testWorldTransformFontSize); +CPPUNIT_TEST(testBigPPI); CPPUNIT_TEST(testTdf93750); CPPUNIT_TEST(testTdf99402); CPPUNIT_TEST(testTdf39894); @@ -310,6 +312,27 @@ void WmfTest::testWorldTransformFontSize() assertXPath(pDoc, "/metafile/font[4]", "weight", "normal"); } +void WmfTest::testBigPPI() +{ +// Test that PPI is reduced from 2540 to 96 (width from META_SETWINDOWEXT) to make the graphic +// bigger +SvFileStream aFileStream(getFullUrl(u"TestBigPPI.wmf"), StreamMode::READ); +GDIMetaFile aGDIMetaFile; +ReadWindowMetafile(aFileStream, aGDIMetaFile); + +MetafileXmlDump dumper; +dumper.filterAllActionTypes(); +dumper.filterActionType(MetaActionType::FONT, false); +xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + +CPPUNIT_ASSERT(pDoc); + +// If the PPI was not reduced the width and height would be <100 which is too small +// Related: tdf#150888 +assertXPath(pDoc, "/metafile", "width", "2540"); +assertXPath(pDoc, "/metafile", "height", "2143"); +} + void WmfTest::testTdf93750() { SvFileStream aFileStream(getFullUrl(u"tdf93750.emf"), StreamMode::READ); diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 8a54b21f0580..33ef9dd3d0e1 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1351,11 +1351,11 @@ namespace emfio tools::Rectangle aPlaceableBound; -bool bPlaceable = nPlaceableMetaKey == 0x9ac6cdd7L; +mbPlaceable = nPlaceableMetaKey == 0x9ac6cdd7L; -SAL_INFO("emfio", "Placeable: \"" << (bPlaceable ? "yes" : "no") << "\""); +SAL_INFO("emfio", "Placeable: \"" << (mbPlaceable ? "yes" : "no") << "\""); -if (bPlaceable) +if (mbPlaceable) { //TODO do some real error handling here sal_Int16 nVal(0); @@ -1608,9 +1608,10 @@ namespace emfio Point aViewportOrg(0,0); std::optional aViewportExt; +MappingMode eMapMode = MappingMode::MM_ANISOTROPIC; + if (nEnd - nPos) { -MappingMode eMapMode = MappingMode::MM_ANISOTROPIC; sal_uInt16 nFunction; sal_uInt32 nRSize; @@ -1952,6 +1953,21 @@ namespace emfio if (aWinExt) {
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx |2 +- emfio/qa/cppunit/wmf/wmfimporttest.cxx |2 +- emfio/source/reader/mtftools.cxx |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) New commits: commit 51431559bda9a81293d502328982452caeeba6c6 Author: Hossein AuthorDate: Wed Apr 6 04:41:07 2022 +0200 Commit: Stephan Bergmann CommitDate: Wed Apr 6 10:52:50 2022 +0200 Fix type, calculation of FamilyFont PitchAndFamily This patch fixes problems caused by the cleanup commit 3e7dd04dd8ca1baea4b7918eb7a7080c595c4625 for type and calculation of FamilyFont and PitchAndFamily enumerations. FamilyFont enumeration is described in [MS-WMF] v20210625 page 33: "In a Font Object, when a FamilyFont value is packed into a byte with a PitchFont Enumeration value, the result is a PitchAndFamily Object". Thus, we will use sal_uInt8 as the underlying type for FamilyFont. The PitchAndFamily is created as shown in [MS-WMF] v20210625 page 96: [0 1 2 3] 4 5 [6 7] Family 0 0 Pitch The values for FamilyFont enumeration are created according to the [MS-WMF], and the calculations are changed to use '<< 4' and '>> 4' instead of applying the same shift to the enumeration values. Change-Id: I4f6df33ed6405589acf89ba2c9223a571cb510b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132614 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index cb6e1c7ff243..0290c487c574 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -275,7 +275,7 @@ namespace emfio }; /* [MS-WMF] - v20210625 - pages 33, */ -enum FamilyFont : sal_uInt32 +enum FamilyFont : sal_uInt8 { FF_DONTCARE = 0x00, FF_ROMAN = 0x01, diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx index 1ae7416521aa..b8c2218fdec2 100644 --- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx +++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx @@ -336,7 +336,7 @@ void WmfTest::testTdf99402() logfontw.lfUnderline = 0; logfontw.lfStrikeOut = 0; logfontw.lfCharSet = emfio::CharacterSet::OEM_CHARSET; -logfontw.lfPitchAndFamily = +emfio::FamilyFont::FF_ROMAN | +emfio::PitchFont::DEFAULT_PITCH; +logfontw.lfPitchAndFamily = emfio::FamilyFont::FF_ROMAN << 4 | emfio::PitchFont::DEFAULT_PITCH; logfontw.alfFaceName = "Symbol"; emfio::WinMtfFontStyle fontStyle(logfontw); diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index b4973f6e51ab..f829788dbd1b 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -179,7 +179,7 @@ namespace emfio aFont.SetCharSet( eCharSet ); aFont.SetFamilyName( rFont.alfFaceName ); FontFamily eFamily; -switch ( rFont.lfPitchAndFamily & 0xf0 ) +switch ( rFont.lfPitchAndFamily >> 4 & 0x0f ) { case FamilyFont::FF_ROMAN: eFamily = FAMILY_ROMAN;
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source
emfio/inc/mtftools.hxx | 445 ++--- emfio/qa/cppunit/wmf/wmfimporttest.cxx |4 emfio/source/reader/emfreader.cxx | 23 - emfio/source/reader/mtftools.cxx | 168 ++-- emfio/source/reader/wmfreader.cxx | 64 ++-- 5 files changed, 397 insertions(+), 307 deletions(-) New commits: commit 3e7dd04dd8ca1baea4b7918eb7a7080c595c4625 Author: Hossein AuthorDate: Mon Feb 28 00:07:16 2022 +0100 Commit: Hossein CommitDate: Tue Mar 15 13:00:59 2022 +0100 tdf#145614 Convert #define to enum and constexpr * Converted symbolic constants with #define in mftools.hxx to: a) 'enum' where facing multiple values of the same category with similar prefixes, or enums from the [MS-WMF] / [MS-EMF] b) extracted the underlying integral type from the above documents c) 'constexpr' where there was a single value * Where possible, 'enum class' in 'emfio' namespace is used * Some enums with binary or comparison operations are not converted MappingMode, TextAlignmentMode, RasterOperations, PenStyle CharacterSet, ExtTextOutOptions, PitchFont, FamilyFont, WeightFont Change-Id: I144b2df4722e23d3b0c0aca7880cf603faa80686 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124099 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index d258a9250b91..cb6e1c7ff243 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -32,51 +32,60 @@ #include "emfiodllapi.h" -#define ERROR 0 -#define NULLREGION 1 -#define COMPLEXREGION 3 - -#define RGN_AND 1 -#define RGN_OR 2 -#define RGN_XOR 3 -#define RGN_DIFF4 -#define RGN_COPY5 - namespace emfio { -enum class BkMode +/* [MS-EMF] - v20210625 - pages 43, 107 */ +enum class RegionMode : sal_uInt32 +{ +RGN_AND = 0x01, +RGN_OR = 0x02, +RGN_XOR = 0x03, +RGN_DIFF = 0x04, +RGN_COPY = 0x05 +}; + +/* [MS-EMF] - v20210625 - pages 40, 198 */ +enum class BackgroundMode : sal_uInt32 { NONE = 0, Transparent = 1, OPAQUE = 2, }; -} -/* xform stuff */ -#define MWT_IDENTITY1 -#define MWT_LEFTMULTIPLY2 -#define MWT_RIGHTMULTIPLY 3 -#define MWT_SET 4 - -#define ENHMETA_STOCK_OBJECT0x8000 - -/* Stock Logical Objects */ -#define WHITE_BRUSH 0 -#define LTGRAY_BRUSH1 -#define GRAY_BRUSH 2 -#define DKGRAY_BRUSH3 -#define BLACK_BRUSH 4 -#define NULL_BRUSH 5 -#define WHITE_PEN 6 -#define BLACK_PEN 7 -#define NULL_PEN8 -#define ANSI_FIXED_FONT 11 -#define ANSI_VAR_FONT 12 -#define SYSTEM_FIXED_FONT 16 +/* [MS-EMF] - v20210625 - pages 40, 210 */ +/* xform stuff */ +enum class ModifyWorldTransformMode : sal_uInt32 +{ +MWT_IDENTITY = 0x01, +MWT_LEFTMULTIPLY = 0x02, +MWT_RIGHTMULTIPLY = 0x03, +MWT_SET = 0x04 +}; + +constexpr sal_uInt32 ENHMETA_STOCK_OBJECT = 0x8000; -namespace emfio -{ -enum class WMFRasterOp { +/* [MS-EMF] - v20210625 - pages 44, 45, 182 */ +/* Stock Logical Objects */ +enum class StockObject : sal_uInt32 +{ +WHITE_BRUSH = 0, +LTGRAY_BRUSH = 1, +GRAY_BRUSH= 2, +DKGRAY_BRUSH = 3, +BLACK_BRUSH = 4, +NULL_BRUSH= 5, +WHITE_PEN = 6, +BLACK_PEN = 7, +NULL_PEN = 8, +ANSI_FIXED_FONT = 11, +ANSI_VAR_FONT = 12, +SYSTEM_FIXED_FONT = 16 +}; + +/* Note: This enum is incomplete compared to the specification */ +/* [MS-WMF] - v20210625 - pages 25-26 */ +enum class WMFRasterOp : sal_uInt16 +{ NONE = 0, Black = 1, Not = 6, @@ -84,35 +93,48 @@ namespace emfio Nop = 11, CopyPen = 13 }; -} -/* Mapping modes */ -#define MM_TEXT 1 -#define MM_LOMETRIC 2 -#define MM_HIMETRIC 3 -#define MM_LOENGLISH4 -#define MM_HIENGLISH5 -#define MM_TWIPS6 -#define MM_ISOTROPIC7 -#define MM_ANISOTROPIC 8 - -/* Graphics modes */ -#define GM_COMPATIBLE 1 -#define GM_ADVANCED 2 - -/* StretchBlt() modes */ -#define BLACKONWHITE1 -#define WHITEONBLACK2 -#define COLORONCOLOR3 -#define HALFTONE4 -#define STRETCH_ANDSCANSBLACKONWHITE -#define STRETCH_ORSCANS WHITEONBLACK -#define STRETCH_DELETESCANS COLORONCOLOR - -#define LF_FACESIZE 32 +/* Note: We have
[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", +"1070,1570 1110,1560 1160,1540 1200,1530 1250,1520 1300,1510 1350,1510 1400,1500 1440,1500 " +"1490,1500 1540,1500 1590,1500 1640,1510 1690,1510 1740,1520 1780,1530 1830,1540 1880,1560 " +
[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]", +"color", "#00"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[3]", +"color", "#ff"); +assertXPath(pDocument,
[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", +"fontcolor", "#00"); + +assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 2); +
[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
[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/qa/cppunit/emf/data/TestEllipseXformIntersectClipRect.emf new file mode 100644 index ..bda2ad233f4a Binary files /dev/null and
[Libreoffice-commits] core.git: emfio/inc emfio/qa emfio/source filter/source include/vcl vcl/source
emfio/inc/mtftools.hxx |5 - emfio/qa/cppunit/emf/EmfImportTest.cxx | 15 +++ emfio/source/reader/emfreader.cxx |3 ++- emfio/source/reader/mtftools.cxx |9 - filter/source/pdf/pdfdecomposer.cxx|2 +- include/vcl/pdfread.hxx|6 +++--- vcl/source/filter/ipdf/pdfread.cxx | 31 --- vcl/source/gdi/vectorgraphicdata.cxx |2 +- 8 files changed, 62 insertions(+), 11 deletions(-) New commits: commit 4a35c118a3a6b954827953674cc9bad435c394ee Author: Miklos Vajna AuthorDate: Mon Oct 26 21:16:28 2020 +0100 Commit: Miklos Vajna CommitDate: Tue Oct 27 11:20:46 2020 +0100 tdf#137413 EMF import: fix transparency in the PDF fallback case Commit d75c5b38911557173c54a78f42ff220ab3918573 (tdf#136836 emfio: speed up import of EMF import when the orig PDF is available, 2020-09-17) improved both performance and correctness of the EMF import, in case it had a PDF fallback. It turns out that PDF fallback can be nominally non-transparent, and still the EMF equivalent supports transparency. Fix the problem by enabling transparency in the PDF-in-EMF case. Change-Id: I4d1585a5db6f28bd9c9cb380b5f193f4d5edcc8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104849 Reviewed-by: Miklos Vajna Tested-by: Jenkins diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 5c0c60973350..70471b66ea21 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -441,6 +441,7 @@ namespace emfio BitmapExaBmpEx; tools::RectangleaOutRect; sal_uInt32 nWinRop; +bool m_bForceAlpha = false; BSaveStruct(const Bitmap& rBmp, const tools::Rectangle& rOutRect, sal_uInt32 nRop) : aBmpEx(rBmp) @@ -448,10 +449,12 @@ namespace emfio , nWinRop(nRop) {} -BSaveStruct(const BitmapEx& rBmpEx, const tools::Rectangle& rOutRect, sal_uInt32 nRop) +BSaveStruct(const BitmapEx& rBmpEx, const tools::Rectangle& rOutRect, sal_uInt32 nRop, +bool bForceAlpha = false) : aBmpEx(rBmpEx) , aOutRect(rOutRect) , nWinRop(nRop) +, m_bForceAlpha(bForceAlpha) {} }; diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 9d3364693530..45894455141e 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -26,6 +26,7 @@ #include #include +#include #include @@ -243,6 +244,20 @@ void Test::TestPdfInEmf() // i.e. there was no size hint, the shape with 14cm height had a bitmap-from-PDF fill, the PDF // height was only 5cm, so it looked blurry. CPPUNIT_ASSERT_EQUAL(14321.0, pVectorGraphicData->getSizeHint().getY()); + +#if !defined(WNT) && !defined(MACOSX) +// Hmm, manual testing on Windows looks OK. +BitmapEx aBitmapEx = aGraphic.GetBitmapEx(); +AlphaMask aMask = aBitmapEx.GetAlpha(); +Bitmap::ScopedReadAccess pAccess(aMask); +Color aColor(pAccess->GetPixel(0, 0)); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 220 +// - Actual : 0 +// i.e. the pixel at the top left corner was entirely opaque, while it should be mostly +// transparent. +CPPUNIT_ASSERT_EQUAL(static_cast(220), aColor.GetBlue()); +#endif } CPPUNIT_TEST_SUITE_REGISTRATION(Test); diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index b47d0c86496f..1bc6339ff897 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -507,7 +507,8 @@ namespace emfio // ours. aGraphic.getVectorGraphicData()->setSizeHint(maSizeHint); -maBmpSaveList.emplace_back(new BSaveStruct(aGraphic.GetBitmapEx(), aOutputRect, SRCCOPY)); +maBmpSaveList.emplace_back( +new BSaveStruct(aGraphic.GetBitmapEx(), aOutputRect, SRCCOPY, /*bForceAlpha=*/true)); const std::shared_ptr pVectorGraphicData = aGraphic.getVectorGraphicData(); if (!pVectorGraphicData) diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index e32b0f2be502..7cd1ff58093d 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1837,7 +1837,14 @@ namespace emfio { if ( nRasterOperation == 0x33 ) aBitmap.Invert(); -ImplDrawBitmap( aPos, aSize, BitmapEx(aBitmap) ); +if (pSave->m_bForceAlpha) +{ +ImplDrawBitmap(aPos, aSize, pSave->aBmpEx); +} +else +