1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucb.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <cachedcontentresultset.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/ucb/FetchError.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/ucb/ResultSetException.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
38*cdf0e10cSrcweir #include <rtl/ustring.hxx>
39*cdf0e10cSrcweir #include <osl/diagnose.h>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir using namespace com::sun::star::beans;
42*cdf0e10cSrcweir using namespace com::sun::star::lang;
43*cdf0e10cSrcweir using namespace com::sun::star::script;
44*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
45*cdf0e10cSrcweir using namespace com::sun::star::ucb;
46*cdf0e10cSrcweir using namespace com::sun::star::uno;
47*cdf0e10cSrcweir using namespace com::sun::star::util;
48*cdf0e10cSrcweir using namespace cppu;
49*cdf0e10cSrcweir using namespace rtl;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #define COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE 256
52*cdf0e10cSrcweir #define COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION FetchDirection::FORWARD
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //--------------------------------------------------------------------------
55*cdf0e10cSrcweir //--------------------------------------------------------------------------
56*cdf0e10cSrcweir //define for getXXX methods of interface XRow
57*cdf0e10cSrcweir //--------------------------------------------------------------------------
58*cdf0e10cSrcweir //--------------------------------------------------------------------------
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //if you change this macro please pay attention to
61*cdf0e10cSrcweir //function ::getObject, where this is similar implemented
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir #define XROW_GETXXX( getXXX, Type )						\
64*cdf0e10cSrcweir impl_EnsureNotDisposed();								\
65*cdf0e10cSrcweir ReacquireableGuard aGuard( m_aMutex );					\
66*cdf0e10cSrcweir sal_Int32 nRow = m_nRow;								\
67*cdf0e10cSrcweir sal_Int32 nFetchSize = m_nFetchSize;					\
68*cdf0e10cSrcweir sal_Int32 nFetchDirection = m_nFetchDirection;			\
69*cdf0e10cSrcweir if( !m_aCache.hasRow( nRow ) )							\
70*cdf0e10cSrcweir {														\
71*cdf0e10cSrcweir 	if( !m_aCache.hasCausedException( nRow ) )			\
72*cdf0e10cSrcweir {														\
73*cdf0e10cSrcweir 		if( !m_xFetchProvider.is() )					\
74*cdf0e10cSrcweir 		{												\
75*cdf0e10cSrcweir 			OSL_ENSURE( sal_False, "broadcaster was disposed already" );	\
76*cdf0e10cSrcweir 			throw SQLException();						\
77*cdf0e10cSrcweir 		}												\
78*cdf0e10cSrcweir 		aGuard.clear();									\
79*cdf0e10cSrcweir 		if( impl_isForwardOnly() )						\
80*cdf0e10cSrcweir 			applyPositionToOrigin( nRow );				\
81*cdf0e10cSrcweir 														\
82*cdf0e10cSrcweir 		impl_fetchData( nRow, nFetchSize, nFetchDirection ); \
83*cdf0e10cSrcweir 	}													\
84*cdf0e10cSrcweir 	aGuard.reacquire();									\
85*cdf0e10cSrcweir 	if( !m_aCache.hasRow( nRow ) )						\
86*cdf0e10cSrcweir 	{													\
87*cdf0e10cSrcweir 		m_bLastReadWasFromCache = sal_False;			\
88*cdf0e10cSrcweir 		aGuard.clear();									\
89*cdf0e10cSrcweir 		applyPositionToOrigin( nRow );					\
90*cdf0e10cSrcweir 		impl_init_xRowOrigin();							\
91*cdf0e10cSrcweir 		return m_xRowOrigin->getXXX( columnIndex );		\
92*cdf0e10cSrcweir 	}													\
93*cdf0e10cSrcweir }														\
94*cdf0e10cSrcweir const Any& rValue = m_aCache.getAny( nRow, columnIndex );\
95*cdf0e10cSrcweir Type aRet = Type();                                     \
96*cdf0e10cSrcweir m_bLastReadWasFromCache = sal_True;						\
97*cdf0e10cSrcweir m_bLastCachedReadWasNull = !( rValue >>= aRet );		\
98*cdf0e10cSrcweir /* Last chance. Try type converter service... */        \
99*cdf0e10cSrcweir if ( m_bLastCachedReadWasNull && rValue.hasValue() )    \
100*cdf0e10cSrcweir {                                                       \
101*cdf0e10cSrcweir     Reference< XTypeConverter > xConverter              \
102*cdf0e10cSrcweir                                 = getTypeConverter();   \
103*cdf0e10cSrcweir     if ( xConverter.is() )                              \
104*cdf0e10cSrcweir     {                                                   \
105*cdf0e10cSrcweir         try                                             \
106*cdf0e10cSrcweir         {                                               \
107*cdf0e10cSrcweir             Any aConvAny = xConverter->convertTo(       \
108*cdf0e10cSrcweir                 rValue,                                 \
109*cdf0e10cSrcweir                 getCppuType( static_cast<               \
110*cdf0e10cSrcweir                     const Type * >( 0 ) ) );            \
111*cdf0e10cSrcweir             m_bLastCachedReadWasNull = !( aConvAny >>= aRet ); \
112*cdf0e10cSrcweir         }                                               \
113*cdf0e10cSrcweir         catch ( IllegalArgumentException )              \
114*cdf0e10cSrcweir         {                                               \
115*cdf0e10cSrcweir         }                                               \
116*cdf0e10cSrcweir         catch ( CannotConvertException )                \
117*cdf0e10cSrcweir         {                                               \
118*cdf0e10cSrcweir         }                                               \
119*cdf0e10cSrcweir     }                                                   \
120*cdf0e10cSrcweir }                                                       \
121*cdf0e10cSrcweir return aRet;
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir //--------------------------------------------------------------------------
124*cdf0e10cSrcweir //--------------------------------------------------------------------------
125*cdf0e10cSrcweir // CCRS_Cache methoeds.
126*cdf0e10cSrcweir //--------------------------------------------------------------------------
127*cdf0e10cSrcweir //--------------------------------------------------------------------------
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir CachedContentResultSet::CCRS_Cache::CCRS_Cache(
130*cdf0e10cSrcweir 	const Reference< XContentIdentifierMapping > & xMapping )
131*cdf0e10cSrcweir 	: m_pResult( NULL )
132*cdf0e10cSrcweir 	, m_xContentIdentifierMapping( xMapping )
133*cdf0e10cSrcweir 	, m_pMappedReminder( NULL )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir CachedContentResultSet::CCRS_Cache::~CCRS_Cache()
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	delete m_pResult;
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet::CCRS_Cache
143*cdf0e10cSrcweir 	::clear()
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	if( m_pResult )
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		delete m_pResult;
148*cdf0e10cSrcweir 		m_pResult = NULL;
149*cdf0e10cSrcweir 	}
150*cdf0e10cSrcweir 	clearMappedReminder();
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet::CCRS_Cache
154*cdf0e10cSrcweir 	::loadData( const FetchResult& rResult )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	clear();
157*cdf0e10cSrcweir 	m_pResult = new FetchResult( rResult );
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
161*cdf0e10cSrcweir 	::hasRow( sal_Int32 row )
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir 	if( !m_pResult )
164*cdf0e10cSrcweir 		return sal_False;
165*cdf0e10cSrcweir 	long nStart = m_pResult->StartIndex;
166*cdf0e10cSrcweir 	long nEnd = nStart;
167*cdf0e10cSrcweir 	if( m_pResult->Orientation )
168*cdf0e10cSrcweir 		nEnd += m_pResult->Rows.getLength() - 1;
169*cdf0e10cSrcweir 	else
170*cdf0e10cSrcweir 		nStart -= m_pResult->Rows.getLength() + 1;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	return nStart <= row && row <= nEnd;
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir sal_Int32 SAL_CALL CachedContentResultSet::CCRS_Cache
176*cdf0e10cSrcweir 	::getMaxRow()
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir 	if( !m_pResult )
179*cdf0e10cSrcweir 		return 0;
180*cdf0e10cSrcweir 	long nEnd = m_pResult->StartIndex;
181*cdf0e10cSrcweir 	if( m_pResult->Orientation )
182*cdf0e10cSrcweir 		return nEnd += m_pResult->Rows.getLength() - 1;
183*cdf0e10cSrcweir 	else
184*cdf0e10cSrcweir 		return nEnd;
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
188*cdf0e10cSrcweir 	::hasKnownLast()
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir 	if( !m_pResult )
191*cdf0e10cSrcweir 		return sal_False;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	if( ( m_pResult->FetchError & FetchError::ENDOFDATA )
194*cdf0e10cSrcweir 		&& m_pResult->Orientation
195*cdf0e10cSrcweir 		&& m_pResult->Rows.getLength() )
196*cdf0e10cSrcweir 		return sal_True;
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	return sal_False;
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
202*cdf0e10cSrcweir 	::hasCausedException( sal_Int32 nRow )
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir 	if( !m_pResult )
205*cdf0e10cSrcweir 		return sal_False;
206*cdf0e10cSrcweir 	if( !( m_pResult->FetchError & FetchError::EXCEPTION ) )
207*cdf0e10cSrcweir 		return sal_False;
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	long nEnd = m_pResult->StartIndex;
210*cdf0e10cSrcweir 	if( m_pResult->Orientation )
211*cdf0e10cSrcweir 		nEnd += m_pResult->Rows.getLength();
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	return nRow == nEnd+1;
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir Any& SAL_CALL CachedContentResultSet::CCRS_Cache
217*cdf0e10cSrcweir 	::getRowAny( sal_Int32 nRow )
218*cdf0e10cSrcweir 	throw( SQLException,
219*cdf0e10cSrcweir 	RuntimeException )
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir 	if( !nRow )
222*cdf0e10cSrcweir 		throw SQLException();
223*cdf0e10cSrcweir 	if( !m_pResult )
224*cdf0e10cSrcweir 		throw SQLException();
225*cdf0e10cSrcweir 	if( !hasRow( nRow ) )
226*cdf0e10cSrcweir 		throw SQLException();
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	long nDiff = nRow - m_pResult->StartIndex;
229*cdf0e10cSrcweir 	if( nDiff < 0 )
230*cdf0e10cSrcweir 		nDiff *= -1;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 	return (m_pResult->Rows)[nDiff];
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet::CCRS_Cache
236*cdf0e10cSrcweir 	::remindMapped( sal_Int32 nRow )
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir 	//remind that this row was mapped
239*cdf0e10cSrcweir 	if( !m_pResult )
240*cdf0e10cSrcweir 		return;
241*cdf0e10cSrcweir 	long nDiff = nRow - m_pResult->StartIndex;
242*cdf0e10cSrcweir 	if( nDiff < 0 )
243*cdf0e10cSrcweir 		nDiff *= -1;
244*cdf0e10cSrcweir 	Sequence< sal_Bool >* pMappedReminder = getMappedReminder();
245*cdf0e10cSrcweir 	if( nDiff < pMappedReminder->getLength() )
246*cdf0e10cSrcweir 		(*pMappedReminder)[nDiff] = sal_True;
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
250*cdf0e10cSrcweir 	::isRowMapped( sal_Int32 nRow )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	if( !m_pMappedReminder || !m_pResult )
253*cdf0e10cSrcweir 		return sal_False;
254*cdf0e10cSrcweir 	long nDiff = nRow - m_pResult->StartIndex;
255*cdf0e10cSrcweir 	if( nDiff < 0 )
256*cdf0e10cSrcweir 		nDiff *= -1;
257*cdf0e10cSrcweir 	if( nDiff < m_pMappedReminder->getLength() )
258*cdf0e10cSrcweir 		return (*m_pMappedReminder)[nDiff];
259*cdf0e10cSrcweir 	return sal_False;
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet::CCRS_Cache
263*cdf0e10cSrcweir 	::clearMappedReminder()
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir 	delete m_pMappedReminder;
266*cdf0e10cSrcweir 	m_pMappedReminder = NULL;
267*cdf0e10cSrcweir }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir Sequence< sal_Bool >* SAL_CALL CachedContentResultSet::CCRS_Cache
270*cdf0e10cSrcweir 	::getMappedReminder()
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir 	if( !m_pMappedReminder )
273*cdf0e10cSrcweir 	{
274*cdf0e10cSrcweir 		sal_Int32 nCount = m_pResult->Rows.getLength();
275*cdf0e10cSrcweir 		m_pMappedReminder = new Sequence< sal_Bool >( nCount );
276*cdf0e10cSrcweir 		for( ;nCount; nCount-- )
277*cdf0e10cSrcweir 			(*m_pMappedReminder)[nCount] = sal_False;
278*cdf0e10cSrcweir 	}
279*cdf0e10cSrcweir 	return m_pMappedReminder;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir const Any& SAL_CALL CachedContentResultSet::CCRS_Cache
283*cdf0e10cSrcweir 	::getAny( sal_Int32 nRow, sal_Int32 nColumnIndex )
284*cdf0e10cSrcweir 	throw( SQLException,
285*cdf0e10cSrcweir 	RuntimeException )
286*cdf0e10cSrcweir {
287*cdf0e10cSrcweir 	if( !nColumnIndex )
288*cdf0e10cSrcweir 		throw SQLException();
289*cdf0e10cSrcweir 	if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
290*cdf0e10cSrcweir 	{
291*cdf0e10cSrcweir 		Any& rRow = getRowAny( nRow );
292*cdf0e10cSrcweir 		Sequence< Any > aValue;
293*cdf0e10cSrcweir 		rRow >>= aValue;
294*cdf0e10cSrcweir 		if( m_xContentIdentifierMapping->mapRow( aValue ) )
295*cdf0e10cSrcweir 		{
296*cdf0e10cSrcweir 			rRow <<= aValue;
297*cdf0e10cSrcweir 			remindMapped( nRow );
298*cdf0e10cSrcweir 		}
299*cdf0e10cSrcweir 		else
300*cdf0e10cSrcweir 			m_xContentIdentifierMapping.clear();
301*cdf0e10cSrcweir 	}
302*cdf0e10cSrcweir 	const Sequence< Any >& rRow =
303*cdf0e10cSrcweir 		(* reinterpret_cast< const Sequence< Any > * >
304*cdf0e10cSrcweir 		(getRowAny( nRow ).getValue() ));
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 	if( nColumnIndex > rRow.getLength() )
307*cdf0e10cSrcweir 		throw SQLException();
308*cdf0e10cSrcweir 	return rRow[nColumnIndex-1];
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir const rtl::OUString& SAL_CALL CachedContentResultSet::CCRS_Cache
312*cdf0e10cSrcweir 	::getContentIdentifierString( sal_Int32 nRow )
313*cdf0e10cSrcweir 	throw( com::sun::star::uno::RuntimeException )
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir 	try
316*cdf0e10cSrcweir 	{
317*cdf0e10cSrcweir 		if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
318*cdf0e10cSrcweir 		{
319*cdf0e10cSrcweir 			Any& rRow = getRowAny( nRow );
320*cdf0e10cSrcweir 			rtl::OUString aValue;
321*cdf0e10cSrcweir 			rRow >>= aValue;
322*cdf0e10cSrcweir 			rRow <<= m_xContentIdentifierMapping->mapContentIdentifierString( aValue );
323*cdf0e10cSrcweir 			remindMapped( nRow );
324*cdf0e10cSrcweir 		}
325*cdf0e10cSrcweir 		return (* reinterpret_cast< const rtl::OUString * >
326*cdf0e10cSrcweir 				(getRowAny( nRow ).getValue() ));
327*cdf0e10cSrcweir 	}
328*cdf0e10cSrcweir 	catch( SQLException )
329*cdf0e10cSrcweir 	{
330*cdf0e10cSrcweir 		throw RuntimeException();
331*cdf0e10cSrcweir 	}
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir const Reference< XContentIdentifier >& SAL_CALL CachedContentResultSet::CCRS_Cache
335*cdf0e10cSrcweir 	::getContentIdentifier( sal_Int32 nRow )
336*cdf0e10cSrcweir 	throw( com::sun::star::uno::RuntimeException )
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir 	try
339*cdf0e10cSrcweir 	{
340*cdf0e10cSrcweir 		if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
341*cdf0e10cSrcweir 		{
342*cdf0e10cSrcweir 			Any& rRow = getRowAny( nRow );
343*cdf0e10cSrcweir 			Reference< XContentIdentifier > aValue;
344*cdf0e10cSrcweir 			rRow >>= aValue;
345*cdf0e10cSrcweir 			rRow <<= m_xContentIdentifierMapping->mapContentIdentifier( aValue );
346*cdf0e10cSrcweir 			remindMapped( nRow );
347*cdf0e10cSrcweir 		}
348*cdf0e10cSrcweir 		return (* reinterpret_cast< const Reference< XContentIdentifier > * >
349*cdf0e10cSrcweir 				(getRowAny( nRow ).getValue() ));
350*cdf0e10cSrcweir 	}
351*cdf0e10cSrcweir 	catch( SQLException )
352*cdf0e10cSrcweir 	{
353*cdf0e10cSrcweir 		throw RuntimeException();
354*cdf0e10cSrcweir 	}
355*cdf0e10cSrcweir }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir const Reference< XContent >& SAL_CALL CachedContentResultSet::CCRS_Cache
358*cdf0e10cSrcweir 	::getContent( sal_Int32 nRow )
359*cdf0e10cSrcweir 	throw( com::sun::star::uno::RuntimeException )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	try
362*cdf0e10cSrcweir 	{
363*cdf0e10cSrcweir 		if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
364*cdf0e10cSrcweir 		{
365*cdf0e10cSrcweir 			Any& rRow = getRowAny( nRow );
366*cdf0e10cSrcweir 			Reference< XContent > aValue;
367*cdf0e10cSrcweir 			rRow >>= aValue;
368*cdf0e10cSrcweir 			rRow <<= m_xContentIdentifierMapping->mapContent( aValue );
369*cdf0e10cSrcweir 			remindMapped( nRow );
370*cdf0e10cSrcweir 		}
371*cdf0e10cSrcweir 		return (* reinterpret_cast< const Reference< XContent > * >
372*cdf0e10cSrcweir 				(getRowAny( nRow ).getValue() ));
373*cdf0e10cSrcweir 	}
374*cdf0e10cSrcweir 	catch( SQLException )
375*cdf0e10cSrcweir 	{
376*cdf0e10cSrcweir 		throw RuntimeException();
377*cdf0e10cSrcweir 	}
378*cdf0e10cSrcweir }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir //--------------------------------------------------------------------------
381*cdf0e10cSrcweir //--------------------------------------------------------------------------
382*cdf0e10cSrcweir // class CCRS_PropertySetInfo
383*cdf0e10cSrcweir //--------------------------------------------------------------------------
384*cdf0e10cSrcweir //--------------------------------------------------------------------------
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir class CCRS_PropertySetInfo :
387*cdf0e10cSrcweir 				public cppu::OWeakObject,
388*cdf0e10cSrcweir 				public com::sun::star::lang::XTypeProvider,
389*cdf0e10cSrcweir 				public com::sun::star::beans::XPropertySetInfo
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir     friend class CachedContentResultSet;
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 	//my Properties
394*cdf0e10cSrcweir 	Sequence< com::sun::star::beans::Property >*
395*cdf0e10cSrcweir 							m_pProperties;
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 	//some helping variables ( names for my special properties )
398*cdf0e10cSrcweir 	static rtl::OUString	m_aPropertyNameForCount;
399*cdf0e10cSrcweir 	static rtl::OUString	m_aPropertyNameForFinalCount;
400*cdf0e10cSrcweir 	static rtl::OUString	m_aPropertyNameForFetchSize;
401*cdf0e10cSrcweir 	static rtl::OUString	m_aPropertyNameForFetchDirection;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 	long					m_nFetchSizePropertyHandle;
404*cdf0e10cSrcweir 	long					m_nFetchDirectionPropertyHandle;
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir private:
407*cdf0e10cSrcweir 	sal_Int32 SAL_CALL
408*cdf0e10cSrcweir 	impl_getRemainedHandle() const;
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     sal_Bool SAL_CALL
411*cdf0e10cSrcweir 	impl_queryProperty(
412*cdf0e10cSrcweir 			const rtl::OUString& rName
413*cdf0e10cSrcweir 			, com::sun::star::beans::Property& rProp ) const;
414*cdf0e10cSrcweir 	sal_Int32 SAL_CALL
415*cdf0e10cSrcweir 	impl_getPos( const rtl::OUString& rName ) const;
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	static sal_Bool SAL_CALL
418*cdf0e10cSrcweir 	impl_isMyPropertyName( const rtl::OUString& rName );
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir public:
421*cdf0e10cSrcweir 	CCRS_PropertySetInfo(	Reference<
422*cdf0e10cSrcweir 			XPropertySetInfo > xPropertySetInfoOrigin );
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 	virtual ~CCRS_PropertySetInfo();
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 	// XInterface
427*cdf0e10cSrcweir 	XINTERFACE_DECL()
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 	// XTypeProvider
430*cdf0e10cSrcweir 	XTYPEPROVIDER_DECL()
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	// XPropertySetInfo
433*cdf0e10cSrcweir     virtual Sequence< com::sun::star::beans::Property > SAL_CALL
434*cdf0e10cSrcweir 	getProperties()
435*cdf0e10cSrcweir 		throw( RuntimeException );
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir     virtual com::sun::star::beans::Property SAL_CALL
438*cdf0e10cSrcweir 	getPropertyByName( const rtl::OUString& aName )
439*cdf0e10cSrcweir 		throw( com::sun::star::beans::UnknownPropertyException, RuntimeException );
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
442*cdf0e10cSrcweir 	hasPropertyByName( const rtl::OUString& Name )
443*cdf0e10cSrcweir 		throw( RuntimeException );
444*cdf0e10cSrcweir };
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir OUString	CCRS_PropertySetInfo::m_aPropertyNameForCount( OUString::createFromAscii( "RowCount" ) );
447*cdf0e10cSrcweir OUString	CCRS_PropertySetInfo::m_aPropertyNameForFinalCount( OUString::createFromAscii( "IsRowCountFinal" ) );
448*cdf0e10cSrcweir OUString	CCRS_PropertySetInfo::m_aPropertyNameForFetchSize( OUString::createFromAscii( "FetchSize" ) );
449*cdf0e10cSrcweir OUString	CCRS_PropertySetInfo::m_aPropertyNameForFetchDirection( OUString::createFromAscii( "FetchDirection" ) );
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir CCRS_PropertySetInfo::CCRS_PropertySetInfo(
452*cdf0e10cSrcweir 		Reference< XPropertySetInfo > xInfo )
453*cdf0e10cSrcweir 		: m_pProperties( NULL )
454*cdf0e10cSrcweir 		, m_nFetchSizePropertyHandle( -1 )
455*cdf0e10cSrcweir 		, m_nFetchDirectionPropertyHandle( -1 )
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir 	//initialize list of properties:
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 	// it is required, that the received xInfo contains the two
460*cdf0e10cSrcweir 	// properties with names 'm_aPropertyNameForCount' and
461*cdf0e10cSrcweir 	// 'm_aPropertyNameForFinalCount'
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 	if( xInfo.is() )
464*cdf0e10cSrcweir 	{
465*cdf0e10cSrcweir 		Sequence<Property> aProps = xInfo->getProperties();
466*cdf0e10cSrcweir 		m_pProperties = new Sequence<Property> ( aProps );
467*cdf0e10cSrcweir 	}
468*cdf0e10cSrcweir 	else
469*cdf0e10cSrcweir 	{
470*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "The received XPropertySetInfo doesn't contain required properties" );
471*cdf0e10cSrcweir 		m_pProperties = new Sequence<Property>;
472*cdf0e10cSrcweir 	}
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	//ensure, that we haven't got the Properties 'FetchSize' and 'Direction' twice:
475*cdf0e10cSrcweir 	sal_Int32 nFetchSize = impl_getPos( m_aPropertyNameForFetchSize );
476*cdf0e10cSrcweir 	sal_Int32 nFetchDirection = impl_getPos( m_aPropertyNameForFetchDirection );
477*cdf0e10cSrcweir 	sal_Int32 nDeleted = 0;
478*cdf0e10cSrcweir 	if( nFetchSize != -1 )
479*cdf0e10cSrcweir 		nDeleted++;
480*cdf0e10cSrcweir 	if( nFetchDirection != -1 )
481*cdf0e10cSrcweir 		nDeleted++;
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 	Sequence< Property >* pOrigProps = new Sequence<Property> ( *m_pProperties );
484*cdf0e10cSrcweir 	sal_Int32 nOrigProps = pOrigProps->getLength();
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	m_pProperties->realloc( nOrigProps + 2 - nDeleted );//note that nDeleted is <= 2
487*cdf0e10cSrcweir 	for( sal_Int32 n = 0, m = 0; n < nOrigProps; n++, m++ )
488*cdf0e10cSrcweir 	{
489*cdf0e10cSrcweir 		if( n == nFetchSize || n == nFetchDirection )
490*cdf0e10cSrcweir 			m--;
491*cdf0e10cSrcweir 		else
492*cdf0e10cSrcweir 			(*m_pProperties)[ m ] = (*pOrigProps)[ n ];
493*cdf0e10cSrcweir 	}
494*cdf0e10cSrcweir 	{
495*cdf0e10cSrcweir 		Property& rMyProp = (*m_pProperties)[ nOrigProps - nDeleted ];
496*cdf0e10cSrcweir 		rMyProp.Name = m_aPropertyNameForFetchSize;
497*cdf0e10cSrcweir 		rMyProp.Type = getCppuType( static_cast< const sal_Int32 * >( 0 ) );
498*cdf0e10cSrcweir 		rMyProp.Attributes = PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT;
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 		if( nFetchSize != -1 )
501*cdf0e10cSrcweir 			m_nFetchSizePropertyHandle = (*pOrigProps)[nFetchSize].Handle;
502*cdf0e10cSrcweir 		else
503*cdf0e10cSrcweir 			m_nFetchSizePropertyHandle = impl_getRemainedHandle();
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 		rMyProp.Handle = m_nFetchSizePropertyHandle;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 	}
508*cdf0e10cSrcweir 	{
509*cdf0e10cSrcweir 		Property& rMyProp = (*m_pProperties)[ nOrigProps - nDeleted + 1 ];
510*cdf0e10cSrcweir 		rMyProp.Name = m_aPropertyNameForFetchDirection;
511*cdf0e10cSrcweir 		rMyProp.Type = getCppuType( static_cast< const sal_Bool * >( 0 ) );
512*cdf0e10cSrcweir 		rMyProp.Attributes = PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT;
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir 		if( nFetchSize != -1 )
515*cdf0e10cSrcweir 			m_nFetchDirectionPropertyHandle = (*pOrigProps)[nFetchDirection].Handle;
516*cdf0e10cSrcweir 		else
517*cdf0e10cSrcweir 			m_nFetchDirectionPropertyHandle = impl_getRemainedHandle();
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir 		m_nFetchDirectionPropertyHandle = rMyProp.Handle;
520*cdf0e10cSrcweir 	}
521*cdf0e10cSrcweir 	delete pOrigProps;
522*cdf0e10cSrcweir }
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir CCRS_PropertySetInfo::~CCRS_PropertySetInfo()
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir 	delete m_pProperties;
527*cdf0e10cSrcweir }
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir //--------------------------------------------------------------------------
530*cdf0e10cSrcweir // XInterface methods.
531*cdf0e10cSrcweir //--------------------------------------------------------------------------
532*cdf0e10cSrcweir //list all interfaces inclusive baseclasses of interfaces
533*cdf0e10cSrcweir XINTERFACE_IMPL_2( CCRS_PropertySetInfo
534*cdf0e10cSrcweir 				  , XTypeProvider
535*cdf0e10cSrcweir 				  , XPropertySetInfo
536*cdf0e10cSrcweir 				  );
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir //--------------------------------------------------------------------------
539*cdf0e10cSrcweir // XTypeProvider methods.
540*cdf0e10cSrcweir //--------------------------------------------------------------------------
541*cdf0e10cSrcweir //list all interfaces exclusive baseclasses
542*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( CCRS_PropertySetInfo
543*cdf0e10cSrcweir 					, XTypeProvider
544*cdf0e10cSrcweir 					, XPropertySetInfo
545*cdf0e10cSrcweir 					);
546*cdf0e10cSrcweir //--------------------------------------------------------------------------
547*cdf0e10cSrcweir // XPropertySetInfo methods.
548*cdf0e10cSrcweir //--------------------------------------------------------------------------
549*cdf0e10cSrcweir //virtual
550*cdf0e10cSrcweir Sequence< Property > SAL_CALL CCRS_PropertySetInfo
551*cdf0e10cSrcweir 	::getProperties() throw( RuntimeException )
552*cdf0e10cSrcweir {
553*cdf0e10cSrcweir 	return *m_pProperties;
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir //virtual
557*cdf0e10cSrcweir Property SAL_CALL CCRS_PropertySetInfo
558*cdf0e10cSrcweir 	::getPropertyByName( const rtl::OUString& aName )
559*cdf0e10cSrcweir 		throw( UnknownPropertyException, RuntimeException )
560*cdf0e10cSrcweir {
561*cdf0e10cSrcweir 	if ( !aName.getLength() )
562*cdf0e10cSrcweir 		throw UnknownPropertyException();
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 	Property aProp;
565*cdf0e10cSrcweir 	if ( impl_queryProperty( aName, aProp ) )
566*cdf0e10cSrcweir 		return aProp;
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 	throw UnknownPropertyException();
569*cdf0e10cSrcweir }
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir //virtual
572*cdf0e10cSrcweir sal_Bool SAL_CALL CCRS_PropertySetInfo
573*cdf0e10cSrcweir 	::hasPropertyByName( const rtl::OUString& Name )
574*cdf0e10cSrcweir 		throw( RuntimeException )
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir 	return ( impl_getPos( Name ) != -1 );
577*cdf0e10cSrcweir }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir //--------------------------------------------------------------------------
580*cdf0e10cSrcweir // impl_ methods.
581*cdf0e10cSrcweir //--------------------------------------------------------------------------
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir sal_Int32 SAL_CALL CCRS_PropertySetInfo
584*cdf0e10cSrcweir 			::impl_getPos( const OUString& rName ) const
585*cdf0e10cSrcweir {
586*cdf0e10cSrcweir 	for( sal_Int32 nN = m_pProperties->getLength(); nN--; )
587*cdf0e10cSrcweir 	{
588*cdf0e10cSrcweir 		const Property& rMyProp = (*m_pProperties)[nN];
589*cdf0e10cSrcweir 		if( rMyProp.Name == rName )
590*cdf0e10cSrcweir 			return nN;
591*cdf0e10cSrcweir 	}
592*cdf0e10cSrcweir 	return -1;
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir sal_Bool SAL_CALL CCRS_PropertySetInfo
596*cdf0e10cSrcweir 		::impl_queryProperty( const OUString& rName, Property& rProp ) const
597*cdf0e10cSrcweir {
598*cdf0e10cSrcweir 	for( sal_Int32 nN = m_pProperties->getLength(); nN--; )
599*cdf0e10cSrcweir 	{
600*cdf0e10cSrcweir 		const Property& rMyProp = (*m_pProperties)[nN];
601*cdf0e10cSrcweir 		if( rMyProp.Name == rName )
602*cdf0e10cSrcweir 		{
603*cdf0e10cSrcweir 			rProp.Name = rMyProp.Name;
604*cdf0e10cSrcweir 			rProp.Handle = rMyProp.Handle;
605*cdf0e10cSrcweir 			rProp.Type = rMyProp.Type;
606*cdf0e10cSrcweir 			rProp.Attributes = rMyProp.Attributes;
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 			return sal_True;
609*cdf0e10cSrcweir 		}
610*cdf0e10cSrcweir 	}
611*cdf0e10cSrcweir 	return sal_False;
612*cdf0e10cSrcweir }
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir //static
615*cdf0e10cSrcweir sal_Bool SAL_CALL CCRS_PropertySetInfo
616*cdf0e10cSrcweir 		::impl_isMyPropertyName( const OUString& rPropertyName )
617*cdf0e10cSrcweir {
618*cdf0e10cSrcweir 	return ( rPropertyName == m_aPropertyNameForCount
619*cdf0e10cSrcweir 	|| rPropertyName == m_aPropertyNameForFinalCount
620*cdf0e10cSrcweir 	|| rPropertyName == m_aPropertyNameForFetchSize
621*cdf0e10cSrcweir 	|| rPropertyName == m_aPropertyNameForFetchDirection );
622*cdf0e10cSrcweir }
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir sal_Int32 SAL_CALL CCRS_PropertySetInfo
625*cdf0e10cSrcweir 			::impl_getRemainedHandle( ) const
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir 	sal_Int32 nHandle = 1;
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir 	if( !m_pProperties )
630*cdf0e10cSrcweir 	{
631*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "Properties not initialized yet" );
632*cdf0e10cSrcweir 		return nHandle;
633*cdf0e10cSrcweir 	}
634*cdf0e10cSrcweir 	sal_Bool bFound = sal_True;
635*cdf0e10cSrcweir 	while( bFound )
636*cdf0e10cSrcweir 	{
637*cdf0e10cSrcweir 		bFound = sal_False;
638*cdf0e10cSrcweir 		for( sal_Int32 nN = m_pProperties->getLength(); nN--; )
639*cdf0e10cSrcweir 		{
640*cdf0e10cSrcweir 			if( nHandle == (*m_pProperties)[nN].Handle )
641*cdf0e10cSrcweir 			{
642*cdf0e10cSrcweir 				bFound = sal_True;
643*cdf0e10cSrcweir 				nHandle++;
644*cdf0e10cSrcweir 				break;
645*cdf0e10cSrcweir 			}
646*cdf0e10cSrcweir 		}
647*cdf0e10cSrcweir 	}
648*cdf0e10cSrcweir 	return nHandle;
649*cdf0e10cSrcweir }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir //--------------------------------------------------------------------------
652*cdf0e10cSrcweir //--------------------------------------------------------------------------
653*cdf0e10cSrcweir // class CachedContentResultSet
654*cdf0e10cSrcweir //--------------------------------------------------------------------------
655*cdf0e10cSrcweir //--------------------------------------------------------------------------
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir CachedContentResultSet::CachedContentResultSet(
658*cdf0e10cSrcweir                   const Reference< XMultiServiceFactory > & xSMgr
659*cdf0e10cSrcweir                 , const Reference< XResultSet > & xOrigin
660*cdf0e10cSrcweir                 , const Reference< XContentIdentifierMapping > &
661*cdf0e10cSrcweir 					xContentIdentifierMapping )
662*cdf0e10cSrcweir 				: ContentResultSetWrapper( xOrigin )
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir                 , m_xSMgr( xSMgr )
665*cdf0e10cSrcweir 				, m_xFetchProvider( NULL )
666*cdf0e10cSrcweir 				, m_xFetchProviderForContentAccess( NULL )
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 				, m_xMyPropertySetInfo( NULL )
669*cdf0e10cSrcweir 				, m_pMyPropSetInfo( NULL )
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 				, m_xContentIdentifierMapping( xContentIdentifierMapping )
672*cdf0e10cSrcweir 				, m_nRow( 0 ) // Position is one-based. Zero means: before first element.
673*cdf0e10cSrcweir 				, m_bAfterLast( sal_False )
674*cdf0e10cSrcweir 				, m_nLastAppliedPos( 0 )
675*cdf0e10cSrcweir 				, m_bAfterLastApplied( sal_False )
676*cdf0e10cSrcweir 				, m_nKnownCount( 0 )
677*cdf0e10cSrcweir 				, m_bFinalCount( sal_False )
678*cdf0e10cSrcweir 				, m_nFetchSize(
679*cdf0e10cSrcweir 					COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE )
680*cdf0e10cSrcweir 				, m_nFetchDirection(
681*cdf0e10cSrcweir 					COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION )
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 				, m_bLastReadWasFromCache( sal_False )
684*cdf0e10cSrcweir 				, m_bLastCachedReadWasNull( sal_True )
685*cdf0e10cSrcweir 				, m_aCache( m_xContentIdentifierMapping )
686*cdf0e10cSrcweir 				, m_aCacheContentIdentifierString( m_xContentIdentifierMapping )
687*cdf0e10cSrcweir 				, m_aCacheContentIdentifier( m_xContentIdentifierMapping )
688*cdf0e10cSrcweir 				, m_aCacheContent( m_xContentIdentifierMapping )
689*cdf0e10cSrcweir                 , m_bTriedToGetTypeConverter( sal_False )
690*cdf0e10cSrcweir                 , m_xTypeConverter( NULL )
691*cdf0e10cSrcweir {
692*cdf0e10cSrcweir 	m_xFetchProvider = Reference< XFetchProvider >( m_xResultSetOrigin, UNO_QUERY );
693*cdf0e10cSrcweir 	OSL_ENSURE( m_xFetchProvider.is(), "interface XFetchProvider is required" );
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir 	m_xFetchProviderForContentAccess = Reference< XFetchProviderForContentAccess >( m_xResultSetOrigin, UNO_QUERY );
696*cdf0e10cSrcweir 	OSL_ENSURE( m_xFetchProviderForContentAccess.is(), "interface XFetchProviderForContentAccess is required" );
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	impl_init();
699*cdf0e10cSrcweir };
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir CachedContentResultSet::~CachedContentResultSet()
702*cdf0e10cSrcweir {
703*cdf0e10cSrcweir 	impl_deinit();
704*cdf0e10cSrcweir 	//do not delete m_pMyPropSetInfo, cause it is hold via reference
705*cdf0e10cSrcweir };
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir //--------------------------------------------------------------------------
708*cdf0e10cSrcweir // impl_ methods.
709*cdf0e10cSrcweir //--------------------------------------------------------------------------
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
712*cdf0e10cSrcweir 	::applyPositionToOrigin( sal_Int32 nRow )
713*cdf0e10cSrcweir 	throw( SQLException,
714*cdf0e10cSrcweir 		   RuntimeException )
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
717*cdf0e10cSrcweir 	//-------------------------------------------------------------------------
718*cdf0e10cSrcweir     /**
719*cdf0e10cSrcweir 	@returns
720*cdf0e10cSrcweir 		<TRUE/> if the cursor is on a valid row; <FALSE/> if it is off
721*cdf0e10cSrcweir 		the result set.
722*cdf0e10cSrcweir 	*/
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
725*cdf0e10cSrcweir 	OSL_ENSURE( nRow >= 0, "only positive values supported" );
726*cdf0e10cSrcweir 	if( !m_xResultSetOrigin.is() )
727*cdf0e10cSrcweir 	{
728*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
729*cdf0e10cSrcweir 		return sal_False;
730*cdf0e10cSrcweir 	}
731*cdf0e10cSrcweir //	OSL_ENSURE( nRow <= m_nKnownCount, "don't step into regions you don't know with this method" );
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir 	sal_Int32 nLastAppliedPos = m_nLastAppliedPos;
734*cdf0e10cSrcweir 	sal_Bool bAfterLastApplied = m_bAfterLastApplied;
735*cdf0e10cSrcweir 	sal_Bool bAfterLast = m_bAfterLast;
736*cdf0e10cSrcweir 	sal_Int32 nForwardOnly = m_nForwardOnly;
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir 	aGuard.clear();
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir 	if( bAfterLastApplied || nLastAppliedPos != nRow )
741*cdf0e10cSrcweir 	{
742*cdf0e10cSrcweir 		if( nForwardOnly == 1 )
743*cdf0e10cSrcweir 		{
744*cdf0e10cSrcweir 			if( bAfterLastApplied || bAfterLast || !nRow || nRow < nLastAppliedPos )
745*cdf0e10cSrcweir 				throw SQLException();
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir 			sal_Int32 nN = nRow - nLastAppliedPos;
748*cdf0e10cSrcweir 			sal_Int32 nM;
749*cdf0e10cSrcweir 			for( nM = 0; nN--; nM++ )
750*cdf0e10cSrcweir 			{
751*cdf0e10cSrcweir 				if( !m_xResultSetOrigin->next() )
752*cdf0e10cSrcweir 					break;
753*cdf0e10cSrcweir 			}
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 			aGuard.reacquire();
756*cdf0e10cSrcweir 			m_nLastAppliedPos += nM;
757*cdf0e10cSrcweir 			m_bAfterLastApplied = nRow != m_nLastAppliedPos;
758*cdf0e10cSrcweir 			return nRow == m_nLastAppliedPos;
759*cdf0e10cSrcweir 		}
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 		if( !nRow ) //absolute( 0 ) will throw exception
762*cdf0e10cSrcweir 		{
763*cdf0e10cSrcweir 			m_xResultSetOrigin->beforeFirst();
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir 			aGuard.reacquire();
766*cdf0e10cSrcweir 			m_nLastAppliedPos = 0;
767*cdf0e10cSrcweir 			m_bAfterLastApplied = sal_False;
768*cdf0e10cSrcweir 			return sal_False;
769*cdf0e10cSrcweir 		}
770*cdf0e10cSrcweir 		try
771*cdf0e10cSrcweir 		{
772*cdf0e10cSrcweir 			//move absolute, if !nLastAppliedPos
773*cdf0e10cSrcweir 			//because move relative would throw exception
774*cdf0e10cSrcweir 			if( !nLastAppliedPos || bAfterLast || bAfterLastApplied )
775*cdf0e10cSrcweir 			{
776*cdf0e10cSrcweir 				sal_Bool bValid = m_xResultSetOrigin->absolute( nRow );
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir 				aGuard.reacquire();
779*cdf0e10cSrcweir 				m_nLastAppliedPos = nRow;
780*cdf0e10cSrcweir 				m_bAfterLastApplied = !bValid;
781*cdf0e10cSrcweir 				return bValid;
782*cdf0e10cSrcweir 			}
783*cdf0e10cSrcweir 			else
784*cdf0e10cSrcweir 			{
785*cdf0e10cSrcweir 				sal_Bool bValid = m_xResultSetOrigin->relative( nRow - nLastAppliedPos );
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 				aGuard.reacquire();
788*cdf0e10cSrcweir 				m_nLastAppliedPos += ( nRow - nLastAppliedPos );
789*cdf0e10cSrcweir 				m_bAfterLastApplied = !bValid;
790*cdf0e10cSrcweir 				return bValid;
791*cdf0e10cSrcweir 			}
792*cdf0e10cSrcweir 		}
793*cdf0e10cSrcweir 		catch( SQLException& rEx )
794*cdf0e10cSrcweir 		{
795*cdf0e10cSrcweir 			if( !bAfterLastApplied && !bAfterLast && nRow > nLastAppliedPos && impl_isForwardOnly() )
796*cdf0e10cSrcweir 			{
797*cdf0e10cSrcweir 				sal_Int32 nN = nRow - nLastAppliedPos;
798*cdf0e10cSrcweir 				sal_Int32 nM;
799*cdf0e10cSrcweir 				for( nM = 0; nN--; nM++ )
800*cdf0e10cSrcweir 				{
801*cdf0e10cSrcweir 					if( !m_xResultSetOrigin->next() )
802*cdf0e10cSrcweir 						break;
803*cdf0e10cSrcweir 				}
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir 				aGuard.reacquire();
806*cdf0e10cSrcweir 				m_nLastAppliedPos += nM;
807*cdf0e10cSrcweir 				m_bAfterLastApplied = nRow != m_nLastAppliedPos;
808*cdf0e10cSrcweir 			}
809*cdf0e10cSrcweir 			else
810*cdf0e10cSrcweir 				throw rEx;
811*cdf0e10cSrcweir 		}
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir 		return nRow == m_nLastAppliedPos;
814*cdf0e10cSrcweir 	}
815*cdf0e10cSrcweir     return sal_True;
816*cdf0e10cSrcweir };
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir //--------------------------------------------------------------------------
819*cdf0e10cSrcweir //--------------------------------------------------------------------------
820*cdf0e10cSrcweir //define for fetching data
821*cdf0e10cSrcweir //--------------------------------------------------------------------------
822*cdf0e10cSrcweir //--------------------------------------------------------------------------
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir #define FETCH_XXX( aCache, fetchInterface, fetchMethod )			\
825*cdf0e10cSrcweir sal_Bool bDirection = !!(											\
826*cdf0e10cSrcweir 	nFetchDirection != FetchDirection::REVERSE );					\
827*cdf0e10cSrcweir FetchResult aResult =												\
828*cdf0e10cSrcweir 	fetchInterface->fetchMethod( nRow, nFetchSize, bDirection );	\
829*cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard2( m_aMutex );				\
830*cdf0e10cSrcweir aCache.loadData( aResult );											\
831*cdf0e10cSrcweir sal_Int32 nMax = aCache.getMaxRow();								\
832*cdf0e10cSrcweir sal_Int32 nCurCount = m_nKnownCount;								\
833*cdf0e10cSrcweir sal_Bool bIsFinalCount = aCache.hasKnownLast();						\
834*cdf0e10cSrcweir sal_Bool bCurIsFinalCount = m_bFinalCount;							\
835*cdf0e10cSrcweir aGuard2.clear();													\
836*cdf0e10cSrcweir if( nMax > nCurCount )												\
837*cdf0e10cSrcweir 	impl_changeRowCount( nCurCount, nMax );							\
838*cdf0e10cSrcweir if( bIsFinalCount && !bCurIsFinalCount )							\
839*cdf0e10cSrcweir 	impl_changeIsRowCountFinal( bCurIsFinalCount, bIsFinalCount );
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
842*cdf0e10cSrcweir 	::impl_fetchData( sal_Int32 nRow
843*cdf0e10cSrcweir 		, sal_Int32 nFetchSize, sal_Int32 nFetchDirection )
844*cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException )
845*cdf0e10cSrcweir {
846*cdf0e10cSrcweir 	FETCH_XXX( m_aCache, m_xFetchProvider, fetch );
847*cdf0e10cSrcweir }
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
850*cdf0e10cSrcweir 	::impl_changeRowCount( sal_Int32 nOld, sal_Int32 nNew )
851*cdf0e10cSrcweir {
852*cdf0e10cSrcweir 	OSL_ENSURE( nNew > nOld, "RowCount only can grow" );
853*cdf0e10cSrcweir 	if( nNew <= nOld )
854*cdf0e10cSrcweir 		return;
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 	//create PropertyChangeEvent and set value
857*cdf0e10cSrcweir 	PropertyChangeEvent aEvt;
858*cdf0e10cSrcweir 	{
859*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
860*cdf0e10cSrcweir 		aEvt.Source =  static_cast< XPropertySet * >( this );
861*cdf0e10cSrcweir 		aEvt.Further = sal_False;
862*cdf0e10cSrcweir 		aEvt.OldValue <<= nOld;
863*cdf0e10cSrcweir 		aEvt.NewValue <<= nNew;
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 		m_nKnownCount = nNew;
866*cdf0e10cSrcweir 	}
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir 	//send PropertyChangeEvent to listeners
869*cdf0e10cSrcweir 	impl_notifyPropertyChangeListeners( aEvt );
870*cdf0e10cSrcweir }
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
873*cdf0e10cSrcweir 	::impl_changeIsRowCountFinal( sal_Bool bOld, sal_Bool bNew )
874*cdf0e10cSrcweir {
875*cdf0e10cSrcweir 	OSL_ENSURE( !bOld && bNew, "This change is not allowed for IsRowCountFinal" );
876*cdf0e10cSrcweir 	if( ! (!bOld && bNew ) )
877*cdf0e10cSrcweir 		return;
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir 	//create PropertyChangeEvent and set value
880*cdf0e10cSrcweir 	PropertyChangeEvent aEvt;
881*cdf0e10cSrcweir 	{
882*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
883*cdf0e10cSrcweir 		aEvt.Source =  static_cast< XPropertySet * >( this );
884*cdf0e10cSrcweir 		aEvt.Further = sal_False;
885*cdf0e10cSrcweir 		aEvt.OldValue <<= bOld;
886*cdf0e10cSrcweir 		aEvt.NewValue <<= bNew;
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir 		m_bFinalCount = bNew;
889*cdf0e10cSrcweir 	}
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir 	//send PropertyChangeEvent to listeners
892*cdf0e10cSrcweir 	impl_notifyPropertyChangeListeners( aEvt );
893*cdf0e10cSrcweir }
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
896*cdf0e10cSrcweir 	::impl_isKnownValidPosition( sal_Int32 nRow )
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir 	return m_nKnownCount && nRow
899*cdf0e10cSrcweir 			&& nRow <= m_nKnownCount;
900*cdf0e10cSrcweir }
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
903*cdf0e10cSrcweir 	::impl_isKnownInvalidPosition( sal_Int32 nRow )
904*cdf0e10cSrcweir {
905*cdf0e10cSrcweir 	if( !nRow )
906*cdf0e10cSrcweir 		return sal_True;
907*cdf0e10cSrcweir 	if( !m_bFinalCount )
908*cdf0e10cSrcweir 		return sal_False;
909*cdf0e10cSrcweir 	return nRow > m_nKnownCount;
910*cdf0e10cSrcweir }
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir //virtual
914*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
915*cdf0e10cSrcweir 	::impl_initPropertySetInfo()
916*cdf0e10cSrcweir {
917*cdf0e10cSrcweir 	ContentResultSetWrapper::impl_initPropertySetInfo();
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
920*cdf0e10cSrcweir 	if( m_pMyPropSetInfo )
921*cdf0e10cSrcweir 		return;
922*cdf0e10cSrcweir 	m_pMyPropSetInfo = new CCRS_PropertySetInfo( m_xPropertySetInfo );
923*cdf0e10cSrcweir 	m_xMyPropertySetInfo = m_pMyPropSetInfo;
924*cdf0e10cSrcweir 	m_xPropertySetInfo = m_xMyPropertySetInfo;
925*cdf0e10cSrcweir }
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir //--------------------------------------------------------------------------
928*cdf0e10cSrcweir // XInterface methods. ( inherited )
929*cdf0e10cSrcweir //--------------------------------------------------------------------------
930*cdf0e10cSrcweir XINTERFACE_COMMON_IMPL( CachedContentResultSet )
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir Any SAL_CALL CachedContentResultSet
933*cdf0e10cSrcweir 	::queryInterface( const Type&  rType )
934*cdf0e10cSrcweir 	throw ( RuntimeException )
935*cdf0e10cSrcweir {
936*cdf0e10cSrcweir 	//list all interfaces inclusive baseclasses of interfaces
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir 	Any aRet = ContentResultSetWrapper::queryInterface( rType );
939*cdf0e10cSrcweir 	if( aRet.hasValue() )
940*cdf0e10cSrcweir 		return aRet;
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir 	aRet = cppu::queryInterface( rType,
943*cdf0e10cSrcweir 				static_cast< XTypeProvider* >( this ),
944*cdf0e10cSrcweir 				static_cast< XServiceInfo* >( this ) );
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
947*cdf0e10cSrcweir }
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir //--------------------------------------------------------------------------
950*cdf0e10cSrcweir // XTypeProvider methods.
951*cdf0e10cSrcweir //--------------------------------------------------------------------------
952*cdf0e10cSrcweir //list all interfaces exclusive baseclasses
953*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_11( CachedContentResultSet
954*cdf0e10cSrcweir 					, XTypeProvider
955*cdf0e10cSrcweir 					, XServiceInfo
956*cdf0e10cSrcweir 					, XComponent
957*cdf0e10cSrcweir 					, XCloseable
958*cdf0e10cSrcweir 					, XResultSetMetaDataSupplier
959*cdf0e10cSrcweir 					, XPropertySet
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir 					, XPropertyChangeListener
962*cdf0e10cSrcweir 					, XVetoableChangeListener
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir 					, XContentAccess
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir 					, XResultSet
967*cdf0e10cSrcweir 					, XRow );
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir //--------------------------------------------------------------------------
970*cdf0e10cSrcweir // XServiceInfo methods.
971*cdf0e10cSrcweir //--------------------------------------------------------------------------
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir XSERVICEINFO_NOFACTORY_IMPL_1( CachedContentResultSet,
974*cdf0e10cSrcweir 		 		   		   OUString::createFromAscii(
975*cdf0e10cSrcweir 							"com.sun.star.comp.ucb.CachedContentResultSet" ),
976*cdf0e10cSrcweir 					 	   OUString::createFromAscii(
977*cdf0e10cSrcweir 							CACHED_CONTENT_RESULTSET_SERVICE_NAME ) );
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir //--------------------------------------------------------------------------
980*cdf0e10cSrcweir // XPropertySet methods. ( inherited )
981*cdf0e10cSrcweir //--------------------------------------------------------------------------
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir // virtual
984*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
985*cdf0e10cSrcweir 	::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
986*cdf0e10cSrcweir 	throw( UnknownPropertyException,
987*cdf0e10cSrcweir 		   PropertyVetoException,
988*cdf0e10cSrcweir 		   IllegalArgumentException,
989*cdf0e10cSrcweir 		   WrappedTargetException,
990*cdf0e10cSrcweir 		   RuntimeException )
991*cdf0e10cSrcweir {
992*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir 	if( !getPropertySetInfo().is() )
995*cdf0e10cSrcweir 	{
996*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
997*cdf0e10cSrcweir 		throw UnknownPropertyException();
998*cdf0e10cSrcweir 	}
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir 	Property aProp = m_pMyPropSetInfo->getPropertyByName( aPropertyName );
1001*cdf0e10cSrcweir 		//throws UnknownPropertyException, if so
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir 	if( aProp.Attributes & PropertyAttribute::READONLY )
1004*cdf0e10cSrcweir 	{
1005*cdf0e10cSrcweir 		//It is assumed, that the properties
1006*cdf0e10cSrcweir 		//'RowCount' and 'IsRowCountFinal' are readonly!
1007*cdf0e10cSrcweir 		throw IllegalArgumentException();
1008*cdf0e10cSrcweir 	}
1009*cdf0e10cSrcweir 	if( aProp.Name == CCRS_PropertySetInfo
1010*cdf0e10cSrcweir 						::m_aPropertyNameForFetchDirection )
1011*cdf0e10cSrcweir 	{
1012*cdf0e10cSrcweir 		//check value
1013*cdf0e10cSrcweir 		sal_Int32 nNew;
1014*cdf0e10cSrcweir 		if( !( aValue >>= nNew ) )
1015*cdf0e10cSrcweir 		{
1016*cdf0e10cSrcweir 			throw IllegalArgumentException();
1017*cdf0e10cSrcweir 		}
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir 		if( nNew == FetchDirection::UNKNOWN )
1020*cdf0e10cSrcweir 		{
1021*cdf0e10cSrcweir 			nNew = COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION;
1022*cdf0e10cSrcweir 		}
1023*cdf0e10cSrcweir 		else if( !(	nNew == FetchDirection::FORWARD
1024*cdf0e10cSrcweir 				|| nNew == FetchDirection::REVERSE ) )
1025*cdf0e10cSrcweir 		{
1026*cdf0e10cSrcweir 			throw IllegalArgumentException();
1027*cdf0e10cSrcweir 		}
1028*cdf0e10cSrcweir 
1029*cdf0e10cSrcweir 		//create PropertyChangeEvent and set value
1030*cdf0e10cSrcweir 		PropertyChangeEvent aEvt;
1031*cdf0e10cSrcweir 		{
1032*cdf0e10cSrcweir 			osl::Guard< osl::Mutex > aGuard( m_aMutex );
1033*cdf0e10cSrcweir 			aEvt.Source =  static_cast< XPropertySet * >( this );
1034*cdf0e10cSrcweir 			aEvt.PropertyName = aPropertyName;
1035*cdf0e10cSrcweir 			aEvt.Further = sal_False;
1036*cdf0e10cSrcweir 			aEvt.PropertyHandle = m_pMyPropSetInfo->
1037*cdf0e10cSrcweir 									m_nFetchDirectionPropertyHandle;
1038*cdf0e10cSrcweir 			aEvt.OldValue <<= m_nFetchDirection;
1039*cdf0e10cSrcweir 			aEvt.NewValue <<= nNew;
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir 			m_nFetchDirection = nNew;
1042*cdf0e10cSrcweir 		}
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 		//send PropertyChangeEvent to listeners
1045*cdf0e10cSrcweir 		impl_notifyPropertyChangeListeners( aEvt );
1046*cdf0e10cSrcweir 	}
1047*cdf0e10cSrcweir 	else if( aProp.Name == CCRS_PropertySetInfo
1048*cdf0e10cSrcweir 						::m_aPropertyNameForFetchSize )
1049*cdf0e10cSrcweir 	{
1050*cdf0e10cSrcweir 		//check value
1051*cdf0e10cSrcweir 		sal_Int32 nNew;
1052*cdf0e10cSrcweir 		if( !( aValue >>= nNew ) )
1053*cdf0e10cSrcweir 		{
1054*cdf0e10cSrcweir 			throw IllegalArgumentException();
1055*cdf0e10cSrcweir 		}
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir 		if( nNew < 0 )
1058*cdf0e10cSrcweir 		{
1059*cdf0e10cSrcweir 			nNew = COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE;
1060*cdf0e10cSrcweir 		}
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir 		//create PropertyChangeEvent and set value
1063*cdf0e10cSrcweir 		PropertyChangeEvent aEvt;
1064*cdf0e10cSrcweir 		{
1065*cdf0e10cSrcweir 			osl::Guard< osl::Mutex > aGuard( m_aMutex );
1066*cdf0e10cSrcweir 			aEvt.Source =  static_cast< XPropertySet * >( this );
1067*cdf0e10cSrcweir 			aEvt.PropertyName = aPropertyName;
1068*cdf0e10cSrcweir 			aEvt.Further = sal_False;
1069*cdf0e10cSrcweir 			aEvt.PropertyHandle = m_pMyPropSetInfo->
1070*cdf0e10cSrcweir 									m_nFetchSizePropertyHandle;
1071*cdf0e10cSrcweir 			aEvt.OldValue <<= m_nFetchSize;
1072*cdf0e10cSrcweir 			aEvt.NewValue <<= nNew;
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir 			m_nFetchSize = nNew;
1075*cdf0e10cSrcweir 		}
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir 		//send PropertyChangeEvent to listeners
1078*cdf0e10cSrcweir 		impl_notifyPropertyChangeListeners( aEvt );
1079*cdf0e10cSrcweir 	}
1080*cdf0e10cSrcweir 	else
1081*cdf0e10cSrcweir 	{
1082*cdf0e10cSrcweir 		impl_init_xPropertySetOrigin();
1083*cdf0e10cSrcweir 		{
1084*cdf0e10cSrcweir 			osl::Guard< osl::Mutex > aGuard( m_aMutex );
1085*cdf0e10cSrcweir 			if( !m_xPropertySetOrigin.is() )
1086*cdf0e10cSrcweir 			{
1087*cdf0e10cSrcweir 				OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1088*cdf0e10cSrcweir 				return;
1089*cdf0e10cSrcweir 			}
1090*cdf0e10cSrcweir 		}
1091*cdf0e10cSrcweir 		m_xPropertySetOrigin->setPropertyValue( aPropertyName, aValue );
1092*cdf0e10cSrcweir 	}
1093*cdf0e10cSrcweir }
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir //--------------------------------------------------------------------------
1096*cdf0e10cSrcweir // virtual
1097*cdf0e10cSrcweir Any SAL_CALL CachedContentResultSet
1098*cdf0e10cSrcweir 	::getPropertyValue( const OUString& rPropertyName )
1099*cdf0e10cSrcweir 	throw( UnknownPropertyException,
1100*cdf0e10cSrcweir 		   WrappedTargetException,
1101*cdf0e10cSrcweir 		   RuntimeException )
1102*cdf0e10cSrcweir {
1103*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir 	if( !getPropertySetInfo().is() )
1106*cdf0e10cSrcweir 	{
1107*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1108*cdf0e10cSrcweir 		throw UnknownPropertyException();
1109*cdf0e10cSrcweir 	}
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir 	Property aProp = m_pMyPropSetInfo->getPropertyByName( rPropertyName );
1112*cdf0e10cSrcweir 		//throws UnknownPropertyException, if so
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir 	Any aValue;
1115*cdf0e10cSrcweir 	if( rPropertyName == CCRS_PropertySetInfo
1116*cdf0e10cSrcweir 						::m_aPropertyNameForCount )
1117*cdf0e10cSrcweir 	{
1118*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1119*cdf0e10cSrcweir 		aValue <<= m_nKnownCount;
1120*cdf0e10cSrcweir 	}
1121*cdf0e10cSrcweir 	else if( rPropertyName == CCRS_PropertySetInfo
1122*cdf0e10cSrcweir 							::m_aPropertyNameForFinalCount )
1123*cdf0e10cSrcweir 	{
1124*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1125*cdf0e10cSrcweir 		aValue <<= m_bFinalCount;
1126*cdf0e10cSrcweir 	}
1127*cdf0e10cSrcweir 	else if( rPropertyName == CCRS_PropertySetInfo
1128*cdf0e10cSrcweir 							::m_aPropertyNameForFetchSize )
1129*cdf0e10cSrcweir 	{
1130*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1131*cdf0e10cSrcweir 		aValue <<= m_nFetchSize;
1132*cdf0e10cSrcweir 	}
1133*cdf0e10cSrcweir 	else if( rPropertyName == CCRS_PropertySetInfo
1134*cdf0e10cSrcweir 							::m_aPropertyNameForFetchDirection )
1135*cdf0e10cSrcweir 	{
1136*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1137*cdf0e10cSrcweir 		aValue <<= m_nFetchDirection;
1138*cdf0e10cSrcweir 	}
1139*cdf0e10cSrcweir 	else
1140*cdf0e10cSrcweir 	{
1141*cdf0e10cSrcweir 		impl_init_xPropertySetOrigin();
1142*cdf0e10cSrcweir 		{
1143*cdf0e10cSrcweir 			osl::Guard< osl::Mutex > aGuard( m_aMutex );
1144*cdf0e10cSrcweir 			if( !m_xPropertySetOrigin.is() )
1145*cdf0e10cSrcweir 			{
1146*cdf0e10cSrcweir 				OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1147*cdf0e10cSrcweir 				throw UnknownPropertyException();
1148*cdf0e10cSrcweir 			}
1149*cdf0e10cSrcweir 		}
1150*cdf0e10cSrcweir 		aValue = m_xPropertySetOrigin->getPropertyValue( rPropertyName );
1151*cdf0e10cSrcweir 	}
1152*cdf0e10cSrcweir 	return aValue;
1153*cdf0e10cSrcweir }
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir //--------------------------------------------------------------------------
1156*cdf0e10cSrcweir // own methods.  ( inherited )
1157*cdf0e10cSrcweir //--------------------------------------------------------------------------
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir //virtual
1160*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
1161*cdf0e10cSrcweir 	::impl_disposing( const EventObject& rEventObject )
1162*cdf0e10cSrcweir 	throw( RuntimeException )
1163*cdf0e10cSrcweir {
1164*cdf0e10cSrcweir 	{
1165*cdf0e10cSrcweir 		impl_EnsureNotDisposed();
1166*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1167*cdf0e10cSrcweir 		//release all references to the broadcaster:
1168*cdf0e10cSrcweir 		m_xFetchProvider.clear();
1169*cdf0e10cSrcweir 		m_xFetchProviderForContentAccess.clear();
1170*cdf0e10cSrcweir 	}
1171*cdf0e10cSrcweir 	ContentResultSetWrapper::impl_disposing( rEventObject );
1172*cdf0e10cSrcweir }
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir //virtual
1175*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
1176*cdf0e10cSrcweir 	::impl_propertyChange( const PropertyChangeEvent& rEvt )
1177*cdf0e10cSrcweir 	throw( RuntimeException )
1178*cdf0e10cSrcweir {
1179*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir 	PropertyChangeEvent aEvt( rEvt );
1182*cdf0e10cSrcweir 	aEvt.Source = static_cast< XPropertySet * >( this );
1183*cdf0e10cSrcweir 	aEvt.Further = sal_False;
1184*cdf0e10cSrcweir 	//---------
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir 	if( CCRS_PropertySetInfo
1187*cdf0e10cSrcweir 			::impl_isMyPropertyName( rEvt.PropertyName ) )
1188*cdf0e10cSrcweir 	{
1189*cdf0e10cSrcweir 		//don't notify foreign events on fetchsize and fetchdirection
1190*cdf0e10cSrcweir 		if( aEvt.PropertyName == CCRS_PropertySetInfo
1191*cdf0e10cSrcweir 								::m_aPropertyNameForFetchSize
1192*cdf0e10cSrcweir 		|| aEvt.PropertyName == CCRS_PropertySetInfo
1193*cdf0e10cSrcweir 								::m_aPropertyNameForFetchDirection )
1194*cdf0e10cSrcweir 			return;
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir 		//adjust my props 'RowCount' and 'IsRowCountFinal'
1197*cdf0e10cSrcweir 		if( aEvt.PropertyName == CCRS_PropertySetInfo
1198*cdf0e10cSrcweir 							::m_aPropertyNameForCount )
1199*cdf0e10cSrcweir 		{//RowCount changed
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir 			//check value
1202*cdf0e10cSrcweir 			sal_Int32 nNew = 0;
1203*cdf0e10cSrcweir 			if( !( aEvt.NewValue >>= nNew ) )
1204*cdf0e10cSrcweir 			{
1205*cdf0e10cSrcweir 				OSL_ENSURE( sal_False, "PropertyChangeEvent contains wrong data" );
1206*cdf0e10cSrcweir 				return;
1207*cdf0e10cSrcweir 			}
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir 			impl_changeRowCount( m_nKnownCount, nNew );
1210*cdf0e10cSrcweir 		}
1211*cdf0e10cSrcweir 		else if( aEvt.PropertyName == CCRS_PropertySetInfo
1212*cdf0e10cSrcweir 								::m_aPropertyNameForFinalCount )
1213*cdf0e10cSrcweir 		{//IsRowCountFinal changed
1214*cdf0e10cSrcweir 
1215*cdf0e10cSrcweir 			//check value
1216*cdf0e10cSrcweir 			sal_Bool bNew = sal_False;
1217*cdf0e10cSrcweir 			if( !( aEvt.NewValue >>= bNew ) )
1218*cdf0e10cSrcweir 			{
1219*cdf0e10cSrcweir 				OSL_ENSURE( sal_False, "PropertyChangeEvent contains wrong data" );
1220*cdf0e10cSrcweir 				return;
1221*cdf0e10cSrcweir 			}
1222*cdf0e10cSrcweir 			impl_changeIsRowCountFinal( m_bFinalCount, bNew );
1223*cdf0e10cSrcweir 		}
1224*cdf0e10cSrcweir 		return;
1225*cdf0e10cSrcweir 	}
1226*cdf0e10cSrcweir 
1227*cdf0e10cSrcweir 	//-----------
1228*cdf0e10cSrcweir 	impl_notifyPropertyChangeListeners(	aEvt );
1229*cdf0e10cSrcweir }
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir 
1232*cdf0e10cSrcweir //virtual
1233*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
1234*cdf0e10cSrcweir 	::impl_vetoableChange( const PropertyChangeEvent& rEvt )
1235*cdf0e10cSrcweir 	throw( PropertyVetoException,
1236*cdf0e10cSrcweir 		   RuntimeException )
1237*cdf0e10cSrcweir {
1238*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir 	//don't notify events on my properties, cause they are not vetoable
1241*cdf0e10cSrcweir 	if( CCRS_PropertySetInfo
1242*cdf0e10cSrcweir 			::impl_isMyPropertyName( rEvt.PropertyName ) )
1243*cdf0e10cSrcweir 	{
1244*cdf0e10cSrcweir 		return;
1245*cdf0e10cSrcweir 	}
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir 	PropertyChangeEvent aEvt( rEvt );
1249*cdf0e10cSrcweir 	aEvt.Source = static_cast< XPropertySet * >( this );
1250*cdf0e10cSrcweir 	aEvt.Further = sal_False;
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir 	impl_notifyVetoableChangeListeners( aEvt );
1253*cdf0e10cSrcweir }
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir //--------------------------------------------------------------------------
1256*cdf0e10cSrcweir // XContentAccess methods. ( inherited ) ( -- position dependent )
1257*cdf0e10cSrcweir //--------------------------------------------------------------------------
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir #define XCONTENTACCESS_queryXXX( queryXXX, XXX, TYPE )				\
1260*cdf0e10cSrcweir impl_EnsureNotDisposed();									\
1261*cdf0e10cSrcweir ReacquireableGuard aGuard( m_aMutex );						\
1262*cdf0e10cSrcweir sal_Int32 nRow = m_nRow;									\
1263*cdf0e10cSrcweir sal_Int32 nFetchSize = m_nFetchSize;						\
1264*cdf0e10cSrcweir sal_Int32 nFetchDirection = m_nFetchDirection;				\
1265*cdf0e10cSrcweir if( !m_aCache##XXX.hasRow( nRow ) )							\
1266*cdf0e10cSrcweir {															\
1267*cdf0e10cSrcweir 	if( !m_aCache##XXX.hasCausedException( nRow ) )			\
1268*cdf0e10cSrcweir {															\
1269*cdf0e10cSrcweir 		if( !m_xFetchProviderForContentAccess.is() )		\
1270*cdf0e10cSrcweir 		{													\
1271*cdf0e10cSrcweir 			OSL_ENSURE( sal_False, "broadcaster was disposed already" );\
1272*cdf0e10cSrcweir 			throw RuntimeException();						\
1273*cdf0e10cSrcweir 		}													\
1274*cdf0e10cSrcweir 		aGuard.clear();										\
1275*cdf0e10cSrcweir 		if( impl_isForwardOnly() )							\
1276*cdf0e10cSrcweir 			applyPositionToOrigin( nRow );					\
1277*cdf0e10cSrcweir 															\
1278*cdf0e10cSrcweir 		FETCH_XXX( m_aCache##XXX, m_xFetchProviderForContentAccess, fetch##XXX##s ); \
1279*cdf0e10cSrcweir 	}														\
1280*cdf0e10cSrcweir 	aGuard.reacquire();										\
1281*cdf0e10cSrcweir 	if( !m_aCache##XXX.hasRow( nRow ) )						\
1282*cdf0e10cSrcweir 	{														\
1283*cdf0e10cSrcweir 		aGuard.clear();										\
1284*cdf0e10cSrcweir 		applyPositionToOrigin( nRow );						\
1285*cdf0e10cSrcweir 		TYPE aRet = ContentResultSetWrapper::queryXXX();	\
1286*cdf0e10cSrcweir 		if( m_xContentIdentifierMapping.is() )				\
1287*cdf0e10cSrcweir 			return m_xContentIdentifierMapping->map##XXX( aRet );\
1288*cdf0e10cSrcweir 		return aRet;										\
1289*cdf0e10cSrcweir 	}														\
1290*cdf0e10cSrcweir }															\
1291*cdf0e10cSrcweir return m_aCache##XXX.get##XXX( nRow );
1292*cdf0e10cSrcweir 
1293*cdf0e10cSrcweir //--------------------------------------------------------------------------
1294*cdf0e10cSrcweir // virtual
1295*cdf0e10cSrcweir OUString SAL_CALL CachedContentResultSet
1296*cdf0e10cSrcweir 	::queryContentIdentifierString()
1297*cdf0e10cSrcweir 	throw( RuntimeException )
1298*cdf0e10cSrcweir {
1299*cdf0e10cSrcweir 	XCONTENTACCESS_queryXXX( queryContentIdentifierString, ContentIdentifierString, OUString )
1300*cdf0e10cSrcweir }
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir //--------------------------------------------------------------------------
1303*cdf0e10cSrcweir // virtual
1304*cdf0e10cSrcweir Reference< XContentIdentifier > SAL_CALL CachedContentResultSet
1305*cdf0e10cSrcweir 	::queryContentIdentifier()
1306*cdf0e10cSrcweir 	throw( RuntimeException )
1307*cdf0e10cSrcweir {
1308*cdf0e10cSrcweir 	XCONTENTACCESS_queryXXX( queryContentIdentifier, ContentIdentifier, Reference< XContentIdentifier > )
1309*cdf0e10cSrcweir }
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir //--------------------------------------------------------------------------
1312*cdf0e10cSrcweir // virtual
1313*cdf0e10cSrcweir Reference< XContent > SAL_CALL CachedContentResultSet
1314*cdf0e10cSrcweir 	::queryContent()
1315*cdf0e10cSrcweir 	throw( RuntimeException )
1316*cdf0e10cSrcweir {
1317*cdf0e10cSrcweir 	XCONTENTACCESS_queryXXX( queryContent, Content, Reference< XContent > )
1318*cdf0e10cSrcweir }
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir //-----------------------------------------------------------------
1321*cdf0e10cSrcweir // XResultSet methods. ( inherited )
1322*cdf0e10cSrcweir //-----------------------------------------------------------------
1323*cdf0e10cSrcweir //virtual
1324*cdf0e10cSrcweir 
1325*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1326*cdf0e10cSrcweir 	::next()
1327*cdf0e10cSrcweir 	throw( SQLException,
1328*cdf0e10cSrcweir 		   RuntimeException )
1329*cdf0e10cSrcweir {
1330*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1333*cdf0e10cSrcweir 	//after last
1334*cdf0e10cSrcweir 	if( m_bAfterLast )
1335*cdf0e10cSrcweir 		return sal_False;
1336*cdf0e10cSrcweir 	//last
1337*cdf0e10cSrcweir 	aGuard.clear();
1338*cdf0e10cSrcweir 	if( isLast() )
1339*cdf0e10cSrcweir 	{
1340*cdf0e10cSrcweir 		aGuard.reacquire();
1341*cdf0e10cSrcweir 		m_nRow++;
1342*cdf0e10cSrcweir 		m_bAfterLast = sal_True;
1343*cdf0e10cSrcweir 		return sal_False;
1344*cdf0e10cSrcweir 	}
1345*cdf0e10cSrcweir 	aGuard.reacquire();
1346*cdf0e10cSrcweir 	//known valid position
1347*cdf0e10cSrcweir 	if( impl_isKnownValidPosition( m_nRow + 1 ) )
1348*cdf0e10cSrcweir 	{
1349*cdf0e10cSrcweir 		m_nRow++;
1350*cdf0e10cSrcweir 		return sal_True;
1351*cdf0e10cSrcweir 	}
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir 	//unknown position
1354*cdf0e10cSrcweir 	sal_Int32 nRow = m_nRow;
1355*cdf0e10cSrcweir 	aGuard.clear();
1356*cdf0e10cSrcweir 
1357*cdf0e10cSrcweir 	sal_Bool bValid = applyPositionToOrigin( nRow + 1 );
1358*cdf0e10cSrcweir 
1359*cdf0e10cSrcweir 	aGuard.reacquire();
1360*cdf0e10cSrcweir 	m_nRow = nRow + 1;
1361*cdf0e10cSrcweir 	m_bAfterLast = !bValid;
1362*cdf0e10cSrcweir 	return bValid;
1363*cdf0e10cSrcweir }
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir //virtual
1366*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1367*cdf0e10cSrcweir 	::previous()
1368*cdf0e10cSrcweir 	throw( SQLException,
1369*cdf0e10cSrcweir 		   RuntimeException )
1370*cdf0e10cSrcweir {
1371*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1372*cdf0e10cSrcweir 
1373*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1374*cdf0e10cSrcweir 		throw SQLException();
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1377*cdf0e10cSrcweir 	//before first ?:
1378*cdf0e10cSrcweir 	if( !m_bAfterLast && !m_nRow )
1379*cdf0e10cSrcweir 		return sal_False;
1380*cdf0e10cSrcweir 	//first ?:
1381*cdf0e10cSrcweir 	if( !m_bAfterLast && m_nKnownCount && m_nRow == 1 )
1382*cdf0e10cSrcweir 	{
1383*cdf0e10cSrcweir 		m_nRow--;
1384*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1385*cdf0e10cSrcweir 		return sal_False;
1386*cdf0e10cSrcweir 	}
1387*cdf0e10cSrcweir 	//known valid position ?:
1388*cdf0e10cSrcweir 	if( impl_isKnownValidPosition( m_nRow - 1 ) )
1389*cdf0e10cSrcweir 	{
1390*cdf0e10cSrcweir 		m_nRow--;
1391*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1392*cdf0e10cSrcweir 		return sal_True;
1393*cdf0e10cSrcweir 	}
1394*cdf0e10cSrcweir 	//unknown position:
1395*cdf0e10cSrcweir 	sal_Int32 nRow = m_nRow;
1396*cdf0e10cSrcweir 	aGuard.clear();
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir 	sal_Bool bValid = applyPositionToOrigin( nRow - 1  );
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir 	aGuard.reacquire();
1401*cdf0e10cSrcweir 	m_nRow = nRow - 1;
1402*cdf0e10cSrcweir 	m_bAfterLast = sal_False;
1403*cdf0e10cSrcweir 	return bValid;
1404*cdf0e10cSrcweir }
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir //virtual
1407*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1408*cdf0e10cSrcweir 	::absolute( sal_Int32 row )
1409*cdf0e10cSrcweir 	throw( SQLException,
1410*cdf0e10cSrcweir 		   RuntimeException )
1411*cdf0e10cSrcweir {
1412*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir 	if( !row )
1415*cdf0e10cSrcweir 		throw SQLException();
1416*cdf0e10cSrcweir 
1417*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1418*cdf0e10cSrcweir 		throw SQLException();
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir 	if( !m_xResultSetOrigin.is() )
1423*cdf0e10cSrcweir 	{
1424*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1425*cdf0e10cSrcweir 		return sal_False;
1426*cdf0e10cSrcweir 	}
1427*cdf0e10cSrcweir 	if( row < 0 )
1428*cdf0e10cSrcweir 	{
1429*cdf0e10cSrcweir 		if( m_bFinalCount )
1430*cdf0e10cSrcweir 		{
1431*cdf0e10cSrcweir 			sal_Int32 nNewRow = m_nKnownCount + 1 + row;
1432*cdf0e10cSrcweir 			sal_Bool bValid = sal_True;
1433*cdf0e10cSrcweir 			if( nNewRow <= 0 )
1434*cdf0e10cSrcweir 			{
1435*cdf0e10cSrcweir 				nNewRow = 0;
1436*cdf0e10cSrcweir 				bValid = sal_False;
1437*cdf0e10cSrcweir 			}
1438*cdf0e10cSrcweir 			m_nRow = nNewRow;
1439*cdf0e10cSrcweir 			m_bAfterLast = sal_False;
1440*cdf0e10cSrcweir 			return bValid;
1441*cdf0e10cSrcweir 		}
1442*cdf0e10cSrcweir 		//unknown final count:
1443*cdf0e10cSrcweir 		aGuard.clear();
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir 		// Solaris has problems catching or propagating derived exceptions
1446*cdf0e10cSrcweir 		// when only the base class is known, so make ResultSetException
1447*cdf0e10cSrcweir 		// (derived from SQLException) known here:
1448*cdf0e10cSrcweir 		sal_Bool bValid;
1449*cdf0e10cSrcweir 		try
1450*cdf0e10cSrcweir 		{
1451*cdf0e10cSrcweir 			bValid = m_xResultSetOrigin->absolute( row );
1452*cdf0e10cSrcweir 		}
1453*cdf0e10cSrcweir 		catch (ResultSetException &)
1454*cdf0e10cSrcweir 		{
1455*cdf0e10cSrcweir 			throw;
1456*cdf0e10cSrcweir 		}
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir 		aGuard.reacquire();
1459*cdf0e10cSrcweir 		if( m_bFinalCount )
1460*cdf0e10cSrcweir 		{
1461*cdf0e10cSrcweir 			sal_Int32 nNewRow = m_nKnownCount + 1 + row;
1462*cdf0e10cSrcweir 			if( nNewRow < 0 )
1463*cdf0e10cSrcweir 				nNewRow = 0;
1464*cdf0e10cSrcweir 			m_nLastAppliedPos = nNewRow;
1465*cdf0e10cSrcweir 			m_nRow = nNewRow;
1466*cdf0e10cSrcweir 			m_bAfterLastApplied = m_bAfterLast = sal_False;
1467*cdf0e10cSrcweir 			return bValid;
1468*cdf0e10cSrcweir 		}
1469*cdf0e10cSrcweir 		aGuard.clear();
1470*cdf0e10cSrcweir 
1471*cdf0e10cSrcweir 		sal_Int32 nCurRow = m_xResultSetOrigin->getRow();
1472*cdf0e10cSrcweir 
1473*cdf0e10cSrcweir 		aGuard.reacquire();
1474*cdf0e10cSrcweir 		m_nLastAppliedPos = nCurRow;
1475*cdf0e10cSrcweir 		m_nRow = nCurRow;
1476*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1477*cdf0e10cSrcweir 		return nCurRow != 0;
1478*cdf0e10cSrcweir 	}
1479*cdf0e10cSrcweir 	//row > 0:
1480*cdf0e10cSrcweir 	if( m_bFinalCount )
1481*cdf0e10cSrcweir 	{
1482*cdf0e10cSrcweir 		if( row > m_nKnownCount )
1483*cdf0e10cSrcweir 		{
1484*cdf0e10cSrcweir 			m_nRow = m_nKnownCount + 1;
1485*cdf0e10cSrcweir 			m_bAfterLast = sal_True;
1486*cdf0e10cSrcweir 			return sal_False;
1487*cdf0e10cSrcweir 		}
1488*cdf0e10cSrcweir 		m_nRow = row;
1489*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1490*cdf0e10cSrcweir 		return sal_True;
1491*cdf0e10cSrcweir 	}
1492*cdf0e10cSrcweir 	//unknown new position:
1493*cdf0e10cSrcweir 	aGuard.clear();
1494*cdf0e10cSrcweir 
1495*cdf0e10cSrcweir 	sal_Bool bValid = m_xResultSetOrigin->absolute( row );
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir 	aGuard.reacquire();
1498*cdf0e10cSrcweir 	if( m_bFinalCount )
1499*cdf0e10cSrcweir 	{
1500*cdf0e10cSrcweir 		sal_Int32 nNewRow = row;
1501*cdf0e10cSrcweir 		if( nNewRow > m_nKnownCount )
1502*cdf0e10cSrcweir 		{
1503*cdf0e10cSrcweir 			nNewRow = m_nKnownCount + 1;
1504*cdf0e10cSrcweir 			m_bAfterLastApplied = m_bAfterLast = sal_True;
1505*cdf0e10cSrcweir 		}
1506*cdf0e10cSrcweir 		else
1507*cdf0e10cSrcweir 			m_bAfterLastApplied = m_bAfterLast = sal_False;
1508*cdf0e10cSrcweir 
1509*cdf0e10cSrcweir 		m_nLastAppliedPos = nNewRow;
1510*cdf0e10cSrcweir 		m_nRow = nNewRow;
1511*cdf0e10cSrcweir 		return bValid;
1512*cdf0e10cSrcweir 	}
1513*cdf0e10cSrcweir 	aGuard.clear();
1514*cdf0e10cSrcweir 
1515*cdf0e10cSrcweir 	sal_Int32 nCurRow = m_xResultSetOrigin->getRow();
1516*cdf0e10cSrcweir 	sal_Bool bIsAfterLast = m_xResultSetOrigin->isAfterLast();
1517*cdf0e10cSrcweir 
1518*cdf0e10cSrcweir 	aGuard.reacquire();
1519*cdf0e10cSrcweir 	m_nLastAppliedPos = nCurRow;
1520*cdf0e10cSrcweir 	m_nRow = nCurRow;
1521*cdf0e10cSrcweir 	m_bAfterLastApplied = m_bAfterLast = bIsAfterLast;
1522*cdf0e10cSrcweir 	return nCurRow && !bIsAfterLast;
1523*cdf0e10cSrcweir }
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir //virtual
1526*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1527*cdf0e10cSrcweir 	::relative( sal_Int32 rows )
1528*cdf0e10cSrcweir 	throw( SQLException,
1529*cdf0e10cSrcweir 		   RuntimeException )
1530*cdf0e10cSrcweir {
1531*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1532*cdf0e10cSrcweir 
1533*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1534*cdf0e10cSrcweir 		throw SQLException();
1535*cdf0e10cSrcweir 
1536*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1537*cdf0e10cSrcweir 	if( m_bAfterLast || impl_isKnownInvalidPosition( m_nRow ) )
1538*cdf0e10cSrcweir 		throw SQLException();
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir 	if( !rows )
1541*cdf0e10cSrcweir 		return sal_True;
1542*cdf0e10cSrcweir 
1543*cdf0e10cSrcweir 	sal_Int32 nNewRow = m_nRow + rows;
1544*cdf0e10cSrcweir 		if( nNewRow < 0 )
1545*cdf0e10cSrcweir 			nNewRow = 0;
1546*cdf0e10cSrcweir 
1547*cdf0e10cSrcweir 	if( impl_isKnownValidPosition( nNewRow ) )
1548*cdf0e10cSrcweir 	{
1549*cdf0e10cSrcweir 		m_nRow = nNewRow;
1550*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1551*cdf0e10cSrcweir 		return sal_True;
1552*cdf0e10cSrcweir 	}
1553*cdf0e10cSrcweir 	else
1554*cdf0e10cSrcweir 	{
1555*cdf0e10cSrcweir 		//known invalid new position:
1556*cdf0e10cSrcweir 		if( nNewRow == 0 )
1557*cdf0e10cSrcweir 		{
1558*cdf0e10cSrcweir 			m_bAfterLast = sal_False;
1559*cdf0e10cSrcweir 			m_nRow = 0;
1560*cdf0e10cSrcweir 			return sal_False;
1561*cdf0e10cSrcweir 		}
1562*cdf0e10cSrcweir 		if( m_bFinalCount && nNewRow > m_nKnownCount )
1563*cdf0e10cSrcweir 		{
1564*cdf0e10cSrcweir 			m_bAfterLast = sal_True;
1565*cdf0e10cSrcweir 			m_nRow = m_nKnownCount + 1;
1566*cdf0e10cSrcweir 			return sal_False;
1567*cdf0e10cSrcweir 		}
1568*cdf0e10cSrcweir 		//unknown new position:
1569*cdf0e10cSrcweir 		aGuard.clear();
1570*cdf0e10cSrcweir 		sal_Bool bValid = applyPositionToOrigin( nNewRow );
1571*cdf0e10cSrcweir 
1572*cdf0e10cSrcweir 		aGuard.reacquire();
1573*cdf0e10cSrcweir 		m_nRow = nNewRow;
1574*cdf0e10cSrcweir 		m_bAfterLast = !bValid && nNewRow > 0;
1575*cdf0e10cSrcweir 		return bValid;
1576*cdf0e10cSrcweir 	}
1577*cdf0e10cSrcweir }
1578*cdf0e10cSrcweir 
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir //virtual
1581*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1582*cdf0e10cSrcweir 	::first()
1583*cdf0e10cSrcweir 	throw( SQLException,
1584*cdf0e10cSrcweir 		   RuntimeException )
1585*cdf0e10cSrcweir {
1586*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1589*cdf0e10cSrcweir 		throw SQLException();
1590*cdf0e10cSrcweir 
1591*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1592*cdf0e10cSrcweir 	if( impl_isKnownValidPosition( 1 ) )
1593*cdf0e10cSrcweir 	{
1594*cdf0e10cSrcweir 		m_nRow = 1;
1595*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1596*cdf0e10cSrcweir 		return sal_True;
1597*cdf0e10cSrcweir 	}
1598*cdf0e10cSrcweir 	if( impl_isKnownInvalidPosition( 1 ) )
1599*cdf0e10cSrcweir 	{
1600*cdf0e10cSrcweir 		m_nRow = 1;
1601*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1602*cdf0e10cSrcweir 		return sal_False;
1603*cdf0e10cSrcweir 	}
1604*cdf0e10cSrcweir 	//unknown position
1605*cdf0e10cSrcweir 	aGuard.clear();
1606*cdf0e10cSrcweir 
1607*cdf0e10cSrcweir 	sal_Bool bValid = applyPositionToOrigin( 1 );
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir 	aGuard.reacquire();
1610*cdf0e10cSrcweir 	m_nRow = 1;
1611*cdf0e10cSrcweir 	m_bAfterLast = sal_False;
1612*cdf0e10cSrcweir 	return bValid;
1613*cdf0e10cSrcweir }
1614*cdf0e10cSrcweir 
1615*cdf0e10cSrcweir //virtual
1616*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1617*cdf0e10cSrcweir 	::last()
1618*cdf0e10cSrcweir 	throw( SQLException,
1619*cdf0e10cSrcweir 		   RuntimeException )
1620*cdf0e10cSrcweir {
1621*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1622*cdf0e10cSrcweir 
1623*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1624*cdf0e10cSrcweir 		throw SQLException();
1625*cdf0e10cSrcweir 
1626*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1627*cdf0e10cSrcweir 	if( m_bFinalCount )
1628*cdf0e10cSrcweir 	{
1629*cdf0e10cSrcweir 		m_nRow = m_nKnownCount;
1630*cdf0e10cSrcweir 		m_bAfterLast = sal_False;
1631*cdf0e10cSrcweir 		return m_nKnownCount != 0;
1632*cdf0e10cSrcweir 	}
1633*cdf0e10cSrcweir 	//unknown position
1634*cdf0e10cSrcweir 	if( !m_xResultSetOrigin.is() )
1635*cdf0e10cSrcweir 	{
1636*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1637*cdf0e10cSrcweir 		return sal_False;
1638*cdf0e10cSrcweir 	}
1639*cdf0e10cSrcweir 	aGuard.clear();
1640*cdf0e10cSrcweir 
1641*cdf0e10cSrcweir 	sal_Bool bValid = m_xResultSetOrigin->last();
1642*cdf0e10cSrcweir 
1643*cdf0e10cSrcweir 	aGuard.reacquire();
1644*cdf0e10cSrcweir 	m_bAfterLastApplied = m_bAfterLast = sal_False;
1645*cdf0e10cSrcweir 	if( m_bFinalCount )
1646*cdf0e10cSrcweir 	{
1647*cdf0e10cSrcweir 		m_nLastAppliedPos = m_nKnownCount;
1648*cdf0e10cSrcweir 		m_nRow = m_nKnownCount;
1649*cdf0e10cSrcweir 		return bValid;
1650*cdf0e10cSrcweir 	}
1651*cdf0e10cSrcweir 	aGuard.clear();
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir 	sal_Int32 nCurRow = m_xResultSetOrigin->getRow();
1654*cdf0e10cSrcweir 
1655*cdf0e10cSrcweir 	aGuard.reacquire();
1656*cdf0e10cSrcweir 	m_nLastAppliedPos = nCurRow;
1657*cdf0e10cSrcweir 	m_nRow = nCurRow;
1658*cdf0e10cSrcweir 	OSL_ENSURE( nCurRow >= m_nKnownCount, "position of last row < known Count, that could not be" );
1659*cdf0e10cSrcweir 	m_nKnownCount = nCurRow;
1660*cdf0e10cSrcweir 	m_bFinalCount = sal_True;
1661*cdf0e10cSrcweir 	return nCurRow != 0;
1662*cdf0e10cSrcweir }
1663*cdf0e10cSrcweir 
1664*cdf0e10cSrcweir //virtual
1665*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
1666*cdf0e10cSrcweir 	::beforeFirst()
1667*cdf0e10cSrcweir 	throw( SQLException,
1668*cdf0e10cSrcweir 		   RuntimeException )
1669*cdf0e10cSrcweir {
1670*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1671*cdf0e10cSrcweir 
1672*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1673*cdf0e10cSrcweir 		throw SQLException();
1674*cdf0e10cSrcweir 
1675*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
1676*cdf0e10cSrcweir 	m_nRow = 0;
1677*cdf0e10cSrcweir 	m_bAfterLast = sal_False;
1678*cdf0e10cSrcweir }
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir //virtual
1681*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
1682*cdf0e10cSrcweir 	::afterLast()
1683*cdf0e10cSrcweir 	throw( SQLException,
1684*cdf0e10cSrcweir 		   RuntimeException )
1685*cdf0e10cSrcweir {
1686*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir 	if( impl_isForwardOnly() )
1689*cdf0e10cSrcweir 		throw SQLException();
1690*cdf0e10cSrcweir 
1691*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
1692*cdf0e10cSrcweir 	m_nRow = 1;
1693*cdf0e10cSrcweir 	m_bAfterLast = sal_True;
1694*cdf0e10cSrcweir }
1695*cdf0e10cSrcweir 
1696*cdf0e10cSrcweir //virtual
1697*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1698*cdf0e10cSrcweir 	::isAfterLast()
1699*cdf0e10cSrcweir 	throw( SQLException,
1700*cdf0e10cSrcweir 		   RuntimeException )
1701*cdf0e10cSrcweir {
1702*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1703*cdf0e10cSrcweir 
1704*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1705*cdf0e10cSrcweir 	if( !m_bAfterLast )
1706*cdf0e10cSrcweir 		return sal_False;
1707*cdf0e10cSrcweir 	if( m_nKnownCount )
1708*cdf0e10cSrcweir 		return m_bAfterLast;
1709*cdf0e10cSrcweir 	if( m_bFinalCount )
1710*cdf0e10cSrcweir 		return sal_False;
1711*cdf0e10cSrcweir 
1712*cdf0e10cSrcweir 	if( !m_xResultSetOrigin.is() )
1713*cdf0e10cSrcweir 	{
1714*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1715*cdf0e10cSrcweir 		return sal_False;
1716*cdf0e10cSrcweir 	}
1717*cdf0e10cSrcweir 	aGuard.clear();
1718*cdf0e10cSrcweir 
1719*cdf0e10cSrcweir 	//find out whethter the original resultset contains rows or not
1720*cdf0e10cSrcweir 	m_xResultSetOrigin->afterLast();
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir 	aGuard.reacquire();
1723*cdf0e10cSrcweir 	m_bAfterLastApplied = sal_True;
1724*cdf0e10cSrcweir 	aGuard.clear();
1725*cdf0e10cSrcweir 
1726*cdf0e10cSrcweir 	return m_xResultSetOrigin->isAfterLast();
1727*cdf0e10cSrcweir }
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir //virtual
1730*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1731*cdf0e10cSrcweir 	::isBeforeFirst()
1732*cdf0e10cSrcweir 	throw( SQLException,
1733*cdf0e10cSrcweir 		   RuntimeException )
1734*cdf0e10cSrcweir {
1735*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1736*cdf0e10cSrcweir 
1737*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
1738*cdf0e10cSrcweir 	if( m_bAfterLast )
1739*cdf0e10cSrcweir 		return sal_False;
1740*cdf0e10cSrcweir 	if( m_nRow )
1741*cdf0e10cSrcweir 		return sal_False;
1742*cdf0e10cSrcweir 	if( m_nKnownCount )
1743*cdf0e10cSrcweir 		return !m_nRow;
1744*cdf0e10cSrcweir 	if( m_bFinalCount )
1745*cdf0e10cSrcweir 		return sal_False;
1746*cdf0e10cSrcweir 
1747*cdf0e10cSrcweir 	if( !m_xResultSetOrigin.is() )
1748*cdf0e10cSrcweir 	{
1749*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1750*cdf0e10cSrcweir 		return sal_False;
1751*cdf0e10cSrcweir 	}
1752*cdf0e10cSrcweir 	aGuard.clear();
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir 	//find out whethter the original resultset contains rows or not
1755*cdf0e10cSrcweir 	m_xResultSetOrigin->beforeFirst();
1756*cdf0e10cSrcweir 
1757*cdf0e10cSrcweir 	aGuard.reacquire();
1758*cdf0e10cSrcweir 	m_bAfterLastApplied = sal_False;
1759*cdf0e10cSrcweir 	m_nLastAppliedPos = 0;
1760*cdf0e10cSrcweir 	aGuard.clear();
1761*cdf0e10cSrcweir 
1762*cdf0e10cSrcweir 	return m_xResultSetOrigin->isBeforeFirst();
1763*cdf0e10cSrcweir }
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir //virtual
1766*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1767*cdf0e10cSrcweir 	::isFirst()
1768*cdf0e10cSrcweir 	throw( SQLException,
1769*cdf0e10cSrcweir 		   RuntimeException )
1770*cdf0e10cSrcweir {
1771*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1772*cdf0e10cSrcweir 
1773*cdf0e10cSrcweir 	sal_Int32 nRow = 0;
1774*cdf0e10cSrcweir 	Reference< XResultSet > xResultSetOrigin;
1775*cdf0e10cSrcweir 
1776*cdf0e10cSrcweir 	{
1777*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1778*cdf0e10cSrcweir 		if( m_bAfterLast )
1779*cdf0e10cSrcweir 			return sal_False;
1780*cdf0e10cSrcweir 		if( m_nRow != 1 )
1781*cdf0e10cSrcweir 			return sal_False;
1782*cdf0e10cSrcweir 		if( m_nKnownCount )
1783*cdf0e10cSrcweir 			return m_nRow == 1;
1784*cdf0e10cSrcweir 		if( m_bFinalCount )
1785*cdf0e10cSrcweir 			return sal_False;
1786*cdf0e10cSrcweir 
1787*cdf0e10cSrcweir 		nRow = m_nRow;
1788*cdf0e10cSrcweir 		xResultSetOrigin = m_xResultSetOrigin;
1789*cdf0e10cSrcweir 	}
1790*cdf0e10cSrcweir 
1791*cdf0e10cSrcweir 	//need to ask origin
1792*cdf0e10cSrcweir 	{
1793*cdf0e10cSrcweir 		if( applyPositionToOrigin( nRow ) )
1794*cdf0e10cSrcweir 			return xResultSetOrigin->isFirst();
1795*cdf0e10cSrcweir 		else
1796*cdf0e10cSrcweir 			return sal_False;
1797*cdf0e10cSrcweir 	}
1798*cdf0e10cSrcweir }
1799*cdf0e10cSrcweir 
1800*cdf0e10cSrcweir //virtual
1801*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1802*cdf0e10cSrcweir 	::isLast()
1803*cdf0e10cSrcweir 	throw( SQLException,
1804*cdf0e10cSrcweir 		   RuntimeException )
1805*cdf0e10cSrcweir {
1806*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1807*cdf0e10cSrcweir 
1808*cdf0e10cSrcweir 	sal_Int32 nRow = 0;
1809*cdf0e10cSrcweir 	Reference< XResultSet > xResultSetOrigin;
1810*cdf0e10cSrcweir 	{
1811*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1812*cdf0e10cSrcweir 		if( m_bAfterLast )
1813*cdf0e10cSrcweir 			return sal_False;
1814*cdf0e10cSrcweir 		if( m_nRow < m_nKnownCount )
1815*cdf0e10cSrcweir 			return sal_False;
1816*cdf0e10cSrcweir 		if( m_bFinalCount )
1817*cdf0e10cSrcweir 			return m_nKnownCount && m_nRow == m_nKnownCount;
1818*cdf0e10cSrcweir 
1819*cdf0e10cSrcweir 		nRow = m_nRow;
1820*cdf0e10cSrcweir 		xResultSetOrigin = m_xResultSetOrigin;
1821*cdf0e10cSrcweir 	}
1822*cdf0e10cSrcweir 
1823*cdf0e10cSrcweir 	//need to ask origin
1824*cdf0e10cSrcweir 	{
1825*cdf0e10cSrcweir 		if( applyPositionToOrigin( nRow ) )
1826*cdf0e10cSrcweir 			return xResultSetOrigin->isLast();
1827*cdf0e10cSrcweir 		else
1828*cdf0e10cSrcweir 			return sal_False;
1829*cdf0e10cSrcweir 	}
1830*cdf0e10cSrcweir }
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir 
1833*cdf0e10cSrcweir //virtual
1834*cdf0e10cSrcweir sal_Int32 SAL_CALL CachedContentResultSet
1835*cdf0e10cSrcweir 	::getRow()
1836*cdf0e10cSrcweir 	throw( SQLException,
1837*cdf0e10cSrcweir 		   RuntimeException )
1838*cdf0e10cSrcweir {
1839*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1840*cdf0e10cSrcweir 
1841*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
1842*cdf0e10cSrcweir 	if( m_bAfterLast )
1843*cdf0e10cSrcweir 		return 0;
1844*cdf0e10cSrcweir 	return m_nRow;
1845*cdf0e10cSrcweir }
1846*cdf0e10cSrcweir 
1847*cdf0e10cSrcweir //virtual
1848*cdf0e10cSrcweir void SAL_CALL CachedContentResultSet
1849*cdf0e10cSrcweir 	::refreshRow()
1850*cdf0e10cSrcweir 	throw( SQLException,
1851*cdf0e10cSrcweir 		   RuntimeException )
1852*cdf0e10cSrcweir {
1853*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1854*cdf0e10cSrcweir 
1855*cdf0e10cSrcweir 	//the ContentResultSet is static and will not change
1856*cdf0e10cSrcweir 	//therefore we don't need to reload anything
1857*cdf0e10cSrcweir }
1858*cdf0e10cSrcweir 
1859*cdf0e10cSrcweir //virtual
1860*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1861*cdf0e10cSrcweir 	::rowUpdated()
1862*cdf0e10cSrcweir 	throw( SQLException,
1863*cdf0e10cSrcweir 		   RuntimeException )
1864*cdf0e10cSrcweir {
1865*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1866*cdf0e10cSrcweir 
1867*cdf0e10cSrcweir 	//the ContentResultSet is static and will not change
1868*cdf0e10cSrcweir 	return sal_False;
1869*cdf0e10cSrcweir }
1870*cdf0e10cSrcweir //virtual
1871*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1872*cdf0e10cSrcweir 	::rowInserted()
1873*cdf0e10cSrcweir 	throw( SQLException,
1874*cdf0e10cSrcweir 		   RuntimeException )
1875*cdf0e10cSrcweir {
1876*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1877*cdf0e10cSrcweir 
1878*cdf0e10cSrcweir 	//the ContentResultSet is static and will not change
1879*cdf0e10cSrcweir 	return sal_False;
1880*cdf0e10cSrcweir }
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir //virtual
1883*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1884*cdf0e10cSrcweir 	::rowDeleted()
1885*cdf0e10cSrcweir 	throw( SQLException,
1886*cdf0e10cSrcweir 		   RuntimeException )
1887*cdf0e10cSrcweir {
1888*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1889*cdf0e10cSrcweir 
1890*cdf0e10cSrcweir 	//the ContentResultSet is static and will not change
1891*cdf0e10cSrcweir 	return sal_False;
1892*cdf0e10cSrcweir }
1893*cdf0e10cSrcweir 
1894*cdf0e10cSrcweir //virtual
1895*cdf0e10cSrcweir Reference< XInterface > SAL_CALL CachedContentResultSet
1896*cdf0e10cSrcweir 	::getStatement()
1897*cdf0e10cSrcweir 	throw( SQLException,
1898*cdf0e10cSrcweir 		   RuntimeException )
1899*cdf0e10cSrcweir {
1900*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1901*cdf0e10cSrcweir 	//@todo ?return anything
1902*cdf0e10cSrcweir 	return Reference< XInterface >();
1903*cdf0e10cSrcweir }
1904*cdf0e10cSrcweir 
1905*cdf0e10cSrcweir //-----------------------------------------------------------------
1906*cdf0e10cSrcweir // XRow methods. ( inherited )
1907*cdf0e10cSrcweir //-----------------------------------------------------------------
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir //virtual
1910*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1911*cdf0e10cSrcweir 	::wasNull()
1912*cdf0e10cSrcweir 	throw( SQLException,
1913*cdf0e10cSrcweir 		   RuntimeException )
1914*cdf0e10cSrcweir {
1915*cdf0e10cSrcweir 	impl_EnsureNotDisposed();
1916*cdf0e10cSrcweir 	impl_init_xRowOrigin();
1917*cdf0e10cSrcweir 	{
1918*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_aMutex );
1919*cdf0e10cSrcweir 		if( m_bLastReadWasFromCache )
1920*cdf0e10cSrcweir 			return m_bLastCachedReadWasNull;
1921*cdf0e10cSrcweir 		if( !m_xRowOrigin.is() )
1922*cdf0e10cSrcweir 		{
1923*cdf0e10cSrcweir 			OSL_ENSURE( sal_False, "broadcaster was disposed already" );
1924*cdf0e10cSrcweir 			return sal_False;
1925*cdf0e10cSrcweir 		}
1926*cdf0e10cSrcweir 	}
1927*cdf0e10cSrcweir 	return m_xRowOrigin->wasNull();
1928*cdf0e10cSrcweir }
1929*cdf0e10cSrcweir 
1930*cdf0e10cSrcweir //virtual
1931*cdf0e10cSrcweir rtl::OUString SAL_CALL CachedContentResultSet
1932*cdf0e10cSrcweir 	::getString( sal_Int32 columnIndex )
1933*cdf0e10cSrcweir 	throw( SQLException,
1934*cdf0e10cSrcweir 		   RuntimeException )
1935*cdf0e10cSrcweir {
1936*cdf0e10cSrcweir 	XROW_GETXXX( getString, OUString );
1937*cdf0e10cSrcweir }
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir //virtual
1940*cdf0e10cSrcweir sal_Bool SAL_CALL CachedContentResultSet
1941*cdf0e10cSrcweir 	::getBoolean( sal_Int32 columnIndex )
1942*cdf0e10cSrcweir 	throw( SQLException,
1943*cdf0e10cSrcweir 		   RuntimeException )
1944*cdf0e10cSrcweir {
1945*cdf0e10cSrcweir 	XROW_GETXXX( getBoolean, sal_Bool );
1946*cdf0e10cSrcweir }
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir //virtual
1949*cdf0e10cSrcweir sal_Int8 SAL_CALL CachedContentResultSet
1950*cdf0e10cSrcweir 	::getByte( sal_Int32 columnIndex )
1951*cdf0e10cSrcweir 	throw( SQLException,
1952*cdf0e10cSrcweir 		   RuntimeException )
1953*cdf0e10cSrcweir {
1954*cdf0e10cSrcweir 	XROW_GETXXX( getByte, sal_Int8 );
1955*cdf0e10cSrcweir }
1956*cdf0e10cSrcweir 
1957*cdf0e10cSrcweir //virtual
1958*cdf0e10cSrcweir sal_Int16 SAL_CALL CachedContentResultSet
1959*cdf0e10cSrcweir 	::getShort( sal_Int32 columnIndex )
1960*cdf0e10cSrcweir 	throw( SQLException,
1961*cdf0e10cSrcweir 		   RuntimeException )
1962*cdf0e10cSrcweir {
1963*cdf0e10cSrcweir 	XROW_GETXXX( getShort, sal_Int16 );
1964*cdf0e10cSrcweir }
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir //virtual
1967*cdf0e10cSrcweir sal_Int32 SAL_CALL CachedContentResultSet
1968*cdf0e10cSrcweir 	::getInt( sal_Int32 columnIndex )
1969*cdf0e10cSrcweir 	throw( SQLException,
1970*cdf0e10cSrcweir 		   RuntimeException )
1971*cdf0e10cSrcweir {
1972*cdf0e10cSrcweir 	XROW_GETXXX( getInt, sal_Int32 );
1973*cdf0e10cSrcweir }
1974*cdf0e10cSrcweir 
1975*cdf0e10cSrcweir //virtual
1976*cdf0e10cSrcweir sal_Int64 SAL_CALL CachedContentResultSet
1977*cdf0e10cSrcweir 	::getLong( sal_Int32 columnIndex )
1978*cdf0e10cSrcweir 	throw( SQLException,
1979*cdf0e10cSrcweir 		   RuntimeException )
1980*cdf0e10cSrcweir {
1981*cdf0e10cSrcweir 	XROW_GETXXX( getLong, sal_Int64 );
1982*cdf0e10cSrcweir }
1983*cdf0e10cSrcweir 
1984*cdf0e10cSrcweir //virtual
1985*cdf0e10cSrcweir float SAL_CALL CachedContentResultSet
1986*cdf0e10cSrcweir 	::getFloat( sal_Int32 columnIndex )
1987*cdf0e10cSrcweir 	throw( SQLException,
1988*cdf0e10cSrcweir 		   RuntimeException )
1989*cdf0e10cSrcweir {
1990*cdf0e10cSrcweir 	XROW_GETXXX( getFloat, float );
1991*cdf0e10cSrcweir }
1992*cdf0e10cSrcweir 
1993*cdf0e10cSrcweir //virtual
1994*cdf0e10cSrcweir double SAL_CALL CachedContentResultSet
1995*cdf0e10cSrcweir 	::getDouble( sal_Int32 columnIndex )
1996*cdf0e10cSrcweir 	throw( SQLException,
1997*cdf0e10cSrcweir 		   RuntimeException )
1998*cdf0e10cSrcweir {
1999*cdf0e10cSrcweir 	XROW_GETXXX( getDouble, double );
2000*cdf0e10cSrcweir }
2001*cdf0e10cSrcweir 
2002*cdf0e10cSrcweir //virtual
2003*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL CachedContentResultSet
2004*cdf0e10cSrcweir 	::getBytes( sal_Int32 columnIndex )
2005*cdf0e10cSrcweir 	throw( SQLException,
2006*cdf0e10cSrcweir 		   RuntimeException )
2007*cdf0e10cSrcweir {
2008*cdf0e10cSrcweir 	XROW_GETXXX( getBytes, Sequence< sal_Int8 > );
2009*cdf0e10cSrcweir }
2010*cdf0e10cSrcweir 
2011*cdf0e10cSrcweir //virtual
2012*cdf0e10cSrcweir Date SAL_CALL CachedContentResultSet
2013*cdf0e10cSrcweir 	::getDate( sal_Int32 columnIndex )
2014*cdf0e10cSrcweir 	throw( SQLException,
2015*cdf0e10cSrcweir 		   RuntimeException )
2016*cdf0e10cSrcweir {
2017*cdf0e10cSrcweir 	XROW_GETXXX( getDate, Date );
2018*cdf0e10cSrcweir }
2019*cdf0e10cSrcweir 
2020*cdf0e10cSrcweir //virtual
2021*cdf0e10cSrcweir Time SAL_CALL CachedContentResultSet
2022*cdf0e10cSrcweir 	::getTime( sal_Int32 columnIndex )
2023*cdf0e10cSrcweir 	throw( SQLException,
2024*cdf0e10cSrcweir 		   RuntimeException )
2025*cdf0e10cSrcweir {
2026*cdf0e10cSrcweir 	XROW_GETXXX( getTime, Time );
2027*cdf0e10cSrcweir }
2028*cdf0e10cSrcweir 
2029*cdf0e10cSrcweir //virtual
2030*cdf0e10cSrcweir DateTime SAL_CALL CachedContentResultSet
2031*cdf0e10cSrcweir 	::getTimestamp( sal_Int32 columnIndex )
2032*cdf0e10cSrcweir 	throw( SQLException,
2033*cdf0e10cSrcweir 		   RuntimeException )
2034*cdf0e10cSrcweir {
2035*cdf0e10cSrcweir 	XROW_GETXXX( getTimestamp, DateTime );
2036*cdf0e10cSrcweir }
2037*cdf0e10cSrcweir 
2038*cdf0e10cSrcweir //virtual
2039*cdf0e10cSrcweir Reference< com::sun::star::io::XInputStream >
2040*cdf0e10cSrcweir 	SAL_CALL CachedContentResultSet
2041*cdf0e10cSrcweir 	::getBinaryStream( sal_Int32 columnIndex )
2042*cdf0e10cSrcweir 	throw( SQLException,
2043*cdf0e10cSrcweir 		   RuntimeException )
2044*cdf0e10cSrcweir {
2045*cdf0e10cSrcweir 	XROW_GETXXX( getBinaryStream, Reference< com::sun::star::io::XInputStream > );
2046*cdf0e10cSrcweir }
2047*cdf0e10cSrcweir 
2048*cdf0e10cSrcweir //virtual
2049*cdf0e10cSrcweir Reference< com::sun::star::io::XInputStream >
2050*cdf0e10cSrcweir 	SAL_CALL CachedContentResultSet
2051*cdf0e10cSrcweir 	::getCharacterStream( sal_Int32 columnIndex )
2052*cdf0e10cSrcweir 	throw( SQLException,
2053*cdf0e10cSrcweir 		   RuntimeException )
2054*cdf0e10cSrcweir {
2055*cdf0e10cSrcweir 	XROW_GETXXX( getCharacterStream, Reference< com::sun::star::io::XInputStream > );
2056*cdf0e10cSrcweir }
2057*cdf0e10cSrcweir 
2058*cdf0e10cSrcweir //virtual
2059*cdf0e10cSrcweir Any SAL_CALL CachedContentResultSet
2060*cdf0e10cSrcweir 	::getObject( sal_Int32 columnIndex,
2061*cdf0e10cSrcweir 		   const Reference<
2062*cdf0e10cSrcweir 			com::sun::star::container::XNameAccess >& typeMap )
2063*cdf0e10cSrcweir 	throw( SQLException,
2064*cdf0e10cSrcweir 		   RuntimeException )
2065*cdf0e10cSrcweir {
2066*cdf0e10cSrcweir 	//if you change this macro please pay attention to
2067*cdf0e10cSrcweir 	//define XROW_GETXXX, where this is similar implemented
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir 	ReacquireableGuard aGuard( m_aMutex );
2070*cdf0e10cSrcweir 	sal_Int32 nRow = m_nRow;
2071*cdf0e10cSrcweir 	sal_Int32 nFetchSize = m_nFetchSize;
2072*cdf0e10cSrcweir 	sal_Int32 nFetchDirection = m_nFetchDirection;
2073*cdf0e10cSrcweir 	if( !m_aCache.hasRow( nRow ) )
2074*cdf0e10cSrcweir 	{
2075*cdf0e10cSrcweir 		if( !m_aCache.hasCausedException( nRow ) )
2076*cdf0e10cSrcweir 		{
2077*cdf0e10cSrcweir 			if( !m_xFetchProvider.is() )
2078*cdf0e10cSrcweir 			{
2079*cdf0e10cSrcweir 				OSL_ENSURE( sal_False, "broadcaster was disposed already" );
2080*cdf0e10cSrcweir 				return Any();
2081*cdf0e10cSrcweir 			}
2082*cdf0e10cSrcweir 			aGuard.clear();
2083*cdf0e10cSrcweir 
2084*cdf0e10cSrcweir 			impl_fetchData( nRow, nFetchSize, nFetchDirection );
2085*cdf0e10cSrcweir 		}
2086*cdf0e10cSrcweir 		aGuard.reacquire();
2087*cdf0e10cSrcweir 		if( !m_aCache.hasRow( nRow ) )
2088*cdf0e10cSrcweir 		{
2089*cdf0e10cSrcweir 			m_bLastReadWasFromCache = sal_False;
2090*cdf0e10cSrcweir 			aGuard.clear();
2091*cdf0e10cSrcweir 			applyPositionToOrigin( nRow );
2092*cdf0e10cSrcweir 			impl_init_xRowOrigin();
2093*cdf0e10cSrcweir 			return m_xRowOrigin->getObject( columnIndex, typeMap );
2094*cdf0e10cSrcweir 		}
2095*cdf0e10cSrcweir 	}
2096*cdf0e10cSrcweir 	//@todo: pay attention to typeMap
2097*cdf0e10cSrcweir 	const Any& rValue = m_aCache.getAny( nRow, columnIndex );
2098*cdf0e10cSrcweir 	Any aRet;
2099*cdf0e10cSrcweir 	m_bLastReadWasFromCache = sal_True;
2100*cdf0e10cSrcweir 	m_bLastCachedReadWasNull = !( rValue >>= aRet );
2101*cdf0e10cSrcweir 	return aRet;
2102*cdf0e10cSrcweir }
2103*cdf0e10cSrcweir 
2104*cdf0e10cSrcweir //virtual
2105*cdf0e10cSrcweir Reference< XRef > SAL_CALL CachedContentResultSet
2106*cdf0e10cSrcweir 	::getRef( sal_Int32 columnIndex )
2107*cdf0e10cSrcweir 	throw( SQLException,
2108*cdf0e10cSrcweir 		   RuntimeException )
2109*cdf0e10cSrcweir {
2110*cdf0e10cSrcweir 	XROW_GETXXX( getRef, Reference< XRef > );
2111*cdf0e10cSrcweir }
2112*cdf0e10cSrcweir 
2113*cdf0e10cSrcweir //virtual
2114*cdf0e10cSrcweir Reference< XBlob > SAL_CALL CachedContentResultSet
2115*cdf0e10cSrcweir 	::getBlob( sal_Int32 columnIndex )
2116*cdf0e10cSrcweir 	throw( SQLException,
2117*cdf0e10cSrcweir 		   RuntimeException )
2118*cdf0e10cSrcweir {
2119*cdf0e10cSrcweir 	XROW_GETXXX( getBlob, Reference< XBlob > );
2120*cdf0e10cSrcweir }
2121*cdf0e10cSrcweir 
2122*cdf0e10cSrcweir //virtual
2123*cdf0e10cSrcweir Reference< XClob > SAL_CALL CachedContentResultSet
2124*cdf0e10cSrcweir 	::getClob( sal_Int32 columnIndex )
2125*cdf0e10cSrcweir 	throw( SQLException,
2126*cdf0e10cSrcweir 		   RuntimeException )
2127*cdf0e10cSrcweir {
2128*cdf0e10cSrcweir 	XROW_GETXXX( getClob, Reference< XClob > );
2129*cdf0e10cSrcweir }
2130*cdf0e10cSrcweir 
2131*cdf0e10cSrcweir //virtual
2132*cdf0e10cSrcweir Reference< XArray > SAL_CALL CachedContentResultSet
2133*cdf0e10cSrcweir 	::getArray( sal_Int32 columnIndex )
2134*cdf0e10cSrcweir 	throw( SQLException,
2135*cdf0e10cSrcweir 		   RuntimeException )
2136*cdf0e10cSrcweir {
2137*cdf0e10cSrcweir 	XROW_GETXXX( getArray, Reference< XArray > );
2138*cdf0e10cSrcweir }
2139*cdf0e10cSrcweir 
2140*cdf0e10cSrcweir //-----------------------------------------------------------------
2141*cdf0e10cSrcweir // Type Converter Support
2142*cdf0e10cSrcweir //-----------------------------------------------------------------
2143*cdf0e10cSrcweir 
2144*cdf0e10cSrcweir const Reference< XTypeConverter >& CachedContentResultSet::getTypeConverter()
2145*cdf0e10cSrcweir {
2146*cdf0e10cSrcweir     osl::Guard< osl::Mutex > aGuard( m_aMutex );
2147*cdf0e10cSrcweir 
2148*cdf0e10cSrcweir 	if ( !m_bTriedToGetTypeConverter && !m_xTypeConverter.is() )
2149*cdf0e10cSrcweir 	{
2150*cdf0e10cSrcweir 		m_bTriedToGetTypeConverter = sal_True;
2151*cdf0e10cSrcweir 		m_xTypeConverter = Reference< XTypeConverter >(
2152*cdf0e10cSrcweir 								m_xSMgr->createInstance(
2153*cdf0e10cSrcweir 									OUString::createFromAscii(
2154*cdf0e10cSrcweir 										"com.sun.star.script.Converter" ) ),
2155*cdf0e10cSrcweir 								UNO_QUERY );
2156*cdf0e10cSrcweir 
2157*cdf0e10cSrcweir         OSL_ENSURE( m_xTypeConverter.is(),
2158*cdf0e10cSrcweir 					"PropertyValueSet::getTypeConverter() - "
2159*cdf0e10cSrcweir 					"Service 'com.sun.star.script.Converter' n/a!" );
2160*cdf0e10cSrcweir 	}
2161*cdf0e10cSrcweir 	return m_xTypeConverter;
2162*cdf0e10cSrcweir }
2163*cdf0e10cSrcweir 
2164*cdf0e10cSrcweir //--------------------------------------------------------------------------
2165*cdf0e10cSrcweir //--------------------------------------------------------------------------
2166*cdf0e10cSrcweir // class CachedContentResultSetFactory
2167*cdf0e10cSrcweir //--------------------------------------------------------------------------
2168*cdf0e10cSrcweir //--------------------------------------------------------------------------
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir CachedContentResultSetFactory::CachedContentResultSetFactory(
2171*cdf0e10cSrcweir 		const Reference< XMultiServiceFactory > & rSMgr )
2172*cdf0e10cSrcweir {
2173*cdf0e10cSrcweir 	m_xSMgr = rSMgr;
2174*cdf0e10cSrcweir }
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir CachedContentResultSetFactory::~CachedContentResultSetFactory()
2177*cdf0e10cSrcweir {
2178*cdf0e10cSrcweir }
2179*cdf0e10cSrcweir 
2180*cdf0e10cSrcweir //--------------------------------------------------------------------------
2181*cdf0e10cSrcweir // CachedContentResultSetFactory XInterface methods.
2182*cdf0e10cSrcweir //--------------------------------------------------------------------------
2183*cdf0e10cSrcweir 
2184*cdf0e10cSrcweir XINTERFACE_IMPL_3( CachedContentResultSetFactory,
2185*cdf0e10cSrcweir 				   XTypeProvider,
2186*cdf0e10cSrcweir 				   XServiceInfo,
2187*cdf0e10cSrcweir 				   XCachedContentResultSetFactory );
2188*cdf0e10cSrcweir 
2189*cdf0e10cSrcweir //--------------------------------------------------------------------------
2190*cdf0e10cSrcweir // CachedContentResultSetFactory XTypeProvider methods.
2191*cdf0e10cSrcweir //--------------------------------------------------------------------------
2192*cdf0e10cSrcweir 
2193*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_3( CachedContentResultSetFactory,
2194*cdf0e10cSrcweir 					  XTypeProvider,
2195*cdf0e10cSrcweir 				   	  XServiceInfo,
2196*cdf0e10cSrcweir 					  XCachedContentResultSetFactory );
2197*cdf0e10cSrcweir 
2198*cdf0e10cSrcweir //--------------------------------------------------------------------------
2199*cdf0e10cSrcweir // CachedContentResultSetFactory XServiceInfo methods.
2200*cdf0e10cSrcweir //--------------------------------------------------------------------------
2201*cdf0e10cSrcweir 
2202*cdf0e10cSrcweir XSERVICEINFO_IMPL_1( CachedContentResultSetFactory,
2203*cdf0e10cSrcweir 					 OUString::createFromAscii(
2204*cdf0e10cSrcweir 			   			"com.sun.star.comp.ucb.CachedContentResultSetFactory" ),
2205*cdf0e10cSrcweir 	 		   		 OUString::createFromAscii(
2206*cdf0e10cSrcweir 					 	CACHED_CONTENT_RESULTSET_FACTORY_NAME ) );
2207*cdf0e10cSrcweir 
2208*cdf0e10cSrcweir //--------------------------------------------------------------------------
2209*cdf0e10cSrcweir // Service factory implementation.
2210*cdf0e10cSrcweir //--------------------------------------------------------------------------
2211*cdf0e10cSrcweir 
2212*cdf0e10cSrcweir ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedContentResultSetFactory );
2213*cdf0e10cSrcweir 
2214*cdf0e10cSrcweir //--------------------------------------------------------------------------
2215*cdf0e10cSrcweir // CachedContentResultSetFactory XCachedContentResultSetFactory methods.
2216*cdf0e10cSrcweir //--------------------------------------------------------------------------
2217*cdf0e10cSrcweir 
2218*cdf0e10cSrcweir 	//virtual
2219*cdf0e10cSrcweir Reference< XResultSet > SAL_CALL CachedContentResultSetFactory
2220*cdf0e10cSrcweir 	::createCachedContentResultSet(
2221*cdf0e10cSrcweir 			const Reference< XResultSet > & xSource,
2222*cdf0e10cSrcweir 			const Reference< XContentIdentifierMapping > & xMapping )
2223*cdf0e10cSrcweir 			throw( com::sun::star::uno::RuntimeException )
2224*cdf0e10cSrcweir {
2225*cdf0e10cSrcweir 	Reference< XResultSet > xRet;
2226*cdf0e10cSrcweir     xRet = new CachedContentResultSet( m_xSMgr, xSource, xMapping );
2227*cdf0e10cSrcweir 	return xRet;
2228*cdf0e10cSrcweir }
2229*cdf0e10cSrcweir 
2230