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 #include <ucbhelper/contentidentifier.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
33*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_
34*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include <com/sun/star/ucb/ListActionType.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/ucb/XSourceInitialization.hpp>
38*cdf0e10cSrcweir #include <ucbhelper/resultsetmetadata.hxx>
39*cdf0e10cSrcweir #include "ftpresultsetbase.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir using namespace ftp;
42*cdf0e10cSrcweir using namespace com::sun::star;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir ResultSetBase::ResultSetBase(
45*cdf0e10cSrcweir 	const uno::Reference< lang::XMultiServiceFactory >&  xMSF,
46*cdf0e10cSrcweir 	const uno::Reference< ucb::XContentProvider >&  xProvider,
47*cdf0e10cSrcweir 	sal_Int32 nOpenMode,
48*cdf0e10cSrcweir 	const uno::Sequence< beans::Property >& seq,
49*cdf0e10cSrcweir 	const uno::Sequence< ucb::NumberedSortingInfo >& seqSort )
50*cdf0e10cSrcweir 	: m_xMSF( xMSF ),
51*cdf0e10cSrcweir 	  m_xProvider( xProvider ),
52*cdf0e10cSrcweir 	  m_nRow( -1 ),
53*cdf0e10cSrcweir 	  m_nWasNull( true ),
54*cdf0e10cSrcweir 	  m_nOpenMode( nOpenMode ),
55*cdf0e10cSrcweir 	  m_bRowCountFinal( true ),
56*cdf0e10cSrcweir 	  m_sProperty( seq ),
57*cdf0e10cSrcweir 	  m_sSortingInfo( seqSort ),
58*cdf0e10cSrcweir 	  m_pDisposeEventListeners( 0 ),
59*cdf0e10cSrcweir 	  m_pRowCountListeners( 0 ),
60*cdf0e10cSrcweir 	  m_pIsFinalListeners( 0 )
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir ResultSetBase::~ResultSetBase()
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir 	delete m_pIsFinalListeners;
67*cdf0e10cSrcweir 	delete m_pRowCountListeners;
68*cdf0e10cSrcweir 	delete m_pDisposeEventListeners;
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // XInterface
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir void SAL_CALL
75*cdf0e10cSrcweir ResultSetBase::acquire(
76*cdf0e10cSrcweir 	void )
77*cdf0e10cSrcweir 	throw()
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir 	OWeakObject::acquire();
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir void SAL_CALL
84*cdf0e10cSrcweir ResultSetBase::release(
85*cdf0e10cSrcweir 	void )
86*cdf0e10cSrcweir 	throw()
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir 	OWeakObject::release();
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir uno::Any SAL_CALL
94*cdf0e10cSrcweir ResultSetBase::queryInterface(
95*cdf0e10cSrcweir 	const uno::Type& rType )
96*cdf0e10cSrcweir 	throw( uno::RuntimeException )
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	uno::Any aRet = cppu::queryInterface(
99*cdf0e10cSrcweir 		rType,
100*cdf0e10cSrcweir 		SAL_STATIC_CAST( lang::XComponent*, this),
101*cdf0e10cSrcweir 		SAL_STATIC_CAST( sdbc::XRow*, this),
102*cdf0e10cSrcweir 		SAL_STATIC_CAST( sdbc::XResultSet*, this),
103*cdf0e10cSrcweir 		SAL_STATIC_CAST( sdbc::XResultSetMetaDataSupplier*, this),
104*cdf0e10cSrcweir 		SAL_STATIC_CAST( beans::XPropertySet*, this ),
105*cdf0e10cSrcweir 		SAL_STATIC_CAST( ucb::XContentAccess*, this) );
106*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir // XComponent
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir void SAL_CALL
115*cdf0e10cSrcweir ResultSetBase::addEventListener(
116*cdf0e10cSrcweir 	const uno::Reference< lang::XEventListener >& Listener )
117*cdf0e10cSrcweir 	throw( uno::RuntimeException )
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	if ( ! m_pDisposeEventListeners )
122*cdf0e10cSrcweir 		m_pDisposeEventListeners =
123*cdf0e10cSrcweir 			new cppu::OInterfaceContainerHelper( m_aMutex );
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	m_pDisposeEventListeners->addInterface( Listener );
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir void SAL_CALL
130*cdf0e10cSrcweir ResultSetBase::removeEventListener(
131*cdf0e10cSrcweir 	const uno::Reference< lang::XEventListener >& Listener )
132*cdf0e10cSrcweir 	throw( uno::RuntimeException )
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	if ( m_pDisposeEventListeners )
137*cdf0e10cSrcweir 		m_pDisposeEventListeners->removeInterface( Listener );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void SAL_CALL
143*cdf0e10cSrcweir ResultSetBase::dispose()
144*cdf0e10cSrcweir 	throw( uno::RuntimeException )
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	lang::EventObject aEvt;
149*cdf0e10cSrcweir 	aEvt.Source = static_cast< lang::XComponent * >( this );
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
152*cdf0e10cSrcweir 	{
153*cdf0e10cSrcweir 		m_pDisposeEventListeners->disposeAndClear( aEvt );
154*cdf0e10cSrcweir 	}
155*cdf0e10cSrcweir 	if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
156*cdf0e10cSrcweir 	{
157*cdf0e10cSrcweir 		m_pRowCountListeners->disposeAndClear( aEvt );
158*cdf0e10cSrcweir 	}
159*cdf0e10cSrcweir 	if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
160*cdf0e10cSrcweir 	{
161*cdf0e10cSrcweir 		m_pIsFinalListeners->disposeAndClear( aEvt );
162*cdf0e10cSrcweir 	}
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir //  XResultSet
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir sal_Bool SAL_CALL
170*cdf0e10cSrcweir ResultSetBase::next(
171*cdf0e10cSrcweir 	void )
172*cdf0e10cSrcweir 	throw( sdbc::SQLException,
173*cdf0e10cSrcweir 		   uno::RuntimeException )
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir 	sal_Bool test;
176*cdf0e10cSrcweir 	if( ++m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
177*cdf0e10cSrcweir 		test = true;
178*cdf0e10cSrcweir 	else
179*cdf0e10cSrcweir 		test = false;
180*cdf0e10cSrcweir 	return test;
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir sal_Bool SAL_CALL
185*cdf0e10cSrcweir ResultSetBase::isBeforeFirst(
186*cdf0e10cSrcweir 	void )
187*cdf0e10cSrcweir 	throw( sdbc::SQLException,
188*cdf0e10cSrcweir 		   uno::RuntimeException )
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir 	return m_nRow == -1;
191*cdf0e10cSrcweir }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir sal_Bool SAL_CALL
195*cdf0e10cSrcweir ResultSetBase::isAfterLast(
196*cdf0e10cSrcweir 	void )
197*cdf0e10cSrcweir 	throw( sdbc::SQLException,
198*cdf0e10cSrcweir 		   uno::RuntimeException )
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir 	return m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size());   // Cannot happen, if m_aFolder.isOpen()
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir sal_Bool SAL_CALL
205*cdf0e10cSrcweir ResultSetBase::isFirst(
206*cdf0e10cSrcweir 	void )
207*cdf0e10cSrcweir 	throw( sdbc::SQLException,
208*cdf0e10cSrcweir 		   uno::RuntimeException )
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir 	return m_nRow == 0;
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir sal_Bool SAL_CALL
215*cdf0e10cSrcweir ResultSetBase::isLast(
216*cdf0e10cSrcweir 	void  )
217*cdf0e10cSrcweir 	throw( sdbc::SQLException,
218*cdf0e10cSrcweir 		   uno::RuntimeException)
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 	if( m_nRow ==  sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1 )
221*cdf0e10cSrcweir 		return true;
222*cdf0e10cSrcweir 	else
223*cdf0e10cSrcweir 		return false;
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir void SAL_CALL
228*cdf0e10cSrcweir ResultSetBase::beforeFirst(
229*cdf0e10cSrcweir 	void  )
230*cdf0e10cSrcweir 	throw( sdbc::SQLException,
231*cdf0e10cSrcweir 		   uno::RuntimeException)
232*cdf0e10cSrcweir {
233*cdf0e10cSrcweir 	m_nRow = -1;
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir void SAL_CALL
238*cdf0e10cSrcweir ResultSetBase::afterLast(
239*cdf0e10cSrcweir 	void  )
240*cdf0e10cSrcweir 	throw( sdbc::SQLException,
241*cdf0e10cSrcweir 		   uno::RuntimeException )
242*cdf0e10cSrcweir {
243*cdf0e10cSrcweir 	m_nRow = m_aItems.size();
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir sal_Bool SAL_CALL
248*cdf0e10cSrcweir ResultSetBase::first(
249*cdf0e10cSrcweir 	void  )
250*cdf0e10cSrcweir 	throw( sdbc::SQLException,
251*cdf0e10cSrcweir 		   uno::RuntimeException)
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir 	m_nRow = -1;
254*cdf0e10cSrcweir 	return next();
255*cdf0e10cSrcweir }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir sal_Bool SAL_CALL
259*cdf0e10cSrcweir ResultSetBase::last(
260*cdf0e10cSrcweir 	void  )
261*cdf0e10cSrcweir 	throw( sdbc::SQLException,
262*cdf0e10cSrcweir 		   uno::RuntimeException )
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir 	m_nRow = m_aItems.size() - 1;
265*cdf0e10cSrcweir 	return true;
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir sal_Int32 SAL_CALL
270*cdf0e10cSrcweir ResultSetBase::getRow(
271*cdf0e10cSrcweir 	void )
272*cdf0e10cSrcweir 	throw( sdbc::SQLException,
273*cdf0e10cSrcweir 		   uno::RuntimeException)
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir 	// Test, whether behind last row
276*cdf0e10cSrcweir 	if( -1 == m_nRow || m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
277*cdf0e10cSrcweir 		return 0;
278*cdf0e10cSrcweir 	else
279*cdf0e10cSrcweir 		return m_nRow+1;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir sal_Bool SAL_CALL ResultSetBase::absolute( sal_Int32 row )
284*cdf0e10cSrcweir 	throw( sdbc::SQLException, uno::RuntimeException)
285*cdf0e10cSrcweir {
286*cdf0e10cSrcweir 	if( row >= 0 )
287*cdf0e10cSrcweir 		m_nRow = row - 1;
288*cdf0e10cSrcweir 	else
289*cdf0e10cSrcweir 	{
290*cdf0e10cSrcweir 		last();
291*cdf0e10cSrcweir 		m_nRow += ( row + 1 );
292*cdf0e10cSrcweir 		if( m_nRow < -1 )
293*cdf0e10cSrcweir 			m_nRow = -1;
294*cdf0e10cSrcweir 	}
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 	return 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
297*cdf0e10cSrcweir }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir sal_Bool SAL_CALL
303*cdf0e10cSrcweir ResultSetBase::relative(
304*cdf0e10cSrcweir 	sal_Int32 row )
305*cdf0e10cSrcweir 	throw( sdbc::SQLException,
306*cdf0e10cSrcweir 		   uno::RuntimeException)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	if( isAfterLast() || isBeforeFirst() )
309*cdf0e10cSrcweir 		throw sdbc::SQLException();
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 	if( row > 0 )
312*cdf0e10cSrcweir 		while( row-- )
313*cdf0e10cSrcweir 			next();
314*cdf0e10cSrcweir 	else if( row < 0 )
315*cdf0e10cSrcweir 		while( row++ && m_nRow > - 1 )
316*cdf0e10cSrcweir 			previous();
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
319*cdf0e10cSrcweir }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir sal_Bool SAL_CALL
324*cdf0e10cSrcweir ResultSetBase::previous(
325*cdf0e10cSrcweir 	void )
326*cdf0e10cSrcweir 	throw( sdbc::SQLException,
327*cdf0e10cSrcweir 		   uno::RuntimeException)
328*cdf0e10cSrcweir {
329*cdf0e10cSrcweir 	if( m_nRow > sal::static_int_cast<sal_Int32>(m_aItems.size()) )
330*cdf0e10cSrcweir 		m_nRow = m_aItems.size();  // Correct Handling of afterLast
331*cdf0e10cSrcweir 	if( 0 <= m_nRow ) -- m_nRow;
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 	return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir void SAL_CALL
338*cdf0e10cSrcweir ResultSetBase::refreshRow(
339*cdf0e10cSrcweir 	void )
340*cdf0e10cSrcweir 	throw( sdbc::SQLException,
341*cdf0e10cSrcweir 		   uno::RuntimeException)
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir sal_Bool SAL_CALL
347*cdf0e10cSrcweir ResultSetBase::rowUpdated(
348*cdf0e10cSrcweir 	void )
349*cdf0e10cSrcweir 	throw( sdbc::SQLException,
350*cdf0e10cSrcweir 		   uno::RuntimeException )
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir 	return false;
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir sal_Bool SAL_CALL
356*cdf0e10cSrcweir ResultSetBase::rowInserted(
357*cdf0e10cSrcweir 	void  )
358*cdf0e10cSrcweir 	throw( sdbc::SQLException,
359*cdf0e10cSrcweir 		   uno::RuntimeException )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	return false;
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir sal_Bool SAL_CALL
365*cdf0e10cSrcweir ResultSetBase::rowDeleted(
366*cdf0e10cSrcweir 	void  )
367*cdf0e10cSrcweir 	throw( sdbc::SQLException,
368*cdf0e10cSrcweir 		   uno::RuntimeException )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	return false;
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL
375*cdf0e10cSrcweir ResultSetBase::getStatement(
376*cdf0e10cSrcweir 	void  )
377*cdf0e10cSrcweir 	throw( sdbc::SQLException,
378*cdf0e10cSrcweir 		   uno::RuntimeException )
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir 	uno::Reference< uno::XInterface > test( 0 );
381*cdf0e10cSrcweir 	return test;
382*cdf0e10cSrcweir }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir // XCloseable
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir void SAL_CALL
388*cdf0e10cSrcweir ResultSetBase::close(
389*cdf0e10cSrcweir 	void )
390*cdf0e10cSrcweir 	throw( sdbc::SQLException,
391*cdf0e10cSrcweir 		   uno::RuntimeException)
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir rtl::OUString SAL_CALL
397*cdf0e10cSrcweir ResultSetBase::queryContentIdentifierString(
398*cdf0e10cSrcweir 	void )
399*cdf0e10cSrcweir 	throw( uno::RuntimeException )
400*cdf0e10cSrcweir {
401*cdf0e10cSrcweir 	if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
402*cdf0e10cSrcweir 		return m_aPath[m_nRow];
403*cdf0e10cSrcweir 	else
404*cdf0e10cSrcweir 		return rtl::OUString();
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > SAL_CALL
409*cdf0e10cSrcweir ResultSetBase::queryContentIdentifier(
410*cdf0e10cSrcweir 	void
411*cdf0e10cSrcweir )
412*cdf0e10cSrcweir 	throw(
413*cdf0e10cSrcweir 		uno::RuntimeException
414*cdf0e10cSrcweir 	)
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir 	if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
417*cdf0e10cSrcweir 	{
418*cdf0e10cSrcweir 		if(!m_aIdents[m_nRow].is()) {
419*cdf0e10cSrcweir 			rtl::OUString url = queryContentIdentifierString();
420*cdf0e10cSrcweir 			if(url.getLength() )
421*cdf0e10cSrcweir 				m_aIdents[m_nRow] =
422*cdf0e10cSrcweir 					uno::Reference< ucb::XContentIdentifier >(
423*cdf0e10cSrcweir 						new ::ucbhelper::ContentIdentifier(m_xMSF,url) );
424*cdf0e10cSrcweir 		}
425*cdf0e10cSrcweir 		return m_aIdents[m_nRow];
426*cdf0e10cSrcweir 	}
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 	return uno::Reference<ucb::XContentIdentifier>();
429*cdf0e10cSrcweir }
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL
433*cdf0e10cSrcweir ResultSetBase::queryContent(
434*cdf0e10cSrcweir 	void )
435*cdf0e10cSrcweir 	throw( uno::RuntimeException )
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir 	if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
438*cdf0e10cSrcweir 		return m_xProvider->queryContent(queryContentIdentifier());
439*cdf0e10cSrcweir 	else
440*cdf0e10cSrcweir 		return uno::Reference< ucb::XContent >();
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir class XPropertySetInfoImpl
446*cdf0e10cSrcweir     : public cppu::OWeakObject,
447*cdf0e10cSrcweir       public beans::XPropertySetInfo
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir public:
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir     XPropertySetInfoImpl( const uno::Sequence< beans::Property >& aSeq )
452*cdf0e10cSrcweir         : m_aSeq( aSeq )
453*cdf0e10cSrcweir     {
454*cdf0e10cSrcweir     }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir     void SAL_CALL acquire( void )
457*cdf0e10cSrcweir         throw()
458*cdf0e10cSrcweir     {
459*cdf0e10cSrcweir         OWeakObject::acquire();
460*cdf0e10cSrcweir     }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     void SAL_CALL release( void )
464*cdf0e10cSrcweir         throw()
465*cdf0e10cSrcweir     {
466*cdf0e10cSrcweir         OWeakObject::release();
467*cdf0e10cSrcweir     }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     uno::Any SAL_CALL queryInterface( const uno::Type& rType )
470*cdf0e10cSrcweir         throw( uno::RuntimeException )
471*cdf0e10cSrcweir     {
472*cdf0e10cSrcweir         uno::Any aRet = cppu::queryInterface(
473*cdf0e10cSrcweir 			rType,
474*cdf0e10cSrcweir 			SAL_STATIC_CAST( beans::XPropertySetInfo*, this ) );
475*cdf0e10cSrcweir         return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
476*cdf0e10cSrcweir     }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir     uno::Sequence< beans::Property > SAL_CALL getProperties()
479*cdf0e10cSrcweir         throw( uno::RuntimeException )
480*cdf0e10cSrcweir     {
481*cdf0e10cSrcweir         return m_aSeq;
482*cdf0e10cSrcweir     }
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir     beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName )
485*cdf0e10cSrcweir         throw( beans::UnknownPropertyException,
486*cdf0e10cSrcweir                uno::RuntimeException)
487*cdf0e10cSrcweir     {
488*cdf0e10cSrcweir         for( int i = 0; i < m_aSeq.getLength(); ++i )
489*cdf0e10cSrcweir             if( aName == m_aSeq[i].Name )
490*cdf0e10cSrcweir                 return m_aSeq[i];
491*cdf0e10cSrcweir         throw beans::UnknownPropertyException();
492*cdf0e10cSrcweir     }
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir     sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name )
495*cdf0e10cSrcweir         throw( uno::RuntimeException )
496*cdf0e10cSrcweir     {
497*cdf0e10cSrcweir         for( int i = 0; i < m_aSeq.getLength(); ++i )
498*cdf0e10cSrcweir             if( Name == m_aSeq[i].Name )
499*cdf0e10cSrcweir                 return true;
500*cdf0e10cSrcweir         return false;
501*cdf0e10cSrcweir     }
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir private:
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir     uno::Sequence< beans::Property > m_aSeq;
506*cdf0e10cSrcweir };
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir // XPropertySet
511*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL
512*cdf0e10cSrcweir ResultSetBase::getPropertySetInfo()
513*cdf0e10cSrcweir 	throw( uno::RuntimeException)
514*cdf0e10cSrcweir {
515*cdf0e10cSrcweir 	uno::Sequence< beans::Property > seq(2);
516*cdf0e10cSrcweir 	seq[0].Name = rtl::OUString::createFromAscii( "RowCount" );
517*cdf0e10cSrcweir 	seq[0].Handle = -1;
518*cdf0e10cSrcweir 	seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) );
519*cdf0e10cSrcweir 	seq[0].Attributes = beans::PropertyAttribute::READONLY;
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	seq[1].Name = rtl::OUString::createFromAscii( "IsRowCountFinal" );
522*cdf0e10cSrcweir 	seq[1].Handle = -1;
523*cdf0e10cSrcweir 	seq[1].Type = getCppuType( static_cast< sal_Bool* >(0) );
524*cdf0e10cSrcweir 	seq[1].Attributes = beans::PropertyAttribute::READONLY;
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 	//t
527*cdf0e10cSrcweir 	return uno::Reference< beans::XPropertySetInfo > (
528*cdf0e10cSrcweir 		new XPropertySetInfoImpl( seq ) );
529*cdf0e10cSrcweir }
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir void SAL_CALL ResultSetBase::setPropertyValue(
534*cdf0e10cSrcweir 	const rtl::OUString& aPropertyName, const uno::Any& /*aValue*/ )
535*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
536*cdf0e10cSrcweir 		   beans::PropertyVetoException,
537*cdf0e10cSrcweir 		   lang::IllegalArgumentException,
538*cdf0e10cSrcweir 		   lang::WrappedTargetException,
539*cdf0e10cSrcweir 		   uno::RuntimeException)
540*cdf0e10cSrcweir {
541*cdf0e10cSrcweir 	if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) ||
542*cdf0e10cSrcweir 		aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
543*cdf0e10cSrcweir 		return;
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 	throw beans::UnknownPropertyException();
546*cdf0e10cSrcweir }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir uno::Any SAL_CALL ResultSetBase::getPropertyValue(
550*cdf0e10cSrcweir 	const rtl::OUString& PropertyName )
551*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
552*cdf0e10cSrcweir 		   lang::WrappedTargetException,
553*cdf0e10cSrcweir 		   uno::RuntimeException)
554*cdf0e10cSrcweir {
555*cdf0e10cSrcweir 	if( PropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
556*cdf0e10cSrcweir 	{
557*cdf0e10cSrcweir 		uno::Any aAny;
558*cdf0e10cSrcweir 		aAny <<= m_bRowCountFinal;
559*cdf0e10cSrcweir 		return aAny;
560*cdf0e10cSrcweir 	}
561*cdf0e10cSrcweir 	else if ( PropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
562*cdf0e10cSrcweir 	{
563*cdf0e10cSrcweir 		uno::Any aAny;
564*cdf0e10cSrcweir 		sal_Int32 count = m_aItems.size();
565*cdf0e10cSrcweir 		aAny <<= count;
566*cdf0e10cSrcweir 		return aAny;
567*cdf0e10cSrcweir 	}
568*cdf0e10cSrcweir 	else
569*cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir void SAL_CALL ResultSetBase::addPropertyChangeListener(
574*cdf0e10cSrcweir 	const rtl::OUString& aPropertyName,
575*cdf0e10cSrcweir 	const uno::Reference< beans::XPropertyChangeListener >& xListener )
576*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
577*cdf0e10cSrcweir 		   lang::WrappedTargetException,
578*cdf0e10cSrcweir 		   uno::RuntimeException)
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir 	if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
581*cdf0e10cSrcweir 	{
582*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
583*cdf0e10cSrcweir 		if ( ! m_pIsFinalListeners )
584*cdf0e10cSrcweir 			m_pIsFinalListeners =
585*cdf0e10cSrcweir 				new cppu::OInterfaceContainerHelper( m_aMutex );
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 		m_pIsFinalListeners->addInterface( xListener );
588*cdf0e10cSrcweir 	}
589*cdf0e10cSrcweir 	else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
590*cdf0e10cSrcweir 	{
591*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
592*cdf0e10cSrcweir 		if ( ! m_pRowCountListeners )
593*cdf0e10cSrcweir 			m_pRowCountListeners =
594*cdf0e10cSrcweir 				new cppu::OInterfaceContainerHelper( m_aMutex );
595*cdf0e10cSrcweir 		m_pRowCountListeners->addInterface( xListener );
596*cdf0e10cSrcweir 	}
597*cdf0e10cSrcweir 	else
598*cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
599*cdf0e10cSrcweir }
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir void SAL_CALL ResultSetBase::removePropertyChangeListener(
603*cdf0e10cSrcweir 	const rtl::OUString& aPropertyName,
604*cdf0e10cSrcweir 	const uno::Reference< beans::XPropertyChangeListener >& aListener )
605*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
606*cdf0e10cSrcweir 		   lang::WrappedTargetException,
607*cdf0e10cSrcweir 		   uno::RuntimeException)
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) &&
610*cdf0e10cSrcweir 		m_pIsFinalListeners )
611*cdf0e10cSrcweir 	{
612*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
613*cdf0e10cSrcweir 		m_pIsFinalListeners->removeInterface( aListener );
614*cdf0e10cSrcweir 	}
615*cdf0e10cSrcweir 	else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) &&
616*cdf0e10cSrcweir 			  m_pRowCountListeners )
617*cdf0e10cSrcweir 	{
618*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
619*cdf0e10cSrcweir 		m_pRowCountListeners->removeInterface( aListener );
620*cdf0e10cSrcweir 	}
621*cdf0e10cSrcweir 	else
622*cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
623*cdf0e10cSrcweir }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir void SAL_CALL ResultSetBase::addVetoableChangeListener(
627*cdf0e10cSrcweir 	const rtl::OUString& /*PropertyName*/,
628*cdf0e10cSrcweir 	const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
629*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
630*cdf0e10cSrcweir 		   lang::WrappedTargetException,
631*cdf0e10cSrcweir 		   uno::RuntimeException)
632*cdf0e10cSrcweir {
633*cdf0e10cSrcweir }
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir void SAL_CALL ResultSetBase::removeVetoableChangeListener(
637*cdf0e10cSrcweir 	const rtl::OUString& /*PropertyName*/,
638*cdf0e10cSrcweir 	const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
639*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
640*cdf0e10cSrcweir 		   lang::WrappedTargetException,
641*cdf0e10cSrcweir 		   uno::RuntimeException)
642*cdf0e10cSrcweir {
643*cdf0e10cSrcweir }
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir // XResultSetMetaDataSupplier
648*cdf0e10cSrcweir uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
649*cdf0e10cSrcweir ResultSetBase::getMetaData(
650*cdf0e10cSrcweir 	void )
651*cdf0e10cSrcweir 	throw( sdbc::SQLException,
652*cdf0e10cSrcweir 		   uno::RuntimeException )
653*cdf0e10cSrcweir {
654*cdf0e10cSrcweir 	::ucbhelper::ResultSetMetaData* p =
655*cdf0e10cSrcweir 		  new ::ucbhelper::ResultSetMetaData(
656*cdf0e10cSrcweir 			  m_xMSF, m_sProperty );
657*cdf0e10cSrcweir 	return uno::Reference< sdbc::XResultSetMetaData >( p );
658*cdf0e10cSrcweir }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir 
663