diff options
-rw-r--r-- | dbaccess/source/ui/control/dbtreelistbox.cxx | 2 | ||||
-rw-r--r-- | framework/inc/classes/rootactiontriggercontainer.hxx | 6 | ||||
-rw-r--r-- | framework/source/fwe/classes/rootactiontriggercontainer.cxx | 20 | ||||
-rw-r--r-- | framework/source/fwe/helper/actiontriggerhelper.cxx | 47 | ||||
-rw-r--r-- | include/framework/actiontriggerhelper.hxx | 11 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/docvw/romenu.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/olmenu.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewling.cxx | 2 |
11 files changed, 54 insertions, 58 deletions
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx index efb5a6871668..a153b42eda9a 100644 --- a/dbaccess/source/ui/control/dbtreelistbox.cxx +++ b/dbaccess/source/ui/control/dbtreelistbox.cxx @@ -400,7 +400,7 @@ IMPL_LINK(TreeListBox, CommandHdl, const CommandEvent&, rCEvt, bool) aEvent.ExecutePosition.X = -1; aEvent.ExecutePosition.Y = -1; aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( - pContextMenu.get(), &aMenuIdentifier ); + xPopupMenu, &aMenuIdentifier ); aEvent.Selection = new SelectionSupplier(m_pContextMenuProvider->getCurrentSelection(*m_xTreeView)); ::comphelper::OInterfaceIteratorHelper2 aIter( *pInterceptors ); diff --git a/framework/inc/classes/rootactiontriggercontainer.hxx b/framework/inc/classes/rootactiontriggercontainer.hxx index cc4f42d941b2..4e0691db989e 100644 --- a/framework/inc/classes/rootactiontriggercontainer.hxx +++ b/framework/inc/classes/rootactiontriggercontainer.hxx @@ -20,7 +20,7 @@ #pragma once #include <helper/propertysetcontainer.hxx> -#include <vcl/menu.hxx> +#include <com/sun/star/awt/XPopupMenu.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -40,7 +40,7 @@ class RootActionTriggerContainer final : public PropertySetContainer, public css::container::XNamed { public: - RootActionTriggerContainer( const Menu* pMenu, const OUString* pMenuIdentifier); + RootActionTriggerContainer(const css::uno::Reference<css::awt::XPopupMenu>& rMenu, const OUString* pMenuIdentifier); virtual ~RootActionTriggerContainer() override; // XInterface @@ -92,7 +92,7 @@ class RootActionTriggerContainer final : public PropertySetContainer, void FillContainer(); bool m_bContainerCreated; - VclPtr<const Menu> m_pMenu; + css::uno::Reference<css::awt::XPopupMenu> m_xMenu; const OUString* m_pMenuIdentifier; }; diff --git a/framework/source/fwe/classes/rootactiontriggercontainer.cxx b/framework/source/fwe/classes/rootactiontriggercontainer.cxx index 46e36d9bb94a..0325ede70ea0 100644 --- a/framework/source/fwe/classes/rootactiontriggercontainer.cxx +++ b/framework/source/fwe/classes/rootactiontriggercontainer.cxx @@ -44,10 +44,11 @@ const css::uno::Sequence<sal_Int8>& RootActionTriggerContainer::getUnoTunnelId() return seqID; } -RootActionTriggerContainer::RootActionTriggerContainer( const Menu* pMenu, const OUString* pMenuIdentifier ) : - m_bContainerCreated( false ) - , m_pMenu( pMenu ) - , m_pMenuIdentifier( pMenuIdentifier ) +RootActionTriggerContainer::RootActionTriggerContainer(const css::uno::Reference<css::awt::XPopupMenu>& rMenu, + const OUString* pMenuIdentifier) + : m_bContainerCreated(false) + , m_xMenu(rMenu) + , m_pMenuIdentifier(pMenuIdentifier) { } @@ -149,10 +150,10 @@ sal_Int32 SAL_CALL RootActionTriggerContainer::getCount() if ( !m_bContainerCreated ) { - if ( m_pMenu ) + if ( m_xMenu ) { SolarMutexGuard aSolarMutexGuard; - return m_pMenu->GetItemCount(); + return m_xMenu->getItemCount(); } else return 0; @@ -181,10 +182,10 @@ Type SAL_CALL RootActionTriggerContainer::getElementType() sal_Bool SAL_CALL RootActionTriggerContainer::hasElements() { - if ( m_pMenu ) + if (m_xMenu) { SolarMutexGuard aSolarMutexGuard; - return ( m_pMenu->GetItemCount() > 0 ); + return m_xMenu->getItemCount() > 0; } return false; @@ -237,8 +238,7 @@ void RootActionTriggerContainer::FillContainer() { m_bContainerCreated = true; ActionTriggerHelper::FillActionTriggerContainerFromMenu( - this, - m_pMenu ); + this, m_xMenu); } OUString RootActionTriggerContainer::getName() { diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx index 60917cccbfd0..fdacff5e3327 100644 --- a/framework/source/fwe/helper/actiontriggerhelper.cxx +++ b/framework/source/fwe/helper/actiontriggerhelper.cxx @@ -30,10 +30,9 @@ #include <tools/stream.hxx> #include <comphelper/servicehelper.hxx> #include <cppuhelper/weak.hxx> -#include <vcl/image.hxx> -#include <vcl/svapp.hxx> -#include <vcl/graph.hxx> #include <vcl/dibtools.hxx> +#include <vcl/graph.hxx> +#include <vcl/svapp.hxx> const sal_uInt16 START_ITEMID = 1000; @@ -228,7 +227,9 @@ static void InsertSubMenuItems(const Reference<XPopupMenu>& rSubMenu, sal_uInt16 // implementation helper ( ActionTrigger => menu ) /// @throws RuntimeException -static Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const Menu* pMenu, const Reference< XIndexContainer >& rActionTriggerContainer ) +static Reference< XPropertySet > CreateActionTrigger(sal_uInt16 nItemId, + const Reference<XPopupMenu>& rMenu, + const Reference<XIndexContainer>& rActionTriggerContainer) { Reference< XPropertySet > xPropSet; @@ -243,11 +244,11 @@ static Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const try { // Retrieve the menu attributes and set them in our PropertySet - OUString aLabel = pMenu->GetItemText( nItemId ); + OUString aLabel = rMenu->getItemText(nItemId); a <<= aLabel; xPropSet->setPropertyValue("Text", a ); - OUString aCommandURL = pMenu->GetItemCommand( nItemId ); + OUString aCommandURL = rMenu->getCommand(nItemId); if ( aCommandURL.isEmpty() ) { @@ -257,12 +258,9 @@ static Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const a <<= aCommandURL; xPropSet->setPropertyValue("CommandURL", a ); - Image aImage = pMenu->GetItemImage( nItemId ); - if ( !!aImage ) + Reference<XBitmap> xBitmap(rMenu->getItemImage(nItemId), UNO_QUERY); + if (xBitmap.is()) { - Reference<css::graphic::XGraphic> xGraphic = Graphic(aImage.GetBitmapEx()).GetXGraphic(); - Reference<XBitmap> xBitmap(xGraphic, UNO_QUERY); - assert(xGraphic.is() == xBitmap.is()); a <<= xBitmap; xPropSet->setPropertyValue("Image", a ); } @@ -303,21 +301,22 @@ static Reference< XIndexContainer > CreateActionTriggerContainer( const Referenc return Reference< XIndexContainer >(); } -static void FillActionTriggerContainerWithMenu( const Menu* pMenu, Reference< XIndexContainer > const & rActionTriggerContainer ) +static void FillActionTriggerContainerWithMenu(const Reference<XPopupMenu>& rMenu, + const Reference<XIndexContainer>& rActionTriggerContainer) { SolarMutexGuard aGuard; - for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ ) + for (sal_uInt16 nPos = 0, nCount = rMenu->getItemCount(); nPos < nCount; ++nPos) { - sal_uInt16 nItemId = pMenu->GetItemId( nPos ); - ::MenuItemType nType = pMenu->GetItemType( nPos ); + sal_uInt16 nItemId = rMenu->getItemId(nPos); + css::awt::MenuItemType nType = rMenu->getItemType(nPos); try { Any a; Reference< XPropertySet > xPropSet; - if ( nType == ::MenuItemType::SEPARATOR ) + if (nType == css::awt::MenuItemType_SEPARATOR) { xPropSet = CreateActionTriggerSeparator( rActionTriggerContainer ); @@ -326,20 +325,20 @@ static void FillActionTriggerContainerWithMenu( const Menu* pMenu, Reference< XI } else { - xPropSet = CreateActionTrigger( nItemId, pMenu, rActionTriggerContainer ); + xPropSet = CreateActionTrigger(nItemId, rMenu, rActionTriggerContainer); a <<= xPropSet; rActionTriggerContainer->insertByIndex( nPos, a ); - PopupMenu* pPopupMenu = pMenu->GetPopupMenu( nItemId ); - if ( pPopupMenu ) + css::uno::Reference<XPopupMenu> xPopupMenu = rMenu->getPopupMenu(nItemId); + if (xPopupMenu.is()) { // recursive call to build next sub menu Reference< XIndexContainer > xSubContainer = CreateActionTriggerContainer( rActionTriggerContainer ); a <<= xSubContainer; xPropSet->setPropertyValue("SubContainer", a ); - FillActionTriggerContainerWithMenu( pPopupMenu, xSubContainer ); + FillActionTriggerContainerWithMenu(xPopupMenu, xSubContainer); } } } @@ -361,16 +360,16 @@ void ActionTriggerHelper::CreateMenuFromActionTriggerContainer( void ActionTriggerHelper::FillActionTriggerContainerFromMenu( Reference< XIndexContainer > const & xActionTriggerContainer, - const Menu* pMenu ) + const css::uno::Reference<XPopupMenu>& rMenu) { - FillActionTriggerContainerWithMenu( pMenu, xActionTriggerContainer ); + FillActionTriggerContainerWithMenu(rMenu, xActionTriggerContainer); } Reference< XIndexContainer > ActionTriggerHelper::CreateActionTriggerContainerFromMenu( - const Menu* pMenu, + const css::uno::Reference<XPopupMenu>& rMenu, const OUString* pMenuIdentifier ) { - return new RootActionTriggerContainer( pMenu, pMenuIdentifier ); + return new RootActionTriggerContainer(rMenu, pMenuIdentifier); } } diff --git a/include/framework/actiontriggerhelper.hxx b/include/framework/actiontriggerhelper.hxx index 227535648950..d0efa7a3a39b 100644 --- a/include/framework/actiontriggerhelper.hxx +++ b/include/framework/actiontriggerhelper.hxx @@ -24,7 +24,6 @@ namespace com::sun::star::awt { class XPopupMenu; } namespace com::sun::star::container { class XIndexContainer; } -class Menu; namespace framework { @@ -45,20 +44,20 @@ namespace framework // to optimize the time of creation of a menu from an actiontrigger structure. // IMPORTANT: The caller must ensure that the menu pointer is valid through the // life time of the XIndexContainer object!!! - // @param pNewMenu = Must be a valid menu. Please be aware that this implementation is based on - // the above mentioned restriction!!! + // @param rMenu = Must be a valid menu. Please be aware that this implementation is based on + // the above mentioned restriction!!! static css::uno::Reference< css::container::XIndexContainer > CreateActionTriggerContainerFromMenu( - const Menu* pMenu, const OUString* pMenuIdentifier ); + const css::uno::Reference<css::awt::XPopupMenu>& rMenu, const OUString* pMenuIdentifier ); // Fills the submitted rActionTriggerContainer with the structure of the menu // provided as the second parameter // @param rActionTriggerContainer = must be an instance of service "com.sun.star.ui.ActionTriggerContainer" - // @param pNewMenu = must be a valid menu + // @param rMenu = must be a valid menu static void FillActionTriggerContainerFromMenu( css::uno::Reference< css::container::XIndexContainer > const & rActionTriggerContainer, - const Menu* pMenu ); + const css::uno::Reference<css::awt::XPopupMenu>& rMenu); }; } diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 2971c210ea59..54d962450e8f 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -53,7 +53,6 @@ class SfxModule; class SfxViewFrame; class Printer; class SfxPrinter; -class Menu; class NotifyEvent; class SfxInPlaceClient; class SfxLokCallbackInterface; @@ -299,7 +298,8 @@ public: void SetController( SfxBaseController* pController ); css::uno::Reference<css::frame::XController> GetController() const; - bool TryContextMenuInterception(const Menu& rIn, const OUString& rMenuIdentifier, + bool TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>& rIn, + const OUString& rMenuIdentifier, css::uno::Reference<css::awt::XPopupMenu>& rOut, css::ui::ContextMenuExecuteEvent aEvent); bool TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>&, diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 03cd1fe842d0..8fdf33487a56 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -25,7 +25,6 @@ #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> #include <vcl/weld.hxx> @@ -1850,7 +1849,8 @@ void SfxViewShell::RemoveContextMenuInterceptor_Impl( const uno::Reference< ui:: pImpl->aInterceptorContainer.removeInterface( xInterceptor ); } -bool SfxViewShell::TryContextMenuInterception(const Menu& rIn, const OUString& rMenuIdentifier, +bool SfxViewShell::TryContextMenuInterception(const css::uno::Reference<css::awt::XPopupMenu>& rIn, + const OUString& rMenuIdentifier, css::uno::Reference<css::awt::XPopupMenu>& rOut, ui::ContextMenuExecuteEvent aEvent) { @@ -1859,7 +1859,7 @@ bool SfxViewShell::TryContextMenuInterception(const Menu& rIn, const OUString& r // create container from menu aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( - &rIn, &rMenuIdentifier ); + rIn, &rMenuIdentifier); // get selection from controller aEvent.Selection.set( GetController(), uno::UNO_QUERY ); @@ -1920,15 +1920,11 @@ bool SfxViewShell::TryContextMenuInterception(const Menu& rIn, const OUString& r 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(pVCLMenu, &rMenuIdentifier); + aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( + rPopupMenu, &rMenuIdentifier); // get selection from controller aEvent.Selection = css::uno::Reference< css::view::XSelectionSupplier >( GetController(), css::uno::UNO_QUERY ); diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index b7c3890a5f71..5d0f3855a7c9 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5377,7 +5377,7 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) aEvent.ExecutePosition.X = aPixPos.X(); aEvent.ExecutePosition.Y = aPixPos.Y(); css::uno::Reference<css::awt::XPopupMenu> xMenu; - if (GetView().TryContextMenuInterception(aROPopup.GetMenu(), "private:resource/ReadonlyContextMenu", xMenu, aEvent)) + if (GetView().TryContextMenuInterception(aROPopup.CreateMenuInterface(), "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 edaab24da8ce..8961b93d7f12 100644 --- a/sw/source/uibase/docvw/romenu.hxx +++ b/sw/source/uibase/docvw/romenu.hxx @@ -70,7 +70,7 @@ class SwReadOnlyPopup public: SwReadOnlyPopup(const Point &rDPos, SwView &rV); - PopupMenu& GetMenu() const { return *m_xMenu; } + css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface() { return m_xMenu->CreateMenuInterface(); } ~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 479f4be98ab9..b5d8e59d7e5f 100644 --- a/sw/source/uibase/inc/olmenu.hxx +++ b/sw/source/uibase/inc/olmenu.hxx @@ -129,6 +129,8 @@ public: return *m_xPopupMenu; } + css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface() { return m_xPopupMenu->CreateMenuInterface(); } + 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 6a2685c5b38f..adb16218ef45 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -713,7 +713,7 @@ bool SwView::ExecSpellPopup(const Point& rPt) OUString sMenuName = bUseGrammarContext ? OUString("private:resource/GrammarContextMenu") : OUString("private:resource/SpellContextMenu"); - if (TryContextMenuInterception(xPopup->GetMenu(), sMenuName, xMenu, aEvent)) + if (TryContextMenuInterception(xPopup->CreateMenuInterface(), sMenuName, xMenu, aEvent)) { //! happy hacking for context menu modifying extensions of this //! 'custom made' menu... *sigh* (code copied from sfx2 and framework) |