summaryrefslogtreecommitdiff
path: root/framework/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-11 21:09:39 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-12-12 13:35:00 +0100
commitafa35742a4633db31b6d6c72cf45741506e9edfb (patch)
tree10fb0b0116ddf6fcc2ee34c9baa39b1ec0103a83 /framework/source
parent569de88e9c7eda964252518282d26a8f7d059718 (diff)
prefer more css::awt::XPopupMenu api
Change-Id: Ib008281d63071ea79935af83cbe434be66155455 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126692 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'framework/source')
-rw-r--r--framework/source/fwe/classes/rootactiontriggercontainer.cxx20
-rw-r--r--framework/source/fwe/helper/actiontriggerhelper.cxx47
2 files changed, 33 insertions, 34 deletions
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);
}
}