include/svx/theme/IThemeColorChanger.hxx      |   10 +++++-
 include/svx/theme/ThemeColorChangerCommon.hxx |    3 +
 sc/source/ui/inc/ThemeColorChanger.hxx        |    2 -
 sc/source/ui/theme/ThemeColorChanger.cxx      |    4 +-
 sc/source/ui/view/tabvwshc.cxx                |    7 ++++
 sd/inc/theme/ThemeColorChanger.hxx            |    2 -
 sd/source/core/ThemeColorChanger.cxx          |    4 +-
 sd/source/ui/view/ViewShellBase.cxx           |    7 +++-
 sd/source/ui/view/drviews2.cxx                |    8 ----
 svx/source/theme/ThemeColorChangerCommon.cxx  |   43 +++++++++++++++++---------
 sw/source/core/inc/ThemeColorChanger.hxx      |    2 -
 sw/source/core/model/ThemeColorChanger.cxx    |    4 +-
 sw/source/uibase/shells/basesh.cxx            |    7 ----
 sw/source/uibase/uiview/view.cxx              |    5 +--
 14 files changed, 64 insertions(+), 44 deletions(-)

New commits:
commit 5148c8411ffb6ae9a0411678d01b67fe7f097725
Author:     Szymon Kłos <[email protected]>
AuthorDate: Sun Jan 7 18:31:22 2024 +0100
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Jan 9 07:51:31 2024 +0100

    sc: announce theme colors with lok callback
    
    As it is done already for Writer. Unfortunately cannot
    move the code from afterCallbackRegistered to base class
    in sfx2 as it is not linked to svx which is needed to
    generate JSON. So at least share generation and sending
    part in ThemeColorChangerCommon.
    
    Signed-off-by: Szymon Kłos <[email protected]>
    Change-Id: Icbf681230bd4c49698c47d852a0862620d93bcec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161771
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/include/svx/theme/IThemeColorChanger.hxx 
b/include/svx/theme/IThemeColorChanger.hxx
index d9273238c712..0b3b88d60afa 100644
--- a/include/svx/theme/IThemeColorChanger.hxx
+++ b/include/svx/theme/IThemeColorChanger.hxx
@@ -11,6 +11,7 @@
 
 #include <svx/svxdllapi.h>
 #include <docmodel/theme/ColorSet.hxx>
+#include "ThemeColorChangerCommon.hxx"
 
 namespace svx
 {
@@ -18,7 +19,14 @@ class SVXCORE_DLLPUBLIC IThemeColorChanger
 {
 public:
     virtual ~IThemeColorChanger() = default;
-    virtual void apply(std::shared_ptr<model::ColorSet> const& pColorSet) = 0;
+    void apply(std::shared_ptr<model::ColorSet> const& pColorSet)
+    {
+        doApply(pColorSet);
+        svx::theme::notifyLOK(pColorSet);
+    }
+
+private:
+    virtual void doApply(std::shared_ptr<model::ColorSet> const& pColorSet) = 
0;
 };
 
 } // end svx namespace
diff --git a/include/svx/theme/ThemeColorChangerCommon.hxx 
b/include/svx/theme/ThemeColorChangerCommon.hxx
index d60d9c1ba7fb..f40fb639878d 100644
--- a/include/svx/theme/ThemeColorChangerCommon.hxx
+++ b/include/svx/theme/ThemeColorChangerCommon.hxx
@@ -10,7 +10,6 @@
 #pragma once
 
 #include <svx/svxdllapi.h>
-#include <svx/theme/IThemeColorChanger.hxx>
 #include <docmodel/theme/ColorSet.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/svdobj.hxx>
@@ -23,6 +22,8 @@ namespace theme
 {
 SVXCORE_DLLPUBLIC void updateSdrObject(model::ColorSet const& rColorSet, 
SdrObject* pObject,
                                        SdrView* pView, SfxUndoManager* 
pUndoManager = nullptr);
+
+SVXCORE_DLLPUBLIC void notifyLOK(std::shared_ptr<model::ColorSet> const& 
pColorSet);
 }
 
 } // end svx namespace
diff --git a/sc/source/ui/inc/ThemeColorChanger.hxx 
b/sc/source/ui/inc/ThemeColorChanger.hxx
index 57ca91cdb83c..f85401385888 100644
--- a/sc/source/ui/inc/ThemeColorChanger.hxx
+++ b/sc/source/ui/inc/ThemeColorChanger.hxx
@@ -24,7 +24,7 @@ public:
     ThemeColorChanger(ScDocShell& rDocShell);
     virtual ~ThemeColorChanger() override;
 
-    void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
+    void doApply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
 };
 
 } // end sc namespace
diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx 
b/sc/source/ui/theme/ThemeColorChanger.cxx
index c9b88652dcc3..2ba881544372 100644
--- a/sc/source/ui/theme/ThemeColorChanger.cxx
+++ b/sc/source/ui/theme/ThemeColorChanger.cxx
@@ -19,7 +19,7 @@
 #include <editeng/boxitem.hxx>
 #include <editeng/borderline.hxx>
 #include <svx/svditer.hxx>
