vcl: rename enum variable prefixes
[LibreOffice.git] / sd / qa / filter / eppt / eppt.cxx
blob0d3c554e4b76c9eb15cffa3e22013a338d4bcff1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/unoapixml_test.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
14 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
15 #include <com/sun/star/util/Color.hpp>
16 #include <com/sun/star/util/XTheme.hpp>
18 #include <test/xmldocptr.hxx>
19 #include <docmodel/uno/UnoTheme.hxx>
20 #include <docmodel/theme/Theme.hxx>
22 using namespace ::com::sun::star;
24 namespace
26 /// Covers sd/source/filter/eppt/ fixes.
27 class Test : public UnoApiXmlTest
29 public:
30 Test();
33 Test::Test()
34 : UnoApiXmlTest(u"/sd/qa/filter/eppt/data/"_ustr)
38 CPPUNIT_TEST_FIXTURE(Test, testOOXMLCustomShapeBitmapFill)
40 // Save the bugdoc to PPT.
41 loadFromFile(u"custom-shape-bitmap-fill.pptx");
42 saveAndReload(u"MS PowerPoint 97"_ustr);
44 // Check if the bitmap shape was lost.
45 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
46 uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
47 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY);
48 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
49 // Without the accompanying fix in place, this test would have failed with:
50 // - Expected: com.sun.star.drawing.GraphicObjectShape
51 // - Actual : com.sun.star.drawing.CustomShape
52 // i.e. the custom shape geometry was kept, but the actual bitmap was lost.
53 CPPUNIT_ASSERT_EQUAL(u"com.sun.star.drawing.GraphicObjectShape"_ustr, xShape->getShapeType());
56 CPPUNIT_TEST_FIXTURE(Test, testThemeExport)
58 // Given a document with a master slide and a theme, lt1 is set to 0x000002:
59 loadFromURL(u"private:factory/simpress"_ustr);
61 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
62 uno::Reference<drawing::XMasterPageTarget> xDrawPage(
63 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
64 uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
66 auto pTheme = std::make_shared<model::Theme>("mytheme");
67 auto pColorSet = std::make_shared<model::ColorSet>("mycolorscheme");
68 pColorSet->add(model::ThemeColorType::Dark1, 0x111111);
69 pColorSet->add(model::ThemeColorType::Light1, 0x222222);
70 pColorSet->add(model::ThemeColorType::Dark2, 0x333333);
71 pColorSet->add(model::ThemeColorType::Light2, 0x444444);
72 pColorSet->add(model::ThemeColorType::Accent1, 0x555555);
73 pColorSet->add(model::ThemeColorType::Accent2, 0x666666);
74 pColorSet->add(model::ThemeColorType::Accent3, 0x777777);
75 pColorSet->add(model::ThemeColorType::Accent4, 0x888888);
76 pColorSet->add(model::ThemeColorType::Accent5, 0x999999);
77 pColorSet->add(model::ThemeColorType::Accent6, 0xaaaaaa);
78 pColorSet->add(model::ThemeColorType::Hyperlink, 0xbbbbbb);
79 pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xcccccc);
80 pTheme->setColorSet(pColorSet);
82 xMasterPage->setPropertyValue(u"Theme"_ustr, uno::Any(model::theme::createXTheme(pTheme)));
85 // Export to PPTX and load again:
86 saveAndReload(u"Impress Office Open XML"_ustr);
88 // Verify that this color is not lost:
89 xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/theme/theme1.xml"_ustr);
90 assertXPath(pXmlDoc, "//a:clrScheme/a:lt1/a:srgbClr", "val",
91 u"222222"); // expected color 22-22-22
93 // Check the theme after loading again
95 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
96 uno::Reference<drawing::XMasterPageTarget> xDrawPage(
97 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
98 uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
99 uno::Reference<util::XTheme> xTheme(xMasterPage->getPropertyValue(u"Theme"_ustr),
100 uno::UNO_QUERY);
101 CPPUNIT_ASSERT_EQUAL(true, xTheme.is());
103 auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get());
104 CPPUNIT_ASSERT(pUnoTheme);
105 auto pTheme = pUnoTheme->getTheme();
107 CPPUNIT_ASSERT_EQUAL(u"mytheme"_ustr, pTheme->GetName());
108 CPPUNIT_ASSERT_EQUAL(u"mycolorscheme"_ustr, pTheme->getColorSet()->getName());
109 CPPUNIT_ASSERT_EQUAL(u"Office"_ustr, pTheme->getFontScheme().getName());
110 CPPUNIT_ASSERT_EQUAL(u""_ustr, pTheme->getFormatScheme().getName());
114 CPPUNIT_TEST_FIXTURE(Test, testLoopingFromAnimation)
116 // Given a media shape that has an animation that specifies looping for the video:
117 loadFromFile(u"video-loop.pptx");
119 // When exporting that to PPTX:
120 save(u"Impress Office Open XML"_ustr);
122 // Then make sure that the "infinite" repeat count is written:
123 xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/slides/slide1.xml"_ustr);
124 // Without the fix in place, this test would have failed with:
125 // - Expected: 1
126 // - Actual : 0
127 // - In <>, XPath '//p:cMediaNode/p:cTn' number of nodes is incorrect
128 // i.e. the media node was lost on export, the video no longer looped.
129 assertXPath(pXmlDoc, "//p:cMediaNode/p:cTn", "repeatCount", u"indefinite");
133 CPPUNIT_PLUGIN_IMPLEMENT();
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */