24#include <com/sun/star/awt/XBitmap.hpp>
25#include <com/sun/star/awt/XPopupMenu.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28#include <com/sun/star/lang/XServiceInfo.hpp>
65 OUString& aCommandURL,
75 a = xActionTriggerPropertySet->getPropertyValue(
"Text");
77 a = xActionTriggerPropertySet->getPropertyValue(
"CommandURL");
79 a = xActionTriggerPropertySet->getPropertyValue(
"Image");
81 a = xActionTriggerPropertySet->getPropertyValue(
"SubContainer");
91 a = xActionTriggerPropertySet->getPropertyValue(
"HelpURL");
102 if ( !xActionTriggerContainer.is() )
105 AddonsOptions aAddonOptions;
106 OUString aSlotURL(
"slot:" );
108 for ( sal_Int32
i = 0;
i < xActionTriggerContainer->getCount();
i++ )
113 if (( xActionTriggerContainer->getByIndex(
i ) >>= xPropSet ) && ( xPropSet.is() ))
119 rSubMenu->insertSeparator(
i);
125 OUString aCommandURL;
130 sal_uInt16 nNewItemId = nItemId++;
136 sal_Int32
nIndex = aCommandURL.indexOf( aSlotURL );
143 nNewItemId =
static_cast<sal_uInt16
>(
o3tl::toInt32(aCommandURL.subView(
nIndex+aSlotURL.getLength() )));
144 rSubMenu->insertItem(nNewItemId,
aLabel, 0,
i);
148 rSubMenu->insertItem(nNewItemId,
aLabel, 0,
i);
149 rSubMenu->setCommand(nNewItemId, aCommandURL);
155 bool bImageSet =
false;
161 rSubMenu->setItemImage(nNewItemId, xGraphic,
false);
173 aDIBSeq = xBitmap->getDIB();
174 SvMemoryStream aMem(
const_cast<sal_Int8 *
>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ );
178 aDIBSeq = xBitmap->getMaskDIB();
179 if ( aDIBSeq.hasElements() )
182 SvMemoryStream aMem(
const_cast<sal_Int8 *
>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ );
183 ReadDIB(aMaskBitmap, aMem,
true);
188 rSubMenu->setItemImage(nNewItemId,
Graphic(aBitmap).GetXGraphic(),
false);
194 BitmapEx aBitmap(aAddonOptions.GetImageFromURL(aCommandURL,
false,
true));
196 rSubMenu->setItemImage(nNewItemId,
Graphic(aBitmap).GetXGraphic(),
false);
199 if ( xSubContainer.is() )
205 rSubMenu->setPopupMenu(nNewItemId, xNewSubMenu);
211 catch (
const IndexOutOfBoundsException&)
215 catch (
const WrappedTargetException&)
236 if ( xMultiServiceFactory.is() )
238 xPropSet.set( xMultiServiceFactory->createInstance(
"com.sun.star.ui.ActionTrigger" ),
246 OUString
aLabel = rMenu->getItemText(nItemId);
248 xPropSet->setPropertyValue(
"Text",
a );
250 OUString aCommandURL = rMenu->getCommand(nItemId);
252 if ( aCommandURL.isEmpty() )
254 aCommandURL =
"slot:" + OUString::number( nItemId );
258 xPropSet->setPropertyValue(
"CommandURL",
a );
264 xPropSet->setPropertyValue(
"Image",
a );
279 if ( xMultiServiceFactory.is() )
282 "com.sun.star.ui.ActionTriggerSeparator" ),
293 if ( xMultiServiceFactory.is() )
296 "com.sun.star.ui.ActionTriggerContainer" ),
310 sal_uInt16 nItemId = rMenu->getItemId(
nPos);
311 css::awt::MenuItemType
nType = rMenu->getItemType(
nPos);
318 if (
nType == css::awt::MenuItemType_SEPARATOR)
323 rActionTriggerContainer->insertByIndex(
nPos,
a );
330 rActionTriggerContainer->insertByIndex(
nPos,
a );
332 css::uno::Reference<XPopupMenu> xPopupMenu = rMenu->getPopupMenu(nItemId);
339 xPropSet->setPropertyValue(
"SubContainer",
a );
356 if ( rActionTriggerContainer.is() )
362 const css::uno::Reference<XPopupMenu>& rMenu)
368 const css::uno::Reference<XPopupMenu>& rMenu,
369 const OUString* pMenuIdentifier )
const sal_uInt16 START_ITEMID
constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGERSEPARATOR
Bitmap GetBitmap(Color aTransparentReplaceColor) const
static void FillActionTriggerContainerFromMenu(css::uno::Reference< css::container::XIndexContainer > const &rActionTriggerContainer, const css::uno::Reference< css::awt::XPopupMenu > &rMenu)
static void CreateMenuFromActionTriggerContainer(const css::uno::Reference< css::awt::XPopupMenu > &rNewMenu, const css::uno::Reference< css::container::XIndexContainer > &rActionTriggerContainer)
static css::uno::Reference< css::container::XIndexContainer > CreateActionTriggerContainerFromMenu(const css::uno::Reference< css::awt::XPopupMenu > &rMenu, const OUString *pMenuIdentifier)
static void InsertSubMenuItems(const Reference< XPopupMenu > &rSubMenu, sal_uInt16 &nItemId, const Reference< XIndexContainer > &xActionTriggerContainer)
static void GetMenuItemAttributes(const Reference< XPropertySet > &xActionTriggerPropertySet, OUString &aMenuLabel, OUString &aCommandURL, OUString &aHelpURL, Reference< XBitmap > &xBitmap, Reference< XIndexContainer > &xSubContainer)
static void FillActionTriggerContainerWithMenu(const Reference< XPopupMenu > &rMenu, const Reference< XIndexContainer > &rActionTriggerContainer)
static Reference< XPropertySet > CreateActionTriggerSeparator(const Reference< XIndexContainer > &rActionTriggerContainer)
static Reference< XPropertySet > CreateActionTrigger(sal_uInt16 nItemId, const Reference< XPopupMenu > &rMenu, const Reference< XIndexContainer > &rActionTriggerContainer)
static bool IsSeparator(const Reference< XPropertySet > &xPropertySet)
static Reference< XIndexContainer > CreateActionTriggerContainer(const Reference< XIndexContainer > &rActionTriggerContainer)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)