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