docmodel/Library_docmodel.mk | 1 docmodel/source/theme/Theme.cxx | 158 ++++++++++++++++++++++ include/docmodel/theme/Theme.hxx | 163 +++++++++++++++++++++++ include/oox/drawingml/theme.hxx | 4 include/oox/export/ThemeExport.hxx | 8 - include/svx/ColorSets.hxx | 186 --------------------------- include/svx/dialog/ThemeDialog.hxx | 5 include/svx/svdmodel.hxx | 6 include/svx/svdpage.hxx | 8 - oox/inc/drawingml/textfont.hxx | 4 oox/source/drawingml/textfont.cxx | 4 oox/source/drawingml/theme.cxx | 30 ++-- oox/source/export/ThemeExport.cxx | 10 - sd/source/filter/eppt/epptooxml.hxx | 6 sd/source/filter/eppt/pptx-epptooxml.cxx | 6 sd/source/ui/docshell/docshell.cxx | 2 sd/source/ui/func/fuconstr.cxx | 2 sd/source/ui/func/fupage.cxx | 4 sd/source/ui/unoidl/unomodel.cxx | 4 sd/source/ui/unoidl/unopage.cxx | 4 svx/qa/unit/ThemeTest.cxx | 4 svx/source/dialog/ThemeDialog.cxx | 3 svx/source/styles/ColorSets.cxx | 136 ------------------- svx/source/svdraw/svdmodel.cxx | 8 - svx/source/svdraw/svdpage.cxx | 4 sw/qa/core/theme/ThemeTest.cxx | 4 sw/source/core/model/ThemeColorChanger.cxx | 4 sw/source/filter/xml/xmlfmte.cxx | 2 sw/source/uibase/app/docst.cxx | 4 sw/source/uibase/shells/basesh.cxx | 4 sw/source/uibase/sidebar/ThemePanel.cxx | 4 writerfilter/source/dmapper/ThemeHandler.cxx | 8 - xmloff/source/draw/sdxmlexp.cxx | 2 33 files changed, 402 insertions(+), 400 deletions(-)
New commits: commit c9fb441c55d03f55877ed3bb2f5c39310d1ec44b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jan 27 08:41:16 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Jan 27 03:22:22 2023 +0000 move Theme class to own file inside docmodel Also move Theme from svx to model namespace so it is consistent with other classes in docmodel. Theme header also includes ThemeSupplementalFont, ThemeFont, FontScheme classes that are used by the Theme and were also moved to docmodel. These may be moved to its own file in the future when they are used in more places. Change-Id: Ic409bea8e5298adc2b039b529c4f7b01cf64f03e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146221 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/docmodel/Library_docmodel.mk b/docmodel/Library_docmodel.mk index 22ecdfa59ac4..7974027a7a9e 100644 --- a/docmodel/Library_docmodel.mk +++ b/docmodel/Library_docmodel.mk @@ -12,6 +12,7 @@ $(eval $(call gb_Library_Library,docmodel)) $(eval $(call gb_Library_add_exception_objects,docmodel,\ docmodel/source/uno/UnoThemeColor \ docmodel/source/theme/ColorSet \ + docmodel/source/theme/Theme \ )) $(eval $(call gb_Library_set_include,docmodel,\ diff --git a/docmodel/source/theme/Theme.cxx b/docmodel/source/theme/Theme.cxx new file mode 100644 index 000000000000..0f8ff8002870 --- /dev/null +++ b/docmodel/source/theme/Theme.cxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <docmodel/theme/Theme.hxx> + +#include <utility> +#include <libxml/xmlwriter.h> +#include <comphelper/sequenceashashmap.hxx> +#include <comphelper/sequence.hxx> +#include <sal/log.hxx> +#include <sal/types.h> +#include <o3tl/enumrange.hxx> +#include <com/sun/star/util/Color.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +using namespace com::sun::star; + +namespace model +{ +Theme::Theme(OUString const& rName) + : maName(rName) +{ +} + +void Theme::SetColorSet(std::unique_ptr<model::ColorSet> pColorSet) +{ + mpColorSet = std::move(pColorSet); +} + +const model::ColorSet* Theme::GetColorSet() const { return mpColorSet.get(); } + +model::ColorSet* Theme::GetColorSet() { return mpColorSet.get(); } + +void Theme::SetName(const OUString& rName) { maName = rName; } + +const OUString& Theme::GetName() const { return maName; } + +void Theme::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("Theme")); + (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maName"), + BAD_CAST(maName.toUtf8().getStr())); + + if (mpColorSet) + { + mpColorSet->dumpAsXml(pWriter); + } + + (void)xmlTextWriterEndElement(pWriter); +} + +void Theme::ToAny(uno::Any& rVal) const +{ + comphelper::SequenceAsHashMap aMap; + aMap["Name"] <<= maName; + + if (mpColorSet) + { + std::vector<util::Color> aColorScheme; + for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) + { + if (eThemeColorType != model::ThemeColorType::Unknown) + { + Color aColor = mpColorSet->getColor(eThemeColorType); + aColorScheme.push_back(sal_Int32(aColor)); + } + } + + aMap["ColorSchemeName"] <<= mpColorSet->getName(); + aMap["ColorScheme"] <<= comphelper::containerToSequence(aColorScheme); + } + + rVal <<= aMap.getAsConstPropertyValueList(); +} + +std::unique_ptr<Theme> Theme::FromAny(const uno::Any& rVal) +{ + comphelper::SequenceAsHashMap aMap(rVal); + std::unique_ptr<Theme> pTheme; + model::ColorSet* pColorSet = nullptr; + + auto it = aMap.find("Name"); + if (it != aMap.end()) + { + OUString aName; + it->second >>= aName; + pTheme = std::make_unique<Theme>(aName); + } + + it = aMap.find("ColorSchemeName"); + if (it != aMap.end() && pTheme) + { + OUString aName; + it->second >>= aName; + auto pSet = std::make_unique<model::ColorSet>(aName); + pTheme->SetColorSet(std::move(pSet)); + pColorSet = pTheme->GetColorSet(); + } + + it = aMap.find("ColorScheme"); + if (it != aMap.end() && pColorSet) + { + uno::Sequence<util::Color> aColors; + it->second >>= aColors; + + SAL_WARN_IF(aColors.size() > 12, "svx", + "Theme::FromAny: number of colors greater than max theme colors supported"); + + for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) + { + if (eThemeColorType != model::ThemeColorType::Unknown) + { + size_t nIndex(static_cast<sal_Int16>(eThemeColorType)); + if (nIndex < aColors.size()) + { + Color aColor(ColorTransparency, aColors[nIndex]); + pColorSet->add(eThemeColorType, aColor); + } + } + } + } + + return pTheme; +} + +std::vector<Color> Theme::GetColors() const +{ + if (!mpColorSet) + return {}; + + std::vector<Color> aColors; + for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) + { + if (eThemeColorType != model::ThemeColorType::Unknown) + aColors.push_back(mpColorSet->getColor(eThemeColorType)); + } + return aColors; +} + +Color Theme::GetColor(model::ThemeColorType eType) const +{ + if (!mpColorSet) + return {}; + + return mpColorSet->getColor(eType); +} + +} // end of namespace model + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/docmodel/theme/Theme.hxx b/include/docmodel/theme/Theme.hxx new file mode 100644 index 000000000000..1f6a91762964 --- /dev/null +++ b/include/docmodel/theme/Theme.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <docmodel/dllapi.h> +#include <vector> + +#include <rtl/ustring.hxx> +#include <docmodel/theme/ThemeColor.hxx> +#include <docmodel/theme/ThemeColorType.hxx> +#include <docmodel/theme/Theme.hxx> +#include <docmodel/theme/ColorSet.hxx> +#include <tools/color.hxx> + +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +namespace model +{ +struct DOCMODEL_DLLPUBLIC ThemeSupplementalFont +{ + OUString maScript; + OUString maTypeface; +}; + +struct DOCMODEL_DLLPUBLIC ThemeFont +{ + OUString maTypeface; + OUString maPanose; + sal_Int16 maPitch = 0; + sal_Int16 maFamily = 0; + sal_Int32 maCharset = 0; + + sal_Int16 getPitchFamily() const { return (maPitch & 0x0F) | (maFamily & 0x0F) << 4; } +}; + +class DOCMODEL_DLLPUBLIC FontScheme +{ +private: + OUString maName; + + ThemeFont maMinorLatin; + ThemeFont maMinorAsian; + ThemeFont maMinorComplex; + + ThemeFont maMajorLatin; + ThemeFont maMajorAsian; + ThemeFont maMajorComplex; + + std::vector<ThemeSupplementalFont> maMinorSupplementalFontList; + std::vector<ThemeSupplementalFont> maMajorSupplementalFontList; + +public: + FontScheme() = default; + FontScheme(OUString const& rName) + : maName(rName) + { + } + + const OUString& getName() const { return maName; } + + ThemeFont const& getMinorLatin() const { return maMinorLatin; } + void setMinorLatin(ThemeFont const& aMinor) { maMinorLatin = aMinor; } + + ThemeFont const& getMinorAsian() const { return maMinorAsian; } + void setMinorAsian(ThemeFont const& aMinor) { maMinorAsian = aMinor; } + + ThemeFont const& getMinorComplex() const { return maMinorComplex; } + void setMinorComplex(ThemeFont const& aMinor) { maMinorComplex = aMinor; } + + ThemeFont const& getMajorLatin() const { return maMajorLatin; } + void setMajorLatin(ThemeFont const& aMajor) { maMajorLatin = aMajor; } + + ThemeFont const& getMajorAsian() const { return maMajorAsian; } + void setMajorAsian(ThemeFont const& aMajor) { maMajorAsian = aMajor; } + + ThemeFont const& getMajorComplex() const { return maMajorComplex; } + void setMajorComplex(ThemeFont const& aMajor) { maMajorComplex = aMajor; } + + OUString findMinorSupplementalTypeface(std::u16string_view rScript) const + { + for (auto const& rSupplementalFont : maMinorSupplementalFontList) + { + if (rSupplementalFont.maScript == rScript) + return rSupplementalFont.maTypeface; + } + return OUString(); + } + + std::vector<ThemeSupplementalFont> const& getMinorSupplementalFontList() const + { + return maMinorSupplementalFontList; + } + void setMinorSupplementalFontList(std::vector<ThemeSupplementalFont> const& rSupplementalFont) + { + maMinorSupplementalFontList = rSupplementalFont; + } + + OUString findMajorSupplementalTypeface(std::u16string_view rScript) const + { + for (auto const& rSupplementalFont : maMajorSupplementalFontList) + { + if (rSupplementalFont.maScript == rScript) + return rSupplementalFont.maTypeface; + } + return OUString(); + } + + std::vector<ThemeSupplementalFont> const& getMajorSupplementalFontList() const + { + return maMajorSupplementalFontList; + } + + void setMajorSupplementalFontList(std::vector<ThemeSupplementalFont> const& rSupplementalFont) + { + maMajorSupplementalFontList = rSupplementalFont; + } +}; + +/// A named theme has a named color set. +class DOCMODEL_DLLPUBLIC Theme +{ +private: + OUString maName; + std::unique_ptr<model::ColorSet> mpColorSet; + + FontScheme maFontScheme; + +public: + Theme(OUString const& rName); + + void setFontScheme(FontScheme const& rFontScheme) { maFontScheme = rFontScheme; } + + FontScheme const& getFontScheme() const { return maFontScheme; } + + void SetColorSet(std::unique_ptr<ColorSet> pColorSet); + const ColorSet* GetColorSet() const; + ColorSet* GetColorSet(); + + void SetName(const OUString& rName); + const OUString& GetName() const; + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + void ToAny(css::uno::Any& rVal) const; + + static std::unique_ptr<Theme> FromAny(const css::uno::Any& rVal); + + std::vector<Color> GetColors() const; + + Color GetColor(model::ThemeColorType eType) const; +}; + +} // end of namespace model + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx index ebd05957bf3b..a779472b5331 100644 --- a/include/oox/drawingml/theme.hxx +++ b/include/oox/drawingml/theme.hxx @@ -35,7 +35,7 @@ namespace com::sun::star { namespace drawing { class XDrawPage; } namespace xml::dom { class XDocument; } } -namespace svx { +namespace model { class Theme; } @@ -107,7 +107,7 @@ 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; } - std::unique_ptr<svx::Theme> createSvxTheme() const; + std::unique_ptr<model::Theme> createSvxTheme() const; void addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage) const; private: diff --git a/include/oox/export/ThemeExport.hxx b/include/oox/export/ThemeExport.hxx index 02f222cadafe..69f048afbaa0 100644 --- a/include/oox/export/ThemeExport.hxx +++ b/include/oox/export/ThemeExport.hxx @@ -12,7 +12,7 @@ #include <sal/config.h> #include <oox/dllapi.h> #include <oox/core/xmlfilterbase.hxx> -#include <svx/ColorSets.hxx> +#include <docmodel/theme/Theme.hxx> namespace oox { @@ -24,12 +24,12 @@ private: public: ThemeExport(oox::core::XmlFilterBase* pFilterBase); - void write(OUString const& rPath, svx::Theme const& rTheme); + void write(OUString const& rPath, model::Theme const& rTheme); private: - static bool writeColorSet(sax_fastparser::FSHelperPtr pFS, svx::Theme const& rTheme); + static bool writeColorSet(sax_fastparser::FSHelperPtr pFS, model::Theme const& rTheme); static bool writeFontScheme(sax_fastparser::FSHelperPtr pFS, - svx::FontScheme const& rFontScheme); + model::FontScheme const& rFontScheme); static bool writeFormatScheme(sax_fastparser::FSHelperPtr pFS); }; diff --git a/include/svx/ColorSets.hxx b/include/svx/ColorSets.hxx index b06dbea0694e..faec6d2c2249 100644 --- a/include/svx/ColorSets.hxx +++ b/include/svx/ColorSets.hxx @@ -11,19 +11,10 @@ #ifndef INCLUDED_SVX_COLORSETS_HXX #define INCLUDED_SVX_COLORSETS_HXX -#include <array> -#include <vector> - #include <rtl/ustring.hxx> #include <sal/log.hxx> -#include <sal/types.h> #include <svx/svxdllapi.h> -#include <docmodel/theme/ThemeColor.hxx> #include <docmodel/theme/ColorSet.hxx> -#include <tools/color.hxx> - -typedef struct _xmlTextWriter* xmlTextWriterPtr; -class SdrPage; namespace svx { @@ -51,183 +42,6 @@ public: void insert(model::ColorSet const& rColorSet); }; -struct SVXCORE_DLLPUBLIC ThemeSupplementalFont -{ - OUString maScript; - OUString maTypeface; -}; - -struct SVXCORE_DLLPUBLIC ThemeFont -{ - OUString maTypeface; - OUString maPanose; - sal_Int16 maPitch = 0; - sal_Int16 maFamily = 0; - sal_Int32 maCharset = 0; - - sal_Int16 getPitchFamily() const - { - return (maPitch & 0x0F) | (maFamily & 0x0F) << 4; - } -}; - -class SVXCORE_DLLPUBLIC FontScheme -{ -private: - OUString maName; - - ThemeFont maMinorLatin; - ThemeFont maMinorAsian; - ThemeFont maMinorComplex; - - ThemeFont maMajorLatin; - ThemeFont maMajorAsian; - ThemeFont maMajorComplex; - - std::vector<ThemeSupplementalFont> maMinorSupplementalFontList; - std::vector<ThemeSupplementalFont> maMajorSupplementalFontList; - -public: - FontScheme() = default; - FontScheme(OUString const& rName) - : maName(rName) - {} - - const OUString& getName() const - { - return maName; - } - - ThemeFont const& getMinorLatin() const - { - return maMinorLatin; - } - void setMinorLatin(ThemeFont const& aMinor) - { - maMinorLatin = aMinor; - } - - ThemeFont const& getMinorAsian() const - { - return maMinorAsian; - } - void setMinorAsian(ThemeFont const& aMinor) - { - maMinorAsian = aMinor; - } - - ThemeFont const& getMinorComplex() const - { - return maMinorComplex; - } - void setMinorComplex(ThemeFont const& aMinor) - { - maMinorComplex = aMinor; - } - - ThemeFont const& getMajorLatin() const - { - return maMajorLatin; - } - void setMajorLatin(ThemeFont const& aMajor) - { - maMajorLatin = aMajor; - } - - ThemeFont const& getMajorAsian() const - { - return maMajorAsian; - } - void setMajorAsian(ThemeFont const& aMajor) - { - maMajorAsian = aMajor; - } - - ThemeFont const& getMajorComplex() const - { - return maMajorComplex; - } - void setMajorComplex(ThemeFont const& aMajor) - { - maMajorComplex = aMajor; - } - - OUString findMinorSupplementalTypeface(std::u16string_view rScript) const - { - for (auto const& rSupplementalFont : maMinorSupplementalFontList) - { - if (rSupplementalFont.maScript == rScript) - return rSupplementalFont.maTypeface; - } - return OUString(); - } - - std::vector<ThemeSupplementalFont> const& getMinorSupplementalFontList() const - { - return maMinorSupplementalFontList; - } - void setMinorSupplementalFontList(std::vector<ThemeSupplementalFont> const& rSupplementalFont) - { - maMinorSupplementalFontList = rSupplementalFont; - } - - OUString findMajorSupplementalTypeface(std::u16string_view rScript) const - { - for (auto const& rSupplementalFont : maMajorSupplementalFontList) - { - if (rSupplementalFont.maScript == rScript) - return rSupplementalFont.maTypeface; - } - return OUString(); - } - - std::vector<ThemeSupplementalFont> const& getMajorSupplementalFontList() const - { - return maMajorSupplementalFontList; - } - void setMajorSupplementalFontList(std::vector<ThemeSupplementalFont> const& rSupplementalFont) - { - maMajorSupplementalFontList = rSupplementalFont; - } -}; - -/// A named theme has a named color set. -class SVXCORE_DLLPUBLIC Theme -{ -private: - OUString maName; - std::unique_ptr<model::ColorSet> mpColorSet; - - FontScheme maFontScheme; - -public: - Theme(OUString const& rName); - - void setFontScheme(FontScheme const& rFontScheme) - { - maFontScheme = rFontScheme; - } - - FontScheme const& getFontScheme() const { return maFontScheme; } - - void SetColorSet(std::unique_ptr<model::ColorSet> pColorSet); - const model::ColorSet* GetColorSet() const; - model::ColorSet* GetColorSet(); - - void SetName(const OUString& rName); - const OUString& GetName() const; - - void dumpAsXml(xmlTextWriterPtr pWriter) const; - - void ToAny(css::uno::Any& rVal) const; - - static std::unique_ptr<Theme> FromAny(const css::uno::Any& rVal); - - std::vector<Color> GetColors() const; - - Color GetColor(model::ThemeColorType eType) const; -}; - } // end of namespace svx #endif // INCLUDED_SVX_COLORSETS_HXX diff --git a/include/svx/dialog/ThemeDialog.hxx b/include/svx/dialog/ThemeDialog.hxx index 968c54af9e98..1db4f2f43e6a 100644 --- a/include/svx/dialog/ThemeDialog.hxx +++ b/include/svx/dialog/ThemeDialog.hxx @@ -11,6 +11,7 @@ #include <svx/svxdllapi.h> #include <vcl/weld.hxx> +#include <docmodel/theme/Theme.hxx> #include <svx/ColorSets.hxx> #include <svx/svdpage.hxx> #include <svx/theme/IThemeColorChanger.hxx> @@ -21,7 +22,7 @@ namespace svx class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController { private: - svx::Theme* mpTheme; + model::Theme* mpTheme; svx::ColorSets maColorSets; std::shared_ptr<IThemeColorChanger> mpChanger; @@ -29,7 +30,7 @@ private: std::unique_ptr<weld::CustomWeld> mxValueSetThemeColorsWindow; public: - ThemeDialog(weld::Window* pParent, svx::Theme* pTheme, + ThemeDialog(weld::Window* pParent, model::Theme* pTheme, std::shared_ptr<IThemeColorChanger> const& pChanger); virtual ~ThemeDialog() override; diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index b5d93fa53eb7..3eac3de05489 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -90,7 +90,7 @@ namespace com::sun::star::beans { struct PropertyValue; } -namespace svx +namespace model { class Theme; } @@ -542,8 +542,8 @@ public: SfxStyleSheetBasePool* GetStyleSheetPool() const { return mxStyleSheetPool.get(); } void SetStyleSheetPool(SfxStyleSheetBasePool* pPool) { mxStyleSheetPool=pPool; } - void SetTheme(std::unique_ptr<svx::Theme> pTheme); - svx::Theme* GetTheme(); + void SetTheme(std::unique_ptr<model::Theme> pTheme); + model::Theme* GetTheme(); void SetStarDrawPreviewMode(bool bPreview); bool IsStarDrawPreviewMode() const { return m_bStarDrawPreviewMode; } diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index 5b6a1a434da0..186a49a028f8 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -30,7 +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 <docmodel/theme/Theme.hxx> #include <unotools/weakref.hxx> #include <memory> #include <optional> @@ -317,7 +317,7 @@ private: // data SdrPage* mpSdrPage; SfxStyleSheet* mpStyleSheet; - std::unique_ptr<svx::Theme> mpTheme; + std::unique_ptr<model::Theme> mpTheme; SfxItemSet maProperties; // internal helpers @@ -346,8 +346,8 @@ public: void SetStyleSheet(SfxStyleSheet* pStyleSheet); SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;} - void SetTheme(std::unique_ptr<svx::Theme> pTheme); - svx::Theme* GetTheme(); + void SetTheme(std::unique_ptr<model::Theme> pTheme); + model::Theme* GetTheme(); void dumpAsXml(xmlTextWriterPtr pWriter) const; }; diff --git a/oox/inc/drawingml/textfont.hxx b/oox/inc/drawingml/textfont.hxx index 3847ed8c61be..1c6da232d443 100644 --- a/oox/inc/drawingml/textfont.hxx +++ b/oox/inc/drawingml/textfont.hxx @@ -24,7 +24,7 @@ namespace oox { class AttributeList; } namespace oox::core { class XmlFilterBase; } -namespace svx { struct ThemeFont; } +namespace model { struct ThemeFont; } namespace oox::drawingml { @@ -52,7 +52,7 @@ public: sal_Int16& rnFontFamily, const ::oox::core::XmlFilterBase& rFilter ) const; - void fillThemeFont(svx::ThemeFont& rThemeFont) const; + void fillThemeFont(model::ThemeFont& rThemeFont) const; static void resolvePitch(sal_Int32 nOoxPitch, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily); diff --git a/oox/source/drawingml/textfont.cxx b/oox/source/drawingml/textfont.cxx index c531ef7ffba6..1ac57258a7da 100644 --- a/oox/source/drawingml/textfont.cxx +++ b/oox/source/drawingml/textfont.cxx @@ -24,7 +24,7 @@ #include <oox/core/xmlfilterbase.hxx> #include <oox/helper/attributelist.hxx> #include <oox/token/tokens.hxx> -#include <svx/ColorSets.hxx> +#include <docmodel/theme/Theme.hxx> using ::oox::core::XmlFilterBase; @@ -91,7 +91,7 @@ bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal return !rFontName.isEmpty(); } -void TextFont::fillThemeFont(svx::ThemeFont& rThemeFont) const +void TextFont::fillThemeFont(model::ThemeFont& rThemeFont) const { rThemeFont.maTypeface = maTypeface; rThemeFont.maPanose = maPanose; diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx index 78471490f35a..f4ebe63e00e2 100644 --- a/oox/source/drawingml/theme.cxx +++ b/oox/source/drawingml/theme.cxx @@ -27,8 +27,8 @@ #include <sal/log.hxx> #include <svx/unopage.hxx> #include <svx/svdpage.hxx> -#include <svx/ColorSets.hxx> #include <docmodel/theme/ColorSet.hxx> +#include <docmodel/theme/Theme.hxx> #include <svx/unoapi.hxx> using namespace com::sun::star; @@ -109,61 +109,61 @@ const TextFont* Theme::resolveFont( std::u16string_view rName ) const return nullptr; } -std::unique_ptr<svx::Theme> Theme::createSvxTheme() const +std::unique_ptr<model::Theme> Theme::createSvxTheme() const { - auto pTheme = std::make_unique<svx::Theme>(maThemeName); + auto pTheme = std::make_unique<model::Theme>(maThemeName); auto pColorSet = std::make_unique<model::ColorSet>(maClrScheme.GetName()); maClrScheme.fill(*pColorSet); pTheme->SetColorSet(std::move(pColorSet)); - svx::FontScheme aFontScheme(maFontSchemeName); + model::FontScheme aFontScheme(maFontSchemeName); if (auto* pCharProps = getFontStyle(XML_minor)) { - svx::ThemeFont aMinorLatin; + model::ThemeFont aMinorLatin; pCharProps->maLatinFont.fillThemeFont(aMinorLatin); aFontScheme.setMinorLatin(aMinorLatin); - svx::ThemeFont aMinorAsian; + model::ThemeFont aMinorAsian; pCharProps->maAsianFont.fillThemeFont(aMinorAsian); aFontScheme.setMinorAsian(aMinorAsian); - svx::ThemeFont aMinorComplex; + model::ThemeFont aMinorComplex; pCharProps->maComplexFont.fillThemeFont(aMinorComplex); aFontScheme.setMinorComplex(aMinorComplex); } if (auto* pCharProps = getFontStyle(XML_major)) { - svx::ThemeFont aMajorLatin; + model::ThemeFont aMajorLatin; pCharProps->maLatinFont.fillThemeFont(aMajorLatin); aFontScheme.setMajorLatin(aMajorLatin); - svx::ThemeFont aMajorAsian; + model::ThemeFont aMajorAsian; pCharProps->maAsianFont.fillThemeFont(aMajorAsian); aFontScheme.setMajorAsian(aMajorAsian); - svx::ThemeFont aMajorComplex; + model::ThemeFont aMajorComplex; pCharProps->maComplexFont.fillThemeFont(aMajorComplex); aFontScheme.setMajorComplex(aMajorComplex); } if (maSupplementalFontMap.find(XML_minor) != maSupplementalFontMap.cend()) { - std::vector<svx::ThemeSupplementalFont> aList; + std::vector<model::ThemeSupplementalFont> aList; for (auto const& [rScript, rTypeface] : maSupplementalFontMap.at(XML_minor)) { - aList.push_back(svx::ThemeSupplementalFont{rScript, rTypeface}); + aList.push_back(model::ThemeSupplementalFont{rScript, rTypeface}); } aFontScheme.setMinorSupplementalFontList(aList); } if (maSupplementalFontMap.find(XML_major) != maSupplementalFontMap.cend()) { - std::vector<svx::ThemeSupplementalFont> aList; + std::vector<model::ThemeSupplementalFont> aList; for (auto const& [rScript, rTypeface] : maSupplementalFontMap.at(XML_major)) { - aList.push_back(svx::ThemeSupplementalFont{rScript, rTypeface}); + aList.push_back(model::ThemeSupplementalFont{rScript, rTypeface}); } aFontScheme.setMajorSupplementalFontList(aList); } @@ -184,7 +184,7 @@ void Theme::addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPa if (!pPage) return; - std::unique_ptr<svx::Theme> pTheme = createSvxTheme(); + std::unique_ptr<model::Theme> pTheme = createSvxTheme(); pPage->getSdrPageProperties().SetTheme(std::move(pTheme)); } diff --git a/oox/source/export/ThemeExport.cxx b/oox/source/export/ThemeExport.cxx index 0f1b8eb919b8..6733a70b2057 100644 --- a/oox/source/export/ThemeExport.cxx +++ b/oox/source/export/ThemeExport.cxx @@ -25,7 +25,7 @@ ThemeExport::ThemeExport(oox::core::XmlFilterBase* pFilterBase) { } -void ThemeExport::write(OUString const& rPath, svx::Theme const& rTheme) +void ThemeExport::write(OUString const& rPath, model::Theme const& rTheme) { sax_fastparser::FSHelperPtr pFS = mpFilterBase->openFragmentStreamWithSerializer( rPath, "application/vnd.openxmlformats-officedocument.theme+xml"); @@ -43,7 +43,7 @@ void ThemeExport::write(OUString const& rPath, svx::Theme const& rTheme) writeColorSet(pFS, rTheme); pFS->endElementNS(XML_a, XML_clrScheme); - svx::FontScheme const& rFontScheme = rTheme.getFontScheme(); + model::FontScheme const& rFontScheme = rTheme.getFontScheme(); pFS->startElementNS(XML_a, XML_fontScheme, XML_name, rFontScheme.getName()); writeFontScheme(pFS, rFontScheme); pFS->endElementNS(XML_a, XML_fontScheme); @@ -61,7 +61,7 @@ void ThemeExport::write(OUString const& rPath, svx::Theme const& rTheme) namespace { void fillAttrList(rtl::Reference<sax_fastparser::FastAttributeList> const& pAttrList, - svx::ThemeFont const& rThemeFont) + model::ThemeFont const& rThemeFont) { pAttrList->add(XML_typeface, rThemeFont.maTypeface); pAttrList->add(XML_panose, rThemeFont.maPanose); @@ -72,7 +72,7 @@ void fillAttrList(rtl::Reference<sax_fastparser::FastAttributeList> const& pAttr } // end anonymous ns bool ThemeExport::writeFontScheme(sax_fastparser::FSHelperPtr pFS, - svx::FontScheme const& rFontScheme) + model::FontScheme const& rFontScheme) { pFS->startElementNS(XML_a, XML_majorFont); @@ -222,7 +222,7 @@ bool ThemeExport::writeFormatScheme(sax_fastparser::FSHelperPtr pFS) return true; } -bool ThemeExport::writeColorSet(sax_fastparser::FSHelperPtr pFS, svx::Theme const& rTheme) +bool ThemeExport::writeColorSet(sax_fastparser::FSHelperPtr pFS, model::Theme const& rTheme) { static std::unordered_map<sal_Int32, model::ThemeColorType> constTokenMap = { { XML_dk1, model::ThemeColorType::Dark1 }, diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx index 5ee3248ec81e..48c928d60abb 100644 --- a/sd/source/filter/eppt/epptooxml.hxx +++ b/sd/source/filter/eppt/epptooxml.hxx @@ -26,7 +26,7 @@ using ::sax_fastparser::FSHelperPtr; -namespace svx +namespace model { class Theme; } @@ -92,13 +92,13 @@ private: void ImplWritePPTXLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum ); /// Export the color set part of a theme. - static bool WriteColorSets(const FSHelperPtr& pFS, svx::Theme* pTheme); + static bool WriteColorSets(const FSHelperPtr& pFS, model::Theme* pTheme); /// Same as WriteColorSets(), but works from a grab-bag. bool WriteColorSchemes(const FSHelperPtr& pFS, const OUString& rThemePath); static void WriteDefaultColorSchemes(const FSHelperPtr& pFS); - void WriteTheme( sal_Int32 nThemeNum, svx::Theme* pTheme ); + void WriteTheme( sal_Int32 nThemeNum, model::Theme* pTheme ); virtual bool ImplCreateDocument() override; virtual bool ImplCreateMainNotes() override; diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 23eaeba53715..16208f48fb79 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -1508,7 +1508,7 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"); SdrPage* pMasterPage = SdPage::getImplementation(mXDrawPage); - svx::Theme* pTheme = nullptr; + model::Theme* pTheme = nullptr; if (pMasterPage) { pTheme = pMasterPage->getSdrPageProperties().GetTheme(); @@ -2153,7 +2153,7 @@ void PowerPointExport::WriteDefaultColorSchemes(const FSHelperPtr& pFS) } } -bool PowerPointExport::WriteColorSets(const FSHelperPtr& pFS, svx::Theme* pTheme) +bool PowerPointExport::WriteColorSets(const FSHelperPtr& pFS, model::Theme* pTheme) { static std::map<PredefinedClrSchemeId, sal_Int32> aPredefinedClrTokens = { @@ -2251,7 +2251,7 @@ bool PowerPointExport::WriteColorSchemes(const FSHelperPtr& pFS, const OUString& return false; } -void PowerPointExport::WriteTheme(sal_Int32 nThemeNum, svx::Theme* pTheme) +void PowerPointExport::WriteTheme(sal_Int32 nThemeNum, model::Theme* pTheme) { OUString sThemePath = "ppt/theme/theme" + OUString::number(nThemeNum + 1) + ".xml"; diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx index d837092eba68..4237aa8af7af 100644 --- a/sd/source/ui/docshell/docshell.cxx +++ b/sd/source/ui/docshell/docshell.cxx @@ -494,7 +494,7 @@ std::vector<Color> DrawDocShell::GetThemeColors() } SdPage* pPage = pViewShell->getCurrentPage(); - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (!pPage->IsMasterPage()) { pTheme = pPage->TRG_GetMasterPage().getSdrPageProperties().GetTheme(); diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx index e7f0bb3a67bb..ea8443d9183b 100644 --- a/sd/source/ui/func/fuconstr.cxx +++ b/sd/source/ui/func/fuconstr.cxx @@ -379,7 +379,7 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj, pThemePage = &pThemePage->TRG_GetMasterPage(); } - svx::Theme* pTheme = pThemePage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pThemePage->getSdrPageProperties().GetTheme(); if (pTheme) { // We construct an object on a page where the master page has a theme. Take the diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index 098295758b40..edb242ab1a6e 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -265,7 +265,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest& if (mpDoc->GetDocumentType() == DocumentType::Impress && mpPage->IsMasterPage()) { // A master slide may have a theme. - svx::Theme* pTheme = mpPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = mpPage->getSdrPageProperties().GetTheme(); if (pTheme) { uno::Any aTheme; @@ -573,7 +573,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs ) auto it = pGrabBag->GetGrabBag().find("Theme"); if (it != pGrabBag->GetGrabBag().end()) { - std::unique_ptr<svx::Theme> pTheme = svx::Theme::FromAny(it->second); + std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(it->second); pMasterPage->getSdrPageProperties().SetTheme(std::move(pTheme)); } else diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index d68c4cf4a2f8..9b9ed18dbfc6 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -1281,7 +1281,7 @@ void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyNam case WID_MODEL_THEME: { SdrModel& rModel = getSdrModelFromUnoModel(); - std::unique_ptr<svx::Theme> pTheme = svx::Theme::FromAny(aValue); + std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue); rModel.SetTheme(std::move(pTheme)); } break; @@ -1408,7 +1408,7 @@ uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& Property case WID_MODEL_THEME: { SdrModel& rModel = getSdrModelFromUnoModel(); - svx::Theme* pTheme = rModel.GetTheme(); + model::Theme* pTheme = rModel.GetTheme(); if (pTheme) { pTheme->ToAny(aAny); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index dda5cb3baea0..2dfff467ceb7 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -976,7 +976,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName case WID_PAGE_THEME: { SdrPage* pPage = GetPage(); - std::unique_ptr<svx::Theme> pTheme = svx::Theme::FromAny(aValue); + std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue); pPage->getSdrPageProperties().SetTheme(std::move(pTheme)); break; } @@ -1298,7 +1298,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) case WID_PAGE_THEME: { SdrPage* pPage = GetPage(); - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (pTheme) { pTheme->ToAny(aAny); diff --git a/svx/qa/unit/ThemeTest.cxx b/svx/qa/unit/ThemeTest.cxx index 757561b1bd17..c3aeb93b0217 100644 --- a/svx/qa/unit/ThemeTest.cxx +++ b/svx/qa/unit/ThemeTest.cxx @@ -14,7 +14,7 @@ #include <config_features.h> -#include <svx/ColorSets.hxx> +#include <docmodel/theme/Theme.hxx> namespace { @@ -24,7 +24,7 @@ class ThemeTest : public CppUnit::TestFixture CPPUNIT_TEST_FIXTURE(ThemeTest, testPitchFamilyConversion) { - svx::ThemeFont aFont; + model::ThemeFont aFont; aFont.maPitch = 2; aFont.maFamily = 1; diff --git a/svx/source/dialog/ThemeDialog.cxx b/svx/source/dialog/ThemeDialog.cxx index ff078650d8e4..842a40203efa 100644 --- a/svx/source/dialog/ThemeDialog.cxx +++ b/svx/source/dialog/ThemeDialog.cxx @@ -10,11 +10,12 @@ #include <svx/dialog/ThemeDialog.hxx> #include <docmodel/theme/ThemeColor.hxx> #include <docmodel/theme/ColorSet.hxx> +#include <docmodel/theme/Theme.hxx> #include <vcl/svapp.hxx> namespace svx { -ThemeDialog::ThemeDialog(weld::Window* pParent, svx::Theme* pTheme, +ThemeDialog::ThemeDialog(weld::Window* pParent, model::Theme* pTheme, std::shared_ptr<IThemeColorChanger> const& pChanger) : GenericDialogController(pParent, "svx/ui/themedialog.ui", "ThemeDialog") , mpTheme(pTheme) diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 23adaf3281a1..145babb7d98d 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -11,18 +11,7 @@ #include <svx/ColorSets.hxx> #include <utility> - -#include <libxml/xmlwriter.h> -#include <comphelper/sequenceashashmap.hxx> -#include <comphelper/sequence.hxx> -#include <sal/log.hxx> -#include <svx/svdpage.hxx> -#include <svx/svditer.hxx> -#include <editeng/unoprnms.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> #include <docmodel/theme/ColorSet.hxx> -#include <o3tl/enumrange.hxx> -#include <com/sun/star/util/Color.hpp> using namespace com::sun::star; @@ -166,131 +155,6 @@ void ColorSets::insert(model::ColorSet const& rColorSet) maColorSets.push_back(rColorSet); } -Theme::Theme(OUString const& rName) - : maName(rName) -{ -} - -void Theme::SetColorSet(std::unique_ptr<model::ColorSet> pColorSet) { mpColorSet = std::move(pColorSet); } - -const model::ColorSet* Theme::GetColorSet() const { return mpColorSet.get(); } - -model::ColorSet* Theme::GetColorSet() { return mpColorSet.get(); } - -void Theme::SetName(const OUString& rName) { maName = rName; } - -const OUString& Theme::GetName() const { return maName; } - -void Theme::dumpAsXml(xmlTextWriterPtr pWriter) const -{ - (void)xmlTextWriterStartElement(pWriter, BAD_CAST("Theme")); - (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maName"), - BAD_CAST(maName.toUtf8().getStr())); - - if (mpColorSet) - { - mpColorSet->dumpAsXml(pWriter); - } - - (void)xmlTextWriterEndElement(pWriter); -} - -void Theme::ToAny(css::uno::Any& rVal) const -{ - comphelper::SequenceAsHashMap aMap; - aMap["Name"] <<= maName; - - if (mpColorSet) - { - std::vector<util::Color> aColorScheme; - for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) - { - if (eThemeColorType != model::ThemeColorType::Unknown) - { - Color aColor = mpColorSet->getColor(eThemeColorType); - aColorScheme.push_back(sal_Int32(aColor)); - } - } - - aMap["ColorSchemeName"] <<= mpColorSet->getName(); - aMap["ColorScheme"] <<= comphelper::containerToSequence(aColorScheme); - } - - rVal <<= aMap.getAsConstPropertyValueList(); -} - -std::unique_ptr<Theme> Theme::FromAny(const css::uno::Any& rVal) -{ - comphelper::SequenceAsHashMap aMap(rVal); - std::unique_ptr<Theme> pTheme; - model::ColorSet* pColorSet = nullptr; - - auto it = aMap.find("Name"); - if (it != aMap.end()) - { - OUString aName; - it->second >>= aName; - pTheme = std::make_unique<Theme>(aName); - } - - it = aMap.find("ColorSchemeName"); - if (it != aMap.end() && pTheme) - { - OUString aName; - it->second >>= aName; - auto pSet = std::make_unique<model::ColorSet>(aName); - pTheme->SetColorSet(std::move(pSet)); - pColorSet = pTheme->GetColorSet(); - } - - it = aMap.find("ColorScheme"); - if (it != aMap.end() && pColorSet) - { - uno::Sequence<util::Color> aColors; - it->second >>= aColors; - - SAL_WARN_IF(aColors.size() > 12, "svx", "Theme::FromAny: number of colors greater than max theme colors supported"); - - for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) - { - if (eThemeColorType != model::ThemeColorType::Unknown) - { - size_t nIndex(static_cast<sal_Int16>(eThemeColorType)); - if (nIndex < aColors.size()) - { - Color aColor(ColorTransparency, aColors[nIndex]); - pColorSet->add(eThemeColorType, aColor); - } - } - } - } - - return pTheme; -} - -std::vector<Color> Theme::GetColors() const -{ - if (!mpColorSet) - return {}; - - std::vector<Color> aColors; - for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) - { - if (eThemeColorType != model::ThemeColorType::Unknown) - aColors.push_back(mpColorSet->getColor(eThemeColorType)); - } - return aColors; -} - -Color Theme::GetColor(model::ThemeColorType eType) const -{ - if (!mpColorSet) - return {}; - - return mpColorSet->getColor(eType); -} - } // end of namespace svx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index bc86671c9437..28ec1e556f23 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -71,7 +71,7 @@ #include <o3tl/enumrange.hxx> #include <comphelper/diagnose_ex.hxx> #include <tools/UnitConversion.hxx> -#include <svx/ColorSets.hxx> +#include <docmodel/theme/Theme.hxx> #include <svx/svditer.hxx> #include <svx/svdoashp.hxx> @@ -84,7 +84,7 @@ struct SdrModelImpl SdrUndoFactory* mpUndoFactory; bool mbAnchoredTextOverflowLegacy; // tdf#99729 compatibility flag bool mbLegacySingleLineFontwork; // tdf#148000 compatibility flag - std::unique_ptr<svx::Theme> mpTheme; + std::unique_ptr<model::Theme> mpTheme; SdrModelImpl() : mpUndoManager(nullptr) @@ -1570,9 +1570,9 @@ void SdrModel::SetStarDrawPreviewMode(bool bPreview) } } -void SdrModel::SetTheme(std::unique_ptr<svx::Theme> pTheme) { mpImpl->mpTheme = std::move(pTheme); } +void SdrModel::SetTheme(std::unique_ptr<model::Theme> pTheme) { mpImpl->mpTheme = std::move(pTheme); } -svx::Theme* SdrModel::GetTheme() { return mpImpl->mpTheme.get(); } +model::Theme* SdrModel::GetTheme() { return mpImpl->mpTheme.get(); } uno::Reference< uno::XInterface > const & SdrModel::getUnoModel() { diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 7ec883e397c5..cb2fb64e7e80 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1288,7 +1288,7 @@ void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet) ImpPageChange(*mpSdrPage); } -void SdrPageProperties::SetTheme(std::unique_ptr<svx::Theme> pTheme) +void SdrPageProperties::SetTheme(std::unique_ptr<model::Theme> pTheme) { mpTheme = std::move(pTheme); @@ -1310,7 +1310,7 @@ void SdrPageProperties::SetTheme(std::unique_ptr<svx::Theme> pTheme) } } -svx::Theme* SdrPageProperties::GetTheme() { return mpTheme.get(); } +model::Theme* SdrPageProperties::GetTheme() { return mpTheme.get(); } void SdrPageProperties::dumpAsXml(xmlTextWriterPtr pWriter) const { diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx index 412482e3f471..8f12e8bdacbd 100644 --- a/sw/qa/core/theme/ThemeTest.cxx +++ b/sw/qa/core/theme/ThemeTest.cxx @@ -49,7 +49,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testDrawPageThemeExists) CPPUNIT_ASSERT(pDoc); SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); CPPUNIT_ASSERT(pTheme); CPPUNIT_ASSERT_EQUAL(OUString(u"Office Theme"), pTheme->GetName()); @@ -68,7 +68,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testDrawPageThemeExists) CPPUNIT_ASSERT_EQUAL(Color(0xFFFFFF), pTheme->GetColor(model::ThemeColorType::Light1)); CPPUNIT_ASSERT_EQUAL(Color(0xCCDDEA), pTheme->GetColor(model::ThemeColorType::Light2)); - svx::FontScheme const& rFontScheme = pTheme->getFontScheme(); + model::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()); diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index 715c02e68b63..589ca7e8cc17 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -151,14 +151,14 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) pDocument->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (pTheme) { pTheme->SetColorSet(std::make_unique<model::ColorSet>(rColorSet)); } else { - pPage->getSdrPageProperties().SetTheme(std::make_unique<svx::Theme>("Office")); + pPage->getSdrPageProperties().SetTheme(std::make_unique<model::Theme>("Office")); pTheme = pPage->getSdrPageProperties().GetTheme(); pTheme->SetColorSet(std::make_unique<model::ColorSet>(rColorSet)); } diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx index f3c4ca04ddfd..4392158ebccd 100644 --- a/sw/source/filter/xml/xmlfmte.cxx +++ b/sw/source/filter/xml/xmlfmte.cxx @@ -43,10 +43,10 @@ #include <sax/tools/converter.hxx> #include <o3tl/enumrange.hxx> -#include <svx/ColorSets.hxx> #include <svx/unoapi.hxx> #include <svx/svdpage.hxx> #include <docmodel/theme/ThemeColor.hxx> +#include <docmodel/theme/Theme.hxx> using namespace ::com::sun::star::beans; diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index e3cc7b0f6b6e..b11599e576d5 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -81,7 +81,7 @@ #include <SwUndoFmt.hxx> #include <strings.hrc> #include <AccessibilityCheck.hxx> -#include <svx/ColorSets.hxx> +#include <docmodel/theme/Theme.hxx> #include <svx/svdpage.hxx> using namespace ::com::sun::star; @@ -1582,7 +1582,7 @@ std::vector<Color> SwDocShell::GetThemeColors() SdrPage* pPage = m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); if (!pPage) return {}; - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (!pTheme) return {}; return pTheme->GetColors(); diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index eb071c1d4bfb..3fb250b658eb 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -2217,7 +2217,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); if (pPage) { - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (pTheme) bDisable = false; } @@ -3058,7 +3058,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) if (pDocumentShell) { SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (pTheme) { std::shared_ptr<svx::IThemeColorChanger> pChanger(new sw::ThemeColorChanger(pDocumentShell)); diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index d2c225c171c3..6a2647ebbbee 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -18,8 +18,8 @@ #include <ThemeColorChanger.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <docmodel/theme/Theme.hxx> #include <svx/svdpage.hxx> -#include <svx/ColorSets.hxx> #include <svx/dialog/ThemeColorValueSet.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -54,7 +54,7 @@ ThemePanel::ThemePanel(weld::Widget* pParent) if (pDocument) { SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); if (pTheme) maColorSets.insert(*pTheme->GetColorSet()); } diff --git a/writerfilter/source/dmapper/ThemeHandler.cxx b/writerfilter/source/dmapper/ThemeHandler.cxx index 3a7260d89047..fef0cabe1d29 100644 --- a/writerfilter/source/dmapper/ThemeHandler.cxx +++ b/writerfilter/source/dmapper/ThemeHandler.cxx @@ -10,7 +10,7 @@ #include "ThemeHandler.hxx" #include <i18nlangtag/languagetag.hxx> #include <ooxml/resourceids.hxx> -#include <svx/ColorSets.hxx> +#include <docmodel/theme/Theme.hxx> using namespace com::sun::star; @@ -320,7 +320,7 @@ OUString fromLocaleToScriptTag(const OUString& sLocale) return fromLCIDToScriptTag(LanguageTag::convertToLanguageType(sLocale)); } -OUString resolveMajorMinorTypeFace(svx::FontScheme const& rFontSheme, const Id id) +OUString resolveMajorMinorTypeFace(model::FontScheme const& rFontSheme, const Id id) { switch (id) { @@ -346,7 +346,7 @@ OUString resolveMajorMinorTypeFace(svx::FontScheme const& rFontSheme, const Id i return OUString(); } -OUString resolveSupplementalFontList(svx::FontScheme const& rFontSheme, const Id id, +OUString resolveSupplementalFontList(model::FontScheme const& rFontSheme, const Id id, std::u16string_view rLangAsia, std::u16string_view rLangBidi) { switch (id) @@ -409,7 +409,7 @@ OUString ThemeHandler::getStringForTheme(const Id id) OUString ThemeHandler::getFontNameForTheme(const Id id) const { auto pSvxTheme = mpTheme->createSvxTheme(); - svx::FontScheme const& rFontScheme = pSvxTheme->getFontScheme(); + model::FontScheme const& rFontScheme = pSvxTheme->getFontScheme(); OUString aSupplementalTypeFace = resolveSupplementalFontList( rFontScheme, id, maThemeFontLangEastAsia, maThemeFontLangBidi); if (!aSupplementalTypeFace.isEmpty()) diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 7c336989496b..df0c7e45aa27 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2428,7 +2428,7 @@ void SdXMLExport::ExportThemeElement(const uno::Reference<drawing::XDrawPage>& x }; for (size_t nColor = 0; nColor < aColors.size(); ++nColor) { - // Import goes via svx::Theme::FromAny(), which sanitizes user input. + // Import goes via model::Theme::FromAny(), which sanitizes user input. assert(nColor < SAL_N_ELEMENTS(aColorTokens)); AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, GetXMLToken(aColorTokens[nColor]));