summaryrefslogtreecommitdiff
path: root/docmodel
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-06-09 16:06:37 +0900
committerXisco Fauli <xiscofauli@libreoffice.org>2023-06-12 17:56:02 +0200
commit7f7bada86cb2ac495d27fce9aca56a4dc9b0aedc (patch)
treed992159d52578405658811e15ca43b20b1586c77 /docmodel
parentf60e889c95cc894eaae06ea2199e2b2d107d54a0 (diff)
fix wrong transform type, error handling when JSON parsing
also fix theme export - change scheme enum type name "hlink" to "hyperlink" and "folHlink" to "followedHyperlink" Change-Id: Id5435d59cd51352efc4a4a8e333ec1ff45847a6f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152782 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 7d2a7307da71b245fe55c55c5a29f4695c3c54f7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152883 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'docmodel')
-rw-r--r--docmodel/source/color/ComplexColorJSON.cxx52
1 files changed, 27 insertions, 25 deletions
diff --git a/docmodel/source/color/ComplexColorJSON.cxx b/docmodel/source/color/ComplexColorJSON.cxx
index db36f29e6a4e..f6b52d1bf55c 100644
--- a/docmodel/source/color/ComplexColorJSON.cxx
+++ b/docmodel/source/color/ComplexColorJSON.cxx
@@ -18,40 +18,42 @@ namespace model::color
bool convertFromJSON(OString const& rJsonString, model::ComplexColor& rComplexColor)
{
model::ComplexColor aComplexColor;
- std::stringstream aStream((std::string(rJsonString)));
- boost::property_tree::ptree aRootTree;
+
try
{
+ std::stringstream aStream((std::string(rJsonString)));
+ boost::property_tree::ptree aRootTree;
boost::property_tree::read_json(aStream, aRootTree);
+
+ sal_Int32 nThemeType = aRootTree.get<sal_Int32>("ThemeIndex", -1);
+ aComplexColor.setSchemeColor(model::convertToThemeColorType(nThemeType));
+ boost::property_tree::ptree aTransformTree = aRootTree.get_child("Transformations");
+ for (const auto& rEachTransformationNode :
+ boost::make_iterator_range(aTransformTree.equal_range("")))
+ {
+ auto const& rTransformationTree = rEachTransformationNode.second;
+ std::string sType = rTransformationTree.get<std::string>("Type", "");
+ sal_Int16 nValue = rTransformationTree.get<sal_Int16>("Value", 0);
+
+ auto eType = model::TransformationType::Undefined;
+ if (sType == "LumOff")
+ eType = model::TransformationType::LumOff;
+ else if (sType == "LumMod")
+ eType = model::TransformationType::LumMod;
+ else if (sType == "Tint")
+ eType = model::TransformationType::Tint;
+ else if (sType == "Shade")
+ eType = model::TransformationType::Shade;
+
+ if (eType != model::TransformationType::Undefined)
+ aComplexColor.addTransformation({ eType, nValue });
+ }
}
catch (const boost::property_tree::json_parser_error& /*exception*/)
{
return false;
}
- sal_Int32 nThemeType = aRootTree.get<sal_Int32>("ThemeIndex", -1);
- aComplexColor.setSchemeColor(model::convertToThemeColorType(nThemeType));
- boost::property_tree::ptree aTransformTree = aRootTree.get_child("Transformations");
- for (const auto& rEachTransformationNode :
- boost::make_iterator_range(aTransformTree.equal_range("")))
- {
- auto const& rTransformationTree = rEachTransformationNode.second;
- std::string sType = rTransformationTree.get<std::string>("Type", "");
- sal_Int16 nValue = rTransformationTree.get<sal_Int16>("Value", 0);
-
- auto eType = model::TransformationType::Undefined;
- if (sType == "LumOff")
- eType = model::TransformationType::LumOff;
- else if (sType == "LumMod")
- eType = model::TransformationType::LumMod;
- else if (sType == "Tint")
- eType = model::TransformationType::Tint;
- else if (sType == "Shade")
- eType = model::TransformationType::Shade;
-
- if (eType != model::TransformationType::Undefined)
- aComplexColor.addTransformation({ eType, nValue });
- }
rComplexColor = aComplexColor;
return true;
}