diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-27 15:03:09 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-31 08:59:09 +0000 |
commit | 75c0d7827625c683d52a9e2f3a7c514df890107b (patch) | |
tree | 8ac5856ae7ae10a1aa558dfe2eca3fbe918d842d /sd | |
parent | ed9d987e2ad8f6af554a5fc1f858ca48c6970446 (diff) |
sd: use XTheme to transport the theme to xmloff import/export
Refactor the existing places and tests in Impress code (sd) to
use it instead.
Also keep the old property of construction and view of the theme
with a sequence of property values, but under the new property
named "ThemeUnoRepresentation". This is needed by the UI tests
currently.
Change-Id: I484567f4a603f1a5e2e03955fdd2b63132dcc66e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146225
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/CppunitTest_sd_filter_eppt.mk | 1 | ||||
-rw-r--r-- | sd/qa/filter/eppt/eppt.cxx | 28 | ||||
-rw-r--r-- | sd/qa/unit/uiimpress.cxx | 27 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 32 |
5 files changed, 71 insertions, 20 deletions
diff --git a/sd/CppunitTest_sd_filter_eppt.mk b/sd/CppunitTest_sd_filter_eppt.mk index 2a570b5dcd92..261fa3052ee8 100644 --- a/sd/CppunitTest_sd_filter_eppt.mk +++ b/sd/CppunitTest_sd_filter_eppt.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_filter_eppt, \ comphelper \ cppu \ cppuhelper \ + docmodel \ sd \ sal \ subsequenttest \ diff --git a/sd/qa/filter/eppt/eppt.cxx b/sd/qa/filter/eppt/eppt.cxx index 57c73456aea0..fe8151a67638 100644 --- a/sd/qa/filter/eppt/eppt.cxx +++ b/sd/qa/filter/eppt/eppt.cxx @@ -15,7 +15,7 @@ #include <com/sun/star/util/Color.hpp> #include <test/xmldocptr.hxx> -#include <comphelper/sequenceashashmap.hxx> +#include <docmodel/uno/UnoTheme.hxx> using namespace ::com::sun::star; @@ -66,14 +66,24 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeExport) uno::Reference<drawing::XMasterPageTarget> xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY); - comphelper::SequenceAsHashMap aMap; - aMap["Name"] <<= OUString("mytheme"); - aMap["ColorSchemeName"] <<= OUString("mycolorscheme"); - uno::Sequence<util::Color> aColorScheme - = { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc }; - aMap["ColorScheme"] <<= aColorScheme; - uno::Any aTheme(aMap.getAsConstPropertyValueList()); - xMasterPage->setPropertyValue("Theme", aTheme); + + model::Theme aTheme("mytheme"); + std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("mycolorscheme")); + pColorSet->add(model::ThemeColorType::Dark1, 0x1); + pColorSet->add(model::ThemeColorType::Light1, 0x2); + pColorSet->add(model::ThemeColorType::Dark2, 0x3); + pColorSet->add(model::ThemeColorType::Light2, 0x4); + pColorSet->add(model::ThemeColorType::Accent1, 0x5); + pColorSet->add(model::ThemeColorType::Accent2, 0x6); + pColorSet->add(model::ThemeColorType::Accent3, 0x7); + pColorSet->add(model::ThemeColorType::Accent4, 0x8); + pColorSet->add(model::ThemeColorType::Accent5, 0x9); + pColorSet->add(model::ThemeColorType::Accent6, 0xa); + pColorSet->add(model::ThemeColorType::Hyperlink, 0xb); + pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xc); + aTheme.SetColorSet(std::move(pColorSet)); + + xMasterPage->setPropertyValue("Theme", uno::Any(model::theme::createXTheme(aTheme))); // When exporting to PPTX: save("Impress Office Open XML"); diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index e311087673ab..4eb16f50713b 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -46,6 +46,7 @@ #include <docmodel/uno/UnoThemeColor.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> +#include <docmodel/uno/UnoTheme.hxx> #include <drawdoc.hxx> #include <DrawDocShell.hxx> @@ -1195,14 +1196,24 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testThemeShapeInsert) uno::Reference<drawing::XMasterPageTarget> xMasterPageTarget(xDrawPage, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xMasterPage(xMasterPageTarget->getMasterPage(), uno::UNO_QUERY); - comphelper::SequenceAsHashMap aMap; - aMap["Name"] <<= OUString("mytheme"); - aMap["ColorSchemeName"] <<= OUString("mycolorscheme"); - uno::Sequence<util::Color> aColorScheme - = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb }; - aMap["ColorScheme"] <<= aColorScheme; - uno::Any aTheme(aMap.getAsConstPropertyValueList()); - xMasterPage->setPropertyValue("Theme", aTheme); + + model::Theme aTheme("mytheme"); + std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("mycolorscheme")); + pColorSet->add(model::ThemeColorType::Dark1, 0x0); + pColorSet->add(model::ThemeColorType::Light1, 0x1); + pColorSet->add(model::ThemeColorType::Dark2, 0x2); + pColorSet->add(model::ThemeColorType::Light2, 0x3); + pColorSet->add(model::ThemeColorType::Accent1, 0x4); + pColorSet->add(model::ThemeColorType::Accent2, 0x5); + pColorSet->add(model::ThemeColorType::Accent3, 0x6); + pColorSet->add(model::ThemeColorType::Accent4, 0x7); + pColorSet->add(model::ThemeColorType::Accent5, 0x8); + pColorSet->add(model::ThemeColorType::Accent6, 0x9); + pColorSet->add(model::ThemeColorType::Hyperlink, 0xa); + pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xb); + aTheme.SetColorSet(std::move(pColorSet)); + + xMasterPage->setPropertyValue("Theme", uno::Any(model::theme::createXTheme(aTheme))); // When inserting a shape: uno::Sequence<beans::PropertyValue> aArgs = { diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 9b9ed18dbfc6..b5c9e64a61bc 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/util/XTheme.hpp> #include <com/sun/star/embed/Aspects.hpp> @@ -245,7 +246,7 @@ static const SvxItemPropertySet* ImplGetDrawModelPropertySet() { sUNO_Prop_HasValidSignatures, WID_MODEL_HASVALIDSIGNATURES, ::cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::READONLY, 0}, { u"Fonts", WID_MODEL_FONTS, cppu::UnoType<uno::Sequence<uno::Any>>::get(), beans::PropertyAttribute::READONLY, 0}, { sUNO_Prop_InteropGrabBag, WID_MODEL_INTEROPGRABBAG, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0}, - { sUNO_Prop_Theme, WID_MODEL_THEME, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0}, + { sUNO_Prop_Theme, WID_MODEL_THEME, cppu::UnoType<util::XTheme>::get(), 0, 0}, }; static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); return &aDrawModelPropertySet_Impl; diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 2dfff467ceb7..5292349b4ba8 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/presentation/AnimationSpeed.hpp> #include <com/sun/star/view/PaperOrientation.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/util/XTheme.hpp> #include <cppuhelper/implbase.hxx> #include <comphelper/profilezone.hxx> #include <comphelper/servicehelper.hxx> @@ -74,6 +75,7 @@ #include <vcl/dibtools.hxx> #include <tools/debug.hxx> #include <tools/stream.hxx> +#include <docmodel/uno/UnoTheme.hxx> #include <o3tl/string_view.hxx> using ::com::sun::star::animations::XAnimationNode; @@ -100,7 +102,7 @@ enum WID_PAGE WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED, WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE, WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND, - WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE, WID_PAGE_THEME + WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE, WID_PAGE_THEME, WID_PAGE_THEME_UNO_REPRESENTATION }; } @@ -279,7 +281,9 @@ static const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKin { u"BackgroundFullSize", WID_PAGE_BACKFULL, cppu::UnoType<bool>::get(), 0, 0}, { sUNO_Prop_UserDefinedAttributes,WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, { u"IsBackgroundDark", WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0}, - { u"Theme", WID_PAGE_THEME, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0} + { u"Theme", WID_PAGE_THEME, cppu::UnoType<util::XTheme>::get(), 0, 0}, + // backwards compatible view of the theme for use in tests + { u"ThemeUnoRepresentation", WID_PAGE_THEME_UNO_REPRESENTATION, cppu::UnoType<uno::Sequence<beans::PropertyValue>>::get(), 0, 0} }; static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] = @@ -976,6 +980,19 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName case WID_PAGE_THEME: { SdrPage* pPage = GetPage(); + uno::Reference<util::XTheme> xTheme; + if (aValue >>= xTheme) + { + auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get()); + std::unique_ptr<model::Theme> pTheme(new model::Theme(pUnoTheme->getTheme())); + pPage->getSdrPageProperties().SetTheme(std::move(pTheme)); + } + break; + } + + case WID_PAGE_THEME_UNO_REPRESENTATION: + { + SdrPage* pPage = GetPage(); std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue); pPage->getSdrPageProperties().SetTheme(std::move(pTheme)); break; @@ -1298,6 +1315,17 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) case WID_PAGE_THEME: { SdrPage* pPage = GetPage(); + css::uno::Reference<css::util::XTheme> xTheme; + auto* pTheme = pPage->getSdrPageProperties().GetTheme(); + if (pTheme) + xTheme = new UnoTheme(*pTheme); + aAny <<= xTheme; + break; + } + + case WID_PAGE_THEME_UNO_REPRESENTATION: + { + SdrPage* pPage = GetPage(); model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (pTheme) { |