summaryrefslogtreecommitdiff
path: root/docmodel
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-05-08 14:09:00 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-06-01 11:19:17 +0200
commitb0da2f52374c04192ac92951519e0a47410d0a24 (patch)
treeb1b81ebf7fecb2024b3dc99396e399a12a107862 /docmodel
parent34872a4d4e721bdf17642d406b08d407e9cfe8b2 (diff)
use ComplexColor instead of ThemeColor for better OOXML compat.
In OOXML a color definition includes more represenations, one of which is scheme color (which is what is implemented in ThemeColor currently), but it supports other representations too (RGB, HSL, System,..). ComplexColor includes all the representations, so to have a better compatibility with OOXML, this changes all uses of ThemeColor to ComplexColor. In many cases the usage of ComplexColor isn't the same as the usage of ThemeColors, but this cases will need to be changed in a later commit. Change-Id: I9cc8acee2ac0a1998fe9b98247bcf4a96273149a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151492 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 1df0565fb92972bd410e7db85eef1e4bec3fcc31) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152234 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'docmodel')
-rw-r--r--docmodel/Library_docmodel.mk3
-rw-r--r--docmodel/source/color/ComplexColorJSON.cxx (renamed from docmodel/source/theme/ThemeColorJSON.cxx)22
-rw-r--r--docmodel/source/theme/ColorSet.cxx12
-rw-r--r--docmodel/source/uno/UnoThemeColor.cxx40
4 files changed, 12 insertions, 65 deletions
diff --git a/docmodel/Library_docmodel.mk b/docmodel/Library_docmodel.mk
index 7f0623bcbeda..2e474eb4f0b8 100644
--- a/docmodel/Library_docmodel.mk
+++ b/docmodel/Library_docmodel.mk
@@ -11,11 +11,10 @@ $(eval $(call gb_Library_Library,docmodel))
$(eval $(call gb_Library_add_exception_objects,docmodel,\
docmodel/source/uno/UnoComplexColor \
- docmodel/source/uno/UnoThemeColor \
docmodel/source/uno/UnoTheme \
docmodel/source/theme/ColorSet \
docmodel/source/theme/Theme \
- docmodel/source/theme/ThemeColorJSON \
+ docmodel/source/color/ComplexColorJSON \
))
$(eval $(call gb_Library_set_include,docmodel,\
diff --git a/docmodel/source/theme/ThemeColorJSON.cxx b/docmodel/source/color/ComplexColorJSON.cxx
index 6b2293ca1f64..2bfdf9c0761c 100644
--- a/docmodel/source/theme/ThemeColorJSON.cxx
+++ b/docmodel/source/color/ComplexColorJSON.cxx
@@ -8,18 +8,18 @@
*
*/
-#include <docmodel/theme/ThemeColorJSON.hxx>
+#include <docmodel/color/ComplexColorJSON.hxx>
#include <sstream>
#include <utility>
#include <sal/log.hxx>
#include <boost/property_tree/json_parser.hpp>
-namespace model::theme
+namespace model::color
{
-bool convertFromJSON(OString const& rJsonString, model::ThemeColor& rThemeColor)
+bool convertFromJSON(OString const& rJsonString, model::ComplexColor& rComplexColor)
{
- model::ThemeColor aThemeColor;
- std::stringstream aStream(rJsonString.getStr());
+ model::ComplexColor aComplexColor;
+ std::stringstream aStream((std::string(rJsonString)));
boost::property_tree::ptree aRootTree;
try
{
@@ -31,7 +31,7 @@ bool convertFromJSON(OString const& rJsonString, model::ThemeColor& rThemeColor)
}
sal_Int32 nThemeType = aRootTree.get<sal_Int32>("ThemeIndex", -1);
- aThemeColor.setType(model::convertToThemeColorType(nThemeType));
+ 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("")))
@@ -51,19 +51,19 @@ bool convertFromJSON(OString const& rJsonString, model::ThemeColor& rThemeColor)
eType = model::TransformationType::Shade;
if (eType != model::TransformationType::Undefined)
- aThemeColor.addTransformation({ eType, nValue });
+ aComplexColor.addTransformation({ eType, nValue });
}
- rThemeColor = aThemeColor;
+ rComplexColor = aComplexColor;
return true;
}
-OString convertToJSON(model::ThemeColor const& rThemeColor)
+OString convertToJSON(model::ComplexColor const& rComplexColor)
{
boost::property_tree::ptree aTree;
- aTree.put("ThemeIndex", sal_Int16(rThemeColor.getType()));
+ aTree.put("ThemeIndex", sal_Int16(rComplexColor.getSchemeType()));
boost::property_tree::ptree aTransformationsList;
- for (auto const& rTransformation : rThemeColor.getTransformations())
+ for (auto const& rTransformation : rComplexColor.getTransformations())
{
std::string aType;
switch (rTransformation.meType)
diff --git a/docmodel/source/theme/ColorSet.cxx b/docmodel/source/theme/ColorSet.cxx
index 44cd5bdc6c4f..71b928b9f2a7 100644
--- a/docmodel/source/theme/ColorSet.cxx
+++ b/docmodel/source/theme/ColorSet.cxx
@@ -38,18 +38,6 @@ Color ColorSet::getColor(model::ThemeColorType eType) const
return maColors[size_t(eType)];
}
-Color ColorSet::resolveColor(model::ThemeColor const& rThemeColor) const
-{
- auto eType = rThemeColor.getType();
- if (eType == model::ThemeColorType::Unknown)
- {
- SAL_WARN("svx", "ColorSet::resolveColor with ThemeColorType::Unknown");
- return COL_AUTO;
- }
- Color aColor = getColor(eType);
- return rThemeColor.applyTransformations(aColor);
-}
-
Color ColorSet::resolveColor(model::ComplexColor const& rComplexColor) const
{
auto eSchemeType = rComplexColor.meSchemeType;
diff --git a/docmodel/source/uno/UnoThemeColor.cxx b/docmodel/source/uno/UnoThemeColor.cxx
deleted file mode 100644
index f6374b54933b..000000000000
--- a/docmodel/source/uno/UnoThemeColor.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#include <docmodel/uno/UnoThemeColor.hxx>
-#include <cppuhelper/queryinterface.hxx>
-
-using namespace css;
-
-// css::lang::XUnoTunnel
-UNO3_GETIMPLEMENTATION_IMPL(UnoThemeColor);
-
-sal_Int16 UnoThemeColor::getType() { return sal_uInt16(maThemeColor.getType()); }
-
-namespace model::theme
-{
-uno::Reference<util::XThemeColor> createXThemeColor(model::ThemeColor const& rThemeColor)
-{
- return new UnoThemeColor(rThemeColor);
-}
-
-void setFromXThemeColor(model::ThemeColor& rThemeColor,
- uno::Reference<util::XThemeColor> const& rxColorTheme)
-{
- UnoThemeColor* pUnoThemeColor = comphelper::getFromUnoTunnel<UnoThemeColor>(rxColorTheme);
- if (pUnoThemeColor)
- {
- rThemeColor = pUnoThemeColor->getThemeColor();
- }
-}
-
-} // end model::theme
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */