diff options
-rw-r--r-- | docmodel/source/color/ComplexColorJSON.cxx | 19 | ||||
-rw-r--r-- | include/docmodel/color/ComplexColorJSON.hxx | 8 | ||||
-rw-r--r-- | include/svx/PaletteManager.hxx | 3 | ||||
-rw-r--r-- | include/svx/theme/ThemeColorPaletteManager.hxx | 7 | ||||
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 20 | ||||
-rw-r--r-- | svx/source/theme/ThemeColorChangerCommon.cxx | 8 | ||||
-rw-r--r-- | svx/source/theme/ThemeColorPaletteManager.cxx | 21 |
7 files changed, 40 insertions, 46 deletions
diff --git a/docmodel/source/color/ComplexColorJSON.cxx b/docmodel/source/color/ComplexColorJSON.cxx index 7c09a1e8221d..a2a683acfb89 100644 --- a/docmodel/source/color/ComplexColorJSON.cxx +++ b/docmodel/source/color/ComplexColorJSON.cxx @@ -13,6 +13,7 @@ #include <sstream> #include <utility> #include <sal/log.hxx> +#include <tools/json_writer.hxx> namespace model::color { @@ -59,11 +60,11 @@ bool convertFromJSON(OString const& rJsonString, model::ComplexColor& rComplexCo return true; } -void convertToJSONTree(boost::property_tree::ptree& rTree, model::ComplexColor const& rComplexColor) +void convertToJSONTree(tools::JsonWriter& rTree, model::ComplexColor const& rComplexColor) { rTree.put("ThemeIndex", sal_Int16(rComplexColor.getThemeColorType())); + auto aTransformationsList = rTree.startArray("Transformations"); - boost::property_tree::ptree aTransformationsList; for (auto const& rTransformation : rComplexColor.getTransformations()) { std::string aType; @@ -86,22 +87,18 @@ void convertToJSONTree(boost::property_tree::ptree& rTree, model::ComplexColor c } if (!aType.empty()) { - boost::property_tree::ptree aChild; - aChild.put("Type", aType); - aChild.put("Value", rTransformation.mnValue); - aTransformationsList.push_back(std::make_pair("", aChild)); + auto aChild = rTree.startStruct(); + rTree.put("Type", aType); + rTree.put("Value", rTransformation.mnValue); } } - rTree.add_child("Transformations", aTransformationsList); } OString convertToJSON(model::ComplexColor const& rComplexColor) { - boost::property_tree::ptree aTree; + tools::JsonWriter aTree; convertToJSONTree(aTree, rComplexColor); - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); - return OString(aStream.str()); + return aTree.finishAndGetAsOString(); } } // end model::theme diff --git a/include/docmodel/color/ComplexColorJSON.hxx b/include/docmodel/color/ComplexColorJSON.hxx index 0f95bb2288c3..b35d938f007c 100644 --- a/include/docmodel/color/ComplexColorJSON.hxx +++ b/include/docmodel/color/ComplexColorJSON.hxx @@ -12,12 +12,16 @@ #include <docmodel/dllapi.h> #include <docmodel/color/ComplexColor.hxx> -#include <boost/property_tree/ptree_fwd.hpp> + +namespace tools +{ +class JsonWriter; +} namespace model::color { DOCMODEL_DLLPUBLIC OString convertToJSON(model::ComplexColor const& rComplexColor); -DOCMODEL_DLLPUBLIC void convertToJSONTree(boost::property_tree::ptree& rTree, +DOCMODEL_DLLPUBLIC void convertToJSONTree(tools::JsonWriter& rTree, model::ComplexColor const& rComplexColor); DOCMODEL_DLLPUBLIC bool convertFromJSON(OString const& rJsonString, model::ComplexColor& rComplexColor); diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx index 90fa00de59fe..5882a7c465b7 100644 --- a/include/svx/PaletteManager.hxx +++ b/include/svx/PaletteManager.hxx @@ -33,6 +33,7 @@ namespace com::sun::star::uno { class XComponentContext; } namespace svx { class ToolboxButtonColorUpdaterBase; } namespace weld { class Window; } namespace model { class ColorSet; } +namespace tools { class JsonWriter; } class SVXCORE_DLLPUBLIC PaletteManager : public std::enable_shared_from_this<PaletteManager> { @@ -89,7 +90,7 @@ public: static void DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor); /// Appends node for Document Colors into the ptree - static void generateJSON(boost::property_tree::ptree& aTree, const std::set<Color>& rColors); + static void generateJSON(tools::JsonWriter& aTree, const std::set<Color>& rColors); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/theme/ThemeColorPaletteManager.hxx b/include/svx/theme/ThemeColorPaletteManager.hxx index 8531021bbc84..09469dee9477 100644 --- a/include/svx/theme/ThemeColorPaletteManager.hxx +++ b/include/svx/theme/ThemeColorPaletteManager.hxx @@ -14,12 +14,15 @@ #include <memory> #include <tools/color.hxx> #include <docmodel/theme/ThemeColorType.hxx> -#include <boost/property_tree/json_parser.hpp> namespace model { class ColorSet; } +namespace tools +{ +class JsonWriter; +} namespace svx { @@ -61,7 +64,7 @@ class SVXCORE_DLLPUBLIC ThemeColorPaletteManager final public: ThemeColorPaletteManager(std::shared_ptr<model::ColorSet> const& pColorSet); ThemePaletteCollection generate(); - void generateJSON(boost::property_tree::ptree& aTree); + void generateJSON(tools::JsonWriter& aTree); }; } // end svx namespace diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index c9330eec408f..891a98cdc92f 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> @@ -469,9 +470,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(); @@ -481,26 +482,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 bca8ea1a1bb7..d15d75839309 100644 --- a/svx/source/theme/ThemeColorChangerCommon.cxx +++ b/svx/source/theme/ThemeColorChangerCommon.cxx @@ -31,6 +31,7 @@ #include <svx/xdef.hxx> #include <svx/xlnclit.hxx> #include <svx/xflclit.hxx> +#include <tools/json_writer.hxx> using namespace css; @@ -178,17 +179,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.finishAndGetAsOString()); } } 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 |