From 3171d185f8c17799f0b85f5931aa59101cbc6b4e Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Wed, 28 Jul 2021 02:03:12 +0300 Subject: make colorsets work outside of styles and with direct formatting [ Miklos: picked only the document model bits, now in SdrModel, next to styles. ] (cherry picked from commit 1647d34d8573f4940c0cbb7fb6cd9c6b4e5a4a15, from the feature/themesupport2 branch) Change-Id: I80f9e0b205b8b4a6914f851bdc63e3e0ca6706e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125313 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- svx/source/styles/ColorSets.cxx | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'svx/source/styles') 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 +#include + +#include + 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 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: */ -- cgit