-#include <svx/theme/ThemeColorChangerCommon.hxx>
+#include <svx/theme/IThemeColorChanger.hxx>
 
 #include <undodraw.hxx>
 #include <stlpool.hxx>
@@ -311,7 +311,7 @@ void changeThemeColorInTheDocModel(ScDocShell& rDocShell,
 
 } // end anonymous ns
 
-void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
+void ThemeColorChanger::doApply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
 {
     // Can't change to an empty color set
     if (!pColorSet)
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 34463e8dd963..116283f48bea 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -20,6 +20,7 @@
 #include <scitems.hxx>
 #include <sfx2/childwin.hxx>
 #include <sfx2/dispatch.hxx>
+#include <svx/theme/ThemeColorChangerCommon.hxx>
 #include <editeng/editview.hxx>
 #include <inputhdl.hxx>
 
@@ -474,6 +475,12 @@ void ScTabViewShell::afterCallbackRegistered()
             pInputWindow->NotifyLOKClient();
         }
     }
+
+    SfxObjectShell* pDocShell = GetObjectShell();
+    if (pDocShell)
+    {
+        svx::theme::notifyLOK(pDocShell->GetThemeColors());
+    }
 }
 
 void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const
diff --git a/sd/inc/theme/ThemeColorChanger.hxx 
b/sd/inc/theme/ThemeColorChanger.hxx
index 72ae70a0ea3c..4304fdd6fff5 100644
--- a/sd/inc/theme/ThemeColorChanger.hxx
+++ b/sd/inc/theme/ThemeColorChanger.hxx
@@ -28,7 +28,7 @@ public:
     ThemeColorChanger(SdrPage* pMasterPage, sd::DrawDocShell* pDocShell);
     virtual ~ThemeColorChanger() override;
 
-    void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
+    void doApply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
 };
 
 } // end sd namespace
diff --git a/sd/source/core/ThemeColorChanger.cxx 
b/sd/source/core/ThemeColorChanger.cxx
index 3a5c7804ae57..1c06ae5df55a 100644
--- a/sd/source/core/ThemeColorChanger.cxx
+++ b/sd/source/core/ThemeColorChanger.cxx
@@ -8,7 +8,7 @@
  */
 
 #include <theme/ThemeColorChanger.hxx>
-#include <svx/theme/ThemeColorChangerCommon.hxx>
+#include <svx/theme/IThemeColorChanger.hxx>
 #include <svx/svdmodel.hxx>
 #include <svx/svditer.hxx>
 #include <docmodel/theme/Theme.hxx>
@@ -132,7 +132,7 @@ bool changeStyles(sd::DrawDocShell* pDocShell, 
std::shared_ptr<model::ColorSet>
 
 } // end anonymous ns
 
-void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
+void ThemeColorChanger::doApply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
 {
     auto* pUndoManager = mpDocShell->GetUndoManager();
     sd::ViewShell* pViewShell = mpDocShell->GetViewShell();
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index 8b88da65aa1e..06c69d31c965 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -62,6 +62,7 @@
 #include <sfx2/objface.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <svl/whiter.hxx>
+#include <svx/theme/ThemeColorChangerCommon.hxx>
 #include <vcl/commandinfoprovider.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
@@ -1019,7 +1020,11 @@ void ViewShellBase::afterCallbackRegistered()
     // common tasks
     SfxViewShell::afterCallbackRegistered();
 
-    // TODO: Add theme color palette changed callback
+    SfxObjectShell* pDocShell = GetObjectShell();
+    if (pDocShell)
+    {
+        svx::theme::notifyLOK(pDocShell->GetThemeColors());
+    }
 }
 
 void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 8a4cb4fac976..f86c0f115587 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -188,8 +188,6 @@
 
 #include <theme/ThemeColorChanger.hxx>
 #include <svx/dialog/ThemeDialog.hxx>
-#include <svx/theme/ThemeColorPaletteManager.hxx>
-#include <sfx2/lokhelper.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <ViewShellBase.hxx>
@@ -3571,12 +3569,6 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                 {
                     sd::ThemeColorChanger aChanger(pMasterPage, pDocShell);
                     aChanger.apply(pColorSet);
-
-                    if (comphelper::LibreOfficeKit::isActive())
-                    {
-                        svx::ThemeColorPaletteManager aManager(pColorSet);
-                        
SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON());
-                    }
                 }
             });
 
diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx 
b/svx/source/theme/ThemeColorChangerCommon.cxx
index 5ff1a0de8cd6..f5f660b657a4 100644
--- a/svx/source/theme/ThemeColorChangerCommon.cxx
+++ b/svx/source/theme/ThemeColorChangerCommon.cxx
@@ -7,12 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <svx/theme/ThemeColorChangerCommon.hxx>
-
-#include <sal/config.h>
-#include <editeng/unoprnms.hxx>
-#include <docmodel/uno/UnoComplexColor.hxx>
-#include <docmodel/theme/ColorSet.hxx>
+#include <comphelper/lok.hxx>
 
 #include <com/sun/star/text/XTextRange.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
@@ -20,17 +15,28 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/util/XComplexColor.hpp>
 
