summaryrefslogtreecommitdiff
path: root/xmloff/qa/unit
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-01-28 18:43:51 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-02-01 08:41:30 +0000
commitd8de2dc3c55a9013a71167c8058a333e7221a6a0 (patch)
tree1419829f0f77b8ce692bb31823d148d4ffa75c85 /xmloff/qa/unit
parent7ab51def766ad6bfdcf5111e7b751bbc2bbf1d73 (diff)
xmloff: import of theme structure + import/export/round-trip tests
Change-Id: I50e8c53c534895098613e81fd97b346fd3d7d05f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146287 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r--xmloff/qa/unit/text.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index f7155f546df3..5dfd52010a09 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -16,11 +16,13 @@
#include <com/sun/star/text/BibliographyDataType.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <unotools/tempfile.hxx>
+#include <docmodel/uno/UnoTheme.hxx>
using namespace ::com::sun::star;
@@ -907,6 +909,53 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthRedline)
assertXPath(pXmlDoc, "//draw:frame[@draw:name='Image45']", "width", "6.1728in");
}
+CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testThemeExport)
+{
+ mxComponent = loadFromDesktop("private:factory/swriter");
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<beans::XPropertySet> xPageProps(xDrawPage, uno::UNO_QUERY);
+
+ model::Theme aTheme("My Theme");
+ std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("My Color Scheme"));
+ pColorSet->add(model::ThemeColorType::Dark1, 0x101010);
+ pColorSet->add(model::ThemeColorType::Light1, 0x202020);
+ pColorSet->add(model::ThemeColorType::Dark2, 0x303030);
+ pColorSet->add(model::ThemeColorType::Light2, 0x404040);
+ pColorSet->add(model::ThemeColorType::Accent1, 0x505050);
+ pColorSet->add(model::ThemeColorType::Accent2, 0x606060);
+ pColorSet->add(model::ThemeColorType::Accent3, 0x707070);
+ pColorSet->add(model::ThemeColorType::Accent4, 0x808080);
+ pColorSet->add(model::ThemeColorType::Accent5, 0x909090);
+ pColorSet->add(model::ThemeColorType::Accent6, 0xa0a0a0);
+ pColorSet->add(model::ThemeColorType::Hyperlink, 0xb0b0b0);
+ pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xc0c0c0);
+ aTheme.SetColorSet(std::move(pColorSet));
+
+ uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(aTheme);
+ xPageProps->setPropertyValue("Theme", uno::Any(xTheme));
+
+ // Export to ODT:
+ save("writer8");
+
+ // Check if the 12 colors are written in the XML:
+ xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color", 12);
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color[1]", "name",
+ "dk1");
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color[1]", "color",
+ "#101010");
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color[2]", "name",
+ "lt1");
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color[2]", "color",
+ "#202020");
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color[12]", "name",
+ "folHlink");
+ assertXPath(pXmlDoc, "//office:styles/loext:theme/loext:color-table/loext:color[12]", "color",
+ "#c0c0c0");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */