diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-03-01 22:11:14 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-03-04 11:51:58 +0100 |
commit | 0f03f7807541fc6eadb2e3642e37c5d63dae36ad (patch) | |
tree | be4c3e2336c689c741db2cf0bf1c05a22b4ae992 /docmodel/source | |
parent | ebfd17e47c1bdfd25090fe73495e4e729ac19564 (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>
Diffstat (limited to 'docmodel/source')
-rw-r--r-- | docmodel/source/color/ComplexColorJSON.cxx | 19 |
1 files changed, 8 insertions, 11 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 |