diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-08-31 22:29:46 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-09-01 10:12:11 +0200 |
commit | b36f7769dd07a6b6f55cdf4ce76e2f39ed186e89 (patch) | |
tree | a26f63a64df6fe34e306ae7f0b5e4f5767ca4a42 /xmloff/source/style | |
parent | b53a03d1d55de7fd04efc47c4a57baa11d72dd85 (diff) |
sc: add ODF import/export of the Theme + tests
One missing thing is the support in calc to save the Theme into
the ODS document and read that back. The theme element is added as
a child element to the office:styles - the same as it already is
added in Writer.
Also adds "Theme" property as a top level document property
so it is possible to get and set the theme in xmloff.
Also tests have been added to cover this usecases.
Change-Id: Ic214ff5e945b77d50e6c881def9d49509560a0e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156363
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff/source/style')
-rw-r--r-- | xmloff/source/style/XMLThemeContext.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 22 |
2 files changed, 16 insertions, 12 deletions
diff --git a/xmloff/source/style/XMLThemeContext.cxx b/xmloff/source/style/XMLThemeContext.cxx index 1579af468003..5c210c7a48dc 100644 --- a/xmloff/source/style/XMLThemeContext.cxx +++ b/xmloff/source/style/XMLThemeContext.cxx @@ -33,9 +33,9 @@ using namespace xmloff::token; XMLThemeContext::XMLThemeContext(SvXMLImport& rImport, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList, - css::uno::Reference<css::drawing::XDrawPage> const& xPage) + css::uno::Reference<css::uno::XInterface> const& xObject) : SvXMLImportContext(rImport) - , m_xPage(xPage) + , m_xObject(xObject) , mpTheme(new model::Theme) { for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList)) @@ -56,7 +56,7 @@ XMLThemeContext::~XMLThemeContext() { if (mpTheme && mpTheme->getColorSet()) { - uno::Reference<beans::XPropertySet> xPropertySet(m_xPage, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(m_xObject, uno::UNO_QUERY); auto xTheme = model::theme::createXTheme(mpTheme); xPropertySet->setPropertyValue("Theme", uno::Any(xTheme)); } diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index d0dc368870a2..5158b43592cd 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -683,22 +683,26 @@ SvXMLStylesContext::~SvXMLStylesContext() css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLStylesContext::createFastChildContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - SvXMLStyleContext* pStyle = CreateStyleChildContext( nElement, xAttrList ); - if (pStyle) - { - if (!pStyle->IsTransient()) - mpImpl->AddStyle(pStyle); - return pStyle; - } - else if (nElement == XML_ELEMENT(LO_EXT, XML_THEME)) + if (nElement == XML_ELEMENT(LO_EXT, XML_THEME)) { + uno::Reference<uno::XInterface> xObject(GetImport().GetModel(), uno::UNO_QUERY); uno::Reference<drawing::XDrawPageSupplier> const xDrawPageSupplier(GetImport().GetModel(), uno::UNO_QUERY); if (xDrawPageSupplier.is()) { uno::Reference<drawing::XDrawPage> xPage = xDrawPageSupplier->getDrawPage(); if (xPage.is()) - return new XMLThemeContext(GetImport(), xAttrList, xPage); + xObject = xPage; } + + return new XMLThemeContext(GetImport(), xAttrList, xObject); + } + + SvXMLStyleContext* pStyle = CreateStyleChildContext( nElement, xAttrList ); + if (pStyle) + { + if (!pStyle->IsTransient()) + mpImpl->AddStyle(pStyle); + return pStyle; } return nullptr; |