diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-30 14:02:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-10-31 15:31:36 +0100 |
commit | 0ac9a10d312dc8f12a74720ce211823ce4addf7b (patch) | |
tree | 2c812432eca9315170af8b5b6b7ae5bcbf828d5b /framework | |
parent | d27c92961b78da138d3563ab596cca416af9eb38 (diff) |
fdo#46808, Deprecate configuration::ConfigurationProvider old-style service
...in favor of existing new-style configuration::theDefaultProvider singleton.
Theoretically, ConfigurationProvider instances can be created with specific
Locale and EnableAsync arguments, but this is hardly used in practice, and thus
effectively all uses of the ConfigurationProvider service use the
theDefaultProvider instance, anyway.
theDefaultProvider is restricted to the XMultiServiceFactory interface, while
ConfigurationProvider also makes available XComponent. However, dispose must
not be called manually on theDefaultProvider singleton anyway, and calls to
add-/removeEventListener are so few (and in dubious code that should better be
cleaned up) that requiring an explicit queryInterface does not really hurt
there.
This commit originated as a patch by Noel Grandin to "Adapt
configuration::ConfigurationProvider UNO service to new style [by creating] a
merged XConfigurationProvider interface for this service to implement." It was
then modified by Stephan Bergmann by deprecating ConfigurationProvider instead
of adding XConfigurationProvider and by replacing calls to
ConfigurationProvider::create with calls to theDefaultProvider::get.
Change-Id: I9c16700afe0faff1ef6f20338a66bd7a9af990bd
Diffstat (limited to 'framework')
34 files changed, 216 insertions, 221 deletions
diff --git a/framework/inc/jobs/configaccess.hxx b/framework/inc/jobs/configaccess.hxx index 30ef4f2a47d8..dd9386a19630 100644 --- a/framework/inc/jobs/configaccess.hxx +++ b/framework/inc/jobs/configaccess.hxx @@ -25,6 +25,7 @@ #include <general.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <rtl/ustring.hxx> #include <fwidllapi.h> @@ -65,7 +66,7 @@ class FWI_DLLPUBLIC ConfigAccess : public ThreadHelpBase reference to the uno service manager It's neccessary to instanciate own needed services. */ - css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + css::uno::Reference< css::uno::XComponentContext > m_xContext; /** hold an opened configuration alive */ css::uno::Reference< css::uno::XInterface > m_xConfig; @@ -81,8 +82,8 @@ class FWI_DLLPUBLIC ConfigAccess : public ThreadHelpBase public: - ConfigAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , - const ::rtl::OUString& sRoot ); + ConfigAccess( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const ::rtl::OUString& sRoot ); virtual ~ConfigAccess(); virtual void open ( EOpenMode eMode ); diff --git a/framework/inc/jobs/jobdata.hxx b/framework/inc/jobs/jobdata.hxx index acb107d9d8ac..5ca4691abb12 100644 --- a/framework/inc/jobs/jobdata.hxx +++ b/framework/inc/jobs/jobdata.hxx @@ -28,6 +28,7 @@ #include <general.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/frame/DispatchResultEvent.hpp> @@ -152,7 +153,7 @@ class JobData : private ThreadHelpBase We need it for creating of own uno services ... e.g. for opening the configuration. */ - css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + css::uno::Reference< css::uno::XComponentContext > m_xContext; /** An instance of this class can be used in two different modes: @@ -224,7 +225,7 @@ class JobData : private ThreadHelpBase public: - JobData( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ); + JobData( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); JobData( const JobData& rCopy ); virtual ~JobData( ); @@ -250,10 +251,10 @@ class JobData : private ThreadHelpBase void setResult ( const JobResult& aResult ); void disableJob ( ); - static css::uno::Sequence< ::rtl::OUString > getEnabledJobsForEvent( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , - const ::rtl::OUString& sEvent ); + static css::uno::Sequence< ::rtl::OUString > getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const ::rtl::OUString& sEvent ); - static void appendEnabledJobsForEvent( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , + static void appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const ::rtl::OUString& sEvent , ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding >& lJobs ); diff --git a/framework/inc/macros/xserviceinfo.hxx b/framework/inc/macros/xserviceinfo.hxx index bcca5c25f6a0..6197bd3cec98 100644 --- a/framework/inc/macros/xserviceinfo.hxx +++ b/framework/inc/macros/xserviceinfo.hxx @@ -225,6 +225,10 @@ ________________________________________________________________________________ PRIVATE_DEFINE_XSERVICEINFO_NEWSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ PRIVATE_DEFINE_SINGLEFACTORY( CLASS ) +#define DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_NEWSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_ONEINSTANCEFACTORY( CLASS ) + //***************************************************************************************************************** // public // implementation of service initialize! diff --git a/framework/inc/services.h b/framework/inc/services.h index ccb8bfb0e2b1..e32de32c1ed3 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -41,7 +41,6 @@ namespace framework{ #define SERVICENAME_GENERICFRAMELOADER DECLARE_ASCII("com.sun.star.comp.office.FilterDetect" ) #define SERVICENAME_TYPEDETECTION DECLARE_ASCII("com.sun.star.document.TypeDetection" ) #define SERVICENAME_CFGREGISTRY DECLARE_ASCII("com.sun.star.configuration.ConfigurationRegistry" ) // describe simple registry service for read access to configuration -#define SERVICENAME_CFGPROVIDER DECLARE_ASCII("com.sun.star.configuration.ConfigurationProvider" ) // describe cfg-provider service for fatoffice, network installation #define SERVICENAME_ADMINPROVIDER DECLARE_ASCII("com.sun.star.configuration.AdministrationProvider" ) // describe cfg-provider service for sun webtop #define SERVICENAME_CFGUPDATEACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationUpdateAccess") // provides read/write access to the configuration #define SERVICENAME_CFGREADACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationAccess" ) // provides readonly access to the configuration diff --git a/framework/inc/services/license.hxx b/framework/inc/services/license.hxx index b0bb81f11f06..399b07ce6e24 100644 --- a/framework/inc/services/license.hxx +++ b/framework/inc/services/license.hxx @@ -69,10 +69,10 @@ namespace framework public ::cppu::OWeakObject // => XWeak, XInterface { private: - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::uno::XComponentContext > m_xContext; sal_Bool m_bTerminate; public: - License( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMGR ); + License( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext ); virtual ~License(); /** declaration of XInterface, XTypeProvider, XServiceInfo */ diff --git a/framework/inc/uiconfiguration/globalsettings.hxx b/framework/inc/uiconfiguration/globalsettings.hxx index 49f39b1f3ca7..3b253d8100f0 100644 --- a/framework/inc/uiconfiguration/globalsettings.hxx +++ b/framework/inc/uiconfiguration/globalsettings.hxx @@ -47,7 +47,7 @@ namespace framework class GlobalSettings { public: - GlobalSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSrvMgr ); + GlobalSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); ~GlobalSettings(); enum UIElementType @@ -72,7 +72,7 @@ class GlobalSettings GlobalSettings(const GlobalSettings&); GlobalSettings& operator=(const GlobalSettings& ); - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSrvMgr; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; }; } // namespace framework diff --git a/framework/inc/uiconfiguration/uicategorydescription.hxx b/framework/inc/uiconfiguration/uicategorydescription.hxx index 028452fb300b..bb3e73660f5b 100644 --- a/framework/inc/uiconfiguration/uicategorydescription.hxx +++ b/framework/inc/uiconfiguration/uicategorydescription.hxx @@ -43,7 +43,7 @@ namespace framework class UICategoryDescription : public UICommandDescription { public: - UICategoryDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + UICategoryDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); virtual ~UICategoryDescription(); DECLARE_XSERVICEINFO diff --git a/framework/inc/uiconfiguration/windowstateconfiguration.hxx b/framework/inc/uiconfiguration/windowstateconfiguration.hxx index 61cc1c3cf169..d254d8d4005d 100644 --- a/framework/inc/uiconfiguration/windowstateconfiguration.hxx +++ b/framework/inc/uiconfiguration/windowstateconfiguration.hxx @@ -75,7 +75,7 @@ class WindowStateConfiguration : private ThreadHelpBase public ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameAccess, css::lang::XServiceInfo> { public: - WindowStateConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + WindowStateConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); virtual ~WindowStateConfiguration(); // XInterface, XTypeProvider, XServiceInfo @@ -110,7 +110,7 @@ class WindowStateConfiguration : private ThreadHelpBase ::std::equal_to< ::rtl::OUString > > ModuleToWindowStateConfigHashMap; private: - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext; ModuleToWindowStateFileMap m_aModuleToFileHashMap; ModuleToWindowStateConfigHashMap m_aModuleToWindowStateHashMap; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; diff --git a/framework/inc/uielement/uicommanddescription.hxx b/framework/inc/uielement/uicommanddescription.hxx index 601b1c3e7531..9f14a97c1875 100644 --- a/framework/inc/uielement/uicommanddescription.hxx +++ b/framework/inc/uielement/uicommanddescription.hxx @@ -45,6 +45,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/frame/XModuleManager2.hpp> @@ -58,7 +59,7 @@ class UICommandDescription : private ThreadHelpBase , com::sun::star::container::XNameAccess > { public: - UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); virtual ~UICommandDescription(); // XInterface, XTypeProvider, XServiceInfo @@ -92,12 +93,12 @@ public: ::std::equal_to< ::rtl::OUString > > UICommandsHashMap; protected: - UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager,bool ); + UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, bool ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > impl_createConfigAccess(const ::rtl::OUString& _sName); void impl_fillElements(const sal_Char* _pName); sal_Bool m_bConfigRead; rtl::OUString m_aPrivateResourceURL; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ModuleToCommandFileMap m_aModuleToCommandFileMap; UICommandsHashMap m_aUICommandsHashMap; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xGenericUICommands; diff --git a/framework/inc/uifactory/factoryconfiguration.hxx b/framework/inc/uifactory/factoryconfiguration.hxx index d055fd6ee87e..9a2658c93cde 100644 --- a/framework/inc/uifactory/factoryconfiguration.hxx +++ b/framework/inc/uifactory/factoryconfiguration.hxx @@ -60,7 +60,7 @@ class ConfigurationAccess_ControllerFactory : // interfaces public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener> { public: - ConfigurationAccess_ControllerFactory( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot,bool _bAskValue = false ); + ConfigurationAccess_ControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const ::rtl::OUString& _sRoot,bool _bAskValue = false ); virtual ~ConfigurationAccess_ControllerFactory(); void readConfigurationData(); @@ -107,7 +107,6 @@ private: rtl::OUString m_aPropValue; rtl::OUString m_sRoot; MenuControllerMap m_aMenuControllerMap; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess; ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigAccessListener; diff --git a/framework/inc/uifactory/uielementfactorymanager.hxx b/framework/inc/uifactory/uielementfactorymanager.hxx index 16672532b473..1f403e88e8b2 100644 --- a/framework/inc/uifactory/uielementfactorymanager.hxx +++ b/framework/inc/uifactory/uielementfactorymanager.hxx @@ -63,7 +63,7 @@ namespace framework public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener> { public: - ConfigurationAccess_FactoryManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot ); + ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const ::rtl::OUString& _sRoot ); virtual ~ConfigurationAccess_FactoryManager(); void readConfigurationData(); @@ -101,7 +101,6 @@ namespace framework rtl::OUString m_aPropFactory; ::rtl::OUString m_sRoot; FactoryManagerMap m_aFactoryManagerMap; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess; ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigListener; @@ -115,7 +114,7 @@ class UIElementFactoryManager : private ThreadHelpBase ::com::sun::star::ui::XUIElementFactoryRegistration> { public: - UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); virtual ~UIElementFactoryManager(); // XInterface, XTypeProvider, XServiceInfo @@ -133,7 +132,7 @@ class UIElementFactoryManager : private ThreadHelpBase private: sal_Bool m_bConfigRead; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; ConfigurationAccess_FactoryManager* m_pConfigAccess; }; diff --git a/framework/inc/uifactory/windowcontentfactorymanager.hxx b/framework/inc/uifactory/windowcontentfactorymanager.hxx index 5facbbd73608..c189218a32a3 100644 --- a/framework/inc/uifactory/windowcontentfactorymanager.hxx +++ b/framework/inc/uifactory/windowcontentfactorymanager.hxx @@ -49,7 +49,7 @@ class WindowContentFactoryManager : private ThreadHelpBase com::sun::star::lang::XSingleComponentFactory> { public: - WindowContentFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + WindowContentFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext ); virtual ~WindowContentFactoryManager(); // XInterface, XTypeProvider, XServiceInfo @@ -63,7 +63,6 @@ class WindowContentFactoryManager : private ThreadHelpBase private: sal_Bool m_bConfigRead; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; ConfigurationAccess_FactoryManager* m_pConfigAccess; }; diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index eef8c1dd94cc..7ed41e9fd57e 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -624,7 +624,7 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteA aReadLock.unlock(); // <- SAFE ---------------------------------- - css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig(xSMGR, + css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig( comphelper::getComponentContext(xSMGR), "/org.openoffice.Setup", "L10N", fpc::ConfigurationHelper::E_READONLY); css::uno::Reference< css::beans::XPropertySet > xProp (xCFG, css::uno::UNO_QUERY_THROW); ::rtl::OUString sISOLocale; @@ -1663,7 +1663,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bPrefer aReadLock.unlock(); // <- SAFE ---------------------------------- - css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig(xSMGR, + css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig( comphelper::getComponentContext(xSMGR), "/org.openoffice.Setup", "L10N", fpc::ConfigurationHelper::E_READONLY); css::uno::Reference< css::beans::XPropertySet > xProp (xCFG, css::uno::UNO_QUERY_THROW); ::rtl::OUString sISOLocale; diff --git a/framework/source/fwi/jobs/configaccess.cxx b/framework/source/fwi/jobs/configaccess.cxx index 1e23ed32e243..14d6e762b64c 100644 --- a/framework/source/fwi/jobs/configaccess.cxx +++ b/framework/source/fwi/jobs/configaccess.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/util/XChangesBatch.hpp> @@ -55,10 +56,10 @@ namespace framework{ @param eMode force opening of the configuration access in readonly or in read/write mode */ -ConfigAccess::ConfigAccess( /*IN*/ const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , - /*IN*/ const ::rtl::OUString& sRoot ) +ConfigAccess::ConfigAccess( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& rxContext, + /*IN*/ const ::rtl::OUString& sRoot ) : ThreadHelpBase( ) - , m_xSMGR ( xSMGR ) + , m_xContext ( rxContext) , m_sRoot ( sRoot ) , m_eMode ( E_CLOSED ) { @@ -129,35 +130,32 @@ void ConfigAccess::open( /*IN*/ EOpenMode eMode ) close(); // create the configuration provider, which provides sub access points - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(m_xSMGR->createInstance(SERVICENAME_CFGPROVIDER), css::uno::UNO_QUERY); - if (xConfigProvider.is()) + css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider = css::configuration::theDefaultProvider::get(m_xContext); + css::beans::PropertyValue aParam; + aParam.Name = DECLARE_ASCII("nodepath"); + aParam.Value <<= m_sRoot; + + css::uno::Sequence< css::uno::Any > lParams(1); + lParams[0] <<= aParam; + + // open it + try { - css::beans::PropertyValue aParam; - aParam.Name = DECLARE_ASCII("nodepath"); - aParam.Value <<= m_sRoot; - - css::uno::Sequence< css::uno::Any > lParams(1); - lParams[0] <<= aParam; - - // open it - try - { - if (eMode==E_READONLY) - m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS , lParams); - else - if (eMode==E_READWRITE) - m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGUPDATEACCESS, lParams); - } - catch(const css::uno::Exception& ex) - { - (void) ex; // avoid warning - LOG_WARNING("open config ...", U2B(ex.Message)) - } - - m_eMode = E_CLOSED; - if (m_xConfig.is()) - m_eMode = eMode; + if (eMode==E_READONLY) + m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS , lParams); + else + if (eMode==E_READWRITE) + m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGUPDATEACCESS, lParams); } + catch(const css::uno::Exception& ex) + { + (void) ex; // avoid warning + LOG_WARNING("open config ...", U2B(ex.Message)) + } + + m_eMode = E_CLOSED; + if (m_xConfig.is()) + m_eMode = eMode; } aWriteLock.unlock(); diff --git a/framework/source/inc/pattern/configuration.hxx b/framework/source/inc/pattern/configuration.hxx index f39d5922328b..3b346a3693f3 100644 --- a/framework/source/inc/pattern/configuration.hxx +++ b/framework/source/inc/pattern/configuration.hxx @@ -36,6 +36,7 @@ #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -80,7 +81,7 @@ class ConfigurationHelper @descr TODO - @param xSMGR + @param rxContext this method need an uno service manager for internal work. @param sPackage @@ -100,7 +101,7 @@ class ConfigurationHelper force opening of the configuration access in special mode. see enum EOpenMode for further informations. */ - static css::uno::Reference< css::uno::XInterface > openConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , + static css::uno::Reference< css::uno::XInterface > openConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext, const ::rtl::OUString& sPackage , const ::rtl::OUString& sRelPath , sal_Int32 nOpenFlags) @@ -109,8 +110,8 @@ class ConfigurationHelper try { - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( - xSMGR->createInstance(SERVICENAME_CFGPROVIDER), css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider = + css::configuration::theDefaultProvider::get( rxContext ); ::rtl::OUStringBuffer sPath(1024); sPath.append(sPackage ); diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx index cc881a4d424d..4c6bfee6f01f 100644 --- a/framework/source/jobs/job.cxx +++ b/framework/source/jobs/job.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <comphelper/processfactory.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> @@ -76,7 +77,7 @@ Job::Job( /*IN*/ const css::uno::Reference< css::lang::XMultiServiceFactory >& x /*IN*/ const css::uno::Reference< css::frame::XFrame >& xFrame ) : ThreadHelpBase (&Application::GetSolarMutex()) , ::cppu::OWeakObject ( ) - , m_aJobCfg (xSMGR ) + , m_aJobCfg (comphelper::getComponentContext(xSMGR)) , m_xSMGR (xSMGR ) , m_xFrame (xFrame ) , m_bListenOnDesktop (sal_False ) @@ -106,7 +107,7 @@ Job::Job( /*IN*/ const css::uno::Reference< css::lang::XMultiServiceFactory >& x /*IN*/ const css::uno::Reference< css::frame::XModel >& xModel ) : ThreadHelpBase (&Application::GetSolarMutex()) , ::cppu::OWeakObject ( ) - , m_aJobCfg (xSMGR ) + , m_aJobCfg (comphelper::getComponentContext(xSMGR)) , m_xSMGR (xSMGR ) , m_xModel (xModel ) , m_bListenOnDesktop (sal_False ) diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index 6195d0c18b31..fe1b1bd4e895 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -79,12 +79,12 @@ const sal_Char* JobData::PROP_CONTEXT = "Context" But for real working it's neccessary to call setAlias() or setService() later. Because we need the job data ... - @param xSMGR + @param rxContext reference to the uno service manager */ -JobData::JobData( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ) +JobData::JobData( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) : ThreadHelpBase(&Application::GetSolarMutex()) - , m_xSMGR (xSMGR ) + , m_xContext (rxContext ) { // share code for member initialization with defaults! impl_reset(); @@ -170,7 +170,7 @@ void JobData::setAlias( const ::rtl::OUString& sAlias ) ::rtl::OUString sKey(::rtl::OUString::createFromAscii(JOBCFG_ROOT)); sKey += ::utl::wrapConfigurationElementName(m_sAlias); - ConfigAccess aConfig(m_xSMGR, sKey); + ConfigAccess aConfig(m_xContext, sKey); aConfig.open(ConfigAccess::E_READONLY); if (aConfig.getMode()==ConfigAccess::E_CLOSED) { @@ -304,7 +304,7 @@ void JobData::setJobConfig( const css::uno::Sequence< css::beans::NamedValue >& ::rtl::OUString sKey(::rtl::OUString::createFromAscii(JOBCFG_ROOT)); sKey += ::utl::wrapConfigurationElementName(m_sAlias); - ConfigAccess aConfig(m_xSMGR, sKey); + ConfigAccess aConfig(m_xContext, sKey); aConfig.open(ConfigAccess::E_READWRITE); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return; @@ -537,7 +537,7 @@ void JobData::disableJob() sKey.appendAscii("/" ); sKey.append (::utl::wrapConfigurationElementName(m_sAlias)); - ConfigAccess aConfig(m_xSMGR, sKey.makeStringAndClear()); + ConfigAccess aConfig(m_xContext, sKey.makeStringAndClear()); aConfig.open(ConfigAccess::E_READWRITE); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return; @@ -585,11 +585,11 @@ sal_Bool isEnabled( const ::rtl::OUString& sAdminTime , //________________________________ /** */ -void JobData::appendEnabledJobsForEvent( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , +void JobData::appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const ::rtl::OUString& sEvent , ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding >& lJobs ) { - css::uno::Sequence< ::rtl::OUString > lAdditionalJobs = JobData::getEnabledJobsForEvent(xSMGR, sEvent); + css::uno::Sequence< ::rtl::OUString > lAdditionalJobs = JobData::getEnabledJobsForEvent(rxContext, sEvent); sal_Int32 c = lAdditionalJobs.getLength(); sal_Int32 i = 0; @@ -627,8 +627,8 @@ sal_Bool JobData::hasCorrectContext(const ::rtl::OUString& rModuleIdent) const //________________________________ /** */ -css::uno::Sequence< ::rtl::OUString > JobData::getEnabledJobsForEvent( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , - const ::rtl::OUString& sEvent ) +css::uno::Sequence< ::rtl::OUString > JobData::getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const ::rtl::OUString& sEvent ) { // these static values may perform following loop for reading time stamp values ... static ::rtl::OUString ADMINTIME = ::rtl::OUString::createFromAscii(JobData::EVENTCFG_PROP_ADMINTIME); @@ -637,7 +637,7 @@ css::uno::Sequence< ::rtl::OUString > JobData::getEnabledJobsForEvent( const css static ::rtl::OUString JOBLIST = ::rtl::OUString::createFromAscii(JobData::EVENTCFG_PATH_JOBLIST ); // create a config access to "/org.openoffice.Office.Jobs/Events" - ConfigAccess aConfig(xSMGR,ROOT); + ConfigAccess aConfig(rxContext,ROOT); aConfig.open(ConfigAccess::E_READONLY); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return css::uno::Sequence< ::rtl::OUString >(); diff --git a/framework/source/jobs/jobdispatch.cxx b/framework/source/jobs/jobdispatch.cxx index 8672062f1cd7..03aeca373d91 100644 --- a/framework/source/jobs/jobdispatch.cxx +++ b/framework/source/jobs/jobdispatch.cxx @@ -271,7 +271,7 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const ::rtl::OUString& // filter disabled jobs using it's time stamp values. /* SAFE { */ ReadGuard aReadLock(m_aLock); - css::uno::Sequence< ::rtl::OUString > lJobs = JobData::getEnabledJobsForEvent(m_xSMGR, sEvent); + css::uno::Sequence< ::rtl::OUString > lJobs = JobData::getEnabledJobsForEvent(comphelper::getComponentContext(m_xSMGR), sEvent); aReadLock.unlock(); /* } SAFE */ @@ -288,7 +288,7 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const ::rtl::OUString& /* SAFE { */ aReadLock.lock(); - JobData aCfg(m_xSMGR); + JobData aCfg(comphelper::getComponentContext(m_xSMGR)); aCfg.setEvent(sEvent, lJobs[j]); aCfg.setEnvironment(JobData::E_DISPATCH); const bool bIsEnabled=aCfg.hasCorrectContext(m_sModuleIdentifier); @@ -352,7 +352,7 @@ void JobDispatch::impl_dispatchService( /*IN*/ const ::rtl::OUString& /* SAFE { */ ReadGuard aReadLock(m_aLock); - JobData aCfg(m_xSMGR); + JobData aCfg(comphelper::getComponentContext(m_xSMGR)); aCfg.setService(sService); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -403,7 +403,7 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const ::rtl::OUString& /* SAFE { */ ReadGuard aReadLock(m_aLock); - JobData aCfg(m_xSMGR); + JobData aCfg(comphelper::getComponentContext(m_xSMGR)); aCfg.setAlias(sAlias); aCfg.setEnvironment(JobData::E_DISPATCH); diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 5df32396eded..e3e6c58c800b 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -126,7 +126,7 @@ JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::lang::XMultiSer , ::cppu::OWeakObject ( ) , m_xSMGR (xSMGR ) , m_xModuleManager ( ) - , m_aConfig (xSMGR, ::rtl::OUString::createFromAscii(JobData::EVENTCFG_ROOT) ) + , m_aConfig (comphelper::getComponentContext(xSMGR), ::rtl::OUString::createFromAscii(JobData::EVENTCFG_ROOT) ) { // Don't do any reference related code here! Do it inside special // impl_ method() ... see DEFINE_INIT_SERVICE() macro for further informations. @@ -166,7 +166,7 @@ void SAL_CALL JobExecutor::trigger( const ::rtl::OUString& sEvent ) throw(css::u // get list of all enabled jobs // The called static helper methods read it from the configuration and // filter disabled jobs using it's time stamp values. - css::uno::Sequence< ::rtl::OUString > lJobs = JobData::getEnabledJobsForEvent(m_xSMGR, sEvent); + css::uno::Sequence< ::rtl::OUString > lJobs = JobData::getEnabledJobsForEvent(comphelper::getComponentContext(m_xSMGR), sEvent); aReadLock.unlock(); /* } SAFE */ @@ -178,7 +178,7 @@ void SAL_CALL JobExecutor::trigger( const ::rtl::OUString& sEvent ) throw(css::u /* SAFE { */ aReadLock.lock(); - JobData aCfg(m_xSMGR); + JobData aCfg(comphelper::getComponentContext(m_xSMGR)); aCfg.setEvent(sEvent, lJobs[j]); aCfg.setEnvironment(JobData::E_EXECUTION); @@ -235,7 +235,7 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent ) { if (m_lEvents.find(EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end()) - JobData::appendEnabledJobsForEvent(m_xSMGR, EVENT_ON_DOCUMENT_OPENED, lJobs); + JobData::appendEnabledJobsForEvent(comphelper::getComponentContext(m_xSMGR), EVENT_ON_DOCUMENT_OPENED, lJobs); } // Special feature: If the events "OnCreate" or "OnLoadFinished" occures - we generate our own event "onDocumentAdded". @@ -245,12 +245,12 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent ) { if (m_lEvents.find(EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end()) - JobData::appendEnabledJobsForEvent(m_xSMGR, EVENT_ON_DOCUMENT_ADDED, lJobs); + JobData::appendEnabledJobsForEvent(comphelper::getComponentContext(m_xSMGR), EVENT_ON_DOCUMENT_ADDED, lJobs); } // Add all jobs for "real" notified event too .-) if (m_lEvents.find(aEvent.EventName) != m_lEvents.end()) - JobData::appendEnabledJobsForEvent(m_xSMGR, aEvent.EventName, lJobs); + JobData::appendEnabledJobsForEvent(comphelper::getComponentContext(m_xSMGR), aEvent.EventName, lJobs); aReadLock.unlock(); /* } SAFE */ @@ -266,7 +266,7 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent const JobData::TJob2DocEventBinding& rBinding = *pIt; - JobData aCfg(m_xSMGR); + JobData aCfg(comphelper::getComponentContext(m_xSMGR)); aCfg.setEvent(rBinding.m_sDocEvent, rBinding.m_sJobName); aCfg.setEnvironment(JobData::E_DOCUMENTEVENT); diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 37e08e6f5e79..b29960cca32d 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -164,7 +164,7 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM m_aStatusBarElement.m_aType = rtl::OUString( "statusbar" ); m_aStatusBarElement.m_aName = m_aStatusBarAlias; - m_pToolbarManager = new ToolbarLayoutManager( xServiceManager, m_xUIElementFactoryManager, this ); + m_pToolbarManager = new ToolbarLayoutManager( comphelper::getComponentContext(xServiceManager), m_xUIElementFactoryManager, this ); m_xToolbarManager = uno::Reference< ui::XUIConfigurationListener >( static_cast< OWeakObject* >( m_pToolbarManager ), uno::UNO_QUERY ); Application::AddEventListener( LINK( this, LayoutManager, SettingsChanged ) ); @@ -517,7 +517,7 @@ sal_Bool LayoutManager::implts_readWindowStateData( const rtl::OUString& aName, GlobalSettings* pGlobalSettings( 0 ); if ( m_pGlobalSettings == 0 ) { - m_pGlobalSettings = new GlobalSettings( m_xSMGR ); + m_pGlobalSettings = new GlobalSettings( comphelper::getComponentContext(m_xSMGR) ); bGetSettingsState = sal_True; } pGlobalSettings = m_pGlobalSettings; diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 0a67895c9b42..2bb41fe93235 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -56,11 +56,11 @@ namespace framework { ToolbarLayoutManager::ToolbarLayoutManager( - const uno::Reference< lang::XMultiServiceFactory >& xSMGR, + const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< ui::XUIElementFactory >& xUIElementFactory, ILayoutNotifications* pParentLayouter ) : ThreadHelpBase( &Application::GetSolarMutex() ), - m_xSMGR( xSMGR ), + m_xContext( rxContext), m_xUIElementFactoryManager( xUIElementFactory ), m_pParentLayouter( pParentLayouter ), m_eDockOperation( DOCKOP_ON_COLROW ), @@ -83,7 +83,7 @@ ToolbarLayoutManager::ToolbarLayoutManager( setZeroRectangle( m_aDockingArea ); // create toolkit object - m_xToolkit = awt::Toolkit::create( comphelper::getComponentContext(m_xSMGR) ); + m_xToolkit = awt::Toolkit::create( m_xContext ); } ToolbarLayoutManager::~ToolbarLayoutManager() @@ -913,10 +913,10 @@ void ToolbarLayoutManager::setParentWindow( { static const char DOCKINGAREASTRING[] = "dockingarea"; - uno::Reference< awt::XWindow > xTopDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( comphelper::getComponentContext(m_xSMGR), xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); - uno::Reference< awt::XWindow > xLeftDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( comphelper::getComponentContext(m_xSMGR), xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); - uno::Reference< awt::XWindow > xRightDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( comphelper::getComponentContext(m_xSMGR), xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); - uno::Reference< awt::XWindow > xBottomDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( comphelper::getComponentContext(m_xSMGR), xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); + uno::Reference< awt::XWindow > xTopDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xContext, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); + uno::Reference< awt::XWindow > xLeftDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xContext, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); + uno::Reference< awt::XWindow > xRightDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xContext, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); + uno::Reference< awt::XWindow > xBottomDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xContext, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); WriteGuard aWriteLock( m_aLock ); m_xContainerWindow = uno::Reference< awt::XWindow2 >( xParentWindow, uno::UNO_QUERY ); @@ -1582,7 +1582,7 @@ sal_Bool ToolbarLayoutManager::implts_readWindowStateData( const rtl::OUString& GlobalSettings* pGlobalSettings( 0 ); if ( m_pGlobalSettings.get() == 0 ) { - m_pGlobalSettings.reset( new GlobalSettings( m_xSMGR ) ); + m_pGlobalSettings.reset( new GlobalSettings( m_xContext ) ); bGetSettingsState = true; } pGlobalSettings = m_pGlobalSettings.get(); diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx index 2d4389428ea2..1237c147de4b 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx @@ -90,7 +90,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a PREVIEWFRAME_YES }; - ToolbarLayoutManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMGR, + ToolbarLayoutManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory >& xUIElementFactory, ILayoutNotifications* pParentLayouter ); virtual ~ToolbarLayoutManager(); @@ -299,7 +299,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a //--------------------------------------------------------------------------------------------------------- // members //--------------------------------------------------------------------------------------------------------- - css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< css::awt::XWindow2 > m_xContainerWindow; css::uno::Reference< css::awt::XWindow > m_xDockAreaWindows[DOCKINGAREAS_COUNT]; diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 34c2585e22f9..765c46575c3b 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -62,6 +62,7 @@ #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/container/XNameAccess.hpp" +#include "com/sun/star/configuration/theDefaultProvider.hpp" #include "com/sun/star/system/SystemShellExecute.hpp" #include "com/sun/star/system/SystemShellExecuteFlags.hpp" #include "com/sun/star/task/XJobExecutor.hpp" @@ -163,23 +164,20 @@ BackingWindow::BackingWindow( Window* i_pParent ) : try { - Reference<lang::XMultiServiceFactory> xConfig( comphelper::getProcessServiceFactory()->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY); - if( xConfig.is() ) + Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ); + Sequence<Any> args(1); + PropertyValue val( + rtl::OUString( "nodepath" ), + 0, + Any(rtl::OUString( "/org.openoffice.Office.Common/Help/StartCenter")), + PropertyState_DIRECT_VALUE); + args.getArray()[0] <<= val; + Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY); + if( xNameAccess.is() ) { - Sequence<Any> args(1); - PropertyValue val( - rtl::OUString( "nodepath" ), - 0, - Any(rtl::OUString( "/org.openoffice.Office.Common/Help/StartCenter")), - PropertyState_DIRECT_VALUE); - args.getArray()[0] <<= val; - Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY); - if( xNameAccess.is() ) - { - //throws css::container::NoSuchElementException, css::lang::WrappedTargetException - Any value( xNameAccess->getByName(rtl::OUString("StartCenterHideExternalLinks")) ); - mnHideExternalLinks = value.get<sal_Int32>(); - } + //throws css::container::NoSuchElementException, css::lang::WrappedTargetException + Any value( xNameAccess->getByName(rtl::OUString("StartCenterHideExternalLinks")) ); + mnHideExternalLinks = value.get<sal_Int32>(); } } catch (const Exception&) @@ -886,30 +884,27 @@ IMPL_LINK_NOARG(BackingWindow, ToolboxHdl) { try { - Reference<lang::XMultiServiceFactory> xConfig( comphelper::getProcessServiceFactory()->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY); - if( xConfig.is() ) + Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ); + Sequence<Any> args(1); + PropertyValue val( + rtl::OUString( "nodepath" ), + 0, + Any(rtl::OUString::createFromAscii(pNodePath)), + PropertyState_DIRECT_VALUE); + args.getArray()[0] <<= val; + Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY); + if( xNameAccess.is() ) { - Sequence<Any> args(1); - PropertyValue val( - rtl::OUString( "nodepath" ), - 0, - Any(rtl::OUString::createFromAscii(pNodePath)), - PropertyState_DIRECT_VALUE); - args.getArray()[0] <<= val; - Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY); - if( xNameAccess.is() ) - { - rtl::OUString sURL; - //throws css::container::NoSuchElementException, css::lang::WrappedTargetException - Any value( xNameAccess->getByName(rtl::OUString::createFromAscii(pNode)) ); - sURL = value.get<rtl::OUString> (); - localizeWebserviceURI(sURL); - - Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute( - com::sun::star::system::SystemShellExecute::create(comphelper::getProcessComponentContext())); - //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException - xSystemShellExecute->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY); - } + rtl::OUString sURL; + //throws css::container::NoSuchElementException, css::lang::WrappedTargetException + Any value( xNameAccess->getByName(rtl::OUString::createFromAscii(pNode)) ); + sURL = value.get<rtl::OUString> (); + localizeWebserviceURI(sURL); + + Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute( + com::sun::star::system::SystemShellExecute::create(comphelper::getProcessComponentContext())); + //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException + xSystemShellExecute->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY); } } catch (const Exception&) diff --git a/framework/source/services/license.cxx b/framework/source/services/license.cxx index 6dff1bf129e3..a7f435fffb63 100644 --- a/framework/source/services/license.cxx +++ b/framework/source/services/license.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/beans/NamedValue.hpp> @@ -64,6 +65,7 @@ using namespace ::osl ; using namespace ::cppu ; using namespace ::com::sun::star::uno ; using namespace ::com::sun::star::beans ; +using namespace ::com::sun::star::configuration ; using namespace ::com::sun::star::lang ; using namespace ::com::sun::star::util ; using namespace ::com::sun::star::frame ; @@ -81,7 +83,7 @@ static const char *szWNTLicenseExt = ".txt"; //***************************************************************************************************************** // constructor //***************************************************************************************************************** -License::License( const Reference< XMultiServiceFactory >& xFactory ) +License::License( const Reference< XComponentContext >& rxContext ) // Init baseclasses first // Attention: // Don't change order of initialization! @@ -91,7 +93,7 @@ License::License( const Reference< XMultiServiceFactory >& xFactory ) : ThreadHelpBase ( &Application::GetSolarMutex() ) , OWeakObject ( ) // Init member - , m_xFactory ( xFactory ) + , m_xContext ( rxContext ) , m_bTerminate ( sal_False ) { } @@ -122,7 +124,7 @@ DEFINE_XTYPEPROVIDER_4 ( License , XCloseable ) -DEFINE_XSERVICEINFO_MULTISERVICE ( License, +DEFINE_XSERVICEINFO_MULTISERVICE_2 ( License, OWeakObject , SERVICENAME_LICENSE , IMPLEMENTATIONNAME_LICENSE @@ -262,12 +264,10 @@ css::uno::Any SAL_CALL License::execute(const css::uno::Sequence< css::beans::Na #endif // check if we need to show the license at all // open org.openoffice.Setup/Office/ooLicenseAcceptDate - ::rtl::OUString sConfigSrvc = SERVICENAME_CFGPROVIDER; ::rtl::OUString sAccessSrvc("com.sun.star.configuration.ConfigurationUpdateAccess"); // get configuration provider - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( - m_xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); + Reference< XMultiServiceFactory > theConfigProvider = theDefaultProvider::get( m_xContext ); Sequence< Any > theArgs(1); NamedValue v; v.Name = ::rtl::OUString("NodePath"); diff --git a/framework/source/uiconfiguration/globalsettings.cxx b/framework/source/uiconfiguration/globalsettings.cxx index de8304da6534..4567c5ceddd9 100644 --- a/framework/source/uiconfiguration/globalsettings.cxx +++ b/framework/source/uiconfiguration/globalsettings.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -74,7 +75,7 @@ class GlobalSettings_Access : public ::com::sun::star::lang::XComponent , public ::cppu::OWeakObject { public: - GlobalSettings_Access( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + GlobalSettings_Access( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); virtual ~GlobalSettings_Access(); // XInterface, XTypeProvider, XServiceInfo @@ -103,7 +104,7 @@ class GlobalSettings_Access : public ::com::sun::star::lang::XComponent , rtl::OUString m_aPropLocked; rtl::OUString m_aPropDocked; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext; }; @@ -116,7 +117,7 @@ DEFINE_XINTERFACE_2 ( GlobalSettings_Access , DIRECT_INTERFACE ( css::lang::XEventListener ) ) -GlobalSettings_Access::GlobalSettings_Access( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) : +GlobalSettings_Access::GlobalSettings_Access( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) : ThreadHelpBase(), m_bDisposed( sal_False ), m_bConfigRead( sal_False ), @@ -125,7 +126,7 @@ GlobalSettings_Access::GlobalSettings_Access( const css::uno::Reference< css::la m_aPropStatesEnabled( RTL_CONSTASCII_USTRINGPARAM( GLOBALSETTINGS_PROPERTY_STATESENABLED )), m_aPropLocked( RTL_CONSTASCII_USTRINGPARAM( GLOBALSETTINGS_PROPERTY_LOCKED )), m_aPropDocked( RTL_CONSTASCII_USTRINGPARAM( GLOBALSETTINGS_PROPERTY_DOCKED )), - m_xServiceManager( rServiceManager ) + m_xContext( rxContext ) { } @@ -255,14 +256,11 @@ sal_Bool GlobalSettings_Access::impl_initConfigAccess() try { - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider; - if ( m_xServiceManager.is() ) - xConfigProvider = css::uno::Reference< css::lang::XMultiServiceFactory >( - m_xServiceManager->createInstance( SERVICENAME_CFGPROVIDER ), - css::uno::UNO_QUERY ); - - if ( xConfigProvider.is() ) + if ( m_xContext.is() ) { + css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider = + css::configuration::theDefaultProvider::get( m_xContext ); + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); aPropValue.Value = css::uno::makeAny( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GLOBALSETTINGS_ROOT_ACCESS ))); aArgs[0] = css::uno::makeAny( aPropValue ); @@ -275,9 +273,8 @@ sal_Bool GlobalSettings_Access::impl_initConfigAccess() SERVICENAME_CFGREADACCESS, aArgs ), css::uno::UNO_QUERY ); - css::uno::Reference< css::lang::XComponent > xComponent( xConfigProvider, css::uno::UNO_QUERY ); - if ( xComponent.is() ) - xComponent->addEventListener( + css::uno::Reference< css::lang::XComponent >( + xConfigProvider, css::uno::UNO_QUERY_THROW )->addEventListener( css::uno::Reference< css::lang::XEventListener >( static_cast< cppu::OWeakObject* >( this ), css::uno::UNO_QUERY )); @@ -302,16 +299,16 @@ sal_Bool GlobalSettings_Access::impl_initConfigAccess() struct mutexGlobalSettings : public rtl::Static< osl::Mutex, mutexGlobalSettings > {}; static GlobalSettings_Access* pStaticSettings = 0; -static GlobalSettings_Access* GetGlobalSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSrvMgr ) +static GlobalSettings_Access* GetGlobalSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) { osl::MutexGuard aGuard(mutexGlobalSettings::get()); if ( !pStaticSettings ) - pStaticSettings = new GlobalSettings_Access( rSrvMgr ); + pStaticSettings = new GlobalSettings_Access( rxContext ); return pStaticSettings; } -GlobalSettings::GlobalSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSrvMgr ) : - m_xSrvMgr( rSrvMgr ) +GlobalSettings::GlobalSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) : + m_xContext( rxContext ) { } @@ -322,7 +319,7 @@ GlobalSettings::~GlobalSettings() // settings access sal_Bool GlobalSettings::HasStatesInfo( UIElementType eElementType ) { - GlobalSettings_Access* pSettings( GetGlobalSettings( m_xSrvMgr )); + GlobalSettings_Access* pSettings( GetGlobalSettings( m_xContext )); if ( pSettings ) return pSettings->HasStatesInfo( eElementType ); @@ -332,7 +329,7 @@ sal_Bool GlobalSettings::HasStatesInfo( UIElementType eElementType ) sal_Bool GlobalSettings::GetStateInfo( UIElementType eElementType, StateInfo eStateInfo, ::com::sun::star::uno::Any& aValue ) { - GlobalSettings_Access* pSettings( GetGlobalSettings( m_xSrvMgr )); + GlobalSettings_Access* pSettings( GetGlobalSettings( m_xContext )); if ( pSettings ) return pSettings->GetStateInfo( eElementType, eStateInfo, aValue ); diff --git a/framework/source/uiconfiguration/uicategorydescription.cxx b/framework/source/uiconfiguration/uicategorydescription.cxx index 18ed4445d477..7f701e8f4446 100644 --- a/framework/source/uiconfiguration/uicategorydescription.cxx +++ b/framework/source/uiconfiguration/uicategorydescription.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -55,6 +56,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; +using namespace com::sun::star::configuration; using namespace com::sun::star::container; using namespace ::com::sun::star::frame; @@ -85,7 +87,7 @@ class ConfigurationAccess_UICategory : // Order is neccessary for right initiali public ::cppu::WeakImplHelper2<XNameAccess,XContainerListener> { public: - ConfigurationAccess_UICategory( const ::rtl::OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XMultiServiceFactory >& rServiceManager ); + ConfigurationAccess_UICategory( const ::rtl::OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext ); virtual ~ConfigurationAccess_UICategory(); // XNameAccess @@ -130,7 +132,6 @@ class ConfigurationAccess_UICategory : // Order is neccessary for right initiali rtl::OUString m_aConfigCategoryAccess; rtl::OUString m_aPropUIName; Reference< XNameAccess > m_xGenericUICategories; - Reference< XMultiServiceFactory > m_xServiceManager; Reference< XMultiServiceFactory > m_xConfigProvider; Reference< XNameAccess > m_xConfigAccess; Reference< XContainerListener > m_xConfigListener; @@ -143,12 +144,11 @@ class ConfigurationAccess_UICategory : // Order is neccessary for right initiali // XInterface, XTypeProvider //***************************************************************************************************************** -ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const rtl::OUString& aModuleName, const Reference< XNameAccess >& rGenericUICategories, const Reference< XMultiServiceFactory >& rServiceManager ) : +ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const rtl::OUString& aModuleName, const Reference< XNameAccess >& rGenericUICategories, const Reference< XComponentContext >& rxContext ) : ThreadHelpBase(), m_aConfigCategoryAccess( CONFIGURATION_ROOT_ACCESS ), m_aPropUIName( CONFIGURATION_PROPERTY_NAME ), m_xGenericUICategories( rGenericUICategories ), - m_xServiceManager( rServiceManager ), m_bConfigAccessInitialized( sal_False ), m_bCacheFilled( sal_False ) { @@ -157,7 +157,7 @@ ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const rtl::OUStr m_aConfigCategoryAccess += aModuleName; m_aConfigCategoryAccess += rtl::OUString( CONFIGURATION_CATEGORY_ELEMENT_ACCESS ); - m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY ); + m_xConfigProvider = theDefaultProvider::get( rxContext ); } ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory() @@ -424,7 +424,7 @@ void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEve //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UICategoryDescription , +DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( UICategoryDescription , ::cppu::OWeakObject , SERVICENAME_UICATEGORYDESCRIPTION , IMPLEMENTATIONNAME_UICATEGORYDESCRIPTION @@ -432,12 +432,12 @@ DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UICategoryDescription DEFINE_INIT_SERVICE ( UICategoryDescription, {} ) -UICategoryDescription::UICategoryDescription( const Reference< XMultiServiceFactory >& xServiceManager ) : - UICommandDescription(xServiceManager,true) +UICategoryDescription::UICategoryDescription( const Reference< XComponentContext >& rxContext ) : + UICommandDescription(rxContext,true) { Reference< XNameAccess > xEmpty; rtl::OUString aGenericCategories( "GenericCategories" ); - m_xGenericUICommands = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, xServiceManager ); + m_xGenericUICommands = new ConfigurationAccess_UICategory( aGenericCategories, xEmpty, rxContext ); // insert generic categories mappings m_aModuleToCommandFileMap.insert( ModuleToCommandFileMap::value_type( @@ -455,7 +455,7 @@ UICategoryDescription::~UICategoryDescription() } Reference< XNameAccess > UICategoryDescription::impl_createConfigAccess(const ::rtl::OUString& _sName) { - return new ConfigurationAccess_UICategory( _sName,m_xGenericUICommands,m_xServiceManager ); + return new ConfigurationAccess_UICategory( _sName, m_xGenericUICommands, m_xContext ); } } // namespace framework diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx index 0c831f3e1505..625aeb3128d8 100644 --- a/framework/source/uiconfiguration/windowstateconfiguration.cxx +++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -55,6 +56,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace com::sun::star::util; +using namespace com::sun::star::configuration; using namespace com::sun::star::container; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::ui; @@ -140,7 +142,7 @@ class ConfigurationAccess_WindowState : // interfaces public ::cppu::OWeakObject { public: - ConfigurationAccess_WindowState( const ::rtl::OUString& aWindowStateConfigFile, const Reference< XMultiServiceFactory >& rServiceManager ); + ConfigurationAccess_WindowState( const ::rtl::OUString& aWindowStateConfigFile, const Reference< XComponentContext >& rxContext ); virtual ~ConfigurationAccess_WindowState(); // XInterface, XTypeProvider @@ -250,7 +252,6 @@ class ConfigurationAccess_WindowState : // interfaces ::std::equal_to< ::rtl::OUString > > ResourceURLToInfoCache; rtl::OUString m_aConfigWindowAccess; - Reference< XMultiServiceFactory > m_xServiceManager; Reference< XMultiServiceFactory > m_xConfigProvider; Reference< XNameAccess > m_xConfigAccess; Reference< XContainerListener > m_xConfigListener; @@ -284,17 +285,16 @@ DEFINE_XTYPEPROVIDER_7 ( ConfigurationAccess_WindowState , css::lang::XTypeProvider ) -ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( const rtl::OUString& aModuleName, const Reference< XMultiServiceFactory >& rServiceManager ) : +ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( const rtl::OUString& aModuleName, const Reference< XComponentContext >& rxContext ) : ThreadHelpBase(), m_aConfigWindowAccess( CONFIGURATION_ROOT_ACCESS ), - m_xServiceManager( rServiceManager ), m_bConfigAccessInitialized( sal_False ), m_bModified( sal_False ) { // Create configuration hierachical access name m_aConfigWindowAccess += aModuleName; m_aConfigWindowAccess += rtl::OUString( CONFIGURATION_WINDOWSTATE_ACCESS ); - m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance( SERVICENAME_CFGPROVIDER ), UNO_QUERY ); + m_xConfigProvider = theDefaultProvider::get( rxContext ); // Initialize access array with property names. sal_Int32 n = 0; @@ -1352,7 +1352,7 @@ DEFINE_XTYPEPROVIDER_4 ( WindowStateConfiguration css::container::XElementAccess ) -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( WindowStateConfiguration , +DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( WindowStateConfiguration , ::cppu::OWeakObject , SERVICENAME_WINDOWSTATECONFIGURATION , IMPLEMENTATIONNAME_WINDOWSTATECONFIGURATION @@ -1360,11 +1360,11 @@ DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( WindowStateConfiguration DEFINE_INIT_SERVICE ( WindowStateConfiguration, {} ) -WindowStateConfiguration::WindowStateConfiguration( const Reference< XMultiServiceFactory >& xServiceManager ) : +WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentContext >& rxContext ) : ThreadHelpBase(), - m_xServiceManager( xServiceManager ) + m_xContext( rxContext ) { - m_xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) ); + m_xModuleManager = ModuleManager::create( m_xContext ); Reference< XNameAccess > xEmptyNameAccess; Sequence< rtl::OUString > aElementNames; try @@ -1432,7 +1432,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la else { Reference< XNameAccess > xResourceURLWindowState; - ConfigurationAccess_WindowState* pModuleWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xServiceManager ); + ConfigurationAccess_WindowState* pModuleWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xContext ); xResourceURLWindowState = Reference< XNameAccess >( static_cast< cppu::OWeakObject* >( pModuleWindowState ),UNO_QUERY ); pModuleIter->second = xResourceURLWindowState; a <<= xResourceURLWindowState; diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx index 232a1ce151e9..2946f1da2482 100644 --- a/framework/source/uielement/uicommanddescription.cxx +++ b/framework/source/uielement/uicommanddescription.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/ModuleManager.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -58,6 +59,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; +using namespace com::sun::star::configuration; using namespace com::sun::star::container; using namespace ::com::sun::star::frame; @@ -97,12 +99,12 @@ namespace framework // Configuration access class for PopupMenuControllerFactory implementation //***************************************************************************************************************** -class ConfigurationAccess_UICommand : // Order is neccessary for right initialization! +class ConfigurationAccess_UICommand : // Order is necessary for right initialization! private ThreadHelpBase , public ::cppu::WeakImplHelper2<XNameAccess,XContainerListener> { public: - ConfigurationAccess_UICommand( const ::rtl::OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XMultiServiceFactory >& rServiceManager ); + ConfigurationAccess_UICommand( const ::rtl::OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext ); virtual ~ConfigurationAccess_UICommand(); // XNameAccess @@ -180,7 +182,6 @@ class ConfigurationAccess_UICommand : // Order is neccessary for right initializ rtl::OUString m_aExtension; rtl::OUString m_aPrivateResourceURL; Reference< XNameAccess > m_xGenericUICommands; - Reference< XMultiServiceFactory > m_xServiceManager; Reference< XMultiServiceFactory > m_xConfigProvider; Reference< XNameAccess > m_xConfigAccess; Reference< XContainerListener > m_xConfigListener; @@ -198,7 +199,7 @@ class ConfigurationAccess_UICommand : // Order is neccessary for right initializ //***************************************************************************************************************** // XInterface, XTypeProvider //***************************************************************************************************************** -ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const rtl::OUString& aModuleName, const Reference< XNameAccess >& rGenericUICommands, const Reference< XMultiServiceFactory >& rServiceManager ) : +ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const rtl::OUString& aModuleName, const Reference< XNameAccess >& rGenericUICommands, const Reference< XComponentContext>& rxContext ) : ThreadHelpBase(), m_aConfigCmdAccess( CONFIGURATION_ROOT_ACCESS ), m_aConfigPopupAccess( CONFIGURATION_ROOT_ACCESS ), @@ -210,7 +211,6 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const rtl::OUStrin m_aPropProperties( PROPSET_PROPERTIES ), m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ), m_xGenericUICommands( rGenericUICommands ), - m_xServiceManager( rServiceManager ), m_bConfigAccessInitialized( sal_False ), m_bCacheFilled( sal_False ), m_bGenericDataRetrieved( sal_False ) @@ -219,7 +219,7 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const rtl::OUStrin m_aConfigCmdAccess += aModuleName; m_aConfigCmdAccess += rtl::OUString( CONFIGURATION_CMD_ELEMENT_ACCESS ); - m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance(SERVICENAME_CFGPROVIDER),UNO_QUERY ); + m_xConfigProvider = theDefaultProvider::get( rxContext ); m_aConfigPopupAccess += aModuleName; m_aConfigPopupAccess += rtl::OUString( CONFIGURATION_POP_ELEMENT_ACCESS ); @@ -624,7 +624,7 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UICommandDescription , +DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( UICommandDescription , ::cppu::OWeakObject , SERVICENAME_UICOMMANDDESCRIPTION , IMPLEMENTATIONNAME_UICOMMANDDESCRIPTION @@ -632,15 +632,15 @@ DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UICommandDescription DEFINE_INIT_SERVICE ( UICommandDescription, {} ) -UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactory >& xServiceManager ) : +UICommandDescription::UICommandDescription( const Reference< XComponentContext >& rxContext ) : ThreadHelpBase(), m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ), - m_xServiceManager( xServiceManager ) + m_xContext( rxContext ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UICommandDescription::UICommandDescription" ); Reference< XNameAccess > xEmpty; rtl::OUString aGenericUICommand( "GenericCommands" ); - m_xGenericUICommands = new ConfigurationAccess_UICommand( aGenericUICommand, xEmpty, xServiceManager ); + m_xGenericUICommands = new ConfigurationAccess_UICommand( aGenericUICommand, xEmpty, m_xContext ); impl_fillElements("ooSetupFactoryCommandConfigRef"); @@ -649,9 +649,9 @@ UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactor if ( pIter != m_aUICommandsHashMap.end() ) pIter->second = m_xGenericUICommands; } -UICommandDescription::UICommandDescription( const Reference< XMultiServiceFactory >& xServiceManager,bool ) : +UICommandDescription::UICommandDescription( const Reference< XComponentContext >& rxContext, bool ) : ThreadHelpBase(), - m_xServiceManager( xServiceManager ) + m_xContext( rxContext ) { } UICommandDescription::~UICommandDescription() @@ -663,7 +663,7 @@ UICommandDescription::~UICommandDescription() } void UICommandDescription::impl_fillElements(const sal_Char* _pName) { - m_xModuleManager.set( ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) ) ); + m_xModuleManager.set( ModuleManager::create( m_xContext ) ); Sequence< rtl::OUString > aElementNames = m_xModuleManager->getElementNames(); Sequence< PropertyValue > aSeq; ::rtl::OUString aModuleIdentifier; @@ -695,7 +695,7 @@ void UICommandDescription::impl_fillElements(const sal_Char* _pName) } Reference< XNameAccess > UICommandDescription::impl_createConfigAccess(const ::rtl::OUString& _sName) { - return new ConfigurationAccess_UICommand( _sName,m_xGenericUICommands,m_xServiceManager ); + return new ConfigurationAccess_UICommand( _sName, m_xGenericUICommands, m_xContext ); } Any SAL_CALL UICommandDescription::getByName( const ::rtl::OUString& aName ) @@ -720,7 +720,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la Reference< XNameAccess > xUICommands; ConfigurationAccess_UICommand* pUICommands = new ConfigurationAccess_UICommand( aCommandFile, m_xGenericUICommands, - m_xServiceManager ); + m_xContext ); xUICommands = Reference< XNameAccess >( static_cast< cppu::OWeakObject* >( pUICommands ),UNO_QUERY ); pIter->second = xUICommands; a <<= xUICommands; diff --git a/framework/source/uifactory/factoryconfiguration.cxx b/framework/source/uifactory/factoryconfiguration.cxx index d029b849f013..476fefcb391b 100644 --- a/framework/source/uifactory/factoryconfiguration.cxx +++ b/framework/source/uifactory/factoryconfiguration.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -69,19 +70,18 @@ rtl::OUString getHashKeyFromStrings( const rtl::OUString& aCommandURL, const rtl //***************************************************************************************************************** // XInterface, XTypeProvider //***************************************************************************************************************** -ConfigurationAccess_ControllerFactory::ConfigurationAccess_ControllerFactory( Reference< XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot,bool _bAskValue ) : +ConfigurationAccess_ControllerFactory::ConfigurationAccess_ControllerFactory( const Reference< XComponentContext >& rxContext, const ::rtl::OUString& _sRoot,bool _bAskValue ) : ThreadHelpBase(), m_aPropCommand( RTL_CONSTASCII_USTRINGPARAM( "Command" )), m_aPropModule( RTL_CONSTASCII_USTRINGPARAM( "Module" )), m_aPropController( RTL_CONSTASCII_USTRINGPARAM( "Controller" )), m_aPropValue( RTL_CONSTASCII_USTRINGPARAM( "Value" )), m_sRoot(_sRoot), - m_xServiceManager( rServiceManager ), m_bConfigAccessInitialized( sal_False ), m_bAskValue(_bAskValue) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ConfigurationAccess_ControllerFactory::ConfigurationAccess_ControllerFactory" ); - m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance( SERVICENAME_CFGPROVIDER),UNO_QUERY ); + m_xConfigProvider = configuration::theDefaultProvider::get( rxContext ); } ConfigurationAccess_ControllerFactory::~ConfigurationAccess_ControllerFactory() diff --git a/framework/source/uifactory/popupmenucontrollerfactory.cxx b/framework/source/uifactory/popupmenucontrollerfactory.cxx index e98f03e91464..34dd936f7b72 100644 --- a/framework/source/uifactory/popupmenucontrollerfactory.cxx +++ b/framework/source/uifactory/popupmenucontrollerfactory.cxx @@ -64,7 +64,7 @@ PopupMenuControllerFactory::PopupMenuControllerFactory( const Reference< XMultiS ToolbarControllerFactory(xServiceManager,true) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PopupMenuControllerFactory::PopupMenuControllerFactory" ); - m_pConfigAccess = new ConfigurationAccess_ControllerFactory( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Controller/Registered/PopupMenu" )) ); + m_pConfigAccess = new ConfigurationAccess_ControllerFactory( comphelper::getComponentContext(m_xServiceManager), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Controller/Registered/PopupMenu" )) ); m_pConfigAccess->acquire(); } diff --git a/framework/source/uifactory/statusbarcontrollerfactory.cxx b/framework/source/uifactory/statusbarcontrollerfactory.cxx index 3de5b25245ab..b0e0342f3e94 100644 --- a/framework/source/uifactory/statusbarcontrollerfactory.cxx +++ b/framework/source/uifactory/statusbarcontrollerfactory.cxx @@ -61,7 +61,7 @@ DEFINE_INIT_SERVICE ( StatusbarControllerFactory, {} ) StatusbarControllerFactory::StatusbarControllerFactory( const Reference< XMultiServiceFactory >& xServiceManager ) : ToolbarControllerFactory(xServiceManager,true) { - m_pConfigAccess = new ConfigurationAccess_ControllerFactory( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Controller/Registered/StatusBar" )),true ); + m_pConfigAccess = new ConfigurationAccess_ControllerFactory( comphelper::getComponentContext(m_xServiceManager), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Controller/Registered/StatusBar" )),true ); m_pConfigAccess->acquire(); } diff --git a/framework/source/uifactory/toolbarcontrollerfactory.cxx b/framework/source/uifactory/toolbarcontrollerfactory.cxx index 5651159be7dd..6967a8aae367 100644 --- a/framework/source/uifactory/toolbarcontrollerfactory.cxx +++ b/framework/source/uifactory/toolbarcontrollerfactory.cxx @@ -73,7 +73,7 @@ ToolbarControllerFactory::ToolbarControllerFactory( const Reference< XMultiServi m_bConfigRead( sal_False ), m_xServiceManager( xServiceManager ) { - m_pConfigAccess = new ConfigurationAccess_ControllerFactory( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Controller/Registered/ToolBar" )) ); + m_pConfigAccess = new ConfigurationAccess_ControllerFactory( comphelper::getComponentContext(m_xServiceManager), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Controller/Registered/ToolBar" )) ); m_pConfigAccess->acquire(); } diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx index 9e0debabe42c..6e4b9d59b9b8 100644 --- a/framework/source/uifactory/uielementfactorymanager.cxx +++ b/framework/source/uifactory/uielementfactorymanager.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -54,6 +55,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace com::sun::star::frame; +using namespace com::sun::star::configuration; using namespace com::sun::star::container; using namespace ::com::sun::star::ui; using namespace ::com::sun::star::frame; @@ -82,18 +84,17 @@ rtl::OUString getHashKeyFromStrings( const rtl::OUString& aType, const rtl::OUSt //***************************************************************************************************************** -ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( Reference< XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot ) : +ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, const ::rtl::OUString& _sRoot ) : ThreadHelpBase(), m_aPropType( RTL_CONSTASCII_USTRINGPARAM( "Type" )), m_aPropName( RTL_CONSTASCII_USTRINGPARAM( "Name" )), m_aPropModule( RTL_CONSTASCII_USTRINGPARAM( "Module" )), m_aPropFactory( RTL_CONSTASCII_USTRINGPARAM( "FactoryImplementation" )), m_sRoot(_sRoot), - m_xServiceManager( rServiceManager ), m_bConfigAccessInitialized( sal_False ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::ConfigurationAccess_FactoryManager" ); - m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance( SERVICENAME_CFGPROVIDER),UNO_QUERY ); + m_xConfigProvider = theDefaultProvider::get( rxContext ); } ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager() @@ -379,7 +380,7 @@ sal_Bool ConfigurationAccess_FactoryManager::impl_getElementProps( const Any& aE //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UIElementFactoryManager , +DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( UIElementFactoryManager , ::cppu::OWeakObject , SERVICENAME_UIELEMENTFACTORYMANAGER , IMPLEMENTATIONNAME_UIELEMENTFACTORYMANAGER @@ -387,15 +388,15 @@ DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( UIElementFactoryManager DEFINE_INIT_SERVICE ( UIElementFactoryManager, {} ) -UIElementFactoryManager::UIElementFactoryManager( const Reference< XMultiServiceFactory >& xServiceManager ) : +UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) : ThreadHelpBase( &Application::GetSolarMutex() ), m_bConfigRead( sal_False ), - m_xServiceManager( xServiceManager ) + m_xContext(rxContext) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::UIElementFactoryManager" ); - m_pConfigAccess = new ConfigurationAccess_FactoryManager( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories" )) ); + m_pConfigAccess = new ConfigurationAccess_FactoryManager( rxContext, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories" )) ); m_pConfigAccess->acquire(); - m_xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) ); + m_xModuleManager = ModuleManager::create( rxContext ); } UIElementFactoryManager::~UIElementFactoryManager() @@ -491,13 +492,13 @@ throw ( RuntimeException ) WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName ); - Reference< XMultiServiceFactory > xSManager( m_xServiceManager ); + Reference< XComponentContext > xContext( m_xContext ); rtl::OUString aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId ); aLock.unlock(); if ( !aServiceSpecifier.isEmpty() ) - return Reference< XUIElementFactory >( xSManager->createInstance( aServiceSpecifier ), UNO_QUERY ); + return Reference< XUIElementFactory >( xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier, xContext), UNO_QUERY ); else return Reference< XUIElementFactory >(); } diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx index a6a950bf2d5c..68176592ae00 100644 --- a/framework/source/uifactory/windowcontentfactorymanager.cxx +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -63,7 +63,7 @@ namespace framework //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** -DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( WindowContentFactoryManager , +DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2 ( WindowContentFactoryManager , ::cppu::OWeakObject , SERVICENAME_WINDOWCONTENTFACTORYMANAGER , IMPLEMENTATIONNAME_WINDOWCONTENTFACTORYMANAGER @@ -71,14 +71,13 @@ DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( WindowContentFactoryManager DEFINE_INIT_SERVICE ( WindowContentFactoryManager, {} ) -WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) : +WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference< uno::XComponentContext >& rxContext ) : ThreadHelpBase( &Application::GetSolarMutex() ), - m_bConfigRead( sal_False ), - m_xServiceManager( xServiceManager ) + m_bConfigRead( sal_False ) { - m_pConfigAccess = new ConfigurationAccess_FactoryManager( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories" )) ); + m_pConfigAccess = new ConfigurationAccess_FactoryManager( rxContext, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories" )) ); m_pConfigAccess->acquire(); - m_xModuleManager = frame::ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) ); + m_xModuleManager = frame::ModuleManager::create( rxContext ); } WindowContentFactoryManager::~WindowContentFactoryManager() |