-#include <svx/xlnclit.hxx>
-#include <svx/xflclit.hxx>
-#include <svx/xdef.hxx>
-#include <editeng/eeitem.hxx>
-#include <svx/svdundo.hxx>
-#include <svx/svdmodel.hxx>
-#include <svx/svdotext.hxx>
+#include <docmodel/uno/UnoComplexColor.hxx>
+#include <docmodel/theme/ColorSet.hxx>
 
 #include <editeng/editeng.hxx>
-#include <editeng/section.hxx>
 #include <editeng/eeitem.hxx>
+#include <editeng/section.hxx>
+#include <editeng/unoprnms.hxx>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
+#include <sal/config.h>
+
+#include <sfx2/lokhelper.hxx>
+
+#include <svx/svdmodel.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/theme/ThemeColorChangerCommon.hxx>
+#include <svx/theme/ThemeColorPaletteManager.hxx>
+#include <svx/xdef.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xflclit.hxx>
 
 using namespace css;
 
@@ -172,6 +178,15 @@ void updateSdrObject(model::ColorSet const& rColorSet, 
SdrObject* pObject, SdrVi
         updateEditEngTextSections(rColorSet, pObject, *pView);
 }
 
+void notifyLOK(std::shared_ptr<model::ColorSet> const& pColorSet)
+{
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        svx::ThemeColorPaletteManager aManager(pColorSet);
+        SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON());
+    }
+}
+
 } // end svx::theme namespace
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/ThemeColorChanger.hxx 
b/sw/source/core/inc/ThemeColorChanger.hxx
index 6eeb3a25f612..f919496fd595 100644
--- a/sw/source/core/inc/ThemeColorChanger.hxx
+++ b/sw/source/core/inc/ThemeColorChanger.hxx
@@ -25,7 +25,7 @@ public:
     ThemeColorChanger(SwDocShell* pDocSh);
     virtual ~ThemeColorChanger() override;
 
-    void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
+    void doApply(std::shared_ptr<model::ColorSet> const& pColorSet) override;
 };
 
 } // end sw namespace
diff --git a/sw/source/core/model/ThemeColorChanger.cxx 
b/sw/source/core/model/ThemeColorChanger.cxx
index 74dca3154d67..5391c6983a61 100644
--- a/sw/source/core/model/ThemeColorChanger.cxx
+++ b/sw/source/core/model/ThemeColorChanger.cxx
@@ -34,7 +34,7 @@
 #include <sal/config.h>
 #include <svx/svdpage.hxx>
 #include <svx/svditer.hxx>
-#include <svx/theme/ThemeColorChangerCommon.hxx>
+#include <svx/theme/IThemeColorChanger.hxx>
 #include <docmodel/uno/UnoComplexColor.hxx>
 #include <docmodel/theme/Theme.hxx>
 #include <editeng/unoprnms.hxx>
@@ -322,7 +322,7 @@ ThemeColorChanger::ThemeColorChanger(SwDocShell* pDocSh)
 
 ThemeColorChanger::~ThemeColorChanger() = default;
 
-void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
+void ThemeColorChanger::doApply(std::shared_ptr<model::ColorSet> const& 
pColorSet)
 {
     SwDoc* pDocument = mpDocSh->GetDoc();
     if (!pDocument)
diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index a2b415cf27c9..df26a1ff117c 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -91,7 +91,6 @@
 #include <SwRewriter.hxx>
 #include <GraphicSizeCheck.hxx>
 #include <svx/galleryitem.hxx>
-#include <svx/theme/ThemeColorPaletteManager.hxx>
 #include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
 #include <com/sun/star/gallery/GalleryItemType.hpp>
 #include <com/sun/star/beans/PropertyValues.hpp>
@@ -102,7 +101,6 @@
 #include <svx/dialog/ThemeDialog.hxx>
 #include <comphelper/scopeguard.hxx>
 #include <comphelper/lok.hxx>
-#include <sfx2/lokhelper.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <osl/diagnose.h>
 
@@ -3096,11 +3094,6 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
                         if (pColorSet)
                         {
                             pChanger->apply(pColorSet);
-                            if (comphelper::LibreOfficeKit::isActive())
-                            {
-                                svx::ThemeColorPaletteManager 
aManager(pColorSet);
-                                
SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON());
-                            }
                         }
                     });
                 }
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 00d4ba26df31..c5bc51ea4ce1 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -102,7 +102,7 @@
 #include <PostItMgr.hxx>
 #include <annotsh.hxx>
 #include <swruler.hxx>
-#include <svx/theme/ThemeColorPaletteManager.hxx>
+#include <svx/theme/ThemeColorChangerCommon.hxx>
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 
@@ -1195,8 +1195,7 @@ void SwView::afterCallbackRegistered()
     auto* pDocShell = GetDocShell();
     if (pDocShell)
     {
-        svx::ThemeColorPaletteManager aManager(pDocShell->GetThemeColors());
-        libreOfficeKitViewCallback(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON().getStr());
+        svx::theme::notifyLOK(pDocShell->GetThemeColors());
     }
 }
 

Reply via email to