include/svx/svxids.hrc         |    6 ++--
 sd/qa/unit/uiimpress.cxx       |   50 ++++++++++++++++++++++++++++-------------
 sd/source/ui/view/drtxtob1.cxx |   24 -------------------
 sd/source/ui/view/drviews2.cxx |   33 +--------------------------
 svx/sdi/svx.sdi                |    4 +--
 5 files changed, 42 insertions(+), 75 deletions(-)

New commits:
commit 6471181b66ebe634e9ffbdc2b55dbf1da17a3acf
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Aug 18 22:31:51 2023 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Aug 26 21:04:37 2023 +0200

    svx: remove theme related parameters for Color and FillColor
    
    For SvxColorItem, XFillColorItem, XLineColorItem,... we set the
    ComplexColor via the JSON additional UNO Command argument, so we
    don't need the parameters to set the theme color and LumOff and
    LumMod color modifiers for the UNO Command. Actually this has
    broken the setting the colors in certain situations, so we must
    remove this.
    
    Change-Id: Ic28aa1e43559d3627703d93c7c1bd9310a149986
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155864
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 97832803a7d8..7cc55ac02813 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -452,9 +452,9 @@ class XFillGradientItem;
 #define SID_ATTR_TEXTCOLUMNS_SPACING                    ( SID_SVX_START + 341 )
 
 // FREE                                                 ( SID_SVX_START + 342 )
-#define SID_ATTR_COLOR_THEME_INDEX                      
TypedWhichId<SfxInt16Item>( SID_SVX_START + 343 )
-#define SID_ATTR_COLOR_LUM_MOD                          
TypedWhichId<SfxInt16Item>( SID_SVX_START + 344 )
-#define SID_ATTR_COLOR_LUM_OFF                          
TypedWhichId<SfxInt16Item>( SID_SVX_START + 345 )
+// FREE                                                 ( SID_SVX_START + 343 )
+// FREE                                                 ( SID_SVX_START + 344 )
+// FREE                                                 ( SID_SVX_START + 345 )
 
 #define SID_SB_CONNECTIONPOOLING                        ( SID_SVX_START + 348 )
 #define SID_SB_DBREGISTEROPTIONS                        ( SID_SVX_START + 349 )
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index c99d4bd5df49..61ab0c301ed6 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -47,6 +47,7 @@
 #include <comphelper/sequenceashashmap.hxx>
 #include <docmodel/uno/UnoTheme.hxx>
 #include <docmodel/theme/Theme.hxx>
+#include <docmodel/color/ComplexColorJSON.hxx>
 
 #include <drawdoc.hxx>
 #include <DrawDocShell.hxx>
@@ -1019,13 +1020,22 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testCharColorTheme)
     dispatchCommand(mxComponent, ".uno:SelectAll", {});
 
     // When picking a theme color on the sidebar:
-    uno::Sequence<beans::PropertyValue> aColorArgs = {
-        comphelper::makePropertyValue("Color", 
static_cast<sal_Int32>(0xdae3f3)), // 80% light blue
-        comphelper::makePropertyValue("ColorThemeIndex", 
static_cast<sal_Int16>(4)), // accent 1
-        comphelper::makePropertyValue("ColorLumMod", 
static_cast<sal_Int16>(2000)),
-        comphelper::makePropertyValue("ColorLumOff", 
static_cast<sal_Int16>(8000)),
-    };
-    dispatchCommand(mxComponent, ".uno:Color", aColorArgs);
+    {
+        model::ComplexColor aComplexColor;
+        aComplexColor.setThemeColor(model::ThemeColorType::Accent1);
+        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<beans::PropertyValue> aColorArgs = {
+            comphelper::makePropertyValue("Color.Color", sal_Int32(0xdae3f3)), 
// 80% light blue
+            comphelper::makePropertyValue("Color.ComplexColorJSON", 
uno::Any(aJSON)),
+        };
+        dispatchCommand(mxComponent, ".uno:Color", aColorArgs);
+    }
 
     // Then make sure the theme "metadata" is set in the document model:
     pView->EndTextEditCurrentView();
@@ -1063,14 +1073,24 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testFillColorTheme)
                                                          uno::UNO_QUERY);
     xController->select(uno::Any(xShape));
 
-    // When setting the fill color of that shape, with theme metadata & 
effects:
-    uno::Sequence<beans::PropertyValue> aColorArgs = {
-        comphelper::makePropertyValue("FillColor", 
static_cast<sal_Int32>(0xed7d31)), // orange
-        comphelper::makePropertyValue("ColorThemeIndex", 
static_cast<sal_Int16>(4)), // accent 1
-        comphelper::makePropertyValue("ColorLumMod", 
static_cast<sal_Int16>(4000)),
-        comphelper::makePropertyValue("ColorLumOff", 
static_cast<sal_Int16>(6000)),
-    };
-    dispatchCommand(mxComponent, ".uno:FillColor", aColorArgs);
+    // Change fill color
+    {
+        model::ComplexColor aComplexColor;
+        aComplexColor.setThemeColor(model::ThemeColorType::Accent1);
+        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<beans::PropertyValue> aColorArgs = {
+            comphelper::makePropertyValue("FillColor.Color", 
sal_Int32(0xed7d31)), // orange
+            comphelper::makePropertyValue("FillColor.ComplexColorJSON",
+                                          uno::Any(aJSON)), // accent 1
+        };
+        dispatchCommand(mxComponent, ".uno:FillColor", aColorArgs);
+    }
 
     // Then make sure the theme index is not lost when the sidebar sets it:
     {
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
index f0e46120d5a4..b176db5596c8 100644
--- a/sd/source/ui/view/drtxtob1.cxx
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -774,30 +774,6 @@ void TextObjectBar::Execute( SfxRequest &rReq )
             }
 
             std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone();
