summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2021-07-28 02:03:12 +0300
committerMiklos Vajna <vmiklos@collabora.com>2021-11-17 13:26:45 +0100
commit3171d185f8c17799f0b85f5931aa59101cbc6b4e (patch)
tree76bdf97c13114991a08648cc81c02243f90bef0e /svx/source/styles
parenteb515f11caae5d1b30f7c306fc32111a0cf617b2 (diff)
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 <vmiklos@collabora.com>
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/ColorSets.cxx53
1 files changed, 53 insertions, 0 deletions
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: */