oox/qa/unit/data/tdf155327_WordArtDefaultColor.pptx |binary
 oox/qa/unit/shape.cxx                               |   17 +++++++++++++++++
 oox/source/drawingml/shape.cxx                      |    5 +++++
 3 files changed, 22 insertions(+)

New commits:
commit 04ae198019cf2c6593023f9ef630e4e99f65defe
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Tue May 16 20:46:28 2023 +0200
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Tue May 16 21:57:28 2023 +0200

    tdf#155327 Detect default color in WordArt
    
    It is possible to not set the character color explicitely in a WordArt
    shape. In such case MS Office uses the scheme color 'tx1' from current
    active scheme. The import of the character properties does not set this
    color in the fill properties. The patch adds it, when the character fill
    properties are converted to shape fill properties.
    
    Change-Id: Ic72fd9f55bac1e2874cbf701ffa692ca4fbc9435
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151851
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.hensc...@t-online.de>

diff --git a/oox/qa/unit/data/tdf155327_WordArtDefaultColor.pptx 
b/oox/qa/unit/data/tdf155327_WordArtDefaultColor.pptx
new file mode 100644
index 000000000000..a813f4a329a6
Binary files /dev/null and 
b/oox/qa/unit/data/tdf155327_WordArtDefaultColor.pptx differ
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
index 722d7d6d644b..68ce372335df 100644
--- a/oox/qa/unit/shape.cxx
+++ b/oox/qa/unit/shape.cxx
@@ -795,6 +795,23 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWordArtBitmapFill)
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1592), aSize100thMM.Width);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1592), aSize100thMM.Height);
 }
+
+CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWordArtDefaultColor)
+{
+    // The document has a WordArt shape for which the text color is not 
explicitly set. In such cases
+    // MS Office uses the scheme color 'tx1'. Without fix it was imported as 
'fill none'. The shape
+    // existed but was not visible on screen.
+    loadFromURL(u"tdf155327_WordArtDefaultColor.pptx");
+
+    uno::Reference<drawing::XDrawPagesSupplier> 
xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> 
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+                                                 uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_SOLID),
+                         xShapeProps->getPropertyValue(u"FillStyle"));
+
+    CPPUNIT_ASSERT_EQUAL(uno::Any(Color(3, 74, 144)), 
xShapeProps->getPropertyValue(u"FillColor"));
+}
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 69f3bf5a4d60..9417551b0f86 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -728,7 +728,12 @@ static void lcl_copyCharPropsToShape(const 
uno::Reference<drawing::XShape>& xSha
 
             // Fill
             // ToDo: Replace flip and rotate constants in parameters with 
actual values.
+            // tdf#155327 If color is not explicitly set, MS Office uses 
scheme color 'tx1'.
             oox::drawingml::ShapePropertyMap 
aFillShapeProps(rFilter.getModelObjectHelper());
+            if (!rCharProps.maFillProperties.moFillType.has_value())
+                rCharProps.maFillProperties.moFillType = XML_solidFill;
+            if (!rCharProps.maFillProperties.maFillColor.isUsed())
+                rCharProps.maFillProperties.maFillColor.setSchemeClr(XML_tx1);
             rCharProps.maFillProperties.pushToPropMap(aFillShapeProps, 
rFilter.getGraphicHelper(),
                                                       /*nShapeRotation*/ 0,
                                                       /*nPhClr*/ 
API_RGB_TRANSPARENT,

Reply via email to