emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 ++++++++++ emfio/qa/cppunit/emf/data/TestUnderlineTransparentBackground.emf |binary emfio/source/reader/mtftools.cxx | 7 ++ 3 files changed, 30 insertions(+), 1 deletion(-)
New commits: commit b6a3a10140708380dc98a3ecb7437ac976bca393 Author: Andras Timar <[email protected]> AuthorDate: Sat Feb 7 21:18:19 2026 +0100 Commit: Bartosz Kosiorek <[email protected]> CommitDate: Mon Feb 9 05:17:21 2026 +0100 tdf#126965 emfio: fix opaque background on underlined text... when BkMode is TRANSPARENT In DrawText, the font's fill color was unconditionally set to maBkColor before checking the background mode. When BkMode is TRANSPARENT, VCL's underline rendering uses the font's fill color directly, ignoring the transparency flag, causing an unwanted opaque background behind underlined text. Set COL_TRANSPARENT as the fill color when BkMode is TRANSPARENT, and only use maBkColor when OPAQUE. Change-Id: I0e94d2a1beae8ce2feecb0f7c0f8e03b36d2d80a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198889 Reviewed-by: Andras Timar <[email protected]> Tested-by: Jenkins (cherry picked from commit eddbe3b36d257ca2163c9e971fff47e29ccc0ccf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198919 Reviewed-by: Bartosz Kosiorek <[email protected]> diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 0b2119628463..2a5aa8ab9968 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -23,6 +23,9 @@ #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <drawinglayer/tools/primitive2dxmldump.hxx> #include <vcl/filter/PDFiumLibrary.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/vectorgraphicdata.hxx> +#include <vcl/wmf.hxx> #include <memory> #include <string_view> @@ -1282,6 +1285,27 @@ CPPUNIT_TEST_FIXTURE(Test, testExtTextOutOpaqueAndClipTransform) u"#000000"); } +CPPUNIT_TEST_FIXTURE(Test, testUnderlineTransparentBackground) +{ + // EMF with SETBKMODE=TRANSPARENT, SETBKCOLOR=black, underlined font, and EXTTEXTOUTW "TEST". + // The font's fill color must be COL_TRANSPARENT when BkMode is TRANSPARENT. + // Before the fix, the fill color was unconditionally set to maBkColor (black), + // causing VCL's underline rendering to draw an opaque background. + OUString aUrl = m_directories.getURLFromSrc( + u"/emfio/qa/cppunit/emf/data/TestUnderlineTransparentBackground.emf"); + SvFileStream aFileStream(aUrl, StreamMode::READ); + GDIMetaFile aGDIMetaFile; + ReadWindowMetafile(aFileStream, aGDIMetaFile); + + MetafileXmlDump dumper; + xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + CPPUNIT_ASSERT(pDoc); + + // The font must have fillcolor="#ffffff" (COL_TRANSPARENT), not "#000000" (maBkColor). + assertXPath(pDoc, "/metafile/push[2]/font", "fillcolor", u"#ffffff"); + assertXPathContent(pDoc, "/metafile/push[2]/textarray/text", u"TEST"); +} + CPPUNIT_TEST_FIXTURE(Test, testNegativeWinOrg) { Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestNegativeWinOrg.emf"); diff --git a/emfio/qa/cppunit/emf/data/TestUnderlineTransparentBackground.emf b/emfio/qa/cppunit/emf/data/TestUnderlineTransparentBackground.emf new file mode 100644 index 000000000000..8268d14f0b0a Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestUnderlineTransparentBackground.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index a8380cb374fc..2fd4b5f28ae5 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1773,12 +1773,17 @@ namespace emfio } vcl::Font aTmp( maFont ); aTmp.SetColor( maTextColor ); - aTmp.SetFillColor( maBkColor ); if( mnBkMode == BackgroundMode::Transparent ) + { + aTmp.SetFillColor( COL_TRANSPARENT ); aTmp.SetTransparent( true ); + } else + { + aTmp.SetFillColor( maBkColor ); aTmp.SetTransparent( false ); + } aTmp.SetAlignment( eTextAlign );
