diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-12-11 12:55:41 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-12-11 15:25:05 +0100 |
commit | 49528082f2070268c0b1507ce6e63aa7e5794467 (patch) | |
tree | 65f1598b3b0a5a35e7050fb1d6353b440ed46507 /sfx2/source | |
parent | 21154ea8c450f9f5568b32123d34a20e498a9290 (diff) |
keep as css::awt::XPopupMenu through another layer of api
Change-Id: I36e98e45d7d8ea092b1c58aea83652fe5df7bb17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126660
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index e6b62ca774f9..cf5509af155d 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1889,9 +1889,11 @@ static void Change( Menu* pMenu, SfxViewShell* pView ) } -bool SfxViewShell::TryContextMenuInterception( const Menu& rIn, const OUString& rMenuIdentifier, VclPtr<Menu>& rpOut, ui::ContextMenuExecuteEvent aEvent ) +bool SfxViewShell::TryContextMenuInterception(const Menu& rIn, const OUString& rMenuIdentifier, + css::uno::Reference<css::awt::XPopupMenu>& rOut, + ui::ContextMenuExecuteEvent aEvent) { - rpOut = nullptr; + rOut.clear(); bool bModified = false; // create container from menu @@ -1943,13 +1945,20 @@ bool SfxViewShell::TryContextMenuInterception( const Menu& rIn, const OUString& break; } - if ( bModified ) + if (bModified) { - // container was modified, create a new window out of it - rpOut = VclPtr<PopupMenu>::Create(); - ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( rpOut, aEvent.ActionTriggerContainer ); + // container was modified, create a new menu out of it + css::uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext(), css::uno::UNO_SET_THROW); + rOut.set(xContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.PopupMenu", xContext), css::uno::UNO_QUERY_THROW); + + VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>(rOut); + assert(pAwtMenu); + PopupMenu* pVCLMenu = static_cast<PopupMenu*>(pAwtMenu->GetMenu()); + assert(pVCLMenu); + + ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer(pVCLMenu, aEvent.ActionTriggerContainer); - Change( rpOut, this ); + Change(pVCLMenu, this); } return true; |