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>
This commit is contained in:
Jan Holesovsky
2018-03-08 21:07:40 +01:00
parent e0d59468b1
commit 8938e8b153
5 changed files with 24 additions and 5 deletions

View File

@@ -1025,7 +1025,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
EPaM aP = pImpEditView->pEditEngine->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);

View File

@@ -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 );
};

View File

@@ -128,7 +128,7 @@ public:
~SwSpellPopup();
Menu& GetMenu()
PopupMenu& GetMenu()
{
return *m_xPopupMenu.get();
}

View File

@@ -24,6 +24,7 @@
#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include <linguistic/lngprops.hxx>
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/propertysequence.hxx>
@@ -710,11 +711,10 @@ bool SwView::ExecSpellPopup(const Point& rPt)
aEvent.ExecutePosition.Y = aPixPos.Y();
ScopedVclPtr<Menu> 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);
}
}

View File

@@ -20,6 +20,7 @@
#include <tools/diagnose_ex.h>
#include <tools/stream.hxx>
#include <comphelper/lok.hxx>
#include <vcl/svapp.hxx>
#include <vcl/mnemonic.hxx>
#include <vcl/image.hxx>
@@ -40,6 +41,7 @@
#include <vcl/dockingarea.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/IDialogRenderable.hxx>
#include <salinst.hxx>
#include <svdata.hxx>
@@ -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<vcl::Window>& pW, const tools::R
}
VclPtrInstance<MenuFloatingWindow> pWin( this, pW, WB_BORDER | WB_SYSTEMWINDOW );
if (comphelper::LibreOfficeKit::isActive() && mpLOKNotifier)
pWin->SetLOKNotifier(mpLOKNotifier);
if( pSVData->maNWFData.mbFlatMenu )
pWin->SetBorderStyle( WindowBorderStyle::NOBORDER );
else