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 /sc/source/ui/unoobj | |
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 'sc/source/ui/unoobj')
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index d98731951d17..86333bbd4b43 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -57,6 +57,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/XTheme.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> #include <com/sun/star/sheet/XLabelRanges.hpp> #include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp> @@ -82,6 +83,8 @@ #include <sfx2/lokhelper.hxx> #include <sfx2/lokcomponenthelpers.hxx> #include <sfx2/LokControlHandler.hxx> +#include <docmodel/uno/UnoTheme.hxx> +#include <docmodel/theme/Theme.hxx> #include <cellsuno.hxx> #include <columnspanset.hxx> @@ -165,6 +168,7 @@ static o3tl::span<const SfxItemPropertyMapEntry> lcl_GetDocOptPropertyMap() { SC_UNO_LOOKUPLABELS, PROP_UNO_LOOKUPLABELS, cppu::UnoType<bool>::get(), 0, 0}, { SC_UNO_MATCHWHOLE, PROP_UNO_MATCHWHOLE, cppu::UnoType<bool>::get(), 0, 0}, { SC_UNO_NAMEDRANGES, 0, cppu::UnoType<sheet::XNamedRanges>::get(), 0, 0}, + { SC_UNO_THEME, 0, cppu::UnoType<util::XTheme>::get(), 0, 0}, { SC_UNO_DATABASERNG, 0, cppu::UnoType<sheet::XDatabaseRanges>::get(), 0, 0}, { SC_UNO_NULLDATE, PROP_UNO_NULLDATE, cppu::UnoType<util::Date>::get(), 0, 0}, { SC_UNO_ROWLABELRNG, 0, cppu::UnoType<sheet::XLabelRanges>::get(), 0, 0}, @@ -2837,6 +2841,16 @@ void SAL_CALL ScModelObj::setPropertyValue( { setGrabBagItem(aValue); } + else if (aPropertyName == SC_UNO_THEME) + { + SdrModel& rSdrModel = getSdrModelFromUnoModel(); + uno::Reference<util::XTheme> xTheme; + if (aValue >>= xTheme) + { + auto& rUnoTheme = dynamic_cast<UnoTheme&>(*xTheme); + rSdrModel.setTheme(rUnoTheme.getTheme()); + } + } if ( aNewOpt != rOldOpt ) { @@ -3023,6 +3037,15 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName ) { getGrabBagItem(aRet); } + else if (aPropertyName == SC_UNO_THEME) + { + SdrModel& rSdrModel = getSdrModelFromUnoModel(); + css::uno::Reference<css::util::XTheme> xTheme; + auto pTheme = rSdrModel.getTheme(); + if (pTheme) + xTheme = model::theme::createXTheme(pTheme); + aRet <<= xTheme; + } } return aRet; |