From 0cd4caa547a75316c6b3f2992dd66b2294c6f1ae Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 1 Feb 2013 13:28:32 +0200 Subject: fdo#46808, convert code in desktop module to XComponentContext Change-Id: I79a22f52ebe59f8f89291d4e6e78bd37817cd047 --- desktop/inc/app.hxx | 2 +- desktop/source/app/app.cxx | 41 ++++++++++++++++------------- desktop/source/app/appfirststart.cxx | 6 +++-- desktop/source/app/appinit.cxx | 14 +++++----- desktop/source/migration/migration.cxx | 22 ++++++++-------- desktop/source/migration/migration_impl.hxx | 4 +-- 6 files changed, 46 insertions(+), 43 deletions(-) (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 8fd1b58103f5..2f44f7307d13 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -148,7 +148,7 @@ class Desktop : public Application bool InitializeConfiguration(); void FlushConfiguration(); static sal_Bool shouldLaunchQuickstart(); - sal_Bool InitializeQuickstartMode( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr ); + sal_Bool InitializeQuickstartMode( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext ); void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg ); void StartSetup( const ::rtl::OUString& aParameters ); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 6a355dcda25c..70060ed1b306 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1113,10 +1113,10 @@ sal_Bool impl_callRecoveryUI(sal_Bool bEmergencySave , static ::rtl::OUString COMMAND_RECOVERY("vnd.sun.star.autorecovery:/doAutoRecovery"); static ::rtl::OUString COMMAND_CRASHREPORT("vnd.sun.star.autorecovery:/doCrashReport"); - css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); + css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< css::frame::XSynchronousDispatch > xRecoveryUI( - xSMGR->createInstance(SERVICENAME_RECOVERYUI), + xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_RECOVERYUI, xContext), css::uno::UNO_QUERY_THROW); Reference< css::util::XURLTransformer > xURLParser = @@ -1428,7 +1428,6 @@ int Desktop::Main() utl::Bootstrap::reloadData(); SetSplashScreenProgress(20); - Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory(); Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< XRestartManager > xRestartManager( OfficeRestartManager::get(xContext) ); @@ -1633,7 +1632,7 @@ int Desktop::Main() if ( !bTerminateRequested && !rCmdLineArgs.IsInvisible() && !rCmdLineArgs.IsNoQuickstart() ) - InitializeQuickstartMode( xSMgr ); + InitializeQuickstartMode( xContext ); RTL_LOGFILE_CONTEXT( aLog2, "desktop (cd100003) createInstance com.sun.star.frame.Desktop" ); try @@ -1859,7 +1858,7 @@ sal_Bool Desktop::shouldLaunchQuickstart() } -sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& rSMgr ) +sal_Bool Desktop::InitializeQuickstartMode( const Reference< XComponentContext >& rxContext ) { try { @@ -1883,9 +1882,9 @@ sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& r { Sequence< Any > aSeq( 1 ); aSeq[0] <<= bQuickstart; - Reference < XComponent > xQuickstart( rSMgr->createInstanceWithArguments( - rtl::OUString( "com.sun.star.office.Quickstart" ), aSeq ), - UNO_QUERY ); + Reference < XComponent > xQuickstart( + rxContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.office.Quickstart", aSeq, rxContext), + UNO_QUERY ); } return sal_True; } @@ -2060,7 +2059,6 @@ void Desktop::PreloadModuleData( const CommandLineArgs& rArgs ) void Desktop::PreloadConfigurationData() { - Reference< XMultiServiceFactory > rFactory = ::comphelper::getProcessServiceFactory(); Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< XNameAccess > xNameAccess = css::frame::UICommandDescription::create(xContext); @@ -2181,8 +2179,9 @@ void Desktop::PreloadConfigurationData() // preload filter configuration Sequence< OUString > aSeq; - xNameAccess = Reference< XNameAccess >( rFactory->createInstance( - rtl::OUString( "com.sun.star.document.FilterFactory" )), UNO_QUERY ); + xNameAccess = Reference< XNameAccess >( + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.FilterFactory", xContext), + UNO_QUERY ); if ( xNameAccess.is() ) { try @@ -2195,8 +2194,9 @@ void Desktop::PreloadConfigurationData() } // preload type detection configuration - xNameAccess = Reference< XNameAccess >( rFactory->createInstance( - rtl::OUString( "com.sun.star.document.TypeDetection" )), UNO_QUERY ); + xNameAccess = Reference< XNameAccess >( + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", xContext), + UNO_QUERY ); if ( xNameAccess.is() ) { try @@ -2700,8 +2700,8 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) Sequence< Any > aSeq( 1 ); aSeq[0] <<= bQuickstart; - Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( "com.sun.star.office.Quickstart" )), + Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference < XInitialization > xQuickstart( xContext->getServiceManager()->createInstanceWithContext("com.sun.star.office.Quickstart", xContext), UNO_QUERY ); if ( xQuickstart.is() ) xQuickstart->initialize( aSeq ); @@ -2787,9 +2787,10 @@ void Desktop::OpenSplashScreen() Sequence< Any > aSeq( 2 ); aSeq[0] <<= bVisible; aSeq[1] <<= aAppName; + css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); m_rSplashScreen = Reference( - comphelper::getProcessServiceFactory()->createInstanceWithArguments( - aSplashService, aSeq), UNO_QUERY); + xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aSplashService, aSeq, xContext), + UNO_QUERY); if(m_rSplashScreen.is()) m_rSplashScreen->start(OUString("SplashScreen"), 100); @@ -2907,8 +2908,10 @@ void Desktop::CheckFirstRun( ) aSeq[0] <<= bQuickstart; aSeq[1] <<= bAutostart; - Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance( - OUString::createFromAscii( "com.sun.star.office.Quickstart" )),UNO_QUERY ); + css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference < XInitialization > xQuickstart( + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.office.Quickstart", xContext), + UNO_QUERY ); if ( xQuickstart.is() ) xQuickstart->initialize( aSeq ); RegCloseKey( hKey ); diff --git a/desktop/source/app/appfirststart.cxx b/desktop/source/app/appfirststart.cxx index 1af0ac9abe67..471f77bca391 100644 --- a/desktop/source/app/appfirststart.cxx +++ b/desktop/source/app/appfirststart.cxx @@ -70,8 +70,10 @@ void Desktop::DoRestartActionsIfNecessary( sal_Bool bQuickStart ) sal_Bool bQuickstart = shouldLaunchQuickstart(); aSeq[0] <<= bQuickstart; - Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance( - OUString( "com.sun.star.office.Quickstart" ) ),UNO_QUERY_THROW ); + css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference < XInitialization > xQuickstart( + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.office.Quickstart", xContext), + UNO_QUERY_THROW ); xQuickstart->initialize( aSeq ); } } diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 9e6a5c131b2c..cbb7a3239dc9 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -89,12 +89,11 @@ static void configureUcb() OUString aDesktopEnvironment; if ((aValue >>= aDesktopEnvironment) && aDesktopEnvironment == "GNOME") { - UniversalContentBroker::create( - comphelper::getProcessComponentContext())-> - registerContentProvider( + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + UniversalContentBroker::create(xContext) + ->registerContentProvider( Reference( - comphelper::getProcessServiceFactory()->createInstance( - "com.sun.star.ucb.GnomeVFSContentProvider"), + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.GnomeVFSContentProvider", xContext), UNO_QUERY_THROW), ".*", false); } @@ -174,9 +173,10 @@ void Desktop::createAcceptor(const OUString& aAcceptString) Sequence< Any > aSeq( 2 ); aSeq[0] <<= aAcceptString; aSeq[1] <<= bAccept; + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference rAcceptor( - ::comphelper::getProcessServiceFactory()->createInstance( - OUString("com.sun.star.office.Acceptor" )), UNO_QUERY ); + xContext->getServiceManager()->createInstanceWithContext("com.sun.star.office.Acceptor", xContext), + UNO_QUERY ); if ( rAcceptor.is() ) { try diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 6301fdc3acba..61c57c1c9b75 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -207,7 +207,7 @@ bool MigrationImpl::initializeMigration() void Migration::migrateSettingsIfNecessary() { - MigrationImpl aImpl( comphelper::getProcessServiceFactory() ); + MigrationImpl aImpl; if (! aImpl.initializeMigration() ) return; @@ -227,9 +227,8 @@ void Migration::migrateSettingsIfNecessary() (void)bResult; } -MigrationImpl::MigrationImpl(const uno::Reference< XMultiServiceFactory >& xFactory) +MigrationImpl::MigrationImpl() : m_vrVersions(new strings_v) - , m_xFactory(xFactory) { } @@ -265,10 +264,10 @@ sal_Bool MigrationImpl::doMigration() lArgs[0] <<= aOldCfgDataPath + vModulesInfo[i].sModuleShortName; lArgs[1] <<= embed::ElementModes::READ; - uno::Reference< lang::XSingleServiceFactory > xStorageFactory( - embed::FileSystemStorageFactory::create(comphelper::getComponentContext(m_xFactory))); + uno::Reference< uno::XComponentContext > xContext(comphelper::getProcessComponentContext()); + uno::Reference< lang::XSingleServiceFactory > xStorageFactory(embed::FileSystemStorageFactory::create(xContext)); uno::Reference< embed::XStorage > xModules(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); - uno::Reference< ui::XUIConfigurationManager > xOldCfgManager( m_xFactory->createInstance("com.sun.star.ui.UIConfigurationManager"), uno::UNO_QUERY ); + uno::Reference< ui::XUIConfigurationManager > xOldCfgManager(xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ui.UIConfigurationManager", xContext), uno::UNO_QUERY ); uno::Reference< ui::XUIConfigurationStorage > xOldCfgStorage( xOldCfgManager, uno::UNO_QUERY ); uno::Reference< ui::XUIConfigurationPersistence > xOldCfgPersistence( xOldCfgManager, uno::UNO_QUERY ); @@ -336,8 +335,7 @@ sal_Bool MigrationImpl::doMigration() void MigrationImpl::refresh() { uno::Reference< XRefreshable >( - configuration::theDefaultProvider::get( - comphelper::getComponentContext(m_xFactory)), + configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()), uno::UNO_QUERY_THROW)->refresh(); } @@ -952,6 +950,7 @@ void MigrationImpl::runServices() // and execute the migration job uno::Reference< XJob > xMigrationJob; + uno::Reference< uno::XComponentContext > xContext(comphelper::getProcessComponentContext()); migrations_v::const_iterator i_mig = m_vrMigrations->begin(); while (i_mig != m_vrMigrations->end()) { @@ -969,8 +968,9 @@ void MigrationImpl::runServices() seqArguments[2] = uno::makeAny(NamedValue("ExtensionBlackList", uno::makeAny( seqExtBlackList ))); - xMigrationJob = uno::Reference< XJob >(m_xFactory->createInstanceWithArguments( - i_mig->service, seqArguments), uno::UNO_QUERY_THROW); + xMigrationJob = uno::Reference< XJob >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext(i_mig->service, seqArguments, xContext), + uno::UNO_QUERY_THROW); xMigrationJob->execute(uno::Sequence< NamedValue >()); @@ -1007,7 +1007,7 @@ void MigrationImpl::runServices() lArgs[1] <<= embed::ElementModes::READ; uno::Reference< lang::XSingleServiceFactory > xStorageFactory( - embed::FileSystemStorageFactory::create(comphelper::getComponentContext(m_xFactory))); + embed::FileSystemStorageFactory::create(comphelper::getProcessComponentContext())); uno::Reference< embed::XStorage > xModules; xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx index ef2e659954fc..653813fbd2dd 100644 --- a/desktop/source/migration/migration_impl.hxx +++ b/desktop/source/migration/migration_impl.hxx @@ -32,7 +32,6 @@ #include -#include #include #include #include @@ -185,7 +184,6 @@ class MigrationImpl private: strings_vr m_vrVersions; - NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory > m_xFactory; migrations_available m_vMigrationsAvailable; // list of all available migrations migrations_vr m_vrMigrations; // list of all migration specs from config @@ -232,7 +230,7 @@ private: bool checkMigrationCompleted(); public: - MigrationImpl(const NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory >&); + MigrationImpl(); ~MigrationImpl(); bool initializeMigration(); sal_Bool doMigration(); -- cgit