diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 142427b58ebe..95a915aeeacc 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -219,7 +219,6 @@ public: void testRenderSearchResult_CommonNode(); void testNoDuplicateTableSelection(); void testMultiViewTableSelection(); - void testColorPaletteCallback(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -301,7 +300,6 @@ public: CPPUNIT_TEST(testRenderSearchResult_CommonNode); CPPUNIT_TEST(testNoDuplicateTableSelection); CPPUNIT_TEST(testMultiViewTableSelection); - CPPUNIT_TEST(testColorPaletteCallback); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -4167,34 +4165,6 @@ void DesktopLOKTest::testMultiViewTableSelection() CPPUNIT_ASSERT(!aView1.m_bEmptyTableSelection); } -void DesktopLOKTest::testColorPaletteCallback() -{ - LibLODocument_Impl* pDocument = loadDoc("ThemeDocument.docx"); - - // Create view 1. - pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); - ViewCallback aView1(pDocument); - Scheduler::ProcessEventsToIdle(); - { - CPPUNIT_ASSERT_EQUAL(1, aView1.m_nColorPaletteCallbackCount); - boost::property_tree::ptree aValues = aView1.m_aColorPaletteCallbackResult.get_child("ThemeColors"); - CPPUNIT_ASSERT(!aValues.empty()); - CPPUNIT_ASSERT_EQUAL(size_t(6), aValues.size()); - } - - // Create view 2. - pDocument->m_pDocumentClass->createView(pDocument); - pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); - ViewCallback aView2(pDocument); - Scheduler::ProcessEventsToIdle(); - { - CPPUNIT_ASSERT_EQUAL(1, aView2.m_nColorPaletteCallbackCount); - boost::property_tree::ptree aValues = aView1.m_aColorPaletteCallbackResult.get_child("ThemeColors"); - CPPUNIT_ASSERT(!aValues.empty()); - CPPUNIT_ASSERT_EQUAL(size_t(6), aValues.size()); - } -} - namespace { constexpr size_t classOffset(int i) diff --git a/docmodel/Library_docmodel.mk b/docmodel/Library_docmodel.mk index 01e63c4b7e48..11ffbe302639 100644 --- a/docmodel/Library_docmodel.mk +++ b/docmodel/Library_docmodel.mk @@ -17,7 +17,6 @@ $(eval $(call gb_Library_add_exception_objects,docmodel,\ docmodel/source/uno/UnoTheme \ docmodel/source/theme/ColorSet \ docmodel/source/theme/Theme \ - docmodel/source/color/ComplexColorJSON \ docmodel/source/color/ComplexColor \ docmodel/source/styles/ChartStyle \ docmodel/source/styles/ChartColorStyle \ diff --git a/docmodel/source/color/ComplexColorJSON.cxx b/docmodel/source/color/ComplexColorJSON.cxx deleted file mode 100644 index 4ff997ff2505..000000000000 --- a/docmodel/source/color/ComplexColorJSON.cxx +++ /dev/null @@ -1,105 +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 -#include -#include -#include -#include - -namespace model::color -{ -bool convertFromJSON(OString const& rJsonString, model::ComplexColor& rComplexColor) -{ - model::ComplexColor aComplexColor; - - try - { - std::stringstream aStream((std::string(rJsonString))); - boost::property_tree::ptree aRootTree; - boost::property_tree::read_json(aStream, aRootTree); - - sal_Int32 nThemeType = aRootTree.get("ThemeIndex", -1); - aComplexColor.setThemeColor(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("Type", ""); - sal_Int16 nValue = rTransformationTree.get("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; - } - - rComplexColor = std::move(aComplexColor); - return true; -} - -void convertToJSONTree(tools::JsonWriter& rTree, model::ComplexColor const& rComplexColor) -{ - rTree.put("ThemeIndex", sal_Int16(rComplexColor.getThemeColorType())); - auto aTransformationsList = rTree.startArray("Transformations"); - - for (auto const& rTransformation : rComplexColor.getTransformations()) - { - std::string aType; - switch (rTransformation.meType) - { - case model::TransformationType::LumMod: - aType = "LumMod"; - break; - case model::TransformationType::LumOff: - aType = "LumOff"; - break; - case model::TransformationType::Tint: - aType = "Tint"; - break; - case model::TransformationType::Shade: - aType = "Shade"; - break; - default: - break; - } - if (!aType.empty()) - { - auto aChild = rTree.startStruct(); - rTree.put("Type", aType); - rTree.put("Value", rTransformation.mnValue); - } - } -} - -OString convertToJSON(model::ComplexColor const& rComplexColor) -{ - tools::JsonWriter aTree; - convertToJSONTree(aTree, rComplexColor); - return aTree.finishAndGetAsOString(); -} - -} // end model::theme - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/docmodel/source/uno/UnoComplexColor.cxx b/docmodel/source/uno/UnoComplexColor.cxx index c5533009a7e0..65e30eed78c0 100644 --- a/docmodel/source/uno/UnoComplexColor.cxx +++ b/docmodel/source/uno/UnoComplexColor.cxx @@ -9,7 +9,6 @@ */ #include -#include using namespace css; @@ -17,11 +16,6 @@ sal_Int32 UnoComplexColor::getType() { return sal_Int32(maColor.getType()); } sal_Int32 UnoComplexColor::getThemeColorType() { return sal_Int32(maColor.getThemeColorType()); } -OUString UnoComplexColor::getRepresentation() -{ - return OStringToOUString(model::color::convertToJSON(maColor), RTL_TEXTENCODING_UTF8); -} - util::Color UnoComplexColor::resolveColor(uno::Reference const& /*xTheme*/) { return util::Color(maColor.getFinalColor()); diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 1a6fc66c116f..5b351d551d5a 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -84,7 +84,6 @@ #include #include #include -#include #include #include #include @@ -1640,11 +1639,6 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= nValue; break; } - case MID_COMPLEX_COLOR_JSON: - { - rVal <<= OStringToOUString(model::color::convertToJSON(maComplexColor), RTL_TEXTENCODING_UTF8); - break; - } case MID_COMPLEX_COLOR: { auto xComplexColor = model::color::createXComplexColor(maComplexColor); @@ -1727,20 +1721,6 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) maComplexColor.addTransformation({model::TransformationType::LumOff, nLumOff}); } break; - case MID_COMPLEX_COLOR_JSON: - { - OUString sComplexColorJson; - if (!(rVal >>= sComplexColorJson)) - return false; - - if (sComplexColorJson.isEmpty()) - return false; - - OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US); - if (!model::color::convertFromJSON(aJSON, maComplexColor)) - return false; - } - break; case MID_COMPLEX_COLOR: { css::uno::Reference xComplexColor; diff --git a/include/docmodel/color/ComplexColorJSON.hxx b/include/docmodel/color/ComplexColorJSON.hxx deleted file mode 100644 index b35d938f007c..000000000000 --- a/include/docmodel/color/ComplexColorJSON.hxx +++ /dev/null @@ -1,31 +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/. - * - */ - -#pragma once - -#include -#include - -namespace tools -{ -class JsonWriter; -} - -namespace model::color -{ -DOCMODEL_DLLPUBLIC OString convertToJSON(model::ComplexColor const& rComplexColor); -DOCMODEL_DLLPUBLIC void convertToJSONTree(tools::JsonWriter& rTree, - model::ComplexColor const& rComplexColor); -DOCMODEL_DLLPUBLIC bool convertFromJSON(OString const& rJsonString, - model::ComplexColor& rComplexColor); - -} // end of namespace model - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/docmodel/uno/UnoComplexColor.hxx b/include/docmodel/uno/UnoComplexColor.hxx index 500c1c125a3f..4c584b2ab7c4 100644 --- a/include/docmodel/uno/UnoComplexColor.hxx +++ b/include/docmodel/uno/UnoComplexColor.hxx @@ -35,7 +35,6 @@ public: // XComplexColor sal_Int32 SAL_CALL getType() override; sal_Int32 SAL_CALL getThemeColorType() override; - OUString SAL_CALL getRepresentation() override; css::util::Color SAL_CALL resolveColor(css::uno::Reference const& xTheme) override; }; diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index 19ea071076a7..8f55ec0d12db 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -218,8 +218,7 @@ #define MID_COLOR_TINT_OR_SHADE 5 #define MID_COLOR_LUM_MOD 6 #define MID_COLOR_LUM_OFF 7 -#define MID_COMPLEX_COLOR_JSON 8 -#define MID_COMPLEX_COLOR 9 +#define MID_COMPLEX_COLOR 8 // SvxRubyItem and SwFormatRuby #define MID_RUBY_TEXT 0 diff --git a/include/svx/theme/ThemeColorPaletteManager.hxx b/include/svx/theme/ThemeColorPaletteManager.hxx index a2d45c19f492..98765acd2a8c 100644 --- a/include/svx/theme/ThemeColorPaletteManager.hxx +++ b/include/svx/theme/ThemeColorPaletteManager.hxx @@ -65,7 +65,6 @@ class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) ThemeColorPaletteManager final public: ThemeColorPaletteManager(std::shared_ptr const& pColorSet); ThemePaletteCollection generate(); - void generateJSON(tools::JsonWriter& aTree); }; } // end svx namespace diff --git a/offapi/com/sun/star/util/XComplexColor.idl b/offapi/com/sun/star/util/XComplexColor.idl index 83c5b5b1f081..c2f10e92b124 100644 --- a/offapi/com/sun/star/util/XComplexColor.idl +++ b/offapi/com/sun/star/util/XComplexColor.idl @@ -25,12 +25,6 @@ interface XComplexColor /** resolve the color */ Color resolveColor([in] com::sun::star::util::XTheme xTheme); - - /** String representation of the complex color. - - @since LibreOffice 26.2 - */ - string getRepresentation(); }; }; }; }; }; diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 18a80fe5882f..874cdca38e35 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -57,7 +57,6 @@ #include #include #include -#include #include #include @@ -2028,14 +2027,13 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme) aComplexColor.addTransformation({ model::TransformationType::LumMod, 2000 }); aComplexColor.addTransformation({ model::TransformationType::LumOff, 8000 }); - OUString aJSON - = OStringToOUString(model::color::convertToJSON(aComplexColor), RTL_TEXTENCODING_UTF8); - // When setting the fill color of that shape, with theme metadata & effects: uno::Sequence aColorArgs = { comphelper::makePropertyValue(u"Color.Color"_ustr, sal_Int32(0xdae3f3)), // 80% light blue - comphelper::makePropertyValue(u"Color.ComplexColorJSON"_ustr, uno::Any(aJSON)), + comphelper::makePropertyValue( + u"Color.ComplexColor"_ustr, + uno::Any(model::color::createXComplexColor(aComplexColor))), }; dispatchCommand(mxComponent, u".uno:Color"_ustr, aColorArgs); } @@ -2085,14 +2083,12 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorTheme) aComplexColor.addTransformation({ model::TransformationType::LumMod, 4000 }); aComplexColor.addTransformation({ model::TransformationType::LumOff, 6000 }); - OUString aJSON - = OStringToOUString(model::color::convertToJSON(aComplexColor), RTL_TEXTENCODING_UTF8); - // When setting the fill color of that shape, with theme metadata & effects: uno::Sequence aColorArgs = { comphelper::makePropertyValue(u"FillColor.Color"_ustr, sal_Int32(0xed7d31)), // orange - comphelper::makePropertyValue(u"FillColor.ComplexColorJSON"_ustr, - uno::Any(aJSON)), // accent 1 + comphelper::makePropertyValue( + u"FillColor.ComplexColor"_ustr, + uno::Any(model::color::createXComplexColor(aComplexColor))), // accent 1 }; dispatchCommand(mxComponent, u".uno:FillColor"_ustr, aColorArgs); } diff --git a/svx/sdi/svxitems.sdi b/svx/sdi/svxitems.sdi index bb083d49b161..95b254cb56dc 100644 --- a/svx/sdi/svxitems.sdi +++ b/svx/sdi/svxitems.sdi @@ -181,7 +181,7 @@ item BOOL SvxAutoKernItem; struct SvxColor { INT32 Color MID_COLOR_RGB; - String ComplexColorJSON MID_COMPLEX_COLOR_JSON; + String ComplexColor MID_COMPLEX_COLOR; }; item SvxColor SvxColorItem; @@ -225,7 +225,7 @@ item String avmedia_MediaItem; struct XColor { INT32 Color MID_COLOR_RGB; - String ComplexColorJSON MID_COMPLEX_COLOR_JSON; + String ComplexColor MID_COMPLEX_COLOR; }; item XColor XColorItem; diff --git a/svx/sdi/xoitems.sdi b/svx/sdi/xoitems.sdi index 50db129a6434..3d8def73aebb 100644 --- a/svx/sdi/xoitems.sdi +++ b/svx/sdi/xoitems.sdi @@ -27,7 +27,7 @@ item XFillBitmap XFillBitmapItem; struct XFillColor { INT32 Color MID_COLOR_RGB; - String ComplexColorJSON MID_COMPLEX_COLOR_JSON; + String ComplexColor MID_COMPLEX_COLOR; }; item XFillColor XFillColorItem; // XColorItem @@ -93,7 +93,7 @@ item SvxFillStyle XFillStyleItem; struct XLineColor { INT32 Color MID_COLOR_RGB; - String ComplexColorJSON MID_COMPLEX_COLOR_JSON; + String ComplexColor MID_COMPLEX_COLOR; }; item XLineColor XLineColorItem; diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 9938bab2ef41..96386170b0c7 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include @@ -445,9 +445,9 @@ void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedC aComplexColor.addTransformation({model::TransformationType::LumOff, rColor.m_nLumOff}); uno::Any aAny; - aAny <<= OStringToOUString(model::color::convertToJSON(aComplexColor), RTL_TEXTENCODING_UTF8); + aAny <<= model::color::createXComplexColor(aComplexColor); - aArgs.push_back(comphelper::makePropertyValue(aObj.GetURLPath() + ".ComplexColorJSON", aAny)); + aArgs.push_back(comphelper::makePropertyValue(aObj.GetURLPath() + ".ComplexColor", aAny)); } URL aTargetURL; diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx b/svx/source/theme/ThemeColorChangerCommon.cxx index 94a37908e36b..948085093382 100644 --- a/svx/source/theme/ThemeColorChangerCommon.cxx +++ b/svx/source/theme/ThemeColorChangerCommon.cxx @@ -171,16 +171,13 @@ void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject, SdrVi updateEditEngTextSections(rColorSet, pObject, *pView); } -void notifyLOK(std::shared_ptr const& pColorSet, +void notifyLOK(std::shared_ptr const& /*pColorSet*/, const std::set& rDocumentColors) { if (comphelper::LibreOfficeKit::isActive()) { - svx::ThemeColorPaletteManager aManager(pColorSet); tools::JsonWriter aTree; - if (pColorSet) - aManager.generateJSON(aTree); if (rDocumentColors.size()) PaletteManager::generateJSON(aTree, rDocumentColors); diff --git a/svx/source/theme/ThemeColorPaletteManager.cxx b/svx/source/theme/ThemeColorPaletteManager.cxx index 21c65024be35..7a5ccb8ed260 100644 --- a/svx/source/theme/ThemeColorPaletteManager.cxx +++ b/svx/source/theme/ThemeColorPaletteManager.cxx @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -92,38 +91,6 @@ svx::ThemePaletteCollection ThemeColorPaletteManager::generate() } return aThemePaletteCollection; } - -void ThemeColorPaletteManager::generateJSON(tools::JsonWriter& aTree) -{ - svx::ThemePaletteCollection aThemePaletteCollection = generate(); - - auto aColorListTree = aTree.startArray("ThemeColors"); - - for (size_t nEffect = 0; nEffect < 6; ++nEffect) - { - auto aColorRowTree = aTree.startAnonArray(); - for (size_t nIndex = 0; nIndex < 12; ++nIndex) - { - auto aColorTree = aTree.startStruct(); - - auto const& rColorData = aThemePaletteCollection.maColors[nIndex]; - auto const& rEffectData = rColorData.maEffects[nEffect]; - - aTree.put("Value", rEffectData.maColor.AsRGBHexString().toUtf8()); - aTree.put("Name", rEffectData.maColorName.toUtf8()); - - model::ComplexColor aComplexColor; - aComplexColor.setThemeColor(rColorData.meThemeColorType); - aComplexColor.addTransformation( - { model::TransformationType::LumMod, rEffectData.mnLumMod }); - aComplexColor.addTransformation( - { model::TransformationType::LumOff, rEffectData.mnLumOff }); - auto aDataTree = aTree.startNode("Data"); - model::color::convertToJSONTree(aTree, aComplexColor); - } - } -} - } // end svx namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index aaf154bb5f8a..1db6655b5bcc 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -343,11 +342,6 @@ bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const rVal <<= xComplexColor; break; } - case MID_COMPLEX_COLOR_JSON: - { - rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8); - break; - } default: { rVal <<= GetColorValue().GetRGBColor(); @@ -370,21 +364,6 @@ bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId) setComplexColor(model::color::getFromXComplexColor(xComplexColor)); } break; - case MID_COMPLEX_COLOR_JSON: - { - OUString sComplexColorJson; - if (!(rVal >>= sComplexColorJson)) - return false; - - if (sComplexColorJson.isEmpty()) - return false; - - OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US); - model::ComplexColor aComplexColor; - model::color::convertFromJSON(aJSON, aComplexColor); - setComplexColor(aComplexColor); - } - break; default: { Color nValue; @@ -1067,11 +1046,6 @@ bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const rVal <<= xComplexColor; break; } - case MID_COMPLEX_COLOR_JSON: - { - rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8); - break; - } default: { rVal <<= GetColorValue().GetRGBColor(); @@ -1094,20 +1068,6 @@ bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId) setComplexColor(model::color::getFromXComplexColor(xComplexColor)); } break; - case MID_COMPLEX_COLOR_JSON: - { - OUString sComplexColorJson; - if (!(rVal >>= sComplexColorJson)) - return false; - - if (sComplexColorJson.isEmpty()) - return false; - model::ComplexColor aComplexColor; - OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US); - model::color::convertFromJSON(aJSON, aComplexColor); - setComplexColor(aComplexColor); - } - break; default: { sal_Int32 nValue; @@ -1891,11 +1851,6 @@ bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) cons rVal <<= xComplexColor; break; } - case MID_COMPLEX_COLOR_JSON: - { - rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8); - break; - } default: { rVal <<= GetColorValue().GetRGBColor(); @@ -1945,21 +1900,6 @@ bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) setComplexColor(model::color::getFromXComplexColor(xComplexColor)); } break; - case MID_COMPLEX_COLOR_JSON: - { - OUString sComplexColorJson; - if (!(rVal >>= sComplexColorJson)) - return false; - - if (sComplexColorJson.isEmpty()) - return false; - - OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US); - model::ComplexColor aComplexColor; - model::color::convertFromJSON(aJSON, aComplexColor); - setComplexColor(aComplexColor); - } - break; default: { Color nValue;