[Libreoffice-commits] core.git: emfio/qa emfio/source
Bartosz Kosiorek (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 31 05:35:05 UTC 2021
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 <gang65 at poczta.onet.pl>
AuthorDate: Sat May 29 21:11:55 2021 +0200
Commit: Bartosz Kosiorek <gang65 at poczta.onet.pl>
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 <gang65 at poczta.onet.pl>
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<Primitive2DContainer>(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", "#000000");
- assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 2);
+ assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[2]",
+ "text", "OpaqueTranspa");
+ assertXPath(pDocument, "/primitive2D/metafile/transform/textsimpleportion[2]",
+ "fontcolor", "#000000");
+
+ 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", "#ff0000");
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_OPAQUE )
+ else if ( nOptions & ETO_OPAQUE )
DrawRectWithBGColor( aRect );
mpInputStream->ReadUInt32( offDx );
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 6bf0d98a3e76..866f6996d9e3 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -1381,12 +1381,15 @@ namespace emfio
{
WinMtfFillStyle aFillStyleBackup = maFillStyle;
bool aTransparentBackup = maLineStyle.bTransparent;
+ BkMode mnBkModeBackup = mnBkMode;
const tools::Polygon aPoly( rRect );
maLineStyle.bTransparent = true;
maFillStyle = maBkColor;
+ mnBkMode = BkMode::OPAQUE;
ImplSetNonPersistentLineColorTransparenz();
DrawPolygon(aPoly, false);
+ mnBkMode = mnBkModeBackup; // The rectangle needs to be always drawned even if mode is transparent
maFillStyle = aFillStyleBackup;
maLineStyle.bTransparent = aTransparentBackup;
}
More information about the Libreoffice-commits
mailing list