svx/source/sidebar/text/TextCharacterSpacingControl.cxx |   19 +++++++++-------
 svx/source/sidebar/text/TextUnderlineControl.cxx        |   19 ++++++++++++----
 2 files changed, 26 insertions(+), 12 deletions(-)

New commits:
commit 449d7bad692a6cab1fa925abe2434b72120d1160
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Mon Apr 14 04:00:44 2025 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Apr 15 15:16:21 2025 +0200

    svx: new dispatch for 2 uno commands
    
    Replaced TextUnderlineControl Underline, and
    TextCharacterSpacingControl CharKerning uno command dispatch.
    If a chart was selected, these commands was not sent to them,
    but now they are sent to the chart, so we can implement a way
    to parse them there.
    
    Change-Id: I5258c952457c7173cda2e893ffab8a0f81d94f9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184127
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx 
b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
index afe12502a4e0..80c9c9d73652 100644
--- a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
@@ -23,6 +23,7 @@
 #include <editeng/kernitem.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/dispatch.hxx>
+#include <sfx2/tbxctrl.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <TextCharacterSpacingPopup.hxx>
 #include <svl/itempool.hxx>
@@ -30,6 +31,8 @@
 #include <helpids.h>
 
 #include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
 
 #define SPACING_VERY_TIGHT  -30
 #define SPACING_TIGHT       -15
@@ -155,7 +158,7 @@ void TextCharacterSpacingControl::Initialize()
 
 void TextCharacterSpacingControl::ExecuteCharacterSpacing(tools::Long nValue, 
bool bClose)
 {
-    MapUnit eUnit = GetCoreMetric();
+    MapUnit eUnit = MapUnit::Map100thMM;
 
     tools::Long nSign = (nValue < 0) ? -1 : 1;
     nValue = nValue * nSign;
@@ -163,13 +166,13 @@ void 
TextCharacterSpacingControl::ExecuteCharacterSpacing(tools::Long nValue, bo
     tools::Long nVal = OutputDevice::LogicToLogic(nValue, MapUnit::MapPoint, 
eUnit);
     short nKern = (nValue == 0) ? 0 : 
static_cast<short>(mxEditKerning->denormalize(nVal));
 
-    SvxKerningItem aKernItem(nSign * nKern, SID_ATTR_CHAR_KERNING);
-
-    if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
-    {
-        
pViewFrm->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
-            SfxCallMode::RECORD, { &aKernItem });
-    }
+    css::uno::Sequence<css::beans::PropertyValue> aArgs(1);
+    css::beans::PropertyValue* pArgs = aArgs.getArray();
+    pArgs[0].Name = "Spacing";
+    pArgs[0].Value <<= sal_Int16(nSign * nKern);
+    const css::uno::Reference<com::sun::star::frame::XDispatchProvider> 
xProvider(
+        m_xFrame, css::uno::UNO_QUERY);
+    SfxToolBoxControl::Dispatch(xProvider, u".uno:Spacing"_ustr, aArgs);
 
     if (bClose)
         mxControl->EndPopupMode();
diff --git a/svx/source/sidebar/text/TextUnderlineControl.cxx 
b/svx/source/sidebar/text/TextUnderlineControl.cxx
index 42457cc7ba6b..03156430187f 100644
--- a/svx/source/sidebar/text/TextUnderlineControl.cxx
+++ b/svx/source/sidebar/text/TextUnderlineControl.cxx
@@ -25,6 +25,8 @@
 #include <editeng/udlnitem.hxx>
 #include <svl/itemset.hxx>
 #include <helpids.h>
+#include <sfx2/tbxctrl.hxx>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
 
 namespace svx {
 
@@ -128,11 +130,20 @@ IMPL_LINK(TextUnderlineControl, PBClickHdl, 
weld::Button&, rButton, void)
         {
             const FontLineStyle eUnderline = getLineStyle(rButton);
 
-            SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
-            aLineItem.SetColor(GetUnderlineColor());
+            css::uno::Sequence<css::beans::PropertyValue> aArgs(3);
+            css::beans::PropertyValue* pArgs = aArgs.getArray();
+            pArgs[0].Name = "Underline.LineStyle";
+            pArgs[0].Value <<= sal_Int32(eUnderline);
 
-            
pViewFrm->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_UNDERLINE,
-                   SfxCallMode::RECORD, { &aLineItem });
+            Color aColor(GetUnderlineColor());
+            pArgs[1].Name = "Underline.HasColor";
+            pArgs[1].Value <<= (aColor.GetAlpha() == 255);
+
+            pArgs[2].Name = "Underline.Color";
+            pArgs[2].Value <<= aColor;
+            const 
css::uno::Reference<com::sun::star::frame::XDispatchProvider> xProvider(
+                m_xFrame, css::uno::UNO_QUERY);
+            SfxToolBoxControl::Dispatch(xProvider, u".uno:Underline"_ustr, 
aArgs);
         }
     }
     mxControl->EndPopupMode();

Reply via email to