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