diff options
49 files changed, 283 insertions, 282 deletions
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx index 4c08dd1cbde0..a0f8bc515db1 100644 --- a/connectivity/inc/connectivity/dbtools.hxx +++ b/connectivity/inc/connectivity/dbtools.hxx @@ -60,7 +60,9 @@ namespace lang { namespace container { class XNameAccess; } - +namespace uno { + class XComponentContext; +} namespace util { class XNumberFormatTypes; class XNumberFormatsSupplier; @@ -505,7 +507,7 @@ namespace dbtools sal_Int32 _nDataType); // return the datasource for the given datasource name OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getDataSource(const ::rtl::OUString& _rsDataSourceName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext); /** search for a name that is NOT in the NameAcces @param _rxContainer diff --git a/connectivity/inc/connectivity/virtualdbtools.hxx b/connectivity/inc/connectivity/virtualdbtools.hxx index dfd6ebad32f5..dafaa45c4988 100644 --- a/connectivity/inc/connectivity/virtualdbtools.hxx +++ b/connectivity/inc/connectivity/virtualdbtools.hxx @@ -61,6 +61,9 @@ namespace com { class XColumn; class SQLContext; } + namespace uno { + class XComponentContext; + } namespace container { class XNameAccess; } @@ -175,7 +178,7 @@ namespace connectivity virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource( const ::rtl::OUString& _rsRegisteredName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext ) const = 0; virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index f175c3ed5a66..24f29a15729a 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/BooleanComparisonMode.hpp> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/ParametersRequest.hpp> @@ -62,6 +63,7 @@ #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/util/XNumberFormatTypes.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/extract.hxx> #include <comphelper/interaction.hxx> #include <comphelper/property.hxx> @@ -245,14 +247,11 @@ Reference< XConnection> findConnection(const Reference< XInterface >& xParent) //------------------------------------------------------------------------------ Reference< XDataSource> getDataSource_allowException( const ::rtl::OUString& _rsTitleOrPath, - const Reference< XMultiServiceFactory >& _rxFactory ) + const Reference< XComponentContext >& _rxContext ) { ENSURE_OR_RETURN( !_rsTitleOrPath.isEmpty(), "getDataSource_allowException: invalid arg !", NULL ); - Reference< XNameAccess> xDatabaseContext( - _rxFactory->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DatabaseContext" )) ),UNO_QUERY ); - OSL_ENSURE( xDatabaseContext.is(), "getDataSource_allowException: could not obtain the database context!" ); + Reference< XDatabaseContext> xDatabaseContext = DatabaseContext::create(_rxContext); return Reference< XDataSource >( xDatabaseContext->getByName( _rsTitleOrPath ), UNO_QUERY ); } @@ -260,12 +259,12 @@ Reference< XDataSource> getDataSource_allowException( //------------------------------------------------------------------------------ Reference< XDataSource > getDataSource( const ::rtl::OUString& _rsTitleOrPath, - const Reference< XMultiServiceFactory >& _rxFactory ) + const Reference< XComponentContext >& _rxContext ) { Reference< XDataSource > xDS; try { - xDS = getDataSource_allowException( _rsTitleOrPath, _rxFactory ); + xDS = getDataSource_allowException( _rsTitleOrPath, _rxContext ); } catch( const Exception& ) { @@ -282,7 +281,7 @@ Reference< XConnection > getConnection_allowException( const ::rtl::OUString& _rsPwd, const Reference< XMultiServiceFactory>& _rxFactory) { - Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, _rxFactory) ); + Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, comphelper::ComponentContext(_rxFactory).getUNOContext()) ); Reference<XConnection> xConnection; if (xDataSource.is()) { diff --git a/connectivity/source/simpledbt/staticdbtools_s.cxx b/connectivity/source/simpledbt/staticdbtools_s.cxx index 6c8c9ae9fbef..797555c0c996 100644 --- a/connectivity/source/simpledbt/staticdbtools_s.cxx +++ b/connectivity/source/simpledbt/staticdbtools_s.cxx @@ -149,9 +149,9 @@ namespace connectivity } //---------------------------------------------------------------- - Reference< XDataSource > ODataAccessStaticTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XMultiServiceFactory>& _rxFactory ) const + Reference< XDataSource > ODataAccessStaticTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XComponentContext>& _rxContext ) const { - return ::dbtools::getDataSource( _rsRegisteredName, _rxFactory ); + return ::dbtools::getDataSource( _rsRegisteredName, _rxContext ); } //---------------------------------------------------------------- diff --git a/connectivity/source/simpledbt/staticdbtools_s.hxx b/connectivity/source/simpledbt/staticdbtools_s.hxx index da0f1beca30f..3132f00e36b4 100644 --- a/connectivity/source/simpledbt/staticdbtools_s.hxx +++ b/connectivity/source/simpledbt/staticdbtools_s.hxx @@ -138,7 +138,7 @@ namespace connectivity // ------------------------------------------------ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource( const ::rtl::OUString& _rsRegisteredName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext ) const; // ------------------------------------------------ diff --git a/cui/source/options/dbregisterednamesconfig.cxx b/cui/source/options/dbregisterednamesconfig.cxx index bb935779f273..c2829b16f640 100644 --- a/cui/source/options/dbregisterednamesconfig.cxx +++ b/cui/source/options/dbregisterednamesconfig.cxx @@ -31,6 +31,7 @@ #include "dbregistersettings.hxx" #include "svx/svxids.hrc" #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XDatabaseRegistrations.hpp> #include <comphelper/componentcontext.hxx> #include <comphelper/extract.hxx> @@ -61,9 +62,9 @@ namespace svx try { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); Reference< XDatabaseRegistrations > xRegistrations( - aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + DatabaseContext::create(xContext), UNO_QUERY_THROW ); Sequence< ::rtl::OUString > aRegistrationNames( xRegistrations->getRegistrationNames() ); const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray(); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index e8bc7740cd2b..c4ac4ef2f09b 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/ErrorCondition.hpp> #include <com/sun/star/sdb/RowChangeAction.hpp> #include <com/sun/star/sdb/RowSetVetoException.hpp> @@ -2154,9 +2155,7 @@ Reference< XConnection > ORowSet::calcConnection(const Reference< XInteractionH Reference< XConnection > xNewConn; if ( !m_aDataSourceName.isEmpty() ) { - Reference< XNameAccess > xDatabaseContext( - m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), - UNO_QUERY_THROW ); + Reference< XNameAccess > xDatabaseContext( DatabaseContext::create(m_aContext.getUNOContext()), UNO_QUERY_THROW ); try { Reference< XDataSource > xDataSource( xDatabaseContext->getByName( m_aDataSourceName ), UNO_QUERY_THROW ); diff --git a/dbaccess/source/core/dataaccess/databasecontext.hxx b/dbaccess/source/core/dataaccess/databasecontext.hxx index 83b0195b096a..6e4342597032 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.hxx +++ b/dbaccess/source/core/dataaccess/databasecontext.hxx @@ -31,6 +31,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sdb/XDatabaseContext.hpp> #include <com/sun/star/sdb/XDatabaseEnvironment.hpp> #include <com/sun/star/sdb/XDatabaseRegistrations.hpp> #include <com/sun/star/uno/XNamingService.hpp> @@ -39,7 +40,7 @@ #include <basic/basicmanagerrepository.hxx> #include <comphelper/componentcontext.hxx> #include <comphelper/stl_types.hxx> -#include <cppuhelper/compbase8.hxx> +#include <cppuhelper/compbase3.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <boost/shared_ptr.hpp> @@ -64,14 +65,9 @@ class DatabaseDocumentLoader; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ODatabaseContext_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&); -typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::container::XEnumerationAccess - , ::com::sun::star::container::XNameAccess - , ::com::sun::star::uno::XNamingService - , ::com::sun::star::container::XContainer - , ::com::sun::star::lang::XSingleServiceFactory +typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::sdb::XDatabaseContext , ::com::sun::star::lang::XUnoTunnel - , ::com::sun::star::sdb::XDatabaseRegistrations > DatabaseAccessContext_Base; class ODatabaseContext :public DatabaseAccessContext_Base diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 9b49dc4c62ba..83435d826e2c 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -53,6 +53,7 @@ #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/ucb/XContent.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> @@ -101,6 +102,7 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::embed; using namespace ::com::sun::star::task; using namespace ::com::sun::star::view; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star; using namespace ::com::sun::star::xml::sax; @@ -1868,7 +1870,7 @@ Sequence< ::rtl::OUString > ODatabaseDocument::getSupportedServiceNames( ) thro Reference< XInterface > ODatabaseDocument::Create( const Reference< XComponentContext >& _rxContext ) { ::comphelper::ComponentContext aContext( _rxContext ); - Reference< XUnoTunnel > xDBContextTunnel( aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), UNO_QUERY_THROW ); + Reference< XUnoTunnel > xDBContextTunnel( DatabaseContext::create(_rxContext), UNO_QUERY_THROW ); ODatabaseContext* pContext = reinterpret_cast< ODatabaseContext* >( xDBContextTunnel->getSomething( ODatabaseContext::getUnoTunnelImplementationId() ) ); ::rtl::Reference<ODatabaseModelImpl> pImpl( new ODatabaseModelImpl( aContext.getLegacyServiceFactory(), *pContext ) ); diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 061d873ef0a7..a0480dfeb376 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/reflection/XProxyFactory.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdbc/XDriverAccess.hpp> #include <com/sun/star/sdbc/XDriverManager.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> @@ -600,8 +601,7 @@ Sequence< ::rtl::OUString > ODatabaseSource::getSupportedServiceNames( ) throw Reference< XInterface > ODatabaseSource::Create( const Reference< XComponentContext >& _rxContext ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::Create" ); - ::comphelper::ComponentContext aContext( _rxContext ); - Reference< XSingleServiceFactory > xDBContext( aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), UNO_QUERY_THROW ); + Reference< XSingleServiceFactory > xDBContext( DatabaseContext::create(_rxContext), UNO_QUERY_THROW ); return xDBContext->createInstance(); } diff --git a/dbaccess/source/filter/xml/dbloader2.cxx b/dbaccess/source/filter/xml/dbloader2.cxx index bad3711e4ceb..6441d8d9f46e 100644 --- a/dbaccess/source/filter/xml/dbloader2.cxx +++ b/dbaccess/source/filter/xml/dbloader2.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> #include <com/sun/star/task/XJobExecutor.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> @@ -445,9 +446,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: sal_Int32 nInitialSelection = -1; if ( !xModel.is() ) { - Reference< XSingleServiceFactory > xDatabaseContext; - if ( !m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT, xDatabaseContext ) ) - throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "css.sdb.DatabaseContext not available" ) ), NULL ); + Reference< XSingleServiceFactory > xDatabaseContext( DatabaseContext::create(m_aContext.getUNOContext()), UNO_QUERY_THROW ); ::rtl::OUString sFactoryName = SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE); bCreateNew = sFactoryName.match(_rURL); diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index cb8d8b947bb2..ed7fadf037f8 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -34,6 +34,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/extract.hxx> #include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -255,7 +256,7 @@ sal_Bool OGenericUnoController::Construct(Window* /*pParent*/) OSL_ENSURE(getORB().is(), "OGenericUnoController::Construct need a service factory!"); try { - m_xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + m_xDatabaseContext = Reference< XNameAccess >( DatabaseContext::create(comphelper::ComponentContext(getORB()).getUNOContext()), UNO_QUERY_THROW ); } catch(Exception&) { diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index a0d53c47c5d5..da713f32d1d6 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdbc/XDriver.hpp> #include <com/sun/star/sdbc/XDriverAccess.hpp> @@ -49,6 +50,7 @@ #include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp> #include <com/sun/star/ucb/AuthenticationRequest.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/guarding.hxx> #include <comphelper/interaction.hxx> #include <comphelper/property.hxx> @@ -206,7 +208,7 @@ ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper(const Refer try { - m_xDatabaseContext = Reference< XNameAccess >(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + m_xDatabaseContext = Reference< XNameAccess >( DatabaseContext::create(comphelper::ComponentContext(m_xORB).getUNOContext()), UNO_QUERY_THROW ); m_xDynamicContext.set(m_xDatabaseContext,UNO_QUERY); } catch(Exception&) diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 274c81353e90..664879d7807f 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -858,8 +859,8 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(const ::rtl::OUString& _sPath) { Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); - Reference< XNamingService > xDatabaseContext(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); - Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY); + Reference< XNamingService > xDatabaseContext( DatabaseContext::create(comphelper::ComponentContext(getORB()).getUNOContext()), UNO_QUERY_THROW ); + Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY_THROW ); INetURLObject aURL( _sPath ); ::rtl::OUString sFilename = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); ::rtl::OUString sDatabaseName = ::dbtools::createUniqueName(xNameAccessDatabaseContext, sFilename,sal_False); diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx index 4abcb5920866..574b3ad231e7 100644 --- a/dbaccess/source/ui/inc/UITools.hxx +++ b/dbaccess/source/ui/inc/UITools.hxx @@ -57,6 +57,7 @@ namespace com { namespace sun { namespace star { class XNumberFormatter; } namespace ucb { class XContent; } + namespace uno { class XComponentContext; } }}} @@ -138,7 +139,7 @@ namespace dbaui /** checks if the given name exists in the database context */ sal_Bool checkDataSourceAvailable( const ::rtl::OUString& _sDataSourceName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory_xORB); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext); /** maps SvxCellHorJustify to com::sun::star::awt::TextAlign @param SvxCellHorJustify& _eAlignment @@ -215,7 +216,7 @@ namespace dbaui */ sal_Bool appendToFilter(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection, const ::rtl::OUString& _sName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, Window* _pParent); /** notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search _pWindow. diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index 36c922cdc180..9c30b73dbf91 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -29,6 +29,7 @@ #include <comphelper/string.hxx> #include <comphelper/types.hxx> #include <connectivity/dbtools.hxx> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> @@ -276,7 +277,7 @@ void ODatabaseImportExport::initialize() if ( !m_xConnection.is() ) { // we need a connection OSL_ENSURE(!m_sDataSourceName.isEmpty(),"There must be a datsource name!"); - Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(m_xFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + Reference<XNameAccess> xDatabaseContext( DatabaseContext::create(comphelper::ComponentContext(m_xFactory).getUNOContext()), UNO_QUERY_THROW); Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY); Reference< XConnection > xConnection; diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 4131abc204e0..0ac020f5e792 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -27,6 +27,7 @@ #include "dbtreelistbox.hxx" #include "defaultobjectnamecheck.hxx" #include <comphelper/extract.hxx> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> @@ -223,7 +224,7 @@ Reference< XDataSource > getDataSourceByName( const ::rtl::OUString& _rDataSourc Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, ::dbtools::SQLExceptionInfo* _pErrorInfo ) { ::comphelper::ComponentContext aContext( _rxORB ); - Reference< XNameAccess > xDatabaseContext( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + Reference< XDatabaseContext > xDatabaseContext = DatabaseContext::create(aContext.getUNOContext()); Reference< XDataSource > xDatasource; Any aError; @@ -722,22 +723,18 @@ void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDe return sDefaultName; } // ----------------------------------------------------------------------------- -sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) +sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const Reference< ::com::sun::star::uno::XComponentContext >& _xContext) { - sal_Bool bRet = sal_False; - Reference< XNameAccess > xDataBaseContext(_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); - if ( xDataBaseContext.is() ) - { - bRet = xDataBaseContext->hasByName(_sDataSourceName); - if ( !bRet ) - { // try if this one is a URL - try - { - bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue(); - } - catch(const Exception&) - { - } + Reference< XDatabaseContext > xDataBaseContext = DatabaseContext::create(_xContext); + sal_Bool bRet = xDataBaseContext->hasByName(_sDataSourceName); + if ( !bRet ) + { // try if this one is a URL + try + { + bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue(); + } + catch(const Exception&) + { } } return bRet; @@ -1019,7 +1016,7 @@ const SfxFilter* getStandardDatabaseFilter() // ----------------------------------------------------------------------------- sal_Bool appendToFilter(const Reference<XConnection>& _xConnection, const ::rtl::OUString& _sName, - const Reference< XMultiServiceFactory >& _xFactory, + const Reference< XComponentContext >& _rxContext, Window* _pParent) { sal_Bool bRet = sal_False; @@ -1050,7 +1047,7 @@ sal_Bool appendToFilter(const Reference<XConnection>& _xConnection, bRet = sal_True; if(bHasToInsert) { - if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_xFactory)) + if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_rxContext)) { String aMessage(ModuleRes(STR_TABLEDESIGN_DATASOURCE_DELETED)); OSQLWarningBox( _pParent, aMessage ).Execute(); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 782eb3cb9f3f..e7e0ae95ccdf 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/sdbcx/XViewsSupplier.hpp> #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/extract.hxx> #include <comphelper/types.hxx> #include <comphelper/interaction.hxx> @@ -1337,7 +1338,7 @@ Reference< XPropertySet > OCopyTableWizard::createTable() { xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW ); // insert new table name into table filter - ::dbaui::appendToFilter( m_xDestConnection, m_sName, GetFactory(), this ); + ::dbaui::appendToFilter( m_xDestConnection, m_sName, comphelper::ComponentContext(GetFactory()).getUNOContext(), this ); // copy ui settings m_rSourceObject.copyUISettingsTo( xTable ); diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 7ae234877f80..6d46ff69c348 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -1534,7 +1534,7 @@ bool OQueryController::doSaveAsDoc(sal_Bool _bSaveAs) m_xAlterView.set( xElements->getByName( m_sName ), UNO_QUERY ); // now check if our datasource has set a tablefilter and if so, append the new table name to it - ::dbaui::appendToFilter( getConnection(), m_sName, getORB(), getView() ); + ::dbaui::appendToFilter( getConnection(), m_sName, comphelper::ComponentContext(getORB()).getUNOContext(), getView() ); } Reference< XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY); if ( xEventListener.is() ) diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index ec23a4ba830b..8a72e9082919 100644 --- a/dbaccess/source/ui/relationdesign/RelationController.cxx +++ b/dbaccess/source/ui/relationdesign/RelationController.cxx @@ -26,6 +26,7 @@ #include "dbustrings.hrc" #include <connectivity/dbtools.hxx> #include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/extract.hxx> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -160,7 +161,7 @@ void ORelationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue case ID_BROWSER_SAVEDOC: { OSL_ENSURE(isEditable(),"Slot ID_BROWSER_SAVEDOC should not be enabled!"); - if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_NAME)),getORB())) + if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_NAME)), comphelper::ComponentContext(getORB()).getUNOContext())) { String aMessage(ModuleRes(STR_DATASOURCE_DELETED)); OSQLWarningBox( getView(), aMessage ).Execute(); diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index e86d6f1bc933..f7b969f09378 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -56,6 +56,7 @@ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/extract.hxx> #include <comphelper/streamsection.hxx> #include <comphelper/types.hxx> @@ -405,7 +406,7 @@ sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs) assignTable(); } // now check if our datasource has set a tablefilter and if append the new table name to it - ::dbaui::appendToFilter(getConnection(),m_sName,getORB(),getView()); // we are not interessted in the return value + ::dbaui::appendToFilter(getConnection(),m_sName,comphelper::ComponentContext(getORB()).getUNOContext(),getView()); // we are not interessted in the return value Reference< frame::XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY); if ( xEventListener.is() ) { diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index ea9ceb80b9f3..820569a903af 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdb/CommandType.hpp> @@ -103,6 +104,8 @@ namespace dbaui using ::com::sun::star::container::XChild; using ::com::sun::star::task::XInteractionHandler; using ::com::sun::star::frame::XModel; + using ::com::sun::star::sdb::DatabaseContext; + using ::com::sun::star::sdb::XDatabaseContext; using ::com::sun::star::sdb::XDocumentDataSource; using ::com::sun::star::sdb::XCompletedConnection; using ::com::sun::star::lang::WrappedTargetException; @@ -911,7 +914,7 @@ SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_DATABASE_LOCATION ) >>= sDatabaseLocation ); // need a DatabaseContext for loading the data source - Reference< XNameAccess > xDatabaseContext( m_aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + Reference< XDatabaseContext > xDatabaseContext = DatabaseContext::create( m_aContext.getUNOContext() ); Reference< XDataSource > xDataSource; if ( !sDataSource.isEmpty() ) xDataSource.set( xDatabaseContext->getByName( sDataSource ), UNO_QUERY_THROW ); diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx index 2c45e5e8cc7d..c91b480f53a1 100644 --- a/extensions/source/abpilot/datasourcehandling.cxx +++ b/extensions/source/abpilot/datasourcehandling.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdb/XDatabaseRegistrations.hpp> @@ -77,22 +78,21 @@ namespace abp //===================================================================== //--------------------------------------------------------------------- - static Reference< XNameAccess > lcl_getDataSourceContext( const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW (( Exception )) + static Reference< XDatabaseContext > lcl_getDataSourceContext( const Reference< XComponentContext >& _rxContext ) SAL_THROW (( Exception )) { - Reference< XNameAccess > xContext( _rxORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DatabaseContext" )) ), UNO_QUERY ); - DBG_ASSERT(xContext.is(), "lcl_getDataSourceContext: could not access the data source context!"); + Reference<XDatabaseContext> xContext = DatabaseContext::create(_rxContext); return xContext; } //--------------------------------------------------------------------- /// creates a new data source and inserts it into the context static void lcl_implCreateAndInsert( - const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rName, + const Reference< XComponentContext >& _rxContext, const ::rtl::OUString& _rName, Reference< XPropertySet >& /* [out] */ _rxNewDataSource ) SAL_THROW (( ::com::sun::star::uno::Exception )) { //............................................................. // get the data source context - Reference< XNameAccess > xContext = lcl_getDataSourceContext( _rxORB ); + Reference< XDatabaseContext > xContext = lcl_getDataSourceContext( _rxContext ); DBG_ASSERT( !xContext->hasByName( _rName ), "lcl_implCreateAndInsert: name already used!" ); (void)_rName; @@ -127,7 +127,7 @@ namespace abp { // create the new data source Reference< XPropertySet > xNewDataSource; - lcl_implCreateAndInsert( _rxORB, _rName, xNewDataSource ); + lcl_implCreateAndInsert( comphelper::ComponentContext(_rxORB).getUNOContext(), _rName, xNewDataSource ); //............................................................. // set the URL property @@ -200,7 +200,9 @@ namespace abp try { // create the UNO context - m_pImpl->xContext = lcl_getDataSourceContext( _rxORB ); + m_pImpl->xContext = Reference<XNameAccess>( + lcl_getDataSourceContext( comphelper::ComponentContext(_rxORB).getUNOContext() ), + UNO_QUERY_THROW); if (m_pImpl->xContext.is()) { diff --git a/extensions/source/bibliography/bibconfig.cxx b/extensions/source/bibliography/bibconfig.cxx index 652b4a5c01f9..c1696060e1f8 100644 --- a/extensions/source/bibliography/bibconfig.cxx +++ b/extensions/source/bibliography/bibconfig.cxx @@ -33,12 +33,14 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <comphelper/processfactory.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdb; using ::rtl::OUString; @@ -343,17 +345,9 @@ const Sequence<OUString>& DBChangeDialogConfig_Impl::GetDataSourceNames() { if(!aSourceNames.getLength()) { - Reference<XNameAccess> xDBContext; - Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" )); - xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ; - } - if(xDBContext.is()) - { - aSourceNames = xDBContext->getElementNames(); - } + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext); + aSourceNames = xDBContext->getElementNames(); } return aSourceNames; } diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index 2b04564d3538..05628020b236 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/uno/XNamingService.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> #include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> @@ -96,9 +97,9 @@ Reference< XConnection > getConnection(const ::rtl::OUString& _rURL) Reference< XDataSource > xDataSource; // is it a favorite title ? Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); - Reference<XInterface> xNamingContextIfc = xMgr->createInstance(C2U("com.sun.star.sdb.DatabaseContext")); - Reference< XNameAccess > xNamingContext(xNamingContextIfc, UNO_QUERY); - if (xNamingContext.is() && xNamingContext->hasByName(_rURL)) + Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); + Reference< XDatabaseContext > xNamingContext = DatabaseContext::create(xContext); + if (xNamingContext->hasByName(_rURL)) { DBG_ASSERT(Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !"); try diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx index abe80c4b535b..ba216b3d4451 100644 --- a/extensions/source/dbpilots/controlwizard.cxx +++ b/extensions/source/dbpilots/controlwizard.cxx @@ -30,6 +30,7 @@ #include <tools/debug.hxx> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdbc/XPreparedStatement.hpp> #include <com/sun/star/container/XChild.hpp> @@ -41,6 +42,7 @@ #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbc/SQLWarning.hpp> #include <com/sun/star/sdb/SQLContext.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/types.hxx> #include <connectivity/dbtools.hxx> #include <vcl/msgbox.hxx> @@ -444,13 +446,9 @@ namespace dbp { DBG_ASSERT(xORB.is(), "OControlWizard::implGetDSContext: invalid service factory!"); - Reference< XInterface > xContext; - if (xORB.is()) - xContext = xORB->createInstance(::rtl::OUString("com.sun.star.sdb.DatabaseContext")); - DBG_ASSERT(xContext.is(), "OControlWizard::implGetDSContext: invalid database context!"); - - m_aContext.xDatasourceContext = Reference< XNameAccess >(xContext, UNO_QUERY); - DBG_ASSERT(m_aContext.xDatasourceContext.is() || !xContext.is(), "OControlWizard::implGetDSContext: invalid database context (missing the XNameAccess)!"); + m_aContext.xDatasourceContext = Reference<XNameAccess>( + DatabaseContext::create(comphelper::ComponentContext(xORB).getUNOContext()), + UNO_QUERY_THROW); } catch(const Exception&) { diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index a9451c830e90..104d76c34115 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -235,6 +235,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/script/vba )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/sdb,\ DataAccessDescriptorFactory \ + DatabaseContext \ DatabaseInteractionHandler \ InteractionHandler \ )) @@ -973,7 +974,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/sdb,\ DatabaseAccessConnection \ DatabaseAccessContext \ DatabaseAccessDataSource \ - DatabaseContext \ DatabaseDocument \ DatabaseEnvironment \ DatasourceAdministrationDialog \ @@ -3092,6 +3092,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/sdb,\ XDataAccessDescriptorFactory \ XDatabaseAccess \ XDatabaseAccessListener \ + XDatabaseContext \ XDatabaseEnvironment \ XDatabaseRegistrations \ XDatabaseRegistrationsListener \ diff --git a/offapi/com/sun/star/sdb/DatabaseContext.idl b/offapi/com/sun/star/sdb/DatabaseContext.idl index 52ddc1c0a924..fee353634067 100644 --- a/offapi/com/sun/star/sdb/DatabaseContext.idl +++ b/offapi/com/sun/star/sdb/DatabaseContext.idl @@ -19,19 +19,9 @@ #ifndef __com_sun_star_sdb_DatabaseContext_idl__ #define __com_sun_star_sdb_DatabaseContext_idl__ -#include <com/sun/star/container/XEnumerationAccess.idl> +#include <com/sun/star/sdb/XDatabaseContext.idl> -#include <com/sun/star/container/XContainer.idl> - -#include <com/sun/star/lang/XSingleServiceFactory.idl> - -#include <com/sun/star/container/XNameAccess.idl> - -#include <com/sun/star/uno/XNamingService.idl> - - module com { module sun { module star { module sdb { - -published interface XDatabaseRegistrations; +module com { module sun { module star { module sdb { /** is the context for accessing datasource. @@ -44,50 +34,10 @@ published interface XDatabaseRegistrations; </p> @see com::sun::star::sdb::DataSource */ -published service DatabaseContext -{ - /** Enumeration on all registered data sources. - */ - interface com::sun::star::container::XEnumerationAccess; - - /** NameAccess on all registered data sources. - <p>One exception is the <method "com.sun.star.container.XNameAccess">getByName</method>, this method also allows to ask - for a <member "DataAccessDescriptor">DatabaseLocation</member>. - </p> - */ - interface com::sun::star::container::XNameAccess; - - /** Interface for registering new datasources. - */ - interface com::sun::star::uno::XNamingService; - - /** Interface for registering listener to get notified when new datasources are created or removed. - */ - interface com::sun::star::container::XContainer; - - /** Interface for creation of new datasources. - */ - interface com::sun::star::lang::XSingleServiceFactory; - - /** allows to access and modify the configuration data for registered data source. - - <p>The main purpose of this interface is to allow you to register data sources which you know - by URL only, and have not yet loaded.</p> - - <p>Also, it hides the details of the configuration data where the data source registrations - are maintained, so if possible at all, you should use this interface, instead of modifying or - querying the configuration data directly.</p> - - @since OOo 3.3 - */ - [optional] interface XDatabaseRegistrations; -}; - +published service DatabaseContext : XDatabaseContext; }; }; }; }; -/*=========================================================================== -===========================================================================*/ #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/sdb/DatabaseRegistrationEvent.idl b/offapi/com/sun/star/sdb/DatabaseRegistrationEvent.idl index 29678a2ccf10..7b606cf6864b 100644 --- a/offapi/com/sun/star/sdb/DatabaseRegistrationEvent.idl +++ b/offapi/com/sun/star/sdb/DatabaseRegistrationEvent.idl @@ -33,7 +33,7 @@ module com { module sun { module star { module sdb { @since OpenOffice.org 3.3 */ -struct DatabaseRegistrationEvent : ::com::sun::star::lang::EventObject +published struct DatabaseRegistrationEvent : ::com::sun::star::lang::EventObject { /// is the name of the database registration affected by the event string Name; diff --git a/offapi/com/sun/star/sdb/XDatabaseContext.idl b/offapi/com/sun/star/sdb/XDatabaseContext.idl new file mode 100644 index 000000000000..9c0394215278 --- /dev/null +++ b/offapi/com/sun/star/sdb/XDatabaseContext.idl @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef __com_sun_star_sdb_XDatabaseContext_idl__ +#define __com_sun_star_sdb_XDatabaseContext_idl__ + +#include <com/sun/star/container/XEnumerationAccess.idl> +#include <com/sun/star/container/XContainer.idl> +#include <com/sun/star/lang/XSingleServiceFactory.idl> +#include <com/sun/star/container/XNameAccess.idl> +#include <com/sun/star/uno/XNamingService.idl> +#include <com/sun/star/sdb/XDatabaseRegistrations.idl> + +module com { module sun { module star { module sdb { + +/** + Provides an interface for the new-style DatabaseContext service to implement. + */ +published interface XDatabaseContext +{ + /** Enumeration on all registered data sources. + */ + interface com::sun::star::container::XEnumerationAccess; + + /** NameAccess on all registered data sources. + <p>One exception is the <method "com.sun.star.container.XNameAccess">getByName</method>, this method also allows to ask + for a <member "DataAccessDescriptor">DatabaseLocation</member>. + </p> + */ + interface com::sun::star::container::XNameAccess; + + /** Interface for registering new datasources. + */ + interface com::sun::star::uno::XNamingService; + + /** Interface for registering listener to get notified when new datasources are created or removed. + */ + interface com::sun::star::container::XContainer; + + /** Interface for creation of new datasources. + */ + interface com::sun::star::lang::XSingleServiceFactory; + + /** allows to access and modify the configuration data for registered data source. + + <p>The main purpose of this interface is to allow you to register data sources which you know + by URL only, and have not yet loaded.</p> + + <p>Also, it hides the details of the configuration data where the data source registrations + are maintained, so if possible at all, you should use this interface, instead of modifying or + querying the configuration data directly.</p> + + @since OOo 3.3 + */ + [optional] interface XDatabaseRegistrations; +}; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/sdb/XDatabaseRegistrations.idl b/offapi/com/sun/star/sdb/XDatabaseRegistrations.idl index 3ca15502a505..105264277a28 100644 --- a/offapi/com/sun/star/sdb/XDatabaseRegistrations.idl +++ b/offapi/com/sun/star/sdb/XDatabaseRegistrations.idl @@ -28,7 +28,7 @@ module com { module sun { module star { module sdb { -interface XDatabaseRegistrationsListener; +published interface XDatabaseRegistrationsListener; /** provides access to the application-wide registered databases. @@ -40,7 +40,7 @@ interface XDatabaseRegistrationsListener; @since OOo 3.3 */ -interface XDatabaseRegistrations +published interface XDatabaseRegistrations { /** determines whether a database is registered under the given name. diff --git a/offapi/com/sun/star/sdb/XDatabaseRegistrationsListener.idl b/offapi/com/sun/star/sdb/XDatabaseRegistrationsListener.idl index 1f502fde5ba4..7e4b8afb94b5 100644 --- a/offapi/com/sun/star/sdb/XDatabaseRegistrationsListener.idl +++ b/offapi/com/sun/star/sdb/XDatabaseRegistrationsListener.idl @@ -34,7 +34,7 @@ module com { module sun { module star { module sdb { @since OOo 3.3 */ -interface XDatabaseRegistrationsListener : ::com::sun::star::lang::XEventListener +published interface XDatabaseRegistrationsListener : ::com::sun::star::lang::XEventListener { /** called when a database has been registered */ diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb Binary files differindex c0d725b57da4..312d0eb217cc 100644 --- a/offapi/type_reference/types.rdb +++ b/offapi/type_reference/types.rdb diff --git a/sc/source/ui/dbgui/dapidata.cxx b/sc/source/ui/dbgui/dapidata.cxx index 1f482031f9a0..862698318895 100644 --- a/sc/source/ui/dbgui/dapidata.cxx +++ b/sc/source/ui/dbgui/dapidata.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/sheet/DataImportMode.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> @@ -53,7 +54,6 @@ using namespace com::sun::star; //------------------------------------------------------------------------- -#define DP_SERVICE_DBCONTEXT "com.sun.star.sdb.DatabaseContext" #define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler" // entries in the "type" ListBox @@ -86,20 +86,15 @@ ScDataPilotDatabaseDlg::ScDataPilotDatabaseDlg( Window* pParent ) : { // get database names - uno::Reference<container::XNameAccess> xContext( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( DP_SERVICE_DBCONTEXT )) ), - uno::UNO_QUERY); - if (xContext.is()) + uno::Reference<sdb::XDatabaseContext> xContext = sdb::DatabaseContext::create( + comphelper::getProcessComponentContext() ); + uno::Sequence<rtl::OUString> aNames = xContext->getElementNames(); + long nCount = aNames.getLength(); + const rtl::OUString* pArray = aNames.getConstArray(); + for (long nPos = 0; nPos < nCount; nPos++) { - uno::Sequence<rtl::OUString> aNames = xContext->getElementNames(); - long nCount = aNames.getLength(); - const rtl::OUString* pArray = aNames.getConstArray(); - for (long nPos = 0; nPos < nCount; nPos++) - { - String aName = pArray[nPos]; - aLbDatabase.InsertEntry( aName ); - } + String aName = pArray[nPos]; + aLbDatabase.InsertEntry( aName ); } } catch(uno::Exception&) @@ -161,11 +156,8 @@ void ScDataPilotDatabaseDlg::FillObjects() { // open connection (for tables or queries) - uno::Reference<container::XNameAccess> xContext( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( DP_SERVICE_DBCONTEXT )) ), - uno::UNO_QUERY); - if ( !xContext.is() ) return; + uno::Reference<sdb::XDatabaseContext> xContext = sdb::DatabaseContext::create( + comphelper::getProcessComponentContext() ); uno::Any aSourceAny = xContext->getByName( aDatabaseName ); uno::Reference<sdb::XCompletedConnection> xSource( diff --git a/svtools/inc/svtools/addresstemplate.hxx b/svtools/inc/svtools/addresstemplate.hxx index 790740857156..65462f512da1 100644 --- a/svtools/inc/svtools/addresstemplate.hxx +++ b/svtools/inc/svtools/addresstemplate.hxx @@ -40,6 +40,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/AliasProgrammaticPair.hpp> +#include <com/sun/star/sdb/XDatabaseContext.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> #include <unotools/configitem.hxx> @@ -75,7 +76,7 @@ namespace svt const String m_sNoFieldSelection; /// the DatabaseContext for selecting data sources - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseContext > m_xDatabaseContext; // the ORB for creating objects ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index 67c964ec0bcc..7d362fefff84 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -34,6 +34,7 @@ #include <svtools/helpid.hrc> #include <svtools/svtresid.hxx> #include <tools/debug.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/extract.hxx> #include <comphelper/interaction.hxx> #include <comphelper/processfactory.hxx> @@ -47,6 +48,7 @@ #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdbc/SQLWarning.hpp> @@ -797,14 +799,14 @@ void AssignmentPersistentData::Commit() if (!m_xORB.is()) return; - const rtl::OUString sContextServiceName("com.sun.star.sdb.DatabaseContext"); try { - m_xDatabaseContext = Reference< XNameAccess >(m_xORB->createInstance(sContextServiceName), UNO_QUERY); + m_xDatabaseContext = DatabaseContext::create(comphelper::ComponentContext(m_xORB).getUNOContext()); } catch(Exception&) { } if (!m_xDatabaseContext.is()) { + const rtl::OUString sContextServiceName("com.sun.star.sdb.DatabaseContext"); ShowServiceNotAvailableError( this, sContextServiceName, sal_False); return; } diff --git a/svx/inc/svx/dbtoolsclient.hxx b/svx/inc/svx/dbtoolsclient.hxx index 661f8d8ad2c3..3568c20396c3 100644 --- a/svx/inc/svx/dbtoolsclient.hxx +++ b/svx/inc/svx/dbtoolsclient.hxx @@ -149,7 +149,7 @@ namespace svxform // ------------------------------------------------ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource( const ::rtl::OUString& _rsRegisteredName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext ) const; // ------------------------------------------------ diff --git a/svx/source/form/dbtoolsclient.cxx b/svx/source/form/dbtoolsclient.cxx index da1ef3735d70..c07be75cc19e 100644 --- a/svx/source/form/dbtoolsclient.cxx +++ b/svx/source/form/dbtoolsclient.cxx @@ -249,11 +249,11 @@ namespace svxform } //---------------------------------------------------------------- - Reference< XDataSource > OStaticDataAccessTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XMultiServiceFactory>& _rxFactory ) const + Reference< XDataSource > OStaticDataAccessTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XComponentContext>& _rxContext ) const { Reference< XDataSource > xReturn; if ( ensureLoaded() ) - xReturn = m_xDataAccessTools->getDataSource(_rsRegisteredName,_rxFactory); + xReturn = m_xDataAccessTools->getDataSource(_rsRegisteredName,_rxContext); return xReturn; } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 638fd6eab9d9..d55071e7aff6 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1177,7 +1177,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript // obtain the data source if ( !xDataSource.is() ) - xDataSource = OStaticDataAccessTools().getDataSource( sDataSource, m_aContext.getLegacyServiceFactory() ); + xDataSource = OStaticDataAccessTools().getDataSource( sDataSource, m_aContext.getUNOContext() ); // and the connection, if necessary if ( !xConnection.is() ) diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx index 0c1e17fac9d5..5cf18fe9e8a3 100644 --- a/svx/source/form/formcontrolfactory.cxx +++ b/svx/source/form/formcontrolfactory.cxx @@ -222,7 +222,7 @@ namespace svxform Reference< XPropertySet > xDsProperties; if ( !sDataSourceName.isEmpty() ) - xDsProperties = xDsProperties.query( OStaticDataAccessTools().getDataSource( sDataSourceName, _rContext.getLegacyServiceFactory() ) ); + xDsProperties = xDsProperties.query( OStaticDataAccessTools().getDataSource( sDataSourceName, _rContext.getUNOContext() ) ); if ( xDsProperties.is() ) xDsProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Info" ) ) ) >>= aInfo; } diff --git a/sw/inc/swdbtoolsclient.hxx b/sw/inc/swdbtoolsclient.hxx index 0174125cec5f..eb376d03e739 100644 --- a/sw/inc/swdbtoolsclient.hxx +++ b/sw/inc/swdbtoolsclient.hxx @@ -56,7 +56,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource( const ::rtl::OUString& _rsRegisteredName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext ); sal_Int32 getDefaultNumberFormat( diff --git a/sw/source/core/edit/edfldexp.cxx b/sw/source/core/edit/edfldexp.cxx index 357777674e17..30aa1d64a30b 100644 --- a/sw/source/core/edit/edfldexp.cxx +++ b/sw/source/core/edit/edfldexp.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <doc.hxx> #include <docary.hxx> #include <ndtxt.hxx> // GetCurFld @@ -48,13 +49,8 @@ sal_Bool SwEditShell::IsFieldDataSourceAvailable(String& rUsedDataSource) const { const SwFldTypes * pFldTypes = GetDoc()->GetFldTypes(); const sal_uInt16 nSize = pFldTypes->size(); - uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( !xMgr.is() ) - return sal_False; - uno::Reference<uno::XInterface> xInstance = xMgr->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseContext"))); - uno::Reference<container::XNameAccess> xDBContext(xInstance, uno::UNO_QUERY) ; - if(!xDBContext.is()) - return sal_False; + uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference<sdb::XDatabaseContext> xDBContext = sdb::DatabaseContext::create(xContext); for(sal_uInt16 i = 0; i < nSize; ++i) { SwFieldType& rFldType = *((*pFldTypes)[i]); diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx index 68d4ab4e5121..8a549263be4c 100644 --- a/sw/source/ui/dbui/addresslistdialog.cxx +++ b/sw/source/ui/dbui/addresslistdialog.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/uno/XNamingService.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> @@ -211,61 +212,55 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent) : m_aListLB.SetTabs(&nTabs[0], MAP_PIXEL); m_aOK.SetClickHdl( LINK( this, SwAddressListDialog, OKHdl_Impl)); - uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" )); - m_xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ; - } + uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + m_xDBContext = DatabaseContext::create(xContext); + SwMailMergeConfigItem& rConfigItem = m_pAddressPage->GetWizard()->GetConfigItem(); const SwDBData& rCurrentData = rConfigItem.GetCurrentDBData(); - OSL_ENSURE(m_xDBContext.is(), "service 'com.sun.star.sdb.DatabaseContext' not found!"); sal_Bool bEnableEdit = sal_False; sal_Bool bEnableOK = sal_True; m_aListLB.SelectAll( sal_False ); - if(m_xDBContext.is()) + SwDBConfig aDb; + ::rtl::OUString sBibliography = aDb.GetBibliographySource().sDataSource; + uno::Sequence< ::rtl::OUString> aNames = m_xDBContext->getElementNames(); + const ::rtl::OUString* pNames = aNames.getConstArray(); + for(sal_Int32 nName = 0; nName < aNames.getLength(); ++nName) { - SwDBConfig aDb; - ::rtl::OUString sBibliography = aDb.GetBibliographySource().sDataSource; - uno::Sequence< ::rtl::OUString> aNames = m_xDBContext->getElementNames(); - const ::rtl::OUString* pNames = aNames.getConstArray(); - for(sal_Int32 nName = 0; nName < aNames.getLength(); ++nName) + if ( pNames[nName] == sBibliography ) + continue; + SvLBoxEntry* pEntry = m_aListLB.InsertEntry(pNames[nName]); + AddressUserData_Impl* pUserData = new AddressUserData_Impl(); + pEntry->SetUserData(pUserData); + if(pNames[nName] == rCurrentData.sDataSource) { - if ( pNames[nName] == sBibliography ) - continue; - SvLBoxEntry* pEntry = m_aListLB.InsertEntry(pNames[nName]); - AddressUserData_Impl* pUserData = new AddressUserData_Impl(); - pEntry->SetUserData(pUserData); - if(pNames[nName] == rCurrentData.sDataSource) + m_aListLB.Select(pEntry); + m_aListLB.SetEntryText(rCurrentData.sCommand, pEntry, ITEMID_TABLE - 1); + pUserData->nCommandType = rCurrentData.nCommandType; + pUserData->xSource = rConfigItem.GetSource(); + pUserData->xConnection = rConfigItem.GetConnection(); + pUserData->xColumnsSupplier = rConfigItem.GetColumnsSupplier(); + pUserData->xResultSet = rConfigItem.GetResultSet(); + pUserData->sFilter = rConfigItem.GetFilter(); + //is the data source editable (csv, Unicode, single table) + uno::Reference<beans::XPropertySet> xSourceProperties; + try { - m_aListLB.Select(pEntry); - m_aListLB.SetEntryText(rCurrentData.sCommand, pEntry, ITEMID_TABLE - 1); - pUserData->nCommandType = rCurrentData.nCommandType; - pUserData->xSource = rConfigItem.GetSource(); - pUserData->xConnection = rConfigItem.GetConnection(); - pUserData->xColumnsSupplier = rConfigItem.GetColumnsSupplier(); - pUserData->xResultSet = rConfigItem.GetResultSet(); - pUserData->sFilter = rConfigItem.GetFilter(); - //is the data source editable (csv, Unicode, single table) - uno::Reference<beans::XPropertySet> xSourceProperties; - try - { - m_xDBContext->getByName(pNames[nName]) >>= xSourceProperties; - pUserData->sURL = lcl_getFlatURL( xSourceProperties ); - bEnableEdit = !pUserData->sURL.isEmpty() && - SWUnoHelper::UCB_IsFile( pUserData->sURL ) && //#i97577# - !SWUnoHelper::UCB_IsReadOnlyFileName( pUserData->sURL ); - } - catch (const uno::Exception&) - { - bEnableOK = sal_False; - } - m_aDBData = rCurrentData; + m_xDBContext->getByName(pNames[nName]) >>= xSourceProperties; + pUserData->sURL = lcl_getFlatURL( xSourceProperties ); + bEnableEdit = !pUserData->sURL.isEmpty() && + SWUnoHelper::UCB_IsFile( pUserData->sURL ) && //#i97577# + !SWUnoHelper::UCB_IsReadOnlyFileName( pUserData->sURL ); } + catch (const uno::Exception&) + { + bEnableOK = sal_False; + } + m_aDBData = rCurrentData; } } + m_aOK.Enable(m_aListLB.GetEntryCount()>0 && bEnableOK); m_aEditPB.Enable(bEnableEdit); m_aListLB.SetSelectHdl(LINK(this, SwAddressListDialog, ListBoxSelectHdl_Impl)); diff --git a/sw/source/ui/dbui/addresslistdialog.hxx b/sw/source/ui/dbui/addresslistdialog.hxx index 8a0e19ccfa31..704682270a54 100644 --- a/sw/source/ui/dbui/addresslistdialog.hxx +++ b/sw/source/ui/dbui/addresslistdialog.hxx @@ -41,6 +41,9 @@ namespace com{namespace sun{namespace star{ namespace container{ class XNameAccess; } + namespace sdb{ + class XDatabaseContext; + } namespace sdbc{ class XDataSource; } @@ -81,9 +84,9 @@ class SwAddressListDialog : public SfxModalDialog SwMailMergeAddressBlockPage* m_pAddressPage; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xDBContext; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseContext> m_xDBContext; - SwDBData m_aDBData; + SwDBData m_aDBData; void DetectTablesAndQueries(SvLBoxEntry* pSelect, bool bWidthDialog); diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 63d7c47243c3..563f888a7e8d 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/util/NumberFormatter.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdb/XCompletedExecution.hpp> #include <com/sun/star/container/XChild.hpp> @@ -1571,9 +1572,10 @@ uno::Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const String& rData { Reference< sdbc::XConnection> xConnection; Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); try { - Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xMgr),UNO_QUERY); + Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xContext),UNO_QUERY); if ( xComplConnection.is() ) { rxSource.set(xComplConnection,UNO_QUERY); @@ -2173,18 +2175,9 @@ const SwDBData& SwNewDBMgr::GetAddressDBName() Sequence<rtl::OUString> SwNewDBMgr::GetExistingDatabaseNames() { - uno::Reference<XNameAccess> xDBContext; - uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - uno::Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" )); - xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ; - } - if(xDBContext.is()) - { - return xDBContext->getElementNames(); - } - return Sequence<rtl::OUString>(); + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext); + return xDBContext->getElementNames(); } String SwNewDBMgr::LoadAndRegisterDataSource() @@ -2297,9 +2290,9 @@ String SwNewDBMgr::LoadAndRegisterDataSource() #endif try { - Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" )); - Reference<XNameAccess> xDBContext(xInstance, UNO_QUERY_THROW); + Reference<XMultiServiceFactory> xMgr( ::comphelper::getProcessServiceFactory() ); + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext); Reference<XSingleServiceFactory> xFact( xDBContext, UNO_QUERY); String sNewName = INetURLObject::decode( aURL.getName(), @@ -2569,13 +2562,13 @@ void SwNewDBMgr::InsertText(SwWrtShell& rSh, OSL_FAIL("PropertyValues missing or unset"); return; } - uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); uno::Reference<XDataSource> xSource; uno::Reference<XChild> xChild(xConnection, UNO_QUERY); if(xChild.is()) xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY); if(!xSource.is()) - xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xMgr); + xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xContext); uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY ); SwDBData aDBData; aDBData.sDataSource = sDataSource; @@ -2633,7 +2626,7 @@ uno::Reference<XDataSource> SwNewDBMgr::getDataSourceAsParent(const uno::Referen if ( xChild.is() ) xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY); if ( !xSource.is() ) - xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessServiceFactory()); + xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessComponentContext()); } catch(const Exception&) { diff --git a/sw/source/ui/dbui/dbtree.cxx b/sw/source/ui/dbui/dbtree.cxx index 6070f90ff289..e1b593969562 100644 --- a/sw/source/ui/dbui/dbtree.cxx +++ b/sw/source/ui/dbui/dbtree.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/sdbc/XDataSource.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdb/XDatabaseAccess.hpp> #include <com/sun/star/sdb/CommandType.hpp> @@ -79,7 +80,7 @@ typedef boost::ptr_vector<SwConnectionData> SwConnectionArr; class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener > { - Reference< XNameAccess > xDBContext; + Reference< XDatabaseContext > xDBContext; SwConnectionArr aConnections; SwWrtShell* pWrtSh; @@ -96,7 +97,7 @@ class SwDBTreeList_Impl : public cppu::WeakImplHelper1 < XContainerListener > sal_Bool HasContext(); SwWrtShell* GetWrtShell() { return pWrtSh;} void SetWrtShell(SwWrtShell& rSh) { pWrtSh = &rSh;} - Reference< XNameAccess > GetContext() const {return xDBContext;} + Reference<XDatabaseContext> GetContext() const {return xDBContext;} Reference<XConnection> GetConnection(const rtl::OUString& rSourceName); }; @@ -149,17 +150,11 @@ sal_Bool SwDBTreeList_Impl::HasContext() { if(!xDBContext.is()) { - Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - Reference<XInterface> xInstance = xMgr->createInstance( - C2U( "com.sun.star.sdb.DatabaseContext" )); - xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ; - Reference<XContainer> xContainer(xDBContext, UNO_QUERY); - if(xContainer.is()) - xContainer->addContainerListener( this ); - } - OSL_ENSURE(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available"); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + xDBContext = DatabaseContext::create(xContext); + Reference<XContainer> xContainer(xDBContext, UNO_QUERY); + if(xContainer.is()) + xContainer->addContainerListener( this ); } return xDBContext.is(); } diff --git a/sw/source/ui/dbui/swdbtoolsclient.cxx b/sw/source/ui/dbui/swdbtoolsclient.cxx index 4a80df154cd5..e18db2b4138a 100644 --- a/sw/source/ui/dbui/swdbtoolsclient.cxx +++ b/sw/source/ui/dbui/swdbtoolsclient.cxx @@ -186,13 +186,13 @@ void SwDbtoolsClient::getFactory() Reference< XDataSource > SwDbtoolsClient::getDataSource( const ::rtl::OUString& rRegisteredName, - const Reference< XMultiServiceFactory>& xFactory + const Reference<XComponentContext>& rxContext ) { Reference< XDataSource > xRet; ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools(); if(xAccess.is()) - xRet = xAccess->getDataSource(rRegisteredName, xFactory); + xRet = xAccess->getDataSource(rRegisteredName, rxContext); return xRet; } diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx index eaa22e18bc24..5c0e9c0a2523 100644 --- a/sw/source/ui/fldui/changedb.cxx +++ b/sw/source/ui/fldui/changedb.cxx @@ -30,6 +30,7 @@ #include <vcl/msgbox.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XDatabaseAccess.hpp> #include <comphelper/processfactory.hxx> #include <sfx2/viewfrm.hxx> @@ -51,9 +52,10 @@ #include <unomid.h> -using namespace ::com::sun::star::uno; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::uno; /*-------------------------------------------------------------------- @@ -106,14 +108,8 @@ SwChangeDBDlg::SwChangeDBDlg(SwView& rVw) : --------------------------------------------------------------------*/ void SwChangeDBDlg::FillDBPopup() { - Reference<XNameAccess> xDBContext; - Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" )); - xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ; - } - OSL_ENSURE(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available"); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext); const SwDBData& rDBData = pSh->GetDBData(); String sDBName(rDBData.sDataSource); diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 770866ac9367..c2820ccf733f 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/i18n/TransliterationModules.hpp> #include <svtools/filter.hxx> +#include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> @@ -156,6 +157,7 @@ using namespace ::com::sun::star::scanner; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::ui::dialogs; static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId ) @@ -2149,7 +2151,7 @@ void SwView::EnableMailMerge(sal_Bool bEnable ) namespace { - sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XNameAccess >& _rDatasourceContext ) + sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext ) { Sequence < OUString > aNames = _rDatasourceContext->getElementNames(); @@ -2214,16 +2216,8 @@ void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument) if(!GetWrtShell().IsAnyDatabaseFieldInDoc()) { //check availability of data sources (except biblio source) - uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - uno::Reference<XNameAccess> xDBContext; - if( xMgr.is() ) - { - uno::Reference<XInterface> xInstance = xMgr->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseContext"))); - xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ; - } - if(!xDBContext.is()) - return ; + uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext); sal_Bool bCallAddressPilot = sal_False; if ( lcl_NeedAdditionalDataSource( xDBContext ) ) { |