diff options
author | Noel Grandin <noel@peralex.com> | 2013-02-25 15:17:03 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-03-04 14:22:33 +0200 |
commit | 244c7cdede13980c29850b7b68e9da16cdc61879 (patch) | |
tree | d06ef7ef2a9239302aedf5ba126e3e3e2fc4c146 | |
parent | fdo#46808, Convert the menu classes in framework to XComponentContext (diff) | |
download | core-244c7cdede13980c29850b7b68e9da16cdc61879.tar.gz core-244c7cdede13980c29850b7b68e9da16cdc61879.zip |
fdo#46808, convert task::StatusIndicatorFactory to new style
the service already existed, it just needed an IDL file.
Change-Id: I84c8e48e176ec3a38ac48a7abcec7463390523b9
21 files changed, 138 insertions, 160 deletions
diff --git a/framework/inc/classes/menumanager.hxx b/framework/inc/classes/menumanager.hxx index 8e2ac6f076e8..a6112a1f801c 100644 --- a/framework/inc/classes/menumanager.hxx +++ b/framework/inc/classes/menumanager.hxx @@ -38,8 +38,6 @@ #include <threadhelp/threadhelpbase.hxx> #include <macros/debug.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - #define REFERENCE ::com::sun::star::uno::Reference #define XFRAME ::com::sun::star::frame::XFrame #define XDISPATCH ::com::sun::star::frame::XDispatch @@ -61,7 +59,7 @@ class MenuManager : public ThreadHelpBase , { public: MenuManager( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, REFERENCE< XFRAME >& rFrame, Menu* pMenu, sal_Bool bDelete, @@ -81,7 +79,7 @@ class MenuManager : public ThreadHelpBase , void RemoveListener(); - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory(); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& getContext(); static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,IMutex& _rMutex); static void FillMenuImages( @@ -136,8 +134,8 @@ class MenuManager : public ThreadHelpBase , REFERENCE< XFRAME > m_xFrame; ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector; - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory; - ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; }; } // namespace diff --git a/framework/inc/dispatch/menudispatcher.hxx b/framework/inc/dispatch/menudispatcher.hxx index eb0a8e7711dc..a41318fd3705 100644 --- a/framework/inc/dispatch/menudispatcher.hxx +++ b/framework/inc/dispatch/menudispatcher.hxx @@ -99,14 +99,14 @@ class MenuDispatcher : // interfaces @seealso using at owner - @param "xFactory" , css::uno::Reference to servicemanager for creation of new services + @param "rxContext" , css::uno::Reference to servicemanager for creation of new services @param "xOwner" , css::uno::Reference to our owner, the Desktop!!! @return - @onerror - *//*-*****************************************************************************************************/ - MenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + MenuDispatcher( const css::uno::Reference< css::uno::XComponentContext >& rxContext , const css::uno::Reference< css::frame::XFrame >& xOwner ); //--------------------------------------------------------------------------------------------------------- @@ -252,37 +252,6 @@ class MenuDispatcher : // interfaces void impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel ); //------------------------------------------------------------------------------------------------------------- - // debug methods - // (should be private everyway!) - //------------------------------------------------------------------------------------------------------------- - - /*-****************************************************************************************************//** - @short debug-method to check incoming parameter of some other mehods of this class - @descr The following methods are used to check parameters for other methods - of this class. The return value is used directly for an ASSERT(...). - - @seealso ASSERTs in implementation! - - @param css::uno::References to checking variables - @return sal_False on invalid parameter<BR> - sal_True otherway - - @onerror - - *//*-*****************************************************************************************************/ - - #ifdef ENABLE_ASSERTIONS - - private: - - static sal_Bool impldbg_checkParameter_MenuDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , - const css::uno::Reference< css::frame::XFrame >& xOwner ); - static sal_Bool impldbg_checkParameter_addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , - const css::util::URL& aURL ); - static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , - const css::util::URL& aURL ); - #endif // #ifdef ENABLE_ASSERTIONS - - //------------------------------------------------------------------------------------------------------------- // variables // (should be private everyway!) //------------------------------------------------------------------------------------------------------------- @@ -290,7 +259,7 @@ class MenuDispatcher : // interfaces private: css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak ; /// css::uno::WeakReference to owner (Don't use a hard css::uno::Reference. Owner can't delete us then!) - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services! + css::uno::Reference< css::uno::XComponentContext > m_xContext ; /// factory shared with our owner to create new services! IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation diff --git a/framework/inc/framework/menuconfiguration.hxx b/framework/inc/framework/menuconfiguration.hxx index d122e4043e59..9b6eb7439016 100644 --- a/framework/inc/framework/menuconfiguration.hxx +++ b/framework/inc/framework/menuconfiguration.hxx @@ -71,7 +71,7 @@ class FWE_DLLPUBLIC MenuConfiguration MenuConfiguration( // use const when giving a uno reference by reference - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); virtual ~MenuConfiguration(); @@ -97,8 +97,7 @@ class FWE_DLLPUBLIC MenuConfiguration throw ( ::com::sun::star::lang::WrappedTargetException ); private: - // do not hold the uno reference by reference - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& m_rxServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext; }; } diff --git a/framework/inc/properties.h b/framework/inc/properties.h index 1071b0ebd844..31052a24820e 100644 --- a/framework/inc/properties.h +++ b/framework/inc/properties.h @@ -27,19 +27,6 @@ namespace framework{ //_______________________________________________ -/** properties for "StatusIndicatorFactory" class */ - -#define STATUSINDICATORFACTORY_PROPNAME_ASCII_FRAME "Frame" -#define STATUSINDICATORFACTORY_PROPNAME_ASCII_WINDOW "Window" -#define STATUSINDICATORFACTORY_PROPNAME_ASCII_ALLOWPARENTSHOW "AllowParentShow" -#define STATUSINDICATORFACTORY_PROPNAME_ASCII_DISABLERESCHEDULE "DisableReschedule" - -#define STATUSINDICATORFACTORY_PROPNAME_FRAME DECLARE_ASCII(STATUSINDICATORFACTORY_PROPNAME_ASCII_FRAME ) -#define STATUSINDICATORFACTORY_PROPNAME_WINDOW DECLARE_ASCII(STATUSINDICATORFACTORY_PROPNAME_ASCII_WINDOW ) -#define STATUSINDICATORFACTORY_PROPNAME_ALLOWPARENTSHOW DECLARE_ASCII(STATUSINDICATORFACTORY_PROPNAME_ASCII_ALLOWPARENTSHOW ) -#define STATUSINDICATORFACTORY_PROPNAME_DISABLERESCHEDULE DECLARE_ASCII(STATUSINDICATORFACTORY_PROPNAME_ASCII_DISABLERESCHEDULE) - -//_______________________________________________ /** properties for "Frame" class */ #define FRAME_PROPNAME_ASCII_DISPATCHRECORDERSUPPLIER "DispatchRecorderSupplier" diff --git a/framework/inc/services.h b/framework/inc/services.h index abc275b58ae5..28f8b6d70bad 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -36,7 +36,6 @@ namespace framework{ #define SERVICENAME_CFGREADACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationAccess" ) // provides readonly access to the configuration #define SERVICENAME_CONTENTHANDLER DECLARE_ASCII("com.sun.star.frame.ContentHandler" ) #define SERVICENAME_CONTENTHANDLERFACTORY DECLARE_ASCII("com.sun.star.frame.ContentHandlerFactory" ) -#define SERVICENAME_STATUSINDICATORFACTORY DECLARE_ASCII("com.sun.star.task.StatusIndicatorFactory" ) #define SERVICENAME_JOB DECLARE_ASCII("com.sun.star.task.Job" ) #define SERVICENAME_PROTOCOLHANDLER DECLARE_ASCII("com.sun.star.frame.ProtocolHandler" ) #define SERVICENAME_PATHSETTINGS DECLARE_ASCII("com.sun.star.util.PathSettings" ) @@ -111,7 +110,6 @@ namespace framework{ #define IMPLEMENTATIONNAME_TOOLBARCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.comp.framework.ToolBarControllerFactory" ) #define IMPLEMENTATIONNAME_LICENSE DECLARE_ASCII("com.sun.star.comp.framework.License" ) #define IMPLEMENTATIONNAME_AUTORECOVERY DECLARE_ASCII("com.sun.star.comp.framework.AutoRecovery" ) -#define IMPLEMENTATIONNAME_STATUSINDICATORFACTORY DECLARE_ASCII("com.sun.star.comp.framework.StatusIndicatorFactory" ) #define IMPLEMENTATIONNAME_RECENTFILESMENUCONTROLLER DECLARE_ASCII("com.sun.star.comp.framework.RecentFilesMenuController" ) #define IMPLEMENTATIONNAME_STATUSBARFACTORY DECLARE_ASCII("com.sun.star.comp.framework.StatusBarFactory" ) #define IMPLEMENTATIONNAME_STATUSBARCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.comp.framework.StatusBarControllerFactory" ) diff --git a/framework/inc/uiconfiguration/uiconfigurationmanager.hxx b/framework/inc/uiconfiguration/uiconfigurationmanager.hxx index 17e7f41986be..6d93a74430a2 100644 --- a/framework/inc/uiconfiguration/uiconfigurationmanager.hxx +++ b/framework/inc/uiconfiguration/uiconfigurationmanager.hxx @@ -71,7 +71,7 @@ namespace framework FWK_DECLARE_XTYPEPROVIDER DECLARE_XSERVICEINFO - UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ); + UIConfigurationManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext ); virtual ~UIConfigurationManager(); // XComponent @@ -180,7 +180,7 @@ namespace framework rtl::OUString m_aPropUIName; rtl::OUString m_aPropResourceURL; rtl::OUString m_aModuleIdentifier; - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xImageManager; com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xAccConfig; diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index 54e4dc34ffd1..c53ac70c03ef 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -32,7 +32,6 @@ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XURLTransformer.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/Desktop.hpp> @@ -110,11 +109,11 @@ namespace framework const char UNO_COMMAND[] = ".uno:"; MenuManager::MenuManager( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, REFERENCE< XFRAME >& rFrame, Menu* pMenu, sal_Bool bDelete, sal_Bool bDeleteChildren ) : ThreadHelpBase( &Application::GetSolarMutex() ), - mxServiceFactory(xServiceFactory) + m_xContext(rxContext) { m_bActive = sal_False; m_bDeleteMenu = bDelete; @@ -193,7 +192,7 @@ MenuManager::MenuManager( { if ( nItemId == SID_NEWDOCDIRECT || aItemCommand == aSlotNewDocDirect ) { - MenuConfiguration aMenuCfg( getServiceFactory() ); + MenuConfiguration aMenuCfg( m_xContext ); BmkMenu* pSubMenu = (BmkMenu*)aMenuCfg.CreateBookmarkMenu( rFrame, BOOKMARK_NEWMENU ); pMenu->SetPopupMenu( nItemId, pSubMenu ); @@ -207,7 +206,7 @@ MenuManager::MenuManager( } else if ( nItemId == SID_AUTOPILOTMENU || aItemCommand == aSlotAutoPilot ) { - MenuConfiguration aMenuCfg( getServiceFactory() ); + MenuConfiguration aMenuCfg( m_xContext ); BmkMenu* pSubMenu = (BmkMenu*)aMenuCfg.CreateBookmarkMenu( rFrame, BOOKMARK_WIZARDMENU ); pMenu->SetPopupMenu( nItemId, pSubMenu ); @@ -278,8 +277,8 @@ void MenuManager::SetHdl() m_pVCLMenu->SetDeactivateHdl( LINK( this, MenuManager, Deactivate )); m_pVCLMenu->SetSelectHdl( LINK( this, MenuManager, Select )); - if ( mxServiceFactory.is() ) - m_xURLTransformer.set( URLTransformer::create(::comphelper::getComponentContext(mxServiceFactory)) ); + if ( m_xContext.is() ) + m_xURLTransformer.set( URLTransformer::create( m_xContext ) ); } MenuManager::~MenuManager() @@ -763,7 +762,7 @@ IMPL_LINK( MenuManager, Activate, Menu *, pMenu ) if ( m_aMenuItemCommand == aSpecialFileMenu || m_aMenuItemCommand == aSlotSpecialFileMenu || aCommand == aSpecialFileCommand ) UpdateSpecialFileMenu( pMenu ); else if ( m_aMenuItemCommand == aSpecialWindowMenu || m_aMenuItemCommand == aSlotSpecialWindowMenu || aCommand == aSpecialWindowCommand ) - UpdateSpecialWindowMenu( pMenu, comphelper::getComponentContext(getServiceFactory()), m_aLock ); + UpdateSpecialWindowMenu( pMenu, m_xContext, m_aLock ); // Check if some modes have changed so we have to update our menu images if ( bShowMenuImages != m_bShowMenuImages ) @@ -862,7 +861,7 @@ IMPL_LINK( MenuManager, Select, Menu *, pMenu ) { // window list menu item selected - Reference< XDesktop2 > xDesktop = Desktop::create( comphelper::getComponentContext(getServiceFactory()) ); + Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext ); sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST; Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY ); @@ -923,14 +922,14 @@ IMPL_LINK_NOARG(MenuManager, Highlight) return 0; } -const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& MenuManager::getServiceFactory() +const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& MenuManager::getContext() { - return mxServiceFactory; + return m_xContext; } void MenuManager::AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren) { - MenuManager* pSubMenuManager = new MenuManager( getServiceFactory(), m_xFrame, _pPopupMenu, _bDelete, _bDeleteChildren ); + MenuManager* pSubMenuManager = new MenuManager( m_xContext, m_xFrame, _pPopupMenu, _bDelete, _bDeleteChildren ); // store menu item command as we later have to know which menu is active (see Activate handler) pSubMenuManager->m_aMenuItemCommand = _sItemCommand; diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx index 56053cc8c1bd..90f39948d327 100644 --- a/framework/source/dispatch/dispatchprovider.cxx +++ b/framework/source/dispatch/dispatchprovider.cxx @@ -597,7 +597,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat WriteGuard aWriteLock( m_aLock ); if ( ! m_xMenuDispatcher.is() ) { - MenuDispatcher* pDispatcher = new MenuDispatcher( xFactory, xOwner ); + MenuDispatcher* pDispatcher = new MenuDispatcher( comphelper::getComponentContext(xFactory), xOwner ); m_xMenuDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); } xDispatchHelper = m_xMenuDispatcher; diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx index 61fd1302a15f..0402a9546a90 100644 --- a/framework/source/fwe/xml/menuconfiguration.cxx +++ b/framework/source/fwe/xml/menuconfiguration.cxx @@ -44,8 +44,8 @@ namespace framework { MenuConfiguration::MenuConfiguration( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager ) -: m_rxServiceManager( rServiceManager ) + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) +: m_xContext( rxContext ) { } @@ -59,7 +59,7 @@ Reference< XIndexAccess > MenuConfiguration::CreateMenuBarConfigurationFromXML( Reference< XInputStream >& rInputStream ) throw ( WrappedTargetException ) { - Reference< XParser > xParser = Parser::create( comphelper::getComponentContext(m_rxServiceManager) ); + Reference< XParser > xParser = Parser::create( m_xContext ); // connect stream to input stream to the parser InputSource aInputSource; @@ -121,7 +121,7 @@ void MenuConfiguration::StoreMenuBarConfigurationToXML( Reference< XOutputStream >& rOutputStream ) throw ( WrappedTargetException ) { - Reference< XWriter > xWriter = Writer::create(comphelper::getComponentContext(m_rxServiceManager)); + Reference< XWriter > xWriter = Writer::create(m_xContext); xWriter->setOutputStream( rOutputStream ); try diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index 3f6b34dfb9ed..19347ee43177 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -71,8 +71,8 @@ DEFINE_XTYPEPROVIDER_5(StatusIndicatorFactory , DEFINE_XSERVICEINFO_MULTISERVICE(StatusIndicatorFactory , ::cppu::OWeakObject , - SERVICENAME_STATUSINDICATORFACTORY , - IMPLEMENTATIONNAME_STATUSINDICATORFACTORY) + OUString("com.sun.star.task.StatusIndicatorFactory"), + OUString("com.sun.star.comp.framework.StatusIndicatorFactory")) DEFINE_INIT_SERVICE(StatusIndicatorFactory, { @@ -107,18 +107,37 @@ void SAL_CALL StatusIndicatorFactory::initialize(const css::uno::Sequence< css:: throw(css::uno::Exception , css::uno::RuntimeException) { - ::comphelper::SequenceAsHashMap lArgs(lArguments); - - // SAFE -> ---------------------------------- - WriteGuard aWriteLock(m_aLock); - - m_xFrame = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_FRAME , css::uno::Reference< css::frame::XFrame >()); - m_xPluggWindow = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_WINDOW , css::uno::Reference< css::awt::XWindow >() ); - m_bAllowParentShow = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_ALLOWPARENTSHOW , (sal_Bool)sal_False ); - m_bDisableReschedule = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_DISABLERESCHEDULE, (sal_Bool)sal_False ); + if (lArguments.getLength() > 0) { + // SAFE -> ---------------------------------- + WriteGuard aWriteLock(m_aLock); - aWriteLock.unlock(); - // <- SAFE ---------------------------------- + css::uno::Reference< css::frame::XFrame > xTmpFrame; + css::uno::Reference< css::awt::XWindow > xTmpWindow; + bool b1 = lArguments[0] >>= xTmpFrame; + bool b2 = lArguments[0] >>= xTmpWindow; + if (lArguments.getLength() == 3 && b1) { + // it's the first service constructor "createWithFrame" + m_xFrame = xTmpFrame; + lArguments[1] >>= m_bDisableReschedule; + lArguments[2] >>= m_bAllowParentShow; + } else if (lArguments.getLength() == 3 && b2) { + // it's the second service constructor "createWithWindow" + m_xPluggWindow = xTmpWindow; + lArguments[1] >>= m_bDisableReschedule; + lArguments[2] >>= m_bAllowParentShow; + } else { + // it's an old-style initialisation using properties + ::comphelper::SequenceAsHashMap lArgs(lArguments); + + m_xFrame = lArgs.getUnpackedValueOrDefault("Frame" , css::uno::Reference< css::frame::XFrame >()); + m_xPluggWindow = lArgs.getUnpackedValueOrDefault("Window" , css::uno::Reference< css::awt::XWindow >() ); + m_bAllowParentShow = lArgs.getUnpackedValueOrDefault("AllowParentShow" , (sal_Bool)sal_False ); + m_bDisableReschedule = lArgs.getUnpackedValueOrDefault("DisableReschedule", (sal_Bool)sal_False ); + + aWriteLock.unlock(); + // <- SAFE ---------------------------------- + } + } impl_createProgress(); } diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index ba54b20608f5..4cf109d76a17 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/task/StatusIndicatorFactory.hpp> #include <com/sun/star/task/JobExecutor.hpp> #include <com/sun/star/task/XJobExecutor.hpp> #include <com/sun/star/util/URLTransformer.hpp> @@ -564,17 +565,8 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >& // create progress helper css::uno::Reference< css::frame::XFrame > xThis (static_cast< css::frame::XFrame* >(this) , css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory(xSMGR->createInstance(IMPLEMENTATIONNAME_STATUSINDICATORFACTORY), css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::lang::XInitialization > xIndicatorInit (xIndicatorFactory , css::uno::UNO_QUERY_THROW); - css::uno::Sequence< css::uno::Any > lArgs(2); - css::beans::NamedValue aArg; - aArg.Name = STATUSINDICATORFACTORY_PROPNAME_FRAME; - aArg.Value <<= xThis; - lArgs[0] <<= aArg; - aArg.Name = STATUSINDICATORFACTORY_PROPNAME_ALLOWPARENTSHOW; - aArg.Value <<= sal_True; - lArgs[1] <<= aArg; - xIndicatorInit->initialize(lArgs); + css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory = + css::task::StatusIndicatorFactory::createWithFrame(comphelper::getComponentContext(xSMGR), xThis, sal_False/*DisableReschedule*/, sal_True/*AllowParentShow*/ ); // SAFE -> ---------------------------------- aWriteLock.lock(); diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index f101ef1cbee9..35e14bc20120 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -305,7 +305,7 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement { try { - MenuConfiguration aMenuCfg( m_xServiceManager ); + MenuConfiguration aMenuCfg( comphelper::getComponentContext(m_xServiceManager) ); Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream )); RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer ); if ( pRootItemContainer ) @@ -446,7 +446,7 @@ void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorag { try { - MenuConfiguration aMenuCfg( m_xServiceManager ); + MenuConfiguration aMenuCfg( comphelper::getComponentContext(m_xServiceManager) ); aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream ); } catch ( const ::com::sun::star::lang::WrappedTargetException& ) diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx index 7c2c3c6732da..8f3224f65f63 100644 --- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx @@ -81,7 +81,7 @@ DEFINE_XTYPEPROVIDER_7 ( UIConfigurationManager ::com::sun::star::ui::XUIConfigurationStorage ) -DEFINE_XSERVICEINFO_MULTISERVICE ( UIConfigurationManager , +DEFINE_XSERVICEINFO_MULTISERVICE_2 ( UIConfigurationManager , ::cppu::OWeakObject , SERVICENAME_UICONFIGURATIONMANAGER , IMPLEMENTATIONNAME_UICONFIGURATIONMANAGER @@ -243,7 +243,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, { try { - MenuConfiguration aMenuCfg( m_xServiceManager ); + MenuConfiguration aMenuCfg( m_xContext ); Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream )); RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer ); if ( pRootItemContainer ) @@ -268,7 +268,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, try { Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); - ToolBoxConfiguration::LoadToolBox( comphelper::getComponentContext(m_xServiceManager), xInputStream, xIndexContainer ); + ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer ); RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer ); aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); return; @@ -285,7 +285,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, try { Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY ); - StatusBarConfiguration::LoadStatusBar( comphelper::getComponentContext(m_xServiceManager), xInputStream, xIndexContainer ); + StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer ); RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer ); aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY ); return; @@ -375,7 +375,7 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& x { try { - MenuConfiguration aMenuCfg( m_xServiceManager ); + MenuConfiguration aMenuCfg( m_xContext ); aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream ); } catch ( const ::com::sun::star::lang::WrappedTargetException& ) @@ -388,7 +388,7 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& x { try { - ToolBoxConfiguration::StoreToolBox( comphelper::getComponentContext(m_xServiceManager), xOutputStream, rElement.xSettings ); + ToolBoxConfiguration::StoreToolBox( m_xContext, xOutputStream, rElement.xSettings ); } catch ( const ::com::sun::star::lang::WrappedTargetException& ) { @@ -400,7 +400,7 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& x { try { - StatusBarConfiguration::StoreStatusBar( comphelper::getComponentContext(m_xServiceManager), xOutputStream, rElement.xSettings ); + StatusBarConfiguration::StoreStatusBar( m_xContext, xOutputStream, rElement.xSettings ); } catch ( const ::com::sun::star::lang::WrappedTargetException& ) { @@ -578,7 +578,7 @@ void UIConfigurationManager::impl_Initialize() } } -UIConfigurationManager::UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) : +UIConfigurationManager::UIConfigurationManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext ) : ThreadHelpBase( &Application::GetSolarMutex() ) , m_xDocConfigStorage( 0 ) , m_bReadOnly( true ) @@ -588,7 +588,7 @@ UIConfigurationManager::UIConfigurationManager( com::sun::star::uno::Reference< , m_aXMLPostfix( ".xml" ) , m_aPropUIName( "UIName" ) , m_aPropResourceURL( "ResourceURL" ) - , m_xServiceManager( xServiceManager ) + , m_xContext( rxContext ) , m_aListenerContainer( m_aLock.getShareableOslMutex() ) { // Make sure we have a default initialized entry for every layer and user interface element type! @@ -1050,7 +1050,9 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager() throw if ( !m_xImageManager.is() ) { - m_xImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ImageManager( m_xServiceManager )), + Reference<XMultiServiceFactory> xMSF(m_xContext->getServiceManager(), UNO_QUERY_THROW); + + m_xImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ImageManager( xMSF )), UNO_QUERY ); Reference< XInitialization > xInit( m_xImageManager, UNO_QUERY ); @@ -1077,7 +1079,7 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getShortCutManager() th if (m_xAccConfig.is()) return m_xAccConfig; - Reference< XMultiServiceFactory > xSMGR = m_xServiceManager; + Reference<XMultiServiceFactory> xSMGR(m_xContext->getServiceManager(), UNO_QUERY_THROW); Reference< XStorage > xDocumentRoot = m_xDocConfigStorage; aGuard.unlock(); diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 867a890a5e29..bddc886594b0 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -326,7 +326,7 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopup if ( pVCLPopupMenu ) { - MenuConfiguration aMenuCfg( m_xServiceManager ); + MenuConfiguration aMenuCfg( comphelper::getComponentContext(m_xServiceManager) ); BmkMenu* pSubMenu( 0 ); if ( m_bNewMenu ) diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 81968bbae7bd..0f91b61ed048 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -325,6 +325,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/task,\ OfficeRestartManager \ PasswordContainer \ PasswordContainerInteractionHandler \ + StatusIndicatorFactory \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/text,\ DefaultNumberingProvider \ diff --git a/offapi/com/sun/star/task/StatusIndicatorFactory.idl b/offapi/com/sun/star/task/StatusIndicatorFactory.idl new file mode 100644 index 000000000000..cc2c7497d1ae --- /dev/null +++ b/offapi/com/sun/star/task/StatusIndicatorFactory.idl @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef __com_sun_star_task_StatusIndicatorFactory_idl__ +#define __com_sun_star_task_StatusIndicatorFactory_idl__ + +#include <com/sun/star/awt/XWindow.idl> +#include <com/sun/star/frame/XFrame.idl> +#include <com/sun/star/task/XStatusIndicatorFactory.idl> + + + module com { module sun { module star { module task { + +/** + @since LibreOffice 4.1 + */ +service StatusIndicatorFactory : XStatusIndicatorFactory +{ + createWithFrame( [in] com::sun::star::frame::XFrame Frame, [in] boolean DisableReschedule, [in] boolean AllowParentShow ); + + createWithWindow( [in] com::sun::star::awt::XWindow ParentWindow, [in] boolean DisableReschedule, [in] boolean AllowParentShow ); +}; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index 81f186c3e541..87b3a88a3294 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -766,8 +766,7 @@ void SfxVirtualMenu::UnbindControllers() void SfxVirtualMenu::InsertAddOnsMenuItem( Menu* pMenu ) { // Create special popup menu that is filled with the 3rd party components popup menu items - Reference<com::sun::star::lang::XMultiServiceFactory> aXMultiServiceFactory(::comphelper::getProcessServiceFactory()); - ::framework::MenuConfiguration aConf( aXMultiServiceFactory ); + ::framework::MenuConfiguration aConf( ::comphelper::getProcessComponentContext() ); Reference<com::sun::star::frame::XFrame> xFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() ); PopupMenu* pAddonMenu = NULL; diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index bf7003d36c54..fe863b0b7e58 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -1485,7 +1485,7 @@ SfxPopupWindow* SfxAppToolBoxControl_Impl::CreatePopupWindow() if ( !pMenu ) { - ::framework::MenuConfiguration aConf( m_xServiceManager ); + ::framework::MenuConfiguration aConf( comphelper::getComponentContext(m_xServiceManager) ); if ( m_aCommandURL == ".uno:AddDirect" ) pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU ); else @@ -1552,7 +1552,7 @@ void SfxAppToolBoxControl_Impl::StateChanged // to check for supported URLs ... if ( !pMenu ) { - ::framework::MenuConfiguration aConf( m_xServiceManager ); + ::framework::MenuConfiguration aConf( comphelper::getComponentContext(m_xServiceManager) ); // This toolbox controller is used for two popup menus (new documents and wizards!). Create the correct // popup menu according to the slot ID our controller has been initialized with. if ( nSlotId == SID_NEWDOCDIRECT ) diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index ffed312864dd..64c9a81e6c9f 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -33,7 +33,7 @@ #include <com/sun/star/embed/StateChangeInProgressException.hpp> #include <com/sun/star/embed/XLinkageSupport.hpp> #include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/task/StatusIndicatorFactory.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/embed/EmbedMisc.hpp> @@ -231,7 +231,7 @@ void SAL_CALL SfxInPlaceClient_Impl::saveObject() uno::Reference< frame::XFrame > xFrame; uno::Reference< task::XStatusIndicator > xStatusIndicator; uno::Reference< frame::XModel > xModel( m_xObject->getComponent(), uno::UNO_QUERY ); - uno::Reference< lang::XMultiServiceFactory > xSrvMgr( ::comphelper::getProcessServiceFactory() ); + uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); if ( xModel.is() ) { @@ -240,29 +240,18 @@ void SAL_CALL SfxInPlaceClient_Impl::saveObject() xFrame = xController->getFrame(); } - if ( xSrvMgr.is() && xFrame.is() ) + if ( xFrame.is() ) { // set non-reschedule progress to prevent problems when asynchronous calls are made // during storing of the embedded object - uno::Reference< lang::XInitialization > xInit( - xSrvMgr->createInstance( "com.sun.star.comp.framework.StatusIndicatorFactory" ), uno::UNO_QUERY_THROW ); - beans::PropertyValue aProperty; - uno::Sequence< uno::Any > aArgs( 2 ); - aProperty.Name = "DisableReschedule"; - aProperty.Value = uno::makeAny( sal_True ); - aArgs[0] = uno::makeAny( aProperty ); - aProperty.Name = "Frame"; - aProperty.Value = uno::makeAny( xFrame ); - aArgs[1] = uno::makeAny( aProperty ); - - xInit->initialize( aArgs ); + uno::Reference< task::XStatusIndicatorFactory > xStatusIndicatorFactory = + task::StatusIndicatorFactory::createWithFrame( xContext, xFrame, sal_True/*DisableReschedule*/, sal_False/*AllowParentShow*/ ); uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY ); if ( xPropSet.is() ) { try { - uno::Reference< task::XStatusIndicatorFactory > xStatusIndicatorFactory( xInit, uno::UNO_QUERY_THROW ); xStatusIndicator = xStatusIndicatorFactory->createStatusIndicator(); xPropSet->setPropertyValue( "IndicatorInterception" , uno::makeAny( xStatusIndicator )); } diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx index 2d8d4b46bc7e..d696568cc509 100644 --- a/svx/source/dialog/docrecovery.cxx +++ b/svx/source/dialog/docrecovery.cxx @@ -598,25 +598,12 @@ PluginProgressWindow::~PluginProgressWindow() } //=============================================== -PluginProgress::PluginProgress( Window* pParent, - const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ) +PluginProgress::PluginProgress( Window* pParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext ) { m_pPlugProgressWindow = new PluginProgressWindow(pParent, static_cast< css::lang::XComponent* >(this)); css::uno::Reference< css::awt::XWindow > xProgressWindow = VCLUnoHelper::GetInterface(m_pPlugProgressWindow); - m_xProgressFactory = css::uno::Reference< css::task::XStatusIndicatorFactory >(xSMGR->createInstance(SERVICENAME_PROGRESSFACTORY), css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::lang::XInitialization > xInit(m_xProgressFactory, css::uno::UNO_QUERY_THROW); - - css::uno::Sequence< css::uno::Any > lArgs(2); - css::beans::NamedValue aProp; - aProp.Name = PROP_PARENTWINDOW; - aProp.Value <<= xProgressWindow; - lArgs[0] <<= aProp; - aProp.Name = PROP_ALLOWPARENTSHOW; - aProp.Value <<= sal_True; - lArgs[1] <<= aProp; - - xInit->initialize(lArgs); - + m_xProgressFactory = css::task::StatusIndicatorFactory::createWithWindow(xContext, xProgressWindow, sal_False/*DisableReschedule*/, sal_True/*AllowParentShow*/); m_xProgress = m_xProgressFactory->createStatusIndicator(); } @@ -789,7 +776,7 @@ SaveProgressDialog::SaveProgressDialog(Window* pParent, , m_pCore ( pCore ) { FreeResource(); - PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, css::uno::Reference<css::lang::XMultiServiceFactory>(pCore->getComponentContext()->getServiceManager(), css::uno::UNO_QUERY_THROW) ); + PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, pCore->getComponentContext() ); m_xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW); } @@ -998,7 +985,7 @@ RecoveryDialog::RecoveryDialog(Window* pParent, aVal >>= bCrashRepEnabled; m_bRecoveryOnly = !bCrashRepEnabled; - PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, css::uno::Reference<css::lang::XMultiServiceFactory>(pCore->getComponentContext()->getServiceManager(), css::uno::UNO_QUERY_THROW) ); + PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, pCore->getComponentContext() ); m_xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW); const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); diff --git a/svx/source/inc/docrecovery.hxx b/svx/source/inc/docrecovery.hxx index d4ba999647e2..51f312e2411a 100644 --- a/svx/source/inc/docrecovery.hxx +++ b/svx/source/inc/docrecovery.hxx @@ -32,7 +32,7 @@ #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> -#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/task/StatusIndicatorFactory.hpp> #include <com/sun/star/frame/XStatusListener.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -50,14 +50,10 @@ #define RECOVERY_CMD_DO_ENTRY_BACKUP rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.autorecovery:/doEntryBackup" )) #define RECOVERY_CMD_DO_ENTRY_CLEANUP rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.autorecovery:/doEntryCleanUp" )) -#define SERVICENAME_PROGRESSFACTORY rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.StatusIndicatorFactory")) - -#define PROP_PARENTWINDOW rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Window" )) #define PROP_STATUSINDICATOR rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" )) #define PROP_DISPATCHASYNCHRON rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DispatchAsynchron")) #define PROP_SAVEPATH rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "SavePath" )) #define PROP_ENTRYID rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "EntryID" )) -#define PROP_ALLOWPARENTSHOW rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "AllowParentShow" )) #define STATEPROP_ID rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ID" )) #define STATEPROP_STATE rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DocumentState")) @@ -337,8 +333,8 @@ class PluginProgress : public ::cppu::WeakImplHelper2< css::task::XStatusIndicat //--------------------------------------- /** @short TODO */ - PluginProgress( Window* pParent, - const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ); + PluginProgress( Window* pParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext ); //--------------------------------------- /** @short TODO */ |