diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2009-01-21 15:28:14 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2009-01-21 15:28:14 +0000 |
commit | 1dbbe6b3626b82e49143ee73e5a2ae8dde4a25f0 (patch) | |
tree | c8a7baf8a05061b9b0acf1262211a89f6c8faf42 | |
parent | 2aee183140fa91e554edd22e1cce95ba4ba257e5 (diff) |
CWS-TOOLING: integrate CWS fwk95
2009-01-15 13:24:14 +0100 cd r266366 : #i96390# Change method name to use UNO AWT style for mnemonics
2009-01-15 13:23:30 +0100 cd r266365 : #i96390# Change method name to use UNO AWT style for mnemonics
2009-01-12 17:25:13 +0100 cd r266174 : #i97983# Check pointer returned by dynamic_cast
2009-01-12 15:31:40 +0100 cd r266162 : #i97983# Create toolkit popup menus via service manager instead of implementation class
2008-12-11 15:04:34 +0100 cd r265305 : #i95863# Remove user defined properties
2008-12-11 14:56:45 +0100 cd r265302 : #i95606# Update documentation for textfields
2008-12-11 10:06:20 +0100 cd r265250 : #i96390# Fix warning on Solaris compiler
2008-12-09 17:27:32 +0100 cd r265119 : CWS-TOOLING: rebase CWS fwk95 to trunk@264807 (milestone: DEV300:m37)
2008-12-01 13:29:43 +0100 cd r264597 : #i96390# New interfaces and structures for complete UNO AWT menu API
2008-12-01 13:25:22 +0100 cd r264596 : #i96390# Added implementation of the new UNO AWT interfaces and structures for menus
2008-11-28 13:55:19 +0100 cd r264553 : #i96640# Fixed wrong property type for MenuBarCloser
2008-11-28 13:53:56 +0100 cd r264552 : #i96621# Fixed ambiguous usage of && and ||
2008-11-18 16:05:45 +0100 cd r263781 : #i95316# Initialize SvtTabAppearanceCfg to enable system settings changed notiifcation code
2008-11-18 16:05:43 +0100 cd r263780 : #i96155# Fix wrong statement to check for enabled argument
2008-10-20 16:54:37 +0200 cd r262328 : #i10000# migrate CWS fwk95 to SVN.
-rw-r--r-- | svtools/source/misc/acceleratorexecute.cxx | 6 | ||||
-rw-r--r-- | svtools/source/misc/langtab.src | 4 | ||||
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 11 | ||||
-rw-r--r-- | svtools/source/uno/contextmenuhelper.cxx | 12 | ||||
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxmenu.hxx | 57 | ||||
-rw-r--r-- | toolkit/source/awt/vclxmenu.cxx | 645 |
6 files changed, 702 insertions, 33 deletions
diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx index 2cd884a778..cab65f941c 100644 --- a/svtools/source/misc/acceleratorexecute.cxx +++ b/svtools/source/misc/acceleratorexecute.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: acceleratorexecute.cxx,v $ - * $Revision: 1.14 $ + * $Revision: 1.14.90.1 $ * * This file is part of OpenOffice.org. * @@ -466,7 +466,7 @@ css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st sModule = xModuleDetection->identify(xFrame); } catch(const css::uno::RuntimeException& exRuntime) - { throw exRuntime; } + { throw; } catch(const css::uno::Exception&) { return css::uno::Reference< css::ui::XAcceleratorConfiguration >(); } @@ -561,7 +561,7 @@ IMPL_LINK(AsyncAccelExec, impl_ts_asyncCallback, void*,) catch(const css::lang::DisposedException&) {} catch(const css::uno::RuntimeException& exRuntime) - { throw exRuntime; } + { throw; } catch(const css::uno::Exception&) {} diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index dc0e3c3834..b4919ad687 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: langtab.src,v $ - * $Revision: 1.6.140.6 $ + * $Revision: 1.6.126.1 $ * * This file is part of OpenOffice.org. * @@ -79,7 +79,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Basque" ; LANGUAGE_BASQUE ; > ; < "Bengali (India)" ; LANGUAGE_BENGALI ; > ; < "Bulgarian" ; LANGUAGE_BULGARIAN ; > ; - < "Byelorussian" ; LANGUAGE_BELARUSIAN ; > ; + < "Belarusian" ; LANGUAGE_BELARUSIAN ; > ; < "Catalan" ; LANGUAGE_CATALAN ; > ; < "Chinese (traditional)" ; LANGUAGE_CHINESE_TRADITIONAL ; > ; < "Chinese (simplified)" ; LANGUAGE_CHINESE_SIMPLIFIED ; > ; diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 2376ecb718..9d74e7ea2f 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -1928,9 +1928,14 @@ FASTBOOL HTMLParser::IsHTMLFormat( const sal_Char* pHeader, eEnc = RTL_TEXTENCODING_UCS2; } } - if( RTL_TEXTENCODING_UCS2 == eEnc && - (0xfe == (sal_uChar)pHeader[0] && 0xff == (sal_uChar)pHeader[1]) || - (0xff == (sal_uChar)pHeader[0] && 0xfe == (sal_uChar)pHeader[1]) ) + if + ( + RTL_TEXTENCODING_UCS2 == eEnc && + ( + (0xfe == (sal_uChar)pHeader[0] && 0xff == (sal_uChar)pHeader[1]) || + (0xff == (sal_uChar)pHeader[0] && 0xfe == (sal_uChar)pHeader[1]) + ) + ) { if( 0xfe == (sal_uChar)pHeader[0] ) bUCS2B = TRUE; diff --git a/svtools/source/uno/contextmenuhelper.cxx b/svtools/source/uno/contextmenuhelper.cxx index 8675cdea18..90bca5372f 100644 --- a/svtools/source/uno/contextmenuhelper.cxx +++ b/svtools/source/uno/contextmenuhelper.cxx @@ -298,10 +298,14 @@ ContextMenuHelper::completeAndExecute( if ( pXMenu ) { PopupMenu* pPopupMenu = dynamic_cast< PopupMenu* >( pXMenu->GetMenu() ); - associateUIConfigurationManagers(); - completeMenuProperties( pPopupMenu ); - executePopupMenu( aPos, pPopupMenu ); - resetAssociations(); + // as dynamic_cast can return zero check pointer + if ( pPopupMenu ) + { + associateUIConfigurationManagers(); + completeMenuProperties( pPopupMenu ); + executePopupMenu( aPos, pPopupMenu ); + resetAssociations(); + } } } diff --git a/toolkit/inc/toolkit/awt/vclxmenu.hxx b/toolkit/inc/toolkit/awt/vclxmenu.hxx index 124f539f48..a6e5264b39 100644 --- a/toolkit/inc/toolkit/awt/vclxmenu.hxx +++ b/toolkit/inc/toolkit/awt/vclxmenu.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -32,9 +32,9 @@ #define _TOOLKIT_AWT_VCLXMENU_HXX_ #include <toolkit/dllapi.h> -#include <com/sun/star/awt/XMenuBar.hpp> -#include <com/sun/star/awt/XPopupMenu.hpp> -#include <com/sun/star/awt/XMenuExtended.hpp> +#include <com/sun/star/awt/XMenuBarExtended.hpp> +#include <com/sun/star/awt/XPopupMenuExtended.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <cppuhelper/weak.hxx> @@ -55,12 +55,12 @@ DECLARE_LIST( PopupMenuRefList, ::com::sun::star::uno::Reference< ::com::sun::st // class VCLXMenu // ---------------------------------------------------- -class TOOLKIT_DLLPUBLIC VCLXMenu : public ::com::sun::star::awt::XMenuBar, - public ::com::sun::star::awt::XPopupMenu, - public ::com::sun::star::awt::XMenuExtended, - public ::com::sun::star::lang::XTypeProvider, - public ::com::sun::star::lang::XUnoTunnel, - public ::cppu::OWeakObject +class TOOLKIT_DLLPUBLIC VCLXMenu : public ::com::sun::star::awt::XMenuBarExtended, + public ::com::sun::star::awt::XPopupMenuExtended, + public ::com::sun::star::lang::XServiceInfo, + public ::com::sun::star::lang::XTypeProvider, + public ::com::sun::star::lang::XUnoTunnel, + public ::cppu::OWeakObject { private: ::osl::Mutex maMutex; @@ -128,6 +128,43 @@ public: virtual ::rtl::OUString SAL_CALL getCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString& aHelp ) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getHelpCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException); + + // ======================================================================== + // ======================================================================== + // ======================================================================== + + // XMenuExtended2 Methods + virtual ::sal_Bool SAL_CALL isPopupMenu( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clear( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::MenuItemType SAL_CALL getItemType( ::sal_Int16 nItemPos ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL hideDisabledEntries( ::sal_Bool bHide ) throw (::com::sun::star::uno::RuntimeException); + + // XMenuBarExtended Methods + + // XPopupMenuExtended Methods + virtual ::sal_Bool SAL_CALL isInExecute( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endExecute( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLogo( const ::com::sun::star::awt::MenuLogo& aMenuLogo ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::MenuLogo SAL_CALL getLogo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL enableAutoMnemonics( ::sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAcceleratorKeyEvent( ::sal_Int16 nItemId, const ::com::sun::star::awt::KeyEvent& aKeyEvent ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::KeyEvent SAL_CALL getAcceleratorKeyEvent( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sHelpText ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getHelpText( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTipHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sTipHelpText ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTipHelpText( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemImage( ::sal_Int16 nItemId, const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic, ::sal_Bool bScale ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getItemImage( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemImageAngle( ::sal_Int16 nItemId, ::sal_Int32 nAngle ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getItemImageAngle( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemImageMirrorMode( ::sal_Int16 nItemId, ::sal_Bool bMirror ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isItemImageInMirrorMode( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + }; // ---------------------------------------------------- diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index a7c4ef17c5..314702921e 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -34,6 +34,7 @@ #include <toolkit/awt/vclxmenu.hxx> #include <toolkit/helper/macros.hxx> +#include <toolkit/helper/servicenames.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/convert.hxx> #include <cppuhelper/typeprovider.hxx> @@ -41,22 +42,62 @@ #include <rtl/uuid.h> #include <vcl/menu.hxx> +#include <vcl/keycod.hxx> +#include <vcl/image.hxx> +#include <vcl/mnemonic.hxx> + +#include <com/sun/star/awt/KeyModifier.hpp> + + +#ifdef DBG_UTIL + #define THROW_MENUITEM_NOT_FOUND( Func, nItemId ) \ + if ( MENU_ITEM_NOTFOUND == mpMenu->GetItemPos( nItemId ) ) \ + throw ::com::sun::star::container::NoSuchElementException( \ + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( Func ) ) \ + += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": There is no menu item with " ) ) \ + += ::rtl::OUString::valueOf( sal_Int32( nItemId ) ) \ + += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " as identifier" ) ), \ + *this \ + ); + #define THROW_MENUPOS_NOT_FOUND( Func, nPos ) \ + if ( MENU_ITEM_NOTFOUND == sal_uInt16( nPos ) ) \ + throw ::com::sun::star::container::NoSuchElementException( \ + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( Func ) ) \ + += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": There is no menu item at position " ) ) \ + += ::rtl::OUString::valueOf( sal_Int32( nPos ) ), \ + *this \ + ); +#else + #define THROW_MENUITEM_NOT_FOUND( Func, nItemId ) \ + if ( MENU_ITEM_NOTFOUND == mpMenu->GetItemPos( nItemId ) ) \ + throw ::com::sun::star::container::NoSuchElementException(); + #define THROW_MENUPOS_NOT_FOUND( Func, nPos ) \ + if ( MENU_ITEM_NOTFOUND == sal_uInt16( nPos ) ) \ + throw ::com::sun::star::container::NoSuchElementException(); +#endif + // ---------------------------------------------------- // class VCLXMenu // ---------------------------------------------------- + +DBG_NAME(VCLXMenu) + VCLXMenu::VCLXMenu() : maMenuListeners( *this ) { + DBG_CTOR( VCLXMenu, 0 ); mpMenu = NULL; } VCLXMenu::VCLXMenu( Menu* pMenu ) : maMenuListeners( *this ) { + DBG_CTOR( VCLXMenu, 0 ); mpMenu = pMenu; } VCLXMenu::~VCLXMenu() { + DBG_DTOR( VCLXMenu, 0 ); for ( sal_uInt32 n = maPopupMenueRefs.Count(); n; ) { ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pRef = maPopupMenueRefs.GetObject( --n ); @@ -172,16 +213,89 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent ) } +//============================================================================= +//============================================================================= +//============================================================================= + + +// ::com::sun::star::lang::XServiceInfo +::rtl::OUString SAL_CALL VCLXMenu::getImplementationName( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + ::rtl::OUString implName( RTL_CONSTASCII_USTRINGPARAM( "stardiv.Toolkit." ) ); + if ( bIsPopupMenu ) + implName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VCLXPopupMenu" ) ); + else + implName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VCLXMenuBar" ) ); + + return implName; +} + + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL VCLXMenu::getSupportedServiceNames( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( 1 ); + if ( bIsPopupMenu ) + aNames[ 0 ] = ::rtl::OUString::createFromAscii( szServiceName2_PopupMenu ); + else + aNames[ 0 ] = ::rtl::OUString::createFromAscii( szServiceName2_MenuBar ); + + return aNames; +} + + +::sal_Bool SAL_CALL VCLXMenu::supportsService( const ::rtl::OUString& rServiceName ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + + if ( aServiceNames[ 0 ] == rServiceName ) + return sal_True; + + return sal_False; +} + + // ::com::sun::star::uno::XInterface -::com::sun::star::uno::Any VCLXMenu::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +::com::sun::star::uno::Any VCLXMenu::queryInterface( const ::com::sun::star::uno::Type & rType ) +throw(::com::sun::star::uno::RuntimeException) { - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + ::com::sun::star::uno::Any aRet; + + if ( bIsPopupMenu ) + aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( ::com::sun::star::awt::XMenu*, (::com::sun::star::awt::XMenuBar*) this ), - SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBar*, this ), SAL_STATIC_CAST( ::com::sun::star::awt::XPopupMenu*, this ), - SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XPopupMenuExtended*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, (::com::sun::star::awt::XPopupMenuExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended2*, (::com::sun::star::awt::XPopupMenuExtended*) this ), SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); + else + aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XMenu*, (::com::sun::star::awt::XMenuBar*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBar*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuBarExtended*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended*, (::com::sun::star::awt::XMenuBarExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::awt::XMenuExtended2*, (::com::sun::star::awt::XMenuBarExtended*) this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); } @@ -189,12 +303,104 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent ) IMPL_XUNOTUNNEL( VCLXMenu ) // ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( VCLXMenu ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ) -IMPL_XTYPEPROVIDER_END +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXMenu::getTypes() +throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + static ::cppu::OTypeCollection* pCollectionMenuBar = NULL; + static ::cppu::OTypeCollection* pCollectionPopupMenu = NULL; + + if ( bIsPopupMenu ) + { + if( !pCollectionPopupMenu ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pCollectionPopupMenu ) + { + static ::cppu::OTypeCollection collectionPopupMenu( + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenuExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended2>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ) ); + pCollectionPopupMenu = &collectionPopupMenu; + } + } + + return (*pCollectionPopupMenu).getTypes(); + } + else + { + if( !pCollectionMenuBar ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pCollectionMenuBar ) + { + static ::cppu::OTypeCollection collectionMenuBar( + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenu>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBarExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuExtended2>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ) ); + pCollectionMenuBar = &collectionMenuBar; + } + } + return (*pCollectionMenuBar).getTypes(); + } +} + + +::com::sun::star::uno::Sequence< sal_Int8 > VCLXMenu::getImplementationId() +throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::ResettableGuard < ::osl::Mutex > aGuard( GetMutex() ); + const sal_Bool bIsPopupMenu = IsPopupMenu(); + aGuard.clear(); + + static ::cppu::OImplementationId* pIdMenuBar = NULL; + static ::cppu::OImplementationId* pIdPopupMenu = NULL; + + if ( bIsPopupMenu ) + { + if( !pIdPopupMenu ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pIdPopupMenu ) + { + static ::cppu::OImplementationId idPopupMenu( sal_False ); + pIdPopupMenu = &idPopupMenu; + } + } + + return (*pIdPopupMenu).getImplementationId(); + } + else + { + if( !pIdMenuBar ) + { + ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pIdMenuBar ) + { + static ::cppu::OImplementationId idMenuBar( sal_False ); + pIdMenuBar = &idMenuBar; + } + } + + return (*pIdMenuBar).getImplementationId(); + } +} + + +//============================================================================= +//============================================================================= +//============================================================================= void VCLXMenu::addMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) @@ -413,24 +619,441 @@ void SAL_CALL VCLXMenu::setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString return aHelpCommand; } + +// ============================================================================ +// ============================================================================ +// ============================================================================ + + +// BEGIN ANONYMOUS NAMESPACE +namespace +{ + namespace css = ::com::sun::star; + + Image lcl_XGraphic2VCLImage( + const css::uno::Reference< css::graphic::XGraphic >& xGraphic, + sal_Bool bResize ) + { + Image aImage; + if ( !xGraphic.is() ) + return aImage; + + aImage = Image( xGraphic ); + const ::Size aCurSize = aImage.GetSizePixel(); + const sal_Int32 nCurWidth = aCurSize.Width(); + const sal_Int32 nCurHeight = aCurSize.Height(); + const sal_Int32 nIdeal( 16 ); + + if ( nCurWidth > 0 && nCurHeight > 0 ) + { + if ( bResize && ( nCurWidth > nIdeal || nCurHeight > nIdeal ) ) + { + sal_Int32 nIdealWidth = nCurWidth > nIdeal ? nIdeal : nCurWidth; + sal_Int32 nIdealHeight = nCurHeight > nIdeal ? nIdeal : nCurHeight; + + ::Size aNewSize( nIdealWidth, nIdealHeight ); + + sal_Bool bModified( sal_False ); + BitmapEx aBitmapEx = aImage.GetBitmapEx(); + bModified = aBitmapEx.Scale( aNewSize, BMP_SCALE_INTERPOLATE ); + + if ( bModified ) + aImage = Image( aBitmapEx ); + } + } + return aImage; + } + + /** + As svtools builds after toolkit, we can not include/use + svtools/inc/acceleratorexecute.hxx + So I just copy here svt::AcceleratorExecute::st_AWTKey2VCLKey + and svt::AcceleratorExecute::st_VCLKey2AWTKey + */ + css::awt::KeyEvent lcl_VCLKey2AWTKey(const KeyCode& aVCLKey) + { + css::awt::KeyEvent aAWTKey; + aAWTKey.Modifiers = 0; + aAWTKey.KeyCode = (sal_Int16)aVCLKey.GetCode(); + + if (aVCLKey.IsShift()) + aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT; + if (aVCLKey.IsMod1()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1; + if (aVCLKey.IsMod2()) + aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2; + + return aAWTKey; + } + + KeyCode lcl_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey) + { + sal_Bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ); + sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); + sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); + USHORT nKey = (USHORT)aAWTKey.KeyCode; + + return KeyCode(nKey, bShift, bMod1, bMod2); + } + +} // END ANONYMOUS NAMESPACE + + +// ============================================================================ +// ============================================================================ +// ============================================================================ + + +// XMenuExtended2 Methods + +::sal_Bool SAL_CALL VCLXMenu::isPopupMenu( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + return IsPopupMenu(); +} + +void SAL_CALL VCLXMenu::clear( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( mpMenu ) + mpMenu->Clear(); +} + + +::com::sun::star::awt::MenuItemType SAL_CALL VCLXMenu::getItemType( ::sal_Int16 nItemPos ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::MenuItemType aMenuItemType = + ::com::sun::star::awt::MenuItemType_DONTKNOW; + if ( mpMenu ) + { + THROW_MENUPOS_NOT_FOUND( "VCLXMenu::getItemType()", nItemPos ) + aMenuItemType = ( (::com::sun::star::awt::MenuItemType) mpMenu->GetItemType( nItemPos ) ); + } + + return aMenuItemType; +} + +void SAL_CALL VCLXMenu::hideDisabledEntries( ::sal_Bool bHide ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( mpMenu ) + { + if ( bHide ) + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES ); + else + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MENU_FLAG_HIDEDISABLEDENTRIES ); + } +} + + +// ============================================================================ +// ============================================================================ +// ============================================================================ + + +// XPopupMenuExtended Methods + +::sal_Bool SAL_CALL VCLXMenu::isInExecute( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + return ( (PopupMenu*) mpMenu )->IsInExecute(); + else + return sal_False; +} + + +void SAL_CALL VCLXMenu::endExecute() +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + ( (PopupMenu*) mpMenu )->EndExecute(); +} + + +void SAL_CALL VCLXMenu::setLogo( const ::com::sun::star::awt::MenuLogo& aMenuLogo ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu ) + { + if ( aMenuLogo.Graphic.is() ) + { + Image aImage = lcl_XGraphic2VCLImage( aMenuLogo.Graphic, sal_False ); + MenuLogo aVCLMenuLogo; + + aVCLMenuLogo.aBitmap = aImage.GetBitmapEx(); + aVCLMenuLogo.aStartColor = Color( (sal_uInt32)(aMenuLogo.StartColor) ); + aVCLMenuLogo.aEndColor = Color( (sal_uInt32)(aMenuLogo.EndColor) ); + + mpMenu->SetLogo( aVCLMenuLogo ); + } + else + mpMenu->SetLogo(); + } +} + + +::com::sun::star::awt::MenuLogo SAL_CALL VCLXMenu::getLogo( ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::MenuLogo aAWTMenuLogo; + if ( mpMenu ) + { + if ( mpMenu->HasLogo() ) + { + MenuLogo aVCLMenuLogo = mpMenu->GetLogo(); + aAWTMenuLogo.Graphic = Image(aVCLMenuLogo.aBitmap).GetXGraphic(); + aAWTMenuLogo.StartColor = aVCLMenuLogo.aStartColor.GetColor(); + aAWTMenuLogo.EndColor = aVCLMenuLogo.aEndColor.GetColor(); + } + } + return aAWTMenuLogo; +} + + +void SAL_CALL VCLXMenu::enableAutoMnemonics( ::sal_Bool bEnable ) +throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( mpMenu ) + { + if ( !bEnable ) + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS ); + else + mpMenu->SetMenuFlags( mpMenu->GetMenuFlags() & ~MENU_FLAG_NOAUTOMNEMONICS ); + } +} + + +void SAL_CALL VCLXMenu::setAcceleratorKeyEvent( ::sal_Int16 nItemId, + const ::com::sun::star::awt::KeyEvent& aKeyEvent ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setAcceleratorKeyEvent()", nItemId ) + KeyCode aVCLKeyCode = lcl_AWTKey2VCLKey( aKeyEvent ); + mpMenu->SetAccelKey( nItemId, aVCLKeyCode ); + } +} + + +::com::sun::star::awt::KeyEvent SAL_CALL VCLXMenu::getAcceleratorKeyEvent( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::awt::KeyEvent aKeyEvent; + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getAcceleratorKeyEvent()", nItemId ) + KeyCode nKeyCode = mpMenu->GetAccelKey( nItemId ); + aKeyEvent = lcl_VCLKey2AWTKey( nKeyCode ); + } + + return aKeyEvent; +} + + +void SAL_CALL VCLXMenu::setHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sHelpText ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setHelpText()", nItemId ) + mpMenu->SetHelpText( nItemId, sHelpText ); + } +} + + +::rtl::OUString SAL_CALL VCLXMenu::getHelpText( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + rtl::OUString sHelpText; + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getHelpText()", nItemId ) + sHelpText = mpMenu->GetHelpText( nItemId ); + } + + return sHelpText; +} + + +void SAL_CALL VCLXMenu::setTipHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sTipHelpText ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setTipHelpText()", nItemId ) + mpMenu->SetTipHelpText( nItemId, sTipHelpText ); + } +} + + +::rtl::OUString SAL_CALL VCLXMenu::getTipHelpText( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + rtl::OUString sTipHelpText; + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getTipHelpText()", nItemId ) + sTipHelpText = mpMenu->GetTipHelpText( nItemId ); + } + return sTipHelpText; +} + + +void SAL_CALL VCLXMenu::setItemImage( + ::sal_Int16 nItemId, + const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic, ::sal_Bool bScale ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImage()", nItemId ) + Image aImage = lcl_XGraphic2VCLImage( xGraphic, bScale ); + mpMenu->SetItemImage( nItemId, aImage ); + } +} + + +::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL VCLXMenu::getItemImage( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > rxGraphic; + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getItemImage()", nItemId ) + Image aImage = mpMenu->GetItemImage( nItemId ); + if ( !!aImage ) + rxGraphic = aImage.GetXGraphic(); + } + return rxGraphic; +} + + +void SAL_CALL VCLXMenu::setItemImageAngle( ::sal_Int16 nItemId, ::sal_Int32 nAngle ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImageAngle()", nItemId ) + mpMenu->SetItemImageAngle( nItemId, nAngle ); + } +} + + +::sal_Int32 SAL_CALL VCLXMenu::getItemImageAngle( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::sal_Int32 nItemImageAngle( 0 ); + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::getItemImageAngle()", nItemId ) + nItemImageAngle = mpMenu->GetItemImageAngle( nItemId ); + } + return nItemImageAngle; +} + + +void SAL_CALL VCLXMenu::setItemImageMirrorMode( ::sal_Int16 nItemId, ::sal_Bool bMirror ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::setItemImageMirrorMode()", nItemId ) + mpMenu->SetItemImageMirrorMode( nItemId, bMirror ); + } +} + + +::sal_Bool SAL_CALL VCLXMenu::isItemImageInMirrorMode( ::sal_Int16 nItemId ) +throw ( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + sal_Bool bMirrorMode( sal_False ); + if ( mpMenu && IsPopupMenu() ) + { + THROW_MENUITEM_NOT_FOUND( "VCLXMenu::isItemImageInMirrorMode()", nItemId ) + bMirrorMode = mpMenu->GetItemImageMirrorMode( nItemId ); + } + return bMirrorMode; +} + + // ---------------------------------------------------- // class VCLXMenuBar // ---------------------------------------------------- +DBG_NAME(VCLXMenuBar); + VCLXMenuBar::VCLXMenuBar() { + DBG_CTOR( VCLXMenuBar, 0 ); ImplCreateMenu( FALSE ); } VCLXMenuBar::VCLXMenuBar( MenuBar* pMenuBar ) : VCLXMenu( (Menu *)pMenuBar ) { + DBG_CTOR( VCLXMenuBar, 0 ); } // ---------------------------------------------------- // class VCLXPopupMenu // ---------------------------------------------------- +DBG_NAME(VCLXPopupMenu); + VCLXPopupMenu::VCLXPopupMenu() { + DBG_CTOR( VCLXPopupMenu, 0 ); ImplCreateMenu( TRUE ); } |