diff options
Diffstat (limited to 'desktop/source')
20 files changed, 104 insertions, 166 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 7208345650d3..1781d66b1e1a 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -94,7 +94,6 @@ #include <sfx2/app.hxx> #include <svl/itemset.hxx> #include <svl/eitem.hxx> -#include <ucbhelper/contentbroker.hxx> #include <svtools/fontsubstconfig.hxx> #include <svtools/accessibilityoptions.hxx> @@ -1769,10 +1768,6 @@ int Desktop::doShutdown() pExecGlobals->pPathOptions.reset( 0 ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- dispose path/language options" ); - RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> deinit ucb" ); - ::ucbhelper::ContentBroker::deinitialize(); - RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" ); - sal_Bool bRR = pExecGlobals->bRestartRequested; delete pExecGlobals, pExecGlobals = NULL; diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 4b33cb29fa6d..64a882959468 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -42,18 +42,16 @@ #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/ucb/XContentProviderManager.hpp> -#include <com/sun/star/ucb/XContentProviderFactory.hpp> +#include <com/sun/star/ucb/UniversalContentBroker.hpp> +#include <com/sun/star/ucb/XUniversalContentBroker.hpp> #include <uno/current_context.hxx> #include <cppuhelper/servicefactory.hxx> #include <cppuhelper/bootstrap.hxx> #include <osl/file.hxx> #include <osl/module.h> -#include <osl/security.hxx> #include <rtl/uri.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/bootstrap.hxx> -#include <ucbhelper/configurationkeys.hxx> #include <tools/rcid.h> @@ -63,7 +61,6 @@ #include <unotools/localfilehelper.hxx> #include <unotools/ucbhelper.hxx> #include <unotools/tempfile.hxx> -#include <ucbhelper/contentbroker.hxx> #include <vcl/svapp.hxx> #include <unotools/startoptions.hxx> #include <unotools/pathoptions.hxx> @@ -84,83 +81,34 @@ namespace desktop // ----------------------------------------------------------------------------- -static bool configureUcb() +static void configureUcb() { RTL_LOGFILE_CONTEXT( aLog, "desktop (sb93797) ::configureUcb" ); - Reference< XMultiServiceFactory > - xServiceFactory( comphelper::getProcessServiceFactory() ); - if (!xServiceFactory.is()) - { - OSL_FAIL("configureUcb(): No XMultiServiceFactory"); - return false; - } - - rtl::OUString aPipe; - osl::Security().getUserIdent(aPipe); - - rtl::OUStringBuffer aPortal; - Sequence< Any > aArgs(2); - aArgs[0] - <<= rtl::OUString(UCB_CONFIGURATION_KEY1_LOCAL); - aArgs[1] - <<= rtl::OUString(UCB_CONFIGURATION_KEY2_OFFICE); - - bool ret = - ::ucbhelper::ContentBroker::initialize( xServiceFactory, aArgs ) != false; + // For backwards compatibility, in case some code still uses plain + // createInstance w/o args directly to obtain an instance: + UniversalContentBroker::create(comphelper::getProcessComponentContext()); #ifdef GNOME_VFS_ENABLED - // register GnomeUCP if necessary - ::ucbhelper::ContentBroker* cb = ::ucbhelper::ContentBroker::get(); - if(cb) + // Instantiate GNOME-VFS UCP in the thread that initialized GNOME in order + // to avoid a deadlock that may occure in case the UCP gets initialized from + // a different thread (which may happen when calling remotely via UNO); this + // is not a fix, just a workaround: + Reference< XCurrentContext > xCurrentContext(getCurrentContext()); + Any aValue(xCurrentContext->getValueByName("system.desktop-environment")); + OUString aDesktopEnvironment; + if ((aValue >>= aDesktopEnvironment) && aDesktopEnvironment == "GNOME") { - try - { - Reference< XCurrentContext > xCurrentContext( - getCurrentContext()); - if (xCurrentContext.is()) - { - Any aValue = xCurrentContext->getValueByName( - rtl::OUString( "system.desktop-environment" ) - ); - rtl::OUString aDesktopEnvironment; - if ( (aValue >>= aDesktopEnvironment) && aDesktopEnvironment == "GNOME" ) - { - Reference<XContentProviderManager> xCPM = - cb->getContentProviderManagerInterface(); - - - //Instanciate GNOME-VFS-UCP in the thread that initialized - // GNOME in order to avoid a deadlock that may occure in case UCP gets initialized from - // a different thread. The latter may happen when calling the Office remotely via UNO. - // THIS IS NOT A FIX, JUST A WORKAROUND! - - try - { - Reference<XContentProvider> xCP( - xServiceFactory->createInstance( - rtl::OUString( - "com.sun.star.ucb.GnomeVFSContentProvider")), - UNO_QUERY); - if(xCP.is()) - xCPM->registerContentProvider( - xCP, - rtl::OUString(".*"), - false); - } - catch (...) - { - } - } - } - } - catch (const RuntimeException &) - { - } + UniversalContentBroker::create( + comphelper::getProcessComponentContext())-> + registerContentProvider( + Reference<XContentProvider>( + comphelper::getProcessServiceFactory()->createInstance( + "com.sun.star.ucb.GnomeVFSContentProvider"), + UNO_QUERY_THROW), + ".*", false); } #endif // GNOME_VFS_ENABLED - - return ret; } Reference< XMultiServiceFactory > Desktop::CreateApplicationServiceManager() @@ -228,11 +176,7 @@ void Desktop::RegisterServices() createAcceptor(*i); } - if ( !configureUcb() ) - { - OSL_FAIL( "Can't configure UCB" ); - throw com::sun::star::uno::Exception(rtl::OUString("RegisterServices, configureUcb"), NULL); - } + configureUcb(); CreateTemporaryDirectory(); m_bServicesRegistered = true; diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 7795e3093cc3..323778d4c642 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -875,7 +875,7 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv uno::Any anyTitle; try { - anyTitle = ::ucbhelper::Content( rPackageURL, rCmdEnv.get() ).getPropertyValue( OUSTR("Title") ); + anyTitle = ::ucbhelper::Content( rPackageURL, rCmdEnv.get(), m_xContext ).getPropertyValue( OUSTR("Title") ); } catch ( const uno::Exception & ) { diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index b3c21b4db52e..de78275bb205 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -112,12 +112,12 @@ OUString CompIdentifiers::getName(::std::vector<Reference<deploy::XPackage> > co return extension->getDisplayName(); } -void writeLastModified(OUString & url, Reference<ucb::XCommandEnvironment> const & xCmdEnv) +void writeLastModified(OUString & url, Reference<ucb::XCommandEnvironment> const & xCmdEnv, Reference< uno::XComponentContext > const & xContext) { //Write the lastmodified file try { ::rtl::Bootstrap::expandMacros(url); - ::ucbhelper::Content ucbStamp(url, xCmdEnv ); + ::ucbhelper::Content ucbStamp(url, xCmdEnv, xContext); dp_misc::erase_path( url, xCmdEnv ); ::rtl::OString stamp("1" ); Reference<css::io::XInputStream> xData( @@ -589,7 +589,7 @@ bool ExtensionManager::doChecksForAddExtension( } //Prevent showing the license if requested. Reference<ucb::XCommandEnvironment> _xCmdEnv(xCmdEnv); - ExtensionProperties props(OUString(), properties, Reference<ucb::XCommandEnvironment>()); + ExtensionProperties props(OUString(), properties, Reference<ucb::XCommandEnvironment>(), m_xContext); dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL())); const ::boost::optional<dp_misc::SimpleLicenseAttributes> licenseAttributes = @@ -1315,10 +1315,10 @@ sal_Bool ExtensionManager::synchronize( } OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM( "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); - writeLastModified(lastSyncBundled, xCmdEnv); + writeLastModified(lastSyncBundled, xCmdEnv, m_xContext); OUString lastSyncShared(RTL_CONSTASCII_USTRINGPARAM( "$SHARED_EXTENSIONS_USER/lastsynchronized")); - writeLastModified(lastSyncShared, xCmdEnv); + writeLastModified(lastSyncShared, xCmdEnv, m_xContext); return bModified; } catch ( const deploy::DeploymentException& ) { throw; diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 14f5bfa396fc..c0c7498b634f 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -163,7 +163,7 @@ PackageInformationProvider::getPackageLocation( const rtl::OUString& _sExtension } if ( !aLocationURL.isEmpty() ) { - ::ucbhelper::Content aContent( aLocationURL, NULL ); + ::ucbhelper::Content aContent( aLocationURL, NULL, mxContext ); aLocationURL = aContent.getURL(); } return aLocationURL; diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index c07109bbe78d..ae34f2e67b91 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -101,9 +101,10 @@ struct MatchTempDir namespace { OUString getExtensionFolder(OUString const & parentFolder, - Reference<ucb::XCommandEnvironment> const & xCmdEnv) + Reference<ucb::XCommandEnvironment> const & xCmdEnv, + Reference<uno::XComponentContext> const & xContext) { - ::ucbhelper::Content tempFolder( parentFolder, xCmdEnv ); + ::ucbhelper::Content tempFolder( parentFolder, xCmdEnv, xContext ); Reference<sdbc::XResultSet> xResultSet( StrTitle::createCursor (tempFolder, ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); @@ -147,7 +148,7 @@ void PackageManagerImpl::initActivationLayer( ::ucbhelper::Content sourceContent( Reference<XContentAccess>( xResultSet, UNO_QUERY_THROW )->queryContent(), - xCmdEnv ); + xCmdEnv, m_xComponentContext ); OUString mediaType( detectMediaType( sourceContent, false /* no throw */) ); @@ -193,7 +194,7 @@ void PackageManagerImpl::initActivationLayer( // clean up activation layer, scan for zombie temp dirs: ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv ); + ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv, m_xComponentContext ); Reference<sdbc::XResultSet> xResultSet( StrTitle::createCursor (tempFolder, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); @@ -265,7 +266,7 @@ void PackageManagerImpl::initActivationLayer( ::osl::Security aSecurity; aSecurity.getUserName( aUserName ); ucbhelper::Content remFileContent( - url + OUSTR("removed"), Reference<XCommandEnvironment>()); + url + OUSTR("removed"), Reference<XCommandEnvironment>(), m_xComponentContext); ::rtl::ByteSequence data = dp_misc::readFile(remFileContent); ::rtl::OString osData(reinterpret_cast<const sal_Char*>(data.getConstArray()), data.getLength()); @@ -646,7 +647,7 @@ OUString PackageManagerImpl::insertToActivationLayer( } buf.append( static_cast<sal_Unicode>('/') ); sourceContent = ::ucbhelper::Content( - buf.makeStringAndClear(), xCmdEnv ); + buf.makeStringAndClear(), xCmdEnv, m_xComponentContext ); } if (! destFolderContent.transferContent( sourceContent, ::ucbhelper::InsertOperation_COPY, @@ -667,7 +668,7 @@ OUString PackageManagerImpl::insertToActivationLayer( dbData->version = info.getVersion(); //No write the properties file next to the extension - ExtensionProperties props(sFolderUrl, properties, xCmdEnv); + ExtensionProperties props(sFolderUrl, properties, xCmdEnv, m_xComponentContext); props.write(); return destFolder; } @@ -773,7 +774,7 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage( OUSTR("UCB transferContent() failed!"), 0 ); // set media-type: ::ucbhelper::Content docContent( - makeURL( m_context, title_enc ), xCmdEnv ); + makeURL( m_context, title_enc ), xCmdEnv, m_xComponentContext ); //TODO #i73136#: using title instead of id can lead to // clashes, but the whole m_activePackages.getLength()==0 // case (i.e., document-relative deployment) currently does @@ -915,7 +916,7 @@ void PackageManagerImpl::removePackage( OSL_ASSERT(!val.temporaryName.isEmpty()); OUString url(makeURL(m_activePackages_expanded, val.temporaryName + OUSTR("removed"))); - ::ucbhelper::Content contentRemoved(url, xCmdEnv ); + ::ucbhelper::Content contentRemoved(url, xCmdEnv, m_xComponentContext); OUString aUserName; ::osl::Security aSecurity; aSecurity.getUserName( aUserName ); @@ -1332,7 +1333,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( NULL, m_activePackages_expanded, Reference<css::ucb::XCommandEnvironment>(), false)) return bModified; - ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv ); + ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv, m_xComponentContext ); Reference<sdbc::XResultSet> xResultSet( StrTitle::createCursor( tempFolder, ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); @@ -1381,7 +1382,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( continue; sExtFolder = getExtensionFolder( m_activePackages_expanded + - OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv); + OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv, m_xComponentContext); url = makeURLAppendSysPathSegment(m_activePackages_expanded, title); url = makeURLAppendSysPathSegment(url, sExtFolder); } @@ -1416,7 +1417,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( dp_misc::getDescriptionInfoset(url); ::boost::optional<dp_misc::SimpleLicenseAttributes> attr = info.getSimpleLicenseAttributes(); - ExtensionProperties props(url,xCmdEnv); + ExtensionProperties props(url, xCmdEnv, m_xComponentContext); bool bNoLicense = false; if (attr && attr->suppressIfRequired && props.isSuppressedLicense()) bNoLicense = true; diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx index 4f11eeadca90..aa1b4c5ebfc5 100644 --- a/desktop/source/deployment/manager/dp_properties.cxx +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -55,8 +55,9 @@ namespace dp_manager { //Reading the file ExtensionProperties::ExtensionProperties( OUString const & urlExtension, - Reference<ucb::XCommandEnvironment> const & xCmdEnv) : - m_xCmdEnv(xCmdEnv) + Reference<ucb::XCommandEnvironment> const & xCmdEnv, + Reference<uno::XComponentContext> const & xContext) : + m_xCmdEnv(xCmdEnv), m_xContext(xContext) { m_propFileUrl = urlExtension + OUSTR("properties"); @@ -64,7 +65,7 @@ ExtensionProperties::ExtensionProperties( if (! dp_misc::create_ucb_content(NULL, m_propFileUrl, 0, false)) return; - ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); + ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv, m_xContext); dp_misc::readProperties(props, contentProps); typedef ::std::list< ::std::pair< OUString, OUString> >::const_iterator CI; @@ -79,8 +80,9 @@ ExtensionProperties::ExtensionProperties( ExtensionProperties::ExtensionProperties( OUString const & urlExtension, uno::Sequence<css::beans::NamedValue> const & properties, - Reference<ucb::XCommandEnvironment> const & xCmdEnv) : - m_xCmdEnv(xCmdEnv) + Reference<ucb::XCommandEnvironment> const & xCmdEnv, + Reference<uno::XComponentContext> const & xContext) : + m_xCmdEnv(xCmdEnv), m_xContext(xContext) { m_propFileUrl = urlExtension + OUSTR("properties"); @@ -120,7 +122,7 @@ OUString ExtensionProperties::getPropertyValue(css::beans::NamedValue const & v) } void ExtensionProperties::write() { - ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); + ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv, m_xContext); ::rtl::OUStringBuffer buf; if (m_prop_suppress_license) diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx index 3e85adf5b7a0..25a0594114da 100644 --- a/desktop/source/deployment/manager/dp_properties.hxx +++ b/desktop/source/deployment/manager/dp_properties.hxx @@ -41,6 +41,7 @@ class ExtensionProperties protected: ::rtl::OUString m_propFileUrl; const css::uno::Reference<css::ucb::XCommandEnvironment> m_xCmdEnv; + const css::uno::Reference<css::uno::XComponentContext> m_xContext; ::boost::optional< ::rtl::OUString> m_prop_suppress_license; ::boost::optional< ::rtl::OUString> m_prop_extension_update; @@ -49,11 +50,13 @@ public: virtual ~ExtensionProperties() {}; ExtensionProperties(::rtl::OUString const & urlExtension, - css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv); + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + css::uno::Reference<css::uno::XComponentContext> const & xContext); ExtensionProperties(::rtl::OUString const & urlExtension, css::uno::Sequence<css::beans::NamedValue> const & properties, - css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv); + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + css::uno::Reference<css::uno::XComponentContext> const & xContext); void write(); diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index c63744bba0cb..48054bd77102 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -201,7 +201,7 @@ ExtensionDescription::ExtensionDescription( Reference<css::ucb::XCommandEnvironment> xFilter = static_cast<css::ucb::XCommandEnvironment*>( new FileDoesNotExistFilter(xCmdEnv)); - ::ucbhelper::Content descContent(sDescriptionUri, xFilter); + ::ucbhelper::Content descContent(sDescriptionUri, xFilter, xContext); //throws an com::sun::star::uno::Exception if the file is not available Reference<css::io::XInputStream> xIn; diff --git a/desktop/source/deployment/misc/dp_ucb.cxx b/desktop/source/deployment/misc/dp_ucb.cxx index 9ec87c0f123f..f8ca15915d15 100644 --- a/desktop/source/deployment/misc/dp_ucb.cxx +++ b/desktop/source/deployment/misc/dp_ucb.cxx @@ -38,7 +38,7 @@ #include "com/sun/star/ucb/CommandFailedException.hpp" #include "com/sun/star/ucb/ContentInfo.hpp" #include "com/sun/star/ucb/ContentInfoAttribute.hpp" - +#include "comphelper/processfactory.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -63,7 +63,8 @@ bool create_ucb_content( // raise no such file dialogs, else no interaction for // passwords, ...? xxx todo ::ucbhelper::Content ucbContent( - url, Reference<XCommandEnvironment>() ); + url, Reference<XCommandEnvironment>(), + comphelper::getProcessComponentContext() ); ucbContent.isFolder(); diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 1243087297b7..52bc86b89612 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -448,7 +448,7 @@ void BackendImpl::initServiceRdbFiles() { const Reference<XCommandEnvironment> xCmdEnv; - ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv ); + ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv, m_xComponentContext ); ::ucbhelper::Content oldRDB; // switch common rdb: if (!m_commonRDB_orig.isEmpty()) @@ -697,7 +697,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString name; if (!bRemoved) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( url, xCmdEnv, m_xComponentContext ); name = StrTitle::getTitle( ucbContent ); } @@ -1004,7 +1004,7 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) buf2.getLength() ) ) ); ::ucbhelper::Content ucb_content( makeURL( getCachePath(), getPlatformString() + OUSTR("rc") ), - xCmdEnv ); + xCmdEnv, m_xComponentContext ); ucb_content.writeStream( xData, true /* replace existing */ ); } for (t_stringlist::iterator i(m_components.begin()); @@ -1035,7 +1035,7 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) reinterpret_cast<sal_Int8 const *>(buf.getStr()), buf.getLength() ) ) ); ::ucbhelper::Content ucb_content( - makeURL( getCachePath(), OUSTR("unorc") ), xCmdEnv ); + makeURL( getCachePath(), OUSTR("unorc") ), xCmdEnv, m_xComponentContext ); ucb_content.writeStream( xData, true /* replace existing */ ); m_unorc_modified = false; diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index b0fb42597a43..c1019bacefe4 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -349,11 +349,11 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString name; if (!bRemoved) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( url, xCmdEnv, m_xComponentContext ); name = StrTitle::getTitle( ucbContent ); } - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( url, xCmdEnv, m_xComponentContext ); if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.configuration-data")) { @@ -483,7 +483,7 @@ void BackendImpl::configmgrini_flush( reinterpret_cast<sal_Int8 const *>(buf.getStr()), buf.getLength() ) ) ); ::ucbhelper::Content ucb_content( - makeURL( getCachePath(), OUSTR("configmgr.ini") ), xCmdEnv ); + makeURL( getCachePath(), OUSTR("configmgr.ini") ), xCmdEnv, m_xComponentContext ); ucb_content.writeStream( xData, true /* replace existing */ ); m_configmgrini_modified = false; @@ -616,10 +616,10 @@ OUString encodeForXml( OUString const & text ) //______________________________________________________________________________ OUString replaceOrigin( - OUString const & url, OUString const & destFolder, Reference< XCommandEnvironment > const & xCmdEnv, bool & out_replaced) + OUString const & url, OUString const & destFolder, Reference< XCommandEnvironment > const & xCmdEnv, Reference< XComponentContext > const & xContext, bool & out_replaced) { // looking for %origin%: - ::ucbhelper::Content ucb_content( url, xCmdEnv ); + ::ucbhelper::Content ucb_content( url, xCmdEnv, xContext ); ::rtl::ByteSequence bytes( readFile( ucb_content ) ); ::rtl::ByteSequence filtered( bytes.getLength() * 2, ::rtl::BYTESEQ_NODEFAULT ); @@ -694,7 +694,7 @@ OUString replaceOrigin( newUrl = destFolder + url.copy(i); } - ucbhelper::Content(newUrl, xCmdEnv).writeStream( + ucbhelper::Content(newUrl, xCmdEnv, xContext).writeStream( xmlscript::createInputStream(filtered), true); out_replaced = true; return newUrl; @@ -726,7 +726,7 @@ void BackendImpl::PackageImpl::processPackage_( { const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); bool out_replaced = false; - url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced); + url = replaceOrigin(url, sModFolder, xCmdEnv, that->getComponentContext(), out_replaced); if (out_replaced) data.dataUrl = sModFolder; else @@ -783,7 +783,7 @@ void BackendImpl::PackageImpl::processPackage_( const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); bool out_replaced = false; url_replaced = replaceOrigin( - url2, sModFolder, xCmdEnv, out_replaced); + url2, sModFolder, xCmdEnv, that->getComponentContext(), out_replaced); if (out_replaced) data.dataUrl = sModFolder; else @@ -799,7 +799,7 @@ void BackendImpl::PackageImpl::processPackage_( { ::ucbhelper::Content( makeURL( that->getCachePath(), OUSTR("registry") ), - xCmdEnv ).executeCommand( + xCmdEnv, that->getComponentContext() ).executeCommand( OUSTR("delete"), Any( true /* delete physically */ ) ); } catch(const Exception&) diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index a3979bcad890..023430c72764 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -270,7 +270,7 @@ void PackageRegistryBackend::deleteUnusedFolders( { const OUString sDataFolder = makeURL(getCachePath(), relUrl); ::ucbhelper::Content tempFolder( - sDataFolder, Reference<ucb::XCommandEnvironment>()); + sDataFolder, Reference<ucb::XCommandEnvironment>(), m_xComponentContext); Reference<sdbc::XResultSet> xResultSet( StrTitle::createCursor( tempFolder, ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); @@ -578,8 +578,8 @@ void Package::exportTo( if (m_bRemoved) throw deployment::ExtensionRemovedException(); - ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv ); - ::ucbhelper::Content sourceContent( getURL(), xCmdEnv ); + ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv, getMyBackend()->getComponentContext() ); + ::ucbhelper::Content sourceContent( getURL(), xCmdEnv, getMyBackend()->getComponentContext() ); if (! destFolder.transferContent( sourceContent, ::ucbhelper::InsertOperation_COPY, newTitle, nameClashAction )) diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 4616c2a82aee..4c1105036210 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -70,7 +70,7 @@ void BackendDb::save() const Reference<css::io::XInputStream> xData( ::xmlscript::createInputStream(bytes)); - ::ucbhelper::Content ucbDb(m_urlDb, 0); + ::ucbhelper::Content ucbDb(m_urlDb, 0, m_xContext); ucbDb.writeStream(xData, true /*replace existing*/); } @@ -86,7 +86,8 @@ css::uno::Reference<css::xml::dom::XDocument> BackendDb::getDocument() if (err == ::osl::File::E_None) { ::ucbhelper::Content descContent( - m_urlDb, css::uno::Reference<css::ucb::XCommandEnvironment>()); + m_urlDb, css::uno::Reference<css::ucb::XCommandEnvironment>(), + m_xContext); Reference<css::io::XInputStream> xIn = descContent.openStream(); m_doc = xDocBuilder->parse(xIn); } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 17c056d6443b..f8006532f36d 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -187,7 +187,8 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString name; if (!bRemoved) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( + url, xCmdEnv, getComponentContext() ); name = StrTitle::getTitle( ucbContent ); } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index ba3b785b3673..b094d20ec523 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -203,7 +203,8 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString name; if (!bRemoved) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( + url, xCmdEnv, getComponentContext() ); name = StrTitle::getTitle( ucbContent ); } diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index ea4e345b22cd..cd1fd3066c42 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -437,7 +437,8 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString name; if (!bRemoved) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( + url, xCmdEnv, getComponentContext() ); name = StrTitle::getTitle( ucbContent ); } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { @@ -589,7 +590,8 @@ OUString BackendImpl::PackageImpl::getTextFromURL( { try { - ::ucbhelper::Content descContent(licenseUrl, xCmdEnv); + ::ucbhelper::Content descContent( + licenseUrl, xCmdEnv, getMyBackend()->getComponentContext()); ::rtl::ByteSequence seq = dp_misc::readFile(descContent); return OUString( reinterpret_cast<sal_Char const *>( seq.getConstArray()), seq.getLength(), RTL_TEXTENCODING_UTF8); @@ -1047,7 +1049,8 @@ void BackendImpl::PackageImpl::exportTo( if (m_bRemoved) throw deployment::ExtensionRemovedException(); - ::ucbhelper::Content sourceContent( m_url_expanded, xCmdEnv ); + ::ucbhelper::Content sourceContent( + m_url_expanded, xCmdEnv, getMyBackend()->getComponentContext() ); OUString title(newTitle); if (title.isEmpty()) sourceContent.getPropertyValue( OUSTR( "Title" ) ) >>= title; @@ -1089,7 +1092,8 @@ void BackendImpl::PackageImpl::exportTo( buf.append( static_cast<sal_Unicode>('/') ); OUString destFolder( buf.makeStringAndClear() ); - ::ucbhelper::Content destFolderContent( destFolder, xCmdEnv ); + ::ucbhelper::Content destFolderContent( + destFolder, xCmdEnv, getMyBackend()->getComponentContext() ); { // transfer every item of folder into zip: Reference<sdbc::XResultSet> xResultSet( @@ -1101,7 +1105,8 @@ void BackendImpl::PackageImpl::exportTo( { ::ucbhelper::Content subContent( Reference<ucb::XContentAccess>( - xResultSet, UNO_QUERY_THROW )->queryContent(), xCmdEnv ); + xResultSet, UNO_QUERY_THROW )->queryContent(), + xCmdEnv, getMyBackend()->getComponentContext() ); if (! destFolderContent.transferContent( subContent, ::ucbhelper::InsertOperation_COPY, OUString(), ucb::NameClash::OVERWRITE )) @@ -1156,7 +1161,8 @@ void BackendImpl::PackageImpl::exportTo( OUString fullPath; if (url_.getLength() > baseURLlen) fullPath = url_.copy( baseURLlen + 1 ); - ::ucbhelper::Content ucbContent( url_, xCmdEnv ); + ::ucbhelper::Content ucbContent( + url_, xCmdEnv, getMyBackend()->getComponentContext() ); if (ucbContent.getPropertyValue(strIsFolder).get<bool>()) fullPath += OUSTR("/"); Sequence<beans::PropertyValue> attribs( 2 ); @@ -1190,7 +1196,7 @@ void BackendImpl::PackageImpl::exportTo( // write buffered pipe data to content: ::ucbhelper::Content manifestContent( makeURL( metainfFolderContent.getURL(), OUSTR("manifest.xml") ), - xCmdEnv ); + xCmdEnv, getMyBackend()->getComponentContext() ); manifestContent.writeStream( Reference<io::XInputStream>( xPipe, UNO_QUERY_THROW ), true /* replace existing */ ); @@ -1553,7 +1559,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle( Reference<ucb::XCommandEnvironment> const & xCmdEnv, bool skip_registration ) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::ucbhelper::Content ucbContent( + url, xCmdEnv, getMyBackend()->getComponentContext() ); // check for platform paths: const OUString title( StrTitle::getTitle( ucbContent ) ); diff --git a/desktop/source/deployment/registry/script/dp_lib_container.cxx b/desktop/source/deployment/registry/script/dp_lib_container.cxx index 8240feafc7c3..bb9b968287af 100644 --- a/desktop/source/deployment/registry/script/dp_lib_container.cxx +++ b/desktop/source/deployment/registry/script/dp_lib_container.cxx @@ -62,7 +62,7 @@ OUString LibraryContainer::get_libname( Reference<XComponentContext> const & xContext ) { ::xmlscript::LibDescriptor import; - ::ucbhelper::Content ucb_content( url, xCmdEnv ); + ::ucbhelper::Content ucb_content( url, xCmdEnv, xContext ); xml_parse( ::xmlscript::importLibrary( import ), ucb_content, xContext ); if (import.aName.isEmpty()) { diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index 52b4ab884a1b..a034828646be 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -41,11 +41,10 @@ #include "osl/file.hxx" #include "osl/thread.hxx" #include "tools/getprocessworkingdir.hxx" -#include "ucbhelper/contentbroker.hxx" -#include "ucbhelper/configurationkeys.hxx" #include "comphelper/processfactory.hxx" #include "unotools/configmgr.hxx" #include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/ucb/UniversalContentBroker.hpp" #include "cppuhelper/bootstrap.hxx" #include "comphelper/sequence.hxx" #include <stdio.h> @@ -384,15 +383,10 @@ Reference<XComponentContext> bootstrapStandAlone( // set global process service factory used by unotools config helpers ::comphelper::setProcessServiceFactory( xServiceManager ); - // initialize the ucbhelper ucb, - // because the package implementation uses it - Sequence<Any> ucb_args( 2 ); - ucb_args[ 0 ] <<= OUSTR(UCB_CONFIGURATION_KEY1_LOCAL); - ucb_args[ 1 ] <<= OUSTR(UCB_CONFIGURATION_KEY2_OFFICE); - if (! ::ucbhelper::ContentBroker::initialize( xServiceManager, ucb_args )) - throw RuntimeException( OUSTR("cannot initialize UCB!"), 0 ); + // Initialize the UCB (for backwards compatibility, in case some code still + // uses plain createInstance w/o args directly to obtain an instance): + UniversalContentBroker::create( xContext ); - disposeGuard.setDeinitUCB(); return xContext; } diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h index 400e2835199e..c8cdc3c51a78 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_shared.h +++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h @@ -35,8 +35,6 @@ #include "tools/resmgr.hxx" #include "rtl/ustring.hxx" #include "unotools/configmgr.hxx" -#include "ucbhelper/contentbroker.hxx" - #define APP_NAME "unopkg" @@ -126,14 +124,10 @@ bool isBootstrapVariable(sal_uInt32 * pIndex); class DisposeGuard { css::uno::Reference<css::lang::XComponent> m_xComp; - bool m_bDeinitUCB; + public: - DisposeGuard(): m_bDeinitUCB(false) {} inline ~DisposeGuard() { - if (m_bDeinitUCB) - ::ucbhelper::ContentBroker::deinitialize(); - if (m_xComp.is()) m_xComp->dispose(); } @@ -143,12 +137,6 @@ public: { m_xComp = xComp; } - - inline void setDeinitUCB() - { - m_bDeinitUCB = true; - } - }; //============================================================================== |