oox/source/drawingml/textcharacterproperties.cxx           |    8 +++-
 sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx |binary
 sd/qa/unit/import-tests2.cxx                               |   23 +++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit 83d2cf0e04fcedaea2a0b2f1cb925cb91b8db656
Author:     Sarper Akdemir <sarper.akde...@collabora.com>
AuthorDate: Mon Oct 17 09:06:20 2022 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Oct 25 08:20:29 2022 +0200

    tdf#151547 pptx import: workaround for COL_AUTO collision
    
    In the current implementation of ::Color, it is not possible
    to have fully transparent white text (since it collides with
    COL_AUTO and gets interpreted as Automatic Color).
    
    Implement a workaround for import of fully transparent white
    text color so that it isn't interpreted as the magic value
    COL_AUTO (i.e. instead of fully transparent #FFFFFF import
    as fully transparent #FFFFFE).
    
    Change-Id: Ide750093ef8a89f1424ddd8f4e9ee1e18209f2ad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141439
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit adfdd2bee4d1d59bf1ee372d9c242cf0b691e423)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141780
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index be2409f5795c..1ed3e7499f0c 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -136,7 +136,13 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 
         if (aColor.hasTransparency())
         {
-            rPropMap.setProperty(PROP_CharTransparence, 
aColor.getTransparency());
+            const auto nTransparency = aColor.getTransparency();
+            rPropMap.setProperty(PROP_CharTransparence, nTransparency);
+
+            // WORKAROUND: Fully transparent white has the same value as 
COL_AUTO, avoid collision
+            if (nTransparency == 100
+                && aColor.getColor(rFilter.getGraphicHelper()).GetRGBColor() 
== COL_AUTO.GetRGBColor())
+                rPropMap.setProperty(PROP_CharColor, 
::Color(ColorTransparency, 0xFFFFFFFE));
         }
     }
 
diff --git a/sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx 
b/sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx
new file mode 100644
index 000000000000..1bb723c2afe0
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index e9d71b9b3988..41b3a77cf5ab 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -176,6 +176,7 @@ public:
     void testDefaultTabStop();
     void testCropToZero();
     void testTdf144092TableHeight();
+    void testTdf151547TransparentWhiteText();
 
     CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -244,6 +245,7 @@ public:
     CPPUNIT_TEST(testDefaultTabStop);
     CPPUNIT_TEST(testCropToZero);
     CPPUNIT_TEST(testTdf144092TableHeight);
+    CPPUNIT_TEST(testTdf151547TransparentWhiteText);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2017,6 +2019,27 @@ void SdImportTest2::testTdf144092TableHeight()
     xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf151547TransparentWhiteText()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(
+        
m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx"),
+        PPTX);
+
+    uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, 
xDocShRef));
+    uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, 
xShape));
+    uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
+    uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
+
+    Color nCharColor;
+    xPropSet->getPropertyValue("CharColor") >>= nCharColor;
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: Color: R:255 G:255 B:254 A:255
+    // - Actual  : Color: R:255 G:255 B:255 A:255
+    // i.e. fully transparent white text color was interpreted as COL_AUTO
+    CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xFFFFFFFE), nCharColor);
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to