1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_framework.hxx" 30*cdf0e10cSrcweir #include <framework/actiontriggerhelper.hxx> 31*cdf0e10cSrcweir #include <classes/actiontriggerseparatorpropertyset.hxx> 32*cdf0e10cSrcweir #include <classes/rootactiontriggercontainer.hxx> 33*cdf0e10cSrcweir #include <classes/imagewrapper.hxx> 34*cdf0e10cSrcweir #include <framework/addonsoptions.hxx> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp> 38*cdf0e10cSrcweir #include <vcl/svapp.hxx> 39*cdf0e10cSrcweir #include <vos/mutex.hxx> 40*cdf0e10cSrcweir #include <tools/stream.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 42*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir const sal_uInt16 START_ITEMID = 1000; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace rtl; 48*cdf0e10cSrcweir using namespace vos; 49*cdf0e10cSrcweir using namespace com::sun::star::awt; 50*cdf0e10cSrcweir using namespace com::sun::star::uno; 51*cdf0e10cSrcweir using namespace com::sun::star::lang; 52*cdf0e10cSrcweir using namespace com::sun::star::beans; 53*cdf0e10cSrcweir using namespace com::sun::star::container; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace framework 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 59*cdf0e10cSrcweir // implementation helper ( menu => ActionTrigger ) 60*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir sal_Bool IsSeparator( Reference< XPropertySet > xPropertySet ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir Reference< XServiceInfo > xServiceInfo( xPropertySet, UNO_QUERY ); 65*cdf0e10cSrcweir try 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir return xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR )) ); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir catch ( Exception& ) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir return sal_False; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir void GetMenuItemAttributes( Reference< XPropertySet > xActionTriggerPropertySet, 77*cdf0e10cSrcweir OUString& aMenuLabel, 78*cdf0e10cSrcweir OUString& aCommandURL, 79*cdf0e10cSrcweir OUString& aHelpURL, 80*cdf0e10cSrcweir Reference< XBitmap >& xBitmap, 81*cdf0e10cSrcweir Reference< XIndexContainer >& xSubContainer ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir Any a; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir try 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir // mandatory properties 88*cdf0e10cSrcweir a = xActionTriggerPropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )) ); 89*cdf0e10cSrcweir a >>= aMenuLabel; 90*cdf0e10cSrcweir a = xActionTriggerPropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )) ); 91*cdf0e10cSrcweir a >>= aCommandURL; 92*cdf0e10cSrcweir a = xActionTriggerPropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Image" )) ); 93*cdf0e10cSrcweir a >>= xBitmap; 94*cdf0e10cSrcweir a = xActionTriggerPropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "SubContainer" )) ); 95*cdf0e10cSrcweir a >>= xSubContainer; 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir catch ( Exception& ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // optional properties 102*cdf0e10cSrcweir try 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir a = xActionTriggerPropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" )) ); 105*cdf0e10cSrcweir a >>= aHelpURL; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir catch ( Exception& ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, Reference< XIndexContainer > xActionTriggerContainer ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir Reference< XIndexAccess > xIndexAccess( xActionTriggerContainer, UNO_QUERY ); 115*cdf0e10cSrcweir if ( xIndexAccess.is() ) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir AddonsOptions aAddonOptions; 118*cdf0e10cSrcweir const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); 119*cdf0e10cSrcweir sal_Bool bHiContrast = rSettings.GetHighContrastMode(); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < xIndexAccess->getCount(); i++ ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir try 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir Reference< XPropertySet > xPropSet; 128*cdf0e10cSrcweir if (( xIndexAccess->getByIndex( i ) >>= xPropSet ) && ( xPropSet.is() )) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir if ( IsSeparator( xPropSet )) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir // Separator 133*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 134*cdf0e10cSrcweir pSubMenu->InsertSeparator(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir else 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir // Menu item 139*cdf0e10cSrcweir OUString aLabel; 140*cdf0e10cSrcweir OUString aCommandURL; 141*cdf0e10cSrcweir OUString aHelpURL; 142*cdf0e10cSrcweir Reference< XBitmap > xBitmap; 143*cdf0e10cSrcweir Reference< XIndexContainer > xSubContainer; 144*cdf0e10cSrcweir sal_Bool bSpecialItemId = sal_False; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir sal_uInt16 nNewItemId = nItemId++; 147*cdf0e10cSrcweir GetMenuItemAttributes( xPropSet, aLabel, aCommandURL, aHelpURL, xBitmap, xSubContainer ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir // insert new menu item 152*cdf0e10cSrcweir sal_Int32 nIndex = aCommandURL.indexOf( aSlotURL ); 153*cdf0e10cSrcweir if ( nIndex >= 0 ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir // Special code for our menu implementation: some menu items don't have a 156*cdf0e10cSrcweir // command url but uses the item id as a unqiue identifier. These entries 157*cdf0e10cSrcweir // got a special url during conversion from menu=>actiontriggercontainer. 158*cdf0e10cSrcweir // Now we have to extract this special url and set the correct item id!!! 159*cdf0e10cSrcweir bSpecialItemId = sal_True; 160*cdf0e10cSrcweir nNewItemId = (sal_uInt16)aCommandURL.copy( nIndex+aSlotURL.getLength() ).toInt32(); 161*cdf0e10cSrcweir pSubMenu->InsertItem( nNewItemId, aLabel ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir else 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir pSubMenu->InsertItem( nNewItemId, aLabel ); 166*cdf0e10cSrcweir pSubMenu->SetItemCommand( nNewItemId, aCommandURL ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir // handle bitmap 170*cdf0e10cSrcweir if ( xBitmap.is() ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir sal_Bool bImageSet = sal_False; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir Reference< XUnoTunnel > xUnoTunnel( xBitmap, UNO_QUERY ); 175*cdf0e10cSrcweir if ( xUnoTunnel.is() ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir // Try to get implementation pointer through XUnoTunnel 178*cdf0e10cSrcweir sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::GetUnoTunnelId() ); 179*cdf0e10cSrcweir if ( nPointer ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir // This is our own optimized implementation of menu images! 182*cdf0e10cSrcweir ImageWrapper* pImageWrapper = reinterpret_cast< ImageWrapper * >( nPointer ); 183*cdf0e10cSrcweir Image aMenuImage = pImageWrapper->GetImage(); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if ( !!aMenuImage ) 186*cdf0e10cSrcweir pSubMenu->SetItemImage( nNewItemId, aMenuImage ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir bImageSet = sal_True; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir if ( !bImageSet ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir // This is an unknown implementation of a XBitmap interface. We have to 195*cdf0e10cSrcweir // use a more time consuming way to build an Image! 196*cdf0e10cSrcweir Image aImage; 197*cdf0e10cSrcweir Bitmap aBitmap; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir Sequence< sal_Int8 > aDIBSeq; 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir aDIBSeq = xBitmap->getDIB(); 202*cdf0e10cSrcweir SvMemoryStream aMem( (void *)aDIBSeq.getConstArray(), aDIBSeq.getLength(), STREAM_READ ); 203*cdf0e10cSrcweir aMem >> aBitmap; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir aDIBSeq = xBitmap->getMaskDIB(); 207*cdf0e10cSrcweir if ( aDIBSeq.getLength() > 0 ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir Bitmap aMaskBitmap; 210*cdf0e10cSrcweir SvMemoryStream aMem( (void *)aDIBSeq.getConstArray(), aDIBSeq.getLength(), STREAM_READ ); 211*cdf0e10cSrcweir aMem >> aMaskBitmap; 212*cdf0e10cSrcweir aImage = Image( aBitmap, aMaskBitmap ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir else 215*cdf0e10cSrcweir aImage = Image( aBitmap ); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir if ( !!aImage ) 218*cdf0e10cSrcweir pSubMenu->SetItemImage( nNewItemId, aImage ); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir else 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir // Support add-on images for context menu interceptors 224*cdf0e10cSrcweir Image aImage = aAddonOptions.GetImageFromURL( aCommandURL, sal_False, bHiContrast, sal_True ); 225*cdf0e10cSrcweir if ( !!aImage ) 226*cdf0e10cSrcweir pSubMenu->SetItemImage( nNewItemId, aImage ); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir if ( xSubContainer.is() ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir PopupMenu* pNewSubMenu = new PopupMenu; 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir // Sub menu (recursive call CreateSubMenu ) 234*cdf0e10cSrcweir InsertSubMenuItems( pNewSubMenu, nItemId, xSubContainer ); 235*cdf0e10cSrcweir pSubMenu->SetPopupMenu( nNewItemId, pNewSubMenu ); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir catch ( IndexOutOfBoundsException ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir return; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir catch ( WrappedTargetException ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir return; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir catch ( RuntimeException ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir return; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 259*cdf0e10cSrcweir // implementation helper ( ActionTrigger => menu ) 260*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir Reference< XPropertySet > CreateActionTrigger( sal_uInt16 nItemId, const Menu* pMenu, const Reference< XIndexContainer >& rActionTriggerContainer ) throw ( RuntimeException ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir Reference< XPropertySet > xPropSet; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMultiServiceFactory( rActionTriggerContainer, UNO_QUERY ); 267*cdf0e10cSrcweir if ( xMultiServiceFactory.is() ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir xPropSet = Reference< XPropertySet >( xMultiServiceFactory->createInstance( 270*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ActionTrigger" )) ), 271*cdf0e10cSrcweir UNO_QUERY ); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir Any a; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir try 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir // Retrieve the menu attributes and set them in our PropertySet 278*cdf0e10cSrcweir OUString aLabel = pMenu->GetItemText( nItemId ); 279*cdf0e10cSrcweir a <<= aLabel; 280*cdf0e10cSrcweir xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )), a ); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir OUString aCommandURL = pMenu->GetItemCommand( nItemId ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir if ( aCommandURL.getLength() == 0 ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir aCommandURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 287*cdf0e10cSrcweir aCommandURL += OUString::valueOf( (sal_Int32)nItemId ); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir a <<= aCommandURL; 291*cdf0e10cSrcweir xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )), a ); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir Image aImage = pMenu->GetItemImage( nItemId ); 294*cdf0e10cSrcweir if ( !!aImage ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir // We use our own optimized XBitmap implementation 297*cdf0e10cSrcweir Reference< XBitmap > xBitmap( static_cast< cppu::OWeakObject* >( new ImageWrapper( aImage )), UNO_QUERY ); 298*cdf0e10cSrcweir a <<= xBitmap; 299*cdf0e10cSrcweir xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Image" )), a ); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir catch ( Exception& ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir return xPropSet; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir Reference< XPropertySet > CreateActionTriggerSeparator( const Reference< XIndexContainer >& rActionTriggerContainer ) throw ( RuntimeException ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMultiServiceFactory( rActionTriggerContainer, UNO_QUERY ); 313*cdf0e10cSrcweir if ( xMultiServiceFactory.is() ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir return Reference< XPropertySet >( xMultiServiceFactory->createInstance( 316*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ActionTriggerSeparator" )) ), 317*cdf0e10cSrcweir UNO_QUERY ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir return Reference< XPropertySet >(); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir Reference< XIndexContainer > CreateActionTriggerContainer( const Reference< XIndexContainer >& rActionTriggerContainer ) throw ( RuntimeException ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMultiServiceFactory( rActionTriggerContainer, UNO_QUERY ); 326*cdf0e10cSrcweir if ( xMultiServiceFactory.is() ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir return Reference< XIndexContainer >( xMultiServiceFactory->createInstance( 329*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ActionTriggerContainer" )) ), 330*cdf0e10cSrcweir UNO_QUERY ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir return Reference< XIndexContainer >(); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir void FillActionTriggerContainerWithMenu( const Menu* pMenu, Reference< XIndexContainer >& rActionTriggerContainer ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir sal_uInt16 nItemId = pMenu->GetItemId( nPos ); 343*cdf0e10cSrcweir MenuItemType nType = pMenu->GetItemType( nPos ); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir try 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir Any a; 348*cdf0e10cSrcweir Reference< XPropertySet > xPropSet; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir if ( nType == MENUITEM_SEPARATOR ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir xPropSet = CreateActionTriggerSeparator( rActionTriggerContainer ); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir a <<= xPropSet; 355*cdf0e10cSrcweir rActionTriggerContainer->insertByIndex( nPos, a ); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir else 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir xPropSet = CreateActionTrigger( nItemId, pMenu, rActionTriggerContainer ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir a <<= xPropSet; 362*cdf0e10cSrcweir rActionTriggerContainer->insertByIndex( nPos, a ); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir PopupMenu* pPopupMenu = pMenu->GetPopupMenu( nItemId ); 365*cdf0e10cSrcweir if ( pPopupMenu ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir // recursive call to build next sub menu 368*cdf0e10cSrcweir Reference< XIndexContainer > xSubContainer = CreateActionTriggerContainer( rActionTriggerContainer ); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir a <<= xSubContainer; 371*cdf0e10cSrcweir xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "SubContainer" )), a ); 372*cdf0e10cSrcweir FillActionTriggerContainerWithMenu( pPopupMenu, xSubContainer ); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir catch ( Exception& ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir void ActionTriggerHelper::CreateMenuFromActionTriggerContainer( 383*cdf0e10cSrcweir Menu* pNewMenu, 384*cdf0e10cSrcweir const Reference< XIndexContainer >& rActionTriggerContainer ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir sal_uInt16 nItemId = START_ITEMID; 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir if ( rActionTriggerContainer.is() ) 389*cdf0e10cSrcweir InsertSubMenuItems( pNewMenu, nItemId, rActionTriggerContainer ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir void ActionTriggerHelper::FillActionTriggerContainerFromMenu( 393*cdf0e10cSrcweir Reference< XIndexContainer >& xActionTriggerContainer, 394*cdf0e10cSrcweir const Menu* pMenu ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir FillActionTriggerContainerWithMenu( pMenu, xActionTriggerContainer ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir Reference< XIndexContainer > ActionTriggerHelper::CreateActionTriggerContainerFromMenu( 400*cdf0e10cSrcweir // #110897# 401*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 402*cdf0e10cSrcweir const Menu* pMenu, 403*cdf0e10cSrcweir const ::rtl::OUString* pMenuIdentifier ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir return new RootActionTriggerContainer( pMenu, pMenuIdentifier, xServiceFactory ); 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir } 409