diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2021-09-13 09:47:11 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-11-18 17:17:43 +0100 |
commit | 6ce8066af743b172d36046a8dc8b17ebe010b6cf (patch) | |
tree | c27c1699e29f0a3a8340adbbf1c7704ebb54c866 | |
parent | f4d59ec73682f06fff9f718b3347726f1d53d263 (diff) |
import pptx color schemes as color sets
initial import work for color sets.
Themes (which we get the color schemes from) in MSO can
be different for each master - will need to support that too.
[ Miklos: actually added that per-master-page support. ]
(cherry picked from commit 3b21d166f585dcdf8d576d166aeff3cfd4694aab,
from the feature/themesupport2 branch)
Change-Id: Ia06d2645018e6bfa70817bbddba2374641ae13dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125477
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | include/oox/drawingml/theme.hxx | 5 | ||||
-rw-r--r-- | include/svx/svdpage.hxx | 5 | ||||
-rw-r--r-- | oox/source/drawingml/theme.cxx | 15 | ||||
-rw-r--r-- | oox/source/drawingml/themefragmenthandler.cxx | 6 | ||||
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 27 | ||||
-rw-r--r-- | svx/source/svdraw/svdpage.cxx | 3 |
7 files changed, 65 insertions, 2 deletions
diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx index 944e58b6e79c..6222a4264451 100644 --- a/include/oox/drawingml/theme.hxx +++ b/include/oox/drawingml/theme.hxx @@ -32,6 +32,7 @@ #include <sal/types.h> namespace com::sun::star { + namespace drawing { class XDrawPage; } namespace xml::dom { class XDocument; } } @@ -57,6 +58,7 @@ class OOX_DLLPUBLIC Theme { public: void setStyleName( const OUString& rStyleName ) { maStyleName = rStyleName; } + void setThemeName(const OUString& rThemeName) { maThemeName = rThemeName; } ClrScheme& getClrScheme() { return maClrScheme; } const ClrScheme& getClrScheme() const { return maClrScheme; } @@ -96,8 +98,11 @@ public: const css::uno::Reference<css::xml::dom::XDocument>& getFragment() const { return mxFragment; } void setFragment( const css::uno::Reference< css::xml::dom::XDocument>& xRef ) { mxFragment=xRef; } + void addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage) const; + private: OUString maStyleName; + OUString maThemeName; ClrScheme maClrScheme; FillStyleList maFillStyleList; FillStyleList maBgFillStyleList; diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index eaadcde330c0..540002eb7d14 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> #include <svx/svdobj.hxx> +#include <svx/ColorSets.hxx> #include <memory> #include <optional> #include <vector> @@ -312,6 +313,7 @@ private: // data SdrPage* mpSdrPage; SfxStyleSheet* mpStyleSheet; + std::unique_ptr<svx::Theme> mpTheme; SfxItemSet maProperties; // internal helpers @@ -339,6 +341,9 @@ public: // StyleSheet access void SetStyleSheet(SfxStyleSheet* pStyleSheet); SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;} + + void SetTheme(std::unique_ptr<svx::Theme> pTheme); + svx::Theme* GetTheme(); }; diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx index 036779d21711..be9f199ff8f8 100644 --- a/oox/source/drawingml/theme.cxx +++ b/oox/source/drawingml/theme.cxx @@ -20,6 +20,12 @@ #include <oox/drawingml/theme.hxx> #include <oox/token/tokens.hxx> #include <drawingml/textcharacterproperties.hxx> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <comphelper/propertyvalue.hxx> + +using namespace com::sun::star; namespace oox::drawingml { @@ -97,6 +103,15 @@ const TextFont* Theme::resolveFont( const OUString& rName ) const return nullptr; } +void Theme::addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage) const +{ + beans::PropertyValues aValues = { + comphelper::makePropertyValue("Name", maThemeName), + }; + uno::Reference<beans::XPropertySet> xPropertySet(xDrawPage, uno::UNO_QUERY); + xPropertySet->setPropertyValue("Theme", uno::makeAny(aValues)); +} + } // namespace oox::drawingml /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/themefragmenthandler.cxx b/oox/source/drawingml/themefragmenthandler.cxx index 5c5d4a6ab07a..5ab0ee1e6b21 100644 --- a/oox/source/drawingml/themefragmenthandler.cxx +++ b/oox/source/drawingml/themefragmenthandler.cxx @@ -21,6 +21,7 @@ #include <drawingml/objectdefaultcontext.hxx> #include <oox/drawingml/theme.hxx> #include <oox/token/namespaces.hxx> +#include <oox/helper/attributelist.hxx> #include <drawingml/themeelementscontext.hxx> using namespace ::oox::core; @@ -37,7 +38,7 @@ ThemeFragmentHandler::~ThemeFragmentHandler() { } -ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, const AttributeList& ) +ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs) { // CT_OfficeStyleSheet switch( getCurrentElement() ) @@ -46,7 +47,10 @@ ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, con switch( nElement ) { case A_TOKEN( theme ): + { + mrTheme.setThemeName(rAttribs.getString(XML_name).get()); return this; + } } break; diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 5d5c3a594009..a088bf04636e 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -378,6 +378,12 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) ); pMasterPersistPtr->createBackground( rFilter ); pMasterPersistPtr->createXShapes( rFilter ); + + oox::drawingml::ThemePtr pTheme = pMasterPersistPtr->getTheme(); + if (pTheme) + { + pTheme->addTheme(pMasterPersistPtr->getPage()); + } } } } diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 984b5fd0df2c..656ca7d8a234 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -98,7 +98,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_NAVORDER, WID_PAGE_PREVIEWMETAFILE, WID_PAGE_THEME }; } @@ -280,6 +280,7 @@ 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"", 0, css::uno::Type(), 0, 0 } }; @@ -972,6 +973,14 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName break; } + case WID_PAGE_THEME: + { + SdrPage* pPage = GetPage(); + std::unique_ptr<svx::Theme> pTheme = svx::Theme::FromAny(aValue); + pPage->getSdrPageProperties().SetTheme(std::move(pTheme)); + break; + } + default: throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); } @@ -1286,6 +1295,22 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) aAny <<= GetPage()->getTransitionDuration(); break; + case WID_PAGE_THEME: + { + SdrPage* pPage = GetPage(); + svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + if (pTheme) + { + pTheme->ToAny(aAny); + } + else + { + beans::PropertyValues aValues; + aAny <<= aValues; + } + break; + } + default: throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this)); } diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 0d2febd376e6..a0acaba2ee5f 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1287,6 +1287,9 @@ void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet) ImpPageChange(*mpSdrPage); } +void SdrPageProperties::SetTheme(std::unique_ptr<svx::Theme> pTheme) { mpTheme = std::move(pTheme); } + +svx::Theme* SdrPageProperties::GetTheme() { return mpTheme.get(); } SdrPage::SdrPage(SdrModel& rModel, bool bMasterPage) : mrSdrModelFromSdrPage(rModel), |