diff options
-rw-r--r-- | include/svx/ColorSets.hxx | 23 | ||||
-rw-r--r-- | include/svx/svdmodel.hxx | 7 | ||||
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 53 | ||||
-rw-r--r-- | svx/source/svdraw/svdmodel.cxx | 11 |
4 files changed, 94 insertions, 0 deletions
diff --git a/include/svx/ColorSets.hxx b/include/svx/ColorSets.hxx index 361fe47c622e..eee992da94b5 100644 --- a/include/svx/ColorSets.hxx +++ b/include/svx/ColorSets.hxx @@ -18,6 +18,8 @@ #include <svx/svxdllapi.h> #include <tools/color.hxx> +typedef struct _xmlTextWriter* xmlTextWriterPtr; + namespace svx { @@ -41,6 +43,8 @@ public: { return maColors[nIndex]; } + + void dumpAsXml(xmlTextWriterPtr pWriter) const; }; class SVXCORE_DLLPUBLIC ColorSets @@ -64,6 +68,25 @@ public: const ColorSet& getColorSet(std::u16string_view rName); }; +/// A named theme has a named color set. +class SVXCORE_DLLPUBLIC Theme +{ + OUString maName; + std::unique_ptr<ColorSet> mpColorSet; + +public: + Theme(OUString const& rName); + ~Theme(); + + void SetColorSet(std::unique_ptr<ColorSet> pColorSet); + ColorSet* GetColorSet(); + + void SetName(const OUString& rName); + const OUString& GetName() const; + + void dumpAsXml(xmlTextWriterPtr pWriter) const; +}; + } // end of namespace svx #endif // INCLUDED_SVX_COLORSETS_HXX diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index 73fc9f646f43..ab9578a7bc93 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -90,6 +90,10 @@ namespace com::sun::star::beans { struct PropertyValue; } +namespace svx +{ +class Theme; +} constexpr const sal_Unicode DEGREE_CHAR = u'\x00B0'; /* U+00B0 DEGREE SIGN */ @@ -536,6 +540,9 @@ 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 SetStarDrawPreviewMode(bool bPreview); bool IsStarDrawPreviewMode() const { return m_bStarDrawPreviewMode; } diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 7a04eb4e6314..91a44f1782ea 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -10,6 +10,10 @@ #include <svx/ColorSets.hxx> +#include <sstream> + +#include <libxml/xmlwriter.h> + namespace svx { @@ -21,6 +25,25 @@ ColorSet::ColorSet(OUString const & aColorSetName) ColorSets::ColorSets() {} +void ColorSet::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ColorSet")); + (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maColorSetName"), + BAD_CAST(maColorSetName.toUtf8().getStr())); + + for (const auto& rColor : maColors) + { + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("Color")); + std::stringstream ss; + ss << rColor; + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(ss.str().c_str())); + (void)xmlTextWriterEndElement(pWriter); + } + + (void)xmlTextWriterEndElement(pWriter); +} + ColorSets::~ColorSets() {} @@ -102,6 +125,36 @@ const ColorSet& ColorSets::getColorSet(std::u16string_view rName) return maColorSets[0]; } +Theme::Theme(const OUString& rName) + : maName(rName) +{ +} + +Theme::~Theme() {} + +void Theme::SetColorSet(std::unique_ptr<ColorSet> pColorSet) { mpColorSet = std::move(pColorSet); } + +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); +} + } // 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 0212b99c7232..6dcebf3ef541 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -72,6 +72,7 @@ #include <o3tl/enumrange.hxx> #include <tools/diagnose_ex.h> #include <tools/UnitConversion.hxx> +#include <svx/ColorSets.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -83,6 +84,7 @@ struct SdrModelImpl SfxUndoManager* mpUndoManager; SdrUndoFactory* mpUndoFactory; bool mbAnchoredTextOverflowLegacy; // tdf#99729 compatibility flag + std::unique_ptr<svx::Theme> mpTheme; SdrModelImpl() : mpUndoManager(nullptr) @@ -1571,6 +1573,10 @@ void SdrModel::SetStarDrawPreviewMode(bool bPreview) } } +void SdrModel::SetTheme(std::unique_ptr<svx::Theme> pTheme) { mpImpl->mpTheme = std::move(pTheme); } + +svx::Theme* SdrModel::GetTheme() { return mpImpl->mpTheme.get(); } + uno::Reference< uno::XInterface > const & SdrModel::getUnoModel() { if( !mxUnoModel.is() ) @@ -1875,6 +1881,11 @@ void SdrModel::dumpAsXml(xmlTextWriterPtr pWriter) const pPage->dumpAsXml(pWriter); } + if (mpImpl->mpTheme) + { + mpImpl->mpTheme->dumpAsXml(pWriter); + } + (void)xmlTextWriterEndElement(pWriter); } |