diff options
-rw-r--r-- | oox/source/export/drawingml.cxx | 17 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/tdf94122_autocolor.odp | bin | 0 -> 13942 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml3.cxx | 42 |
3 files changed, 59 insertions, 0 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f35596457caa..9d5af4f8e2ca 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2268,6 +2268,23 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool WriteSolidFill(color, nTransparency); } } + else if (GetDocumentType() == DOCUMENT_PPTX) + { + // Resolve COL_AUTO for PPTX since MS Powerpoint doesn't have automatic colors. + bool bIsTextBackgroundDark = mbIsBackgroundDark; + if (rXShapePropSet.is() && GetProperty(rXShapePropSet, "FillStyle") + && mAny.get<FillStyle>() != FillStyle_NONE + && GetProperty(rXShapePropSet, "FillColor")) + { + ::Color aShapeFillColor(ColorTransparency, mAny.get<sal_uInt32>()); + bIsTextBackgroundDark = aShapeFillColor.IsDark(); + } + + if (bIsTextBackgroundDark) + WriteSolidFill(COL_WHITE); + else + WriteSolidFill(COL_BLACK); + } } } diff --git a/sd/qa/unit/data/odp/tdf94122_autocolor.odp b/sd/qa/unit/data/odp/tdf94122_autocolor.odp Binary files differnew file mode 100644 index 000000000000..921533cbead6 --- /dev/null +++ b/sd/qa/unit/data/odp/tdf94122_autocolor.odp diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index f0fb87479ea9..8655866b9e7b 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -133,6 +133,7 @@ public: void testTdf109169_OctagonBevel(); void testTdf109169_DiamondBevel(); void testTdf144092_emptyShapeTextProps(); + void testTdf94122_autoColor(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest3); @@ -213,6 +214,7 @@ public: CPPUNIT_TEST(testTdf109169_OctagonBevel); CPPUNIT_TEST(testTdf109169_DiamondBevel); CPPUNIT_TEST(testTdf144092_emptyShapeTextProps); + CPPUNIT_TEST(testTdf94122_autoColor); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -2020,6 +2022,46 @@ void SdOOXMLExportTest3::testTdf144092_emptyShapeTextProps() xDocShRef->DoClose(); } +void SdOOXMLExportTest3::testTdf94122_autoColor() +{ + // Document contains three pages, with different scenarios for automatic + // color export to pptx. + // - First page: Page background light, automatic colored text on a FillType_NONE shape + // - Second page: Page background dark, automatic colored text on a FillType_NONE shape + // - Third page: Page background light, automatic colored text on a dark colored fill + // and another automatic colored text on a light colored fill + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf94122_autocolor.odp"), ODP); + + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + // Without the accompanying fix in place, these tests would have failed with: + // - Expected: 1 + // - Actual : 0 + // - In ..., XPath '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr' number of nodes is incorrect + // i.e. automatic color wasn't resolved & exported + + xmlDocUniquePtr pXmlDocContent1 = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocContent1, + "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", "val", + "000000"); + + xmlDocUniquePtr pXmlDocContent2 = parseExport(tempFile, "ppt/slides/slide2.xml"); + assertXPath(pXmlDocContent2, + "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", "val", + "ffffff"); + + xmlDocUniquePtr pXmlDocContent3 = parseExport(tempFile, "ppt/slides/slide3.xml"); + assertXPath(pXmlDocContent3, + "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", + "val", "ffffff"); + assertXPath(pXmlDocContent3, + "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", + "val", "000000"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3); CPPUNIT_PLUGIN_IMPLEMENT(); |