diff options
author | Noel Grandin <noel@peralex.com> | 2012-09-18 09:46:34 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-27 15:03:32 +0200 |
commit | 9c00e38b431b57c3760f6c0aa774424b3239eeda (patch) | |
tree | bfe1bdd57d15eafb617028243cf4ea892016a137 /connectivity | |
parent | 8c20367a2e6d61f830f6dc336761909e38a6bcca (diff) |
fdo#46808, Adapt sdb::DatabaseContext UNO service to new style
Create a merged XDatabaseContext interface for this service to implement.
Which is backwards-compatible, but does not require creating a new service.
Quite a few IDL files had to be marked as published for this to work.
Change-Id: Ie9a0da88d8c33cc83fc9d2334ff83ab2744c222f
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/inc/connectivity/dbtools.hxx | 6 | ||||
-rw-r--r-- | connectivity/inc/connectivity/virtualdbtools.hxx | 5 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools.cxx | 15 | ||||
-rw-r--r-- | connectivity/source/simpledbt/staticdbtools_s.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/simpledbt/staticdbtools_s.hxx | 2 |
5 files changed, 18 insertions, 14 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; // ------------------------------------------------ |