include/sfx2/sidebar/SidebarDockingWindow.hxx | 4 sfx2/source/sidebar/SidebarController.cxx | 20 -- sfx2/source/sidebar/SidebarDockingWindow.cxx | 79 ----------- vcl/inc/salvtables.hxx | 45 ++++++ vcl/jsdialog/jsdialogbuilder.cxx | 4 vcl/source/app/salvtables.cxx | 179 ++++++++++++-------------- 6 files changed, 131 insertions(+), 200 deletions(-)
New commits: commit 71123e5749879ecf5cb7458df10be60c16255279 Author: Szymon Kłos <[email protected]> AuthorDate: Thu Jun 10 15:32:49 2021 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Tue Jul 27 14:20:00 2021 +0200 Move SalInstanceMenuButton decl to header Change-Id: I5f5f0ceb58925874c6878760a99179a4936198fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116991 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119543 Tested-by: Jenkins diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 8c5e64d3deda..74d8179ea356 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1839,4 +1839,49 @@ public: virtual std::unique_ptr<weld::Label> weld_label_widget() const override; }; +class SalInstanceMenuButton : public SalInstanceButton, public virtual weld::MenuButton +{ +private: + VclPtr<::MenuButton> m_xMenuButton; + sal_uInt16 m_nLastId; + + DECL_LINK(MenuSelectHdl, ::MenuButton*, void); + DECL_LINK(ActivateHdl, ::MenuButton*, void); + +public: + SalInstanceMenuButton(::MenuButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_active(bool active) override; + + virtual bool get_active() const override; + + virtual void set_inconsistent(bool /*inconsistent*/) override; + + virtual bool get_inconsistent() const override; + + virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, + const OUString* pIconName, VirtualDevice* pImageSurface, + TriState eCheckRadioFalse) override; + + virtual void insert_separator(int pos, const OUString& rId) override; + + virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override; + + virtual void remove_item(const OString& rId) override; + + virtual void clear() override; + + virtual void set_item_active(const OString& rIdent, bool bActive) override; + + virtual void set_item_label(const OString& rIdent, const OUString& rText) override; + + virtual OUString get_item_label(const OString& rIdent) const override; + + virtual void set_item_visible(const OString& rIdent, bool bShow) override; + + virtual void set_popover(weld::Widget* pPopover) override; + + virtual ~SalInstanceMenuButton() override; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 7d876e8d33d2..2dd874c97843 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -2655,120 +2655,107 @@ weld::Button* SalInstanceAssistant::weld_widget_for_response(int nResponse) return nullptr; } -namespace -{ -class SalInstanceMenuButton : public SalInstanceButton, public virtual weld::MenuButton +SalInstanceMenuButton::SalInstanceMenuButton(::MenuButton* pButton, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceButton(pButton, pBuilder, bTakeOwnership) + , m_xMenuButton(pButton) + , m_nLastId(0) { -private: - VclPtr<::MenuButton> m_xMenuButton; - sal_uInt16 m_nLastId; - - DECL_LINK(MenuSelectHdl, ::MenuButton*, void); - DECL_LINK(ActivateHdl, ::MenuButton*, void); - -public: - SalInstanceMenuButton(::MenuButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceButton(pButton, pBuilder, bTakeOwnership) - , m_xMenuButton(pButton) - , m_nLastId(0) + m_xMenuButton->SetActivateHdl(LINK(this, SalInstanceMenuButton, ActivateHdl)); + m_xMenuButton->SetSelectHdl(LINK(this, SalInstanceMenuButton, MenuSelectHdl)); + if (PopupMenu* pMenu = m_xMenuButton->GetPopupMenu()) { - m_xMenuButton->SetActivateHdl(LINK(this, SalInstanceMenuButton, ActivateHdl)); - m_xMenuButton->SetSelectHdl(LINK(this, SalInstanceMenuButton, MenuSelectHdl)); - if (PopupMenu* pMenu = m_xMenuButton->GetPopupMenu()) - { - pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics); - const auto nCount = pMenu->GetItemCount(); - m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0; - } + pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics); + const auto nCount = pMenu->GetItemCount(); + m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0; } +} - virtual void set_active(bool active) override - { - if (active == get_active()) - return; - if (active) - m_xMenuButton->ExecuteMenu(); - else - m_xMenuButton->CancelMenu(); - } +void SalInstanceMenuButton::set_active(bool active) +{ + if (active == get_active()) + return; + if (active) + m_xMenuButton->ExecuteMenu(); + else + m_xMenuButton->CancelMenu(); +} - virtual bool get_active() const override { return m_xMenuButton->InPopupMode(); } +bool SalInstanceMenuButton::get_active() const { return m_xMenuButton->InPopupMode(); } - virtual void set_inconsistent(bool /*inconsistent*/) override - { - //not available - } +void SalInstanceMenuButton::set_inconsistent(bool /*inconsistent*/) +{ + //not available +} - virtual bool get_inconsistent() const override { return false; } +bool SalInstanceMenuButton::get_inconsistent() const { return false; } - virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, - const OUString* pIconName, VirtualDevice* pImageSurface, - TriState eCheckRadioFalse) override - { - m_nLastId = insert_to_menu(m_nLastId, m_xMenuButton->GetPopupMenu(), pos, rId, rStr, - pIconName, pImageSurface, nullptr, eCheckRadioFalse); - } +void SalInstanceMenuButton::insert_item(int pos, const OUString& rId, const OUString& rStr, + const OUString* pIconName, VirtualDevice* pImageSurface, + TriState eCheckRadioFalse) +{ + m_nLastId = insert_to_menu(m_nLastId, m_xMenuButton->GetPopupMenu(), pos, rId, rStr, pIconName, + pImageSurface, nullptr, eCheckRadioFalse); +} - virtual void insert_separator(int pos, const OUString& rId) override - { - auto nInsertPos = pos == -1 ? MENU_APPEND : pos; - m_xMenuButton->GetPopupMenu()->InsertSeparator(rId.toUtf8(), nInsertPos); - } +void SalInstanceMenuButton::insert_separator(int pos, const OUString& rId) +{ + auto nInsertPos = pos == -1 ? MENU_APPEND : pos; + m_xMenuButton->GetPopupMenu()->InsertSeparator(rId.toUtf8(), nInsertPos); +} - virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - pMenu->EnableItem(rIdent, bSensitive); - } +void SalInstanceMenuButton::set_item_sensitive(const OString& rIdent, bool bSensitive) +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->EnableItem(rIdent, bSensitive); +} - virtual void remove_item(const OString& rId) override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - pMenu->RemoveItem(pMenu->GetItemPos(pMenu->GetItemId(rId))); - } +void SalInstanceMenuButton::remove_item(const OString& rId) +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->RemoveItem(pMenu->GetItemPos(pMenu->GetItemId(rId))); +} - virtual void clear() override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - pMenu->Clear(); - } +void SalInstanceMenuButton::clear() +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->Clear(); +} - virtual void set_item_active(const OString& rIdent, bool bActive) override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - pMenu->CheckItem(rIdent, bActive); - } +void SalInstanceMenuButton::set_item_active(const OString& rIdent, bool bActive) +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->CheckItem(rIdent, bActive); +} - virtual void set_item_label(const OString& rIdent, const OUString& rText) override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - pMenu->SetItemText(pMenu->GetItemId(rIdent), rText); - } +void SalInstanceMenuButton::set_item_label(const OString& rIdent, const OUString& rText) +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->SetItemText(pMenu->GetItemId(rIdent), rText); +} - virtual OUString get_item_label(const OString& rIdent) const override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - return pMenu->GetItemText(pMenu->GetItemId(rIdent)); - } +OUString SalInstanceMenuButton::get_item_label(const OString& rIdent) const +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + return pMenu->GetItemText(pMenu->GetItemId(rIdent)); +} - virtual void set_item_visible(const OString& rIdent, bool bShow) override - { - PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); - pMenu->ShowItem(pMenu->GetItemId(rIdent), bShow); - } +void SalInstanceMenuButton::set_item_visible(const OString& rIdent, bool bShow) +{ + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->ShowItem(pMenu->GetItemId(rIdent), bShow); +} - virtual void set_popover(weld::Widget* pPopover) override - { - SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover); - m_xMenuButton->SetPopover(pPopoverWidget ? pPopoverWidget->getWidget() : nullptr); - } +void SalInstanceMenuButton::set_popover(weld::Widget* pPopover) +{ + SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover); + m_xMenuButton->SetPopover(pPopoverWidget ? pPopoverWidget->getWidget() : nullptr); +} - virtual ~SalInstanceMenuButton() override - { - m_xMenuButton->SetSelectHdl(Link<::MenuButton*, void>()); - m_xMenuButton->SetActivateHdl(Link<::MenuButton*, void>()); - } -}; +SalInstanceMenuButton::~SalInstanceMenuButton() +{ + m_xMenuButton->SetSelectHdl(Link<::MenuButton*, void>()); + m_xMenuButton->SetActivateHdl(Link<::MenuButton*, void>()); } IMPL_LINK_NOARG(SalInstanceMenuButton, MenuSelectHdl, ::MenuButton*, void) commit af0786c3d7e22e961a92e0ccb2fc2c6f504e576e Author: Szymon Kłos <[email protected]> AuthorDate: Thu Jun 10 10:43:05 2021 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Tue Jul 27 14:19:49 2021 +0200 jsdialog: sidebar: remove code for tunneled one Change-Id: Idb60fdfc03729dd3755d5ef1ba61b2f9376e9556 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116965 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119542 Tested-by: Szymon Kłos <[email protected]> diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx index 903db6f42bf0..ff7f2d2aff38 100644 --- a/include/sfx2/sidebar/SidebarDockingWindow.hxx +++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx @@ -32,8 +32,6 @@ class SidebarChildWindow; class SidebarController; -class SidebarNotifyIdle; - class SFX2_DLLPUBLIC SidebarDockingWindow final : public SfxDockingWindow { public: @@ -66,8 +64,6 @@ private: ::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController; bool mbIsReadyToDrag; std::unique_ptr<svt::AcceleratorExecute> mpAccel; - - std::unique_ptr<SidebarNotifyIdle> mpIdleNotify; }; } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 3ca7ca9655f1..116af3e8c8bf 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1230,26 +1230,6 @@ IMPL_LINK(SidebarController, OnSubMenuItemSelected, const OString&, rCurItemId, void SidebarController::RequestCloseDeck() { - if (comphelper::LibreOfficeKit::isActive() && mpCurrentDeck) - { - const SfxViewShell* pViewShell = SfxViewShell::Current(); - if (pViewShell && pViewShell->isLOKMobilePhone()) - { - // Mobile phone. - std::stringstream aStream; - boost::property_tree::ptree aTree; - aTree.put("id", mpParentWindow->get_id()); // TODO could be missing - sort out - aTree.put("type", "dockingwindow"); - aTree.put("text", mpParentWindow->GetText()); - aTree.put("enabled", false); - boost::property_tree::write_json(aStream, aTree); - const std::string message = aStream.str(); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); - } - else if (const vcl::ILibreOfficeKitNotifier* pNotifier = mpCurrentDeck->GetLOKNotifier()) - pNotifier->notifyWindow(mpCurrentDeck->GetLOKWindowId(), "close"); - } - mbIsDeckRequestedOpen = false; UpdateDeckOpenState(); diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index b5b19b10bf74..f8405e7989a9 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -41,81 +41,11 @@ using namespace css::uno; namespace sfx2::sidebar { -class SidebarNotifyIdle : public Idle -{ - SidebarDockingWindow& m_rSidebarDockingWin; - std::string m_LastNotificationMessage; - vcl::LOKWindowId m_LastLOKWindowId; - -public: - SidebarNotifyIdle(SidebarDockingWindow &rSidebarDockingWin) : - Idle("Sidebar notify"), - m_rSidebarDockingWin(rSidebarDockingWin), - m_LastNotificationMessage(), - m_LastLOKWindowId(0) - { - SetPriority(TaskPriority::POST_PAINT); - } - - void Invoke() override - { - auto pNotifier = m_rSidebarDockingWin.GetLOKNotifier(); - if (!pNotifier || !comphelper::LibreOfficeKit::isActive()) - return; - - try - { - const SfxViewShell* pOwnerView = dynamic_cast<const SfxViewShell*>(pNotifier); - if (pOwnerView && pOwnerView->isLOKMobilePhone()) - { - // Mobile phone. - tools::JsonWriter aJsonWriter; - m_rSidebarDockingWin.DumpAsPropertyTree(aJsonWriter); - aJsonWriter.put("id", m_rSidebarDockingWin.GetLOKWindowId()); - std::unique_ptr<char[], o3tl::free_delete> data( aJsonWriter.extractData()); - std::string_view message(data.get()); - if (message != m_LastNotificationMessage) - { - m_LastNotificationMessage = message; - pOwnerView->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, m_LastNotificationMessage.c_str()); - } - } - - // Notify the sidebar is created, and its LOKWindowId, which - // is needed on mobile phones, tablets, and desktop. - const Point pos(m_rSidebarDockingWin.GetOutOffXPixel(), - m_rSidebarDockingWin.GetOutOffYPixel()); - const OString posMessage = pos.toString(); - const OString sizeMessage = m_rSidebarDockingWin.GetSizePixel().toString(); - - const std::string message = OString(posMessage + sizeMessage).getStr(); - const vcl::LOKWindowId lokWindowId = m_rSidebarDockingWin.GetLOKWindowId(); - - if (lokWindowId != m_LastLOKWindowId || message != m_LastNotificationMessage) - { - m_LastLOKWindowId = lokWindowId; - m_LastNotificationMessage = message; - - std::vector<vcl::LOKPayloadItem> aItems; - aItems.emplace_back("type", "deck"); - aItems.emplace_back("position", posMessage); - aItems.emplace_back("size", sizeMessage); - pNotifier->notifyWindow(lokWindowId, "created", aItems); - } - } - catch (boost::property_tree::json_parser::json_parser_error& rError) - { - SAL_WARN("sfx.sidebar", rError.message()); - } - } -}; - SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChildWindow& rChildWindow, vcl::Window* pParentWindow, WinBits nBits) : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits) , mpSidebarController() , mbIsReadyToDrag(false) - , mpIdleNotify(new SidebarNotifyIdle(*this)) { // Get the XFrame from the bindings. if (pSfxBindings==nullptr || pSfxBindings->GetDispatcher()==nullptr) @@ -151,13 +81,8 @@ void SidebarDockingWindow::dispose() void SidebarDockingWindow::LOKClose() { assert(comphelper::LibreOfficeKit::isActive()); - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) - { - mpIdleNotify->Stop(); - - pNotifier->notifyWindow(GetLOKWindowId(), "close"); + if (GetLOKNotifier()) ReleaseLOKNotifier(); - } } void SidebarDockingWindow::GetFocus() @@ -206,8 +131,6 @@ void SidebarDockingWindow::NotifyResize() SetLOKNotifier(pCurrentView); } - - mpIdleNotify->Start(); } SfxChildAlignment SidebarDockingWindow::CheckAlignment ( diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index af68f2c48319..896225aef311 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -419,8 +419,6 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR { vcl::Window* pRoot = m_xBuilder->get_widget_root(); - m_aParentDialog = pRoot->GetParentWithLOKNotifier(); - if (rUIFile == "sfx/ui/panel.ui") { // builder for Panel, get SidebarDockingWindow as m_aContentWindow @@ -436,6 +434,8 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR m_aContentWindow = m_aContentWindow->GetParent(); } + m_aParentDialog = m_aContentWindow; + InsertWindowToMap(m_nWindowId); initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON()); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
