vcl/inc/jsdialog/jsdialogbuilder.hxx | 18 +++ vcl/jsdialog/jsdialogbuilder.cxx | 163 ++++++++++++++++++++++++++++++----- 2 files changed, 159 insertions(+), 22 deletions(-)
New commits: commit 2fdfd5ca5a479fa94f96ca1cad2f68806b69504b Author: Szymon Kłos <[email protected]> AuthorDate: Wed Dec 30 10:05:26 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 12:01:43 2021 +0200 Revert "jsdialog: disable idle notify" This reverts commit 71ec214d7583f637fefcb5eca13c637cc6b38029. and partially 54b5e6b4e083ce7a71e16ef622753898f38dc8ab freeze/thaw functionality was added so no longer needed. Change-Id: Iee29fa79bcebfd409fd3cea4f11cb1d48053daa6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108509 Tested-by: Jenkins Reviewed-by: Szymon Kłos <[email protected]> diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index d7cb687b039d..0a378a11f65e 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1175,9 +1175,6 @@ public: /// Find an existing Window based on the LOKWindowId. static VclPtr<vcl::Window> FindLOKWindow(vcl::LOKWindowId nWindowId); - bool IsDisableIdleNotify(); - void SetDisableIdleNotify(bool bValue); - /// check if LOK Window container is empty static bool IsLOKWindowsEmpty(); diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index cdad380fd861..756f9d34767a 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -71,7 +71,6 @@ public: void notifyDialogState(bool bForce = false); void sendClose(); - void dumpStatus(); void sendUpdate(VclPtr<vcl::Window> pWindow); }; @@ -222,11 +221,6 @@ public: class JSDialog : public JSWidget<SalInstanceDialog, ::Dialog> { - DECL_LINK(on_dump_status, void*, void); - DECL_LINK(on_window_event, VclWindowEvent&, void); - - bool m_bNotifyCreated; - public: JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership, @@ -315,11 +309,6 @@ public: class JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender { - DECL_LINK(on_dump_status, void*, void); - DECL_LINK(on_window_event, VclWindowEvent&, void); - - bool m_bNotifyCreated; - public: JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership); diff --git a/vcl/inc/window.h b/vcl/inc/window.h index a6d46c41eeda..a14852ca02c0 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -117,8 +117,6 @@ struct ImplWinData sal_uInt16 mnIsTopWindow; bool mbMouseOver; //< tracks mouse over for native widget paint effect bool mbEnableNativeWidget; //< toggle native widget rendering - bool mbDisableIdleNotify; - ::std::list< VclPtr<vcl::Window> > maTopWindowChildren; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index f33d0be85fd5..df2d68e71c16 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -159,8 +159,7 @@ void JSDialogNotifyIdle::sendClose() { send(*generateCloseMessage()); } void JSDialogSender::notifyDialogState(bool bForce) { - auto aNotifierWnd = mpIdleNotify->getNotifierWindow(); - if (aNotifierWnd && aNotifierWnd->IsDisableIdleNotify()) + if (!mpIdleNotify->getNotifierWindow()) return; if (bForce) @@ -170,8 +169,6 @@ void JSDialogSender::notifyDialogState(bool bForce) void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); } -void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); } - void JSDialogSender::sendUpdate(VclPtr<vcl::Window> pWindow) { mpIdleNotify->updateStatus(pWindow); @@ -461,16 +458,13 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) m_xBuilder->drop_ownership(pDialog); m_bHasTopLevelDialog = true; - if (id == "MacroSelectorDialog") - pDialog->SetDisableIdleNotify(true); - pRet.reset( new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false, m_sTypeOfJSON)); RememberWidget("__DIALOG__", pRet.get()); const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); - if (pNotifier && id != "MacroSelectorDialog") + if (pNotifier) { tools::JsonWriter aJsonWriter; m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); @@ -497,14 +491,14 @@ std::unique_ptr<weld::MessageDialog> JSInstanceBuilder::weld_message_dialog(cons assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); m_aOwnedToplevel.set(pMessageDialog); m_xBuilder->drop_ownership(pMessageDialog); - - if (id == "MacroWarnMedium") - pMessageDialog->SetDisableIdleNotify(true); } pRet.reset(pMessageDialog ? new JSMessageDialog(pMessageDialog, m_aOwnedToplevel, this, false) : nullptr); + if (pRet) + RememberWidget("__DIALOG__", pRet.get()); + return pRet; } @@ -715,12 +709,7 @@ JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aCon std::string sTypeOfJSON) : JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, pDialog, pBuilder, bTakeOwnership, sTypeOfJSON) - , m_bNotifyCreated(false) { - if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) - { - pDialog->AddEventListener(LINK(this, JSDialog, on_window_event)); - } } void JSDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton) @@ -741,17 +730,6 @@ void JSDialog::response(int response) SalInstanceDialog::response(response); } -IMPL_LINK_NOARG(JSDialog, on_dump_status, void*, void) { JSDialogSender::dumpStatus(); } - -IMPL_LINK(JSDialog, on_window_event, VclWindowEvent&, rEvent, void) -{ - if (rEvent.GetId() == VclEventId::WindowShow && !m_bNotifyCreated) - { - Application::PostUserEvent(LINK(this, JSDialog, on_dump_status)); - m_bNotifyCreated = true; - } -} - JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) @@ -908,12 +886,7 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> a SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) , JSDialogSender(m_xMessageDialog, aContentWindow, "dialog") - , m_bNotifyCreated(false) { - if (aContentWindow && aContentWindow->IsDisableIdleNotify()) - { - pDialog->AddEventListener(LINK(this, JSMessageDialog, on_window_event)); - } } void JSMessageDialog::set_primary_text(const OUString& rText) @@ -928,21 +901,6 @@ void JSMessageDialog::set_secondary_text(const OUString& rText) notifyDialogState(); } -IMPL_LINK_NOARG(JSMessageDialog, on_dump_status, void*, void) { JSDialogSender::dumpStatus(); } - -IMPL_LINK(JSMessageDialog, on_window_event, VclWindowEvent&, rEvent, void) -{ - if (rEvent.GetId() == VclEventId::WindowShow && !m_bNotifyCreated) - { - Application::PostUserEvent(LINK(this, JSMessageDialog, on_dump_status)); - m_bNotifyCreated = true; - } - else if (rEvent.GetId() == VclEventId::WindowHide || rEvent.GetId() == VclEventId::WindowClose) - { - sendClose(); - } -} - JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 3aac45364597..5e6d92b47ef9 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -755,8 +755,7 @@ ImplWinData::ImplWinData() : mnTrackFlags(ShowTrackFlags::NONE), mnIsTopWindow(sal_uInt16(~0)), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mbMouseOver(false), - mbEnableNativeWidget(false), - mbDisableIdleNotify(false) + mbEnableNativeWidget(false) { } @@ -3178,17 +3177,6 @@ VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId) return VclPtr<Window>(); } -bool Window::IsDisableIdleNotify() -{ - return ImplGetWinData()->mbDisableIdleNotify; -} - -void Window::SetDisableIdleNotify(bool bValue) -{ - if (ImplGetWinData()->mbDisableIdleNotify != bValue) - ImplGetWinData()->mbDisableIdleNotify = bValue; -} - bool Window::IsLOKWindowsEmpty() { return GetLOKWindowsMap().empty(); commit e27857accc258edf2320e206196d967682bf5ce3 Author: Szymon Kłos <[email protected]> AuthorDate: Tue Dec 29 09:36:50 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:58:43 2021 +0200 jsdialog: updates in similar fashion like other messages to unify all jsdialog interactions Change-Id: I22e14282f5a2c52ef44e68cb39338600004c4e24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108435 Tested-by: Jenkins Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 3352bac904d1..f33d0be85fd5 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -102,6 +102,7 @@ void JSDialogNotifyIdle::updateStatus(VclPtr<vcl::Window> pWindow) if (!m_aNotifierWindow) return; + // will be deprecated soon if (m_aNotifierWindow->IsReallyVisible()) { if (const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier()) @@ -124,6 +125,21 @@ void JSDialogNotifyIdle::updateStatus(VclPtr<vcl::Window> pWindow) aJsonWriter.extractData()); } } + + // new approach - update also if hidden + if (const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier()) + { + tools::JsonWriter aJsonWriter; + + aJsonWriter.put("jsontype", m_sTypeOfJSON); + aJsonWriter.put("action", "update"); + aJsonWriter.put("id", m_aNotifierWindow->GetLOKWindowId()); + { + auto aEntries = aJsonWriter.startNode("control"); + pWindow->DumpAsPropertyTree(aJsonWriter); + } + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData()); + } } std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateCloseMessage() const commit 48b27bd8277212142644fb4536fcbd226b82ae68 Author: Henry Castro <[email protected]> AuthorDate: Fri Jan 8 16:47:47 2021 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:58:33 2021 +0200 lok: fix initialization variable It should initialize false Change-Id: I67249bc8040688ee82bf12532178eb133f80b8e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109021 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index c3e783452452..3352bac904d1 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -699,11 +699,11 @@ JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aCon std::string sTypeOfJSON) : JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, pDialog, pBuilder, bTakeOwnership, sTypeOfJSON) + , m_bNotifyCreated(false) { if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) { pDialog->AddEventListener(LINK(this, JSDialog, on_window_event)); - m_bNotifyCreated = false; } } @@ -892,11 +892,11 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> a SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) , JSDialogSender(m_xMessageDialog, aContentWindow, "dialog") + , m_bNotifyCreated(false) { if (aContentWindow && aContentWindow->IsDisableIdleNotify()) { pDialog->AddEventListener(LINK(this, JSMessageDialog, on_window_event)); - m_bNotifyCreated = false; } } commit ae4fae990750a60fc6f6559a20d5db1c18bbc987 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Jan 8 20:28:42 2021 +0000 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:58:20 2021 +0200 cid#1470783 Logically dead code Change-Id: I0bf96d28904b84bb970c53d0cb732dc45aa2deb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109020 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 19f8780d2740..c3e783452452 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -448,9 +448,8 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) if (id == "MacroSelectorDialog") pDialog->SetDisableIdleNotify(true); - pRet.reset(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false, - m_sTypeOfJSON) - : nullptr); + pRet.reset( + new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false, m_sTypeOfJSON)); RememberWidget("__DIALOG__", pRet.get()); commit 8a31c30b3daeb70e280d17c1cf0b562a3a1009f3 Author: Henry Castro <[email protected]> AuthorDate: Fri Dec 25 13:29:42 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:57:57 2021 +0200 jsdialog: use the "WindowShow/WindowHide" to notify If the "Macro Security Warning" message dialog is disabled the idle notifier, then it is used, the "WindowShow/Window Hide" events to notify client side. Change-Id: I48281cf5b76285a86f951eb057454610e266b85f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108290 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 1c0a44ae548d..cdad380fd861 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -315,6 +315,11 @@ public: class JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender { + DECL_LINK(on_dump_status, void*, void); + DECL_LINK(on_window_event, VclWindowEvent&, void); + + bool m_bNotifyCreated; + public: JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership); diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 8fba06677b74..19f8780d2740 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -894,6 +894,11 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> a : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) , JSDialogSender(m_xMessageDialog, aContentWindow, "dialog") { + if (aContentWindow && aContentWindow->IsDisableIdleNotify()) + { + pDialog->AddEventListener(LINK(this, JSMessageDialog, on_window_event)); + m_bNotifyCreated = false; + } } void JSMessageDialog::set_primary_text(const OUString& rText) @@ -908,6 +913,21 @@ void JSMessageDialog::set_secondary_text(const OUString& rText) notifyDialogState(); } +IMPL_LINK_NOARG(JSMessageDialog, on_dump_status, void*, void) { JSDialogSender::dumpStatus(); } + +IMPL_LINK(JSMessageDialog, on_window_event, VclWindowEvent&, rEvent, void) +{ + if (rEvent.GetId() == VclEventId::WindowShow && !m_bNotifyCreated) + { + Application::PostUserEvent(LINK(this, JSMessageDialog, on_dump_status)); + m_bNotifyCreated = true; + } + else if (rEvent.GetId() == VclEventId::WindowHide || rEvent.GetId() == VclEventId::WindowClose) + { + sendClose(); + } +} + JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership, commit c413cba7db9811689b52258b249b21a62c9419da Author: Szymon Kłos <[email protected]> AuthorDate: Tue Dec 29 09:03:14 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:56:45 2021 +0200 jsdialog: direct updates for treeview We should use only weld:: interfaces methods to detect moment of control's updates as all the modifications goes through weld:: API. Let's use higher abstraction layer and not use vcl implementation details. this reverts partially: 32bfa0e1c7e859aedc3988d5bfdf86f5d7bab98a Change-Id: I2dd25c08dae3f5a95d077e2715788d636be47fe4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108433 Tested-by: Jenkins Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 0fa94195981c..1c0a44ae548d 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -366,8 +366,6 @@ public: class JSTreeView : public JSWidget<SalInstanceTreeView, ::SvTabListBox> { - DECL_LINK(on_window_event, VclWindowEvent&, void); - public: JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership, @@ -392,6 +390,9 @@ public: virtual void set_text(int row, const OUString& rText, int col = -1) override; virtual void set_text(const weld::TreeIter& rIter, const OUString& rStr, int col = -1) override; + virtual void expand_row(const weld::TreeIter& rIter) override; + virtual void collapse_row(const weld::TreeIter& rIter) override; + void drag_start(); void drag_end(); }; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index f0fb911d8f23..8fba06677b74 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -980,8 +980,6 @@ JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> : JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, aContentWindow, pTreeView, pBuilder, bTakeOwnership, sTypeOfJSON) { - if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) - pTreeView->AddEventListener(LINK(this, JSTreeView, on_window_event)); } void JSTreeView::set_toggle(int pos, TriState eState, int col) @@ -996,7 +994,7 @@ void JSTreeView::set_toggle(int pos, TriState eState, int col) SalInstanceTreeView::set_toggle(pEntry, eState, col); signal_toggled(iter_col(SalInstanceTreeIter(pEntry), col)); - notifyDialogState(); + sendUpdate(m_xTreeView); } } @@ -1042,21 +1040,12 @@ void JSTreeView::drag_end() m_xDropTarget->fire_drop(aEvent); - notifyDialogState(); + sendUpdate(m_xTreeView); } g_DragSource = nullptr; } -IMPL_LINK(JSTreeView, on_window_event, VclWindowEvent&, rEvent, void) -{ - if (rEvent.GetId() == VclEventId::WindowPaint && get_visible() && m_xTreeView->IsDirtyModel()) - { - sendUpdate(m_xTreeView); - m_xTreeView->SetDirtyModel(false); - } -} - void JSTreeView::insert(const weld::TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface, bool bChildrenOnDemand, weld::TreeIter* pRet) @@ -1064,19 +1053,31 @@ void JSTreeView::insert(const weld::TreeIter* pParent, int pos, const OUString* SalInstanceTreeView::insert(pParent, pos, pStr, pId, pIconName, pImageSurface, bChildrenOnDemand, pRet); - notifyDialogState(); + sendUpdate(m_xTreeView); } void JSTreeView::set_text(int row, const OUString& rText, int col) { SalInstanceTreeView::set_text(row, rText, col); - notifyDialogState(); + sendUpdate(m_xTreeView); } void JSTreeView::set_text(const weld::TreeIter& rIter, const OUString& rStr, int col) { SalInstanceTreeView::set_text(rIter, rStr, col); - notifyDialogState(); + sendUpdate(m_xTreeView); +} + +void JSTreeView::expand_row(const weld::TreeIter& rIter) +{ + SalInstanceTreeView::expand_row(rIter); + sendUpdate(m_xTreeView); +} + +void JSTreeView::collapse_row(const weld::TreeIter& rIter) +{ + SalInstanceTreeView::collapse_row(rIter); + sendUpdate(m_xTreeView); } JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, commit f547d89135831706cb1fc27a2f7b973516402581 Author: Henry Castro <[email protected]> AuthorDate: Fri Dec 25 13:23:40 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:56:36 2021 +0200 jsdialog: override weld_message_dialog It is required to create the "Macro Security Warning" message dialog Change-Id: Ic802b6e4f1a2f8c5c294aa5432f3ad5274b5e105 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108289 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 0a02e64cf890..0fa94195981c 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -149,6 +149,7 @@ public: const OUString& rUIFile); virtual ~JSInstanceBuilder() override; + virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString& id) override; virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id) override; virtual std::unique_ptr<weld::Label> weld_label(const OString& id) override; virtual std::unique_ptr<weld::Button> weld_button(const OString& id) override; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 1bef2653ae11..f0fb911d8f23 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -467,6 +467,32 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) return pRet; } +std::unique_ptr<weld::MessageDialog> JSInstanceBuilder::weld_message_dialog(const OString& id) +{ + std::unique_ptr<weld::MessageDialog> pRet; + ::MessageDialog* pMessageDialog = m_xBuilder->get<::MessageDialog>(id); + + if (pMessageDialog) + { + m_nWindowId = pMessageDialog->GetLOKWindowId(); + pMessageDialog->SetLOKTunnelingState(false); + + InsertWindowToMap(m_nWindowId); + + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pMessageDialog); + m_xBuilder->drop_ownership(pMessageDialog); + + if (id == "MacroWarnMedium") + pMessageDialog->SetDisableIdleNotify(true); + } + + pRet.reset(pMessageDialog ? new JSMessageDialog(pMessageDialog, m_aOwnedToplevel, this, false) + : nullptr); + + return pRet; +} + std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id) { ::FixedText* pLabel = m_xBuilder->get<FixedText>(id); commit cdab83516f2c784a588549d0ff0b232600cbf581 Author: Szymon Kłos <[email protected]> AuthorDate: Wed Dec 16 10:18:15 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:56:24 2021 +0200 jsdialog: update JSON on treeview modification Change-Id: Ibaf186768f9be0cb2dc893082590c851abae29b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107819 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108413 Tested-by: Jenkins diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index cf7b17dca2d1..0a02e64cf890 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -382,6 +382,15 @@ public: virtual weld::TreeView* get_drag_source() const override; + using SalInstanceTreeView::insert; + virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr, + const OUString* pId, const OUString* pIconName, + VirtualDevice* pImageSurface, bool bChildrenOnDemand, + weld::TreeIter* pRet) override; + + virtual void set_text(int row, const OUString& rText, int col = -1) override; + virtual void set_text(const weld::TreeIter& rIter, const OUString& rStr, int col = -1) override; + void drag_start(); void drag_end(); }; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index aa1febfe5d2a..1bef2653ae11 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1031,6 +1031,28 @@ IMPL_LINK(JSTreeView, on_window_event, VclWindowEvent&, rEvent, void) } } +void JSTreeView::insert(const weld::TreeIter* pParent, int pos, const OUString* pStr, + const OUString* pId, const OUString* pIconName, + VirtualDevice* pImageSurface, bool bChildrenOnDemand, weld::TreeIter* pRet) +{ + SalInstanceTreeView::insert(pParent, pos, pStr, pId, pIconName, pImageSurface, + bChildrenOnDemand, pRet); + + notifyDialogState(); +} + +void JSTreeView::set_text(int row, const OUString& rText, int col) +{ + SalInstanceTreeView::set_text(row, rText, col); + notifyDialogState(); +} + +void JSTreeView::set_text(const weld::TreeIter& rIter, const OUString& rStr, int col) +{ + SalInstanceTreeView::set_text(rIter, rStr, col); + notifyDialogState(); +} + JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) commit 496083206f73b6479f54d91712b47aac92cacb47 Author: Henry Castro <[email protected]> AuthorDate: Thu Dec 17 11:34:46 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:56:10 2021 +0200 jsdialog: use "WindowPaint" event to update If the idle notifier is disabled instead it uses the "WindowPaint" when the model has changed to notify update status to client side. Anyway the "WindowPaint" is supposed to be asynchronous. Change-Id: I0bb99526c72510a97e3906340c1e9269478da8cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107916 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 1f5ad5563f9d..cf7b17dca2d1 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -50,6 +50,7 @@ public: void ForceUpdate(); void sendClose(); VclPtr<vcl::Window> getNotifierWindow() { return m_aNotifierWindow; } + void updateStatus(VclPtr<vcl::Window> pWindow); private: void send(tools::JsonWriter& aJsonWriter); @@ -71,6 +72,7 @@ public: void notifyDialogState(bool bForce = false); void sendClose(); void dumpStatus(); + void sendUpdate(VclPtr<vcl::Window> pWindow); }; class JSDropTarget final @@ -363,6 +365,8 @@ public: class JSTreeView : public JSWidget<SalInstanceTreeView, ::SvTabListBox> { + DECL_LINK(on_window_event, VclWindowEvent&, void); + public: JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership, diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 7604d06b4c39..aa1febfe5d2a 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -97,6 +97,35 @@ std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::dumpStatus() const return aJsonWriter; } +void JSDialogNotifyIdle::updateStatus(VclPtr<vcl::Window> pWindow) +{ + if (!m_aNotifierWindow) + return; + + if (m_aNotifierWindow->IsReallyVisible()) + { + if (const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier()) + { + tools::JsonWriter aJsonWriter; + + aJsonWriter.put("commandName", ".uno:jsdialog"); + aJsonWriter.put("success", "true"); + { + auto aResult = aJsonWriter.startNode("result"); + aJsonWriter.put("dialog_id", m_aNotifierWindow->GetLOKWindowId()); + aJsonWriter.put("control_id", pWindow->get_id()); + { + auto aEntries = aJsonWriter.startNode("control"); + pWindow->DumpAsPropertyTree(aJsonWriter); + } + } + + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, + aJsonWriter.extractData()); + } + } +} + std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateCloseMessage() const { std::unique_ptr<tools::JsonWriter> aJsonWriter(new tools::JsonWriter()); @@ -127,6 +156,11 @@ void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); } void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); } +void JSDialogSender::sendUpdate(VclPtr<vcl::Window> pWindow) +{ + mpIdleNotify->updateStatus(pWindow); +} + namespace { vcl::Window* extract_sal_widget(weld::Widget* pParent) @@ -920,6 +954,8 @@ JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> : JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, aContentWindow, pTreeView, pBuilder, bTakeOwnership, sTypeOfJSON) { + if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) + pTreeView->AddEventListener(LINK(this, JSTreeView, on_window_event)); } void JSTreeView::set_toggle(int pos, TriState eState, int col) @@ -986,6 +1022,15 @@ void JSTreeView::drag_end() g_DragSource = nullptr; } +IMPL_LINK(JSTreeView, on_window_event, VclWindowEvent&, rEvent, void) +{ + if (rEvent.GetId() == VclEventId::WindowPaint && get_visible() && m_xTreeView->IsDirtyModel()) + { + sendUpdate(m_xTreeView); + m_xTreeView->SetDirtyModel(false); + } +} + JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) commit f3fbffd75d909a7c69e24107c5cf77adf5c2ba73 Author: Henry Castro <[email protected]> AuthorDate: Thu Dec 17 11:15:25 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:55:57 2021 +0200 jsdialog: use the "WindowShow" event If the idle notifier is disabled use the "WindowShow" event to notify the dialog status. This ensures the dialog is initialized with all children and its properties. There is a bug with the "WindowShow" event, it looks like it receive 2 times. Change-Id: I81947de8498aee99c3ea4ad504611c7afa62d7c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107915 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 556e34ffd346..1f5ad5563f9d 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -70,6 +70,7 @@ public: void notifyDialogState(bool bForce = false); void sendClose(); + void dumpStatus(); }; class JSDropTarget final @@ -218,6 +219,11 @@ public: class JSDialog : public JSWidget<SalInstanceDialog, ::Dialog> { + DECL_LINK(on_dump_status, void*, void); + DECL_LINK(on_window_event, VclWindowEvent&, void); + + bool m_bNotifyCreated; + public: JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership, diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 1bd064fc5c3e..7604d06b4c39 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -125,6 +125,8 @@ void JSDialogSender::notifyDialogState(bool bForce) void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); } +void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); } + namespace { vcl::Window* extract_sal_widget(weld::Widget* pParent) @@ -639,6 +641,11 @@ JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aCon : JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, pDialog, pBuilder, bTakeOwnership, sTypeOfJSON) { + if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) + { + pDialog->AddEventListener(LINK(this, JSDialog, on_window_event)); + m_bNotifyCreated = false; + } } void JSDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton) @@ -659,6 +666,17 @@ void JSDialog::response(int response) SalInstanceDialog::response(response); } +IMPL_LINK_NOARG(JSDialog, on_dump_status, void*, void) { JSDialogSender::dumpStatus(); } + +IMPL_LINK(JSDialog, on_window_event, VclWindowEvent&, rEvent, void) +{ + if (rEvent.GetId() == VclEventId::WindowShow && !m_bNotifyCreated) + { + Application::PostUserEvent(LINK(this, JSDialog, on_dump_status)); + m_bNotifyCreated = true; + } +} + JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) commit b86ed3d917a51c34de7048f863ec1359b660ded3 Author: Szymon Kłos <[email protected]> AuthorDate: Wed Dec 9 12:00:59 2020 +0100 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:55:45 2021 +0200 jsdialog: properly destroy JsonWriter Change-Id: Ic9bc13b60284ece25b6c72326fd2185d14e17029 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107466 Tested-by: Szymon Kłos <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 14090f43a0e4..556e34ffd346 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -52,7 +52,7 @@ public: VclPtr<vcl::Window> getNotifierWindow() { return m_aNotifierWindow; } private: - void send(std::unique_ptr<tools::JsonWriter> aJsonWriter); + void send(tools::JsonWriter& aJsonWriter); std::unique_ptr<tools::JsonWriter> dumpStatus() const; std::unique_ptr<tools::JsonWriter> generateCloseMessage() const; }; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 0363d35867af..1bd064fc5c3e 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -40,21 +40,28 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; } -void JSDialogNotifyIdle::send(std::unique_ptr<tools::JsonWriter> aJsonWriter) +void JSDialogNotifyIdle::send(tools::JsonWriter& aJsonWriter) { if (!m_aNotifierWindow) + { + free(aJsonWriter.extractData()); return; + } const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier(); if (pNotifier) { - if (m_bForce || !aJsonWriter->isDataEquals(m_LastNotificationMessage)) + if (m_bForce || !aJsonWriter.isDataEquals(m_LastNotificationMessage)) { m_bForce = false; - m_LastNotificationMessage = aJsonWriter->extractAsStdString(); + m_LastNotificationMessage = aJsonWriter.extractAsStdString(); pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, m_LastNotificationMessage.c_str()); } + else + { + free(aJsonWriter.extractData()); + } } } @@ -101,9 +108,9 @@ std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateCloseMessage() co return aJsonWriter; } -void JSDialogNotifyIdle::Invoke() { send(dumpStatus()); } +void JSDialogNotifyIdle::Invoke() { send(*dumpStatus()); } -void JSDialogNotifyIdle::sendClose() { send(generateCloseMessage()); } +void JSDialogNotifyIdle::sendClose() { send(*generateCloseMessage()); } void JSDialogSender::notifyDialogState(bool bForce) { commit 8e4d4ebd28681439d42d09bbed98f861f59b4f1e Author: Henry Castro <[email protected]> AuthorDate: Tue Dec 22 16:40:20 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:55:31 2021 +0200 jsdialog: fix disable idle notify There is a possible crash due to nullptr deference Change-Id: I3e2034ad89832eec61f1d6910a5ffd34c56df6a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108224 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 84dcbda81208..0363d35867af 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -107,7 +107,8 @@ void JSDialogNotifyIdle::sendClose() { send(generateCloseMessage()); } void JSDialogSender::notifyDialogState(bool bForce) { - if (mpIdleNotify->getNotifierWindow()->IsDisableIdleNotify()) + auto aNotifierWnd = mpIdleNotify->getNotifierWindow(); + if (aNotifierWnd && aNotifierWnd->IsDisableIdleNotify()) return; if (bForce) @@ -401,15 +402,15 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) m_xBuilder->drop_ownership(pDialog); m_bHasTopLevelDialog = true; + if (id == "MacroSelectorDialog") + pDialog->SetDisableIdleNotify(true); + pRet.reset(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false, m_sTypeOfJSON) : nullptr); RememberWidget("__DIALOG__", pRet.get()); - if (id == "MacroSelectorDialog") - pDialog->SetDisableIdleNotify(true); - const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); if (pNotifier && id != "MacroSelectorDialog") { commit 7f342a9874f64681628ec72b6d96d8fd607da765 Author: Henry Castro <[email protected]> AuthorDate: Thu Dec 17 10:45:13 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:55:13 2021 +0200 jsdialog: disable idle notify After testing on client side, when showing the Macro Selector Dialog its receive 5 times the same data. So add an option to not use the idle notifier instead it will use the event 'WindowShow'. Change-Id: Ib5657f3c823fc6e998581b99052aaf578d0913e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107893 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 0a378a11f65e..d7cb687b039d 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1175,6 +1175,9 @@ public: /// Find an existing Window based on the LOKWindowId. static VclPtr<vcl::Window> FindLOKWindow(vcl::LOKWindowId nWindowId); + bool IsDisableIdleNotify(); + void SetDisableIdleNotify(bool bValue); + /// check if LOK Window container is empty static bool IsLOKWindowsEmpty(); diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index d3c6e7b26d48..14090f43a0e4 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -49,6 +49,7 @@ public: void Invoke() override; void ForceUpdate(); void sendClose(); + VclPtr<vcl::Window> getNotifierWindow() { return m_aNotifierWindow; } private: void send(std::unique_ptr<tools::JsonWriter> aJsonWriter); diff --git a/vcl/inc/window.h b/vcl/inc/window.h index a14852ca02c0..a6d46c41eeda 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -117,6 +117,8 @@ struct ImplWinData sal_uInt16 mnIsTopWindow; bool mbMouseOver; //< tracks mouse over for native widget paint effect bool mbEnableNativeWidget; //< toggle native widget rendering + bool mbDisableIdleNotify; + ::std::list< VclPtr<vcl::Window> > maTopWindowChildren; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index b761d5b80312..84dcbda81208 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -107,6 +107,9 @@ void JSDialogNotifyIdle::sendClose() { send(generateCloseMessage()); } void JSDialogSender::notifyDialogState(bool bForce) { + if (mpIdleNotify->getNotifierWindow()->IsDisableIdleNotify()) + return; + if (bForce) mpIdleNotify->ForceUpdate(); mpIdleNotify->Start(); @@ -404,6 +407,9 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) RememberWidget("__DIALOG__", pRet.get()); + if (id == "MacroSelectorDialog") + pDialog->SetDisableIdleNotify(true); + const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); if (pNotifier && id != "MacroSelectorDialog") { diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 5e6d92b47ef9..3aac45364597 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -755,7 +755,8 @@ ImplWinData::ImplWinData() : mnTrackFlags(ShowTrackFlags::NONE), mnIsTopWindow(sal_uInt16(~0)), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mbMouseOver(false), - mbEnableNativeWidget(false) + mbEnableNativeWidget(false), + mbDisableIdleNotify(false) { } @@ -3177,6 +3178,17 @@ VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId) return VclPtr<Window>(); } +bool Window::IsDisableIdleNotify() +{ + return ImplGetWinData()->mbDisableIdleNotify; +} + +void Window::SetDisableIdleNotify(bool bValue) +{ + if (ImplGetWinData()->mbDisableIdleNotify != bValue) + ImplGetWinData()->mbDisableIdleNotify = bValue; +} + bool Window::IsLOKWindowsEmpty() { return GetLOKWindowsMap().empty(); commit d07e21ba5ff2d296cf86c20a37b59dae368773dd Author: Henry Castro <[email protected]> AuthorDate: Fri Dec 4 17:00:51 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:54:59 2021 +0200 lok: jsdialog: fix possible nullptr dereference p = nullptr; if (p) { } p->Somenthing(); Change-Id: I2a46d6a8e7eae96928210c8941ec71eed88bf631 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107245 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index bcf65b1ea255..b761d5b80312 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -383,33 +383,35 @@ VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow() std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) { + std::unique_ptr<weld::Dialog> pRet; ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id); - m_nWindowId = pDialog->GetLOKWindowId(); - pDialog->SetLOKTunnelingState(false); - - InsertWindowToMap(m_nWindowId); if (pDialog) { + m_nWindowId = pDialog->GetLOKWindowId(); + pDialog->SetLOKTunnelingState(false); + + InsertWindowToMap(m_nWindowId); + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); m_aOwnedToplevel.set(pDialog); m_xBuilder->drop_ownership(pDialog); m_bHasTopLevelDialog = true; - } - std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, - pDialog, this, false, m_sTypeOfJSON) - : nullptr); + pRet.reset(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false, + m_sTypeOfJSON) + : nullptr); - RememberWidget("__DIALOG__", pRet.get()); + RememberWidget("__DIALOG__", pRet.get()); - const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); - if (pNotifier && id != "MacroSelectorDialog") - { - tools::JsonWriter aJsonWriter; - m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); - aJsonWriter.put("id", m_aOwnedToplevel->GetLOKWindowId()); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData()); + const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); + if (pNotifier && id != "MacroSelectorDialog") + { + tools::JsonWriter aJsonWriter; + m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); + aJsonWriter.put("id", m_aOwnedToplevel->GetLOKWindowId()); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData()); + } } return pRet; commit d560e0c16a04e509d94664b3e3a95c79a0fd41d8 Author: Henry Castro <[email protected]> AuthorDate: Fri Dec 4 16:49:31 2020 -0400 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 9 11:54:49 2021 +0200 lok: jsbuilder: avoid sending early id to client side In the case of Macro Selector Dialog it is not required to send the id too early when the dialog is created and it is not initialized yet. Change-Id: I22fb05bd9ecff49b3e9eda19737750379a61dd69 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107244 Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 9e77a939ce2f..bcf65b1ea255 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -404,7 +404,7 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) RememberWidget("__DIALOG__", pRet.get()); const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); - if (pNotifier) + if (pNotifier && id != "MacroSelectorDialog") { tools::JsonWriter aJsonWriter; m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
