use GetParentWithLOKNotifier to get the frame LOKNotifier to reuse for menus

so it doesn't have to be explicitly set by the editview menu creator

If I force enable LibreOfficeKit::isActive and right click on a
mispelled word in impress, or in the writer comments-in-margin before or
after this change I see the same ILibreOfficeKitNotifier set on the
MenuFloatingWindow. Seeing as this is used in only the editview spell
checking menu give that a unique id 'editviewspellmenu' and only do
this for that id

SetLOKNotifier in vcl/source/window/menu.cxx added with:
commit 8938e8b153
Author: Jan Holesovsky <kendy@collabora.com>
Date:   Thu Mar 8 21:07:40 2018 +0100

    lokdialog: Tunnel the spell-checking context menu with recommendations.

    Change-Id: I1a7952e88a3f89346c97d2516628b4a7a0423de6
    Reviewed-on: https://gerrit.libreoffice.org/51062
    Reviewed-by: pranavk <pranavk@collabora.co.uk>
    Tested-by: pranavk <pranavk@collabora.co.uk>
    Reviewed-on: https://gerrit.libreoffice.org/51166
    Tested-by: Jenkins <ci@libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy@collabora.com>

SetLOKNotifier in editeng/source/editeng/editview.cxx added with:
commit 7c6fbd0ac3
Author: Tamás Zolnai <tamas.zolnai@collabora.com>
Date:   Mon Apr 16 14:38:36 2018 +0200

    sd lok: Impress: Right-click menu on misspelled word locks up session

    Change-Id: Ib554eea7049c1ea244bc4789ee3d7d2adf87e283
    Reviewed-on: https://gerrit.libreoffice.org/52977
    Tested-by: Jenkins <ci@libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>

Change-Id: I6c23ba4252eab3850b7cc4c8cad2d2f8adee2792
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107747
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2020-12-15 09:32:26 +00:00
parent 3dfbf8d7f1
commit f9af3a9807
4 changed files with 9 additions and 17 deletions

View file

@ -920,7 +920,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
return;
VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "editeng/ui/spellmenu.ui", "");
VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("menu"));
VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("editviewspellmenu"));
const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect");
PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId);
const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert");
@ -1104,8 +1104,6 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
return;
}
else // For desktop and tablets, we use the tunneled dialog
aPopupMenu->SetLOKNotifier(pViewShell);
}
sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);

View file

@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.1 -->
<interface domain="editeng">
<requires lib="gtk+" version="3.20"/>
<object class="GtkMenu" id="menu">
<object class="GtkMenu" id="editviewspellmenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>

View file

@ -500,8 +500,6 @@ 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:
@ -538,12 +536,6 @@ 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 );
};

View file

@ -2714,14 +2714,12 @@ MenuFloatingWindow * PopupMenu::ImplGetFloatingWindow() const {
}
PopupMenu::PopupMenu()
: mpLOKNotifier(nullptr)
{
mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
}
PopupMenu::PopupMenu( const PopupMenu& rMenu )
: Menu(),
mpLOKNotifier(nullptr)
: Menu()
{
mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
*this = rMenu;
@ -2922,8 +2920,12 @@ sal_uInt16 PopupMenu::ImplExecute( const VclPtr<vcl::Window>& pW, const tools::R
}
VclPtrInstance<MenuFloatingWindow> pWin( this, pW, WB_BORDER | WB_SYSTEMWINDOW );
if (comphelper::LibreOfficeKit::isActive() && mpLOKNotifier)
pWin->SetLOKNotifier(mpLOKNotifier);
if (comphelper::LibreOfficeKit::isActive() && get_id() == "editviewspellmenu")
{
VclPtr<vcl::Window> xNotifierParent = pW->GetParentWithLOKNotifier();
assert(xNotifierParent && xNotifierParent->GetLOKNotifier() && "editview menu without LOKNotifier");
pWin->SetLOKNotifier(xNotifierParent->GetLOKNotifier());
}
if( pSVData->maNWFData.mbFlatMenu )
pWin->SetBorderStyle( WindowBorderStyle::NOBORDER );