diff options
-rw-r--r-- | include/sfx2/viewsh.hxx | 5 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 15 |
3 files changed, 21 insertions, 9 deletions
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index fc06eb9ddbe8..cfde481f5e21 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -59,6 +59,7 @@ class SfxInPlaceClient; class SfxLokCallbackInterface; namespace vcl { class PrinterController; } +namespace com::sun::star::awt{ class XPopupMenu; } namespace com::sun::star::beans { struct PropertyValue; } namespace com::sun::star::datatransfer::clipboard { class XClipboardListener; } namespace com::sun::star::datatransfer::clipboard { class XClipboardNotifier; } @@ -299,7 +300,9 @@ public: css::uno::Reference<css::frame::XController> GetController() const; bool TryContextMenuInterception( const Menu& rIn, const OUString& rMenuIdentifier, VclPtr<Menu>& rpOut, css::ui::ContextMenuExecuteEvent aEvent ); - bool TryContextMenuInterception( Menu& rMenu, const OUString& rMenuIdentifier, css::ui::ContextMenuExecuteEvent aEvent ); + bool TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>&, + const OUString& rMenuIdentifier, + css::ui::ContextMenuExecuteEvent aEvent); void ExecPrint( const css::uno::Sequence < css::beans::PropertyValue >&, bool, bool ); // Like ExecPrint(), but only sets up for printing. Use Printer::ExecutePrintJob() and Printer::FinishPrintJob() afterwards. diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 6c6b3134404d..b0eee6eefb22 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -28,6 +28,7 @@ #include <boost/property_tree/json_parser.hpp> +#include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> @@ -1732,10 +1733,10 @@ void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, c aEvent.ExecutePosition.Y = aPos.Y(); xPopupController->setPopupMenu( xPopupMenu ); - VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>( xPopupMenu ); - PopupMenu* pVCLMenu = static_cast< PopupMenu* >( pAwtMenu->GetMenu() ); if (comphelper::LibreOfficeKit::isActive()) { + VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>( xPopupMenu ); + PopupMenu* pVCLMenu = static_cast< PopupMenu* >( pAwtMenu->GetMenu() ); boost::property_tree::ptree aMenu = fillPopupMenu(pVCLMenu); boost::property_tree::ptree aRoot; aRoot.add_child("menu", aMenu); @@ -1748,9 +1749,10 @@ void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, c else { OUString aMenuURL = "private:resource/popupmenu/" + rResName; - if (pVCLMenu && GetFrame()->GetViewShell()->TryContextMenuInterception(*pVCLMenu, aMenuURL, aEvent)) + if (GetFrame()->GetViewShell()->TryContextMenuInterception(xPopupMenu, aMenuURL, aEvent)) { - pVCLMenu->Execute(pWindow, aPos); + css::uno::Reference<css::awt::XWindowPeer> xParent(aEvent.SourceWindow, css::uno::UNO_QUERY); + xPopupMenu->execute(xParent, css::awt::Rectangle(aPos.X(), aPos.Y(), 1, 1), css::awt::PopupMenuDirection::EXECUTE_DOWN); } } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 75826a28d128..e6b62ca774f9 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -24,6 +24,7 @@ #include <svl/stritem.hxx> #include <svl/eitem.hxx> #include <svl/whiter.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <vcl/menu.hxx> #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> @@ -1954,12 +1955,18 @@ bool SfxViewShell::TryContextMenuInterception( const Menu& rIn, const OUString& return true; } -bool SfxViewShell::TryContextMenuInterception( Menu& rMenu, const OUString& rMenuIdentifier, css::ui::ContextMenuExecuteEvent aEvent ) +bool SfxViewShell::TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>& rPopupMenu, + const OUString& rMenuIdentifier, css::ui::ContextMenuExecuteEvent aEvent) { + VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>(rPopupMenu); + PopupMenu* pVCLMenu = static_cast<PopupMenu*>(pAwtMenu->GetMenu()); + if (!pVCLMenu) + return false; + bool bModified = false; // create container from menu - aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( &rMenu, &rMenuIdentifier ); + aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(pVCLMenu, &rMenuIdentifier); // get selection from controller aEvent.Selection = css::uno::Reference< css::view::XSelectionSupplier >( GetController(), css::uno::UNO_QUERY ); @@ -2008,8 +2015,8 @@ bool SfxViewShell::TryContextMenuInterception( Menu& rMenu, const OUString& rMen if ( bModified ) { - rMenu.Clear(); - ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( &rMenu, aEvent.ActionTriggerContainer ); + pVCLMenu->Clear(); + ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer(pVCLMenu, aEvent.ActionTriggerContainer); } return true; |