diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-24 20:11:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-25 08:11:51 +0200 |
commit | 4a54a24c207f3040390e2fefec41cbbf0edd5eca (patch) | |
tree | 8f864651173971bbe6e33b146cb2d5230217514c /sd/qa | |
parent | 4bd8b4e469a4084eee0ec467721704ae51f82301 (diff) |
tdf#149205 sd theme: fix PPTX export loosing dk1 and lt1 colors
Document theme of Impress documents were exported to PPTX only
partially: dk1 and lt1 was hardcoded to the SYS_COLOR_SCHEMES define,
while the rest was written from master-slide-specific svx::Theme.
The benefit of this is that our theme is just a set of colors
(<a:srgbClr> markup in OOXML), while dk1 and lt1 is more dynamic by
default in PowerPoint (<a:sysClr> in OOXML). The downside is that this
way a custom dk1 and lt1 color was lost on export.
Fix the problem by switching to <a:srgbClr> markup even for dk1 and lt1:
not using the <a:sysClr> markup doesn't seem to be a problem in
practice, or at least much less problematic than rendering with bad
colors.
If there is a need, dedicated <a:sysClr> markup support can be still
added later by extending svx::ColorSet::maColors to not only store a
list of colors, but also some additional properties of those colors.
Change-Id: I26df3fd8c891c217df0d36382f6599805198f4bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134883
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/filter/eppt/eppt.cxx | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/sd/qa/filter/eppt/eppt.cxx b/sd/qa/filter/eppt/eppt.cxx index d27713da20b0..1e8e2c7e1491 100644 --- a/sd/qa/filter/eppt/eppt.cxx +++ b/sd/qa/filter/eppt/eppt.cxx @@ -9,20 +9,25 @@ #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> +#include <test/xmltesttools.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/util/Color.hpp> #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> +#include <test/xmldocptr.hxx> using namespace ::com::sun::star; namespace { /// Covers sd/source/filter/eppt/ fixes. -class Test : public test::BootstrapFixture, public unotest::MacrosTest +class Test : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { private: uno::Reference<lang::XComponent> mxComponent; @@ -30,6 +35,7 @@ private: public: void setUp() override; void tearDown() override; + void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override; uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } }; @@ -48,6 +54,11 @@ void Test::tearDown() test::BootstrapFixture::tearDown(); } +void Test::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) +{ + XmlTestTools::registerOOXMLNamespaces(pXmlXpathCtx); +} + constexpr OUStringLiteral DATA_DIRECTORY = u"/sd/qa/filter/eppt/data/"; CPPUNIT_TEST_FIXTURE(Test, testOOXMLCustomShapeBitmapFill) @@ -76,6 +87,44 @@ CPPUNIT_TEST_FIXTURE(Test, testOOXMLCustomShapeBitmapFill) CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"), xShape->getShapeType()); } + +CPPUNIT_TEST_FIXTURE(Test, testThemeExport) +{ + // Given a document with a master slide and a theme, lt1 is set to 0x000002: + uno::Reference<lang::XComponent> xComponent = loadFromDesktop("private:factory/simpress"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, 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; + aMap["Name"] <<= OUString("mytheme"); + aMap["ColorSchemeName"] <<= OUString("mycolorscheme"); + uno::Sequence<util::Color> aColorScheme + = { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc }; + aMap["ColorScheme"] <<= aColorScheme; + uno::Any aTheme(aMap.getAsConstPropertyValueList()); + xMasterPage->setPropertyValue("Theme", aTheme); + + // When exporting to PPTX: + utl::TempFile aTempFile; + uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("Impress Office Open XML"); + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + validate(aTempFile.GetFileName(), test::OOXML); + + // Then verify that this color is not lost: + std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, "ppt/theme/theme1.xml"); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + assertXPath(pXmlDoc, "//a:clrScheme/a:lt1/a:srgbClr", "val", "000002"); + // Without the fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '//a:clrScheme/a:lt1/a:srgbClr' number of nodes is incorrect + // i.e. the RGB color was lost on export. + xComponent->dispose(); +} } CPPUNIT_PLUGIN_IMPLEMENT(); |