summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2022-09-16 03:46:45 +0300
committerMiklos Vajna <vmiklos@collabora.com>2022-09-20 09:35:23 +0200
commitc544caf08b8809272aaced1186997292b74da575 (patch)
tree47e1ccaa6d0e61324198d6d477b3c9a9449e0487
parent286000f2df456cffabd678e3bde56af14c7bd185 (diff)
tdf#94122 pptx export: fix automatic text color export
MS Powerpoint doesn't have automatic colors unlike Word or Excel. Therefore on export the automatic text color should be first resolved and then exported. Change-Id: Ied2c3a4235da403350d8518a3414ff6a372b57a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140059 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140216
-rw-r--r--oox/source/export/drawingml.cxx17
-rw-r--r--sd/qa/unit/data/odp/tdf94122_autocolor.odpbin0 -> 13942 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml3.cxx42
3 files changed, 59 insertions, 0 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3b0bcb1c03b3..0ab497a4fed3 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2298,6 +2298,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
new file mode 100644
index 000000000000..921533cbead6
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf94122_autocolor.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx
index 65956330f535..c897fecebaf2 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -118,6 +118,7 @@ public:
void testTdf109169_OctagonBevel();
void testTdf109169_DiamondBevel();
void testTdf144092_emptyShapeTextProps();
+ void testTdf94122_autoColor();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -202,6 +203,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
@@ -2135,6 +2137,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();