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