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_toolkit.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <toolkit/awt/vclxmenu.hxx> 33*cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 34*cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx> 35*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 36*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 38*cdf0e10cSrcweir #include <rtl/memory.h> 39*cdf0e10cSrcweir #include <rtl/uuid.h> 40*cdf0e10cSrcweir #include <vos/mutex.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <vcl/menu.hxx> 43*cdf0e10cSrcweir #include <vcl/keycod.hxx> 44*cdf0e10cSrcweir #include <vcl/image.hxx> 45*cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 46*cdf0e10cSrcweir #include <vcl/svapp.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #ifdef DBG_UTIL 52*cdf0e10cSrcweir #define THROW_MENUITEM_NOT_FOUND( Func, nItemId ) \ 53*cdf0e10cSrcweir if ( MENU_ITEM_NOTFOUND == mpMenu->GetItemPos( nItemId ) ) \ 54*cdf0e10cSrcweir throw ::com::sun::star::container::NoSuchElementException( \ 55*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( Func ) ) \ 56*cdf0e10cSrcweir += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": There is no menu item with " ) ) \ 57*cdf0e10cSrcweir += ::rtl::OUString::valueOf( sal_Int32( nItemId ) ) \ 58*cdf0e10cSrcweir += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " as identifier" ) ), \ 59*cdf0e10cSrcweir *this \ 60*cdf0e10cSrcweir ); 61*cdf0e10cSrcweir #define THROW_MENUPOS_NOT_FOUND( Func, nPos ) \ 62*cdf0e10cSrcweir if ( MENU_ITEM_NOTFOUND == sal_uInt16( nPos ) ) \ 63*cdf0e10cSrcweir throw ::com::sun::star::container::NoSuchElementException( \ 64*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( Func ) ) \ 65*cdf0e10cSrcweir += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": There is no menu item at position " ) ) \ 66*cdf0e10cSrcweir += ::rtl::OUString::valueOf( sal_Int32( nPos ) ), \ 67*cdf0e10cSrcweir *this \ 68*cdf0e10cSrcweir ); 69*cdf0e10cSrcweir #else 70*cdf0e10cSrcweir #define THROW_MENUITEM_NOT_FOUND( Func, nItemId ) \ 71*cdf0e10cSrcweir if ( MENU_ITEM_NOTFOUND == mpMenu->GetItemPos( nItemId ) ) \ 72*cdf0e10cSrcweir throw ::com::sun::star::container::NoSuchElementException(); 73*cdf0e10cSrcweir #define THROW_MENUPOS_NOT_FOUND( Func, nPos ) \ 74*cdf0e10cSrcweir if ( MENU_ITEM_NOTFOUND == sal_uInt16( nPos ) ) \ 75*cdf0e10cSrcweir throw ::com::sun::star::container::NoSuchElementException(); 76*cdf0e10cSrcweir #endif 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // ---------------------------------------------------- 80*cdf0e10cSrcweir // class VCLXMenu 81*cdf0e10cSrcweir // ---------------------------------------------------- 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir DBG_NAME(VCLXMenu) 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir VCLXMenu::VCLXMenu() : maMenuListeners( *this ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir DBG_CTOR( VCLXMenu, 0 ); 88*cdf0e10cSrcweir mpMenu = NULL; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir VCLXMenu::VCLXMenu( Menu* pMenu ) : maMenuListeners( *this ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir DBG_CTOR( VCLXMenu, 0 ); 94*cdf0e10cSrcweir mpMenu = pMenu; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir VCLXMenu::~VCLXMenu() 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir DBG_DTOR( VCLXMenu, 0 ); 100*cdf0e10cSrcweir for ( sal_uInt32 n = maPopupMenueRefs.Count(); n; ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pRef = maPopupMenueRefs.GetObject( --n ); 103*cdf0e10cSrcweir delete pRef; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir if ( mpMenu ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir mpMenu->RemoveEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); 108*cdf0e10cSrcweir delete mpMenu; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir sal_Bool VCLXMenu::IsPopupMenu() const 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir return (mpMenu && ! mpMenu->IsMenuBar()); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir void VCLXMenu::ImplCreateMenu( sal_Bool bPopup ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir DBG_ASSERT( !mpMenu, "CreateMenu: Menu exists!" ); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if ( bPopup ) 122*cdf0e10cSrcweir mpMenu = new PopupMenu; 123*cdf0e10cSrcweir else 124*cdf0e10cSrcweir mpMenu = new MenuBar; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir DBG_ASSERT( pEvent && pEvent->ISA( VclMenuEvent ), "Unknown Event!" ); 132*cdf0e10cSrcweir if ( pEvent && pEvent->ISA( VclMenuEvent ) ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir DBG_ASSERT( ((VclMenuEvent*)pEvent)->GetMenu() && mpMenu, "Menu???" ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir VclMenuEvent* pMenuEvent = (VclMenuEvent*)pEvent; 137*cdf0e10cSrcweir if ( pMenuEvent->GetMenu() == mpMenu ) // Also called for the root menu 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir switch ( pMenuEvent->GetId() ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir case VCLEVENT_MENU_SELECT: 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir if ( maMenuListeners.getLength() ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir ::com::sun::star::awt::MenuEvent aEvent; 146*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 147*cdf0e10cSrcweir aEvent.MenuId = mpMenu->GetCurItemId(); 148*cdf0e10cSrcweir maMenuListeners.select( aEvent ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir case VCLEVENT_OBJECT_DYING: 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir mpMenu = NULL; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir break; 157*cdf0e10cSrcweir case VCLEVENT_MENU_HIGHLIGHT: 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir if ( maMenuListeners.getLength() ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir ::com::sun::star::awt::MenuEvent aEvent; 162*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 163*cdf0e10cSrcweir aEvent.MenuId = mpMenu->GetCurItemId(); 164*cdf0e10cSrcweir maMenuListeners.highlight( aEvent ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir break; 168*cdf0e10cSrcweir case VCLEVENT_MENU_ACTIVATE: 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir if ( maMenuListeners.getLength() ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir ::com::sun::star::awt::MenuEvent aEvent; 173*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 174*cdf0e10cSrcweir aEvent.MenuId = mpMenu->GetCurItemId(); 175*cdf0e10cSrcweir maMenuListeners.activate( aEvent ); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir break; 179*cdf0e10cSrcweir case VCLEVENT_MENU_DEACTIVATE: 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if ( maMenuListeners.getLength() ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir ::com::sun::star::awt::MenuEvent aEvent; 184*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 185*cdf0e10cSrcweir aEvent.MenuId = mpMenu->GetCurItemId(); 186*cdf0e10cSrcweir maMenuListeners.deactivate( aEvent ); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir break; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir // ignore accessibility events 192*cdf0e10cSrcweir case VCLEVENT_MENU_ENABLE: 193*cdf0e10cSrcweir case VCLEVENT_MENU_INSERTITEM: 194*cdf0e10cSrcweir case VCLEVENT_MENU_REMOVEITEM: 195*cdf0e10cSrcweir case VCLEVENT_MENU_SUBMENUACTIVATE: 196*cdf0e10cSrcweir case VCLEVENT_MENU_SUBMENUDEACTIVATE: 197*cdf0e10cSrcweir case VCLEVENT_MENU_SUBMENUCHANGED: 198*cdf0e10cSrcweir case VCLEVENT_MENU_DEHIGHLIGHT: 199*cdf0e10cSrcweir case VCLEVENT_MENU_DISABLE: 200*cdf0e10cSrcweir case VCLEVENT_MENU_ITEMTEXTCHANGED: 201*cdf0e10cSrcweir case VCLEVENT_MENU_ITEMCHECKED: 202*cdf0e10cSrcweir case VCLEVENT_MENU_ITEMUNCHECKED: 203*cdf0e10cSrcweir case VCLEVENT_MENU_SHOW: 204*cdf0e10cSrcweir case VCLEVENT_MENU_HIDE: 205*cdf0e10cSrcweir break; 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir default: DBG_ERROR( "MenuEventListener - Unknown event!" ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir return 0; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir //============================================================================= 216*cdf0e10cSrcweir //============================================================================= 217*cdf0e10cSrcweir //============================================================================= 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 221*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXMenu::getImplementationName( ) 222*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); 225*cdf0e10cSrcweir const sal_Bool bIsPopupMenu = IsPopupMenu(); 226*cdf0e10cSrcweir aGuard.clear(); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir ::rtl::OUString implName( RTL_CONSTASCII_USTRINGPARAM( "stardiv.Toolkit." ) ); 229*cdf0e10cSrcweir if ( bIsPopupMenu ) 230*cdf0e10cSrcweir implName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VCLXPopupMenu" ) ); 231*cdf0e10cSrcweir else 232*cdf0e10cSrcweir implName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VCLXMenuBar" ) ); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir return implName; 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL VCLXMenu::getSupportedServiceNames( ) 239*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); 242*cdf0e10cSrcweir const sal_Bool bIsPopupMenu = IsPopupMenu(); 243*cdf0e10cSrcweir aGuard.clear(); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( 1 ); 246*cdf0e10cSrcweir if ( bIsPopupMenu ) 247*cdf0e10cSrcweir aNames[ 0 ] = ::rtl::OUString::createFromAscii( szServiceName2_PopupMenu ); 248*cdf0e10cSrcweir else 249*cdf0e10cSrcweir aNames[ 0 ] = ::rtl::OUString::createFromAscii( szServiceName2_MenuBar ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir return aNames; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir ::sal_Bool SAL_CALL VCLXMenu::supportsService( const ::rtl::OUString& rServiceName ) 256*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if ( aServiceNames[ 0 ] == rServiceName ) 261*cdf0e10cSrcweir return sal_True; 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir return sal_False; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 268*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMenu::queryInterface( const ::com::sun::star::uno::Type & rType ) 269*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); 272*cdf0e10cSrcweir const sal_Bool bIsPopupMenu = IsPopupMenu(); 273*cdf0e10cSrcweir aGuard.clear(); 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir if ( bIsPopupMenu ) 278*cdf0e10cSrcweir aRet = ::cppu::queryInterface( rType, 279*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenu*, (::com::sun::star::awt::XMenuBar*) this ), 280*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XPopupMenu*, this ), 281*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XPopupMenuExtended*, this ), 282*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, (::com::sun::star::awt::XPopupMenuExtended*) this ), 283*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended2*, (::com::sun::star::awt::XPopupMenuExtended*) this ), 284*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), 285*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), 286*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); 287*cdf0e10cSrcweir else 288*cdf0e10cSrcweir aRet = ::cppu::queryInterface( rType, 289*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenu*, (::com::sun::star::awt::XMenuBar*) this ), 290*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBar*, this ), 291*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBarExtended*, this ), 292*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, (::com::sun::star::awt::XMenuBarExtended*) this ), 293*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended2*, (::com::sun::star::awt::XMenuBarExtended*) this ), 294*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), 295*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), 296*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir // ::com::sun::star::lang::XUnoTunnel 302*cdf0e10cSrcweir IMPL_XUNOTUNNEL( VCLXMenu ) 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 305*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXMenu::getTypes() 306*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); 309*cdf0e10cSrcweir const sal_Bool bIsPopupMenu = IsPopupMenu(); 310*cdf0e10cSrcweir aGuard.clear(); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir static ::cppu::OTypeCollection* pCollectionMenuBar = NULL; 313*cdf0e10cSrcweir static ::cppu::OTypeCollection* pCollectionPopupMenu = NULL; 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir if ( bIsPopupMenu ) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir if( !pCollectionPopupMenu ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); 320*cdf0e10cSrcweir if( !pCollectionPopupMenu ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir static ::cppu::OTypeCollection collectionPopupMenu( 323*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider>* ) NULL ), 324*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), 325*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu>* ) NULL ), 326*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenuExtended>* ) NULL ), 327*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ), 328*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended2>* ) NULL ), 329*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ) ); 330*cdf0e10cSrcweir pCollectionPopupMenu = &collectionPopupMenu; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir return (*pCollectionPopupMenu).getTypes(); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir else 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir if( !pCollectionMenuBar ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); 341*cdf0e10cSrcweir if( !pCollectionMenuBar ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir static ::cppu::OTypeCollection collectionMenuBar( 344*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider>* ) NULL ), 345*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), 346*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar>* ) NULL ), 347*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBarExtended>* ) NULL ), 348*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ), 349*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended2>* ) NULL ), 350*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ) ); 351*cdf0e10cSrcweir pCollectionMenuBar = &collectionMenuBar; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir return (*pCollectionMenuBar).getTypes(); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > VCLXMenu::getImplementationId() 360*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); 363*cdf0e10cSrcweir const sal_Bool bIsPopupMenu = IsPopupMenu(); 364*cdf0e10cSrcweir aGuard.clear(); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir static ::cppu::OImplementationId* pIdMenuBar = NULL; 367*cdf0e10cSrcweir static ::cppu::OImplementationId* pIdPopupMenu = NULL; 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir if ( bIsPopupMenu ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir if( !pIdPopupMenu ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); 374*cdf0e10cSrcweir if( !pIdPopupMenu ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir static ::cppu::OImplementationId idPopupMenu( sal_False ); 377*cdf0e10cSrcweir pIdPopupMenu = &idPopupMenu; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir return (*pIdPopupMenu).getImplementationId(); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir else 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir if( !pIdMenuBar ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); 388*cdf0e10cSrcweir if( !pIdMenuBar ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir static ::cppu::OImplementationId idMenuBar( sal_False ); 391*cdf0e10cSrcweir pIdMenuBar = &idMenuBar; 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir return (*pIdMenuBar).getImplementationId(); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir //============================================================================= 401*cdf0e10cSrcweir //============================================================================= 402*cdf0e10cSrcweir //============================================================================= 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir void VCLXMenu::addMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir maMenuListeners.addInterface( rxListener ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void VCLXMenu::removeMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir maMenuListeners.removeInterface( rxListener ); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir void VCLXMenu::insertItem( sal_Int16 nItemId, const ::rtl::OUString& aText, sal_Int16 nItemStyle, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 422*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if ( mpMenu ) 425*cdf0e10cSrcweir mpMenu->InsertItem( nItemId, aText, (MenuItemBits)nItemStyle, nPos ); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir void VCLXMenu::removeItem( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 431*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir sal_Int32 nItemCount = (sal_Int32)mpMenu->GetItemCount(); 434*cdf0e10cSrcweir if ( mpMenu && ( nCount > 0 ) && ( nPos >= 0 ) && ( nPos < nItemCount ) && ( nItemCount > 0 )) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir sal_Int16 nP = sal::static_int_cast< sal_Int16 >( 437*cdf0e10cSrcweir Min( (int)(nPos+nCount), (int)nItemCount )); 438*cdf0e10cSrcweir while( nP-nPos > 0 ) 439*cdf0e10cSrcweir mpMenu->RemoveItem( --nP ); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir sal_Int16 VCLXMenu::getItemCount( ) throw(::com::sun::star::uno::RuntimeException) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 446*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir return mpMenu ? mpMenu->GetItemCount() : 0; 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir sal_Int16 VCLXMenu::getItemId( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 454*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir return mpMenu ? mpMenu->GetItemId( nPos ) : 0; 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir sal_Int16 VCLXMenu::getItemPos( sal_Int16 nId ) throw(::com::sun::star::uno::RuntimeException) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 462*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir return mpMenu ? mpMenu->GetItemPos( nId ) : 0; 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir void VCLXMenu::enableItem( sal_Int16 nItemId, sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 470*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir if ( mpMenu ) 473*cdf0e10cSrcweir mpMenu->EnableItem( nItemId, bEnable ); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir sal_Bool VCLXMenu::isItemEnabled( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 479*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir return mpMenu ? mpMenu->IsItemEnabled( nItemId ) : sal_False; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir void VCLXMenu::setItemText( sal_Int16 nItemId, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 487*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir if ( mpMenu ) 490*cdf0e10cSrcweir mpMenu->SetItemText( nItemId, aText ); 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir ::rtl::OUString VCLXMenu::getItemText( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 496*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir ::rtl::OUString aItemText; 499*cdf0e10cSrcweir if ( mpMenu ) 500*cdf0e10cSrcweir aItemText = mpMenu->GetItemText( nItemId ); 501*cdf0e10cSrcweir return aItemText; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir void VCLXMenu::setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& rxPopupMenu ) throw(::com::sun::star::uno::RuntimeException) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 507*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir VCLXMenu* pVCLMenu = VCLXMenu::GetImplementation( rxPopupMenu ); 510*cdf0e10cSrcweir DBG_ASSERT( pVCLMenu && pVCLMenu->GetMenu() && pVCLMenu->IsPopupMenu(), "setPopupMenu: Invalid Menu!" ); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir if ( mpMenu && pVCLMenu && pVCLMenu->GetMenu() && pVCLMenu->IsPopupMenu() ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir // Selbst eine Ref halten! 515*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pNewRef = new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > ; 516*cdf0e10cSrcweir *pNewRef = rxPopupMenu; 517*cdf0e10cSrcweir maPopupMenueRefs.Insert( pNewRef, LIST_APPEND ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir mpMenu->SetPopupMenu( nItemId, (PopupMenu*) pVCLMenu->GetMenu() ); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > VCLXMenu::getPopupMenu( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 526*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > aRef; 529*cdf0e10cSrcweir Menu* pMenu = mpMenu ? mpMenu->GetPopupMenu( nItemId ) : NULL; 530*cdf0e10cSrcweir if ( pMenu ) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir for ( sal_uInt32 n = maPopupMenueRefs.Count(); n; ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pRef = maPopupMenueRefs.GetObject( --n ); 535*cdf0e10cSrcweir Menu* pM = ((VCLXMenu*)pRef->get())->GetMenu(); 536*cdf0e10cSrcweir if ( pM == pMenu ) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir aRef = *pRef; 539*cdf0e10cSrcweir break; 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir return aRef; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir // ::com::sun::star::awt::XPopupMenu 547*cdf0e10cSrcweir void VCLXMenu::insertSeparator( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 550*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir if ( mpMenu ) 553*cdf0e10cSrcweir mpMenu->InsertSeparator( nPos ); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir void VCLXMenu::setDefaultItem( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 559*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir if ( mpMenu ) 562*cdf0e10cSrcweir mpMenu->SetDefaultItem( nItemId ); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir sal_Int16 VCLXMenu::getDefaultItem( ) throw(::com::sun::star::uno::RuntimeException) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 568*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir return mpMenu ? mpMenu->GetDefaultItem() : 0; 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir void VCLXMenu::checkItem( sal_Int16 nItemId, sal_Bool bCheck ) throw(::com::sun::star::uno::RuntimeException) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 576*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir if ( mpMenu ) 579*cdf0e10cSrcweir mpMenu->CheckItem( nItemId, bCheck ); 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir sal_Bool VCLXMenu::isItemChecked( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 585*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir return mpMenu ? mpMenu->IsItemChecked( nItemId ) : sal_False; 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir sal_Int16 VCLXMenu::execute( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& rxWindowPeer, const ::com::sun::star::awt::Rectangle& rArea, sal_Int16 nFlags ) throw(::com::sun::star::uno::RuntimeException) 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 593*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir sal_Int16 nRet = 0; 596*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 597*cdf0e10cSrcweir nRet = ((PopupMenu*)mpMenu)->Execute( VCLUnoHelper::GetWindow( rxWindowPeer ), VCLRectangle(rArea), nFlags | POPUPMENU_NOMOUSEUPCLOSE ); 598*cdf0e10cSrcweir return nRet; 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setCommand( sal_Int16 nItemId, const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 605*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir if ( mpMenu ) 608*cdf0e10cSrcweir mpMenu->SetItemCommand( nItemId, aCommand ); 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXMenu::getCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 614*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir ::rtl::OUString aItemCommand; 617*cdf0e10cSrcweir if ( mpMenu ) 618*cdf0e10cSrcweir aItemCommand = mpMenu->GetItemCommand( nItemId ); 619*cdf0e10cSrcweir return aItemCommand; 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString& aHelp ) throw (::com::sun::star::uno::RuntimeException) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 625*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir if ( mpMenu ) 628*cdf0e10cSrcweir mpMenu->SetHelpCommand( nItemId, aHelp ); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXMenu::getHelpCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 634*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir ::rtl::OUString aHelpCommand; 637*cdf0e10cSrcweir if ( mpMenu ) 638*cdf0e10cSrcweir aHelpCommand = mpMenu->GetHelpCommand( nItemId ); 639*cdf0e10cSrcweir return aHelpCommand; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir // ============================================================================ 644*cdf0e10cSrcweir // ============================================================================ 645*cdf0e10cSrcweir // ============================================================================ 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir // BEGIN ANONYMOUS NAMESPACE 649*cdf0e10cSrcweir namespace 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir namespace css = ::com::sun::star; 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir Image lcl_XGraphic2VCLImage( 654*cdf0e10cSrcweir const css::uno::Reference< css::graphic::XGraphic >& xGraphic, 655*cdf0e10cSrcweir sal_Bool bResize ) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir Image aImage; 658*cdf0e10cSrcweir if ( !xGraphic.is() ) 659*cdf0e10cSrcweir return aImage; 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir aImage = Image( xGraphic ); 662*cdf0e10cSrcweir const ::Size aCurSize = aImage.GetSizePixel(); 663*cdf0e10cSrcweir const sal_Int32 nCurWidth = aCurSize.Width(); 664*cdf0e10cSrcweir const sal_Int32 nCurHeight = aCurSize.Height(); 665*cdf0e10cSrcweir const sal_Int32 nIdeal( 16 ); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir if ( nCurWidth > 0 && nCurHeight > 0 ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir if ( bResize && ( nCurWidth > nIdeal || nCurHeight > nIdeal ) ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir sal_Int32 nIdealWidth = nCurWidth > nIdeal ? nIdeal : nCurWidth; 672*cdf0e10cSrcweir sal_Int32 nIdealHeight = nCurHeight > nIdeal ? nIdeal : nCurHeight; 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir ::Size aNewSize( nIdealWidth, nIdealHeight ); 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir sal_Bool bModified( sal_False ); 677*cdf0e10cSrcweir BitmapEx aBitmapEx = aImage.GetBitmapEx(); 678*cdf0e10cSrcweir bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_INTERPOLATE ); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir if ( bModified ) 681*cdf0e10cSrcweir aImage = Image( aBitmapEx ); 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir return aImage; 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir /** 688*cdf0e10cSrcweir As svtools builds after toolkit, we can not include/use 689*cdf0e10cSrcweir svtools/inc/acceleratorexecute.hxx 690*cdf0e10cSrcweir So I just copy here svt::AcceleratorExecute::st_AWTKey2VCLKey 691*cdf0e10cSrcweir and svt::AcceleratorExecute::st_VCLKey2AWTKey 692*cdf0e10cSrcweir */ 693*cdf0e10cSrcweir css::awt::KeyEvent lcl_VCLKey2AWTKey(const KeyCode& aVCLKey) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir css::awt::KeyEvent aAWTKey; 696*cdf0e10cSrcweir aAWTKey.Modifiers = 0; 697*cdf0e10cSrcweir aAWTKey.KeyCode = (sal_Int16)aVCLKey.GetCode(); 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir if (aVCLKey.IsShift()) 700*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT; 701*cdf0e10cSrcweir if (aVCLKey.IsMod1()) 702*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1; 703*cdf0e10cSrcweir if (aVCLKey.IsMod2()) 704*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2; 705*cdf0e10cSrcweir if (aVCLKey.IsMod3()) 706*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::MOD3; 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir return aAWTKey; 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir KeyCode lcl_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir sal_Bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ); 714*cdf0e10cSrcweir sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); 715*cdf0e10cSrcweir sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); 716*cdf0e10cSrcweir sal_Bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 ); 717*cdf0e10cSrcweir sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode; 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir return KeyCode(nKey, bShift, bMod1, bMod2, bMod3); 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir 722*cdf0e10cSrcweir } // END ANONYMOUS NAMESPACE 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir // ============================================================================ 726*cdf0e10cSrcweir // ============================================================================ 727*cdf0e10cSrcweir // ============================================================================ 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir // XMenuExtended2 Methods 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir ::sal_Bool SAL_CALL VCLXMenu::isPopupMenu( ) throw (::com::sun::star::uno::RuntimeException) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 735*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 736*cdf0e10cSrcweir return IsPopupMenu(); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir void SAL_CALL VCLXMenu::clear( ) throw (::com::sun::star::uno::RuntimeException) 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 742*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 743*cdf0e10cSrcweir if ( mpMenu ) 744*cdf0e10cSrcweir mpMenu->Clear(); 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir ::com::sun::star::awt::MenuItemType SAL_CALL VCLXMenu::getItemType( ::sal_Int16 nItemPos ) 749*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 750*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 753*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir ::com::sun::star::awt::MenuItemType aMenuItemType = 756*cdf0e10cSrcweir ::com::sun::star::awt::MenuItemType_DONTKNOW; 757*cdf0e10cSrcweir if ( mpMenu ) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir THROW_MENUPOS_NOT_FOUND( "VCLXMenu::getItemType()", nItemPos ) 760*cdf0e10cSrcweir aMenuItemType = ( (::com::sun::star::awt::MenuItemType) mpMenu->GetItemType( nItemPos ) ); 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir return aMenuItemType; 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir void SAL_CALL VCLXMenu::hideDisabledEntries( ::sal_Bool bHide ) 767*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 770*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 771*cdf0e10cSrcweir if ( mpMenu ) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir if ( bHide ) 774*cdf0e10cSrcweir mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES ); 775*cdf0e10cSrcweir else 776*cdf0e10cSrcweir mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MENU_FLAG_HIDEDISABLEDENTRIES ); 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir // ============================================================================ 782*cdf0e10cSrcweir // ============================================================================ 783*cdf0e10cSrcweir // ============================================================================ 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir // XPopupMenuExtended Methods 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir ::sal_Bool SAL_CALL VCLXMenu::isInExecute( ) 789*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 792*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 795*cdf0e10cSrcweir return ( (PopupMenu*) mpMenu )->IsInExecute(); 796*cdf0e10cSrcweir else 797*cdf0e10cSrcweir return sal_False; 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir void SAL_CALL VCLXMenu::endExecute() 802*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 805*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 808*cdf0e10cSrcweir ( (PopupMenu*) mpMenu )->EndExecute(); 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setLogo( const ::com::sun::star::awt::MenuLogo& aMenuLogo ) 813*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 816*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir if ( mpMenu ) 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir if ( aMenuLogo.Graphic.is() ) 821*cdf0e10cSrcweir { 822*cdf0e10cSrcweir Image aImage = lcl_XGraphic2VCLImage( aMenuLogo.Graphic, sal_False ); 823*cdf0e10cSrcweir MenuLogo aVCLMenuLogo; 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir aVCLMenuLogo.aBitmap = aImage.GetBitmapEx(); 826*cdf0e10cSrcweir aVCLMenuLogo.aStartColor = Color( (sal_uInt32)(aMenuLogo.StartColor) ); 827*cdf0e10cSrcweir aVCLMenuLogo.aEndColor = Color( (sal_uInt32)(aMenuLogo.EndColor) ); 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir mpMenu->SetLogo( aVCLMenuLogo ); 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir else 832*cdf0e10cSrcweir mpMenu->SetLogo(); 833*cdf0e10cSrcweir } 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir ::com::sun::star::awt::MenuLogo SAL_CALL VCLXMenu::getLogo( ) 838*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 841*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir ::com::sun::star::awt::MenuLogo aAWTMenuLogo; 844*cdf0e10cSrcweir if ( mpMenu ) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir if ( mpMenu->HasLogo() ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir MenuLogo aVCLMenuLogo = mpMenu->GetLogo(); 849*cdf0e10cSrcweir aAWTMenuLogo.Graphic = Image(aVCLMenuLogo.aBitmap).GetXGraphic(); 850*cdf0e10cSrcweir aAWTMenuLogo.StartColor = aVCLMenuLogo.aStartColor.GetColor(); 851*cdf0e10cSrcweir aAWTMenuLogo.EndColor = aVCLMenuLogo.aEndColor.GetColor(); 852*cdf0e10cSrcweir } 853*cdf0e10cSrcweir } 854*cdf0e10cSrcweir return aAWTMenuLogo; 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir void SAL_CALL VCLXMenu::enableAutoMnemonics( ::sal_Bool bEnable ) 859*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 862*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 863*cdf0e10cSrcweir if ( mpMenu ) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir if ( !bEnable ) 866*cdf0e10cSrcweir mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS ); 867*cdf0e10cSrcweir else 868*cdf0e10cSrcweir mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MENU_FLAG_NOAUTOMNEMONICS ); 869*cdf0e10cSrcweir } 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setAcceleratorKeyEvent( ::sal_Int16 nItemId, 874*cdf0e10cSrcweir const ::com::sun::star::awt::KeyEvent& aKeyEvent ) 875*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 876*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 879*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setAcceleratorKeyEvent()", nItemId ) 884*cdf0e10cSrcweir KeyCode aVCLKeyCode = lcl_AWTKey2VCLKey( aKeyEvent ); 885*cdf0e10cSrcweir mpMenu->SetAccelKey( nItemId, aVCLKeyCode ); 886*cdf0e10cSrcweir } 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir ::com::sun::star::awt::KeyEvent SAL_CALL VCLXMenu::getAcceleratorKeyEvent( ::sal_Int16 nItemId ) 891*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 892*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 895*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir ::com::sun::star::awt::KeyEvent aKeyEvent; 898*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getAcceleratorKeyEvent()", nItemId ) 901*cdf0e10cSrcweir KeyCode nKeyCode = mpMenu->GetAccelKey( nItemId ); 902*cdf0e10cSrcweir aKeyEvent = lcl_VCLKey2AWTKey( nKeyCode ); 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir return aKeyEvent; 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sHelpText ) 910*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 911*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 914*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setHelpText()", nItemId ) 919*cdf0e10cSrcweir mpMenu->SetHelpText( nItemId, sHelpText ); 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXMenu::getHelpText( ::sal_Int16 nItemId ) 925*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 926*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 929*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir rtl::OUString sHelpText; 932*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 933*cdf0e10cSrcweir { 934*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getHelpText()", nItemId ) 935*cdf0e10cSrcweir sHelpText = mpMenu->GetHelpText( nItemId ); 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir return sHelpText; 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setTipHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sTipHelpText ) 943*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 944*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 947*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 950*cdf0e10cSrcweir { 951*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setTipHelpText()", nItemId ) 952*cdf0e10cSrcweir mpMenu->SetTipHelpText( nItemId, sTipHelpText ); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXMenu::getTipHelpText( ::sal_Int16 nItemId ) 958*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 959*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 962*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir rtl::OUString sTipHelpText; 965*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getTipHelpText()", nItemId ) 968*cdf0e10cSrcweir sTipHelpText = mpMenu->GetTipHelpText( nItemId ); 969*cdf0e10cSrcweir } 970*cdf0e10cSrcweir return sTipHelpText; 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setItemImage( 975*cdf0e10cSrcweir ::sal_Int16 nItemId, 976*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic, ::sal_Bool bScale ) 977*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 978*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 981*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 984*cdf0e10cSrcweir { 985*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImage()", nItemId ) 986*cdf0e10cSrcweir Image aImage = lcl_XGraphic2VCLImage( xGraphic, bScale ); 987*cdf0e10cSrcweir mpMenu->SetItemImage( nItemId, aImage ); 988*cdf0e10cSrcweir } 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL VCLXMenu::getItemImage( ::sal_Int16 nItemId ) 993*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 994*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 997*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > rxGraphic; 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getItemImage()", nItemId ) 1004*cdf0e10cSrcweir Image aImage = mpMenu->GetItemImage( nItemId ); 1005*cdf0e10cSrcweir if ( !!aImage ) 1006*cdf0e10cSrcweir rxGraphic = aImage.GetXGraphic(); 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir return rxGraphic; 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setItemImageAngle( ::sal_Int16 nItemId, ::sal_Int32 nAngle ) 1013*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 1014*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 1017*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImageAngle()", nItemId ) 1022*cdf0e10cSrcweir mpMenu->SetItemImageAngle( nItemId, nAngle ); 1023*cdf0e10cSrcweir } 1024*cdf0e10cSrcweir } 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir ::sal_Int32 SAL_CALL VCLXMenu::getItemImageAngle( ::sal_Int16 nItemId ) 1028*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 1029*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 1030*cdf0e10cSrcweir { 1031*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 1032*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir ::sal_Int32 nItemImageAngle( 0 ); 1035*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 1036*cdf0e10cSrcweir { 1037*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getItemImageAngle()", nItemId ) 1038*cdf0e10cSrcweir nItemImageAngle = mpMenu->GetItemImageAngle( nItemId ); 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir return nItemImageAngle; 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir void SAL_CALL VCLXMenu::setItemImageMirrorMode( ::sal_Int16 nItemId, ::sal_Bool bMirror ) 1045*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 1046*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 1047*cdf0e10cSrcweir { 1048*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 1049*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 1050*cdf0e10cSrcweir 1051*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImageMirrorMode()", nItemId ) 1054*cdf0e10cSrcweir mpMenu->SetItemImageMirrorMode( nItemId, bMirror ); 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir ::sal_Bool SAL_CALL VCLXMenu::isItemImageInMirrorMode( ::sal_Int16 nItemId ) 1060*cdf0e10cSrcweir throw ( ::com::sun::star::container::NoSuchElementException, 1061*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 1064*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir sal_Bool bMirrorMode( sal_False ); 1067*cdf0e10cSrcweir if ( mpMenu && IsPopupMenu() ) 1068*cdf0e10cSrcweir { 1069*cdf0e10cSrcweir THROW_MENUITEM_NOT_FOUND( "VCLXMenu::isItemImageInMirrorMode()", nItemId ) 1070*cdf0e10cSrcweir bMirrorMode = mpMenu->GetItemImageMirrorMode( nItemId ); 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir return bMirrorMode; 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir // ---------------------------------------------------- 1077*cdf0e10cSrcweir // class VCLXMenuBar 1078*cdf0e10cSrcweir // ---------------------------------------------------- 1079*cdf0e10cSrcweir 1080*cdf0e10cSrcweir DBG_NAME(VCLXMenuBar); 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir VCLXMenuBar::VCLXMenuBar() 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir DBG_CTOR( VCLXMenuBar, 0 ); 1085*cdf0e10cSrcweir ImplCreateMenu( sal_False ); 1086*cdf0e10cSrcweir } 1087*cdf0e10cSrcweir 1088*cdf0e10cSrcweir VCLXMenuBar::VCLXMenuBar( MenuBar* pMenuBar ) : VCLXMenu( (Menu *)pMenuBar ) 1089*cdf0e10cSrcweir { 1090*cdf0e10cSrcweir DBG_CTOR( VCLXMenuBar, 0 ); 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir // ---------------------------------------------------- 1094*cdf0e10cSrcweir // class VCLXPopupMenu 1095*cdf0e10cSrcweir // ---------------------------------------------------- 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir DBG_NAME(VCLXPopupMenu); 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir VCLXPopupMenu::VCLXPopupMenu() 1100*cdf0e10cSrcweir { 1101*cdf0e10cSrcweir DBG_CTOR( VCLXPopupMenu, 0 ); 1102*cdf0e10cSrcweir ImplCreateMenu( sal_True ); 1103*cdf0e10cSrcweir } 1104