summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-02-08 12:37:38 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-02-08 15:59:57 +0100
commite2e63b2bc9530e8836c2c5e4cda42acb0f5af945 (patch)
tree37a3adf48794558e45d6921305a54e6a71e26a09
parentcb2e6cbd490804fc2d29171b982b14aedd37dc65 (diff)
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@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--include/vcl/jsdialog/executor.hxx1
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx9
-rw-r--r--vcl/inc/jsdialog/jsdialogbuilder.hxx25
-rw-r--r--vcl/jsdialog/executor.cxx11
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx14
5 files changed, 42 insertions, 18 deletions
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)