summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/ColorSets.cxx34
1 files changed, 26 insertions, 8 deletions
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index 145babb7d98d..438a9a36b01c 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -19,10 +19,18 @@ namespace svx
{
ColorSets::ColorSets()
-{}
+{
+ init();
+}
+
+ColorSets& ColorSets::get()
+{
+ static std::optional<ColorSets> sColorSet;
+ if (!sColorSet)
+ sColorSet = ColorSets();
+ return *sColorSet;
+}
-ColorSets::~ColorSets()
-{}
void ColorSets::init()
{
@@ -140,19 +148,29 @@ void ColorSets::init()
}
}
-const model::ColorSet& ColorSets::getColorSet(std::u16string_view rName)
+model::ColorSet const* ColorSets::getColorSet(std::u16string_view rName) const
{
for (const model::ColorSet & rColorSet : maColorSets)
{
if (rColorSet.getName() == rName)
- return rColorSet;
+ return &rColorSet;
}
- return maColorSets[0];
+ return nullptr;
}
-void ColorSets::insert(model::ColorSet const& rColorSet)
+void ColorSets::insert(model::ColorSet const& rNewColorSet)
{
- maColorSets.push_back(rColorSet);
+ for (model::ColorSet& rColorSet : maColorSets)
+ {
+ if (rColorSet.getName() == rNewColorSet.getName())
+ {
+ rColorSet = rNewColorSet;
+ return;
+ }
+ }
+
+ // color set not found, so insert it
+ maColorSets.push_back(rNewColorSet);
}
} // end of namespace svx