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