Tag: cws_src680_dba24d User: fs Date: 2007-11-22 13:10:30+0000 Modified: dba/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx
Log: #i81658# DataAccessDescriptor is no service anymore, instead there is a (singleton) DataAccessDescriptorFactory which can create it File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: dataaccessdescriptor.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +114 -36 ---------------------- --- dataaccessdescriptor.cxx 2007-11-08 14:58:55+0000 1.1.2.2 +++ dataaccessdescriptor.cxx 2007-11-22 13:10:28+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: dataaccessdescriptor.cxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: fs $ $Date: 2007/11/08 14:58:55 $ + * last change: $Author: fs $ $Date: 2007/11/22 13:10:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,8 +36,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#include "dba_reghelper.hxx" #include "dbastrings.hrc" +#include "module_dba.hxx" /** === begin UNO includes === **/ #include <com/sun/star/lang/XServiceInfo.hpp> @@ -45,6 +45,7 @@ #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp> /** === end UNO includes === **/ #include <comphelper/broadcasthelper.hxx> @@ -53,6 +54,7 @@ #include <comphelper/propertycontainer.hxx> #include <comphelper/uno3.hxx> #include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> //........................................................................ namespace dbaccess @@ -76,6 +78,9 @@ using ::com::sun::star::beans::Property; using ::com::sun::star::sdbc::XConnection; using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::sdb::XDataAccessDescriptorFactory; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::uno::XComponentContext; /** === end UNO using === **/ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; @@ -97,6 +102,8 @@ ,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor > { public: + DataAccessDescriptor( const ::comphelper::ComponentContext& _rContext ); + // UNO DECLARE_XINTERFACE() DECLARE_XTYPEPROVIDER() @@ -106,13 +113,7 @@ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); - // XServiceInfo - static versions - static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException ); - static ::rtl::OUString getImplementationName_Static(void) throw( RuntimeException ); - static Reference< XInterface > Create(const Reference< XMultiServiceFactory >&); - protected: - DataAccessDescriptor( const Reference< XMultiServiceFactory >& _rxORB ); ~DataAccessDescriptor(); protected: @@ -150,11 +151,11 @@ registerProperty( PROPERTY_##propname, PROPERTY_ID_##propname, PropertyAttribute::BOUND, &member, ::getCppuType( &member ) ) //-------------------------------------------------------------------- - DataAccessDescriptor::DataAccessDescriptor( const Reference< XMultiServiceFactory >& _rxORB ) + DataAccessDescriptor::DataAccessDescriptor( const ::comphelper::ComponentContext& _rContext ) :DataAccessDescriptor_MutexBase() ,DataAccessDescriptor_TypeBase() ,DataAccessDescriptor_PropertyBase( m_aBHelper ) - ,m_aContext( _rxORB ) + ,m_aContext( _rContext ) ,m_sDataSourceName() ,m_sDatabaseLocation() ,m_sConnectionResource() @@ -202,35 +203,15 @@ IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase ); //-------------------------------------------------------------------- - Sequence< ::rtl::OUString > DataAccessDescriptor::getSupportedServiceNames_Static() throw( RuntimeException ) - { - Sequence< ::rtl::OUString > aServices(1); - aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptor" ) ); - return aServices; - } - - //-------------------------------------------------------------------- - ::rtl::OUString DataAccessDescriptor::getImplementationName_Static() throw( RuntimeException ) - { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptor" ) ); - } - - //-------------------------------------------------------------------- - Reference< XInterface > DataAccessDescriptor::Create( const Reference< XMultiServiceFactory >& _rxORB ) - { - return *( new DataAccessDescriptor( _rxORB ) ); - } - - //-------------------------------------------------------------------- ::rtl::OUString SAL_CALL DataAccessDescriptor::getImplementationName() throw (RuntimeException) { - return getImplementationName_Static(); + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptor" ) ); } //-------------------------------------------------------------------- ::sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) { - Sequence< ::rtl::OUString > aServices( getSupportedServiceNames_Static() ); + Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() ); const ::rtl::OUString* pStart = aServices.getConstArray(); const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength(); return ::std::find( pStart, pEnd, rServiceName ) != pEnd; @@ -239,7 +220,9 @@ //-------------------------------------------------------------------- Sequence< ::rtl::OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames( ) throw (RuntimeException) { - return getSupportedServiceNames_Static(); + Sequence< ::rtl::OUString > aServices(1); + aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptor" ) ); + return aServices; } //------------------------------------------------------------------------- @@ -263,12 +246,107 @@ return new ::cppu::OPropertyArrayHelper( aProps ); } + //==================================================================== + //= DataAccessDescriptorFactory + //==================================================================== + typedef ::cppu::WeakImplHelper2 < XServiceInfo + , XDataAccessDescriptorFactory + > DataAccessDescriptorFactory_Base; + class DataAccessDescriptorFactory : public DataAccessDescriptorFactory_Base + { + public: + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + // XServiceInfo - static versions + static Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( RuntimeException ); + static ::rtl::OUString getImplementationName_static(void) throw( RuntimeException ); + static Reference< XInterface > Create(const Reference< XComponentContext >& _rxContext); + static ::rtl::OUString getSingletonName_static(); + + // XDataAccessDescriptorFactory + virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor( ) throw (RuntimeException); + + protected: + DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext ); + ~DataAccessDescriptorFactory(); + + private: + ::comphelper::ComponentContext m_aContext; + }; + + //-------------------------------------------------------------------- + DataAccessDescriptorFactory::DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext ) + :m_aContext( _rxContext ) + { + } + + //-------------------------------------------------------------------- + DataAccessDescriptorFactory::~DataAccessDescriptorFactory() + { + } + + //-------------------------------------------------------------------- + ::rtl::OUString DataAccessDescriptorFactory::getSingletonName_static() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptorFactory" ) ); + } + + //-------------------------------------------------------------------- + Sequence< ::rtl::OUString > DataAccessDescriptorFactory::getSupportedServiceNames_static() throw( RuntimeException ) + { + Sequence< ::rtl::OUString > aServices(1); + aServices[0] = getSingletonName_static(); + return aServices; + } + + //-------------------------------------------------------------------- + ::rtl::OUString DataAccessDescriptorFactory::getImplementationName_static() throw( RuntimeException ) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptorFactory" ) ); + } + + //-------------------------------------------------------------------- + Reference< XInterface > DataAccessDescriptorFactory::Create( const Reference< XComponentContext >& _rxContext ) + { + return *( new DataAccessDescriptorFactory( _rxContext ) ); + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName() throw (RuntimeException) + { + return getImplementationName_static(); + } + + //-------------------------------------------------------------------- + ::sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServices( getSupportedServiceNames_static() ); + const ::rtl::OUString* pStart = aServices.getConstArray(); + const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength(); + return ::std::find( pStart, pEnd, rServiceName ) != pEnd; + } + + //-------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames( ) throw (RuntimeException) + { + return getSupportedServiceNames_static(); + } + + //-------------------------------------------------------------------- + Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor( ) throw (RuntimeException) + { + return new DataAccessDescriptor( m_aContext ); + } + //........................................................................ } // namespace dbaccess //........................................................................ //-------------------------------------------------------------------------- -extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptor() +extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory() { - static ::dbaccess::OMultiInstanceAutoRegistration< ::dbaccess::DataAccessDescriptor > aAutoRegistration; + static ::dba::OSingletonRegistration< ::dbaccess::DataAccessDescriptorFactory > aAutoRegistration; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
