summaryrefslogtreecommitdiff
path: root/oox/qa/unit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-19 13:44:40 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-11-19 15:28:42 +0100
commit32ae1ed7504d58f9216593cb87f25c480a0e623b (patch)
treec5f5907e1dd6a072e7be3473d4c0cb7cd114cc5a /oox/qa/unit
parent13aa5081793f133077610cd01b7f01ee765b4add (diff)
PPTX import: handle <a:clrScheme name="...">
We had doc model for this, but the UNO API and the PPTX import was missing. Change-Id: I199e9cc235a783d91700ce74f17d442f41d3c3f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125532 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'oox/qa/unit')
-rw-r--r--oox/qa/unit/data/theme.pptxbin0 -> 32660 bytes
-rw-r--r--oox/qa/unit/drawingml.cxx35
2 files changed, 35 insertions, 0 deletions
diff --git a/oox/qa/unit/data/theme.pptx b/oox/qa/unit/data/theme.pptx
new file mode 100644
index 000000000000..6d9ffc00bbbb
--- /dev/null
+++ b/oox/qa/unit/data/theme.pptx
Binary files differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index 57e02545eb62..b220170f3edc 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
+#include <com/sun/star/drawing/XMasterPageTarget.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <unotools/mediadescriptor.hxx>
@@ -397,6 +398,40 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testChartThemeOverride)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472C4), nActual);
}
+CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme)
+{
+ // Given a PPTX file with a slide -> master slide -> theme:
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "theme.pptx";
+
+ // When importing the document:
+ load(aURL);
+
+ // Then make sure the theme + referring to that theme is imported:
+ // Check the imported theme of the master page:
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XMasterPageTarget> xDrawPage(
+ xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xMasterpage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
+ comphelper::SequenceAsHashMap aMap(xMasterpage->getPropertyValue("Theme"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), aMap["Name"].get<OUString>());
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Cannot extract an Any(void) to string!
+ // i.e. the name of the color scheme was lost on import.
+ CPPUNIT_ASSERT_EQUAL(OUString("Office"), aMap["ColorSchemeName"].get<OUString>());
+
+ // Check the reference to that theme:
+ uno::Reference<drawing::XShapes> xDrawPageShapes(xDrawPage, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xShape(xDrawPageShapes->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xText(xShape->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xPara(xText->createEnumeration()->nextElement(),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPortion(xPara->createEnumeration()->nextElement(),
+ uno::UNO_QUERY);
+ // 4 is accent1, see oox::drawingml::Color::getSchemeColorIndex().
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4),
+ xPortion->getPropertyValue("CharColorTheme").get<sal_Int32>());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */