summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/dispatch.hxx3
-rw-r--r--sfx2/source/control/dispatch.cxx4
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx31
3 files changed, 30 insertions, 8 deletions
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 92d0b42cb3fb..a172ced137de 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -148,8 +148,7 @@ public:
SfxViewFrame* GetFrame() const;
SfxModule* GetModule() const;
- void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr,
- PopupMenuFlags nFlags = PopupMenuFlags::ExecuteDown );
+ void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr );
static void ExecutePopup( vcl::Window *pWin = nullptr, const Point *pPosPixel = nullptr );
bool IsAppDispatcher() const;
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index fefdf6aa87ab..b56fa9cb6168 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -1942,7 +1942,7 @@ void SfxDispatcher::ExecutePopup( vcl::Window *pWin, const Point *pPos )
}
}
-void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, const Point* pPos, PopupMenuFlags nFlags )
+void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, const Point* pPos )
{
css::uno::Sequence< css::uno::Any > aArgs( 3 );
aArgs[0] <<= comphelper::makePropertyValue( "Value", rResName );
@@ -1987,7 +1987,7 @@ void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, c
OUString aMenuURL = "private:resource/popupmenu/" + rResName;
if (pVCLMenu && GetFrame()->GetViewShell()->TryContextMenuInterception(*pVCLMenu, aMenuURL, aEvent))
{
- pVCLMenu->Execute(pWindow, Rectangle(aPos, aPos), nFlags);
+ pVCLMenu->Execute(pWindow, aPos);
}
}
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 203c0f93f729..2ced9f926204 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -11,11 +11,13 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
#include <unotools/viewoptions.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
#include <vcl/notebookbar.hxx>
#include <vcl/syswin.hxx>
#include <vcl/tabctrl.hxx>
#include <sfx2/viewfrm.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
@@ -23,6 +25,7 @@
#include <officecfg/Office/UI/Notebookbar.hxx>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
+#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <unotools/confignode.hxx>
#include <comphelper/types.hxx>
@@ -336,12 +339,32 @@ void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow)
IMPL_STATIC_LINK(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, pNotebookbar, void)
{
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
- SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : nullptr;
- if (pNotebookbar && pDispatcher)
+ if (pNotebookbar && pViewFrame)
{
+ css::uno::Sequence<css::uno::Any> aArgs {
+ css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("notebookbar"))),
+ css::uno::makeAny(comphelper::makePropertyValue("Frame", pViewFrame->GetFrame().GetFrameInterface())) };
+
+ css::uno::Reference<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
+ css::uno::Reference<css::frame::XPopupMenuController> xPopupController(
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
+
+ css::uno::Reference<css::awt::XPopupMenu> xPopupMenu(xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.awt.PopupMenu", xContext), css::uno::UNO_QUERY);
+
+ if (!xPopupController.is() || !xPopupMenu.is())
+ return;
+
+ xPopupController->setPopupMenu(xPopupMenu);
+ VCLXMenu* pAwtMenu = VCLXMenu::GetImplementation(xPopupMenu);
+ PopupMenu* pVCLMenu = static_cast<PopupMenu*>(pAwtMenu->GetMenu());
Point aPos(0, NotebookbarTabControl::GetHeaderHeight());
- pDispatcher->ExecutePopup("notebookbar", pNotebookbar, &aPos,
- PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose);
+ pVCLMenu->Execute(pNotebookbar, Rectangle(aPos, aPos),PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose);
+
+ css::uno::Reference<css::lang::XComponent> xComponent(xPopupController, css::uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
}
}