include/svx/theme/IThemeColorChanger.hxx      |   10 ++++++-
 include/svx/theme/ThemeColorChangerCommon.hxx |    2 +
 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/inc/ViewShellBase.hxx            |    2 +
 sd/source/ui/view/ViewShellBase.cxx           |   13 +++++++++
 sd/source/ui/view/drviews2.cxx                |    8 -----
 svx/source/theme/ThemeColorChangerCommon.cxx  |   36 ++++++++++++++++++--------
 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 +--
 15 files changed, 70 insertions(+), 38 deletions(-)

New commits:
commit 13e055808461f92be68f7691392b23159ac9a1ba
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Sun Jan 7 18:31:22 2024 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Jan 12 08:04:34 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 <szymon.k...@collabora.com>
    Change-Id: Icbf681230bd4c49698c47d852a0862620d93bcec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161771
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161927
    Tested-by: Jenkins

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 febc34ae3873..3a585236fbf8 100644
--- a/include/svx/theme/ThemeColorChangerCommon.hxx
+++ b/include/svx/theme/ThemeColorChangerCommon.hxx
@@ -21,6 +21,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 0c214a02eb67..eeb554454eab 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>
 
@@ -477,6 +478,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 ff100fd511ce..6a467bc4c47a 100644
--- a/sd/inc/theme/ThemeColorChanger.hxx
+++ b/sd/inc/theme/ThemeColorChanger.hxx
@@ -27,7 +27,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 70d14bc37438..b941407881ed 100644
--- a/sd/source/core/ThemeColorChanger.cxx
+++ b/sd/source/core/ThemeColorChanger.cxx
@@ -9,7 +9,7 @@
 
 #include <editeng/colritem.hxx>
 #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>
@@ -133,7 +133,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/inc/ViewShellBase.hxx 
b/sd/source/ui/inc/ViewShellBase.hxx
index acdd244c70f3..e31429f6e41a 100644
--- a/sd/source/ui/inc/ViewShellBase.hxx
+++ b/sd/source/ui/inc/ViewShellBase.hxx
@@ -217,6 +217,8 @@ public:
     int getEditMode() const override;
     /// See SfxViewShell::setEditMode().
     void setEditMode(int nMode);
+    /// See SfxViewShell::afterCallbackRegistered().
+    void afterCallbackRegistered() override;
     /// See SfxViewShell::NotifyCursor().
     void NotifyCursor(SfxViewShell* pViewShell) const override;
     /// See SfxViewShell::GetColorConfigColor().
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index 9e8e7b1aa5d4..6ba412acf7d9 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>
@@ -1010,6 +1011,18 @@ void ViewShellBase::setEditMode(int nMode)
     }
 }
 
+void ViewShellBase::afterCallbackRegistered()
+{
+    // common tasks
+    SfxViewShell::afterCallbackRegistered();
+
+    SfxObjectShell* pDocShell = GetObjectShell();
+    if (pDocShell)
+    {
+        svx::theme::notifyLOK(pDocShell->GetThemeColors());
+    }
+}
+
 void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const
 {
     ViewShell* pThisShell = 
framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 8358e95cf8a9..b47fe474c68f 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>
@@ -3566,12 +3564,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 a41e53b7e30b..0e3548ed83cc 100644
--- a/svx/source/theme/ThemeColorChangerCommon.cxx
+++ b/svx/source/theme/ThemeColorChangerCommon.cxx
@@ -7,22 +7,29 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <svx/theme/ThemeColorChangerCommon.hxx>
+#include <comphelper/lok.hxx>
 
-#include <sal/config.h>
-#include <editeng/colritem.hxx>
 #include <docmodel/theme/ColorSet.hxx>
 
-#include <svx/xlnclit.hxx>
-#include <svx/xflclit.hxx>
-#include <svx/xdef.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/editeng.hxx>
 #include <editeng/eeitem.hxx>
-#include <svx/svdundo.hxx>
+#include <editeng/section.hxx>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
+#include <sal/config.h>
+
+#include <sfx2/lokhelper.hxx>
+
 #include <svx/svdmodel.hxx>
 #include <svx/svdotext.hxx>
-
-#include <editeng/editeng.hxx>
-#include <editeng/section.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;
 
@@ -164,6 +171,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 8cbc0b971066..c61ea96b2a5a 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 c96945ccdf30..5c5af8c3581a 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>
 
@@ -2981,11 +2979,6 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
                         if (pColorSet)
                         {
                             xChanger->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 ac1c15e95e26..d21738670d8b 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>
 
@@ -1218,8 +1218,7 @@ void SwView::afterCallbackRegistered()
     auto* pDocShell = GetDocShell();
     if (pDocShell)
     {
-        svx::ThemeColorPaletteManager aManager(pDocShell->GetThemeColors());
-        libreOfficeKitViewCallback(LOK_CALLBACK_COLOR_PALETTES, 
aManager.generateJSON());
+        svx::theme::notifyLOK(pDocShell->GetThemeColors());
     }
 }
 

Reply via email to