[Libreoffice-commits] core.git: include/vcl sc/source vcl/inc vcl/jsdialog

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 8 17:37:00 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 598ffe47a7f47157d891ad97d1edef032208d9f4
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 18:36:11 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/+/110578
    Tested-by: Jenkins
    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 00d8a882d80c..dcd287527ca6 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -294,15 +294,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 267dc960ecd9..4be8eee0d0c0 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -84,7 +84,7 @@ public:
         initializeSender(aNotifierWindow, aContentWindow, sTypeOfJSON);
     }
 
-    virtual ~JSDialogSender() = default;
+    virtual ~JSDialogSender();
 
     virtual void sendFullUpdate(bool bForce = false);
     void sendClose();
@@ -146,6 +146,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);
@@ -204,7 +206,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;
@@ -272,19 +287,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 1de6db627f96..53f70630fe1c 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -34,6 +34,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 9fd33ae26b3a..8c14e93e4a72 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -97,18 +97,20 @@ std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateFullUpdate() cons
     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();
             aJsonWriter->put("posx", aPos.getX());
             aJsonWriter->put("posy", aPos.getY());
+            if (!pDockingWindow->IsVisible())
+                aJsonWriter->put("visible", "false");
         }
     }
 
@@ -167,6 +169,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