diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/data/theme.pptx | bin | 0 -> 32660 bytes | |||
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 35 | ||||
-rw-r--r-- | oox/source/drawingml/theme.cxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/themeelementscontext.cxx | 4 |
4 files changed, 40 insertions, 0 deletions
diff --git a/oox/qa/unit/data/theme.pptx b/oox/qa/unit/data/theme.pptx Binary files differnew file mode 100644 index 000000000000..6d9ffc00bbbb --- /dev/null +++ b/oox/qa/unit/data/theme.pptx 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: */ diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx index be9f199ff8f8..ba1761311154 100644 --- a/oox/source/drawingml/theme.cxx +++ b/oox/source/drawingml/theme.cxx @@ -107,6 +107,7 @@ void Theme::addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPa { beans::PropertyValues aValues = { comphelper::makePropertyValue("Name", maThemeName), + comphelper::makePropertyValue("ColorSchemeName", maClrScheme.GetName()), }; uno::Reference<beans::XPropertySet> xPropertySet(xDrawPage, uno::UNO_QUERY); xPropertySet->setPropertyValue("Theme", uno::makeAny(aValues)); diff --git a/oox/source/drawingml/themeelementscontext.cxx b/oox/source/drawingml/themeelementscontext.cxx index 6fbd62e91d18..0922c4b61939 100644 --- a/oox/source/drawingml/themeelementscontext.cxx +++ b/oox/source/drawingml/themeelementscontext.cxx @@ -214,6 +214,10 @@ ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, con switch( nElement ) { case A_TOKEN( clrScheme ): // CT_ColorScheme + if (rAttribs.hasAttribute(XML_name)) + { + mrTheme.getClrScheme().SetName(rAttribs.getString(XML_name).get()); + } return new clrSchemeContext( *this, mrTheme.getClrScheme() ); case A_TOKEN( fontScheme ): // CT_FontScheme return new FontSchemeContext( *this, mrTheme.getFontScheme() ); |