diff options
Diffstat (limited to 'framework/source/uielement')
37 files changed, 827 insertions, 2697 deletions
diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx index 30680801d19f..5bf655a4a0d6 100644 --- a/framework/source/uielement/addonstoolbarmanager.cxx +++ b/framework/source/uielement/addonstoolbarmanager.cxx @@ -343,20 +343,20 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue PropertyValue aPropValue; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" )); - aPropValue.Value = makeAny( m_aModuleIdentifier ); - aArgs[0] = makeAny( aPropValue ); + aPropValue.Value <<= m_aModuleIdentifier; + aArgs[0] <<= aPropValue; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - aPropValue.Value = makeAny( m_xFrame ); - aArgs[1] = makeAny( aPropValue ); + aPropValue.Value <<= m_xFrame; + aArgs[1] <<= aPropValue; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); - aPropValue.Value = makeAny( m_xServiceManager ); - aArgs[2] = makeAny( aPropValue ); + aPropValue.Value <<= m_xServiceManager; + aArgs[2] <<= aPropValue; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); - aPropValue.Value = makeAny( xToolbarWindow ); - aArgs[3] = makeAny( aPropValue ); + aPropValue.Value <<= xToolbarWindow; + aArgs[3] <<= aPropValue; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ItemId" )); aPropValue.Value = makeAny( sal_Int32( nId )); - aArgs[4] = makeAny( aPropValue ); + aArgs[4] <<= aPropValue; try { @@ -387,14 +387,14 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue PropertyValue aPropValue; Sequence< Any > aArgs( 3 ); aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - aPropValue.Value = makeAny( m_xFrame ); - aArgs[0] = makeAny( aPropValue ); + aPropValue.Value <<= m_xFrame; + aArgs[0] <<= aPropValue; aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); - aPropValue.Value = makeAny( aURL ); - aArgs[1] = makeAny( aPropValue ); + aPropValue.Value <<= aURL; + aArgs[1] <<= aPropValue; aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); - aPropValue.Value = makeAny( m_xServiceManager ); - aArgs[2] = makeAny( aPropValue ); + aPropValue.Value <<= m_xServiceManager; + aArgs[2] <<= aPropValue; try { xInit->initialize( aArgs ); diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx b/framework/source/uielement/addonstoolbarwrapper.cxx index c7e0287274a1..0f6ce41ce269 100644 --- a/framework/source/uielement/addonstoolbarwrapper.cxx +++ b/framework/source/uielement/addonstoolbarwrapper.cxx @@ -51,6 +51,7 @@ // interface includes //_________________________________________________________________________________________________________________ #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp> #include <com/sun/star/awt/XMenuBar.hpp> diff --git a/framework/source/uielement/buttontoolbarcontroller.cxx b/framework/source/uielement/buttontoolbarcontroller.cxx index bce27ca58c76..ed1aaeb2ae61 100644 --- a/framework/source/uielement/buttontoolbarcontroller.cxx +++ b/framework/source/uielement/buttontoolbarcontroller.cxx @@ -285,7 +285,7 @@ throw (::com::sun::star::uno::RuntimeException) // Provide key modifier information to dispatch function aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value = makeAny( KeyModifier ); + aArgs[0].Value <<= KeyModifier; if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# UiEventLogHelper(::rtl::OUString::createFromAscii("ButtonToolbarController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); diff --git a/framework/source/uielement/comboboxtoolbarcontroller.cxx b/framework/source/uielement/comboboxtoolbarcontroller.cxx index 5c63e6e064d7..dd3f9f0bb4b4 100644 --- a/framework/source/uielement/comboboxtoolbarcontroller.cxx +++ b/framework/source/uielement/comboboxtoolbarcontroller.cxx @@ -214,52 +214,17 @@ throw ( RuntimeException ) } // ------------------------------------------------------------------ - -void SAL_CALL ComboboxToolbarController::execute( sal_Int16 KeyModifier ) -throw ( RuntimeException ) +Sequence<PropertyValue> ComboboxToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const { - Reference< XDispatch > xDispatch; - Reference< XURLTransformer > xURLTransformer; - ::rtl::OUString aCommandURL; - ::rtl::OUString aSelectedText; - ::com::sun::star::util::URL aTargetURL; - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_bInitialized && - m_xFrame.is() && - m_xServiceManager.is() && - m_aCommandURL.getLength() ) - { - xURLTransformer = m_xURLTransformer; - xDispatch = getDispatchFromCommand( m_aCommandURL ); - aCommandURL = m_aCommandURL; - aTargetURL = getInitializedURL(); - aSelectedText = m_pComboBox->GetText(); - } - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) - { - Sequence<PropertyValue> aArgs( 2 ); - - // Add key modifier to argument list - aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value <<= KeyModifier; - aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); - aArgs[1].Value <<= aSelectedText; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, ComplexToolbarController , ExecuteHdl_Impl), pExecuteInfo ); - } + Sequence<PropertyValue> aArgs( 2 ); + ::rtl::OUString aSelectedText = m_pComboBox->GetText(); + + // Add key modifier to argument list + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); + aArgs[0].Value <<= KeyModifier; + aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); + aArgs[1].Value <<= aSelectedText; + return aArgs; } // ------------------------------------------------------------------ diff --git a/framework/source/uielement/complextoolbarcontroller.cxx b/framework/source/uielement/complextoolbarcontroller.cxx index 1571d53ca497..e3b4d5e5a135 100644 --- a/framework/source/uielement/complextoolbarcontroller.cxx +++ b/framework/source/uielement/complextoolbarcontroller.cxx @@ -92,7 +92,7 @@ ComplexToolbarController::ComplexToolbarController( , m_nID( nID ) , m_bMadeInvisible( sal_False ) { - m_xURLTransformer = Reference< XURLTransformer >( m_xServiceManager->createInstance( + m_xURLTransformer.set( m_xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY_THROW ); } @@ -119,7 +119,16 @@ throw ( RuntimeException ) } // ------------------------------------------------------------------ +Sequence<PropertyValue> ComplexToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const +{ + Sequence<PropertyValue> aArgs( 1 ); + // Add key modifier to argument list + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); + aArgs[0].Value <<= KeyModifier; + return aArgs; +} +// ----------------------------------------------------------------------------- void SAL_CALL ComplexToolbarController::execute( sal_Int16 KeyModifier ) throw ( RuntimeException ) { @@ -127,6 +136,7 @@ throw ( RuntimeException ) Reference< XURLTransformer > xURLTransformer; ::rtl::OUString aCommandURL; ::com::sun::star::util::URL aTargetURL; + Sequence<PropertyValue> aArgs; { vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); @@ -143,17 +153,12 @@ throw ( RuntimeException ) xDispatch = getDispatchFromCommand( m_aCommandURL ); aCommandURL = m_aCommandURL; aTargetURL = getInitializedURL(); + aArgs = getExecuteArgs(KeyModifier); } } if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) { - Sequence<PropertyValue> aArgs( 1 ); - - // Add key modifier to argument list - aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value <<= KeyModifier; - // Execute dispatch asynchronously ExecuteInfo* pExecuteInfo = new ExecuteInfo; pExecuteInfo->xDispatch = xDispatch; diff --git a/framework/source/uielement/constitemcontainer.cxx b/framework/source/uielement/constitemcontainer.cxx index afd3fd7159d4..959f91776db0 100644 --- a/framework/source/uielement/constitemcontainer.cxx +++ b/framework/source/uielement/constitemcontainer.cxx @@ -201,13 +201,13 @@ ConstItemContainer::ConstItemContainer( const Reference< XIndexAccess >& rSource try { sal_Int32 nCount = rSourceContainer->getCount(); + m_aItemVector.reserve(nCount); if ( bFastCopy ) { for ( sal_Int32 i = 0; i < nCount; i++ ) { Sequence< PropertyValue > aPropSeq; - Any a = rSourceContainer->getByIndex( i ); - if ( a >>= aPropSeq ) + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) m_aItemVector.push_back( aPropSeq ); } } @@ -216,8 +216,7 @@ ConstItemContainer::ConstItemContainer( const Reference< XIndexAccess >& rSource for ( sal_Int32 i = 0; i < nCount; i++ ) { Sequence< PropertyValue > aPropSeq; - Any a = rSourceContainer->getByIndex( i ); - if ( a >>= aPropSeq ) + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) { sal_Int32 nContainerIndex = -1; Reference< XIndexAccess > xIndexAccess; @@ -252,7 +251,8 @@ ConstItemContainer::~ConstItemContainer() // private void ConstItemContainer::copyItemContainer( const std::vector< Sequence< PropertyValue > >& rSourceVector ) { - for ( sal_uInt32 i = 0; i < rSourceVector.size(); i++ ) + const sal_uInt32 nCount = rSourceVector.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { sal_Int32 nContainerIndex = -1; Sequence< PropertyValue > aPropSeq( rSourceVector[i] ); @@ -328,7 +328,7 @@ ConstItemContainer* ConstItemContainer::GetImplementation( const ::com::sun::sta sal_Bool SAL_CALL ConstItemContainer::hasElements() throw ( RuntimeException ) { - return ( m_aItemVector.size() != 0 ); + return ( !m_aItemVector.empty() ); } // XIndexAccess diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx index 6b3edfb22a6b..0872e778a727 100644 --- a/framework/source/uielement/controlmenucontroller.cxx +++ b/framework/source/uielement/controlmenucontroller.cxx @@ -44,7 +44,6 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -346,51 +345,17 @@ void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Eve } // XMenuListener -void SAL_CALL ControlMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) +void ControlMenuController::impl_select(const Reference< XDispatch >& /*_xDispatch*/,const ::com::sun::star::util::URL& aURL) { -} - -void SAL_CALL ControlMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xRefDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xRefDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() ) + UrlToDispatchMap::iterator pIter = m_aURLToDispatchMap.find( aURL.Complete ); + if ( pIter != m_aURLToDispatchMap.end() ) { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs( 1 ); - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - UrlToDispatchMap::iterator pIter = m_aURLToDispatchMap.find( aTargetURL.Complete ); - if ( pIter != m_aURLToDispatchMap.end() ) - { - Reference< XDispatch > xDispatch = pIter->second; - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("ControlMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - if ( xDispatch.is() ) - xDispatch->dispatch( aTargetURL, aArgs ); - } - } + Sequence<PropertyValue> aArgs; + Reference< XDispatch > xDispatch = pIter->second; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString::createFromAscii("ControlMenuController")).log(m_xServiceManager, m_xFrame, aURL, aArgs); + if ( xDispatch.is() ) + xDispatch->dispatch( aURL, aArgs ); } } @@ -425,54 +390,26 @@ void SAL_CALL ControlMenuController::activate( const css::awt::MenuEvent& ) thro } } -void SAL_CALL ControlMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - // XPopupMenuController -void SAL_CALL ControlMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) +void ControlMenuController::impl_setPopupMenu() { - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) + if ( m_pResPopupMenu == 0 ) { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + rtl::OStringBuffer aBuf( 32 ); + aBuf.append( "svx" ); - if ( m_pResPopupMenu == 0 ) + ResMgr* pResMgr = ResMgr::CreateResMgr( aBuf.getStr() ); + if ( pResMgr ) { - rtl::OStringBuffer aBuf( 32 ); - aBuf.append( "svx" ); - - ResMgr* pResMgr = ResMgr::CreateResMgr( aBuf.getStr() ); - if ( pResMgr ) - { - ResId aResId( RID_FMSHELL_CONVERSIONMENU, *pResMgr ); - aResId.SetRT( RSC_MENU ); - if ( pResMgr->IsAvailable( aResId )) - m_pResPopupMenu = new PopupMenu( aResId ); + ResId aResId( RID_FMSHELL_CONVERSIONMENU, *pResMgr ); + aResId.SetRT( RSC_MENU ); + if ( pResMgr->IsAvailable( aResId )) + m_pResPopupMenu = new PopupMenu( aResId ); - updateImagesPopupMenu( m_pResPopupMenu ); - delete pResMgr; - } + updateImagesPopupMenu( m_pResPopupMenu ); + delete pResMgr; } - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - } + } // if ( m_pResPopupMenu == 0 ) } void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) @@ -485,10 +422,6 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star:: if ( m_xFrame.is() && m_xPopupMenu.is() ) { URL aTargetURL; - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); fillPopupMenu( m_xPopupMenu ); m_aURLToDispatchMap.free(); @@ -496,7 +429,7 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star:: for (sal_uInt32 i=0; i<sizeof(aCommands)/sizeof(aCommands[0]); ++i) { aTargetURL.Complete = rtl::OUString::createFromAscii( aCommands[i] ); - xURLTransformer->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); if ( xDispatch.is() ) @@ -512,36 +445,9 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star:: // XInitialization void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - const rtl::OUString aFrameName( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - const rtl::OUString aCommandURLName( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); - ResetableGuard aLock( m_aLock ); - - sal_Bool bInitalized( m_bInitialized ); - if ( !bInitalized ) - { - PropertyValue aPropValue; - rtl::OUString aCommandURL; - Reference< XFrame > xFrame; - - for ( int i = 0; i < aArguments.getLength(); i++ ) - { - if ( aArguments[i] >>= aPropValue ) - { - if ( aPropValue.Name.equalsAscii( "Frame" )) - aPropValue.Value >>= xFrame; - else if ( aPropValue.Name.equalsAscii( "CommandURL" )) - aPropValue.Value >>= aCommandURL; - } - } - - if ( xFrame.is() && aCommandURL.getLength() ) - { - m_xFrame = xFrame; - m_aCommandURL = aCommandURL; - m_bInitialized = sal_True; - } - } + PopupMenuControllerBase::initialize(aArguments); + m_aBaseURL = ::rtl::OUString(); } } diff --git a/framework/source/uielement/dropdownboxtoolbarcontroller.cxx b/framework/source/uielement/dropdownboxtoolbarcontroller.cxx index b62a9891313d..cb3327c560e4 100644 --- a/framework/source/uielement/dropdownboxtoolbarcontroller.cxx +++ b/framework/source/uielement/dropdownboxtoolbarcontroller.cxx @@ -197,52 +197,17 @@ throw ( RuntimeException ) } // ------------------------------------------------------------------ - -void SAL_CALL DropdownToolbarController::execute( sal_Int16 KeyModifier ) -throw ( RuntimeException ) +Sequence<PropertyValue> DropdownToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const { - Reference< XDispatch > xDispatch; - Reference< XURLTransformer > xURLTransformer; - ::rtl::OUString aCommandURL; - ::rtl::OUString aSelectedText; - ::com::sun::star::util::URL aTargetURL; - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_bInitialized && - m_xFrame.is() && - m_xServiceManager.is() && - m_aCommandURL.getLength() ) - { - xURLTransformer = m_xURLTransformer; - xDispatch = getDispatchFromCommand( m_aCommandURL ); - aCommandURL = m_aCommandURL; - aTargetURL = getInitializedURL(); - aSelectedText = m_pListBoxControl->GetText(); - } - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) - { - Sequence<PropertyValue> aArgs( 2 ); - - // Add key modifier to argument list - aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value <<= KeyModifier; - aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); - aArgs[1].Value <<= aSelectedText; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, ComplexToolbarController , ExecuteHdl_Impl), pExecuteInfo ); - } + Sequence<PropertyValue> aArgs( 2 ); + ::rtl::OUString aSelectedText = m_pListBoxControl->GetText(); + + // Add key modifier to argument list + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); + aArgs[0].Value <<= KeyModifier; + aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); + aArgs[1].Value <<= aSelectedText; + return aArgs; } // ------------------------------------------------------------------ diff --git a/framework/source/uielement/edittoolbarcontroller.cxx b/framework/source/uielement/edittoolbarcontroller.cxx index 0d6c88e83aec..88eb8641e0da 100644 --- a/framework/source/uielement/edittoolbarcontroller.cxx +++ b/framework/source/uielement/edittoolbarcontroller.cxx @@ -194,52 +194,17 @@ throw ( RuntimeException ) } // ------------------------------------------------------------------ - -void SAL_CALL EditToolbarController::execute( sal_Int16 KeyModifier ) -throw ( RuntimeException ) +Sequence<PropertyValue> EditToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const { - Reference< XDispatch > xDispatch; - Reference< XURLTransformer > xURLTransformer; - ::rtl::OUString aCommandURL; - ::rtl::OUString aSelectedText; - ::com::sun::star::util::URL aTargetURL; - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_bInitialized && - m_xFrame.is() && - m_xServiceManager.is() && - m_aCommandURL.getLength() ) - { - xURLTransformer = m_xURLTransformer; - xDispatch = getDispatchFromCommand( m_aCommandURL ); - aCommandURL = m_aCommandURL; - aTargetURL = getInitializedURL(); - aSelectedText = m_pEditControl->GetText(); - } - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) - { - Sequence<PropertyValue> aArgs( 2 ); - - // Add key modifier to argument list - aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value <<= KeyModifier; - aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); - aArgs[1].Value <<= aSelectedText; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, ComplexToolbarController , ExecuteHdl_Impl), pExecuteInfo ); - } + Sequence<PropertyValue> aArgs( 2 ); + ::rtl::OUString aSelectedText = m_pEditControl->GetText(); + + // Add key modifier to argument list + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); + aArgs[0].Value <<= KeyModifier; + aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); + aArgs[1].Value <<= aSelectedText; + return aArgs; } // ------------------------------------------------------------------ diff --git a/framework/source/uielement/fontmenucontroller.cxx b/framework/source/uielement/fontmenucontroller.cxx index 1845f6f4cdb7..ee1014f25b77 100644 --- a/framework/source/uielement/fontmenucontroller.cxx +++ b/framework/source/uielement/fontmenucontroller.cxx @@ -44,7 +44,6 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> @@ -119,6 +118,7 @@ void FontMenuController::fillPopupMenu( const Sequence< ::rtl::OUString >& rFont if ( pVCLPopupMenu ) { vector<rtl::OUString> aVector; + aVector.reserve(rFontNameSeq.getLength()); for ( USHORT i = 0; i < rFontNameSeq.getLength(); i++ ) { aVector.push_back(MnemonicGenerator::EraseAllMnemonicChars(pFontNameArray[i])); @@ -126,7 +126,8 @@ void FontMenuController::fillPopupMenu( const Sequence< ::rtl::OUString >& rFont sort(aVector.begin(), aVector.end(), lcl_I18nCompareString ); const rtl::OUString aFontNameCommandPrefix( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName?CharFontName.FamilyName:string=" )); - for(USHORT i = 0; i < aVector.size(); i++) + const sal_Int16 nCount = (sal_Int16)aVector.size(); + for ( sal_Int16 i = 0; i < nCount; i++ ) { const rtl::OUString& rName = aVector[i]; m_xPopupMenu->insertItem( i+1, rName, css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, i ); @@ -178,51 +179,16 @@ void SAL_CALL FontMenuController::statusChanged( const FeatureStateEvent& Event } // XMenuListener -void SAL_CALL FontMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) +void FontMenuController::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aTargetURL) { -} - -void SAL_CALL FontMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() && xDispatch.is() ) - { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs; - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - // Command URL used to dispatch the selected font family name - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("FontMenuController")).log( - m_xServiceManager, - m_xFrame, - aTargetURL, - Sequence<PropertyValue>()); - xDispatch->dispatch( aTargetURL, aArgs ); - } - } + Sequence<PropertyValue> aArgs; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString::createFromAscii("FontMenuController")).log( + m_xServiceManager, + m_xFrame, + aTargetURL, + Sequence<PropertyValue>()); + _xDispatch->dispatch( aTargetURL, aArgs ); } void SAL_CALL FontMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) @@ -262,44 +228,16 @@ void SAL_CALL FontMenuController::activate( const css::awt::MenuEvent& ) throw ( } } -void SAL_CALL FontMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - // XPopupMenuController -void SAL_CALL FontMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw (RuntimeException) +void FontMenuController::impl_setPopupMenu() { - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - // Register for font list updates to get the current font list from the controller - aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontNameList" )); - xURLTransformer->parseStrict( aTargetURL ); - m_xFontListDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - updatePopupMenu(); - } + com::sun::star::util::URL aTargetURL; + // Register for font list updates to get the current font list from the controller + aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontNameList" )); + m_xURLTransformer->parseStrict( aTargetURL ); + m_xFontListDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); } void SAL_CALL FontMenuController::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) @@ -308,12 +246,9 @@ void SAL_CALL FontMenuController::updatePopupMenu() throw ( ::com::sun::star::un ResetableGuard aLock( m_aLock ); Reference< XDispatch > xDispatch( m_xFontListDispatch ); - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontNameList" )); - xURLTransformer->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); aLock.unlock(); if ( xDispatch.is() ) @@ -323,11 +258,5 @@ void SAL_CALL FontMenuController::updatePopupMenu() throw ( ::com::sun::star::un } } -// XInitialization -void SAL_CALL FontMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); -} - } diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx index d1097e621be9..bbf3915d2e06 100644 --- a/framework/source/uielement/fontsizemenucontroller.cxx +++ b/framework/source/uielement/fontsizemenucontroller.cxx @@ -44,7 +44,6 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/view/XPrintable.hpp> @@ -322,93 +321,23 @@ void SAL_CALL FontSizeMenuController::statusChanged( const FeatureStateEvent& Ev } // XMenuListener -void SAL_CALL FontSizeMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL FontSizeMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - // Command URL used to dispatch the selected font family name - const rtl::OUString aFontHeightCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontHeight?FontHeight.Height:float=" )); - - if ( xPopupMenu.is() && xDispatch.is() ) - { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs; - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("FontSizeMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - xDispatch->dispatch( aTargetURL, aArgs ); - } - } -} - -void SAL_CALL FontSizeMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL FontSizeMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) +void FontSizeMenuController::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aTargetURL) { + Sequence<PropertyValue> aArgs; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString::createFromAscii("FontSizeMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); + _xDispatch->dispatch( aTargetURL, aArgs ); } // XPopupMenuController -void SAL_CALL FontSizeMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) +void FontSizeMenuController::impl_setPopupMenu() { - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - - // Register for font name updates which gives us info about the current font! - aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )); - xURLTransformer->parseStrict( aTargetURL ); - m_xCurrentFontDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - // Register for font height updates - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - updatePopupMenu(); - } + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + com::sun::star::util::URL aTargetURL; + // Register for font name updates which gives us info about the current font! + aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )); + m_xURLTransformer->parseStrict( aTargetURL ); + m_xCurrentFontDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); } void SAL_CALL FontSizeMenuController::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) @@ -419,12 +348,9 @@ void SAL_CALL FontSizeMenuController::updatePopupMenu() throw ( ::com::sun::star throw DisposedException(); Reference< XDispatch > xDispatch( m_xCurrentFontDispatch ); - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )); - xURLTransformer->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); aLock.unlock(); if ( xDispatch.is() ) @@ -435,11 +361,4 @@ void SAL_CALL FontSizeMenuController::updatePopupMenu() throw ( ::com::sun::star PopupMenuControllerBase::updatePopupMenu(); } - -// XInitialization -void SAL_CALL FontSizeMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); -} - } diff --git a/framework/source/uielement/footermenucontroller.cxx b/framework/source/uielement/footermenucontroller.cxx index 8f295b82c11d..9396be03d9ea 100644 --- a/framework/source/uielement/footermenucontroller.cxx +++ b/framework/source/uielement/footermenucontroller.cxx @@ -40,7 +40,7 @@ #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_ #include <classes/resource.hrc> #endif -#include <classes/fwkresid.hxx> +#include <classes/fwlresid.hxx> //_________________________________________________________________________________________________________________ // interface includes @@ -80,8 +80,6 @@ using namespace com::sun::star::util; using namespace com::sun::star::style; using namespace com::sun::star::container; -const USHORT ALL_MENUITEM_ID = 1; - namespace framework { @@ -91,256 +89,12 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( FooterMenuController IMPLEMENTATIONNAME_FOOTERMENUCONTROLLER ) -DEFINE_INIT_SERVICE ( FooterMenuController, {} ) - FooterMenuController::FooterMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ) + HeaderMenuController( xServiceManager,true ) { } FooterMenuController::~FooterMenuController() { } - -// private function -void FooterMenuController::fillPopupMenu( const Reference< ::com::sun::star::frame::XModel >& rModel, Reference< css::awt::XPopupMenu >& rPopupMenu ) -{ - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu ); - PopupMenu* pVCLPopupMenu = 0; - - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - resetPopupMenu( rPopupMenu ); - if ( pPopupMenu ) - pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - - Reference< XStyleFamiliesSupplier > xStyleFamiliesSupplier( rModel, UNO_QUERY ); - if ( pVCLPopupMenu && xStyleFamiliesSupplier.is()) - { - Reference< XNameAccess > xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); - - try - { - const rtl::OUString aCmd( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPageFooter" )); - const rtl::OUString aIsPhysicalStr( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" )); - const rtl::OUString aDisplayNameStr( RTL_CONSTASCII_USTRINGPARAM( "DisplayName" )); - const rtl::OUString aFooterIsOnStr( RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" )); - - Reference< XNameContainer > xNameContainer; - Any a = xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageStyles" ))); - if ( a >>= xNameContainer ) - { - Sequence< rtl::OUString > aSeqNames = xNameContainer->getElementNames(); - - USHORT nId = 2; - USHORT nCount = 0; - sal_Bool bAllOneState( sal_True ); - sal_Bool bLastCheck( sal_True ); - sal_Bool bFirstChecked( sal_False ); - sal_Bool bFirstItemInserted( sal_False ); - for ( sal_Int32 n = 0; n < aSeqNames.getLength(); n++ ) - { - rtl::OUString aName = aSeqNames[n]; - Reference< XPropertySet > xPropSet( xNameContainer->getByName( aName ), UNO_QUERY ); - if ( xPropSet.is() ) - { - sal_Bool bIsPhysical( sal_False ); - a = xPropSet->getPropertyValue( aIsPhysicalStr ); - if (( a >>= bIsPhysical ) && bIsPhysical ) - { - rtl::OUString aDisplayName; - sal_Bool bHeaderIsOn( sal_False ); - a = xPropSet->getPropertyValue( aDisplayNameStr ); - a >>= aDisplayName; - a = xPropSet->getPropertyValue( aFooterIsOnStr ); - a >>= bHeaderIsOn; - - rtl::OUStringBuffer aStrBuf( aCmd ); - aStrBuf.appendAscii( "?PageStyle:string="); - aStrBuf.append( aDisplayName ); - aStrBuf.appendAscii( "&On:bool=" ); - if ( !bHeaderIsOn ) - aStrBuf.appendAscii( "true" ); - else - aStrBuf.appendAscii( "false" ); - rtl::OUString aCommand( aStrBuf.makeStringAndClear() ); - pVCLPopupMenu->InsertItem( nId, aDisplayName, MIB_CHECKABLE ); - if ( !bFirstItemInserted ) - { - bFirstItemInserted = sal_True; - bFirstChecked = bHeaderIsOn; - } - - pVCLPopupMenu->SetItemCommand( nId, aCommand ); - if ( bHeaderIsOn ) - pVCLPopupMenu->CheckItem( nId, sal_True ); - ++nId; - - // Check if all entries have the same state - if( bAllOneState && n && bHeaderIsOn != bLastCheck ) - bAllOneState = FALSE; - bLastCheck = bHeaderIsOn; - ++nCount; - } - } - } - - if ( bAllOneState && ( nCount > 1 )) - { - // Insert special item for all command - pVCLPopupMenu->InsertItem( ALL_MENUITEM_ID, String( FwkResId( STR_MENU_HEADFOOTALL )), 0, 0 ); - - rtl::OUStringBuffer aStrBuf( aCmd ); - aStrBuf.appendAscii( "?On:bool=" ); - - // Command depends on check state of first menu item entry - if ( !bFirstChecked ) - aStrBuf.appendAscii( "true" ); - else - aStrBuf.appendAscii( "false" ); - - pVCLPopupMenu->SetItemCommand( 1, aStrBuf.makeStringAndClear() ); - pVCLPopupMenu->InsertSeparator( 1 ); - } - } - } - catch ( com::sun::star::container::NoSuchElementException& ) - { - } - } -} - -// XEventListener -void SAL_CALL FooterMenuController::disposing( const EventObject& ) throw ( RuntimeException ) -{ - Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - - ResetableGuard aLock( m_aLock ); - m_xFrame.clear(); - m_xDispatch.clear(); - m_xServiceManager.clear(); - - if ( m_xPopupMenu.is() ) - m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(( OWeakObject *)this, UNO_QUERY )); - m_xPopupMenu.clear(); -} - -// XStatusListener -void SAL_CALL FooterMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) -{ - Reference< com::sun::star::frame::XModel > xModel; - - if ( Event.State >>= xModel ) - { - ResetableGuard aLock( m_aLock ); - if ( m_xPopupMenu.is() ) - fillPopupMenu( xModel, m_xPopupMenu ); - } -} - -// XMenuListener -void SAL_CALL FooterMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL FooterMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() && xDispatch.is() ) - { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs( 1 ); - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("FooterMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - xDispatch->dispatch( aTargetURL, aArgs ); - } - } -} - -void SAL_CALL FooterMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL FooterMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -// XPopupMenuController -void SAL_CALL FooterMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - updatePopupMenu(); - } -} - -void SAL_CALL FooterMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - Reference< com::sun::star::frame::XModel > xModel( m_xModel ); - aLock.unlock(); - - if ( !xModel.is() ) - PopupMenuControllerBase::updatePopupMenu(); - - aLock.lock(); - if ( m_xPopupMenu.is() && m_xModel.is() ) - fillPopupMenu( m_xModel, m_xPopupMenu ); -} - -// XInitialization -void SAL_CALL FooterMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); -} - } diff --git a/framework/source/uielement/headermenucontroller.cxx b/framework/source/uielement/headermenucontroller.cxx index c3645aea3cac..4e90d86fe0c9 100644 --- a/framework/source/uielement/headermenucontroller.cxx +++ b/framework/source/uielement/headermenucontroller.cxx @@ -41,7 +41,7 @@ #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_ #include <classes/resource.hrc> #endif -#include <classes/fwkresid.hxx> +#include <classes/fwlresid.hxx> //_________________________________________________________________________________________________________________ // interface includes @@ -49,11 +49,11 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/DisposedException.hpp> //_________________________________________________________________________________________________________________ // includes of other projects @@ -99,8 +99,9 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( HeaderMenuController DEFINE_INIT_SERVICE ( HeaderMenuController, {} ) -HeaderMenuController::HeaderMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : +HeaderMenuController::HeaderMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager,bool _bFooter ) : PopupMenuControllerBase( xServiceManager ) + ,m_bFooter(_bFooter) { } @@ -125,16 +126,20 @@ void HeaderMenuController::fillPopupMenu( const Reference< ::com::sun::star::fra { Reference< XNameAccess > xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); - try + rtl::OUString aCmd( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPageHeader" )); + rtl::OUString aHeaderFooterIsOnStr(RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" )); + if ( m_bFooter ) { - const rtl::OUString aCmd( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPageHeader" )); - const rtl::OUString aIsPhysicalStr( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" )); - const rtl::OUString aDisplayNameStr( RTL_CONSTASCII_USTRINGPARAM( "DisplayName" )); - const rtl::OUString aHeaderIsOnStr( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" )); + aCmd = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPageFooter" )); + aHeaderFooterIsOnStr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" )); + } + const rtl::OUString aIsPhysicalStr( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" )); + const rtl::OUString aDisplayNameStr( RTL_CONSTASCII_USTRINGPARAM( "DisplayName" )); + try + { Reference< XNameContainer > xNameContainer; - Any a = xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageStyles" ))); - if ( a >>= xNameContainer ) + if ( xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageStyles" ))) >>= xNameContainer ) { Sequence< rtl::OUString > aSeqNames = xNameContainer->getElementNames(); @@ -151,15 +156,12 @@ void HeaderMenuController::fillPopupMenu( const Reference< ::com::sun::star::fra if ( xPropSet.is() ) { sal_Bool bIsPhysical( sal_False ); - a = xPropSet->getPropertyValue( aIsPhysicalStr ); - if (( a >>= bIsPhysical ) && bIsPhysical ) + if (( xPropSet->getPropertyValue( aIsPhysicalStr ) >>= bIsPhysical ) && bIsPhysical ) { rtl::OUString aDisplayName; sal_Bool bHeaderIsOn( sal_False ); - a = xPropSet->getPropertyValue( aDisplayNameStr ); - a >>= aDisplayName; - a = xPropSet->getPropertyValue( aHeaderIsOnStr ); - a >>= bHeaderIsOn; + xPropSet->getPropertyValue( aDisplayNameStr ) >>= aDisplayName; + xPropSet->getPropertyValue( aHeaderFooterIsOnStr ) >>= bHeaderIsOn; rtl::OUStringBuffer aStrBuf( aCmd ); aStrBuf.appendAscii( "?PageStyle:string="); @@ -195,7 +197,7 @@ void HeaderMenuController::fillPopupMenu( const Reference< ::com::sun::star::fra if ( bAllOneState && ( nCount > 1 )) { // Insert special item for all command - pVCLPopupMenu->InsertItem( ALL_MENUITEM_ID, String( FwkResId( STR_MENU_HEADFOOTALL )), 0, 0 ); + pVCLPopupMenu->InsertItem( ALL_MENUITEM_ID, String( FwlResId( STR_MENU_HEADFOOTALL )), 0, 0 ); rtl::OUStringBuffer aStrBuf( aCmd ); aStrBuf.appendAscii( "?On:bool=" ); @@ -247,84 +249,12 @@ void SAL_CALL HeaderMenuController::statusChanged( const FeatureStateEvent& Even } // XMenuListener -void SAL_CALL HeaderMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) +void HeaderMenuController::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aTargetURL) { -} - -void SAL_CALL HeaderMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() && xDispatch.is() ) - { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs( 1 ); - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("HeaderMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - xDispatch->dispatch( aTargetURL, aArgs ); - } - } -} - -void SAL_CALL HeaderMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL HeaderMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -// XPopupMenuController -void SAL_CALL HeaderMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - updatePopupMenu(); - } + Sequence<PropertyValue> aArgs; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(m_bFooter ? "FooterMenuController" : "HeaderMenuController"))).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); + _xDispatch->dispatch( aTargetURL, aArgs ); } void SAL_CALL HeaderMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) @@ -345,10 +275,4 @@ void SAL_CALL HeaderMenuController::updatePopupMenu() throw (::com::sun::star::u fillPopupMenu( m_xModel, m_xPopupMenu ); } -// XInitialization -void SAL_CALL HeaderMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); -} - } diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx index 588fccf8b526..17fb412aeff5 100644 --- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx @@ -168,14 +168,6 @@ throw ( RuntimeException ) // ------------------------------------------------------------------ -void SAL_CALL ImageButtonToolbarController::execute( sal_Int16 KeyModifier ) -throw ( RuntimeException ) -{ - ComplexToolbarController::execute( KeyModifier ); -} - -// ------------------------------------------------------------------ - void ImageButtonToolbarController::executeControlCommand( const ::com::sun::star::frame::ControlCommand& rControlCommand ) { vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); diff --git a/framework/source/uielement/itemcontainer.cxx b/framework/source/uielement/itemcontainer.cxx index 72a691c6368a..b42930159924 100644 --- a/framework/source/uielement/itemcontainer.cxx +++ b/framework/source/uielement/itemcontainer.cxx @@ -55,39 +55,20 @@ namespace framework //***************************************************************************************************************** // XInterface, XTypeProvider //***************************************************************************************************************** -DEFINE_XINTERFACE_6 ( ItemContainer , - OWeakObject , - DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider ), - DIRECT_INTERFACE( ::com::sun::star::container::XIndexContainer ), - DIRECT_INTERFACE( ::com::sun::star::lang::XUnoTunnel ), - DERIVED_INTERFACE( ::com::sun::star::container::XIndexReplace, com::sun::star::container::XIndexContainer ), - DERIVED_INTERFACE( ::com::sun::star::container::XIndexAccess, com::sun::star::container::XIndexReplace ), - DERIVED_INTERFACE( ::com::sun::star::container::XElementAccess, ::com::sun::star::container::XIndexAccess ) - ) -DEFINE_XTYPEPROVIDER_6 ( ItemContainer , - ::com::sun::star::lang::XTypeProvider , - ::com::sun::star::container::XIndexContainer , - ::com::sun::star::container::XIndexReplace , - ::com::sun::star::container::XIndexAccess , - ::com::sun::star::container::XElementAccess , - ::com::sun::star::lang::XUnoTunnel - ) - -ItemContainer::ItemContainer( const ShareableMutex& rMutex ) : ::cppu::OWeakObject() - , m_aShareMutex( rMutex ) +ItemContainer::ItemContainer( const ShareableMutex& rMutex ) : + m_aShareMutex( rMutex ) { } -ItemContainer::ItemContainer( const ConstItemContainer& rConstItemContainer, const ShareableMutex& rMutex ) : ::cppu::OWeakObject() - , m_aShareMutex( rMutex ) +ItemContainer::ItemContainer( const ConstItemContainer& rConstItemContainer, const ShareableMutex& rMutex ) : m_aShareMutex( rMutex ) { copyItemContainer( rConstItemContainer.m_aItemVector, rMutex ); } -ItemContainer::ItemContainer( const Reference< XIndexAccess >& rSourceContainer, const ShareableMutex& rMutex ) : ::cppu::OWeakObject() - , m_aShareMutex( rMutex ) +ItemContainer::ItemContainer( const Reference< XIndexAccess >& rSourceContainer, const ShareableMutex& rMutex ) : + m_aShareMutex( rMutex ) { if ( rSourceContainer.is() ) { @@ -97,8 +78,7 @@ ItemContainer::ItemContainer( const Reference< XIndexAccess >& rSourceContainer, for ( sal_Int32 i = 0; i < nCount; i++ ) { Sequence< PropertyValue > aPropSeq; - Any a = rSourceContainer->getByIndex( i ); - if ( a >>= aPropSeq ) + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) { sal_Int32 nContainerIndex = -1; Reference< XIndexAccess > xIndexAccess; @@ -132,7 +112,8 @@ ItemContainer::~ItemContainer() // private void ItemContainer::copyItemContainer( const std::vector< Sequence< PropertyValue > >& rSourceVector, const ShareableMutex& rMutex ) { - for ( sal_uInt32 i = 0; i < rSourceVector.size(); i++ ) + const sal_uInt32 nCount = rSourceVector.size(); + for ( sal_uInt32 i = 0; i < nCount; ++i ) { sal_Int32 nContainerIndex = -1; Sequence< PropertyValue > aPropSeq( rSourceVector[i] ); @@ -208,7 +189,7 @@ sal_Bool SAL_CALL ItemContainer::hasElements() throw ( RuntimeException ) { ShareGuard aLock( m_aShareMutex ); - return ( m_aItemVector.size() != 0 ); + return ( !m_aItemVector.empty() ); } // XIndexAccess diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 84323b3bb7ef..555682677e33 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -44,7 +44,6 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> //_________________________________________________________________________________________________________________ @@ -72,7 +71,7 @@ #include <svtools/languageoptions.hxx> #include <com/sun/star/awt/MenuItemStyle.hpp> #include <svtools/langtab.hxx> -#include <classes/fwkresid.hxx> +#include <classes/fwlresid.hxx> #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_ #include <classes/resource.hrc> @@ -107,6 +106,7 @@ DEFINE_INIT_SERVICE ( LanguageSelectionMenuController, {} LanguageSelectionMenuController::LanguageSelectionMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : PopupMenuControllerBase( xServiceManager ), m_bShowMenu( sal_True ) + ,m_aLangGuessHelper(xServiceManager) { } @@ -167,129 +167,65 @@ void SAL_CALL LanguageSelectionMenuController::statusChanged( const FeatureState } // XMenuListener -void SAL_CALL LanguageSelectionMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) +void LanguageSelectionMenuController::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aTargetURL) { -} - -void SAL_CALL LanguageSelectionMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; + Reference< XDispatch > xDispatch = _xDispatch; - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - //xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); + if ( aTargetURL.Complete == m_aMenuCommandURL_Font ) + { //open format/character dialog for current selection + xDispatch = m_xMenuDispatch_Font; + } + else if ( aTargetURL.Complete == m_aMenuCommandURL_Lang ) + { //open language tab-page in tools/options dialog + xDispatch = m_xMenuDispatch_Lang; + } + else if ( aTargetURL.Complete == m_aMenuCommandURL_CharDlgForParagraph ) + { //open format/character dialog for current selection + xDispatch = m_xMenuDispatch_CharDlgForParagraph; + } - if ( xPopupMenu.is())//&& xDispatch.is() + if ( !xDispatch.is() ) { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence< PropertyValue > aArgs; - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - // Command URL used to dispatch the selected font family name - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - if ( aTargetURL.Complete == m_aMenuCommandURL_Font ) - { //open format/character dialog for current selection - xDispatch = m_xMenuDispatch_Font; - } - else if ( aTargetURL.Complete == m_aMenuCommandURL_Lang ) - { //open language tab-page in tools/options dialog - xDispatch = m_xMenuDispatch_Lang; - } - else if ( aTargetURL.Complete == m_aMenuCommandURL_CharDlgForParagraph ) - { //open format/character dialog for current selection - xDispatch = m_xMenuDispatch_CharDlgForParagraph; - } - - xURLTransformer->parseStrict( aTargetURL ); - if ( !xDispatch.is() ) - { - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - if ( xDispatchProvider.is() ) - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - } - - if ( xDispatch.is() ) - { - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("LanguageSelectionMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - xDispatch->dispatch( aTargetURL, aArgs ); - } - } + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + if ( xDispatchProvider.is() ) + xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); } -} -void SAL_CALL LanguageSelectionMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL LanguageSelectionMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ + if ( xDispatch.is() ) + { + Sequence<PropertyValue> aArgs; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString::createFromAscii("LanguageSelectionMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); + xDispatch->dispatch( aTargetURL, aArgs ); + } } // XPopupMenuController -void SAL_CALL LanguageSelectionMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw (RuntimeException) +void LanguageSelectionMenuController::impl_setPopupMenu() { - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - // Register for language updates - aTargetURL.Complete = m_aLangStatusCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xLanguageDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - // Register for setting languages and opening language dialog - aTargetURL.Complete = m_aMenuCommandURL_Lang; - xURLTransformer->parseStrict( aTargetURL ); - m_xMenuDispatch_Lang = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - // Register for opening character dialog - aTargetURL.Complete = m_aMenuCommandURL_Font; - xURLTransformer->parseStrict( aTargetURL ); - m_xMenuDispatch_Font = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - // Register for opening character dialog with preselected paragraph - aTargetURL.Complete = m_aMenuCommandURL_CharDlgForParagraph; - xURLTransformer->parseStrict( aTargetURL ); - m_xMenuDispatch_CharDlgForParagraph = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + com::sun::star::util::URL aTargetURL; - updatePopupMenu(); - } + // Register for language updates + aTargetURL.Complete = m_aLangStatusCommandURL; + m_xURLTransformer->parseStrict( aTargetURL ); + m_xLanguageDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + + // Register for setting languages and opening language dialog + aTargetURL.Complete = m_aMenuCommandURL_Lang; + m_xURLTransformer->parseStrict( aTargetURL ); + m_xMenuDispatch_Lang = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + + // Register for opening character dialog + aTargetURL.Complete = m_aMenuCommandURL_Font; + m_xURLTransformer->parseStrict( aTargetURL ); + m_xMenuDispatch_Font = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + + // Register for opening character dialog with preselected paragraph + aTargetURL.Complete = m_aMenuCommandURL_CharDlgForParagraph; + m_xURLTransformer->parseStrict( aTargetURL ); + m_xMenuDispatch_CharDlgForParagraph = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); } void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu , const Mode eMode ) @@ -306,9 +242,9 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup if ( pVCLPopupMenu ) pPopupMenu = (PopupMenu *)pVCLPopupMenu->GetMenu(); - String aCmd=String::CreateFromAscii(""); - String aCmd_Dialog=String::CreateFromAscii(""); - String aCmd_Language=String::CreateFromAscii(""); + String aCmd; + String aCmd_Dialog; + String aCmd_Language; if( eMode == MODE_SetLanguageSelectionMenu ) { aCmd_Dialog+=String::CreateFromAscii(".uno:FontDialog?Language:string=*"); @@ -332,7 +268,7 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup USHORT nItemId = 1; //1--add current language - if(m_aCurLang!=::rtl::OUString::createFromAscii("")) + if(m_aCurLang.getLength()) { LangItems[m_aCurLang]=m_aCurLang; } @@ -404,17 +340,18 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup break; const Locale& rLocale=rLocales[i]; if(IsScriptTypeMatchingToLanguage(m_nScriptType, aLanguageTable.GetType(rLocale.Language))) - LangItems[::rtl::OUString(rLocale.Language)]=::rtl::OUString(rLocale.Language); + LangItems[rLocale.Language] = rLocale.Language; } } } std::map< sal_Int16, ::rtl::OUString > LangTable; + const ::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); for(std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it) { if(it->first != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&& - it->first != ::rtl::OUString::createFromAscii("*") && - it->first != ::rtl::OUString::createFromAscii("")) + it->first != sAsterix && + it->first.getLength()) { ++nItemId; pPopupMenu->InsertItem( nItemId,it->first); @@ -432,14 +369,14 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup //7--none nItemId++; - pPopupMenu->InsertItem( nItemId, String(FwkResId( STR_LANGSTATUS_NONE )) ); + pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_NONE )) ); aCmd=aCmd_Language; aCmd+=String::CreateFromAscii("LANGUAGE_NONE"); pPopupMenu->SetItemCommand(nItemId,aCmd); //More... nItemId++; - pPopupMenu->InsertItem( nItemId, String(FwkResId( STR_LANGSTATUS_MORE ))); + pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_MORE ))); pPopupMenu->SetItemCommand(nItemId,aCmd_Dialog); } @@ -451,12 +388,9 @@ void SAL_CALL LanguageSelectionMenuController::updatePopupMenu() throw ( ::com:: // Force status update to get information about the current languages ResetableGuard aLock( m_aLock ); Reference< XDispatch > xDispatch( m_xLanguageDispatch ); - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = m_aLangStatusCommandURL; - xURLTransformer->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); aLock.unlock(); if ( xDispatch.is() ) @@ -484,39 +418,19 @@ void SAL_CALL LanguageSelectionMenuController::updatePopupMenu() throw ( ::com:: // XInitialization void SAL_CALL LanguageSelectionMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - const rtl::OUString aFrameName( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - const rtl::OUString aCommandURLName( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); - ResetableGuard aLock( m_aLock ); sal_Bool bInitalized( m_bInitialized ); if ( !bInitalized ) { - PropertyValue aPropValue; - rtl::OUString aCommandURL; - Reference< XFrame > xFrame; - - for ( int i = 0; i < aArguments.getLength(); i++ ) - { - if ( aArguments[i] >>= aPropValue ) - { - if ( aPropValue.Name.equalsAscii( "Frame" )) - aPropValue.Value >>= xFrame; - else if ( aPropValue.Name.equalsAscii( "CommandURL" )) - aPropValue.Value >>= aCommandURL; - } - } + PopupMenuControllerBase::initialize(aArguments); - if ( xFrame.is() && aCommandURL.getLength() ) + if ( m_bInitialized ) { - m_xFrame = xFrame; - m_aCommandURL = aCommandURL; - m_aBaseURL = determineBaseURL( aCommandURL ); m_aLangStatusCommandURL = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LanguageStatus" )); m_aMenuCommandURL_Lang = m_aLangStatusCommandURL; m_aMenuCommandURL_Font = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialog" )); m_aMenuCommandURL_CharDlgForParagraph = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialogForParagraph" )); - m_bInitialized = true; } } } diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 6eee84328315..bccd553b57d3 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -100,6 +100,7 @@ LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::R svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), rtl::OUString(), 0 ), m_bShowMenu( sal_True ), m_nScriptType( 7 ) + ,m_aLangGuessHelper(xServiceManager) { } @@ -123,6 +124,7 @@ void SAL_CALL LangSelectionStatusbarController::release() throw () void SAL_CALL LangSelectionStatusbarController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::initialize" ); vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); svt::StatusbarController::initialize( aArguments ); @@ -142,6 +144,7 @@ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException void SAL_CALL LangSelectionStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::dispose" ); svt::StatusbarController::dispose(); } @@ -149,6 +152,7 @@ throw (::com::sun::star::uno::RuntimeException) void SAL_CALL LangSelectionStatusbarController::disposing( const com::sun::star::lang::EventObject& Source ) throw ( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::disposing" ); svt::StatusbarController::disposing( Source ); } @@ -157,6 +161,7 @@ throw ( RuntimeException ) const ::com::sun::star::awt::MouseEvent& ) throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseButtonDown" ); return sal_False; } @@ -164,6 +169,7 @@ throw (::com::sun::star::uno::RuntimeException) const ::com::sun::star::awt::MouseEvent& ) throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseMove" ); return sal_False; } @@ -171,18 +177,21 @@ throw (::com::sun::star::uno::RuntimeException) const ::com::sun::star::awt::MouseEvent& ) throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseButtonUp" ); return sal_False; } void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" ); if (!m_bShowMenu) return; //add context menu - Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.PopupMenu" ) ), UNO_QUERY ); + const static ::rtl::OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu")); + Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph - Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.PopupMenu" ) ), UNO_QUERY ); + Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); std::set< ::rtl::OUString > LangItems; @@ -190,7 +199,7 @@ void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::R USHORT nItemId=1; //1--add current language - if( m_aCurLang != ::rtl::OUString::createFromAscii( "" ) && + if( m_aCurLang != ::rtl::OUString( ) && LANGUAGE_DONTKNOW != aLanguageTable.GetType( m_aCurLang )) LangItems.insert( m_aCurLang ); @@ -394,6 +403,7 @@ void SAL_CALL LangSelectionStatusbarController::command( const ::com::sun::star::uno::Any& /*aData*/ ) throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::command" ); if ( nCommand & ::awt::Command::CONTEXTMENU ) { LangMenu(); @@ -407,18 +417,21 @@ void SAL_CALL LangSelectionStatusbarController::paint( ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::paint" ); svt::StatusbarController::paint( xGraphics, rOutputRectangle, nItemId, nStyle ); } void SAL_CALL LangSelectionStatusbarController::click() throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::click" ); LangMenu(); } void SAL_CALL LangSelectionStatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::doubleClick" ); svt::StatusbarController::doubleClick(); } @@ -426,6 +439,7 @@ throw (::com::sun::star::uno::RuntimeException) void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" ); vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); if ( m_bDisposed ) diff --git a/framework/source/uielement/logoimagestatusbarcontroller.cxx b/framework/source/uielement/logoimagestatusbarcontroller.cxx index 963c652251fd..7f08e9746370 100644 --- a/framework/source/uielement/logoimagestatusbarcontroller.cxx +++ b/framework/source/uielement/logoimagestatusbarcontroller.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" #include <uielement/logoimagestatusbarcontroller.hxx> -#include <classes/fwkresid.hxx> +#include <classes/fwlresid.hxx> #include <services.h> #include <classes/resource.hrc> #include <vos/mutex.hxx> @@ -64,7 +64,7 @@ DEFINE_INIT_SERVICE ( LogoImageStatusbarController, {} ) LogoImageStatusbarController::LogoImageStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) : svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), rtl::OUString(), 0 ) { - Image aImage( FwkResId( RID_IMAGE_STATUSBAR_LOGO )); + Image aImage( FwlResId( RID_IMAGE_STATUSBAR_LOGO )); m_aLogoImage = aImage; } diff --git a/framework/source/uielement/logotextstatusbarcontroller.cxx b/framework/source/uielement/logotextstatusbarcontroller.cxx index efba92bcfd1d..035bb7b0a523 100644 --- a/framework/source/uielement/logotextstatusbarcontroller.cxx +++ b/framework/source/uielement/logotextstatusbarcontroller.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" #include <uielement/logotextstatusbarcontroller.hxx> -#include <classes/fwkresid.hxx> +#include <classes/fwlresid.hxx> #include <services.h> #include <classes/resource.hrc> #include <vos/mutex.hxx> @@ -65,7 +65,7 @@ DEFINE_INIT_SERVICE ( LogoTextStatusbarController, {} ) LogoTextStatusbarController::LogoTextStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) : svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), rtl::OUString(), 0 ) { - m_aLogoText = String( FwkResId( STR_STATUSBAR_LOGOTEXT )); + m_aLogoText = String( FwlResId( STR_STATUSBAR_LOGOTEXT )); } LogoTextStatusbarController::~LogoTextStatusbarController() diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx index 93997d27cbb0..612f50d62dd0 100644 --- a/framework/source/uielement/macrosmenucontroller.cxx +++ b/framework/source/uielement/macrosmenucontroller.cxx @@ -32,6 +32,7 @@ #include "precompiled_framework.hxx" #include <uielement/macrosmenucontroller.hxx> +#include <uielement/menubarmanager.hxx> #include <threadhelp/resetableguard.hxx> #include "services.h" #include <classes/resource.hrc> @@ -42,7 +43,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <comphelper/processfactory.hxx> #include <vcl/svapp.hxx> @@ -50,6 +50,7 @@ #include <tools/urlobj.hxx> #include <rtl/ustrbuf.hxx> #include <dispatch/uieventloghelper.hxx> +#include "helper/mischelper.hxx" using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -136,60 +137,25 @@ void SAL_CALL MacrosMenuController::statusChanged( const FeatureStateEvent& ) th } // XMenuListener -void SAL_CALL MacrosMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) +void MacrosMenuController::impl_select(const Reference< XDispatch >& /*_xDispatch*/,const ::com::sun::star::util::URL& aTargetURL) { -} - -void SAL_CALL MacrosMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() && xDispatch.is() ) + // need to requery, since we handle more than one type of Command + // if we don't do this only .uno:ScriptOrganizer commands are executed + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + if( xDispatch.is() ) { - VCLXPopupMenu* pVCLPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pVCLPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs; - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pPopupMenu = (PopupMenu *)pVCLPopupMenu->GetMenu(); - - aTargetURL.Complete = pPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - - // need to requery, since we handle more than one type of Command - // if we don't do this only .uno:ScriptOrganizer commands are executed - xDispatch = m_xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - if( xDispatch.is() ) - { - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("MacrosMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + //pExecuteInfo->aArgs = aArgs; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString::createFromAscii("MacrosMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, pExecuteInfo->aArgs); // xDispatch->dispatch( aTargetURL, aArgs ); - Application::PostUserEvent( STATIC_LINK(0, MacrosMenuController , ExecuteHdl_Impl), pExecuteInfo ); - } - else - { - } - } + Application::PostUserEvent( STATIC_LINK(0, MacrosMenuController , ExecuteHdl_Impl), pExecuteInfo ); + } + else + { } } @@ -210,105 +176,10 @@ IMPL_STATIC_LINK_NOINSTANCE( MacrosMenuController, ExecuteHdl_Impl, ExecuteInfo* return 0; } -void SAL_CALL MacrosMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL MacrosMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -// XPopupMenuController -void SAL_CALL MacrosMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - m_xDispatchProvider = xDispatchProvider; - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - updatePopupMenu(); - } -} - -// XInitialization -void SAL_CALL MacrosMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); -} - String MacrosMenuController::RetrieveLabelFromCommand( const String& aCmdURL ) { - String aLabel; - - // Retrieve popup menu labels - if ( !m_aModuleIdentifier.getLength() ) - { - Reference< XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance( - SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); - Reference< XInterface > xIfac( m_xFrame, UNO_QUERY ); - m_aModuleIdentifier = xModuleManager->identify( xIfac ); - - if ( m_aModuleIdentifier.getLength() > 0 ) - { - Reference< XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( - SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); - if ( xNameAccess.is() ) - { - Any a = xNameAccess->getByName( m_aModuleIdentifier ); - Reference< XNameAccess > xUICommands; - a >>= m_xUICommandLabels; - } - } - } - - if ( m_xUICommandLabels.is() ) - { - try - { - if ( aCmdURL.Len() > 0 ) - { - rtl::OUString aStr; - Sequence< PropertyValue > aPropSeq; - Any a( m_xUICommandLabels->getByName( aCmdURL )); - if ( a >>= aPropSeq ) - { - for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name.equalsAscii( "Label" )) - { - aPropSeq[i].Value >>= aStr; - break; - } - } - } - aLabel = aStr; - } - } - catch ( com::sun::star::uno::Exception& ) - { - } - } - - return aLabel; + sal_Bool bModuleIdentified = m_aModuleIdentifier.getLength() != 0; + return framework::RetrieveLabelFromCommand(aCmdURL,m_xServiceManager,m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,bModuleIdentified,"Label"); } void MacrosMenuController::addScriptItems( PopupMenu* pPopupMenu, USHORT startItemId ) diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 54e77596970b..4e1df67d69fb 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -36,14 +36,16 @@ // my own includes //_________________________________________________________________________________________________________________ #include <uielement/menubarmanager.hxx> -#include <classes/menuconfiguration.hxx> +#include <xml/menuconfiguration.hxx> #include <classes/bmkmenu.hxx> #include <classes/addonmenu.hxx> #include <helper/imageproducer.hxx> #include <threadhelp/resetableguard.hxx> #include "classes/addonsoptions.hxx" #include <classes/fwkresid.hxx> +#include <classes/menumanager.hxx> #include <helper/acceleratorinfo.hxx> +#include <helper/mischelper.hxx> #include <classes/menuextensionsupplier.hxx> #include <classes/resource.hrc> #include <services.h> @@ -53,6 +55,7 @@ //_________________________________________________________________________________________________________________ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XDesktop.hpp> @@ -67,7 +70,6 @@ #endif #include <com/sun/star/ui/ItemType.hpp> #include <com/sun/star/ui/ImageType.hpp> -#include <com/sun/star/lang/XSingleComponentFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> @@ -153,7 +155,7 @@ class StringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XSt // XStringWidth sal_Int32 SAL_CALL queryStringWidth( const ::rtl::OUString& aString ) - throw (::com::sun::star::uno::RuntimeException) + throw (RuntimeException) { return aString.getLength(); } @@ -172,9 +174,7 @@ namespace framework #define SID_HELPMENU (SID_SFX_START + 410) #define SFX_REFERER_USER "private:user" -#define DESKTOP_SERVICE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )) -const ::rtl::OUString aSlotString( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); const ::rtl::OUString aCmdHelpIndex( RTL_CONSTASCII_USTRINGPARAM( ".uno:HelpIndex" )); const ::rtl::OUString aCmdToolsMenu( RTL_CONSTASCII_USTRINGPARAM( ".uno:ToolsMenu" )); const ::rtl::OUString aCmdHelpMenu( RTL_CONSTASCII_USTRINGPARAM( ".uno:HelpMenu" )); @@ -204,20 +204,23 @@ static sal_Int16 getImageTypeFromBools( sal_Bool bBig, sal_Bool bHighContrast ) // #110897# MenuBarManager::MenuBarManager( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const Reference< XMultiServiceFactory >& xServiceFactory, const Reference< XFrame >& rFrame, + const Reference< XURLTransformer >& _xURLTransformer, const Reference< XDispatchProvider >& rDispatchProvider, const rtl::OUString& rModuleIdentifier, Menu* pMenu, sal_Bool bDelete, sal_Bool bDeleteChildren ) : ThreadHelpBase( &Application::GetSolarMutex() ), OWeakObject() , m_bDisposed( sal_False ) - , m_bModuleIdentified( sal_False ) , m_bRetrieveImages( sal_False ) , m_bAcceleratorCfg( sal_False ) + , m_bModuleIdentified( sal_False ) , m_aListenerContainer( m_aLock.getShareableOslMutex() ) , mxServiceFactory(xServiceFactory) + , m_xURLTransformer(_xURLTransformer) , m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::MenuBarManager" ); m_xPopupMenuControllerRegistration = Reference< ::com::sun::star::frame::XUIControllerRegistration >( getServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuControllerFactory" ))), UNO_QUERY ); @@ -226,209 +229,59 @@ MenuBarManager::MenuBarManager( // #110897# MenuBarManager::MenuBarManager( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const Reference< XMultiServiceFactory >& xServiceFactory, const Reference< XFrame >& rFrame, + const Reference< XURLTransformer >& _xURLTransformer, AddonMenu* pAddonMenu, sal_Bool bDelete, sal_Bool bDeleteChildren ) : ThreadHelpBase( &Application::GetSolarMutex() ) , OWeakObject() , m_bDisposed( sal_False ) - , m_bModuleIdentified( sal_False ) , m_bRetrieveImages( sal_True ) , m_bAcceleratorCfg( sal_False ) + , m_bModuleIdentified( sal_False ) , m_aListenerContainer( m_aLock.getShareableOslMutex() ) , mxServiceFactory(xServiceFactory) + , m_xURLTransformer(_xURLTransformer) , m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ) { - m_bActive = sal_False; - m_bDeleteMenu = bDelete; - m_bDeleteChildren = bDeleteChildren; - m_pVCLMenu = pAddonMenu; - m_xFrame = rFrame; - m_bInitialized = sal_False; - m_bIsBookmarkMenu = sal_True; - - rtl::OUString aModuleIdentifier; - m_xPopupMenuControllerRegistration = Reference< ::com::sun::star::frame::XUIControllerRegistration >( - getServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuControllerFactory" ))), - UNO_QUERY ); - - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); - m_bWasHiContrast = rSettings.GetMenuColor().IsDark(); - - Reference< XStatusListener > xStatusListener; - Reference< XDispatch > xDispatch; - USHORT nItemCount = pAddonMenu->GetItemCount(); - for ( USHORT i = 0; i < nItemCount; i++ ) - { - USHORT nItemId = pAddonMenu->GetItemId( i ); - - ::rtl::OUString aItemCommand = pAddonMenu->GetItemCommand( nItemId ); - if ( !aItemCommand.getLength() ) - { - aItemCommand = aSlotString; - aItemCommand += ::rtl::OUString::valueOf( (sal_Int32)nItemId ); - pAddonMenu->SetItemCommand( nItemId, aItemCommand ); - } - - PopupMenu* pPopupMenu = pAddonMenu->GetPopupMenu( nItemId ); - if ( pPopupMenu ) - { - // #110897# - Reference< XDispatchProvider > xDispatchProvider; - MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), rFrame, xDispatchProvider, aModuleIdentifier, pPopupMenu, bDeleteChildren, bDeleteChildren ); - - Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); - - // store menu item command as we later have to know which menu is active (see Acivate handler) - pSubMenuManager->m_aMenuItemCommand = aItemCommand; - - MenuItemHandler* pMenuItemHandler = new MenuItemHandler( - nItemId, - xSubMenuManager, - xDispatch ); - m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); - } - else - { - if ( pAddonMenu->GetItemType( i ) != MENUITEM_SEPARATOR ) - { - MenuConfiguration::Attributes* pAddonAttributes = (MenuConfiguration::Attributes *)(pAddonMenu->GetUserValue( nItemId )); - MenuItemHandler* pMenuItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch ); - - if ( pAddonAttributes ) - { - // read additional attributes from attributes struct and AddonMenu implementation will delete all attributes itself!! - pMenuItemHandler->aTargetFrame = pAddonAttributes->aTargetFrame; - } - - pMenuItemHandler->aMenuItemURL = aItemCommand; - m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); - } - } - } - - m_pVCLMenu->SetHighlightHdl( LINK( this, MenuBarManager, Highlight )); - m_pVCLMenu->SetActivateHdl( LINK( this, MenuBarManager, Activate )); - m_pVCLMenu->SetDeactivateHdl( LINK( this, MenuBarManager, Deactivate )); - m_pVCLMenu->SetSelectHdl( LINK( this, MenuBarManager, Select )); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::MenuBarManager" ); + Init(rFrame,pAddonMenu,bDelete,bDeleteChildren); } - // #110897# MenuBarManager::MenuBarManager( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const Reference< XMultiServiceFactory >& xServiceFactory, const Reference< XFrame >& rFrame, + const Reference< XURLTransformer >& _xURLTransformer, AddonPopupMenu* pAddonPopupMenu, sal_Bool bDelete, sal_Bool bDeleteChildren ) : ThreadHelpBase( &Application::GetSolarMutex() ) , OWeakObject() , m_bDisposed( sal_False ) - , m_bModuleIdentified( sal_False ) , m_bRetrieveImages( sal_True ) , m_bAcceleratorCfg( sal_False ) + , m_bModuleIdentified( sal_False ) , m_aListenerContainer( m_aLock.getShareableOslMutex() ) , mxServiceFactory(xServiceFactory) + , m_xURLTransformer(_xURLTransformer) , m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ) { - m_bActive = sal_False; - m_bDeleteMenu = bDelete; - m_bDeleteChildren = bDeleteChildren; - m_pVCLMenu = pAddonPopupMenu; - m_xFrame = rFrame; - m_bInitialized = sal_False; - m_bIsBookmarkMenu = sal_True; - - rtl::OUString aModuleIdentifier; - m_xPopupMenuControllerRegistration = Reference< ::com::sun::star::frame::XUIControllerRegistration >( - getServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuControllerFactory" ))), - UNO_QUERY ); - - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); - m_bWasHiContrast = rSettings.GetMenuColor().IsDark(); - - Reference< XDispatch > xDispatch; - Reference< XStatusListener > xStatusListener; - USHORT nItemCount = pAddonPopupMenu->GetItemCount(); - for ( USHORT i = 0; i < nItemCount; i++ ) - { - USHORT nItemId = pAddonPopupMenu->GetItemId( i ); - - ::rtl::OUString aItemCommand = pAddonPopupMenu->GetItemCommand( nItemId ); - if ( !aItemCommand.getLength() ) - { - aItemCommand = aSlotString; - aItemCommand += ::rtl::OUString::valueOf( (sal_Int32)nItemId ); - pAddonPopupMenu->SetItemCommand( nItemId, aItemCommand ); - } - - PopupMenu* pPopupMenu = pAddonPopupMenu->GetPopupMenu( nItemId ); - if ( pPopupMenu ) - { - // #110897# - Reference< XDispatchProvider > xDispatchProvider; - MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), rFrame, xDispatchProvider, aModuleIdentifier, pPopupMenu, sal_False, sal_False ); - - Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); - - // store menu item command as we later have to know which menu is active (see Acivate handler) - pSubMenuManager->m_aMenuItemCommand = aItemCommand; - - MenuItemHandler* pMenuItemHandler = new MenuItemHandler( - nItemId, - xSubMenuManager, - xDispatch ); - m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); - } - else - { - if ( pAddonPopupMenu->GetItemType( i ) != MENUITEM_SEPARATOR ) - { - MenuConfiguration::Attributes* pAttributes = (MenuConfiguration::Attributes *)(pAddonPopupMenu->GetUserValue( nItemId )); - MenuItemHandler* pMenuItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch ); - - if ( pAttributes ) - { - // read additional attributes from attributes struct and BmkMenu implementation will delete all attributes itself!! - pMenuItemHandler->aTargetFrame = pAttributes->aTargetFrame; - } - - pMenuItemHandler->aMenuItemURL = aItemCommand; - - // Check if we have to create a popup menu for a uno based popup menu controller. - // We have to set an empty popup menu into our menu structure so the controller also - // works with inplace OLE. - if ( m_xPopupMenuControllerRegistration.is() && - m_xPopupMenuControllerRegistration->hasController( aItemCommand, rtl::OUString() )) - { - VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu; - PopupMenu* pCtlPopupMenu = (PopupMenu *)pVCLXPopupMenu->GetMenu(); - pAddonPopupMenu->SetPopupMenu( pMenuItemHandler->nItemId, pCtlPopupMenu ); - pMenuItemHandler->xPopupMenu = Reference< com::sun::star::awt::XPopupMenu >( (OWeakObject *)pVCLXPopupMenu, UNO_QUERY ); - - } - m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); - } - } - } - - m_pVCLMenu->SetHighlightHdl( LINK( this, MenuBarManager, Highlight )); - m_pVCLMenu->SetActivateHdl( LINK( this, MenuBarManager, Activate )); - m_pVCLMenu->SetDeactivateHdl( LINK( this, MenuBarManager, Deactivate )); - m_pVCLMenu->SetSelectHdl( LINK( this, MenuBarManager, Select )); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::MenuBarManager" ); + Init(rFrame,pAddonPopupMenu,bDelete,bDeleteChildren,true); } -Any SAL_CALL MenuBarManager::queryInterface( const ::com::sun::star::uno::Type & rType ) throw ( RuntimeException ) +Any SAL_CALL MenuBarManager::queryInterface( const Type & rType ) throw ( RuntimeException ) { Any a = ::cppu::queryInterface( rType , SAL_STATIC_CAST( ::com::sun::star::frame::XStatusListener*, this ), SAL_STATIC_CAST( ::com::sun::star::frame::XFrameActionListener*, this ), SAL_STATIC_CAST( ::com::sun::star::ui::XUIConfigurationListener*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XEventListener*, (XStatusListener *)this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XComponent*, this ), + SAL_STATIC_CAST( XEventListener*, (XStatusListener *)this ), + SAL_STATIC_CAST( XComponent*, this ), SAL_STATIC_CAST( ::com::sun::star::awt::XSystemDependentMenuPeer*, this )); if ( a.hasValue() ) @@ -450,8 +303,9 @@ void SAL_CALL MenuBarManager::release() throw() } -Any SAL_CALL MenuBarManager::getMenuHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw (::com::sun::star::uno::RuntimeException) +Any SAL_CALL MenuBarManager::getMenuHandle( const Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw (RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::getMenuHandle" ); ResetableGuard aGuard( m_aLock ); if ( m_bDisposed ) @@ -468,16 +322,16 @@ Any SAL_CALL MenuBarManager::getMenuHandle( const ::com::sun::star::uno::Sequenc m_pVCLMenu->GetSystemMenuData( &aSystemMenuData ); #ifdef QUARTZ - if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC ) + if( SystemType == SystemDependent::SYSTEM_MAC ) { } #elif (defined WNT) - if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 ) + if( SystemType == SystemDependent::SYSTEM_WIN32 ) { a <<= (long) aSystemMenuData.hMenu; } #elif (defined UNX) - if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW ) + if( SystemType == SystemDependent::SYSTEM_XWINDOW ) { } #endif @@ -497,6 +351,7 @@ MenuBarManager::~MenuBarManager() void MenuBarManager::Destroy() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::Destroy" ); OGuard aGuard( Application::GetSolarMutex() ); if ( !m_bDisposed ) @@ -529,6 +384,7 @@ void MenuBarManager::Destroy() // XComponent void SAL_CALL MenuBarManager::dispose() throw( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::dispose" ); Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); EventObject aEvent( xThis ); @@ -577,6 +433,7 @@ void SAL_CALL MenuBarManager::dispose() throw( RuntimeException ) void SAL_CALL MenuBarManager::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::addEventListener" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -588,14 +445,16 @@ void SAL_CALL MenuBarManager::addEventListener( const Reference< XEventListener void SAL_CALL MenuBarManager::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::removeEventListener" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener ); } void SAL_CALL MenuBarManager::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) -throw (::com::sun::star::uno::RuntimeException) +throw (RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::elementInserted" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -610,41 +469,24 @@ throw (::com::sun::star::uno::RuntimeException) } void SAL_CALL MenuBarManager::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) -throw (::com::sun::star::uno::RuntimeException) +throw (RuntimeException) { - ResetableGuard aGuard( m_aLock ); - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - if ( m_bDisposed ) - return; - - sal_Int16 nImageType = sal_Int16(); - sal_Int16 nCurrentImageType = getImageTypeFromBools( sal_False, m_bWasHiContrast ); - if (( Event.aInfo >>= nImageType ) && - ( nImageType == nCurrentImageType )) - RequestImages(); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::elementRemoved" ); + elementInserted(Event); } void SAL_CALL MenuBarManager::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) -throw (::com::sun::star::uno::RuntimeException) +throw (RuntimeException) { - ResetableGuard aGuard( m_aLock ); - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - if ( m_bDisposed ) - return; - - sal_Int16 nImageType = sal_Int16(); - sal_Int16 nCurrentImageType = getImageTypeFromBools( sal_False, m_bWasHiContrast ); - if (( Event.aInfo >>= nImageType ) && - ( nImageType == nCurrentImageType )) - RequestImages(); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::elementReplaced" ); + elementInserted(Event); } // XFrameActionListener void SAL_CALL MenuBarManager::frameAction( const FrameActionEvent& Action ) throw ( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::frameAction" ); ResetableGuard aGuard( m_aLock ); if ( m_bDisposed ) @@ -666,6 +508,7 @@ throw ( RuntimeException ) void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::statusChanged" ); ::rtl::OUString aFeatureURL = Event.FeatureURL.Complete; OGuard aSolarGuard( Application::GetSolarMutex() ); @@ -761,6 +604,7 @@ throw ( RuntimeException ) // Helper to retrieve own structure from item ID MenuBarManager::MenuItemHandler* MenuBarManager::GetMenuItemHandler( USHORT nItemId ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::GetMenuItemHandler" ); ResetableGuard aGuard( m_aLock ); std::vector< MenuItemHandler* >::iterator p; @@ -777,10 +621,13 @@ MenuBarManager::MenuItemHandler* MenuBarManager::GetMenuItemHandler( USHORT nIte // Helper to set request images flag void MenuBarManager::RequestImages() { - ResetableGuard aGuard( m_aLock ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::RequestImages" ); + // must be locked from callee + // ResetableGuard aGuard( m_aLock ); m_bRetrieveImages = sal_True; - for ( sal_uInt32 i = 0; i < m_aMenuItemHandlerVector.size(); i++ ) + const sal_uInt32 nCount = m_aMenuItemHandlerVector.size(); + for ( sal_uInt32 i = 0; i < nCount; ++i ) { MenuItemHandler* pItemHandler = m_aMenuItemHandlerVector[i]; if ( pItemHandler->xSubMenuManager.is() ) @@ -794,6 +641,7 @@ void MenuBarManager::RequestImages() // Helper to reset objects to prepare shutdown void MenuBarManager::RemoveListener() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::RemoveListener" ); ResetableGuard aGuard( m_aLock ); // Check service manager reference. Remove listener can be called due @@ -802,9 +650,6 @@ void MenuBarManager::RemoveListener() Reference< XMultiServiceFactory > xServiceManager = getServiceFactory(); if ( xServiceManager.is() ) { - Reference< XURLTransformer > xTrans( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - std::vector< MenuItemHandler* >::iterator p; for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); p++ ) { @@ -813,7 +658,7 @@ void MenuBarManager::RemoveListener() { URL aTargetURL; aTargetURL.Complete = pItemHandler->aMenuItemURL; - xTrans->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); pItemHandler->xMenuItemDispatch->removeStatusListener( static_cast< XStatusListener* >( this ), aTargetURL ); @@ -879,6 +724,7 @@ void MenuBarManager::RemoveListener() void SAL_CALL MenuBarManager::disposing( const EventObject& Source ) throw ( RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::disposing(evt)" ); MenuItemHandler* pMenuItemDisposing = NULL; ResetableGuard aGuard( m_aLock ); @@ -907,9 +753,7 @@ void SAL_CALL MenuBarManager::disposing( const EventObject& Source ) throw ( Run Reference< XMultiServiceFactory > xServiceManager( getServiceFactory() ); if ( xServiceManager.is() ) { - Reference< XURLTransformer > xTrans( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - xTrans->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); pMenuItemDisposing->xMenuItemDispatch->removeStatusListener( static_cast< XStatusListener* >( this ), aTargetURL ); @@ -944,78 +788,10 @@ void SAL_CALL MenuBarManager::disposing( const EventObject& Source ) throw ( Run m_xModuleImageManager.clear(); } -void MenuBarManager::UpdateSpecialWindowMenu( Menu* pMenu ) -{ - // update window list - ::std::vector< ::rtl::OUString > aNewWindowListVector; - - // #110897# - // Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( DESKTOP_SERVICE ), UNO_QUERY ); - Reference< XDesktop > xDesktop( getServiceFactory()->createInstance( DESKTOP_SERVICE ), UNO_QUERY ); - - USHORT nActiveItemId = 0; - USHORT nItemId = START_ITEMID_WINDOWLIST; - - if ( xDesktop.is() ) - { - Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY ); - Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame(); - Reference< XIndexAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY ); - sal_Int32 nCount = xList->getCount(); - for (sal_Int32 i=0; i<nCount; ++i ) - { - Any aItem = xList->getByIndex(i); - Reference< XFrame > xFrame; - aItem >>= xFrame; - if (xFrame.is()) - { - if ( xFrame == xCurrentFrame ) - nActiveItemId = nItemId; - - Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); - if ( pWin && pWin->IsVisible() ) - { - aNewWindowListVector.push_back( pWin->GetText() ); - ++nItemId; - } - } - } - } - - { - ResetableGuard aGuard( m_aLock ); - - int nItemCount = pMenu->GetItemCount(); - - if ( nItemCount > 0 ) - { - // remove all old window list entries from menu - sal_uInt16 nPos = pMenu->GetItemPos( START_ITEMID_WINDOWLIST ); - for ( sal_uInt16 n = nPos; n < pMenu->GetItemCount(); ) - pMenu->RemoveItem( n ); - - if ( pMenu->GetItemType( pMenu->GetItemCount()-1 ) == MENUITEM_SEPARATOR ) - pMenu->RemoveItem( pMenu->GetItemCount()-1 ); - } - - if ( aNewWindowListVector.size() > 0 ) - { - // append new window list entries to menu - pMenu->InsertSeparator(); - nItemId = START_ITEMID_WINDOWLIST; - for ( sal_uInt32 i = 0; i < aNewWindowListVector.size(); i++ ) - { - pMenu->InsertItem( nItemId, aNewWindowListVector.at( i ), MIB_RADIOCHECK ); - if ( nItemId == nActiveItemId ) - pMenu->CheckItem( nItemId ); - ++nItemId; - } - } - } -} void MenuBarManager::CheckAndAddMenuExtension( Menu* pMenu ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::CheckAndAddMenuExtension" ); static const char REFERENCECOMMAND_AFTER[] = ".uno:OnlineRegistrationDlg"; static const char REFERENCECOMMAND_BEFORE[] = ".uno:About"; @@ -1064,6 +840,7 @@ static void lcl_CheckForChildren(Menu* pMenu, USHORT nItemId) IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::Activate" ); if ( pMenu == m_pVCLMenu ) { // set/unset hiding disabled menu entries @@ -1090,7 +867,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) if ( m_aMenuItemCommand == aSpecialWindowMenu || m_aMenuItemCommand == aSlotSpecialWindowMenu || aMenuCommand == aSpecialWindowCommand ) - UpdateSpecialWindowMenu( pMenu ); + MenuManager::UpdateSpecialWindowMenu( pMenu,getServiceFactory(),m_aLock ); // Check if some modes have changed so we have to update our menu images sal_Bool bIsHiContrast = rSettings.GetMenuColor().IsDark(); @@ -1106,48 +883,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) m_bShowMenuImages = bShowMenuImages; m_bRetrieveImages = sal_False; m_nSymbolsStyle = nSymbolsStyle; - AddonsOptions aAddonOptions; - - for ( USHORT nPos = 0; nPos < pMenu->GetItemCount(); nPos++ ) - { - USHORT nId = pMenu->GetItemId( nPos ); - if ( pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR ) - { - if ( bShowMenuImages ) - { - sal_Bool bImageSet = sal_False; - ::rtl::OUString aImageId; - - ::framework::MenuConfiguration::Attributes* pMenuAttributes = - (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nId ); - - if ( pMenuAttributes ) - aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes - - if ( aImageId.getLength() > 0 ) - { - Image aImage = GetImageFromURL( m_xFrame, aImageId, FALSE, bIsHiContrast ); - if ( !!aImage ) - { - bImageSet = sal_True; - pMenu->SetItemImage( nId, aImage ); - } - } - - if ( !bImageSet ) - { - rtl::OUString aMenuItemCommand = pMenu->GetItemCommand( nId ); - Image aImage = GetImageFromURL( m_xFrame, aMenuItemCommand, FALSE, bIsHiContrast ); - if ( !aImage ) - aImage = aAddonOptions.GetImageFromURL( aMenuItemCommand, FALSE, bIsHiContrast ); - - pMenu->SetItemImage( nId, aImage ); - } - } - else - pMenu->SetItemImage( nId, Image() ); - } - } + MenuManager::FillMenuImages(m_xFrame,pMenu,bIsHiContrast,bShowMenuImages); } // Try to map commands to labels @@ -1185,10 +921,6 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) URL aTargetURL; - // #110897# - // Reference< XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - Reference< XURLTransformer > xTrans( getServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - // Use provided dispatch provider => fallback to frame as dispatch provider Reference< XDispatchProvider > xDispatchProvider; if ( m_xDispatchProvider.is() ) @@ -1227,7 +959,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) aTargetURL.Complete = aItemCommand; - xTrans->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); if ( bHasDisabledEntries ) { @@ -1285,7 +1017,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) try { aTargetURL.Complete = pMenuItemHandler->aMenuItemURL; - xTrans->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); pMenuItemHandler->xMenuItemDispatch->addStatusListener( static_cast< XStatusListener* >( this ), aTargetURL ); @@ -1309,6 +1041,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) IMPL_LINK( MenuBarManager, Deactivate, Menu *, pMenu ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::Deactivate" ); if ( pMenu == m_pVCLMenu ) { m_bActive = sal_False; @@ -1344,6 +1077,7 @@ IMPL_LINK( MenuBarManager, AsyncSettingsHdl, Timer*,) IMPL_LINK( MenuBarManager, Select, Menu *, pMenu ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::Select" ); URL aTargetURL; Sequence<PropertyValue> aArgs; Reference< XDispatch > xDispatch; @@ -1363,7 +1097,7 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu ) // #110897# // Reference< XFramesSupplier > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( DESKTOP_SERVICE ), UNO_QUERY ); - Reference< XFramesSupplier > xDesktop( getServiceFactory()->createInstance( DESKTOP_SERVICE ), UNO_QUERY ); + Reference< XFramesSupplier > xDesktop( getServiceFactory()->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY ); if ( xDesktop.is() ) { @@ -1372,9 +1106,8 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu ) sal_Int32 nCount = xList->getCount(); for ( sal_Int32 i=0; i<nCount; ++i ) { - Any aItem = xList->getByIndex(i); Reference< XFrame > xFrame; - aItem >>= xFrame; + xList->getByIndex(i) >>= xFrame; if ( xFrame.is() && nTaskId == nCurItemId ) { Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); @@ -1392,21 +1125,15 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu ) MenuItemHandler* pMenuItemHandler = GetMenuItemHandler( nCurItemId ); if ( pMenuItemHandler && pMenuItemHandler->xMenuItemDispatch.is() ) { - // #110897# - // Reference< XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - Reference< XURLTransformer > xTrans( getServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - aTargetURL.Complete = pMenuItemHandler->aMenuItemURL; - xTrans->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); if ( m_bIsBookmarkMenu ) { // bookmark menu item selected - Any a; aArgs.realloc( 1 ); aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" )); - a <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SFX_REFERER_USER )); - aArgs[0].Value = a; + aArgs[0].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SFX_REFERER_USER )); } xDispatch = pMenuItemHandler->xMenuItemDispatch; @@ -1435,6 +1162,7 @@ IMPL_LINK( MenuBarManager, Highlight, Menu *, EMPTYARG ) sal_Bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, const Reference< XURLTransformer >& rTransformer ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::MustBeHidden" ); if ( pPopupMenu ) { URL aTargetURL; @@ -1475,77 +1203,16 @@ sal_Bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, const Reference< X return sal_True; } - String MenuBarManager::RetrieveLabelFromCommand( const String& aCmdURL ) { - String aLabel; - - // Retrieve popup menu labels - if ( !m_xUICommandLabels.is() ) - { - try - { - if ( !m_bModuleIdentified ) - { - m_bModuleIdentified = sal_True; - Reference< XModuleManager > xModuleManager; - xModuleManager = Reference< XModuleManager >( getServiceFactory()->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); - - try - { - m_aModuleIdentifier = xModuleManager->identify( m_xFrame ); - } - catch( Exception& ) - { - } - } - - Reference< XNameAccess > xNameAccess( getServiceFactory()->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); - if ( xNameAccess.is() ) - { - Any a = xNameAccess->getByName( m_aModuleIdentifier ); - Reference< XNameAccess > xUICommands; - a >>= m_xUICommandLabels; - } - } - catch ( Exception& ) - { - } - } + return framework::RetrieveLabelFromCommand(aCmdURL,mxServiceFactory,m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Label"); +} - if ( m_xUICommandLabels.is() ) - { - try - { - if ( aCmdURL.Len() > 0 ) - { - rtl::OUString aStr; - Sequence< PropertyValue > aPropSeq; - Any a( m_xUICommandLabels->getByName( aCmdURL )); - if ( a >>= aPropSeq ) - { - for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name.equalsAscii( "Label" )) - { - aPropSeq[i].Value >>= aStr; - break; - } - } - } - aLabel = aStr; - } - } - catch ( com::sun::star::uno::Exception& ) - { - } - } - return aLabel; -} sal_Bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHandler ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::CreatePopupMenuController" ); rtl::OUString aItemCommand( pMenuItemHandler->aMenuItemURL ); // Try instanciate a popup menu controller. It is stored in the menu item handler. @@ -1589,6 +1256,7 @@ sal_Bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHa void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rFrame, const Reference< XDispatchProvider >& rDispatchProvider, const rtl::OUString& rModuleIdentifier, sal_Bool bDelete, sal_Bool bDeleteChildren ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::FillMenuManager" ); m_xFrame = rFrame; m_bActive = sal_False; m_bDeleteMenu = bDelete; @@ -1636,17 +1304,11 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF String aEmpty; sal_Bool bAccessibilityEnabled( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() ); USHORT nItemCount = pMenu->GetItemCount(); + ::rtl::OUString aItemCommand; + m_aMenuItemHandlerVector.reserve(nItemCount); for ( USHORT i = 0; i < nItemCount; i++ ) { - USHORT nItemId = pMenu->GetItemId( i ); - - ::rtl::OUString aItemCommand = pMenu->GetItemCommand( nItemId ); - if ( !aItemCommand.getLength() ) - { - aItemCommand = aSlotString; - aItemCommand += ::rtl::OUString::valueOf( (sal_Int32)nItemId ); - pMenu->SetItemCommand( nItemId, aItemCommand ); - } + USHORT nItemId = FillItemCommand(aItemCommand,pMenu, i ); // Set module identifier when provided from outside if ( rModuleIdentifier.getLength() > 0 ) @@ -1676,8 +1338,9 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF } if ( m_xPopupMenuControllerRegistration.is() && - m_xPopupMenuControllerRegistration->hasController( aItemCommand, rtl::OUString() ) && - pPopup->GetItemCount() == 0 ) + pPopup->GetItemCount() == 0 && + m_xPopupMenuControllerRegistration->hasController( aItemCommand, rtl::OUString() ) + ) { // Check if we have to create a popup menu for a uno based popup menu controller. // We have to set an empty popup menu into our menu structure so the controller also @@ -1703,20 +1366,8 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF { // A special addon popup menu, must be created with a different ctor // #110897# - MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), rFrame, (AddonPopupMenu *)pPopup, bDeleteChildren, bDeleteChildren ); - - Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); - rFrame->addFrameActionListener( Reference< XFrameActionListener >( xSubMenuManager, UNO_QUERY )); - - // store menu item command as we later have to know which menu is active (see Activate handler) - pSubMenuManager->m_aMenuItemCommand = aItemCommand; - - MenuItemHandler* pMenuItemHandler = new MenuItemHandler( - nItemId, - xSubMenuManager, - xDispatch ); - pMenuItemHandler->aMenuItemURL = aItemCommand; - m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); + MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), m_xFrame, m_xURLTransformer,(AddonPopupMenu *)pPopup, bDeleteChildren, bDeleteChildren ); + AddMenu(pSubMenuManager,aItemCommand,nItemId); } else { @@ -1750,6 +1401,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF pPopup->SetPopupMenu( ITEMID_ADDONLIST, pSubMenu ); // Set item command for popup menu to enable it for GetImageFromURL + const ::rtl::OUString aSlotString( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); ::rtl::OUString aNewItemCommand( aSlotString ); aNewItemCommand += ::rtl::OUString::valueOf( (sal_Int32)ITEMID_ADDONLIST ); pPopup->SetItemCommand( ITEMID_ADDONLIST, aNewItemCommand ); @@ -1765,17 +1417,9 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF AddonMenu* pSubMenu = dynamic_cast< AddonMenu* >( pPopup ); if ( pSubMenu ) { - MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), rFrame, pSubMenu, sal_True, sal_False ); - - Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); - rFrame->addFrameActionListener( Reference< XFrameActionListener >( xSubMenuManager, UNO_QUERY )); - - MenuItemHandler* pMenuItemHandler = new MenuItemHandler( - nItemId, - xSubMenuManager, - xDispatch ); - pMenuItemHandler->aMenuItemURL = aItemCommand; - m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); + MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), m_xFrame, m_xURLTransformer,pSubMenu, sal_True, sal_False ); + AddMenu(pSubMenuManager,aItemCommand,nItemId); + pSubMenuManager->m_aMenuItemCommand = ::rtl::OUString(); // Set image for the addon popup menu item if ( m_bShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST )) @@ -1790,19 +1434,8 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF else { // #110897# MenuBarManager* pSubMenuManager = new MenuBarManager( rFrame, pPopupMenu, bDeleteChildren, bDeleteChildren ); - MenuBarManager* pSubMenuMgr = new MenuBarManager( getServiceFactory(), rFrame, rDispatchProvider, aModuleIdentifier, pPopup, bDeleteChildren, bDeleteChildren ); - Reference< XStatusListener > xSubMenuMgr( static_cast< OWeakObject *>( pSubMenuMgr ), UNO_QUERY ); - rFrame->addFrameActionListener( Reference< XFrameActionListener >( xSubMenuMgr, UNO_QUERY )); - - // store menu item command as we later have to know which menu is active (see Activate handler) - pSubMenuMgr->m_aMenuItemCommand = aItemCommand; - - MenuItemHandler* pMenuItemHdl = new MenuItemHandler( - nItemId, - xSubMenuMgr, - xDispatch ); - pMenuItemHdl->aMenuItemURL = aItemCommand; - m_aMenuItemHandlerVector.push_back( pMenuItemHdl ); + MenuBarManager* pSubMenuMgr = new MenuBarManager( getServiceFactory(), rFrame, m_xURLTransformer,rDispatchProvider, aModuleIdentifier, pPopup, bDeleteChildren, bDeleteChildren ); + AddMenu(pSubMenuMgr,aItemCommand,nItemId); } } } @@ -1854,10 +1487,9 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF pMenu->SetPopupMenu( pItemHandler->nItemId, pPopupMenu ); pItemHandler->xPopupMenu = Reference< com::sun::star::awt::XPopupMenu >( (OWeakObject *)pVCLXPopupMenu, UNO_QUERY ); - if ( bAccessibilityEnabled ) + if ( bAccessibilityEnabled && CreatePopupMenuController( pItemHandler ) ) { - if ( CreatePopupMenuController( pItemHandler )) - pItemHandler->xPopupMenuController->updatePopupMenu(); + pItemHandler->xPopupMenuController->updatePopupMenu(); } lcl_CheckForChildren(pMenu, pItemHandler->nItemId); @@ -1887,10 +1519,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF } } - m_pVCLMenu->SetHighlightHdl( LINK( this, MenuBarManager, Highlight )); - m_pVCLMenu->SetActivateHdl( LINK( this, MenuBarManager, Activate )); - m_pVCLMenu->SetDeactivateHdl( LINK( this, MenuBarManager, Deactivate )); - m_pVCLMenu->SetSelectHdl( LINK( this, MenuBarManager, Select )); + SetHdl(); } void MenuBarManager::impl_RetrieveShortcutsFromConfiguration( @@ -1898,6 +1527,7 @@ void MenuBarManager::impl_RetrieveShortcutsFromConfiguration( const Sequence< rtl::OUString >& rCommands, std::vector< MenuItemHandler* >& aMenuShortCuts ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::impl_RetrieveShortcutsFromConfiguration" ); if ( rAccelCfg.is() ) { try @@ -1918,6 +1548,7 @@ void MenuBarManager::impl_RetrieveShortcutsFromConfiguration( void MenuBarManager::RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuShortCuts ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::RetrieveShortcuts" ); if ( !m_bModuleIdentified ) { m_bModuleIdentified = sal_True; @@ -2000,7 +1631,8 @@ void MenuBarManager::RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuSh KeyCode aEmptyKeyCode; Sequence< rtl::OUString > aSeq( aMenuShortCuts.size() ); - for ( sal_uInt32 i = 0; i < aMenuShortCuts.size(); i++ ) + const sal_uInt32 nCount = aMenuShortCuts.size(); + for ( sal_uInt32 i = 0; i < nCount; ++i ) { aSeq[i] = aMenuShortCuts[i]->aMenuItemURL; aMenuShortCuts[i]->aKeyCode = aEmptyKeyCode; @@ -2017,6 +1649,7 @@ void MenuBarManager::RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuSh void MenuBarManager::RetrieveImageManagers() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::RetrieveImageManagers" ); if ( !m_xDocImageManager.is() ) { Reference< XController > xController = m_xFrame->getController(); @@ -2041,7 +1674,7 @@ void MenuBarManager::RetrieveImageManagers() Reference< XModuleManager > xModuleManager; if ( m_aModuleIdentifier.getLength() == 0 ) - xModuleManager = Reference< XModuleManager >( getServiceFactory()->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); + xModuleManager.set( getServiceFactory()->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); try { @@ -2058,7 +1691,7 @@ void MenuBarManager::RetrieveImageManagers() SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ), UNO_QUERY ); Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier ); - m_xModuleImageManager = Reference< XImageManager >( xUICfgMgr->getImageManager(), UNO_QUERY ); + m_xModuleImageManager.set( xUICfgMgr->getImageManager(), UNO_QUERY ); m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); } @@ -2071,6 +1704,7 @@ void MenuBarManager::FillMenuWithConfiguration( const Reference< XIndexAccess >& rItemContainer, const Reference< XURLTransformer >& rTransformer ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::FillMenuWithConfiguration" ); Reference< XDispatchProvider > xEmptyDispatchProvider; MenuBarManager::FillMenu( nId, pMenu, rModuleIdentifier, rItemContainer, xEmptyDispatchProvider ); @@ -2106,6 +1740,7 @@ void MenuBarManager::FillMenu( const Reference< XIndexAccess >& rItemContainer, const Reference< XDispatchProvider >& rDispatchProvider ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::FillMenu" ); // Fill menu bar with container contents for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ ) { @@ -2187,7 +1822,7 @@ void MenuBarManager::FillMenu( } } } - catch ( ::com::sun::star::lang::IndexOutOfBoundsException& ) + catch ( IndexOutOfBoundsException& ) { break; } @@ -2199,6 +1834,7 @@ void MenuBarManager::MergeAddonMenus( const MergeMenuInstructionContainer& aMergeInstructionContainer, const ::rtl::OUString& rModuleIdentifier ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::MergeAddonMenus" ); // set start value for the item ID for the new addon menu items sal_uInt16 nItemId = ADDONMENU_MERGE_ITEMID_START; @@ -2299,10 +1935,7 @@ void MenuBarManager::SetItemContainer( const Reference< XIndexAccess >& rItemCon USHORT nId = 1; // Fill menu bar with container contents - Reference< XURLTransformer > xTrans( getServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - FillMenuWithConfiguration( nId, (Menu *)m_pVCLMenu, m_aModuleIdentifier, rItemContainer, xTrans ); + FillMenuWithConfiguration( nId, (Menu *)m_pVCLMenu, m_aModuleIdentifier, rItemContainer, m_xURLTransformer ); // Refill menu manager again Reference< XDispatchProvider > xDispatchProvider; @@ -2315,6 +1948,7 @@ void MenuBarManager::SetItemContainer( const Reference< XIndexAccess >& rItemCon void MenuBarManager::GetPopupController( PopupControllerCache& rPopupController ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::GetPopupController" ); String aPopupScheme = String::CreateFromAscii( "vnd.sun.star.popup:" ); vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); @@ -2360,10 +1994,138 @@ void MenuBarManager::GetPopupController( PopupControllerCache& rPopupController } // #110897# -const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& MenuBarManager::getServiceFactory() +const Reference< XMultiServiceFactory >& MenuBarManager::getServiceFactory() { // #110897# return mxServiceFactory; } +void MenuBarManager::AddMenu(MenuBarManager* pSubMenuManager,const ::rtl::OUString& _sItemCommand,USHORT _nItemId) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::AddMenu" ); + Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); + m_xFrame->addFrameActionListener( Reference< XFrameActionListener >( xSubMenuManager, UNO_QUERY )); + + // store menu item command as we later have to know which menu is active (see Activate handler) + pSubMenuManager->m_aMenuItemCommand = _sItemCommand; + Reference< XDispatch > xDispatch; + MenuItemHandler* pMenuItemHandler = new MenuItemHandler( + _nItemId, + xSubMenuManager, + xDispatch ); + pMenuItemHandler->aMenuItemURL = _sItemCommand; + m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); +} + +USHORT MenuBarManager::FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,USHORT _nIndex) const +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::FillItemCommand" ); + USHORT nItemId = _pMenu->GetItemId( _nIndex ); + + _rItemCommand = _pMenu->GetItemCommand( nItemId ); + if ( !_rItemCommand.getLength() ) + { + const static ::rtl::OUString aSlotString( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); + _rItemCommand = aSlotString; + _rItemCommand += ::rtl::OUString::valueOf( (sal_Int32)nItemId ); + _pMenu->SetItemCommand( nItemId, _rItemCommand ); + } + return nItemId; +} +void MenuBarManager::Init(const Reference< XFrame >& rFrame,AddonMenu* pAddonMenu,sal_Bool bDelete,sal_Bool bDeleteChildren,bool _bHandlePopUp) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "MenuBarManager::Init" ); + m_bActive = sal_False; + m_bDeleteMenu = bDelete; + m_bDeleteChildren = bDeleteChildren; + m_pVCLMenu = pAddonMenu; + m_xFrame = rFrame; + m_bInitialized = sal_False; + m_bIsBookmarkMenu = sal_True; + + rtl::OUString aModuleIdentifier; + m_xPopupMenuControllerRegistration = Reference< ::com::sun::star::frame::XUIControllerRegistration >( + getServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuControllerFactory" ))), + UNO_QUERY ); + + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + m_bWasHiContrast = rSettings.GetMenuColor().IsDark(); + + Reference< XStatusListener > xStatusListener; + Reference< XDispatch > xDispatch; + USHORT nItemCount = pAddonMenu->GetItemCount(); + ::rtl::OUString aItemCommand; + m_aMenuItemHandlerVector.reserve(nItemCount); + for ( USHORT i = 0; i < nItemCount; i++ ) + { + USHORT nItemId = FillItemCommand(aItemCommand,pAddonMenu, i ); + + PopupMenu* pPopupMenu = pAddonMenu->GetPopupMenu( nItemId ); + if ( pPopupMenu ) + { + // #110897# + Reference< XDispatchProvider > xDispatchProvider; + MenuBarManager* pSubMenuManager = new MenuBarManager( getServiceFactory(), rFrame, m_xURLTransformer,xDispatchProvider, aModuleIdentifier, pPopupMenu, _bHandlePopUp ? sal_False : bDeleteChildren, _bHandlePopUp ? sal_False : bDeleteChildren ); + + Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); + + // store menu item command as we later have to know which menu is active (see Acivate handler) + pSubMenuManager->m_aMenuItemCommand = aItemCommand; + + MenuItemHandler* pMenuItemHandler = new MenuItemHandler( + nItemId, + xSubMenuManager, + xDispatch ); + m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); + } + else + { + if ( pAddonMenu->GetItemType( i ) != MENUITEM_SEPARATOR ) + { + MenuConfiguration::Attributes* pAddonAttributes = (MenuConfiguration::Attributes *)(pAddonMenu->GetUserValue( nItemId )); + MenuItemHandler* pMenuItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch ); + + if ( pAddonAttributes ) + { + // read additional attributes from attributes struct and AddonMenu implementation will delete all attributes itself!! + pMenuItemHandler->aTargetFrame = pAddonAttributes->aTargetFrame; + } + + pMenuItemHandler->aMenuItemURL = aItemCommand; + if ( _bHandlePopUp ) + { + // Check if we have to create a popup menu for a uno based popup menu controller. + // We have to set an empty popup menu into our menu structure so the controller also + // works with inplace OLE. + if ( m_xPopupMenuControllerRegistration.is() && + m_xPopupMenuControllerRegistration->hasController( aItemCommand, rtl::OUString() )) + { + VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu; + PopupMenu* pCtlPopupMenu = (PopupMenu *)pVCLXPopupMenu->GetMenu(); + pAddonMenu->SetPopupMenu( pMenuItemHandler->nItemId, pCtlPopupMenu ); + pMenuItemHandler->xPopupMenu = Reference< com::sun::star::awt::XPopupMenu >( (OWeakObject *)pVCLXPopupMenu, UNO_QUERY ); + + } + } + m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); + } + } + } + + SetHdl(); +} + +void MenuBarManager::SetHdl() +{ + m_pVCLMenu->SetHighlightHdl( LINK( this, MenuBarManager, Highlight )); + m_pVCLMenu->SetActivateHdl( LINK( this, MenuBarManager, Activate )); + m_pVCLMenu->SetDeactivateHdl( LINK( this, MenuBarManager, Deactivate )); + m_pVCLMenu->SetSelectHdl( LINK( this, MenuBarManager, Select )); + + if ( !m_xURLTransformer.is() && mxServiceFactory.is() ) + m_xURLTransformer.set( mxServiceFactory->createInstance( + SERVICENAME_URLTRANSFORMER), + UNO_QUERY ); +} + } diff --git a/framework/source/uielement/menubarmerger.cxx b/framework/source/uielement/menubarmerger.cxx index 1f0dc704e004..647bdf3f4f0c 100644 --- a/framework/source/uielement/menubarmerger.cxx +++ b/framework/source/uielement/menubarmerger.cxx @@ -190,7 +190,7 @@ bool MenuBarMerger::CreateSubMenu( { pSubMenu->InsertItem( nItemId, rMenuItem.aTitle, 0, MENU_APPEND ); pSubMenu->SetItemCommand( nItemId, rMenuItem.aURL ); - if ( rMenuItem.aSubMenu.size() > 0 ) + if ( !rMenuItem.aSubMenu.empty() ) { PopupMenu* pPopupMenu = new PopupMenu(); pSubMenu->SetPopupMenu( nItemId, pPopupMenu ); @@ -231,7 +231,7 @@ bool MenuBarMerger::MergeMenuItems( { pMenu->InsertItem( nItemId, rMenuItem.aTitle, 0, nPos+nModIndex+nIndex ); pMenu->SetItemCommand( nItemId, rMenuItem.aURL ); - if ( rMenuItem.aSubMenu.size() > 0 ) + if ( !rMenuItem.aSubMenu.empty() ) { PopupMenu* pSubMenu = new PopupMenu(); pMenu->SetPopupMenu( nItemId, pSubMenu ); @@ -342,7 +342,8 @@ bool MenuBarMerger::ProcessFallbackOperation( { if ( nLevel == nSize-1 ) { - for ( sal_uInt32 i = 0; i < rAddonMenuItems.size(); i++ ) + const sal_uInt32 nCount = rAddonMenuItems.size(); + for ( sal_uInt32 i = 0; i < nCount; ++i ) { const AddonMenuItem& rMenuItem = rAddonMenuItems[i]; if ( IsCorrectContext( rMenuItem.aContext, rModuleIdentifier )) @@ -429,6 +430,7 @@ void MenuBarMerger::GetSubMenu( rSubMenu.clear(); const sal_Int32 nCount = rSubMenuEntries.getLength(); + rSubMenu.reserve(rSubMenu.size() + nCount); for ( sal_Int32 i = 0; i < nCount; i++ ) { const uno::Sequence< beans::PropertyValue >& rMenuEntry = rSubMenuEntries[ i ]; diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx index 434c1cfc4be3..32e7a757d2cd 100644 --- a/framework/source/uielement/menubarwrapper.cxx +++ b/framework/source/uielement/menubarwrapper.cxx @@ -37,8 +37,6 @@ #include <uielement/menubarwrapper.hxx> #include <threadhelp/resetableguard.hxx> #include <helper/actiontriggerhelper.hxx> -#include <uielement/constitemcontainer.hxx> -#include <uielement/rootitemcontainer.hxx> #include <services.h> //_________________________________________________________________________________________________________________ @@ -110,9 +108,8 @@ DEFINE_XTYPEPROVIDER_11 ( MenuBarWrapper , MenuBarWrapper::MenuBarWrapper( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) -: UIConfigElementWrapperBase( UIElementType::MENUBAR ), - m_bRefreshPopupControllerCache( sal_True ), - mxServiceFactory( xServiceManager ) +: UIConfigElementWrapperBase( UIElementType::MENUBAR,xServiceManager ), + m_bRefreshPopupControllerCache( sal_True ) { } @@ -120,13 +117,6 @@ MenuBarWrapper::~MenuBarWrapper() { } -// #110897# -const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& MenuBarWrapper::getServiceFactory() -{ - // #110897# - return mxServiceFactory; -} - void SAL_CALL MenuBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeException) { Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); @@ -173,7 +163,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th Reference< XModuleManager > xModuleManager; xModuleManager = Reference< XModuleManager >( - getServiceFactory()->createInstance( + m_xServiceFactory->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); try @@ -184,15 +174,16 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th { } + Reference< XURLTransformer > xTrans; try { + xTrans.set( m_xServiceFactory->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False ); if ( m_xConfigData.is() ) { // Fill menubar with container contents - Reference< XURLTransformer > xTrans( getServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); USHORT nId = 1; MenuBarManager::FillMenuWithConfiguration( nId, pVCLMenuBar, aModuleIdentifier, m_xConfigData, xTrans ); } @@ -221,8 +212,9 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th Reference< XDispatchProvider > xDispatchProvider; // #110897# - MenuBarManager* pMenuBarManager = new MenuBarManager( getServiceFactory(), + MenuBarManager* pMenuBarManager = new MenuBarManager( m_xServiceFactory, xFrame, + xTrans, xDispatchProvider, aModuleIdentifier, pVCLMenuBar, @@ -270,61 +262,15 @@ void SAL_CALL MenuBarWrapper::updateSettings() throw ( RuntimeException ) } } } - -void SAL_CALL MenuBarWrapper::setSettings( const Reference< XIndexAccess >& xSettings ) throw ( RuntimeException ) +void MenuBarWrapper::impl_fillNewData() { - ResetableGuard aLock( m_aLock ); + // Transient menubar => Fill menubar with new data + MenuBarManager* pMenuBarManager = static_cast< MenuBarManager *>( m_xMenuBarManager.get() ); - if ( m_bDisposed ) - throw DisposedException(); - - if ( xSettings.is() ) - { - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY ); - if ( xReplace.is() ) - m_xConfigData = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY ); - else - m_xConfigData = xSettings; - - if ( m_xConfigSource.is() && m_bPersistent ) - { - ::rtl::OUString aResourceURL( m_aResourceURL ); - Reference< XUIConfigurationManager > xUICfgMgr( m_xConfigSource ); - - aLock.unlock(); - - try - { - xUICfgMgr->replaceSettings( aResourceURL, m_xConfigData ); - } - catch( NoSuchElementException& ) - { - } - } - else if ( !m_bPersistent ) - { - // Transient menubar => Fill menubar with new data - MenuBarManager* pMenuBarManager = static_cast< MenuBarManager *>( m_xMenuBarManager.get() ); - - if ( pMenuBarManager ) - pMenuBarManager->SetItemContainer( m_xConfigData ); - } - } + if ( pMenuBarManager ) + pMenuBarManager->SetItemContainer( m_xConfigData ); } -Reference< XIndexAccess > SAL_CALL MenuBarWrapper::getSettings( sal_Bool bWriteable ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( bWriteable ) - return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY ); - else - return m_xConfigData; -} void MenuBarWrapper::fillPopupControllerCache() { @@ -333,7 +279,7 @@ void MenuBarWrapper::fillPopupControllerCache() MenuBarManager* pMenuBarManager = static_cast< MenuBarManager *>( m_xMenuBarManager.get() ); if ( pMenuBarManager ) pMenuBarManager->GetPopupController( m_aPopupControllerCache ); - if ( m_aPopupControllerCache.size() > 0 ) + if ( !m_aPopupControllerCache.empty() ) m_bRefreshPopupControllerCache = sal_False; } } @@ -354,7 +300,7 @@ throw (::com::sun::star::uno::RuntimeException) throw DisposedException(); fillPopupControllerCache(); - return ( m_aPopupControllerCache.size() > 0 ); + return ( !m_aPopupControllerCache.empty() ); } // XNameAccess @@ -374,12 +320,9 @@ throw ( container::NoSuchElementException, PopupControllerCache::const_iterator pIter = m_aPopupControllerCache.find( aName ); if ( pIter != m_aPopupControllerCache.end() ) { - Any a; uno::Reference< frame::XDispatchProvider > xDispatchProvider; xDispatchProvider = pIter->second.m_xDispatchProvider; - - a = uno::makeAny( xDispatchProvider ); - return a; + return uno::makeAny( xDispatchProvider ); } else throw container::NoSuchElementException(); diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 5162f812ef58..fea156dceb9d 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -43,7 +43,7 @@ #include <classes/fwkresid.hxx> #include <classes/bmkmenu.hxx> #include <helper/imageproducer.hxx> -#include <classes/menuconfiguration.hxx> +#include <xml/menuconfiguration.hxx> //_________________________________________________________________________________________________________________ // interface includes @@ -280,7 +280,8 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu ) aMenuShortCuts.push_back( aEmptyKeyCode ); } - for ( sal_uInt32 i = 0; i < aCmds.size(); i++ ) + const sal_uInt32 nCount = aCmds.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) aSeq[i] = aCmds[i]; if ( m_xGlobalAcceleratorManager.is() ) @@ -290,7 +291,8 @@ void NewMenuController::setAccelerators( PopupMenu* pPopupMenu ) if ( m_xDocAcceleratorManager.is() ) retrieveShortcutsFromConfiguration( xGlobalAccelCfg, aSeq, aMenuShortCuts ); - for ( sal_uInt32 i = 0; i < aIds.size(); i++ ) + const sal_uInt32 nCount2 = aIds.size(); + for ( sal_uInt32 i = 0; i < nCount2; i++ ) pPopupMenu->SetAccelKey( USHORT( aIds[i] ), aMenuShortCuts[i] ); // Special handling for "New" menu short-cut should be set at the @@ -335,10 +337,6 @@ NewMenuController::NewMenuController( const ::com::sun::star::uno::Reference< :: m_bAcceleratorCfg( sal_False ), m_aTargetFrame( RTL_CONSTASCII_USTRINGPARAM( "_default" )) { - m_xURLTransformer = Reference< XURLTransformer >( - xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); } NewMenuController::~NewMenuController() @@ -420,10 +418,6 @@ void SAL_CALL NewMenuController::statusChanged( const FeatureStateEvent& ) throw } // XMenuListener -void SAL_CALL NewMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - void SAL_CALL NewMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) { Reference< css::awt::XPopupMenu > xPopupMenu; @@ -510,118 +504,66 @@ void SAL_CALL NewMenuController::activate( const css::awt::MenuEvent& ) throw (R } } -void SAL_CALL NewMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - // XPopupMenuController -void SAL_CALL NewMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) +void NewMenuController::impl_setPopupMenu() { - ResetableGuard aLock( m_aLock ); - if ( m_bDisposed ) - throw DisposedException(); + if ( m_xPopupMenu.is() ) + fillPopupMenu( m_xPopupMenu ); - if ( m_xFrame.is() && !m_xPopupMenu.is() ) + // Identify module that we are attach to. It's our context that we need to know. + Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),UNO_QUERY ); + if ( xModuleManager.is() ) { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - m_xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - if ( m_xPopupMenu.is() ) - fillPopupMenu( m_xPopupMenu ); - - // Identify module that we are attach to. It's our context that we need to know. - Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),UNO_QUERY ); - if ( xModuleManager.is() ) + try { - try + m_aModuleIdentifier = xModuleManager->identify( m_xFrame ); + m_bModuleIdentified = sal_True; + + Reference< XNameAccess > xNameAccess( xModuleManager, UNO_QUERY ); + if (( m_aModuleIdentifier.getLength() > 0 ) && xNameAccess.is() ) { - m_aModuleIdentifier = xModuleManager->identify( m_xFrame ); - m_bModuleIdentified = sal_True; + Sequence< PropertyValue > aSeq; - Reference< XNameAccess > xNameAccess( xModuleManager, UNO_QUERY ); - if (( m_aModuleIdentifier.getLength() > 0 ) && xNameAccess.is() ) + if ( xNameAccess->getByName( m_aModuleIdentifier ) >>= aSeq ) { - Sequence< PropertyValue > aSeq; - - Any a = xNameAccess->getByName( m_aModuleIdentifier ); - if ( a >>= aSeq ) + for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ ) { - for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ ) + if ( aSeq[y].Name.equalsAscii("ooSetupFactoryEmptyDocumentURL") ) { - if ( aSeq[y].Name.equalsAscii("ooSetupFactoryEmptyDocumentURL") ) - { - aSeq[y].Value >>= m_aEmptyDocURL; - break; - } + aSeq[y].Value >>= m_aEmptyDocURL; + break; } } } } - catch ( RuntimeException& e ) - { - throw e; - } - catch ( Exception& ) - { - } + } + catch ( RuntimeException& e ) + { + throw e; + } + catch ( Exception& ) + { } } } -void SAL_CALL NewMenuController::updatePopupMenu() throw (RuntimeException) -{ - ResetableGuard aLock( m_aLock ); - if ( m_bDisposed ) - throw DisposedException(); -} - // XInitialization void SAL_CALL NewMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - const rtl::OUString aFrameName( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - const rtl::OUString aCommandURLName( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); - ResetableGuard aLock( m_aLock ); sal_Bool bInitalized( m_bInitialized ); if ( !bInitalized ) { - PropertyValue aPropValue; - rtl::OUString aCommandURL; - Reference< XFrame > xFrame; + PopupMenuControllerBase::initialize( aArguments ); - for ( int i = 0; i < aArguments.getLength(); i++ ) + if ( m_bInitialized ) { - if ( aArguments[i] >>= aPropValue ) - { - if ( aPropValue.Name.equalsAscii( "Frame" )) - aPropValue.Value >>= xFrame; - else if ( aPropValue.Name.equalsAscii( "CommandURL" )) - aPropValue.Value >>= aCommandURL; - } - } - - if ( xFrame.is() && aCommandURL.getLength() ) - { - m_xFrame = xFrame; - m_aCommandURL = aCommandURL; - m_bInitialized = sal_True; - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); m_bShowImages = rSettings.GetUseImagesInMenus(); - m_bHiContrast = rSettings.GetMenuColor().IsDark(); + m_bHiContrast = rSettings.GetMenuColor().IsDark(); m_bNewMenu = m_aCommandURL.equalsAscii( ".uno:AddDirect" ); } diff --git a/framework/source/uielement/objectmenucontroller.cxx b/framework/source/uielement/objectmenucontroller.cxx index 2009c16a1f64..9f7d3bb64f5e 100644 --- a/framework/source/uielement/objectmenucontroller.cxx +++ b/framework/source/uielement/objectmenucontroller.cxx @@ -44,7 +44,6 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #ifndef _COM_SUN_STAR_EMBED_VERBDATTRIBUTES_HPP_ @@ -156,90 +155,12 @@ void SAL_CALL ObjectMenuController::statusChanged( const FeatureStateEvent& Even } // XMenuListener -void SAL_CALL ObjectMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) +void ObjectMenuController::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aTargetURL) { -} - -void SAL_CALL ObjectMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() && xDispatch.is() ) - { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs; - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - xURLTransformer->parseStrict( aTargetURL ); - if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("ObjectMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); - xDispatch->dispatch( aTargetURL, aArgs ); - } - } -} - -void SAL_CALL ObjectMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL ObjectMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -// XPopupMenuController -void SAL_CALL ObjectMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - updatePopupMenu(); - } -} - -// XInitialization -void SAL_CALL ObjectMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); + Sequence<PropertyValue> aArgs; + if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# + UiEventLogHelper(::rtl::OUString::createFromAscii("ObjectMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); + _xDispatch->dispatch( aTargetURL, aArgs ); } } diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index 3d92f1e10615..1ca5bf409e6d 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -49,9 +49,8 @@ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/awt/MenuItemStyle.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/XStringWidth.hpp> - +#include <com/sun/star/lang/DisposedException.hpp> //_________________________________________________________________________________________________________________ // includes of other projects //_________________________________________________________________________________________________________________ @@ -166,11 +165,12 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > } } - if ( m_aRecentFilesItems.size() > 0 ) + if ( !m_aRecentFilesItems.empty() ) { URL aTargetURL; - for ( sal_uInt32 i = 0; i < m_aRecentFilesItems.size(); i++ ) + const sal_uInt32 nCount = m_aRecentFilesItems.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { char menuShortCut[5] = "~n: "; @@ -260,14 +260,10 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) if (( nIndex >= 0 ) && ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() ))) { - Reference< XURLTransformer > xURLTransformer( xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - const RecentFile& rRecentFile = m_aRecentFilesItems[ nIndex ]; aTargetURL.Complete = rRecentFile.aURL; - xURLTransformer->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); aArgsList.realloc( NUM_OF_PICKLIST_ARGS ); aArgsList[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" )); @@ -287,14 +283,14 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) aFilterOptions = aFilter.copy( nPos+1 ); aArgsList[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterOptions" )); - aArgsList[2].Value = makeAny( aFilterOptions ); + aArgsList[2].Value <<= aFilterOptions; aFilter = aFilter.copy( 0, nPos-1 ); aArgsList.realloc( ++NUM_OF_PICKLIST_ARGS ); } aArgsList[NUM_OF_PICKLIST_ARGS-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" )); - aArgsList[NUM_OF_PICKLIST_ARGS-1].Value = makeAny( aFilter ); + aArgsList[NUM_OF_PICKLIST_ARGS-1].Value <<= aFilter; xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString::createFromAscii("_default"), 0 ); } @@ -336,11 +332,6 @@ void SAL_CALL RecentFilesMenuController::statusChanged( const FeatureStateEvent& m_bDisabled = !Event.IsEnabled; } -// XMenuListener -void SAL_CALL RecentFilesMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) { Reference< css::awt::XPopupMenu > xPopupMenu; @@ -368,43 +359,14 @@ void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEve void SAL_CALL RecentFilesMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) { ResetableGuard aLock( m_aLock ); - if ( m_xPopupMenu.is() ) - fillPopupMenu( m_xPopupMenu ); -} - -void SAL_CALL RecentFilesMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ + impl_setPopupMenu(); } // XPopupMenuController -void SAL_CALL RecentFilesMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) +void RecentFilesMenuController::impl_setPopupMenu() { - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - if ( m_xPopupMenu.is() ) - fillPopupMenu( m_xPopupMenu ); - } + if ( m_xPopupMenu.is() ) + fillPopupMenu( m_xPopupMenu ); } void SAL_CALL RecentFilesMenuController::updatePopupMenu() throw (RuntimeException) @@ -416,12 +378,9 @@ void SAL_CALL RecentFilesMenuController::updatePopupMenu() throw (RuntimeExcepti Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); Reference< XDispatch > xDispatch( m_xDispatch ); - Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = m_aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); + m_xURLTransformer->parseStrict( aTargetURL ); aLock.unlock(); // Add/remove status listener to get a status update once @@ -450,18 +409,6 @@ throw( RuntimeException ) return Reference< XDispatch >(); } -Sequence< Reference< XDispatch > > SAL_CALL RecentFilesMenuController::queryDispatches( - const Sequence< DispatchDescriptor >& lDescriptor ) -throw( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - return PopupMenuControllerBase::queryDispatches( lDescriptor ); -} - // XDispatch void SAL_CALL RecentFilesMenuController::dispatch( const URL& aURL, @@ -520,12 +467,6 @@ throw( RuntimeException ) PopupMenuControllerBase::removeStatusListener( xControl, aURL ); } -// XInitialization -void SAL_CALL RecentFilesMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - PopupMenuControllerBase::initialize( aArguments ); -} - IMPL_STATIC_LINK_NOINSTANCE( RecentFilesMenuController, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile ) { try diff --git a/framework/source/uielement/rootitemcontainer.cxx b/framework/source/uielement/rootitemcontainer.cxx index b34130ea92c9..e560a95d7923 100644 --- a/framework/source/uielement/rootitemcontainer.cxx +++ b/framework/source/uielement/rootitemcontainer.cxx @@ -146,8 +146,7 @@ RootItemContainer::RootItemContainer( const Reference< XIndexAccess >& rSourceCo for ( sal_Int32 i = 0; i < nCount; i++ ) { Sequence< PropertyValue > aPropSeq; - Any a = rSourceContainer->getByIndex( i ); - if ( a >>= aPropSeq ) + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) { sal_Int32 nContainerIndex = -1; Reference< XIndexAccess > xIndexAccess; @@ -181,7 +180,9 @@ RootItemContainer::~RootItemContainer() // private void RootItemContainer::copyItemContainer( const std::vector< Sequence< PropertyValue > >& rSourceVector ) { - for ( sal_uInt32 i = 0; i < rSourceVector.size(); i++ ) + const sal_uInt32 nCount = rSourceVector.size(); + m_aItemVector.reserve(nCount); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { sal_Int32 nContainerIndex = -1; Sequence< PropertyValue > aPropSeq( rSourceVector[i] ); @@ -256,7 +257,7 @@ sal_Bool SAL_CALL RootItemContainer::hasElements() throw ( RuntimeException ) { ShareGuard aLock( m_aShareMutex ); - return ( m_aItemVector.size() != 0 ); + return ( !m_aItemVector.empty() ); } // XIndexAccess diff --git a/framework/source/uielement/spinfieldtoolbarcontroller.cxx b/framework/source/uielement/spinfieldtoolbarcontroller.cxx index b6de37cd13dc..866de8d701d3 100644 --- a/framework/source/uielement/spinfieldtoolbarcontroller.cxx +++ b/framework/source/uielement/spinfieldtoolbarcontroller.cxx @@ -255,59 +255,20 @@ throw ( RuntimeException ) } // ------------------------------------------------------------------ - -void SAL_CALL SpinfieldToolbarController::execute( sal_Int16 KeyModifier ) -throw ( RuntimeException ) +Sequence<PropertyValue> SpinfieldToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const { - Reference< XDispatch > xDispatch; - Reference< XURLTransformer > xURLTransformer; - ::rtl::OUString aCommandURL; - ::rtl::OUString aSpinfieldText; - ::com::sun::star::util::URL aTargetURL; - bool bFloat( false ); - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + Sequence<PropertyValue> aArgs( 2 ); + ::rtl::OUString aSpinfieldText = m_pSpinfieldControl->GetText(); - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_bInitialized && - m_xFrame.is() && - m_xServiceManager.is() && - m_aCommandURL.getLength() ) - { - xURLTransformer = m_xURLTransformer; - xDispatch = getDispatchFromCommand( m_aCommandURL ); - aCommandURL = m_aCommandURL; - aTargetURL = getInitializedURL(); - aSpinfieldText = m_pSpinfieldControl->GetText(); - bFloat = m_bFloat; - } - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) - { - Sequence<PropertyValue> aArgs( 2 ); - - // Add key modifier to argument list - aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value <<= KeyModifier; - aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" )); - - // Use correct type - if ( bFloat ) - aArgs[1].Value <<= aSpinfieldText.toDouble(); - else - aArgs[1].Value <<= aSpinfieldText.toInt32(); - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, ComplexToolbarController , ExecuteHdl_Impl), pExecuteInfo ); - } + // Add key modifier to argument list + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); + aArgs[0].Value <<= KeyModifier; + aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" )); + if ( m_bFloat ) + aArgs[1].Value <<= aSpinfieldText.toDouble(); + else + aArgs[1].Value <<= aSpinfieldText.toInt32(); + return aArgs; } // ------------------------------------------------------------------ diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index 523e0fa6480f..6f7f235632df 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -46,6 +46,7 @@ #include "services.h" #include "general.h" #include "properties.h" +#include <helper/mischelper.hxx> //_________________________________________________________________________________________________________________ // interface includes @@ -148,15 +149,16 @@ StatusBarManager::StatusBarManager( ThreadHelpBase( &Application::GetSolarMutex() ), OWeakObject(), m_bDisposed( sal_False ), - m_bModuleIdentified( sal_False ), m_bFrameActionRegistered( sal_False ), m_bUpdateControllers( sal_False ), + m_bModuleIdentified( sal_False ), m_pStatusBar( pStatusBar ), m_aResourceName( rResourceName ), m_xFrame( rFrame ), m_aListenerContainer( m_aLock.getShareableOslMutex() ), m_xServiceManager( rServiceManager ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" ); if ( m_xServiceManager.is() ) m_xStatusbarControllerRegistration = uno::Reference< css::frame::XUIControllerRegistration >( @@ -173,6 +175,7 @@ StatusBarManager::~StatusBarManager() StatusBar* StatusBarManager::GetStatusBar() const { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::GetStatusBar" ); ResetableGuard aGuard( m_aLock ); return m_pStatusBar; } @@ -180,6 +183,7 @@ StatusBar* StatusBarManager::GetStatusBar() const void StatusBarManager::frameAction( const frame::FrameActionEvent& Action ) throw ( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::frameAction" ); ResetableGuard aGuard( m_aLock ); if ( Action.Action == frame::FrameAction_CONTEXT_CHANGED ) UpdateControllers(); @@ -187,6 +191,7 @@ throw ( uno::RuntimeException ) void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::disposing" ); { ResetableGuard aGuard( m_aLock ); if ( m_bDisposed ) @@ -207,6 +212,7 @@ void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source ) thr // XComponent void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::dispose" ); uno::Reference< lang::XComponent > xThis( static_cast< OWeakObject* >(this), uno::UNO_QUERY ); @@ -245,6 +251,7 @@ void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException ) void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::addEventListener" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -257,6 +264,7 @@ void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XE void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::removeEventListener" ); m_aListenerContainer.removeInterface( ::getCppuType( ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener ); } @@ -264,6 +272,7 @@ void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang: // XUIConfigurationListener void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -273,6 +282,7 @@ void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEve void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -282,6 +292,7 @@ void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEven void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" ); ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -291,10 +302,12 @@ void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEve void StatusBarManager::UpdateControllers() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UpdateControllers" ); if ( !m_bUpdateControllers ) { m_bUpdateControllers = sal_True; - for ( sal_uInt32 n = 0; n < m_aControllerVector.size(); n++ ) + const sal_uInt32 nCount = m_aControllerVector.size(); + for ( sal_uInt32 n = 0; n < nCount; n++ ) { try { @@ -312,12 +325,14 @@ void StatusBarManager::UpdateControllers() void StatusBarManager::RemoveControllers() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::RemoveControllers" ); ResetableGuard aGuard( m_aLock ); if ( m_bDisposed ) return; - for ( sal_uInt32 n = 0; n < m_aControllerVector.size(); n++ ) + const sal_uInt32 nCount = m_aControllerVector.size(); + for ( sal_uInt32 n = 0; n < nCount; n++ ) { try { @@ -336,71 +351,12 @@ void StatusBarManager::RemoveControllers() rtl::OUString StatusBarManager::RetrieveLabelFromCommand( const rtl::OUString& aCmdURL ) { - rtl::OUString aLabel; - - // Retrieve short bubble help - if ( !m_bModuleIdentified ) - { - uno::Reference< css::frame::XModuleManager > xModuleManager( - m_xServiceManager->createInstance( - SERVICENAME_MODULEMANAGER ), uno::UNO_QUERY_THROW ); - uno::Reference< uno::XInterface > xIfac( m_xFrame, uno::UNO_QUERY ); - try - { - m_bModuleIdentified = sal_True; - m_aModuleIdentifier = xModuleManager->identify( xIfac ); - - if ( m_aModuleIdentifier.getLength() > 0 ) - { - uno::Reference< container::XNameAccess > xNameAccess( - m_xServiceManager->createInstance( - SERVICENAME_UICOMMANDDESCRIPTION ), uno::UNO_QUERY ); - if ( xNameAccess.is() ) - { - uno::Any a = xNameAccess->getByName( m_aModuleIdentifier ); - uno::Reference< container::XNameAccess > xUICommands; - a >>= m_xUICommandLabels; - } - } - } - catch ( uno::Exception& ) - { - } - } - - if ( m_xUICommandLabels.is() ) - { - try - { - if ( aCmdURL.getLength() > 0 ) - { - rtl::OUString aStr; - uno::Sequence< beans::PropertyValue > aPropSeq; - uno::Any a( m_xUICommandLabels->getByName( aCmdURL )); - if ( a >>= aPropSeq ) - { - for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name.equalsAscii( "Name" )) - { - aPropSeq[i].Value >>= aStr; - break; - } - } - } - aLabel = aStr; - } - } - catch ( uno::Exception& ) - { - } - } - - return aLabel; + return framework::RetrieveLabelFromCommand(aCmdURL,m_xServiceManager,m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Name"); } void StatusBarManager::CreateControllers() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" ); uno::Reference< lang::XMultiComponentFactory > xStatusbarControllerFactory( m_xStatusbarControllerRegistration, uno::UNO_QUERY ); uno::Reference< uno::XComponentContext > xComponentContext; uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY ); @@ -499,6 +455,7 @@ void StatusBarManager::CreateControllers() void StatusBarManager::AddFrameActionListener() { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" ); if ( !m_bFrameActionRegistered && m_xFrame.is() ) { m_bFrameActionRegistered = sal_True; @@ -527,6 +484,7 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" ); uno::Sequence< beans::PropertyValue > aProp; rtl::OUString aCommandURL; rtl::OUString aHelpURL; @@ -604,10 +562,12 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc void StatusBarManager::StateChanged( StateChangedType ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" ); } void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" ); ResetableGuard aGuard( m_aLock ); if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || @@ -616,12 +576,10 @@ void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt ) ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && ( rDCEvt.GetFlags() & SETTINGS_STYLE )) { - css::uno::Any a; css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; css::uno::Reference< css::beans::XPropertySet > xPropSet( m_xFrame, css::uno::UNO_QUERY ); if ( xPropSet.is() ) - a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); - a >>= xLayoutManager; + xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager; if ( xLayoutManager.is() ) { aGuard.unlock(); @@ -632,6 +590,7 @@ void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt ) void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" ); ResetableGuard aGuard( m_aLock ); if ( m_bDisposed ) @@ -659,6 +618,7 @@ void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt ) void StatusBarManager::Command( const CommandEvent& rEvt ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" ); ResetableGuard aGuard( m_aLock ); if ( m_bDisposed ) @@ -684,74 +644,43 @@ void StatusBarManager::Command( const CommandEvent& rEvt ) void StatusBarManager::MouseMove( const MouseEvent& rMEvt ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" ); + MouseButton(rMEvt,&frame::XStatusbarController::mouseMove); +} +void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&)) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" ); ResetableGuard aGuard( m_aLock ); - if ( m_bDisposed ) - return; - - USHORT nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() ); - if (( nId > 0 ) && ( nId <= m_aControllerVector.size() )) + if ( !m_bDisposed ) { - uno::Reference< frame::XStatusbarController > xController( - m_aControllerVector[nId-1], uno::UNO_QUERY ); - if ( xController.is() ) + USHORT nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() ); + if (( nId > 0 ) && ( nId <= m_aControllerVector.size() )) { - ::com::sun::star::awt::MouseEvent aMouseEvent; - aMouseEvent.Buttons = rMEvt.GetButtons(); - aMouseEvent.X = rMEvt.GetPosPixel().X(); - aMouseEvent.Y = rMEvt.GetPosPixel().Y(); - aMouseEvent.ClickCount = rMEvt.GetClicks(); - xController->mouseMove( aMouseEvent ); - } + uno::Reference< frame::XStatusbarController > xController( + m_aControllerVector[nId-1], uno::UNO_QUERY ); + if ( xController.is() ) + { + ::com::sun::star::awt::MouseEvent aMouseEvent; + aMouseEvent.Buttons = rMEvt.GetButtons(); + aMouseEvent.X = rMEvt.GetPosPixel().X(); + aMouseEvent.Y = rMEvt.GetPosPixel().Y(); + aMouseEvent.ClickCount = rMEvt.GetClicks(); + (xController.get()->*_pMethod)( aMouseEvent); + } + } // if (( nId > 0 ) && ( nId <= m_aControllerVector.size() )) } } - void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt ) { - ResetableGuard aGuard( m_aLock ); - - if ( m_bDisposed ) - return; - - USHORT nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() ); - if (( nId > 0 ) && ( nId <= m_aControllerVector.size() )) - { - uno::Reference< frame::XStatusbarController > xController( - m_aControllerVector[nId-1], uno::UNO_QUERY ); - if ( xController.is() ) - { - ::com::sun::star::awt::MouseEvent aMouseEvent; - aMouseEvent.Buttons = rMEvt.GetButtons(); - aMouseEvent.X = rMEvt.GetPosPixel().X(); - aMouseEvent.Y = rMEvt.GetPosPixel().Y(); - aMouseEvent.ClickCount = rMEvt.GetClicks(); - xController->mouseButtonDown( aMouseEvent ); - } - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" ); + MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown); } void StatusBarManager::MouseButtonUp( const MouseEvent& rMEvt ) { - ResetableGuard aGuard( m_aLock ); - - if ( m_bDisposed ) - return; - - USHORT nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() ); - if (( nId > 0 ) && ( nId <= m_aControllerVector.size() )) - { - uno::Reference< frame::XStatusbarController > xController( - m_aControllerVector[nId-1], uno::UNO_QUERY ); - if ( xController.is() ) - { - ::com::sun::star::awt::MouseEvent aMouseEvent; - aMouseEvent.Buttons = rMEvt.GetButtons(); - aMouseEvent.X = rMEvt.GetPosPixel().X(); - aMouseEvent.Y = rMEvt.GetPosPixel().Y(); - aMouseEvent.ClickCount = rMEvt.GetClicks(); - xController->mouseButtonUp( aMouseEvent ); - } - } + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" ); + MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp); } IMPL_LINK( StatusBarManager, Click, StatusBar*, EMPTYARG ) diff --git a/framework/source/uielement/statusbarwrapper.cxx b/framework/source/uielement/statusbarwrapper.cxx index b73e85f5dd68..0cfbc52515c4 100644 --- a/framework/source/uielement/statusbarwrapper.cxx +++ b/framework/source/uielement/statusbarwrapper.cxx @@ -80,8 +80,7 @@ namespace framework StatusBarWrapper::StatusBarWrapper( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) - : UIConfigElementWrapperBase( UIElementType::STATUSBAR ), - m_xServiceFactory( xServiceManager ) + : UIConfigElementWrapperBase( UIElementType::STATUSBAR,xServiceManager ) { } @@ -187,53 +186,6 @@ void SAL_CALL StatusBarWrapper::updateSettings() throw ( RuntimeException ) } } -void SAL_CALL StatusBarWrapper::setSettings( const Reference< XIndexAccess >& xSettings ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( xSettings.is() ) - { - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY ); - if ( xReplace.is() ) - m_xConfigData = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY ); - else - m_xConfigData = xSettings; - - if ( m_xConfigSource.is() && m_bPersistent ) - { - ::rtl::OUString aResourceURL( m_aResourceURL ); - Reference< XUIConfigurationManager > xUICfgMgr( m_xConfigSource ); - - aLock.unlock(); - - try - { - xUICfgMgr->replaceSettings( aResourceURL, m_xConfigData ); - } - catch( NoSuchElementException& ) - { - } - } - } -} - -Reference< XIndexAccess > SAL_CALL StatusBarWrapper::getSettings( sal_Bool bWriteable ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( bWriteable ) - return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY ); - else - return m_xConfigData; -} - Reference< XInterface > SAL_CALL StatusBarWrapper::getRealInterface() throw ( RuntimeException ) { ResetableGuard aLock( m_aLock ); diff --git a/framework/source/uielement/statusindicatorinterfacewrapper.cxx b/framework/source/uielement/statusindicatorinterfacewrapper.cxx index c1cc6b1d7fdc..d09a97481315 100644 --- a/framework/source/uielement/statusindicatorinterfacewrapper.cxx +++ b/framework/source/uielement/statusindicatorinterfacewrapper.cxx @@ -53,24 +53,10 @@ using namespace com::sun::star::beans; namespace framework { -//***************************************************************************************************************** -// XInterface, XTypeProvider -//***************************************************************************************************************** -DEFINE_XINTERFACE_2 ( StatusIndicatorInterfaceWrapper , - cppu::OWeakObject , - DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider ), - DIRECT_INTERFACE( ::com::sun::star::task::XStatusIndicator ) - ) - -DEFINE_XTYPEPROVIDER_2 ( StatusIndicatorInterfaceWrapper , - ::com::sun::star::lang::XTypeProvider , - ::com::sun::star::task::XStatusIndicator - ) StatusIndicatorInterfaceWrapper::StatusIndicatorInterfaceWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& rStatusIndicatorImpl ) : - ::cppu::OWeakObject() - , m_xStatusIndicatorImpl( rStatusIndicatorImpl ) + m_xStatusIndicatorImpl( rStatusIndicatorImpl ) { } diff --git a/framework/source/uielement/togglebuttontoolbarcontroller.cxx b/framework/source/uielement/togglebuttontoolbarcontroller.cxx index 9bf4ad91c6f2..b4bcc27f4636 100644 --- a/framework/source/uielement/togglebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/togglebuttontoolbarcontroller.cxx @@ -117,52 +117,16 @@ throw ( RuntimeException ) } // ------------------------------------------------------------------ - -void SAL_CALL ToggleButtonToolbarController::execute( sal_Int16 KeyModifier ) -throw ( RuntimeException ) +Sequence<PropertyValue> ToggleButtonToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const { - Reference< XDispatch > xDispatch; - Reference< XURLTransformer > xURLTransformer; - ::rtl::OUString aCommandURL; - ::rtl::OUString aSelectedText; - ::com::sun::star::util::URL aTargetURL; - - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_bInitialized && - m_xFrame.is() && - m_xServiceManager.is() && - m_aCommandURL.getLength() ) - { - xURLTransformer = m_xURLTransformer; - xDispatch = getDispatchFromCommand( m_aCommandURL ); - aCommandURL = m_aCommandURL; - aTargetURL = getInitializedURL(); - aSelectedText = m_aCurrentSelection; - } - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) - { - Sequence<PropertyValue> aArgs( 2 ); - - // Add key modifier to argument list - aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); - aArgs[0].Value <<= KeyModifier; - aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); - aArgs[1].Value <<= aSelectedText; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, ComplexToolbarController , ExecuteHdl_Impl), pExecuteInfo ); - } + Sequence<PropertyValue> aArgs( 2 ); + + // Add key modifier to argument list + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" )); + aArgs[0].Value <<= KeyModifier; + aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); + aArgs[1].Value <<= m_aCurrentSelection; + return aArgs; } // ------------------------------------------------------------------ @@ -178,8 +142,8 @@ throw (::com::sun::star::uno::RuntimeException) { // create popup menu PopupMenu aPopup; - - for ( sal_uInt32 i = 0; i < m_aDropdownMenuList.size(); i++ ) + const sal_uInt32 nCount = m_aDropdownMenuList.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { rtl::OUString aLabel( m_aDropdownMenuList[i] ); aPopup.InsertItem( sal_uInt16( i+1 ), aLabel ); diff --git a/framework/source/uielement/toolbar.cxx b/framework/source/uielement/toolbar.cxx index 0ff7603c7898..a5c5d679fa9f 100644 --- a/framework/source/uielement/toolbar.cxx +++ b/framework/source/uielement/toolbar.cxx @@ -36,6 +36,7 @@ //_________________________________________________________________________________________________________________ #include <uielement/toolbar.hxx> #include <uielement/toolbarmanager.hxx> +#include <rtl/logfile.hxx> namespace framework { diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index a105f7b281a1..88ecaae88ad1 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -60,7 +60,6 @@ // interface includes //_________________________________________________________________________________________________________________ #include <com/sun/star/ui/ItemType.hpp> -#include <com/sun/star/frame/XToolbarController.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/XDockableWindow.hpp> @@ -101,6 +100,7 @@ #include <rtl/logfile.hxx> #include <svtools/menuoptions.hxx> #include <svtools/cmdoptions.hxx> +#include <boost/bind.hpp> //_________________________________________________________________________________________________________________ // namespaces @@ -200,8 +200,7 @@ static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager { try { - Any a( xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) ); - a >>= xLayoutManager; + xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager; } catch ( RuntimeException& ) { @@ -269,10 +268,16 @@ ToolBarManager::ToolBarManager( const Reference< XMultiServiceFactory >& rServic ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( m_pToolBar ); if ( m_xServiceManager.is() ) + { m_xToolbarControllerRegistration = Reference< XUIControllerRegistration >( m_xServiceManager->createInstance( SERVICENAME_TOOLBARCONTROLLERFACTORY ), UNO_QUERY ); + m_xURLTransformer.set( m_xServiceManager->createInstance( + SERVICENAME_URLTRANSFORMER), + UNO_QUERY ); + } + m_pToolBar->SetSelectHdl( LINK( this, ToolBarManager, Select) ); m_pToolBar->SetActivateHdl( LINK( this, ToolBarManager, Activate) ); m_pToolBar->SetDeactivateHdl( LINK( this, ToolBarManager, Deactivate) ); @@ -681,56 +686,15 @@ void SAL_CALL ToolBarManager::removeEventListener( const Reference< XEventListen // XUIConfigurationListener void SAL_CALL ToolBarManager::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { - ResetableGuard aGuard( m_aLock ); - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - if ( m_bDisposed ) - return; - - Reference< XNameAccess > xNameAccess; - sal_Int16 nImageType = sal_Int16(); - sal_Int16 nCurrentImageType = getImageTypeFromBools( - SvtMiscOptions().AreCurrentSymbolsLarge(), - m_bIsHiContrast ); - - if (( Event.aInfo >>= nImageType ) && - ( nImageType == nCurrentImageType ) && - ( Event.Element >>= xNameAccess )) - { - sal_Int16 nImageInfo( 1 ); - Reference< XInterface > xIfacDocImgMgr( m_xDocImageManager, UNO_QUERY ); - if ( xIfacDocImgMgr == Event.Source ) - nImageInfo = 0; - - Sequence< rtl::OUString > aSeq = xNameAccess->getElementNames(); - for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) - { - // Check if we have commands which have an image. We stored for every command - // from which image manager it got its image. Use only images from this - // notification if stored nImageInfo >= current nImageInfo! - rtl::OUString aCommandURL = aSeq[i]; - CommandToInfoMap::iterator pIter = m_aCommandMap.find( aCommandURL ); - if ( pIter != m_aCommandMap.end() && ( pIter->second.nImageInfo >= nImageInfo )) - { - Reference< XGraphic > xGraphic; - if ( xNameAccess->getByName( aSeq[i] ) >>= xGraphic ) - { - Image aImage( xGraphic ); - m_pToolBar->SetItemImage( pIter->second.nId, aImage ); - if ( pIter->second.aIds.size() > 0 ) - { - for ( sal_uInt32 j=0; j < pIter->second.aIds.size(); j++ ) - m_pToolBar->SetItemImage( pIter->second.aIds[j], aImage ); - } - } - pIter->second.nImageInfo = nImageInfo; - } - } - } + impl_elementChanged(false,Event); } void SAL_CALL ToolBarManager::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { + impl_elementChanged(true,Event); +} +void ToolBarManager::impl_elementChanged(bool _bRemove,const ::com::sun::star::ui::ConfigurationEvent& Event ) +{ ResetableGuard aGuard( m_aLock ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ @@ -755,80 +719,50 @@ void SAL_CALL ToolBarManager::elementRemoved( const ::com::sun::star::ui::Config Sequence< rtl::OUString > aSeq = xNameAccess->getElementNames(); for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) { - CommandToInfoMap::const_iterator pIter = m_aCommandMap.find( aSeq[i] ); + CommandToInfoMap::iterator pIter = m_aCommandMap.find( aSeq[i] ); if ( pIter != m_aCommandMap.end() && ( pIter->second.nImageInfo >= nImageInfo )) { - Image aImage; - if (( pIter->second.nImageInfo == 0 ) && ( pIter->second.nImageInfo == nImageInfo )) + if ( _bRemove ) { - // Special case: An image from the document image manager has been removed. - // It is possible that we have a image at our module image manager. Before - // we can remove our image we have to ask our module image manager. - Sequence< rtl::OUString > aCmdURLSeq( 1 ); - Sequence< Reference< XGraphic > > aGraphicSeq; - aCmdURLSeq[0] = pIter->first; - aGraphicSeq = m_xModuleImageManager->getImages( nImageType, aCmdURLSeq ); - aImage = Image( aGraphicSeq[0] ); - } + Image aImage; + if (( pIter->second.nImageInfo == 0 ) && ( pIter->second.nImageInfo == nImageInfo )) + { + // Special case: An image from the document image manager has been removed. + // It is possible that we have a image at our module image manager. Before + // we can remove our image we have to ask our module image manager. + Sequence< rtl::OUString > aCmdURLSeq( 1 ); + Sequence< Reference< XGraphic > > aGraphicSeq; + aCmdURLSeq[0] = pIter->first; + aGraphicSeq = m_xModuleImageManager->getImages( nImageType, aCmdURLSeq ); + aImage = Image( aGraphicSeq[0] ); + } - m_pToolBar->SetItemImage( pIter->second.nId, aImage ); - if ( pIter->second.aIds.size() > 0 ) + setToolBarImage(aImage,pIter); + } // if ( _bRemove ) + else { - for ( sal_uInt32 j=0; j < pIter->second.aIds.size(); j++ ) - m_pToolBar->SetItemImage( pIter->second.aIds[j], aImage ); + Reference< XGraphic > xGraphic; + if ( xNameAccess->getByName( aSeq[i] ) >>= xGraphic ) + { + Image aImage( xGraphic ); + setToolBarImage(aImage,pIter); + } + pIter->second.nImageInfo = nImageInfo; } } } } } +void ToolBarManager::setToolBarImage(const Image& _aImage,const CommandToInfoMap::const_iterator& _pIter) +{ + const ::std::vector< USHORT >& _rIDs = _pIter->second.aIds; + m_pToolBar->SetItemImage( _pIter->second.nId, _aImage ); + ::std::for_each(_rIDs.begin(),_rIDs.end(),::boost::bind(&ToolBar::SetItemImage,m_pToolBar,_1,_aImage)); +} void SAL_CALL ToolBarManager::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { - ResetableGuard aGuard( m_aLock ); - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - if ( m_bDisposed ) - return; - - Reference< XNameAccess > xNameAccess; - sal_Int16 nImageType = sal_Int16(); - sal_Int16 nCurrentImageType = getImageTypeFromBools( - SvtMiscOptions().AreCurrentSymbolsLarge(), - m_bIsHiContrast ); - - if (( Event.aInfo >>= nImageType ) && - ( nImageType == nCurrentImageType ) && - ( Event.Element >>= xNameAccess )) - { - sal_Int16 nImageInfo( 1 ); - Reference< XInterface > xIfacDocImgMgr( m_xDocImageManager, UNO_QUERY ); - if ( xIfacDocImgMgr == Event.Source ) - nImageInfo = 0; - - Sequence< rtl::OUString > aSeq = xNameAccess->getElementNames(); - for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) - { - // Check if we have commands which have an image. We stored for every command - // from which image manager it got its image. Use only images from this - // notification if stored nImageInfo >= current nImageInfo! - CommandToInfoMap::iterator pIter = m_aCommandMap.find( aSeq[i] ); - if ( pIter != m_aCommandMap.end() && ( pIter->second.nImageInfo >= nImageInfo )) - { - Reference< XGraphic > xGraphic; - if ( xNameAccess->getByName( aSeq[i] ) >>= xGraphic ) - { - Image aImage( xGraphic ); - m_pToolBar->SetItemImage( pIter->second.nId, aImage ); - if ( pIter->second.aIds.size() > 0 ) - { - for ( sal_uInt32 j=0; j < pIter->second.aIds.size(); j++ ) - m_pToolBar->SetItemImage( pIter->second.aIds[j], aImage ); - } - } - pIter->second.nImageInfo = nImageInfo; - } - } - } + impl_elementChanged(false,Event); } void ToolBarManager::RemoveControllers() @@ -887,9 +821,7 @@ void ToolBarManager::RemoveControllers() Reference< XNameAccess > xNameAccess( m_xServiceManager->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); if ( xNameAccess.is() ) { - Any a = xNameAccess->getByName( m_aModuleIdentifier ); - Reference< XNameAccess > xUICommands; - a >>= m_xUICommandLabels; + xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandLabels; } } } @@ -906,8 +838,7 @@ void ToolBarManager::RemoveControllers() { rtl::OUString aStr; Sequence< PropertyValue > aPropSeq; - Any a( m_xUICommandLabels->getByName( aCmdURL )); - if ( a >>= aPropSeq ) + if ( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq ) { for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) { @@ -937,8 +868,6 @@ void ToolBarManager::CreateControllers() Reference< XComponentContext > xComponentContext; Reference< XPropertySet > xProps( m_xServiceManager, UNO_QUERY ); Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar ); - Reference< css::util::XURLTransformer > xTrans( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), css::uno::UNO_QUERY ); css::util::URL aURL; sal_Bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED ); @@ -966,7 +895,7 @@ void ToolBarManager::CreateControllers() if ( bHasDisabledEntries ) { aURL.Complete = aCommandURL; - xTrans->parseStrict( aURL ); + m_xURLTransformer->parseStrict( aURL ); if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aURL.Path )) { m_aControllerMap[ nId ] = xController; @@ -984,22 +913,22 @@ void ToolBarManager::CreateControllers() std::vector< Any > aPropertyVector; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" )); - aPropValue.Value = makeAny( m_aModuleIdentifier ); + aPropValue.Value <<= m_aModuleIdentifier; aPropertyVector.push_back( makeAny( aPropValue )); aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - aPropValue.Value = makeAny( m_xFrame ); + aPropValue.Value <<= m_xFrame; aPropertyVector.push_back( makeAny( aPropValue )); aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); - aPropValue.Value = makeAny( m_xServiceManager ); + aPropValue.Value <<= m_xServiceManager; aPropertyVector.push_back( makeAny( aPropValue )); aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); - aPropValue.Value = makeAny( xToolbarWindow ); + aPropValue.Value <<= xToolbarWindow; aPropertyVector.push_back( makeAny( aPropValue )); if ( nWidth > 0 ) { aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" )); - aPropValue.Value = makeAny( nWidth ); + aPropValue.Value <<= nWidth; aPropertyVector.push_back( makeAny( aPropValue )); } @@ -1082,21 +1011,21 @@ void ToolBarManager::CreateControllers() std::vector< Any > aPropertyVector; aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - aPropValue.Value = makeAny( m_xFrame ); + aPropValue.Value <<= m_xFrame; aPropertyVector.push_back( makeAny( aPropValue )); aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); - aPropValue.Value = makeAny( aCommandURL ); + aPropValue.Value <<= aCommandURL; aPropertyVector.push_back( makeAny( aPropValue )); aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); - aPropValue.Value = makeAny( m_xServiceManager ); + aPropValue.Value <<= m_xServiceManager; aPropertyVector.push_back( makeAny( aPropValue )); aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); - aPropValue.Value = makeAny( xToolbarWindow ); + aPropValue.Value <<= xToolbarWindow; aPropertyVector.push_back( makeAny( aPropValue )); if ( nWidth > 0 ) { aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" )); - aPropValue.Value = makeAny( nWidth ); + aPropValue.Value <<= nWidth; aPropertyVector.push_back( makeAny( aPropValue )); } @@ -1340,10 +1269,11 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine AddonsOptions().GetMergeToolbarInstructions( aToolbarName, aMergeInstructionContainer ); - if ( aMergeInstructionContainer.size() > 0 ) + if ( !aMergeInstructionContainer.empty() ) { sal_uInt16 nItemId( TOOLBAR_ITEM_STARTID ); - for ( sal_uInt32 i = 0; i < aMergeInstructionContainer.size(); i++ ) + const sal_uInt32 nCount = aMergeInstructionContainer.size(); + for ( sal_uInt32 i=0; i < nCount; i++ ) { MergeToolbarInstruction& rInstruction = aMergeInstructionContainer[i]; if ( ToolBarMerger::IsCorrectContext( rInstruction.aMergeContext, m_aModuleIdentifier )) @@ -1403,7 +1333,6 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine Reference< XPropertySet > xPropSet( rItemContainer, UNO_QUERY ); if ( xPropSet.is() ) { - Any a; try { rtl::OUString aUIName; @@ -1428,7 +1357,8 @@ void ToolBarManager::RequestImages() sal_uInt32 i = 0; CommandToInfoMap::iterator pIter = m_aCommandMap.begin(); - while ( pIter != m_aCommandMap.end() ) + CommandToInfoMap::iterator pEnd = m_aCommandMap.end(); + while ( pIter != pEnd ) { aCmdURLSeq[i++] = pIter->first; ++pIter; @@ -1444,7 +1374,7 @@ void ToolBarManager::RequestImages() i = 0; pIter = m_aCommandMap.begin(); - while ( pIter != m_aCommandMap.end() ) + while ( pIter != pEnd ) { rtl::OUString aCommandURL = aCmdURLSeq[i]; @@ -1458,24 +1388,14 @@ void ToolBarManager::RequestImages() // empty image. if ( !aImage ) aImage = QueryAddonsImage( aCmdURLSeq[i], bBigImages, m_bIsHiContrast ); - m_pToolBar->SetItemImage( pIter->second.nId, aImage ); - if ( pIter->second.aIds.size() > 0 ) - { - for ( sal_uInt32 j=0; j < pIter->second.aIds.size(); j++ ) - m_pToolBar->SetItemImage( pIter->second.aIds[j], aImage ); - } + pIter->second.nImageInfo = 1; // mark image as module based } else { - m_pToolBar->SetItemImage( pIter->second.nId, aImage ); - if ( pIter->second.aIds.size() > 0 ) - { - for ( sal_uInt32 j=0; j < pIter->second.aIds.size(); j++ ) - m_pToolBar->SetItemImage( pIter->second.aIds[j], aImage ); - } pIter->second.nImageInfo = 0; // mark image as document based } + setToolBarImage(aImage,pIter); ++pIter; ++i; } @@ -1484,7 +1404,7 @@ void ToolBarManager::RequestImages() void ToolBarManager::notifyRegisteredControllers( const rtl::OUString& aUIElementName, const rtl::OUString& aCommand ) { ResetableGuard aGuard( m_aLock ); - if ( m_aSubToolBarControllerMap.size() > 0 ) + if ( !m_aSubToolBarControllerMap.empty() ) { SubToolBarToSubToolBarControllerMap::const_iterator pIter = m_aSubToolBarControllerMap.find( aUIElementName ); @@ -1492,12 +1412,13 @@ void ToolBarManager::notifyRegisteredControllers( const rtl::OUString& aUIElemen if ( pIter != m_aSubToolBarControllerMap.end() ) { const SubToolBarControllerVector& rSubToolBarVector = pIter->second; - if ( rSubToolBarVector.size() > 0 ) + if ( !rSubToolBarVector.empty() ) { SubToolBarControllerVector aNotifyVector = rSubToolBarVector; aGuard.unlock(); - for ( sal_uInt32 i = 0; i < aNotifyVector.size(); i++ ) + const sal_uInt32 nCount = aNotifyVector.size(); + for ( sal_uInt32 i=0; i < nCount; i++ ) { try { @@ -1517,8 +1438,7 @@ void ToolBarManager::notifyRegisteredControllers( const rtl::OUString& aUIElemen } } } - -IMPL_LINK( ToolBarManager, Click, ToolBox*, EMPTYARG ) +long ToolBarManager::HandleClick(void ( SAL_CALL XToolbarController::*_pClick )()) { ResetableGuard aGuard( m_aLock ); @@ -1532,12 +1452,16 @@ IMPL_LINK( ToolBarManager, Click, ToolBox*, EMPTYARG ) Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); if ( xController.is() ) - xController->click(); - } - + (xController.get()->*_pClick)( ); + } // if ( pIter != m_aControllerMap.end() ) return 1; } +IMPL_LINK( ToolBarManager, Click, ToolBox*, EMPTYARG ) +{ + return HandleClick(&XToolbarController::click); +} + IMPL_LINK( ToolBarManager, DropdownClick, ToolBox*, EMPTYARG ) { ResetableGuard aGuard( m_aLock ); @@ -1554,28 +1478,12 @@ IMPL_LINK( ToolBarManager, DropdownClick, ToolBox*, EMPTYARG ) if ( xController.is() ) xController->createPopupWindow(); } - return 1; } IMPL_LINK( ToolBarManager, DoubleClick, ToolBox*, EMPTYARG ) { - ResetableGuard aGuard( m_aLock ); - - if ( m_bDisposed ) - return 1; - - USHORT nId( m_pToolBar->GetCurItemId() ); - ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId ); - if ( pIter != m_aControllerMap.end() ) - { - Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); - - if ( xController.is() ) - xController->doubleClick(); - } - - return 1; + return HandleClick(&XToolbarController::doubleClick); } void ToolBarManager::ImplClearPopupMenu( ToolBox *pToolBar ) @@ -1668,11 +1576,8 @@ PopupMenu * ToolBarManager::GetToolBarCustomMeun(ToolBox* pToolBar) if ( m_xFrame.is() ) { Reference< XDispatchProvider > xProv( m_xFrame, UNO_QUERY ); - Reference< XURLTransformer > xTrans( m_xServiceManager->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" )); - xTrans->parseStrict( aURL ); + m_xURLTransformer->parseStrict( aURL ); if ( xProv.is() ) xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); @@ -1841,11 +1746,8 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu ) if ( m_xFrame.is() ) { Reference< XDispatchProvider > xProv( m_xFrame, UNO_QUERY ); - Reference< XURLTransformer > xTrans( m_xServiceManager->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" )); - xTrans->parseStrict( aURL ); + m_xURLTransformer->parseStrict( aURL ); if ( xProv.is() ) xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); } @@ -1965,9 +1867,7 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu ) if ( xPropSet.is() ) { Reference< XUIConfigurationPersistence > xUICfgMgr; - Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "ConfigurationSource" ))); - if (( a >>= xUICfgMgr ) && ( xUICfgMgr.is() )) + if (( xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ConfigurationSource" ))) >>= xUICfgMgr ) && ( xUICfgMgr.is() )) xUICfgMgr->store(); } } diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index ab2c72425223..80c4c013a71b 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -58,13 +58,10 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/ui/XUIElementSettings.hpp> -#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGER_HPP_ #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> -#endif #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> -#ifndef _COM_SUN_STAR_UI_UIElementType_HPP_ #include <com/sun/star/ui/UIElementType.hpp> -#endif +#include <com/sun/star/lang/DisposedException.hpp> //_________________________________________________________________________________________________________________ // includes of other projects @@ -85,6 +82,7 @@ #include <svtools/menuoptions.hxx> #include <svtools/cmdoptions.hxx> #include <dispatch/uieventloghelper.hxx> +#include <rtl/logfile.hxx> //_________________________________________________________________________________________________________________ // Defines @@ -148,8 +146,7 @@ Reference< XLayoutManager > getLayoutManagerFromFrame( const Reference< XFrame > try { - Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); - aValue >>= xLayoutManager; + xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager; } catch ( UnknownPropertyException& ) { @@ -264,8 +261,7 @@ rtl::OUString ToolbarsMenuController::getUINameFromCommand( const rtl::OUString& Reference< XNameAccess > xNameAccess( m_xServiceManager->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); - Any a = xNameAccess->getByName( m_aModuleIdentifier ); - a >>= m_xUICommandDescription; + xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandDescription; } catch ( Exception& ) { @@ -278,8 +274,7 @@ rtl::OUString ToolbarsMenuController::getUINameFromCommand( const rtl::OUString& { Sequence< PropertyValue > aPropSeq; rtl::OUString aStr; - Any a( m_xUICommandDescription->getByName( rCommandURL )); - if ( a >>= aPropSeq ) + if ( m_xUICommandDescription->getByName( rCommandURL ) >>= aPropSeq ) { for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) { @@ -367,7 +362,8 @@ Sequence< Sequence< com::sun::star::beans::PropertyValue > > ToolbarsMenuControl aTbSeq[1].Name = m_aPropResourceURL; Sequence< Sequence< com::sun::star::beans::PropertyValue > > aSeq( aToolBarArray.size() ); - for ( sal_uInt32 i = 0; i < aToolBarArray.size(); i++ ) + const sal_uInt32 nCount = aToolBarArray.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { aTbSeq[0].Value <<= aToolBarArray[i].aToolBarUIName; aTbSeq[1].Value <<= aToolBarArray[i].aToolBarResName; @@ -476,7 +472,8 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& r std::sort( aSortedTbs.begin(), aSortedTbs.end(), CompareToolBarEntry ); sal_Int16 nIndex( 1 ); - for ( sal_uInt32 i = 0; i < aSortedTbs.size(); i++ ) + const sal_uInt32 nCount = aSortedTbs.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { USHORT nItemCount = m_xPopupMenu->getItemCount(); m_xPopupMenu->insertItem( nIndex, aSortedTbs[i].aUIName, css::awt::MenuItemStyle::CHECKABLE, nItemCount ); @@ -631,10 +628,6 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev } // XMenuListener -void SAL_CALL ToolbarsMenuController::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - void SAL_CALL ToolbarsMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) { Reference< css::awt::XPopupMenu > xPopupMenu; @@ -679,9 +672,7 @@ void SAL_CALL ToolbarsMenuController::select( const css::awt::MenuEvent& rEvent rtl::OUString aElementName = aElementNames[i]; Sequence< PropertyValue > aWindowState; - Any a( xPersistentWindowState->getByName( aElementName )); - - if ( a >>= aWindowState ) + if ( xPersistentWindowState->getByName( aElementName ) >>= aWindowState ) { sal_Bool bVisible( sal_False ); sal_Bool bContextSensitive( sal_False ); @@ -700,7 +691,7 @@ void SAL_CALL ToolbarsMenuController::select( const css::awt::MenuEvent& rEvent if ( !bVisible && bContextSensitive && nVisibleIndex >= 0 ) { // Default is: Every context sensitive toolbar is visible - aWindowState[nVisibleIndex].Value = makeAny( sal_True ); + aWindowState[nVisibleIndex].Value <<= sal_True; xNameReplace->replaceByName( aElementName, makeAny( aWindowState )); bRefreshToolbars = true; } @@ -810,7 +801,8 @@ void SAL_CALL ToolbarsMenuController::activate( const css::awt::MenuEvent& ) thr } // Update status for all commands inside our toolbars popup menu - for ( sal_uInt32 i=0; i < aCmdVector.size(); i++ ) + const sal_uInt32 nCount = aCmdVector.size(); + for ( sal_uInt32 i = 0; i < nCount; i++ ) { bool bInternal = ( aCmdVector[i].indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STATIC_INTERNAL_CMD_PART ))) == 0); @@ -837,10 +829,6 @@ void SAL_CALL ToolbarsMenuController::activate( const css::awt::MenuEvent& ) thr } } -void SAL_CALL ToolbarsMenuController::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - // XPopupMenuController void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) { @@ -863,37 +851,14 @@ void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::X // XInitialization void SAL_CALL ToolbarsMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - const rtl::OUString aFrameName( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); - const rtl::OUString aCommandURLName( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); - ResetableGuard aLock( m_aLock ); - sal_Bool bInitalized( m_bInitialized ); if ( !bInitalized ) { - PropertyValue aPropValue; - rtl::OUString aCommandURL; - Reference< XFrame > xFrame; + PopupMenuControllerBase::initialize(aArguments); - for ( int i = 0; i < aArguments.getLength(); i++ ) + if ( m_bInitialized ) { - if ( aArguments[i] >>= aPropValue ) - { - if ( aPropValue.Name.equalsAscii( "Frame" )) - aPropValue.Value >>= xFrame; - else if ( aPropValue.Name.equalsAscii( "CommandURL" )) - aPropValue.Value >>= aCommandURL; - } - } - - if ( xFrame.is() && aCommandURL.getLength() ) - { - m_xFrame = xFrame; - m_aCommandURL = aCommandURL; - m_bInitialized = true; - - m_aBaseURL = determineBaseURL( aCommandURL ); - Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ); @@ -932,11 +897,6 @@ void SAL_CALL ToolbarsMenuController::initialize( const Sequence< Any >& aArgume { } } - - m_xURLTransformer = Reference< XURLTransformer >( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.util.URLTransformer" ))), - UNO_QUERY ); } } } diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx index 5f38979f9dbc..4c42c9c863ea 100644 --- a/framework/source/uielement/toolbarwrapper.cxx +++ b/framework/source/uielement/toolbarwrapper.cxx @@ -85,8 +85,7 @@ namespace framework { ToolBarWrapper::ToolBarWrapper( const Reference< XMultiServiceFactory >& xServiceManager ) : - UIConfigElementWrapperBase( UIElementType::TOOLBAR ), - m_xServiceManager( xServiceManager ) + UIConfigElementWrapperBase( UIElementType::TOOLBAR,xServiceManager ) { } @@ -185,7 +184,7 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) th pToolBar = new ToolBar( pWindow, nStyles ); m_xToolBarWindow = VCLUnoHelper::GetInterface( pToolBar ); - pToolBarManager = new ToolBarManager( m_xServiceManager, xFrame, m_aResourceURL, pToolBar ); + pToolBarManager = new ToolBarManager( m_xServiceFactory, xFrame, m_aResourceURL, pToolBar ); pToolBar->SetToolBarManager( pToolBarManager ); m_xToolBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY ); pToolBar->WillUsePopupMode( bPopupMode ); @@ -276,71 +275,12 @@ void SAL_CALL ToolBarWrapper::updateSettings() throw (::com::sun::star::uno::Run } } -Reference< XIndexAccess > SAL_CALL ToolBarWrapper::getSettings( sal_Bool bWriteable ) throw (::com::sun::star::uno::RuntimeException) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( bWriteable ) - return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY ); - else - return m_xConfigData; -} - -void SAL_CALL ToolBarWrapper::setSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xSettings ) throw (::com::sun::star::uno::RuntimeException) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( xSettings.is() ) - { - // Create a copy of the data if the container is not const - Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY ); - if ( xReplace.is() ) - m_xConfigData = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY ); - else - m_xConfigData = xSettings; - - if ( m_xConfigSource.is() && m_bPersistent ) - { - ::rtl::OUString aResourceURL( m_aResourceURL ); - Reference< XUIConfigurationManager > xUICfgMgr( m_xConfigSource ); - - aLock.unlock(); - - try - { - xUICfgMgr->replaceSettings( aResourceURL, m_xConfigData ); - } - catch( NoSuchElementException& ) - { - } - } - else if ( !m_bPersistent ) - { - // Transient toolbar => Fill toolbar with new data - ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() ); - if ( pToolBarManager ) - pToolBarManager->FillToolbar( m_xConfigData ); - } - } -} - -// XUIConfigurationListener -void SAL_CALL ToolBarWrapper::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException) -{ -} - -void SAL_CALL ToolBarWrapper::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException) -{ -} - -void SAL_CALL ToolBarWrapper::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException) +void ToolBarWrapper::impl_fillNewData() { + // Transient toolbar => Fill toolbar with new data + ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( m_xToolBarManager.get() ); + if ( pToolBarManager ) + pToolBarManager->FillToolbar( m_xConfigData ); } // XUIElement interface diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx index 1ac950ec463c..174411bfea8a 100644 --- a/framework/source/uielement/uicommanddescription.cxx +++ b/framework/source/uielement/uicommanddescription.cxx @@ -53,7 +53,7 @@ // includes of other projects //_________________________________________________________________________________________________________________ #include <rtl/ustrbuf.hxx> -#include <cppuhelper/weak.hxx> +#include <cppuhelper/implbase2.hxx> #include <unotools/configmgr.hxx> #include <tools/string.hxx> @@ -113,23 +113,14 @@ namespace framework // Configuration access class for PopupMenuControllerFactory implementation //***************************************************************************************************************** -class ConfigurationAccess_UICommand : // interfaces - public XTypeProvider , - public XNameAccess , - public XContainerListener , - // baseclasses - // Order is neccessary for right initialization! +class ConfigurationAccess_UICommand : // Order is neccessary for right initialization! private ThreadHelpBase , - public ::cppu::OWeakObject + public ::cppu::WeakImplHelper2<XNameAccess,XContainerListener> { public: ConfigurationAccess_UICommand( const ::rtl::OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XMultiServiceFactory >& rServiceManager ); virtual ~ConfigurationAccess_UICommand(); - // XInterface, XTypeProvider - FWK_DECLARE_XINTERFACE - FWK_DECLARE_XTYPEPROVIDER - // XNameAccess virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); @@ -177,6 +168,10 @@ class ConfigurationAccess_UICommand : // interfaces Sequence< rtl::OUString > getAllCommands(); sal_Bool fillCache(); sal_Bool addGenericInfoToCache(); + void impl_fill(const Reference< XNameAccess >& _xConfigAccess,sal_Bool _bPopup, + std::vector< ::rtl::OUString >& aImageCommandVector, + std::vector< ::rtl::OUString >& aImageRotateVector, + std::vector< ::rtl::OUString >& aImageMirrorVector); private: typedef ::std::hash_map< ::rtl::OUString, @@ -202,7 +197,7 @@ class ConfigurationAccess_UICommand : // interfaces Reference< XNameAccess > m_xGenericUICommands; Reference< XMultiServiceFactory > m_xServiceManager; Reference< XMultiServiceFactory > m_xConfigProvider; - Reference< XMultiServiceFactory > m_xConfigProviderPopups; + //Reference< XMultiServiceFactory > m_xConfigProviderPopups; Reference< XNameAccess > m_xConfigAccess; Reference< XNameAccess > m_xConfigAccessPopups; Sequence< rtl::OUString > m_aCommandImageList; @@ -217,23 +212,6 @@ class ConfigurationAccess_UICommand : // interfaces //***************************************************************************************************************** // XInterface, XTypeProvider //***************************************************************************************************************** -DEFINE_XINTERFACE_5 ( ConfigurationAccess_UICommand , - OWeakObject , - DIRECT_INTERFACE ( css::container::XNameAccess ), - DIRECT_INTERFACE ( css::container::XContainerListener ), - DIRECT_INTERFACE ( css::lang::XTypeProvider ), - DERIVED_INTERFACE( css::container::XElementAccess, css::container::XNameAccess ), - DERIVED_INTERFACE( css::lang::XEventListener, XContainerListener ) - ) - -DEFINE_XTYPEPROVIDER_5 ( ConfigurationAccess_UICommand , - css::container::XNameAccess , - css::container::XElementAccess , - css::container::XContainerListener , - css::lang::XTypeProvider , - css::lang::XEventListener - ) - ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const rtl::OUString& aModuleName, const Reference< XNameAccess >& rGenericUICommands, const Reference< XMultiServiceFactory >& rServiceManager ) : ThreadHelpBase(), m_aConfigCmdAccess( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_ROOT_ACCESS )), @@ -255,21 +233,14 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const rtl::OUStrin m_aConfigCmdAccess += aModuleName; m_aConfigCmdAccess += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_CMD_ELEMENT_ACCESS )); - m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationProvider" ))), - UNO_QUERY ); + m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY ); m_aConfigPopupAccess += aModuleName; m_aConfigPopupAccess += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_POP_ELEMENT_ACCESS )); - m_xConfigProviderPopups = Reference< XMultiServiceFactory >( rServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationProvider" ))), - UNO_QUERY ); + //m_xConfigProviderPopups = Reference< XMultiServiceFactory >( rServiceManager->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY ); - Any aRet = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ); rtl::OUString aTmp; - aRet >>= aTmp; + ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ) >>= aTmp; m_aBrandName = aTmp; } @@ -336,11 +307,7 @@ throw ( RuntimeException ) sal_Bool SAL_CALL ConfigurationAccess_UICommand::hasByName( const ::rtl::OUString& rCommandURL ) throw (::com::sun::star::uno::RuntimeException) { - Any a = getByName( rCommandURL ); - if ( a != Any() ) - return sal_True; - else - return sal_False; + return getByName( rCommandURL ).hasValue(); } // XElementAccess @@ -381,48 +348,36 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const ::rtl::OUString& aPropSeq[0].Value = pIter->second.aContextLabel.getLength() ? makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel ); aPropSeq[1].Name = m_aPropName; - aPropSeq[1].Value = makeAny( pIter->second.aCommandName ); + aPropSeq[1].Value <<= pIter->second.aCommandName; aPropSeq[2].Name = m_aPropPopup; - aPropSeq[2].Value = makeAny( pIter->second.bPopup ); + aPropSeq[2].Value <<= pIter->second.bPopup; return makeAny( aPropSeq ); } return Any(); } - -sal_Bool ConfigurationAccess_UICommand::fillCache() +void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _xConfigAccess,sal_Bool _bPopup, + std::vector< ::rtl::OUString >& aImageCommandVector, + std::vector< ::rtl::OUString >& aImageRotateVector, + std::vector< ::rtl::OUString >& aImageMirrorVector) { - RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ConfigurationAccess_UICommand::fillCache" ); - - if ( m_bCacheFilled ) - return sal_True; - - sal_Int32 i( 0 ); - Any a; - std::vector< ::rtl::OUString > aImageCommandVector; - std::vector< ::rtl::OUString > aImageRotateVector; - std::vector< ::rtl::OUString > aImageMirrorVector; - Sequence< ::rtl::OUString > aNameSeq; - - if ( m_xConfigAccess.is() ) + if ( _xConfigAccess.is() ) { - aNameSeq = m_xConfigAccess->getElementNames(); - for ( i = 0; i < aNameSeq.getLength(); i++ ) + Sequence< ::rtl::OUString> aNameSeq = _xConfigAccess->getElementNames(); + const sal_Int32 nCount = aNameSeq.getLength(); + for ( sal_Int32 i = 0; i < nCount; i++ ) { try { - Reference< XNameAccess > xNameAccess; - a = m_xConfigAccess->getByName( aNameSeq[i] ); - if ( a >>= xNameAccess ) + Reference< XNameAccess > xNameAccess(_xConfigAccess->getByName( aNameSeq[i] ),UNO_QUERY); + if ( xNameAccess.is() ) { CmdToInfoMap aCmdToInfo; - a = xNameAccess->getByName( m_aPropUILabel ); - a >>= aCmdToInfo.aLabel; - a = xNameAccess->getByName( m_aPropUIContextLabel ); - a >>= aCmdToInfo.aContextLabel; - a = xNameAccess->getByName( m_aPropProperties ); - a >>= aCmdToInfo.nProperties; + aCmdToInfo.bPopup = _bPopup; + xNameAccess->getByName( m_aPropUILabel ) >>= aCmdToInfo.aLabel; + xNameAccess->getByName( m_aPropUIContextLabel ) >>= aCmdToInfo.aContextLabel; + xNameAccess->getByName( m_aPropProperties ) >>= aCmdToInfo.nProperties; m_aCmdInfoCache.insert( CommandToInfoCache::value_type( aNameSeq[i], aCmdToInfo )); @@ -441,48 +396,21 @@ sal_Bool ConfigurationAccess_UICommand::fillCache() { } } - } - - if ( m_xConfigAccessPopups.is() ) - { - aNameSeq = m_xConfigAccessPopups->getElementNames(); - for ( i = 0; i < aNameSeq.getLength(); i++ ) - { - try - { - Reference< XNameAccess > xNameAccess; - a = m_xConfigAccessPopups->getByName( aNameSeq[i] ); - if ( a >>= xNameAccess ) - { - CmdToInfoMap aCmdToInfo; - - aCmdToInfo.bPopup = sal_True; - a = xNameAccess->getByName( m_aPropUILabel ); - a >>= aCmdToInfo.aLabel; - a = xNameAccess->getByName( m_aPropUIContextLabel ); - a >>= aCmdToInfo.aContextLabel; - a = xNameAccess->getByName( m_aPropProperties ); - a >>= aCmdToInfo.nProperties; + } // if ( m_xConfigAccessPopups.is() ) +} +sal_Bool ConfigurationAccess_UICommand::fillCache() +{ + RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ConfigurationAccess_UICommand::fillCache" ); - m_aCmdInfoCache.insert( CommandToInfoCache::value_type( aNameSeq[i], aCmdToInfo )); + if ( m_bCacheFilled ) + return sal_True; - if ( aCmdToInfo.nProperties & COMMAND_PROPERTY_IMAGE ) - aImageCommandVector.push_back( aNameSeq[i] ); - if ( aCmdToInfo.nProperties & COMMAND_PROPERTY_ROTATE ) - aImageRotateVector.push_back( aNameSeq[i] ); - if ( aCmdToInfo.nProperties & COMMAND_PROPERTY_MIRROR ) - aImageMirrorVector.push_back( aNameSeq[i] ); - } - } - catch ( com::sun::star::lang::WrappedTargetException& ) - { - } - catch ( com::sun::star::container::NoSuchElementException& ) - { - } - } - } + std::vector< ::rtl::OUString > aImageCommandVector; + std::vector< ::rtl::OUString > aImageRotateVector; + std::vector< ::rtl::OUString > aImageMirrorVector; + impl_fill(m_xConfigAccess,sal_False,aImageCommandVector,aImageRotateVector,aImageMirrorVector); + impl_fill(m_xConfigAccessPopups,sal_True,aImageCommandVector,aImageRotateVector,aImageMirrorVector); // Create cached sequences for fast retrieving m_aCommandImageList = comphelper::containerToSequence( aImageCommandVector ); m_aCommandRotateImageList = comphelper::containerToSequence( aImageRotateVector ); @@ -582,7 +510,6 @@ Sequence< rtl::OUString > ConfigurationAccess_UICommand::getAllCommands() if ( m_xConfigAccess.is() ) { - Any a; Reference< XNameAccess > xNameAccess; try @@ -624,14 +551,10 @@ sal_Bool ConfigurationAccess_UICommand::initializeConfigAccess() try { aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); - aPropValue.Value = makeAny( m_aConfigCmdAccess ); + aPropValue.Value <<= m_aConfigCmdAccess; aArgs[0] <<= aPropValue; - m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess" )), - aArgs ), - UNO_QUERY ); + m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY ); if ( m_xConfigAccess.is() ) { // Add as container listener @@ -640,13 +563,9 @@ sal_Bool ConfigurationAccess_UICommand::initializeConfigAccess() xContainer->addContainerListener( this ); } - aPropValue.Value = makeAny( m_aConfigPopupAccess ); + aPropValue.Value <<= m_aConfigPopupAccess; aArgs[0] <<= aPropValue; - m_xConfigAccessPopups = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess" )), - aArgs ), - UNO_QUERY ); + m_xConfigAccessPopups = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY ); if ( m_xConfigAccessPopups.is() ) { // Add as container listener @@ -711,21 +630,6 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XINTERFACE_4 ( UICommandDescription , - OWeakObject , - DIRECT_INTERFACE( css::lang::XTypeProvider ), - DIRECT_INTERFACE( css::lang::XServiceInfo ), - DIRECT_INTERFACE( css::container::XNameAccess ), - DERIVED_INTERFACE( css::container::XElementAccess, css::container::XNameAccess ) - ) - -DEFINE_XTYPEPROVIDER_4 ( UICommandDescription , - css::lang::XTypeProvider , - css::lang::XServiceInfo , - css::container::XNameAccess , - css::container::XElementAccess - ) - DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UICommandDescription , ::cppu::OWeakObject , SERVICENAME_UICOMMANDDESCRIPTION , @@ -739,12 +643,33 @@ UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactor m_aPrivateResourceURL( RTL_CONSTASCII_USTRINGPARAM( PRIVATE_RESOURCE_URL )), m_xServiceManager( xServiceManager ) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::UICommandDescription" ); Reference< XNameAccess > xEmpty; rtl::OUString aGenericUICommand( ::rtl::OUString::createFromAscii( "GenericCommands" )); m_xGenericUICommands = new ConfigurationAccess_UICommand( aGenericUICommand, xEmpty, xServiceManager ); - m_xModuleManager = Reference< XModuleManager >( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), - UNO_QUERY ); + impl_fillElements("ooSetupFactoryCommandConfigRef"); + + // insert generic commands + UICommandsHashMap::iterator pIter = m_aUICommandsHashMap.find( aGenericUICommand ); + if ( pIter != m_aUICommandsHashMap.end() ) + pIter->second = m_xGenericUICommands; +} +UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactory >& xServiceManager,bool ) : + ThreadHelpBase(), + m_xServiceManager( xServiceManager ) +{ +} +UICommandDescription::~UICommandDescription() +{ + ResetableGuard aLock( m_aLock ); + m_aModuleToCommandFileMap.clear(); + m_aUICommandsHashMap.clear(); + m_xGenericUICommands.clear(); +} +void UICommandDescription::impl_fillElements(const sal_Char* _pName) +{ + m_xModuleManager.set( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),UNO_QUERY ); Reference< XNameAccess > xNameAccess( m_xModuleManager, UNO_QUERY_THROW ); Sequence< rtl::OUString > aElementNames = xNameAccess->getElementNames(); Sequence< PropertyValue > aSeq; @@ -753,13 +678,12 @@ UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactor for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ ) { aModuleIdentifier = aElementNames[i]; - Any a = xNameAccess->getByName( aModuleIdentifier ); - if ( a >>= aSeq ) + if ( xNameAccess->getByName( aModuleIdentifier ) >>= aSeq ) { ::rtl::OUString aCommandStr; for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ ) { - if ( aSeq[y].Name.equalsAscii("ooSetupFactoryCommandConfigRef") ) + if ( aSeq[y].Name.equalsAscii(_pName) ) { aSeq[y].Value >>= aCommandStr; break; @@ -774,25 +698,17 @@ UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactor if ( pIter == m_aUICommandsHashMap.end() ) m_aUICommandsHashMap.insert( UICommandsHashMap::value_type( aCommandStr, Reference< XNameAccess >() )); } - } - - // insert generic commands - UICommandsHashMap::iterator pIter = m_aUICommandsHashMap.find( aGenericUICommand ); - if ( pIter != m_aUICommandsHashMap.end() ) - pIter->second = m_xGenericUICommands; + } // for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ ) } - -UICommandDescription::~UICommandDescription() +Reference< XNameAccess > UICommandDescription::impl_createConfigAccess(const ::rtl::OUString& _sName) { - ResetableGuard aLock( m_aLock ); - m_aModuleToCommandFileMap.clear(); - m_aUICommandsHashMap.clear(); - m_xGenericUICommands.clear(); + return new ConfigurationAccess_UICommand( _sName,m_xGenericUICommands,m_xServiceManager ); } Any SAL_CALL UICommandDescription::getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::getByName" ); Any a; ResetableGuard aLock( m_aLock ); @@ -818,7 +734,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la } } } - else if ( aName.indexOf( m_aPrivateResourceURL ) == 0 ) + else if ( m_aPrivateResourceURL.getLength() && aName.indexOf( m_aPrivateResourceURL ) == 0 ) { // special keys to retrieve information about a set of commands return m_xGenericUICommands->getByName( aName ); @@ -834,6 +750,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la Sequence< ::rtl::OUString > SAL_CALL UICommandDescription::getElementNames() throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::getElementNames" ); ResetableGuard aLock( m_aLock ); Sequence< rtl::OUString > aSeq( m_aModuleToCommandFileMap.size() ); @@ -852,6 +769,7 @@ throw (::com::sun::star::uno::RuntimeException) sal_Bool SAL_CALL UICommandDescription::hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::hasByName" ); ResetableGuard aLock( m_aLock ); ModuleToCommandFileMap::const_iterator pIter = m_aModuleToCommandFileMap.find( aName ); @@ -862,12 +780,14 @@ throw (::com::sun::star::uno::RuntimeException) Type SAL_CALL UICommandDescription::getElementType() throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::getElementType" ); return( ::getCppuType( (const Reference< XNameAccess >*)NULL ) ); } sal_Bool SAL_CALL UICommandDescription::hasElements() throw (::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::hasElements" ); // generic UI commands are always available! return sal_True; } |