oox/source/drawingml/shape.cxx                           |    6 +++
 sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx |binary
 sd/qa/unit/import-tests2.cxx                             |   25 +++++++++++++++
 3 files changed, 31 insertions(+)

New commits:
commit 0b91db7bdd624bd5351d132fee0b3eadf637b716
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Thu Jan 5 13:29:32 2023 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Sun Jan 8 16:37:53 2023 +0000

    tdf#149588 pptx import: transparency at SolidFill
    
    When copied color (RGB) property from text content to shape,
    copy alpha component as well. (If text color have alpha component)
    
    Change-Id: Ib86c48ab7b2d3c5f9491a2211b05e90b2c2ea10f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145079
    Tested-by: Jenkins
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145140
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index bbea8f21abab..7740c2e153be 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -545,6 +545,12 @@ static void lcl_createPresetShape(const 
uno::Reference<drawing::XShape>& xShape,
             const sal_Int32 aFillColor = static_cast<sal_Int32>(
                 pProperties.maFillProperties.maFillColor.getColor( 
rGraphicHelper ).GetRGBColor() );
             xSet->setPropertyValue( UNO_NAME_FILLCOLOR, uno::makeAny( 
aFillColor ) );
+
+            if (pProperties.maFillProperties.maFillColor.hasTransparency())
+            {
+                const sal_Int16 aTransparence = 
pProperties.maFillProperties.maFillColor.getTransparency();
+                xSet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, 
uno::Any(aTransparence));
+            }
         }
         else
         {
diff --git a/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx 
b/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx
new file mode 100644
index 000000000000..8967590b9284
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 41b3a77cf5ab..da74fafb6a9c 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -177,6 +177,7 @@ public:
     void testCropToZero();
     void testTdf144092TableHeight();
     void testTdf151547TransparentWhiteText();
+    void testTdf149588TransparentSolidFill();
 
     CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -246,6 +247,7 @@ public:
     CPPUNIT_TEST(testCropToZero);
     CPPUNIT_TEST(testTdf144092TableHeight);
     CPPUNIT_TEST(testTdf151547TransparentWhiteText);
+    CPPUNIT_TEST(testTdf149588TransparentSolidFill);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2040,6 +2042,29 @@ void SdImportTest2::testTdf151547TransparentWhiteText()
     xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf149588TransparentSolidFill()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(
+        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx"),
+        PPTX);
+
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
+
+    uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(6, 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:99 G:99 B:99 A   51  (T:204)
+    // - Actual  : Color: R:99 G:99 B:99 A: 255  (T:  0)
+    CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xCC636363), nCharColor);
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to