LCOV - code coverage report
Current view: top level - libreoffice/toolkit/source/awt - vclxmenu.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 508 4.3 %
Date: 2012-12-27 Functions: 8 68 11.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10