summaryrefslogtreecommitdiff
path: root/xmloff/qa/unit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-09 08:43:27 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-06-29 09:04:07 +0200
commitae2b901849bbc6a1a75ea3c9b855676617e0958e (patch)
tree6e63b27320e56ed008706c583698aa518e7ffedc /xmloff/qa/unit
parent3d210f998928cb00e6989d9c2ad64ef1fa699175 (diff)
ODP import/export: refer to theme from shape text color
Refer to the 12 pre-defined colors by name + don't write the attribute for the case when there is no theme. (cherry picked from commit 91f649a119d4b7ece26f9737a38663664953a57a) Conflicts: xmloff/source/token/tokens.txt Change-Id: Ib6ab5b7b34d896a36e04309bf0cb410998acce01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136527 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r--xmloff/qa/unit/data/refer-to-theme.odpbin0 -> 14488 bytes
-rw-r--r--xmloff/qa/unit/draw.cxx24
2 files changed, 24 insertions, 0 deletions
diff --git a/xmloff/qa/unit/data/refer-to-theme.odp b/xmloff/qa/unit/data/refer-to-theme.odp
new file mode 100644
index 000000000000..83bad49b5f56
--- /dev/null
+++ b/xmloff/qa/unit/data/refer-to-theme.odp
Binary files differ
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index f3bab2a69996..2ea5ec785f44 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -179,6 +179,30 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport)
CPPUNIT_ASSERT_EQUAL(static_cast<util::Color>(0x954F72), aColorScheme[11]);
}
+CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme)
+{
+ // Given a document that refers to a theme color:
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "refer-to-theme.odp";
+
+ // When loading and saving that document:
+ getComponent() = loadFromDesktop(aURL);
+ utl::TempFile aTempFile;
+ save("impress8", aTempFile);
+
+ // Make sure the export result has the theme reference:
+ std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, "content.xml");
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get());
+ // Without the accompanying fix in place, this test would have failed with:
+ // - XPath '//style:style[@style:name='T1']/style:text-properties' no attribute 'theme-color' exist
+ // i.e. only the direct color was written, but not the theme reference.
+ assertXPath(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties", "theme-color",
+ "accent1");
+ assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "theme-color",
+ "accent1");
+ assertXPath(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", "theme-color",
+ "accent1");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */