diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-12-06 17:33:44 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-16 00:22:39 +0000 |
commit | 53731e084ecb5991ed02dc633f180442f91e69cf (patch) | |
tree | 5103c46c7521a4d1359c27995165bbee7e0e1541 /sw | |
parent | e15372dd4ce43bb867d0b4d66cbcee993d4c5449 (diff) |
sw: read theme from OOXML file and set it to the draw page
This change extends writerfilter to use oox::ThemeFragmentHandler
to read the theme properties, and sets that to the one and only
draw page of a Writer document.
This change also removes ThemeTable and replaces it with the
ThemeHandler, which takes theme font data from svx::Theme
instead.
In addition, a test has been writen, which loads a document with
a theme, and asserts the draw page has the theme and the theme
properties currently supported.
Change-Id: Iff0048cd21ea030ac55287707852acc463ec3cb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143699
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 312100003fc7cae358038aaec853584782c698f8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145388
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/theme/ThemeTest.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx index 356fafdb9aa4..0d3816e9a623 100644 --- a/sw/qa/core/theme/ThemeTest.cxx +++ b/sw/qa/core/theme/ThemeTest.cxx @@ -11,6 +11,11 @@ #include <memory> #include <docsh.hxx> +#include <unotxdoc.hxx> +#include <wrtsh.hxx> +#include <drawdoc.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <svx/svdpage.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/theme/data/"; @@ -26,6 +31,46 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testThemeColorInHeading) CPPUNIT_ASSERT_EQUAL(sal_Int16(4), getProperty<sal_Int16>(getParagraph(1), "CharColorTheme")); } +CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testDrawPageThemeExists) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "ThemeColorInHeading.docx"); + CPPUNIT_ASSERT(pDoc); + + SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + CPPUNIT_ASSERT(pTheme); + CPPUNIT_ASSERT_EQUAL(OUString(u"Office Theme"), pTheme->GetName()); + + svx::ColorSet* pColorSet = pTheme->GetColorSet(); + CPPUNIT_ASSERT(pColorSet); + CPPUNIT_ASSERT_EQUAL(OUString(u"Orange"), pColorSet->getName()); + + CPPUNIT_ASSERT_EQUAL(Color(0xE48312), pTheme->GetColor(svx::ThemeColorType::Accent1)); + CPPUNIT_ASSERT_EQUAL(Color(0xBD582C), pTheme->GetColor(svx::ThemeColorType::Accent2)); + CPPUNIT_ASSERT_EQUAL(Color(0x865640), pTheme->GetColor(svx::ThemeColorType::Accent3)); + CPPUNIT_ASSERT_EQUAL(Color(0x9B8357), pTheme->GetColor(svx::ThemeColorType::Accent4)); + CPPUNIT_ASSERT_EQUAL(Color(0xC2BC80), pTheme->GetColor(svx::ThemeColorType::Accent5)); + CPPUNIT_ASSERT_EQUAL(Color(0x94A088), pTheme->GetColor(svx::ThemeColorType::Accent6)); + CPPUNIT_ASSERT_EQUAL(Color(0x000000), pTheme->GetColor(svx::ThemeColorType::Dark1)); + CPPUNIT_ASSERT_EQUAL(Color(0x637052), pTheme->GetColor(svx::ThemeColorType::Dark2)); + CPPUNIT_ASSERT_EQUAL(Color(0xFFFFFF), pTheme->GetColor(svx::ThemeColorType::Light1)); + CPPUNIT_ASSERT_EQUAL(Color(0xCCDDEA), pTheme->GetColor(svx::ThemeColorType::Light2)); + + svx::FontScheme const& rFontScheme = pTheme->getFontScheme(); + CPPUNIT_ASSERT_EQUAL(OUString(u"Calibri Light"), rFontScheme.getMajorLatin().maTypeface); + CPPUNIT_ASSERT_EQUAL(OUString(u"Calibri"), rFontScheme.getMinorLatin().maTypeface); + CPPUNIT_ASSERT_EQUAL(true, rFontScheme.getMajorAsian().maTypeface.isEmpty()); + CPPUNIT_ASSERT_EQUAL(true, rFontScheme.getMinorAsian().maTypeface.isEmpty()); + CPPUNIT_ASSERT_EQUAL(true, rFontScheme.getMajorComplex().maTypeface.isEmpty()); + CPPUNIT_ASSERT_EQUAL(true, rFontScheme.getMinorComplex().maTypeface.isEmpty()); + CPPUNIT_ASSERT_EQUAL(size_t(47), rFontScheme.getMajorSupplementalFontList().size()); + CPPUNIT_ASSERT_EQUAL(size_t(47), rFontScheme.getMinorSupplementalFontList().size()); + CPPUNIT_ASSERT_EQUAL(OUString(u"Angsana New"), + rFontScheme.findMajorSupplementalTypeface(u"Thai")); + CPPUNIT_ASSERT_EQUAL(OUString(u"Cordia New"), + rFontScheme.findMinorSupplementalTypeface(u"Thai")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |