[Libreoffice-commits] core.git: sw/CppunitTest_sw_ww8import.mk sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 24 12:20:48 UTC 2020


 sw/CppunitTest_sw_ww8import.mk                   |    1 +
 sw/qa/extras/ww8import/data/transparent-text.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx             |   12 ++++++++++++
 sw/source/filter/ww8/ww8par6.cxx                 |    7 +++++++
 4 files changed, 20 insertions(+)

New commits:
commit 634a9ba15d65b6fdc506326e6b49b4b957c5cfcb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 24 09:44:36 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Feb 24 13:20:17 2020 +0100

    tdf#130812 DOC import: fix unexpected transparency of text
    
    DOC can have black with transparency set to 0xff, and that is meant to
    be just black. Allow COL_AUTO, though; the rendering will not consider
    that as transparent anyway.
    
    Other than that, DOC does not support text with transparency, it's a
    DOCX-only feature.
    
    Change-Id: I33f61b54b8ebd7958845063ae61900182d6f5e80
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89321
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk
index 97061ef14ab8..6b248fb5f926 100644
--- a/sw/CppunitTest_sw_ww8import.mk
+++ b/sw/CppunitTest_sw_ww8import.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \
     sfx \
     svl \
     sw \
+    tl \
 	utl \
 ))
 
diff --git a/sw/qa/extras/ww8import/data/transparent-text.doc b/sw/qa/extras/ww8import/data/transparent-text.doc
new file mode 100644
index 000000000000..b458db29cc09
Binary files /dev/null and b/sw/qa/extras/ww8import/data/transparent-text.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 468cacfd0967..250a32832752 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -133,6 +133,18 @@ DECLARE_WW8IMPORT_TEST(testTdf106291, "tdf106291.doc")
     CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font size
 }
 
+DECLARE_WW8IMPORT_TEST(testTransparentText, "transparent-text.doc")
+{
+    uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
+        getStyles("PageStyles")->getByName("Standard"), "HeaderText");
+    uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(3, xHeaderText);
+    // Without the accompanying fix in place, this test would have failed: transparency was set to
+    // 100%, so the text was not readable.
+    sal_Int32 nExpected(COL_BLACK);
+    sal_Int32 nActual(getProperty<sal_Int16>(xParagraph, "CharTransparence"));
+    CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+}
+
 DECLARE_WW8IMPORT_TEST( testTdf105570, "tdf105570.doc" )
 {
     /*****
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 992409d562c8..15b3cca4ca34 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3589,6 +3589,13 @@ void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, sho
     else
     {
         Color aColor(msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)));
+
+        // At least when transparency is 0xff and the color is black, Word renders that as black.
+        if (aColor.GetTransparency() && aColor != COL_AUTO)
+        {
+            aColor.SetTransparency(0);
+        }
+
         NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR));
         if (m_pCurrentColl && m_xStyles)
             m_xStyles->mbTextColChanged = true;


More information about the Libreoffice-commits mailing list