From 8938e8b153f32f3f5926baddb87cb76c8e72755a Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Thu, 8 Mar 2018 21:07:40 +0100 Subject: [PATCH] lokdialog: Tunnel the spell-checking context menu with recommendations. Change-Id: I1a7952e88a3f89346c97d2516628b4a7a0423de6 Reviewed-on: https://gerrit.libreoffice.org/51062 Reviewed-by: pranavk Tested-by: pranavk Reviewed-on: https://gerrit.libreoffice.org/51166 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- editeng/source/editeng/editview.cxx | 2 +- include/vcl/menu.hxx | 9 +++++++++ sw/source/uibase/inc/olmenu.hxx | 2 +- sw/source/uibase/uiview/viewling.cxx | 7 +++++-- vcl/source/window/menu.cxx | 9 ++++++++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 22b66cbce8c2..6e1d4ec481a1 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1025,7 +1025,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, LinkpEditEngine->pImpEditEngine->CreateEPaM(aPaM); EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2); - sal_uInt16 nId = aPopupMenu->Execute( pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose ); + sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose); aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2); aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP); diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 3ada2762fb6a..06a2e38680c6 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -60,6 +60,7 @@ namespace vcl class Window; struct MenuLayoutData; typedef OutputDevice RenderContext; // same as in include/vcl/outdev.hxx +class ILibreOfficeKitNotifier; } #define MENU_APPEND (sal_uInt16(0xFFFF)) @@ -483,6 +484,8 @@ class VCL_DLLPUBLIC PopupMenu : public Menu friend struct MenuItemData; private: + const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling. + SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const; protected: @@ -517,6 +520,12 @@ public: static bool IsInExecute(); static PopupMenu* GetActivePopupMenu(); + /// Interface to register for dialog / window tunneling. + void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier) + { + mpLOKNotifier = pNotifier; + } + PopupMenu& operator=( const PopupMenu& rMenu ); }; diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx index a407f618810f..d37eb2edbfb5 100644 --- a/sw/source/uibase/inc/olmenu.hxx +++ b/sw/source/uibase/inc/olmenu.hxx @@ -128,7 +128,7 @@ public: ~SwSpellPopup(); - Menu& GetMenu() + PopupMenu& GetMenu() { return *m_xPopupMenu.get(); } diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index b59abdc05042..8ac2ccd217de 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -710,11 +711,10 @@ bool SwView::ExecSpellPopup(const Point& rPt) aEvent.ExecutePosition.Y = aPixPos.Y(); ScopedVclPtr pMenu; - OUString sMenuName = bUseGrammarContext ? + OUString sMenuName = bUseGrammarContext ? OUString("private:resource/GrammarContextMenu") : OUString("private:resource/SpellContextMenu"); if (TryContextMenuInterception(xPopup->GetMenu(), sMenuName, pMenu, aEvent)) { - //! happy hacking for context menu modifying extensions of this //! 'custom made' menu... *sigh* (code copied from sfx2 and framework) if ( pMenu ) @@ -762,6 +762,9 @@ bool SwView::ExecSpellPopup(const Point& rPt) } else { + if (comphelper::LibreOfficeKit::isActive()) + xPopup->GetMenu().SetLOKNotifier(SfxViewShell::Current()); + xPopup->Execute(aToFill.SVRect(), m_pEditWin); } } diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index b4ab69cccfee..6c6c4715047e 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include #include @@ -2672,12 +2674,14 @@ MenuFloatingWindow * PopupMenu::ImplGetFloatingWindow() const { } PopupMenu::PopupMenu() + : mpLOKNotifier(nullptr) { mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this); } PopupMenu::PopupMenu( const PopupMenu& rMenu ) - : Menu() + : Menu(), + mpLOKNotifier(nullptr) { mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this); *this = rMenu; @@ -2878,6 +2882,9 @@ sal_uInt16 PopupMenu::ImplExecute( const VclPtr& pW, const tools::R } VclPtrInstance pWin( this, pW, WB_BORDER | WB_SYSTEMWINDOW ); + if (comphelper::LibreOfficeKit::isActive() && mpLOKNotifier) + pWin->SetLOKNotifier(mpLOKNotifier); + if( pSVData->maNWFData.mbFlatMenu ) pWin->SetBorderStyle( WindowBorderStyle::NOBORDER ); else -- 2.11.4.GIT