summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-03-01 22:11:14 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-03-05 12:22:02 +0100
commit4ccc2f0e3f45c9d78f74b1848851bedf71f7382d (patch)
tree912e78ae13267d50c3966f1510b55ed4fb082adf /svx
parent4674134d510b89af935492daa3d911b5a086ed01 (diff)
cool#8327 use tools::JsonWriter for theme colors
Change-Id: Iebca3781910f9e28100258da8266d51f673f31d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164250 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164413 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx20
-rw-r--r--svx/source/theme/ThemeColorChangerCommon.cxx8
-rw-r--r--svx/source/theme/ThemeColorPaletteManager.cxx21
3 files changed, 19 insertions, 30 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 0ba97a76ada4..c52dc549f852 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -22,6 +22,7 @@
#include <basegfx/color/bcolortools.hxx>
#include <comphelper/propertyvalue.hxx>
#include <tools/urlobj.hxx>
+#include <tools/json_writer.hxx>
#include <osl/file.hxx>
#include <unotools/pathoptions.hxx>
#include <sfx2/objsh.hxx>
@@ -464,9 +465,9 @@ void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedC
}
// TODO: make it generic, send any palette
-void PaletteManager::generateJSON(boost::property_tree::ptree& aTree, const std::set<Color>& rColors)
+void PaletteManager::generateJSON(tools::JsonWriter& aTree, const std::set<Color>& rColors)
{
- boost::property_tree::ptree aColorListTree;
+ auto aColorListTree = aTree.startArray("DocumentColors");
sal_uInt32 nStartIndex = 1;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
@@ -476,26 +477,21 @@ void PaletteManager::generateJSON(boost::property_tree::ptree& aTree, const std:
auto aColorIt = rColors.begin();
while (aColorIt != rColors.end())
{
- boost::property_tree::ptree aColorRowTree;
+ auto aColorRowTree = aTree.startStruct();
+ auto aColorRowTree2 = aTree.startArray("");
for (sal_uInt32 nColumn = 0; nColumn < nColumnCount; nColumn++)
{
- boost::property_tree::ptree aColorTree;
+ auto aColorTree = aTree.startStruct();
OUString sName = aNamePrefix + OUString::number(nStartIndex++);
- aColorTree.put("Value", aColorIt->AsRGBHexString().toUtf8());
- aColorTree.put("Name", sName);
-
- aColorRowTree.push_back(std::make_pair("", aColorTree));
+ aTree.put("Value", aColorIt->AsRGBHexString().toUtf8());
+ aTree.put("Name", sName);
aColorIt++;
if (aColorIt == rColors.end())
break;
}
-
- aColorListTree.push_back(std::make_pair("", aColorRowTree));
}
-
- aTree.add_child("DocumentColors", aColorListTree);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx b/svx/source/theme/ThemeColorChangerCommon.cxx
index cb4eccd01a25..6c91ac1dfac9 100644
--- a/svx/source/theme/ThemeColorChangerCommon.cxx
+++ b/svx/source/theme/ThemeColorChangerCommon.cxx
@@ -38,6 +38,7 @@
#include <svx/xdef.hxx>
#include <svx/xlnclit.hxx>
#include <svx/xflclit.hxx>
+#include <tools/json_writer.hxx>
using namespace css;
@@ -185,17 +186,14 @@ void notifyLOK(std::shared_ptr<model::ColorSet> const& pColorSet,
if (comphelper::LibreOfficeKit::isActive())
{
svx::ThemeColorPaletteManager aManager(pColorSet);
- std::stringstream aStream;
- boost::property_tree::ptree aTree;
+ tools::JsonWriter aTree;
if (pColorSet)
aManager.generateJSON(aTree);
if (rDocumentColors.size())
PaletteManager::generateJSON(aTree, rDocumentColors);
- boost::property_tree::write_json(aStream, aTree);
-
- SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, OString(aStream.str()));
+ SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, aTree.extractAsOString());
}
}
diff --git a/svx/source/theme/ThemeColorPaletteManager.cxx b/svx/source/theme/ThemeColorPaletteManager.cxx
index a89456576736..5367232b4de4 100644
--- a/svx/source/theme/ThemeColorPaletteManager.cxx
+++ b/svx/source/theme/ThemeColorPaletteManager.cxx
@@ -16,6 +16,7 @@
#include <svx/strings.hrc>
#include <docmodel/theme/ColorSet.hxx>
#include <docmodel/color/ComplexColorJSON.hxx>
+#include <tools/json_writer.hxx>
#include <array>
@@ -126,23 +127,22 @@ svx::ThemePaletteCollection ThemeColorPaletteManager::generate()
return aThemePaletteCollection;
}
-void ThemeColorPaletteManager::generateJSON(boost::property_tree::ptree& aTree)
+void ThemeColorPaletteManager::generateJSON(tools::JsonWriter& aTree)
{
svx::ThemePaletteCollection aThemePaletteCollection = generate();
- boost::property_tree::ptree aColorListTree;
+ auto aColorListTree = aTree.startArray("ThemeColors");
for (size_t nEffect = 0; nEffect < 6; ++nEffect)
{
- boost::property_tree::ptree aColorRowTree;
+ auto aColorRowTree = aTree.startStruct();
for (size_t nIndex = 0; nIndex < 12; ++nIndex)
{
auto const& rColorData = aThemePaletteCollection.maColors[nIndex];
auto const& rEffectData = rColorData.maEffects[nEffect];
- boost::property_tree::ptree aColorTree;
- aColorTree.put("Value", rEffectData.maColor.AsRGBHexString().toUtf8());
- aColorTree.put("Name", rEffectData.maColorName.toUtf8());
+ aTree.put("Value", rEffectData.maColor.AsRGBHexString().toUtf8());
+ aTree.put("Name", rEffectData.maColorName.toUtf8());
model::ComplexColor aComplexColor;
aComplexColor.setThemeColor(rColorData.meThemeColorType);
@@ -150,15 +150,10 @@ void ThemeColorPaletteManager::generateJSON(boost::property_tree::ptree& aTree)
{ model::TransformationType::LumMod, rEffectData.mnLumMod });
aComplexColor.addTransformation(
{ model::TransformationType::LumOff, rEffectData.mnLumOff });
- boost::property_tree::ptree aDataTree;
- model::color::convertToJSONTree(aDataTree, aComplexColor);
- aColorTree.add_child("Data", aDataTree);
- aColorRowTree.push_back(std::make_pair("", aColorTree));
+ auto aDataTree = aTree.startNode("Data");
+ model::color::convertToJSONTree(aTree, aComplexColor);
}
- aColorListTree.push_back(std::make_pair("", aColorRowTree));
}
-
- aTree.add_child("ThemeColors", aColorListTree);
}
} // end svx namespace