-
-            // Merge the color parameters to the color itself.
-            std::unique_ptr<SvxColorItem> pColorItem;
-            if (nSlot == SID_ATTR_CHAR_COLOR)
-            {
-                pColorItem = 
std::make_unique<SvxColorItem>(pNewArgs->Get(EE_CHAR_COLOR));
-                model::ComplexColor aComplexColor;
-
-                if (const SfxInt16Item* pIntItem = 
pArgs->GetItemIfSet(SID_ATTR_COLOR_THEME_INDEX, false))
-                {
-                    
aComplexColor.setThemeColor(model::convertToThemeColorType(pIntItem->GetValue()));
-                }
-                if (const SfxInt16Item* pIntItem = 
pArgs->GetItemIfSet(SID_ATTR_COLOR_LUM_MOD, false))
-                {
-                    
aComplexColor.addTransformation({model::TransformationType::LumMod, 
pIntItem->GetValue()});
-                }
-                if (const SfxInt16Item* pIntItem = 
pArgs->GetItemIfSet(SID_ATTR_COLOR_LUM_OFF, false))
-                {
-                    
aComplexColor.addTransformation({model::TransformationType::LumOff, 
pIntItem->GetValue()});
-                }
-                pColorItem->setComplexColor(aComplexColor);
-                pNewArgs->Put(std::move(pColorItem));
-            }
-
             mpView->SetAttributes(*pNewArgs);
 
             // invalidate entire shell because of performance and
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 51ebf5ef0773..2fea8a46f879 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -549,7 +549,7 @@ public:
     }
 };
 
-    void lcl_convertStringArguments(sal_uInt16 nSlot, const 
std::unique_ptr<SfxItemSet>& pArgs)
+    void lcl_convertStringArguments(const std::unique_ptr<SfxItemSet>& pArgs)
     {
         const SfxPoolItem* pItem = nullptr;
 
@@ -573,35 +573,6 @@ public:
                 pArgs->Put(aItem);
             }
         }
-
-        if (nSlot == SID_ATTR_FILL_COLOR)
-        {
-            // Merge the color parameters to the color itself.
-            const XFillColorItem* pColorItem = static_cast<const 
XFillColorItem*>(pArgs->GetItem(SID_ATTR_FILL_COLOR));
-            if (pColorItem)
-            {
-                XFillColorItem aColorItem(*pColorItem);
-                model::ComplexColor aComplexColor = 
aColorItem.getComplexColor();
-
-                if (pArgs->GetItemState(SID_ATTR_COLOR_THEME_INDEX, false, 
&pItem) == SfxItemState::SET)
-                {
-                    auto pIntItem = static_cast<const SfxInt16Item*>(pItem);
-                    
aComplexColor.setThemeColor(model::convertToThemeColorType(pIntItem->GetValue()));
-                }
-                if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_MOD, false, &pItem) 
== SfxItemState::SET)
-                {
-                    auto pIntItem = static_cast<const SfxInt16Item*>(pItem);
-                    
aComplexColor.addTransformation({model::TransformationType::LumMod, 
pIntItem->GetValue()});
-                }
-                if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_OFF, false, &pItem) 
== SfxItemState::SET)
-                {
-                    auto pIntItem = static_cast<const SfxInt16Item*>(pItem);
-                    
aComplexColor.addTransformation({model::TransformationType::LumOff, 
pIntItem->GetValue()});
-                }
-                aColorItem.setComplexColor(aComplexColor);
-                pArgs->Put(aColorItem);
-            }
-        }
     }
 }
 
@@ -693,7 +664,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             if( rReq.GetArgs() )
             {
                 std::unique_ptr<SfxItemSet> pNewArgs = rReq.GetArgs()->Clone();
-                lcl_convertStringArguments(rReq.GetSlot(), pNewArgs);
+                lcl_convertStringArguments(pNewArgs);
                 mpDrawView->SetAttributes(*pNewArgs);
                 rReq.Done();
             }
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 1bd70a35c084..fad6109d6add 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -1519,7 +1519,7 @@ SfxVoidItem ClearOutline SID_OUTLINE_DELETEALL
 
 
 SvxColorItem Color SID_ATTR_CHAR_COLOR
-(SvxColorItem Color SID_ATTR_CHAR_COLOR, SfxInt16Item ColorThemeIndex 
SID_ATTR_COLOR_THEME_INDEX, SfxInt16Item ColorLumMod SID_ATTR_COLOR_LUM_MOD, 
SfxInt16Item ColorLumOff SID_ATTR_COLOR_LUM_OFF)
+(SvxColorItem Color SID_ATTR_CHAR_COLOR)
 [
     AutoUpdate = TRUE,
     FastCall = FALSE,
@@ -2811,7 +2811,7 @@ XFillBitmapItem FillPageBitmap SID_ATTR_PAGE_BITMAP
 ]
 
 XFillColorItem FillColor SID_ATTR_FILL_COLOR
-(XFillColorItem FillColor SID_ATTR_FILL_COLOR, SfxInt16Item ColorThemeIndex 
SID_ATTR_COLOR_THEME_INDEX, SfxInt16Item ColorLumMod SID_ATTR_COLOR_LUM_MOD, 
SfxInt16Item ColorLumOff SID_ATTR_COLOR_LUM_OFF)
+(XFillColorItem FillColor SID_ATTR_FILL_COLOR)
 [
     AutoUpdate = TRUE,
     FastCall = FALSE,

Reply via email to