[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sc/source vcl/inc vcl/jsdialog

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 8 15:00:38 UTC 2021


 include/vcl/jsdialog/executor.hxx    |    1 +
 sc/source/ui/cctrl/checklistmenu.cxx |    9 +--------
 vcl/inc/jsdialog/jsdialogbuilder.hxx |   25 ++++++++++++++++++++-----
 vcl/jsdialog/executor.cxx            |   11 +++++++++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   14 +++++++++-----
 5 files changed, 42 insertions(+), 18 deletions(-)

New commits:
commit e2e63b2bc9530e8836c2c5e4cda42acb0f5af945
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Feb 8 12:37:38 2021 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Feb 8 15:59:57 2021 +0100

    jsdialog autofilter: show submenu on demad
    
    - add posibility to trigger full update
    - send information if docking window is visible
    - send close message on builder destruction
    
    Change-Id: I0b3abc5ebcacf7f9a48910edf1bf0d73e8120d6e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110577
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/vcl/jsdialog/executor.hxx b/include/vcl/jsdialog/executor.hxx
index 159b1dccd730..713afaff9082 100644
--- a/include/vcl/jsdialog/executor.hxx
+++ b/include/vcl/jsdialog/executor.hxx
@@ -59,6 +59,7 @@ public:
 namespace jsdialog
 {
 VCL_DLLPUBLIC bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rData);
+VCL_DLLPUBLIC void SendFullUpdate(sal_uInt64 nWindowId, const OString& rWidget);
 VCL_DLLPUBLIC StringMap jsonToStringMap(const char* pJSON);
 };
 
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 526a277c6af3..b269760b0010 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -298,15 +298,8 @@ void ScCheckListMenuControl::launchSubMenu(bool bSetMenuPos)
     mxMenu->select(*mxScratchIter);
     rSubMenuControl.GrabFocus();
 
-    // TODO: something better to retrigger JSON dialog invalidation
     if (comphelper::LibreOfficeKit::isActive())
-    {
-        StringMap args;
-        args["cmd"] = "change";
-        args["type"] = "checkbox";
-        args["data"] = "true";
-        jsdialog::ExecuteAction(pSubMenu->GetLOKWindowId(), "toggle_all", args);
-    }
+        jsdialog::SendFullUpdate(pSubMenu->GetLOKWindowId(), "toggle_all");
 }
 
 IMPL_LINK_NOARG(ScCheckListMenuControl, PostPopdownHdl, void*, void)
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 07158c8db0d2..00d94d8a03b5 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -86,7 +86,7 @@ public:
         initializeSender(aNotifierWindow, aContentWindow, sTypeOfJSON);
     }
 
-    virtual ~JSDialogSender() = default;
+    virtual ~JSDialogSender();
 
     virtual void sendFullUpdate(bool bForce = false);
     void sendClose();
@@ -148,6 +148,8 @@ class JSInstanceBuilder : public SalInstanceBuilder, public JSDialogSender
 
     friend VCL_DLLPUBLIC bool jsdialog::ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget,
                                                       StringMap& rData);
+    friend VCL_DLLPUBLIC void jsdialog::SendFullUpdate(sal_uInt64 nWindowId,
+                                                       const OString& rWidget);
 
     static std::map<sal_uInt64, WidgetMap>& GetLOKWeldWidgetsMap();
     static void InsertWindowToMap(sal_uInt64 nWindowId);
@@ -221,7 +223,20 @@ private:
     VclPtr<vcl::Window>& GetNotifierWindow();
 };
 
-template <class BaseInstanceClass, class VclClass> class JSWidget : public BaseInstanceClass
+class BaseJSWidget
+{
+public:
+    virtual ~BaseJSWidget() = default;
+
+    virtual void sendClose() = 0;
+
+    virtual void sendUpdate(bool bForce = false) = 0;
+
+    virtual void sendFullUpdate(bool bForce = false) = 0;
+};
+
+template <class BaseInstanceClass, class VclClass>
+class JSWidget : public BaseInstanceClass, public BaseJSWidget
 {
 protected:
     rtl::Reference<JSDropTarget> m_xDropTarget;
@@ -290,19 +305,19 @@ public:
         m_bIsFreezed = false;
     }
 
-    void sendClose()
+    virtual void sendClose() override
     {
         if (m_pSender)
             m_pSender->sendClose();
     }
 
-    void sendUpdate(bool bForce = false)
+    virtual void sendUpdate(bool bForce = false) override
     {
         if (!m_bIsFreezed && m_pSender)
             m_pSender->sendUpdate(BaseInstanceClass::m_xWidget, bForce);
     }
 
-    void sendFullUpdate(bool bForce = false)
+    virtual void sendFullUpdate(bool bForce = false) override
     {
         if ((!m_bIsFreezed || bForce) && m_pSender)
             m_pSender->sendFullUpdate(bForce);
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index f8a1f938bfb2..937064875248 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -33,6 +33,17 @@ StringMap jsonToStringMap(const char* pJSON)
     return aArgs;
 }
 
+void SendFullUpdate(sal_uInt64 nWindowId, const OString& rWidget)
+{
+    weld::Widget* pWidget = JSInstanceBuilder::FindWeldWidgetsMap(nWindowId, rWidget);
+
+    if (pWidget != nullptr)
+    {
+        auto pJSWidget = dynamic_cast<BaseJSWidget*>(pWidget);
+        pJSWidget->sendFullUpdate();
+    }
+}
+
 bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rData)
 {
     weld::Widget* pWidget = JSInstanceBuilder::FindWeldWidgetsMap(nWindowId, rWidget);
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 80f9882c85fe..a07ac1959573 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -91,18 +91,20 @@ boost::property_tree::ptree JSDialogNotifyIdle::generateFullUpdate() const
     if (m_sTypeOfJSON == "autofilter")
     {
         vcl::Window* pWindow = m_aContentWindow.get();
-        DockingWindow* pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
-        while (pWindow && !pDockingWIndow)
+        DockingWindow* pDockingWindow = dynamic_cast<DockingWindow*>(pWindow);
+        while (pWindow && !pDockingWindow)
         {
             pWindow = pWindow->GetParent();
-            pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
+            pDockingWindow = dynamic_cast<DockingWindow*>(pWindow);
         }
 
-        if (pDockingWIndow)
+        if (pDockingWindow)
         {
-            Point aPos = pDockingWIndow->GetFloatingPos();
+            Point aPos = pDockingWindow->GetFloatingPos();
             aTree.put("posx", aPos.getX());
             aTree.put("posy", aPos.getY());
+            if (!pDockingWindow->IsVisible())
+                aTree.put("visible", "false");
         }
     }
 
@@ -158,6 +160,8 @@ void JSDialogNotifyIdle::Invoke()
     m_aMessageQueue.clear();
 }
 
+JSDialogSender::~JSDialogSender() { sendClose(); }
+
 void JSDialogSender::sendFullUpdate(bool bForce)
 {
     if (bForce)


More information about the Libreoffice-commits mailing list