framework/source/uielement/controlmenucontroller.cxx | 1 framework/source/uielement/fontmenucontroller.cxx | 1 framework/source/uielement/fontsizemenucontroller.cxx | 1 framework/source/uielement/headermenucontroller.cxx | 1 framework/source/uielement/langselectionmenucontroller.cxx | 1 framework/source/uielement/macrosmenucontroller.cxx | 1 framework/source/uielement/newmenucontroller.cxx | 6 ----- framework/source/uielement/objectmenucontroller.cxx | 1 framework/source/uielement/popuptoolbarcontroller.cxx | 15 ++++--------- framework/source/uielement/recentfilesmenucontroller.cxx | 1 framework/source/uielement/resourcemenucontroller.cxx | 11 +++------ framework/source/uielement/thesaurusmenucontroller.cxx | 1 framework/source/uielement/toolbarmodemenucontroller.cxx | 4 ++- framework/source/uielement/toolbarsmenucontroller.cxx | 4 ++- include/sfx2/dispatch.hxx | 4 ++- include/sfx2/viewsh.hxx | 7 +++--- include/svtools/popupmenucontrollerbase.hxx | 4 ++- reportdesign/source/ui/report/ReportSection.cxx | 5 +--- sfx2/source/control/dispatch.cxx | 8 ++---- sfx2/source/notebookbar/NotebookbarTabControl.cxx | 4 +-- sfx2/source/view/viewsh.cxx | 10 ++++---- svtools/source/uno/popupmenucontrollerbase.cxx | 4 ++- sw/source/uibase/docvw/edtwin.cxx | 4 +-- sw/source/uibase/docvw/romenu.hxx | 3 +- sw/source/uibase/inc/olmenu.hxx | 3 +- sw/source/uibase/uiview/viewling.cxx | 4 +-- 26 files changed, 58 insertions(+), 51 deletions(-)
New commits: commit 793904ff3a7d8cceafab3d83a562261c4c17fd14 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 13 14:50:36 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Jan 14 06:36:24 2023 +0000 use more VCLXPopupMenu instead of XPopupMenu which avoids a bunch of casting and makes the dependency explicit instead of implicit Change-Id: I754da72916fbbc51e7edc3c806155da34d347bd8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145472 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx index 2c31081bbe6b..dec13831646f 100644 --- a/framework/source/uielement/controlmenucontroller.cxx +++ b/framework/source/uielement/controlmenucontroller.cxx @@ -31,6 +31,7 @@ #include <vcl/settings.hxx> #include <vcl/image.hxx> #include <svtools/popupmenucontrollerbase.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <osl/mutex.hxx> #include <unordered_map> diff --git a/framework/source/uielement/fontmenucontroller.cxx b/framework/source/uielement/fontmenucontroller.cxx index c0dd19e2e71a..e25b5b210b83 100644 --- a/framework/source/uielement/fontmenucontroller.cxx +++ b/framework/source/uielement/fontmenucontroller.cxx @@ -33,6 +33,7 @@ #include <vcl/mnemonic.hxx> #include <osl/mutex.hxx> #include <cppuhelper/supportsservice.hxx> +#include <toolkit/awt/vclxmenu.hxx> // Defines diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx index 4c5c686888a9..e050c1659eb6 100644 --- a/framework/source/uielement/fontsizemenucontroller.cxx +++ b/framework/source/uielement/fontsizemenucontroller.cxx @@ -34,6 +34,7 @@ #include <vcl/print.hxx> #include <vcl/settings.hxx> #include <svtools/ctrltool.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <osl/mutex.hxx> #include <memory> #include <cppuhelper/supportsservice.hxx> diff --git a/framework/source/uielement/headermenucontroller.cxx b/framework/source/uielement/headermenucontroller.cxx index cbcdc33bc5fa..842e74559fac 100644 --- a/framework/source/uielement/headermenucontroller.cxx +++ b/framework/source/uielement/headermenucontroller.cxx @@ -33,6 +33,7 @@ #include <rtl/ustrbuf.hxx> #include <osl/mutex.hxx> #include <cppuhelper/supportsservice.hxx> +#include <toolkit/awt/vclxmenu.hxx> // Defines diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 94918c02179a..51994c1021a0 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -29,6 +29,7 @@ #include <svl/languageoptions.hxx> #include <svtools/langtab.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <classes/fwkresid.hxx> #include <strings.hrc> diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx index a0745b1e4f6f..b15b3191efe7 100644 --- a/framework/source/uielement/macrosmenucontroller.cxx +++ b/framework/source/uielement/macrosmenucontroller.cxx @@ -26,6 +26,7 @@ #include <vcl/svapp.hxx> #include <vcl/commandinfoprovider.hxx> #include <osl/mutex.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <cppuhelper/supportsservice.hxx> using namespace com::sun::star::uno; diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 14b59c263b85..c36818341ad0 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -395,15 +395,11 @@ void SAL_CALL NewMenuController::itemActivated( const css::awt::MenuEvent& ) if ( !(m_xFrame.is() && m_xPopupMenu.is()) ) return; - VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getFromUnoTunnel<VCLXMenu>( m_xPopupMenu )); - if ( !pPopupMenu ) - return; - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); bool bShowImages( rSettings.GetUseImagesInMenus() ); OUString aIconTheme( rSettings.DetermineIconTheme() ); - PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu()); + PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(m_xPopupMenu->GetMenu()); if ( m_bShowImages != bShowImages || m_aIconTheme != aIconTheme ) { diff --git a/framework/source/uielement/objectmenucontroller.cxx b/framework/source/uielement/objectmenucontroller.cxx index 62b5586eeea9..7e9e056d4293 100644 --- a/framework/source/uielement/objectmenucontroller.cxx +++ b/framework/source/uielement/objectmenucontroller.cxx @@ -27,6 +27,7 @@ #include <cppuhelper/weak.hxx> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> +#include <toolkit/awt/vclxmenu.hxx> using namespace com::sun::star::uno; using namespace com::sun::star::lang; diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx index ac025f8fc7c4..b17e8a6bfc60 100644 --- a/framework/source/uielement/popuptoolbarcontroller.cxx +++ b/framework/source/uielement/popuptoolbarcontroller.cxx @@ -79,7 +79,7 @@ protected: bool m_bHasController; bool m_bResourceURL; OUString m_aPopupCommand; - css::uno::Reference< css::awt::XPopupMenu > m_xPopupMenu; + rtl::Reference< VCLXPopupMenu > m_xPopupMenu; private: css::uno::Reference< css::frame::XUIControllerFactory > m_xPopupMenuFactory; @@ -247,10 +247,7 @@ void PopupMenuToolbarController::createPopupMenuController() try { - m_xPopupMenu.set( - m_xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xContext ), - css::uno::UNO_QUERY_THROW ); + m_xPopupMenu = new VCLXPopupMenu(); if (m_bResourceURL) { @@ -357,7 +354,7 @@ void GenericPopupToolbarController::statusChanged( const css::frame::FeatureStat ToolBoxItemId nId; if ( getToolboxId( nId, &pToolBox ) && pToolBox->IsItemEnabled( nId ) ) { - Menu* pVclMenu = comphelper::getFromUnoTunnel<VCLXMenu>( m_xPopupMenu )->GetMenu(); + Menu* pVclMenu = m_xPopupMenu->GetMenu(); pVclMenu->Activate(); pVclMenu->Deactivate(); } @@ -697,8 +694,7 @@ void SAL_CALL NewToolbarController::execute( sal_Int16 /*KeyModifier*/ ) aURL = m_xPopupMenu->getCommand(m_nMenuId); // TODO investigate how to wrap Get/SetUserValue in css::awt::XMenu - VCLXMenu* pMenu = comphelper::getFromUnoTunnel<VCLXMenu>(m_xPopupMenu); - MenuAttributes* pMenuAttributes(static_cast<MenuAttributes*>(pMenu->getUserValue(m_nMenuId))); + MenuAttributes* pMenuAttributes(static_cast<MenuAttributes*>(m_xPopupMenu->getUserValue(m_nMenuId))); if ( pMenuAttributes ) aTarget = pMenuAttributes->aTargetFrame; else @@ -750,8 +746,7 @@ void SAL_CALL NewToolbarController::updateImage() if ( m_xPopupMenu.is() && m_nMenuId ) { aURL = m_xPopupMenu->getCommand(m_nMenuId); - VCLXMenu* pMenu = comphelper::getFromUnoTunnel<VCLXMenu>(m_xPopupMenu); - MenuAttributes* pMenuAttributes(static_cast<MenuAttributes*>(pMenu->getUserValue(m_nMenuId))); + MenuAttributes* pMenuAttributes(static_cast<MenuAttributes*>(m_xPopupMenu->getUserValue(m_nMenuId))); if ( pMenuAttributes ) aImageId = pMenuAttributes->aImageId; } diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index dc4001a1f645..fe7de1c3d907 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -26,6 +26,7 @@ #include <svtools/imagemgr.hxx> #include <svtools/popupmenucontrollerbase.hxx> #include <tools/urlobj.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <unotools/historyoptions.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/graph.hxx> diff --git a/framework/source/uielement/resourcemenucontroller.cxx b/framework/source/uielement/resourcemenucontroller.cxx index 7a1364b41f4c..c1757895ee5b 100644 --- a/framework/source/uielement/resourcemenucontroller.cxx +++ b/framework/source/uielement/resourcemenucontroller.cxx @@ -225,7 +225,7 @@ void ResourceMenuController::updatePopupMenu() m_nNewMenuId = 1; // Now fill the menu with the configuration data. - framework::MenuBarManager::FillMenu( m_nNewMenuId, comphelper::getFromUnoTunnel<VCLXMenu>( m_xPopupMenu )->GetMenu(), m_aModuleName, m_xMenuContainer, m_xDispatchProvider ); + framework::MenuBarManager::FillMenu( m_nNewMenuId, m_xPopupMenu->GetMenu(), m_aModuleName, m_xMenuContainer, m_xDispatchProvider ); // For context menus, add object verbs. if ( !m_bContextMenu ) @@ -259,8 +259,7 @@ void ResourceMenuController::addVerbs( const css::uno::Sequence< css::embed::Ver xStorable.set( xController->getModel(), css::uno::UNO_QUERY ); bool bReadOnly = xStorable.is() && xStorable->isReadonly(); - VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>( m_xPopupMenu ); - Menu* pVCLMenu = pAwtMenu->GetMenu(); + Menu* pVCLMenu = m_xPopupMenu->GetMenu(); for ( const auto& rVerb : rVerbs ) { @@ -279,9 +278,8 @@ void ResourceMenuController::itemActivated( const css::awt::MenuEvent& /*rEvent* // Must initialize MenuBarManager here, because we want to let the app do context menu interception before. if ( !m_xMenuBarManager.is() ) { - VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>( m_xPopupMenu ); m_xMenuBarManager.set( new framework::MenuBarManager( - m_xContext, m_xFrame, m_xURLTransformer, m_xDispatchProvider, m_aModuleName, pAwtMenu->GetMenu(), false, !m_bContextMenu && !m_bInToolbar ) ); + m_xContext, m_xFrame, m_xURLTransformer, m_xDispatchProvider, m_aModuleName, m_xPopupMenu->GetMenu(), false, !m_bContextMenu && !m_bInToolbar ) ); m_xFrame->addFrameActionListener( m_xMenuBarManager ); } } @@ -475,8 +473,7 @@ void WindowListMenuController::itemActivated( const css::awt::MenuEvent& rEvent { SolarMutexGuard g; - VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>( m_xPopupMenu ); - Menu* pVCLMenu = pAwtMenu->GetMenu(); + Menu* pVCLMenu = m_xPopupMenu->GetMenu(); int nItemCount = pVCLMenu->GetItemCount(); if ( nItemCount > 0 ) diff --git a/framework/source/uielement/thesaurusmenucontroller.cxx b/framework/source/uielement/thesaurusmenucontroller.cxx index a0e9f93218f2..6a834757c3fa 100644 --- a/framework/source/uielement/thesaurusmenucontroller.cxx +++ b/framework/source/uielement/thesaurusmenucontroller.cxx @@ -24,6 +24,7 @@ #include <svl/lngmisc.hxx> #include <svtools/popupmenucontrollerbase.hxx> #include <comphelper/diagnose_ex.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <unotools/lingucfg.hxx> #include <vcl/commandinfoprovider.hxx> diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx index 1740bf1f1405..cf967788a5aa 100644 --- a/framework/source/uielement/toolbarmodemenucontroller.cxx +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/frame/ModuleManager.hpp> +#include <toolkit/awt/vclxmenu.hxx> #include <officecfg/Office/Common.hxx> #include <vcl/svapp.hxx> #include <vcl/EnumContext.hxx> @@ -276,7 +277,8 @@ void SAL_CALL ToolbarModeMenuController::setPopupMenu( const Reference< css::awt // Create popup menu on demand SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = xPopupMenu; + m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get()); + assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu"); m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(this) ); fillPopupMenu( m_xPopupMenu ); } diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 730190240334..aa2ebd88d039 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -47,6 +47,7 @@ #include <vcl/settings.hxx> #include <vcl/commandinfoprovider.hxx> #include <rtl/ustrbuf.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/window.hxx> #include <unotools/cmdoptions.hxx> @@ -714,7 +715,8 @@ void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::X // Create popup menu on demand SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = xPopupMenu; + m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get()); + assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu"); m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(this) ); fillPopupMenu( m_xPopupMenu ); } diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx index ee445710b9c0..9b3fed6d5f23 100644 --- a/include/sfx2/dispatch.hxx +++ b/include/sfx2/dispatch.hxx @@ -21,6 +21,7 @@ #include <memory> #include <sal/config.h> +#include <rtl/ref.hxx> #include <sfx2/dllapi.h> #include <sfx2/toolbarids.hxx> #include <sal/types.h> @@ -39,6 +40,7 @@ class SfxItemSet; class SfxModule; class Point; struct SfxDispatcher_Impl; +class VCLXPopupMenu; namespace com::sun::star::awt { class XPopupMenu; } namespace vcl { class Window; } @@ -176,7 +178,7 @@ public: SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame const * pNew ); SAL_DLLPRIVATE void InvalidateBindings_Impl(bool); - static boost::property_tree::ptree fillPopupMenu(const css::uno::Reference<css::awt::XPopupMenu>& rMenu); + static boost::property_tree::ptree fillPopupMenu(const rtl::Reference<VCLXPopupMenu>& rMenu); }; #endif diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index bb805cdc4179..8efa98a13e4f 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -57,6 +57,7 @@ class NotifyEvent; class SfxInPlaceClient; class SfxLokCallbackInterface; class SfxStoringHelper; +class VCLXPopupMenu; namespace rtl { class OStringBuffer; } namespace vcl { class PrinterController; } @@ -304,11 +305,11 @@ public: void SetController( SfxBaseController* pController ); css::uno::Reference<css::frame::XController> GetController() const; - bool TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>& rIn, + bool TryContextMenuInterception(const rtl::Reference<VCLXPopupMenu>& rIn, const OUString& rMenuIdentifier, - css::uno::Reference<css::awt::XPopupMenu>& rOut, + rtl::Reference<VCLXPopupMenu>& rOut, css::ui::ContextMenuExecuteEvent aEvent); - bool TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>&, + bool TryContextMenuInterception(const rtl::Reference<VCLXPopupMenu>&, const OUString& rMenuIdentifier, css::ui::ContextMenuExecuteEvent aEvent); diff --git a/include/svtools/popupmenucontrollerbase.hxx b/include/svtools/popupmenucontrollerbase.hxx index ef365a876592..7f34ac2e02b5 100644 --- a/include/svtools/popupmenucontrollerbase.hxx +++ b/include/svtools/popupmenucontrollerbase.hxx @@ -32,11 +32,13 @@ #include <tools/link.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/basemutex.hxx> +#include <rtl/ref.hxx> #include <rtl/ustring.hxx> namespace com :: sun :: star :: frame { class XFrame; } namespace com :: sun :: star :: uno { class XComponentContext; } namespace com :: sun :: star :: util { class XURLTransformer; } +class VCLXPopupMenu; namespace svt { @@ -117,7 +119,7 @@ namespace svt css::uno::Reference< css::frame::XDispatch > m_xDispatch; css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - css::uno::Reference< css::awt::XPopupMenu > m_xPopupMenu; + rtl::Reference< VCLXPopupMenu > m_xPopupMenu; }; } diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 1d9ccd42c4e9..c246aeb9971c 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/frame/XPopupMenuController.hpp> #include <comphelper/propertyvalue.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/helper/convert.hxx> #include <comphelper/diagnose_ex.hxx> #include <RptDef.hxx> @@ -434,9 +435,7 @@ void OReportSection::Command( const CommandEvent& _rCEvt ) if (!xMenuController.is()) return; - css::uno::Reference<css::awt::XPopupMenu> xPopupMenu( - xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", xContext), css::uno::UNO_QUERY); + rtl::Reference<VCLXPopupMenu> xPopupMenu = new VCLXPopupMenu(); if (!xPopupMenu.is()) return; diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 17edf97cc16d..e72f4706dd8e 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1801,10 +1801,9 @@ boost::property_tree::ptree fillPopupMenu(Menu* pMenu) } -boost::property_tree::ptree SfxDispatcher::fillPopupMenu(const css::uno::Reference<css::awt::XPopupMenu>& rPopupMenu) +boost::property_tree::ptree SfxDispatcher::fillPopupMenu(const rtl::Reference<VCLXPopupMenu>& rPopupMenu) { - VCLXMenu* pAwtMenu = comphelper::getFromUnoTunnel<VCLXMenu>(rPopupMenu); - PopupMenu* pVCLMenu = static_cast<PopupMenu*>(pAwtMenu->GetMenu()); + PopupMenu* pVCLMenu = static_cast<PopupMenu*>(rPopupMenu->GetMenu()); return ::fillPopupMenu(pVCLMenu); } @@ -1821,8 +1820,7 @@ void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, c 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 ); + rtl::Reference< VCLXPopupMenu > xPopupMenu = new VCLXPopupMenu(); if ( !xPopupController.is() || !xPopupMenu.is() ) return; diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx index 706add207855..f64e16e2a42c 100644 --- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx +++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx @@ -34,6 +34,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <sidebar/SidebarToolBox.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <cppuhelper/implbase.hxx> #define ICON_SIZE 25 @@ -341,8 +342,7 @@ IMPL_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar*, pNotebo xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), UNO_QUERY); - Reference<css::awt::XPopupMenu> xPopupMenu(xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", xContext), UNO_QUERY); + rtl::Reference<VCLXPopupMenu> xPopupMenu = new VCLXPopupMenu(); if (!xPopupController.is() || !xPopupMenu.is()) return; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 108574d410e2..1d494878a0a2 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -89,6 +89,7 @@ #include <iostream> #include <vector> #include <libxml/xmlwriter.h> +#include <toolkit/awt/vclxmenu.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1877,9 +1878,9 @@ void SfxViewShell::RemoveContextMenuInterceptor_Impl( const uno::Reference< ui:: pImpl->aInterceptorContainer.removeInterface( g, xInterceptor ); } -bool SfxViewShell::TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>& rIn, +bool SfxViewShell::TryContextMenuInterception(const rtl::Reference<VCLXPopupMenu>& rIn, const OUString& rMenuIdentifier, - css::uno::Reference<css::awt::XPopupMenu>& rOut, + rtl::Reference<VCLXPopupMenu>& rOut, ui::ContextMenuExecuteEvent aEvent) { rOut.clear(); @@ -1940,15 +1941,14 @@ bool SfxViewShell::TryContextMenuInterception(const css::uno::Reference<css::awt if (bModified) { // 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); + rOut = new VCLXPopupMenu(); ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer(rOut, aEvent.ActionTriggerContainer); } return true; } -bool SfxViewShell::TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>& rPopupMenu, +bool SfxViewShell::TryContextMenuInterception(const rtl::Reference<VCLXPopupMenu>& rPopupMenu, const OUString& rMenuIdentifier, css::ui::ContextMenuExecuteEvent aEvent) { bool bModified = false; diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index b4a4cbdc8bda..fe6ea88392b6 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -29,6 +29,7 @@ #include <vcl/svapp.hxx> #include <osl/mutex.hxx> #include <cppuhelper/supportsservice.hxx> +#include <toolkit/awt/vclxmenu.hxx> using namespace com::sun::star; using namespace css::uno; @@ -341,7 +342,8 @@ void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< awt::XPopu // Create popup menu on demand SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = xPopupMenu; + m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get()); + assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu"); m_xPopupMenu->addMenuListener( Reference< awt::XMenuListener >(this) ); Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 1d3a740126cd..b0a320168924 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5593,8 +5593,8 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) aEvent.SourceWindow = VCLUnoHelper::GetInterface( this ); aEvent.ExecutePosition.X = aPixPos.X(); aEvent.ExecutePosition.Y = aPixPos.Y(); - css::uno::Reference<css::awt::XPopupMenu> xMenu; - auto xMenuInterface = aROPopup.CreateMenuInterface(); + rtl::Reference<VCLXPopupMenu> xMenu; + rtl::Reference<VCLXPopupMenu> xMenuInterface = aROPopup.CreateMenuInterface(); if (GetView().TryContextMenuInterception(xMenuInterface, "private:resource/ReadonlyContextMenu", xMenu, aEvent)) { if (xMenu.is()) diff --git a/sw/source/uibase/docvw/romenu.hxx b/sw/source/uibase/docvw/romenu.hxx index 8961b93d7f12..1af58d3dee6d 100644 --- a/sw/source/uibase/docvw/romenu.hxx +++ b/sw/source/uibase/docvw/romenu.hxx @@ -20,6 +20,7 @@ #pragma once #include <editeng/brushitem.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <vcl/builder.hxx> #include <vcl/graph.hxx> #include <vcl/menu.hxx> @@ -70,7 +71,7 @@ class SwReadOnlyPopup public: SwReadOnlyPopup(const Point &rDPos, SwView &rV); - css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface() { return m_xMenu->CreateMenuInterface(); } + rtl::Reference<VCLXPopupMenu> CreateMenuInterface() { return new VCLXPopupMenu(m_xMenu); } ~SwReadOnlyPopup(); void Execute( vcl::Window* pWin, const Point &rPPos ); diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx index fc043046c93e..a071b6b5cf5f 100644 --- a/sw/source/uibase/inc/olmenu.hxx +++ b/sw/source/uibase/inc/olmenu.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/uno/Sequence.h> #include <rtl/ustring.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <vcl/builder.hxx> #include <vcl/menu.hxx> @@ -129,7 +130,7 @@ public: return *m_xPopupMenu; } - css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface() { return m_xPopupMenu->CreateMenuInterface(); } + rtl::Reference<VCLXPopupMenu> CreateMenuInterface() { return new VCLXPopupMenu(m_xPopupMenu); } void Execute( const tools::Rectangle& rPopupPos, vcl::Window* pWin ); void Execute( sal_uInt16 nId ); diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index 45b1851ad3c5..e6e337b6ccd2 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -723,11 +723,11 @@ bool SwView::ExecSpellPopup(const Point& rPt) aEvent.SourceWindow = VCLUnoHelper::GetInterface( m_pEditWin ); aEvent.ExecutePosition.X = aPixPos.X(); aEvent.ExecutePosition.Y = aPixPos.Y(); - css::uno::Reference<css::awt::XPopupMenu> xMenu; + rtl::Reference<VCLXPopupMenu> xMenu; OUString sMenuName = bUseGrammarContext ? OUString("private:resource/GrammarContextMenu") : OUString("private:resource/SpellContextMenu"); - auto xMenuInterface = xPopup->CreateMenuInterface(); + rtl::Reference<VCLXPopupMenu> xMenuInterface = xPopup->CreateMenuInterface(); if (TryContextMenuInterception(xMenuInterface, sMenuName, xMenu, aEvent)) { //! happy hacking for context menu modifying extensions of this