diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2001-12-05 12:03:43 +0000 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2001-12-05 12:03:43 +0000 |
commit | 19e294428d2682cdfbd3c60352e4f5ff03a1bef7 (patch) | |
tree | 7f4657ee9b379de0bcaa544c069645c30ef36ed1 /ucb | |
parent | 2587750685dd9279e8ab4e56ad7ca73bd6da4dd7 (diff) |
#95600# - XRow implementation now uses Type Converter service if needed.
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/cacher/cached.xml | 5 | ||||
-rw-r--r-- | ucb/source/cacher/cachedcontentresultset.cxx | 68 | ||||
-rw-r--r-- | ucb/source/cacher/cachedcontentresultset.hxx | 37 | ||||
-rw-r--r-- | ucb/source/cacher/cacheddynamicresultset.cxx | 8 |
4 files changed, 101 insertions, 17 deletions
diff --git a/ucb/source/cacher/cached.xml b/ucb/source/cacher/cached.xml index cf0748e6ee25..208520272f7c 100644 --- a/ucb/source/cacher/cached.xml +++ b/ucb/source/cacher/cached.xml @@ -26,6 +26,10 @@ <supported-service> com.sun.star.ucb.CachedContentResultSetFactory </supported-service> + + <service-dependency> + com.sun.star.script.Converter + </service-dependency> </component-description> <component-description> <author> @@ -115,6 +119,7 @@ <type> com.sun.star.lang.XSingleServiceFactory </type> <type> com.sun.star.lang.XTypeProvider </type> <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.script.XTypeConverter </type> <type> com.sun.star.sdbc.FetchDirection </type> <type> com.sun.star.sdbc.ResultSetType </type> <type> com.sun.star.sdbc.XCloseable </type> diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx index e603e40509b8..5bf52c2cecfe 100644 --- a/ucb/source/cacher/cachedcontentresultset.cxx +++ b/ucb/source/cacher/cachedcontentresultset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cachedcontentresultset.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: kso $ $Date: 2001-04-05 09:50:13 $ + * last change: $Author: kso $ $Date: 2001-12-05 13:03:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,6 +77,10 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #endif +#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ +#include <com/sun/star/script/XTypeConverter.hpp> +#endif + #ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ #include <com/sun/star/sdbc/ResultSetType.hpp> #endif @@ -91,6 +95,7 @@ using namespace com::sun::star::beans; using namespace com::sun::star::lang; +using namespace com::sun::star::script; using namespace com::sun::star::sdbc; using namespace com::sun::star::ucb; using namespace com::sun::star::uno; @@ -142,9 +147,32 @@ if( !m_aCache.hasRow( nRow ) ) \ } \ } \ const Any& rValue = m_aCache.getAny( nRow, columnIndex );\ -Type aRet; \ +Type aRet = Type(); \ m_bLastReadWasFromCache = sal_True; \ m_bLastCachedReadWasNull = !( rValue >>= aRet ); \ +/* Last chance. Try type converter service... */ \ +if ( m_bLastCachedReadWasNull && rValue.hasValue() ) \ +{ \ + Reference< XTypeConverter > xConverter \ + = getTypeConverter(); \ + if ( xConverter.is() ) \ + { \ + try \ + { \ + Any aConvAny = xConverter->convertTo( \ + rValue, \ + getCppuType( static_cast< \ + const Type * >( 0 ) ) ); \ + m_bLastCachedReadWasNull = !( aConvAny >>= aRet ); \ + } \ + catch ( IllegalArgumentException ) \ + { \ + } \ + catch ( CannotConvertException ) \ + { \ + } \ + } \ +} \ return aRet; //-------------------------------------------------------------------------- @@ -681,11 +709,14 @@ sal_Int32 SAL_CALL CCRS_PropertySetInfo //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- -CachedContentResultSet::CachedContentResultSet( Reference< XResultSet > xOrigin - , Reference< XContentIdentifierMapping > +CachedContentResultSet::CachedContentResultSet( + const Reference< XMultiServiceFactory > & xSMgr + , const Reference< XResultSet > & xOrigin + , const Reference< XContentIdentifierMapping > & xContentIdentifierMapping ) : ContentResultSetWrapper( xOrigin ) + , m_xSMgr( xSMgr ) , m_xFetchProvider( NULL ) , m_xFetchProviderForContentAccess( NULL ) , m_xContentIdentifierMapping( xContentIdentifierMapping ) @@ -710,6 +741,8 @@ CachedContentResultSet::CachedContentResultSet( Reference< XResultSet > xOrigin , m_aCacheContentIdentifierString( m_xContentIdentifierMapping ) , m_aCacheContentIdentifier( m_xContentIdentifierMapping ) , m_aCacheContent( m_xContentIdentifierMapping ) + , m_xTypeConverter( NULL ) + , m_bTriedToGetTypeConverter( sal_False ) { m_xFetchProvider = Reference< XFetchProvider >( m_xResultSetOrigin, UNO_QUERY ); OSL_ENSURE( m_xFetchProvider.is(), "interface XFetchProvider is required" ); @@ -2176,6 +2209,29 @@ Reference< XArray > SAL_CALL CachedContentResultSet XROW_GETXXX( getArray, Reference< XArray > ); } +//----------------------------------------------------------------- +// Type Converter Support +//----------------------------------------------------------------- + +const Reference< XTypeConverter >& CachedContentResultSet::getTypeConverter() +{ + osl::Guard< osl::Mutex > aGuard( m_aMutex ); + + if ( !m_bTriedToGetTypeConverter && !m_xTypeConverter.is() ) + { + m_bTriedToGetTypeConverter = sal_True; + m_xTypeConverter = Reference< XTypeConverter >( + m_xSMgr->createInstance( + OUString::createFromAscii( + "com.sun.star.script.Converter" ) ), + UNO_QUERY ); + + OSL_ENSURE( m_xTypeConverter.is(), + "PropertyValueSet::getTypeConverter() - " + "Service 'com.sun.star.script.Converter' n/a!" ); + } + return m_xTypeConverter; +} //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -2239,7 +2295,7 @@ Reference< XResultSet > SAL_CALL CachedContentResultSetFactory throw( com::sun::star::uno::RuntimeException ) { Reference< XResultSet > xRet; - xRet = new CachedContentResultSet( xSource, xMapping ); + xRet = new CachedContentResultSet( m_xSMgr, xSource, xMapping ); return xRet; } diff --git a/ucb/source/cacher/cachedcontentresultset.hxx b/ucb/source/cacher/cachedcontentresultset.hxx index b082a1cc4f23..6702c28610e9 100644 --- a/ucb/source/cacher/cachedcontentresultset.hxx +++ b/ucb/source/cacher/cachedcontentresultset.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cachedcontentresultset.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: kso $ $Date: 2000-10-31 10:37:35 $ + * last change: $Author: kso $ $Date: 2001-12-05 13:03:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,6 +99,10 @@ //========================================================================= +namespace com { namespace sun { namespace star { namespace script { + class XTypeConverter; +} } } } + class CCRS_PropertySetInfo; class CachedContentResultSet : public ContentResultSetWrapper @@ -174,6 +178,9 @@ class CachedContentResultSet //----------------------------------------------------------------- //members + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + m_xSMgr; + //different Interfaces from Origin: com::sun::star::uno::Reference< com::sun::star::ucb::XFetchProvider > m_xFetchProvider; //XFetchProvider-interface from m_xOrigin @@ -249,11 +256,15 @@ private: impl_changeIsRowCountFinal( sal_Bool bOld, sal_Bool bNew ); public: - CachedContentResultSet( com::sun::star::uno::Reference< - com::sun::star::sdbc::XResultSet > xOrigin, - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentIdentifierMapping > - xContentIdentifierMapping ); + CachedContentResultSet( + const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > & + xSMgr, + const com::sun::star::uno::Reference< + com::sun::star::sdbc::XResultSet > & xOrigin, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifierMapping > & + xContentIdentifierMapping ); virtual ~CachedContentResultSet(); @@ -509,6 +520,18 @@ public: getArray( sal_Int32 columnIndex ) throw( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException ); + + //----------------------------------------------------------------- + // Type Converter support + //----------------------------------------------------------------- + +private: + sal_Bool m_bTriedToGetTypeConverter; + com::sun::star::uno::Reference< + com::sun::star::script::XTypeConverter > m_xTypeConverter; + + const com::sun::star::uno::Reference< + com::sun::star::script::XTypeConverter >& getTypeConverter(); }; //========================================================================= diff --git a/ucb/source/cacher/cacheddynamicresultset.cxx b/ucb/source/cacher/cacheddynamicresultset.cxx index d42b2c4b8c8e..9cb9da8b809d 100644 --- a/ucb/source/cacher/cacheddynamicresultset.cxx +++ b/ucb/source/cacher/cacheddynamicresultset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cacheddynamicresultset.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: kso $ $Date: 2001-04-05 09:50:13 $ + * last change: $Author: kso $ $Date: 2001-12-05 13:03:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,7 +102,7 @@ void SAL_CALL CachedDynamicResultSet OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" ); Reference< XResultSet > xCache( - new CachedContentResultSet( m_xSourceResultOne, m_xContentIdentifierMapping ) ); + new CachedContentResultSet( m_xSMgr, m_xSourceResultOne, m_xContentIdentifierMapping ) ); osl::Guard< osl::Mutex > aGuard( m_aMutex ); m_xMyResultOne = xCache; @@ -116,7 +116,7 @@ void SAL_CALL CachedDynamicResultSet OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" ); Reference< XResultSet > xCache( - new CachedContentResultSet( m_xSourceResultTwo, m_xContentIdentifierMapping ) ); + new CachedContentResultSet( m_xSMgr, m_xSourceResultTwo, m_xContentIdentifierMapping ) ); osl::Guard< osl::Mutex > aGuard( m_aMutex ); m_xMyResultTwo = xCache; |