IdenticalNameAction is unused
insert() is always called with the same value Change-Id: I319864f112097ce7ba3c01687cf0598789005bdb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182205 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
This commit is contained in:
parent
547c67de9f
commit
b9d7ab8dde
@ -24,7 +24,6 @@ private:
|
|||||||
ColorSets();
|
ColorSets();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
enum class IdenticalNameAction { Overwrite, AutoRename };
|
|
||||||
static ColorSets& get();
|
static ColorSets& get();
|
||||||
|
|
||||||
const std::vector<model::ColorSet>& getColorSetVector() const
|
const std::vector<model::ColorSet>& getColorSetVector() const
|
||||||
@ -39,7 +38,7 @@ public:
|
|||||||
|
|
||||||
model::ColorSet const* getColorSet(std::u16string_view rName) const;
|
model::ColorSet const* getColorSet(std::u16string_view rName) const;
|
||||||
|
|
||||||
void insert(model::ColorSet const& rColorSet, IdenticalNameAction eAction);
|
void insert(model::ColorSet const& rColorSet);
|
||||||
void writeToUserFolder(model::ColorSet const& rNewColorSet);
|
void writeToUserFolder(model::ColorSet const& rNewColorSet);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -102,7 +102,7 @@ void ThemeDialog::runThemeColorEditDialog()
|
|||||||
auto aColorSet = mxSubDialog->getColorSet();
|
auto aColorSet = mxSubDialog->getColorSet();
|
||||||
if (!aColorSet.getName().isEmpty())
|
if (!aColorSet.getName().isEmpty())
|
||||||
{
|
{
|
||||||
ColorSets::get().insert(aColorSet, ColorSets::IdenticalNameAction::AutoRename);
|
ColorSets::get().insert(aColorSet);
|
||||||
maColorSets.clear();
|
maColorSets.clear();
|
||||||
mxValueSetThemeColors->Clear();
|
mxValueSetThemeColors->Clear();
|
||||||
|
|
||||||
|
@ -198,36 +198,21 @@ OUString findUniqueName(std::unordered_set<OUString> const& rNames, OUString con
|
|||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
void ColorSets::insert(model::ColorSet const& rNewColorSet, IdenticalNameAction eAction)
|
void ColorSets::insert(model::ColorSet const& rNewColorSet)
|
||||||
{
|
{
|
||||||
if (eAction == IdenticalNameAction::Overwrite)
|
// auto-rename if it already exists
|
||||||
{
|
|
||||||
for (model::ColorSet& rColorSet : maColorSets)
|
|
||||||
{
|
|
||||||
if (rColorSet.getName() == rNewColorSet.getName())
|
|
||||||
{
|
|
||||||
rColorSet = rNewColorSet;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// color set not found, so insert it
|
|
||||||
maColorSets.push_back(rNewColorSet);
|
|
||||||
writeToUserFolder(rNewColorSet);
|
|
||||||
}
|
|
||||||
else if (eAction == IdenticalNameAction::AutoRename)
|
|
||||||
{
|
|
||||||
std::unordered_set<OUString> aNames;
|
|
||||||
for (model::ColorSet& rColorSet : maColorSets)
|
|
||||||
aNames.insert(rColorSet.getName());
|
|
||||||
|
|
||||||
OUString aName = findUniqueName(aNames, rNewColorSet.getName());
|
std::unordered_set<OUString> aNames;
|
||||||
|
for (model::ColorSet& rColorSet : maColorSets)
|
||||||
|
aNames.insert(rColorSet.getName());
|
||||||
|
|
||||||
model::ColorSet aNewColorSet = rNewColorSet;
|
OUString aName = findUniqueName(aNames, rNewColorSet.getName());
|
||||||
aNewColorSet.setName(aName);
|
|
||||||
|
|
||||||
maColorSets.push_back(aNewColorSet);
|
model::ColorSet aNewColorSet = rNewColorSet;
|
||||||
writeToUserFolder(aNewColorSet);
|
aNewColorSet.setName(aName);
|
||||||
}
|
|
||||||
|
maColorSets.push_back(aNewColorSet);
|
||||||
|
writeToUserFolder(aNewColorSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorSets::writeToUserFolder(model::ColorSet const& rNewColorSet)
|
void ColorSets::writeToUserFolder(model::ColorSet const& rNewColorSet)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user