From 9ac86f484b0c278aafbce685ed19d3ea005ee8f8 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 14 Sep 2012 18:08:57 +0200 Subject: Improvement on previous commit, UCB clean up * As UCB is only ever initialized with "Local"/"Office", remove this configuration vector completely. The "create" ctor creates an instance internally initialized with those "Local"/"Office" keys. Special (test) code can still instantiate an uninitialized one via plain createInstance. And for backwards compatilibity process startup still ensures to create an initialized instance early, in case there is still code out there (in extensions) that later calls plain createInstance and expects to get the already-initialized (single) instance. * XInitialization is an "implementation detail" of the UniversalContentBroker service, do not expose in XUniversalContentBroker. * ucbhelper/configurationkeys.hxx is no longer needed and is removed. * ucbhelper/contentbroker.hxx is an empty wrapper and is removed; however, that requires ucbhelper::Content constructors to take explicit XComponentContext arguments now. * The only remaining code in ucbhelper/source/client/contentbroker.cxx is Android-only InitUCBHelper. Is that relevant still? Change-Id: I3f7bddd0456bffbcd13590c66d9011915c760f28 --- .../source/drivers/dbase/DDatabaseMetaData.cxx | 3 +- connectivity/source/drivers/dbase/DTable.cxx | 17 ++++++------ connectivity/source/drivers/file/FConnection.cxx | 9 ++++-- .../source/drivers/file/FDatabaseMetaData.cxx | 32 ++++++++-------------- 4 files changed, 29 insertions(+), 32 deletions(-) (limited to 'connectivity/source') diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx index f453e9b20bc2..9cd9613a082d 100644 --- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -30,6 +30,7 @@ #include "dbase/DIndex.hxx" #include "connectivity/FValue.hxx" #include +#include #include #include #include @@ -378,7 +379,7 @@ sal_Bool SAL_CALL ODbaseDatabaseMetaData::isReadOnly( ) throw(SQLException, Run sal_Bool bReadOnly = sal_False; static ::rtl::OUString sReadOnly( "IsReadOnly" ); - ::ucbhelper::Content aFile(m_pConnection->getContent(),Reference< XCommandEnvironment >()); + ::ucbhelper::Content aFile(m_pConnection->getContent(),Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext()); aFile.getPropertyValue(sReadOnly) >>= bReadOnly; return bReadOnly; diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 9bd6c0e868fc..28d4436931ec 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -29,6 +29,7 @@ #include #include "dbase/DIndex.hxx" #include "dbase/DIndexes.hxx" +#include #include #include #include @@ -694,7 +695,7 @@ void ODbaseTable::refreshIndexes() aURL.setName(rtl::OStringToOUString(aIndexName, m_eEncoding)); try { - Content aCnt(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aCnt(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); if (aCnt.isDocument()) { aVector.push_back(aURL.getBase()); @@ -1051,7 +1052,7 @@ sal_Bool ODbaseTable::CreateImpl() try { - Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); if (aContent.isDocument()) { // Only if the file exists with length > 0 raise an error @@ -1078,7 +1079,7 @@ sal_Bool ODbaseTable::CreateImpl() { try { - Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); aContent.executeCommand( rtl::OUString("delete"),bool2any( sal_True ) ); } catch(const Exception&) // an exception is thrown when no file exists @@ -1091,7 +1092,7 @@ sal_Bool ODbaseTable::CreateImpl() { String aExt = aURL.getExtension(); aURL.setExtension(rtl::OUString("dbt")); // extension for memo file - Content aMemo1Content(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aMemo1Content(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); sal_Bool bMemoAlreadyExists = sal_False; try @@ -1106,7 +1107,7 @@ sal_Bool ODbaseTable::CreateImpl() aURL.setExtension(aExt); // kill dbf file try { - Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); aMemoContent.executeCommand( rtl::OUString("delete"),bool2any( sal_True ) ); } catch(const Exception&) @@ -1122,7 +1123,7 @@ sal_Bool ODbaseTable::CreateImpl() if (!CreateMemoFile(aURL)) { aURL.setExtension(aExt); // kill dbf file - Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); aMemoContent.executeCommand( rtl::OUString("delete"),bool2any( sal_True ) ); return sal_False; } @@ -1460,7 +1461,7 @@ sal_Bool ODbaseTable::Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMem // as the inf file does not necessarily exist, we aren't allowed to use UCBContentHelper::Kill try { - ::ucbhelper::Content aDeleteContent( aURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment > () ); + ::ucbhelper::Content aDeleteContent( aURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext() ); aDeleteContent.executeCommand( ::rtl::OUString("delete"), makeAny( sal_Bool( sal_True ) ) ); } catch(const Exception&) @@ -2319,7 +2320,7 @@ namespace try { - Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference()); + Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference(), comphelper::getProcessComponentContext()); Sequence< PropertyValue > aProps( 1 ); aProps[0].Name = ::rtl::OUString("Title"); diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx index 4aa2cffc1242..2fa26d5b3a95 100644 --- a/connectivity/source/drivers/file/FConnection.cxx +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "sal/config.h" + +#include #include #include "file/FConnection.hxx" #include "file/FDatabaseMetaData.hxx" @@ -157,7 +160,7 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV ::ucbhelper::Content aFile; try { - aFile = ::ucbhelper::Content(getURL(),Reference< XCommandEnvironment >()); + aFile = ::ucbhelper::Content(getURL(), Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext()); } catch(ContentCreationException& e) { @@ -182,7 +185,7 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV Reference xIdent = xParent->getIdentifier(); m_xContent = xParent; - ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >()); + ::ucbhelper::Content aParent(xIdent->getContentIdentifier(), Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext()); m_xDir = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ); } else @@ -398,7 +401,7 @@ Reference< XDynamicResultSet > OConnection::getDir() const try { Reference xIdent = getContent()->getIdentifier(); - ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >()); + ::ucbhelper::Content aParent(xIdent->getContentIdentifier(), Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext()); xContent = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ); } catch(Exception&) diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx index 61998d2a23aa..86ea5f2b1c9c 100644 --- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx +++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx @@ -24,18 +24,17 @@ #include #include #include +#include #include -#include #include #include #include "file/FDriver.hxx" #include "file/FTable.hxx" #include -#include -#include +#include #include #include - +#include using namespace com::sun::star::ucb; using namespace connectivity::file; @@ -94,14 +93,14 @@ namespace INetURLObject aContentURL( _rFolderOrDoc ); ::ucbhelper::Content aContent1; { - ::ucbhelper::Content aFolderOrDoc( _rFolderOrDoc, Reference< XCommandEnvironment >() ); + ::ucbhelper::Content aFolderOrDoc( _rFolderOrDoc, Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext() ); if ( aFolderOrDoc.isDocument() ) aContent1 = aFolderOrDoc; else { aContentURL = INetURLObject( _rFolderOrDoc, INetURLObject::WAS_ENCODED ); aContentURL.Append( _rDocName ); - aContent1 = ::ucbhelper::Content( aContentURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() ); + aContent1 = ::ucbhelper::Content( aContentURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext() ); } } @@ -125,7 +124,7 @@ namespace ::ucbhelper::Content aContent2; try { - aContent2 = ::ucbhelper::Content( aURL2.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() ); + aContent2 = ::ucbhelper::Content( aURL2.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext() ); bCanAccess = aContent2.isDocument(); } catch( const Exception& ) @@ -144,20 +143,13 @@ namespace Reference< XContentIdentifier > xID1 = xContent1->getIdentifier(); Reference< XContentIdentifier > xID2 = xContent2->getIdentifier(); OSL_ENSURE( xID1.is() && xID2.is(), "isCaseSensitiveParentFolder: invalid ID interfaces!" ); - if ( xID1.is() && xID2.is() ) + if ( xID1.is() && xID2.is() + && ( UniversalContentBroker::create( + comphelper::getProcessComponentContext() )-> + compareContentIds( xID1, xID2 ) == 0 ) ) { - // get a generic content provider - ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get(); - Reference< XContentProvider > xProvider; - if ( pBroker ) - xProvider = pBroker->getContentProviderInterface(); - OSL_ENSURE( xProvider.is(), "isCaseSensitiveParentFolder: invalid content broker!" ); - if ( xProvider.is() ) - { - if ( 0 == xProvider->compareContentIds( xID1, xID2 ) ) - // finally, we know that the folder is not case-sensitive .... - nIsCS = 0; - } + // finally, we know that the folder is not case-sensitive .... + nIsCS = 0; } } } -- cgit