Tag: cws_src680_mysqlnative User: oj Date: 2008-06-04 08:33:04+0000 Modified: dba/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx dba/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx dba/connectivity/source/dbtools/makefile.mk
Log: #i20563# impl DatabaseMetaDataResultSet as service File Changes: Directory: /dba/connectivity/source/inc/ ======================================== File [changed]: FDatabaseMetaDataResultSet.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx?r1=1.15&r2=1.15.12.1 Delta lines: +58 -44 --------------------- --- FDatabaseMetaDataResultSet.hxx 2008-04-10 10:36:28+0000 1.15 +++ FDatabaseMetaDataResultSet.hxx 2008-06-04 08:33:00+0000 1.15.12.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: FDatabaseMetaDataResultSet.hxx,v $ - * $Revision: 1.15 $ + * $Revision: 1.15.12.1 $ * * This file is part of OpenOffice.org. * @@ -37,31 +37,32 @@ #include <com/sun/star/sdbc/XCloseable.hpp> #include <com/sun/star/sdbc/XColumnLocate.hpp> #include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/sdbc/XWarningsSupplier.hpp> #include <com/sun/star/sdbc/XResultSetUpdate.hpp> #include <com/sun/star/sdbc/XRowUpdate.hpp> -#include <cppuhelper/compbase7.hxx> +#include <cppuhelper/compbase9.hxx> #include <comphelper/proparrhlp.hxx> #include "connectivity/CommonTools.hxx" #include <comphelper/propertycontainer.hxx> -#ifndef _CONNECTIVITY_VALUE_HXX_ #include "connectivity/FValue.hxx" -#endif #include <comphelper/broadcasthelper.hxx> #include <vos/refernce.hxx> namespace connectivity { class ODatabaseMetaDataResultSetMetaData; - typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::sdbc::XResultSet, + typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::sdbc::XResultSet, ::com::sun::star::sdbc::XRow, ::com::sun::star::sdbc::XResultSetMetaDataSupplier, ::com::sun::star::util::XCancellable, ::com::sun::star::sdbc::XWarningsSupplier, ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::lang::XServiceInfo, ::com::sun::star::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE; - // typedef ORefVector<ORowSetValue> ORow; // typedef ORefVector<ORow> ORows; @@ -75,6 +76,44 @@ DECLARE_STL_VECTOR(ORowSetValueDecoratorRef,ORow); DECLARE_STL_VECTOR(ORow, ORows); + enum MetaDataResultSetType + { + /// describes a result set as expected by XDatabaseMetaData::getCatalogs + eCatalogs = 0, + /// describes a result set as expected by XDatabaseMetaData::getSchemas + eSchemas = 1, + /// describes a result set as expected by XDatabaseMetaData::getColumnPrivileges + eColumnPrivileges = 2, + /// describes a result set as expected by XDatabaseMetaData::getColumns + eColumns = 3, + /// describes a result set as expected by XDatabaseMetaData::getTables + eTables = 4, + /// describes a result set as expected by XDatabaseMetaData::getTableTypes + eTableTypes = 5, + /// describes a result set as expected by XDatabaseMetaData::getProcedureColumns + eProcedureColumns = 6, + /// describes a result set as expected by XDatabaseMetaData::getProcedures + eProcedures = 7, + /// describes a result set as expected by XDatabaseMetaData::getExportedKeys + eExportedKeys = 8, + /// describes a result set as expected by XDatabaseMetaData::getImportedKeys + eImportedKeys = 9, + /// describes a result set as expected by XDatabaseMetaData::getPrimaryKeys + ePrimaryKeys = 10, + /// describes a result set as expected by XDatabaseMetaData::getIndexInfo + eIndexInfo = 11, + /// describes a result set as expected by XDatabaseMetaData::getTablePrivileges + eTablePrivileges = 12, + /// describes a result set as expected by XDatabaseMetaData::getCrossReference + eCrossReference = 13, + /// describes a result set as expected by XDatabaseMetaData::getTypeInfo + eTypeInfo = 14, + /// describes a result set as expected by XDatabaseMetaData::getBestRowIdentifier + eBestRowIdentifier = 15, + /// describes a result set as expected by XDatabaseMetaData::getVersionColumns + eVersionColumns = 16 + }; + private: ORowSetValue m_aEmptyValue; ::com::sun::star::uno::WeakReferenceHelper m_aStatement; @@ -88,6 +127,7 @@ void construct(); void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); + void setType(MetaDataResultSetType _eType); protected: ORows m_aRows; @@ -108,43 +148,6 @@ virtual void SAL_CALL acquire() throw(); virtual void SAL_CALL release() throw(); - enum MetaDataResultSetType - { - /// describes a result set as expected by XDatabaseMetaData::getCatalogs - eCatalogs, - /// describes a result set as expected by XDatabaseMetaData::getSchemas - eSchemas, - /// describes a result set as expected by XDatabaseMetaData::getColumnPrivileges - eColumnPrivileges, - /// describes a result set as expected by XDatabaseMetaData::getColumns - eColumns, - /// describes a result set as expected by XDatabaseMetaData::getTables - eTables, - /// describes a result set as expected by XDatabaseMetaData::getTableTypes - eTableTypes, - /// describes a result set as expected by XDatabaseMetaData::getProcedureColumns - eProcedureColumns, - /// describes a result set as expected by XDatabaseMetaData::getProcedures - eProcedures, - /// describes a result set as expected by XDatabaseMetaData::getExportedKeys - eExportedKeys, - /// describes a result set as expected by XDatabaseMetaData::getImportedKeys - eImportedKeys, - /// describes a result set as expected by XDatabaseMetaData::getPrimaryKeys - ePrimaryKeys, - /// describes a result set as expected by XDatabaseMetaData::getIndexInfo - eIndexInfo, - /// describes a result set as expected by XDatabaseMetaData::getTablePrivileges - eTablePrivileges, - /// describes a result set as expected by XDatabaseMetaData::getCrossReference - eCrossReference, - /// describes a result set as expected by XDatabaseMetaData::getTypeInfo - eTypeInfo, - /// describes a result set as expected by XDatabaseMetaData::getBestRowIdentifier - eBestRowIdentifier, - /// describes a result set as expected by XDatabaseMetaData::getVersionColumns - eVersionColumns - }; /// default construction ODatabaseMetaDataResultSet(); /// construction of a pre-defined result set type @@ -152,7 +155,15 @@ void setRows(const ORows& _rRows); + // XServiceInfo + + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + protected: + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); // ::cppu::OComponentHelper virtual void SAL_CALL disposing(void); // XInterface @@ -213,6 +224,9 @@ // XColumnLocate virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + void setCatalogsMap(); void setSchemasMap(); void setColumnPrivilegesMap(); Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: FDatabaseMetaDataResultSet.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx?r1=1.22&r2=1.22.12.1 Delta lines: +243 -22 ---------------------- --- FDatabaseMetaDataResultSet.cxx 2008-04-10 07:52:08+0000 1.22 +++ FDatabaseMetaDataResultSet.cxx 2008-06-04 08:33:00+0000 1.22.12.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: FDatabaseMetaDataResultSet.cxx,v $ - * $Revision: 1.22 $ + * $Revision: 1.22.12.1 $ * * This file is part of OpenOffice.org. * @@ -47,6 +47,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <cppuhelper/typeprovider.hxx> #include <comphelper/sequence.hxx> +#include <cppuhelper/factory.hxx> #include "connectivity/dbexception.hxx" #include "TConnection.hxx" @@ -83,6 +84,24 @@ { construct(); + setType(_eType); +} + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() +{ +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::construct() +{ + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +} +// ----------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType) +{ switch( _eType ) { case eCatalogs: setCatalogsMap(); break; @@ -102,21 +121,10 @@ case eTypeInfo: setTypeInfoMap(); break; case eBestRowIdentifier: setBestRowIdentifierMap(); break; case eVersionColumns: setVersionColumnsMap(); break; + default: + OSL_ENSURE(0,"Wrong type!"); } } - -// ------------------------------------------------------------------------- -ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() -{ -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSet::construct() -{ - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); -} // ------------------------------------------------------------------------- void ODatabaseMetaDataResultSet::disposing(void) { @@ -722,6 +730,219 @@ return aValueRef; } // ----------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException) +{ + if ( _aArguments.getLength() == 2 ) + { + sal_Int32 nResultSetType; + if ( _aArguments[0] >>= nResultSetType) + { + setType(static_cast<MetaDataResultSetType>(nResultSetType)); + Sequence< Sequence<Any> > aRows; + if ( _aArguments[1] >>= aRows ) + { + ORows aRowsToSet; + const Sequence<Any>* pRowsIter = aRows.getConstArray(); + const Sequence<Any>* pRowsEnd = pRowsIter + aRows.getLength(); + for (; pRowsIter != pRowsEnd;++pRowsIter) + { + ORow aRowToSet; + const Any* pRowIter = pRowsIter->getConstArray(); + const Any* pRowEnd = pRowIter + pRowsIter->getLength(); + for (; pRowIter != pRowEnd;++pRowIter) + { + ORowSetValueDecoratorRef aValue; + switch( pRowIter->getValueTypeClass() ) + { + case TypeClass_BOOLEAN: + { + sal_Bool bValue; + *pRowIter >>= bValue; + aValue = new ORowSetValueDecorator(ORowSetValue(bValue)); + } + break; + case TypeClass_BYTE: + { + sal_Int8 nValue; + *pRowIter >>= nValue; + aValue = new ORowSetValueDecorator(ORowSetValue(nValue)); + } + break; + case TypeClass_SHORT: + case TypeClass_UNSIGNED_SHORT: + { + sal_Int16 nValue; + *pRowIter >>= nValue; + aValue = new ORowSetValueDecorator(ORowSetValue(nValue)); + } + break; + case TypeClass_LONG: + case TypeClass_UNSIGNED_LONG: + { + sal_Int32 nValue; + *pRowIter >>= nValue; + aValue = new ORowSetValueDecorator(ORowSetValue(nValue)); + } + break; + case TypeClass_HYPER: + case TypeClass_UNSIGNED_HYPER: + { + sal_Int64 nValue; + *pRowIter >>= nValue; + aValue = new ORowSetValueDecorator(ORowSetValue(nValue)); + } + break; + case TypeClass_FLOAT: + { + float nValue; + *pRowIter >>= nValue; + aValue = new ORowSetValueDecorator(ORowSetValue(nValue)); + } + break; + case TypeClass_DOUBLE: + { + double nValue; + *pRowIter >>= nValue; + aValue = new ORowSetValueDecorator(ORowSetValue(nValue)); + } + break; + case TypeClass_STRING: + { + ::rtl::OUString sValue; + *pRowIter >>= sValue; + aValue = new ORowSetValueDecorator(ORowSetValue(sValue)); + } + break; + default: + break; + } + aRowToSet.push_back(aValue); + } + aRowsToSet.push_back(aRowToSet); + } // for (; pRowsIter != pRowsEnd;++pRowsIter + setRows(aRowsToSet); + } + } + } +} +// XServiceInfo + // -------------------------------------------------------------------------------- + //------------------------------------------------------------------------------ + rtl::OUString ODatabaseMetaDataResultSet::getImplementationName_Static( ) throw(RuntimeException) + { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.helper.DatabaseMetaDataResultSet")); + } + //------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); + return aSNS; + } + //------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( ) throw(RuntimeException) + { + return getImplementationName_Static(); + } + + //------------------------------------------------------------------ + sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) + { + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); + for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) + ; + + return pSupported != pEnd; + } + //------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames( ) throw(RuntimeException) + { + return getSupportedServiceNames_Static(); + } + // ------------------------------------------------------------------------- + namespace connectivity + { + Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet_CreateInstance(const Reference< XMultiServiceFactory >& ) throw( Exception ) + { + return *(new ODatabaseMetaDataResultSet()); + } + } + +// ----------------------------------------------------------------------------- +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::registry::InvalidRegistryException; +using ::com::sun::star::registry::InvalidValueException; +using ::com::sun::star::lang::XMultiServiceFactory; +//========================================================================== +//= registration +//========================================================================== +extern "C" +{ + +//--------------------------------------------------------------------------------------- + void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/) +{ + *_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star::registry::XRegistryKey* _pRegistryKey) +{ + ::rtl::OUString sMainKeyName = ::rtl::OUString::createFromAscii("/"); + sMainKeyName += ODatabaseMetaDataResultSet::getImplementationName_Static(); + sMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES"); + + try + { + Reference< XRegistryKey > xMainKey = _pRegistryKey->createKey(sMainKeyName); + if (!xMainKey.is()) + return sal_False; + + Sequence< ::rtl::OUString > sServices = ODatabaseMetaDataResultSet::getSupportedServiceNames_Static(); + const ::rtl::OUString* pServices = sServices.getConstArray(); + for (sal_Int32 i=0; i<sServices.getLength(); ++i, ++pServices) + xMainKey->createKey(*pServices); + } + catch(InvalidRegistryException&) + { + return sal_False; + } + catch(InvalidValueException&) + { + return sal_False; + } + return sal_True; +} +//--------------------------------------------------------------------------------------- +void* SAL_CALL component_getFactory(const sal_Char* _pImplName, ::com::sun::star::lang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/) +{ + void* pRet = NULL; + + if (ODatabaseMetaDataResultSet::getImplementationName_Static().compareToAscii(_pImplName) == 0) + { + Reference< XSingleServiceFactory > xFactory( + ::cppu::createSingleFactory( + _pServiceManager, + ODatabaseMetaDataResultSet::getImplementationName_Static(), + ODatabaseMetaDataResultSet_CreateInstance, + ODatabaseMetaDataResultSet::getSupportedServiceNames_Static(),0 + ) + ); + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} +} // extern "C" Directory: /dba/connectivity/source/dbtools/ ============================================ File [changed]: makefile.mk Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/dbtools/makefile.mk?r1=1.15&r2=1.15.12.1 Delta lines: +3 -3 ------------------- --- makefile.mk 2008-04-10 08:07:08+0000 1.15 +++ makefile.mk 2008-06-04 08:33:01+0000 1.15.12.1 @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.15 $ +# $Revision: 1.15.12.1 $ # # This file is part of OpenOffice.org. # @@ -84,7 +84,7 @@ $(LIB1TARGET) DEFLIB1NAME=$(TARGET) - +DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
