xref: /aoo42x/main/ucb/source/ucp/file/filrset.cxx (revision cdf0e10c)
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 <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
31*cdf0e10cSrcweir #include "filid.hxx"
32*cdf0e10cSrcweir #include "shell.hxx"
33*cdf0e10cSrcweir #include "filprp.hxx"
34*cdf0e10cSrcweir #include "filrset.hxx"
35*cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
36*cdf0e10cSrcweir #include "prov.hxx"
37*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_
40*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #include <com/sun/star/ucb/ListActionType.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/ucb/XSourceInitialization.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
45*cdf0e10cSrcweir #include <ucbhelper/resultsetmetadata.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir using namespace fileaccess;
48*cdf0e10cSrcweir using namespace com::sun::star;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir XResultSet_impl::XResultSet_impl(
51*cdf0e10cSrcweir     shell* pMyShell,
52*cdf0e10cSrcweir     const rtl::OUString& aUnqPath,
53*cdf0e10cSrcweir     sal_Int32 OpenMode,
54*cdf0e10cSrcweir     const uno::Sequence< beans::Property >& seq,
55*cdf0e10cSrcweir     const uno::Sequence< ucb::NumberedSortingInfo >& seqSort )
56*cdf0e10cSrcweir 	: m_pMyShell( pMyShell ),
57*cdf0e10cSrcweir 	  m_xProvider( pMyShell->m_pProvider ),
58*cdf0e10cSrcweir 	  m_nRow( -1 ),
59*cdf0e10cSrcweir 	  m_nOpenMode( OpenMode ),
60*cdf0e10cSrcweir 	  m_bRowCountFinal( false ),
61*cdf0e10cSrcweir 	  m_aBaseDirectory( aUnqPath ),
62*cdf0e10cSrcweir 	  m_aFolder( aUnqPath ),
63*cdf0e10cSrcweir 	  m_sProperty( seq ),
64*cdf0e10cSrcweir 	  m_sSortingInfo( seqSort ),
65*cdf0e10cSrcweir 	  m_pDisposeEventListeners( 0 ),
66*cdf0e10cSrcweir 	  m_pRowCountListeners( 0 ),
67*cdf0e10cSrcweir 	  m_pIsFinalListeners( 0 ),
68*cdf0e10cSrcweir 	  m_bStatic( false ),
69*cdf0e10cSrcweir 	  m_nErrorCode( TASKHANDLER_NO_ERROR ),
70*cdf0e10cSrcweir 	  m_nMinorErrorCode( TASKHANDLER_NO_ERROR )
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir     osl::FileBase::RC err = m_aFolder.open();
73*cdf0e10cSrcweir     if(  err != osl::FileBase::E_None )
74*cdf0e10cSrcweir     {
75*cdf0e10cSrcweir         m_nIsOpen = false;
76*cdf0e10cSrcweir         m_aFolder.close();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         m_nErrorCode = TASKHANDLING_OPEN_FOR_DIRECTORYLISTING;
79*cdf0e10cSrcweir         m_nMinorErrorCode = err;
80*cdf0e10cSrcweir     }
81*cdf0e10cSrcweir     else
82*cdf0e10cSrcweir         m_nIsOpen = true;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	m_pMyShell->registerNotifier( m_aBaseDirectory,this );
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir XResultSet_impl::~XResultSet_impl()
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir 	m_pMyShell->deregisterNotifier( m_aBaseDirectory,this );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     if( m_nIsOpen )
93*cdf0e10cSrcweir 		m_aFolder.close();
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	delete m_pDisposeEventListeners;
96*cdf0e10cSrcweir 	delete m_pRowCountListeners;
97*cdf0e10cSrcweir 	delete m_pIsFinalListeners;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir sal_Int32 SAL_CALL XResultSet_impl::CtorSuccess()
103*cdf0e10cSrcweir {
104*cdf0e10cSrcweir 	return m_nErrorCode;
105*cdf0e10cSrcweir }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir sal_Int32 SAL_CALL XResultSet_impl::getMinorError()
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir 	return m_nMinorErrorCode;
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir void SAL_CALL
116*cdf0e10cSrcweir XResultSet_impl::acquire(
117*cdf0e10cSrcweir 	void )
118*cdf0e10cSrcweir 	throw()
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir 	OWeakObject::acquire();
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir void SAL_CALL
125*cdf0e10cSrcweir XResultSet_impl::release(
126*cdf0e10cSrcweir 	void )
127*cdf0e10cSrcweir 	throw()
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir 	OWeakObject::release();
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir uno::Any SAL_CALL
135*cdf0e10cSrcweir XResultSet_impl::queryInterface(
136*cdf0e10cSrcweir 	const uno::Type& rType )
137*cdf0e10cSrcweir 	throw( uno::RuntimeException )
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	uno::Any aRet = cppu::queryInterface(
140*cdf0e10cSrcweir         rType,
141*cdf0e10cSrcweir         SAL_STATIC_CAST( lang::XComponent*, this),
142*cdf0e10cSrcweir         SAL_STATIC_CAST( lang::XTypeProvider*, this),
143*cdf0e10cSrcweir         SAL_STATIC_CAST( lang::XEventListener*, this),
144*cdf0e10cSrcweir         SAL_STATIC_CAST( sdbc::XRow*, this),
145*cdf0e10cSrcweir         SAL_STATIC_CAST( sdbc::XResultSet*, this),
146*cdf0e10cSrcweir         SAL_STATIC_CAST( sdbc::XCloseable*, this),
147*cdf0e10cSrcweir         SAL_STATIC_CAST( sdbc::XResultSetMetaDataSupplier*, this),
148*cdf0e10cSrcweir         SAL_STATIC_CAST( beans::XPropertySet*, this ),
149*cdf0e10cSrcweir         SAL_STATIC_CAST( ucb::XContentAccess*, this),
150*cdf0e10cSrcweir         SAL_STATIC_CAST( ucb::XDynamicResultSet*,this) );
151*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir void SAL_CALL
156*cdf0e10cSrcweir XResultSet_impl::disposing( const lang::EventObject& )
157*cdf0e10cSrcweir 	throw( uno::RuntimeException )
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir 	// To do, but what
160*cdf0e10cSrcweir }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_10( XResultSet_impl,
164*cdf0e10cSrcweir 					   lang::XTypeProvider,
165*cdf0e10cSrcweir 					   lang::XTypeProvider,
166*cdf0e10cSrcweir 					   lang::XEventListener,
167*cdf0e10cSrcweir 					   sdbc::XRow,
168*cdf0e10cSrcweir 					   sdbc::XResultSet,
169*cdf0e10cSrcweir 					   XDynamicResultSet,
170*cdf0e10cSrcweir 					   sdbc::XCloseable,
171*cdf0e10cSrcweir 					   sdbc::XResultSetMetaDataSupplier,
172*cdf0e10cSrcweir 					   beans::XPropertySet,
173*cdf0e10cSrcweir 					   ucb::XContentAccess )
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir void SAL_CALL
177*cdf0e10cSrcweir XResultSet_impl::addEventListener(
178*cdf0e10cSrcweir 	const uno::Reference< lang::XEventListener >& Listener )
179*cdf0e10cSrcweir 	throw( uno::RuntimeException )
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	if ( ! m_pDisposeEventListeners )
184*cdf0e10cSrcweir 		m_pDisposeEventListeners =
185*cdf0e10cSrcweir 			new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	m_pDisposeEventListeners->addInterface( Listener );
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir void SAL_CALL
192*cdf0e10cSrcweir XResultSet_impl::removeEventListener(
193*cdf0e10cSrcweir 	const uno::Reference< lang::XEventListener >& Listener )
194*cdf0e10cSrcweir 	throw( uno::RuntimeException )
195*cdf0e10cSrcweir {
196*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	if ( m_pDisposeEventListeners )
199*cdf0e10cSrcweir 		m_pDisposeEventListeners->removeInterface( Listener );
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir void SAL_CALL
205*cdf0e10cSrcweir XResultSet_impl::dispose()
206*cdf0e10cSrcweir 	throw( uno::RuntimeException )
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	lang::EventObject aEvt;
211*cdf0e10cSrcweir 	aEvt.Source = static_cast< lang::XComponent * >( this );
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
214*cdf0e10cSrcweir 	{
215*cdf0e10cSrcweir 		m_pDisposeEventListeners->disposeAndClear( aEvt );
216*cdf0e10cSrcweir 	}
217*cdf0e10cSrcweir 	if( m_pRowCountListeners && m_pRowCountListeners->getLength() )
218*cdf0e10cSrcweir 	{
219*cdf0e10cSrcweir 		m_pRowCountListeners->disposeAndClear( aEvt );
220*cdf0e10cSrcweir 	}
221*cdf0e10cSrcweir 	if( m_pIsFinalListeners && m_pIsFinalListeners->getLength() )
222*cdf0e10cSrcweir 	{
223*cdf0e10cSrcweir 		m_pIsFinalListeners->disposeAndClear( aEvt );
224*cdf0e10cSrcweir 	}
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir void XResultSet_impl::rowCountChanged()
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir 	sal_Int32 aOldValue,aNewValue;
232*cdf0e10cSrcweir 	uno::Sequence< uno::Reference< uno::XInterface > > seq;
233*cdf0e10cSrcweir 	{
234*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
235*cdf0e10cSrcweir 		if( m_pRowCountListeners )
236*cdf0e10cSrcweir 			seq = m_pRowCountListeners->getElements();
237*cdf0e10cSrcweir 		aNewValue = m_aItems.size();
238*cdf0e10cSrcweir 		aOldValue = aNewValue-1;
239*cdf0e10cSrcweir 	}
240*cdf0e10cSrcweir 	beans::PropertyChangeEvent aEv;
241*cdf0e10cSrcweir 	aEv.PropertyName = rtl::OUString::createFromAscii( "RowCount" );
242*cdf0e10cSrcweir 	aEv.Further = false;
243*cdf0e10cSrcweir 	aEv.PropertyHandle = -1;
244*cdf0e10cSrcweir 	aEv.OldValue <<= aOldValue;
245*cdf0e10cSrcweir 	aEv.NewValue <<= aNewValue;
246*cdf0e10cSrcweir 	for( sal_Int32 i = 0; i < seq.getLength(); ++i )
247*cdf0e10cSrcweir 	{
248*cdf0e10cSrcweir 		uno::Reference< beans::XPropertyChangeListener > listener(
249*cdf0e10cSrcweir             seq[i], uno::UNO_QUERY );
250*cdf0e10cSrcweir 		if( listener.is() )
251*cdf0e10cSrcweir 			listener->propertyChange( aEv );
252*cdf0e10cSrcweir 	}
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir void XResultSet_impl::isFinalChanged()
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir 	uno::Sequence< uno::Reference< XInterface > > seq;
259*cdf0e10cSrcweir 	{
260*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
261*cdf0e10cSrcweir 		if( m_pIsFinalListeners )
262*cdf0e10cSrcweir 			seq = m_pIsFinalListeners->getElements();
263*cdf0e10cSrcweir 		m_bRowCountFinal = true;
264*cdf0e10cSrcweir 	}
265*cdf0e10cSrcweir 	beans::PropertyChangeEvent aEv;
266*cdf0e10cSrcweir 	aEv.PropertyName = rtl::OUString::createFromAscii( "IsRowCountFinal" );
267*cdf0e10cSrcweir 	aEv.Further = false;
268*cdf0e10cSrcweir 	aEv.PropertyHandle = -1;
269*cdf0e10cSrcweir 	sal_Bool fval = false;
270*cdf0e10cSrcweir 	sal_Bool tval = true;
271*cdf0e10cSrcweir 	aEv.OldValue <<= fval;
272*cdf0e10cSrcweir 	aEv.NewValue <<= tval;
273*cdf0e10cSrcweir 	for( sal_Int32 i = 0; i < seq.getLength(); ++i )
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		uno::Reference< beans::XPropertyChangeListener > listener(
276*cdf0e10cSrcweir             seq[i], uno::UNO_QUERY );
277*cdf0e10cSrcweir 		if( listener.is() )
278*cdf0e10cSrcweir 			listener->propertyChange( aEv );
279*cdf0e10cSrcweir 	}
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir sal_Bool SAL_CALL
284*cdf0e10cSrcweir XResultSet_impl::OneMore(
285*cdf0e10cSrcweir 	void )
286*cdf0e10cSrcweir 	throw( sdbc::SQLException,
287*cdf0e10cSrcweir 		   uno::RuntimeException )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir 	if( ! m_nIsOpen )
290*cdf0e10cSrcweir         return false;
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 	osl::FileBase::RC err;
293*cdf0e10cSrcweir 	sal_Bool IsRegular;
294*cdf0e10cSrcweir 	rtl::OUString aUnqPath;
295*cdf0e10cSrcweir 	osl::DirectoryItem  m_aDirIte;
296*cdf0e10cSrcweir 	uno::Reference< sdbc::XRow > aRow;
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 	while( true )
299*cdf0e10cSrcweir 	{
300*cdf0e10cSrcweir 		err = m_aFolder.getNextItem( m_aDirIte );
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir 		if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL )
303*cdf0e10cSrcweir 		{
304*cdf0e10cSrcweir 			m_aFolder.close();
305*cdf0e10cSrcweir 			isFinalChanged();
306*cdf0e10cSrcweir 			return ( m_nIsOpen = false );
307*cdf0e10cSrcweir 		}
308*cdf0e10cSrcweir 		else if( err == osl::FileBase::E_None )
309*cdf0e10cSrcweir 		{
310*cdf0e10cSrcweir 			aRow = m_pMyShell->getv(
311*cdf0e10cSrcweir                 this, m_sProperty, m_aDirIte, aUnqPath, IsRegular );
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 			if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && IsRegular )
314*cdf0e10cSrcweir 			{
315*cdf0e10cSrcweir 				osl::MutexGuard aGuard( m_aMutex );
316*cdf0e10cSrcweir 				m_aItems.push_back( aRow );
317*cdf0e10cSrcweir 				m_aIdents.push_back(
318*cdf0e10cSrcweir                     uno::Reference< ucb::XContentIdentifier >() );
319*cdf0e10cSrcweir 				m_aUnqPath.push_back( aUnqPath );
320*cdf0e10cSrcweir 				rowCountChanged();
321*cdf0e10cSrcweir 				return true;
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 			}
324*cdf0e10cSrcweir 			else if( m_nOpenMode == ucb::OpenMode::DOCUMENTS && ! IsRegular )
325*cdf0e10cSrcweir 			{
326*cdf0e10cSrcweir 				continue;
327*cdf0e10cSrcweir 			}
328*cdf0e10cSrcweir 			else if( m_nOpenMode == ucb::OpenMode::FOLDERS && ! IsRegular )
329*cdf0e10cSrcweir 			{
330*cdf0e10cSrcweir 				osl::MutexGuard aGuard( m_aMutex );
331*cdf0e10cSrcweir 				m_aItems.push_back( aRow );
332*cdf0e10cSrcweir 				m_aIdents.push_back(
333*cdf0e10cSrcweir                     uno::Reference< ucb::XContentIdentifier >() );
334*cdf0e10cSrcweir 				m_aUnqPath.push_back( aUnqPath );
335*cdf0e10cSrcweir 				rowCountChanged();
336*cdf0e10cSrcweir 				return true;
337*cdf0e10cSrcweir 			}
338*cdf0e10cSrcweir 			else if( m_nOpenMode == ucb::OpenMode::FOLDERS && IsRegular )
339*cdf0e10cSrcweir 			{
340*cdf0e10cSrcweir 				continue;
341*cdf0e10cSrcweir 			}
342*cdf0e10cSrcweir 			else
343*cdf0e10cSrcweir 			{
344*cdf0e10cSrcweir 				osl::MutexGuard aGuard( m_aMutex );
345*cdf0e10cSrcweir 				m_aItems.push_back( aRow );
346*cdf0e10cSrcweir 				m_aIdents.push_back(
347*cdf0e10cSrcweir                     uno::Reference< ucb::XContentIdentifier >() );
348*cdf0e10cSrcweir 				m_aUnqPath.push_back( aUnqPath );
349*cdf0e10cSrcweir 				rowCountChanged();
350*cdf0e10cSrcweir 				return true;
351*cdf0e10cSrcweir 			}
352*cdf0e10cSrcweir 		}
353*cdf0e10cSrcweir 		else  // error fetching anything
354*cdf0e10cSrcweir 		{
355*cdf0e10cSrcweir 			throw sdbc::SQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
356*cdf0e10cSrcweir 		}
357*cdf0e10cSrcweir 	}
358*cdf0e10cSrcweir }
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir sal_Bool SAL_CALL
365*cdf0e10cSrcweir XResultSet_impl::next(
366*cdf0e10cSrcweir 	void )
367*cdf0e10cSrcweir 	throw( sdbc::SQLException,
368*cdf0e10cSrcweir 		   uno::RuntimeException )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	sal_Bool test;
371*cdf0e10cSrcweir 	if( ++m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) ) test = true;
372*cdf0e10cSrcweir 	else
373*cdf0e10cSrcweir         test = OneMore();
374*cdf0e10cSrcweir 	return test;
375*cdf0e10cSrcweir }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir sal_Bool SAL_CALL
379*cdf0e10cSrcweir XResultSet_impl::isBeforeFirst(
380*cdf0e10cSrcweir 	void )
381*cdf0e10cSrcweir 	throw( sdbc::SQLException,
382*cdf0e10cSrcweir 		   uno::RuntimeException )
383*cdf0e10cSrcweir {
384*cdf0e10cSrcweir 	return m_nRow == -1;
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir sal_Bool SAL_CALL
389*cdf0e10cSrcweir XResultSet_impl::isAfterLast(
390*cdf0e10cSrcweir 	void )
391*cdf0e10cSrcweir 	throw( sdbc::SQLException,
392*cdf0e10cSrcweir 		   uno::RuntimeException )
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	return m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size());   // Cannot happen, if m_aFolder.isOpen()
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir sal_Bool SAL_CALL
399*cdf0e10cSrcweir XResultSet_impl::isFirst(
400*cdf0e10cSrcweir 	void )
401*cdf0e10cSrcweir 	throw( sdbc::SQLException,
402*cdf0e10cSrcweir 		   uno::RuntimeException )
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir 	return m_nRow == 0;
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir sal_Bool SAL_CALL
409*cdf0e10cSrcweir XResultSet_impl::isLast(
410*cdf0e10cSrcweir 	void  )
411*cdf0e10cSrcweir 	throw( sdbc::SQLException,
412*cdf0e10cSrcweir 		   uno::RuntimeException)
413*cdf0e10cSrcweir {
414*cdf0e10cSrcweir 	if( m_nRow ==  sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1 )
415*cdf0e10cSrcweir 		return ! OneMore();
416*cdf0e10cSrcweir 	else
417*cdf0e10cSrcweir 		return false;
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir void SAL_CALL
422*cdf0e10cSrcweir XResultSet_impl::beforeFirst(
423*cdf0e10cSrcweir 	void  )
424*cdf0e10cSrcweir 	throw( sdbc::SQLException,
425*cdf0e10cSrcweir 		   uno::RuntimeException)
426*cdf0e10cSrcweir {
427*cdf0e10cSrcweir 	m_nRow = -1;
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir void SAL_CALL
432*cdf0e10cSrcweir XResultSet_impl::afterLast(
433*cdf0e10cSrcweir 	void  )
434*cdf0e10cSrcweir 	throw( sdbc::SQLException,
435*cdf0e10cSrcweir 		   uno::RuntimeException )
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir 	m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());
438*cdf0e10cSrcweir 	while( OneMore() )
439*cdf0e10cSrcweir 		++m_nRow;
440*cdf0e10cSrcweir }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir sal_Bool SAL_CALL
444*cdf0e10cSrcweir XResultSet_impl::first(
445*cdf0e10cSrcweir 	void  )
446*cdf0e10cSrcweir 	throw( sdbc::SQLException,
447*cdf0e10cSrcweir 		   uno::RuntimeException)
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir 	m_nRow = -1;
450*cdf0e10cSrcweir 	return next();
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir sal_Bool SAL_CALL
455*cdf0e10cSrcweir XResultSet_impl::last(
456*cdf0e10cSrcweir 	void  )
457*cdf0e10cSrcweir 	throw( sdbc::SQLException,
458*cdf0e10cSrcweir 		   uno::RuntimeException )
459*cdf0e10cSrcweir {
460*cdf0e10cSrcweir 	m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size()) - 1;
461*cdf0e10cSrcweir 	while( OneMore() )
462*cdf0e10cSrcweir 		++m_nRow;
463*cdf0e10cSrcweir 	return true;
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir sal_Int32 SAL_CALL
468*cdf0e10cSrcweir XResultSet_impl::getRow(
469*cdf0e10cSrcweir 	void )
470*cdf0e10cSrcweir 	throw( sdbc::SQLException,
471*cdf0e10cSrcweir 		   uno::RuntimeException)
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir 	// Test, whether behind last row
474*cdf0e10cSrcweir 	if( -1 == m_nRow || m_nRow >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
475*cdf0e10cSrcweir 		return 0;
476*cdf0e10cSrcweir 	else
477*cdf0e10cSrcweir 		return m_nRow+1;
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir sal_Bool SAL_CALL XResultSet_impl::absolute( sal_Int32 row )
483*cdf0e10cSrcweir 	throw( sdbc::SQLException, uno::RuntimeException)
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir 	if( row >= 0 )
486*cdf0e10cSrcweir 	{
487*cdf0e10cSrcweir 		m_nRow = row - 1;
488*cdf0e10cSrcweir 		if( row >= sal::static_int_cast<sal_Int32>(m_aItems.size()) )
489*cdf0e10cSrcweir 			while( row-- && OneMore() )
490*cdf0e10cSrcweir 				;
491*cdf0e10cSrcweir 	}
492*cdf0e10cSrcweir 	else
493*cdf0e10cSrcweir 	{
494*cdf0e10cSrcweir 		last();
495*cdf0e10cSrcweir 		m_nRow += ( row + 1 );
496*cdf0e10cSrcweir 		if( m_nRow < -1 )
497*cdf0e10cSrcweir 			m_nRow = -1;
498*cdf0e10cSrcweir 	}
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	return 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
501*cdf0e10cSrcweir }
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir sal_Bool SAL_CALL
507*cdf0e10cSrcweir XResultSet_impl::relative(
508*cdf0e10cSrcweir 	sal_Int32 row )
509*cdf0e10cSrcweir 	throw( sdbc::SQLException,
510*cdf0e10cSrcweir 		   uno::RuntimeException)
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir 	if( isAfterLast() || isBeforeFirst() )
513*cdf0e10cSrcweir 		throw sdbc::SQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), ::rtl::OUString(), 0, uno::Any() );
514*cdf0e10cSrcweir 	if( row > 0 )
515*cdf0e10cSrcweir 		while( row-- ) next();
516*cdf0e10cSrcweir 	else if( row < 0 )
517*cdf0e10cSrcweir 		while( row++ && m_nRow > - 1 ) previous();
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir 	return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
520*cdf0e10cSrcweir }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir sal_Bool SAL_CALL
525*cdf0e10cSrcweir XResultSet_impl::previous(
526*cdf0e10cSrcweir 	void )
527*cdf0e10cSrcweir 	throw( sdbc::SQLException,
528*cdf0e10cSrcweir 		   uno::RuntimeException)
529*cdf0e10cSrcweir {
530*cdf0e10cSrcweir 	if( m_nRow > sal::static_int_cast<sal_Int32>(m_aItems.size()) )
531*cdf0e10cSrcweir 		m_nRow = sal::static_int_cast<sal_Int32>(m_aItems.size());  // Correct Handling of afterLast
532*cdf0e10cSrcweir 	if( 0 <= m_nRow ) -- m_nRow;
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir 	return 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size());
535*cdf0e10cSrcweir }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir void SAL_CALL
539*cdf0e10cSrcweir XResultSet_impl::refreshRow(
540*cdf0e10cSrcweir 	void )
541*cdf0e10cSrcweir 	throw( sdbc::SQLException,
542*cdf0e10cSrcweir 		   uno::RuntimeException)
543*cdf0e10cSrcweir {
544*cdf0e10cSrcweir 	// get the row from the filesystem
545*cdf0e10cSrcweir 	return;
546*cdf0e10cSrcweir }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir sal_Bool SAL_CALL
550*cdf0e10cSrcweir XResultSet_impl::rowUpdated(
551*cdf0e10cSrcweir 	void )
552*cdf0e10cSrcweir 	throw( sdbc::SQLException,
553*cdf0e10cSrcweir 		   uno::RuntimeException )
554*cdf0e10cSrcweir {
555*cdf0e10cSrcweir 	return false;
556*cdf0e10cSrcweir }
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir sal_Bool SAL_CALL
559*cdf0e10cSrcweir XResultSet_impl::rowInserted(
560*cdf0e10cSrcweir 	void  )
561*cdf0e10cSrcweir 	throw( sdbc::SQLException,
562*cdf0e10cSrcweir 		   uno::RuntimeException )
563*cdf0e10cSrcweir {
564*cdf0e10cSrcweir 	return false;
565*cdf0e10cSrcweir }
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir sal_Bool SAL_CALL
568*cdf0e10cSrcweir XResultSet_impl::rowDeleted(
569*cdf0e10cSrcweir 	void  )
570*cdf0e10cSrcweir 	throw( sdbc::SQLException,
571*cdf0e10cSrcweir 		   uno::RuntimeException )
572*cdf0e10cSrcweir {
573*cdf0e10cSrcweir 	return false;
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL
578*cdf0e10cSrcweir XResultSet_impl::getStatement(
579*cdf0e10cSrcweir 	void  )
580*cdf0e10cSrcweir 	throw( sdbc::SQLException,
581*cdf0e10cSrcweir 		   uno::RuntimeException )
582*cdf0e10cSrcweir {
583*cdf0e10cSrcweir 	return uno::Reference< uno::XInterface >();
584*cdf0e10cSrcweir }
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir // XCloseable
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir void SAL_CALL
590*cdf0e10cSrcweir XResultSet_impl::close(
591*cdf0e10cSrcweir 	void )
592*cdf0e10cSrcweir 	throw( sdbc::SQLException,
593*cdf0e10cSrcweir 		   uno::RuntimeException)
594*cdf0e10cSrcweir {
595*cdf0e10cSrcweir 	if( m_nIsOpen )
596*cdf0e10cSrcweir 	{
597*cdf0e10cSrcweir         m_aFolder.close();
598*cdf0e10cSrcweir 		isFinalChanged();
599*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
600*cdf0e10cSrcweir 		m_nIsOpen = false;
601*cdf0e10cSrcweir 	}
602*cdf0e10cSrcweir }
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir rtl::OUString SAL_CALL
607*cdf0e10cSrcweir XResultSet_impl::queryContentIdentifierString(
608*cdf0e10cSrcweir 	void )
609*cdf0e10cSrcweir 	throw( uno::RuntimeException )
610*cdf0e10cSrcweir {
611*cdf0e10cSrcweir 	uno::Reference< ucb::XContentIdentifier > xContentId
612*cdf0e10cSrcweir         = queryContentIdentifier();
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	if( xContentId.is() )
615*cdf0e10cSrcweir 		return xContentId->getContentIdentifier();
616*cdf0e10cSrcweir 	else
617*cdf0e10cSrcweir 		return rtl::OUString();
618*cdf0e10cSrcweir }
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > SAL_CALL
622*cdf0e10cSrcweir XResultSet_impl::queryContentIdentifier(
623*cdf0e10cSrcweir 	void )
624*cdf0e10cSrcweir 	throw( uno::RuntimeException )
625*cdf0e10cSrcweir {
626*cdf0e10cSrcweir 	if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
627*cdf0e10cSrcweir 	{
628*cdf0e10cSrcweir 		if( ! m_aIdents[m_nRow].is() )
629*cdf0e10cSrcweir 		{
630*cdf0e10cSrcweir 			FileContentIdentifier* p
631*cdf0e10cSrcweir                 = new FileContentIdentifier( m_pMyShell,
632*cdf0e10cSrcweir                                              m_aUnqPath[  m_nRow ] );
633*cdf0e10cSrcweir 			m_aIdents[m_nRow] = uno::Reference< ucb::XContentIdentifier >(p);
634*cdf0e10cSrcweir 		}
635*cdf0e10cSrcweir 		return m_aIdents[m_nRow];
636*cdf0e10cSrcweir 	}
637*cdf0e10cSrcweir 	return uno::Reference< ucb::XContentIdentifier >();
638*cdf0e10cSrcweir }
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL
642*cdf0e10cSrcweir XResultSet_impl::queryContent(
643*cdf0e10cSrcweir 	void )
644*cdf0e10cSrcweir 	throw( uno::RuntimeException )
645*cdf0e10cSrcweir {
646*cdf0e10cSrcweir 	if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
647*cdf0e10cSrcweir 		return m_pMyShell->m_pProvider->queryContent( queryContentIdentifier() );
648*cdf0e10cSrcweir 	else
649*cdf0e10cSrcweir 		return uno::Reference< ucb::XContent >();
650*cdf0e10cSrcweir }
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir // XDynamicResultSet
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir // virtual
657*cdf0e10cSrcweir uno::Reference< sdbc::XResultSet > SAL_CALL
658*cdf0e10cSrcweir XResultSet_impl::getStaticResultSet()
659*cdf0e10cSrcweir 	throw( ucb::ListenerAlreadySetException,
660*cdf0e10cSrcweir 		   uno::RuntimeException )
661*cdf0e10cSrcweir {
662*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 	if ( m_xListener.is() )
665*cdf0e10cSrcweir 		throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir 	return uno::Reference< sdbc::XResultSet >( this );
668*cdf0e10cSrcweir }
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir //=========================================================================
671*cdf0e10cSrcweir // virtual
672*cdf0e10cSrcweir void SAL_CALL
673*cdf0e10cSrcweir XResultSet_impl::setListener(
674*cdf0e10cSrcweir 	const uno::Reference< ucb::XDynamicResultSetListener >& Listener )
675*cdf0e10cSrcweir 	throw( ucb::ListenerAlreadySetException,
676*cdf0e10cSrcweir 		   uno::RuntimeException )
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir 	osl::ClearableMutexGuard aGuard( m_aMutex );
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 	if ( m_xListener.is() )
681*cdf0e10cSrcweir 		throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 	m_xListener = Listener;
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
686*cdf0e10cSrcweir 	// Create "welcome event" and send it to listener.
687*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	// Note: We only have the implementation for a static result set at the
690*cdf0e10cSrcweir 	//       moment (src590). The dynamic result sets passed to the listener
691*cdf0e10cSrcweir 	//       are a fake. This implementation will never call "notify" at the
692*cdf0e10cSrcweir 	//       listener to propagate any changes!!!
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir 	uno::Any aInfo;
695*cdf0e10cSrcweir 	aInfo <<= ucb::WelcomeDynamicResultSetStruct( this, /* "old" */
696*cdf0e10cSrcweir                                                   this /* "new" */ );
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	uno::Sequence< ucb::ListAction > aActions( 1 );
699*cdf0e10cSrcweir 	aActions.getArray()[ 0 ] = ucb::ListAction( 0, // Position; not used
700*cdf0e10cSrcweir                                                 0, // Count; not used
701*cdf0e10cSrcweir                                                 ucb::ListActionType::WELCOME,
702*cdf0e10cSrcweir                                                 aInfo );
703*cdf0e10cSrcweir 	aGuard.clear();
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 	Listener->notify(
706*cdf0e10cSrcweir 		ucb::ListEvent(
707*cdf0e10cSrcweir             static_cast< cppu::OWeakObject * >( this ), aActions ) );
708*cdf0e10cSrcweir }
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir //=========================================================================
711*cdf0e10cSrcweir // virtual
712*cdf0e10cSrcweir void SAL_CALL
713*cdf0e10cSrcweir XResultSet_impl::connectToCache(
714*cdf0e10cSrcweir 	const uno::Reference< ucb::XDynamicResultSet > & xCache )
715*cdf0e10cSrcweir 	throw( ucb::ListenerAlreadySetException,
716*cdf0e10cSrcweir 		   ucb::AlreadyInitializedException,
717*cdf0e10cSrcweir 		   ucb::ServiceNotFoundException,
718*cdf0e10cSrcweir 		   uno::RuntimeException )
719*cdf0e10cSrcweir {
720*cdf0e10cSrcweir 	uno::Reference< lang::XMultiServiceFactory > mxSMgr
721*cdf0e10cSrcweir 		= m_pMyShell->m_xMultiServiceFactory;
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir 	if( m_xListener.is() )
724*cdf0e10cSrcweir 		throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
725*cdf0e10cSrcweir 	if( m_bStatic )
726*cdf0e10cSrcweir 		throw ucb::ListenerAlreadySetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir 	uno::Reference< ucb::XSourceInitialization > xTarget(
729*cdf0e10cSrcweir         xCache, uno::UNO_QUERY );
730*cdf0e10cSrcweir 	if( xTarget.is() && mxSMgr.is() )
731*cdf0e10cSrcweir 	{
732*cdf0e10cSrcweir 		uno::Reference< ucb::XCachedDynamicResultSetStubFactory > xStubFactory;
733*cdf0e10cSrcweir 		try
734*cdf0e10cSrcweir 		{
735*cdf0e10cSrcweir 			xStubFactory
736*cdf0e10cSrcweir                 = uno::Reference< ucb::XCachedDynamicResultSetStubFactory >(
737*cdf0e10cSrcweir                     mxSMgr->createInstance(
738*cdf0e10cSrcweir                         rtl::OUString::createFromAscii(
739*cdf0e10cSrcweir                             "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ),
740*cdf0e10cSrcweir                     uno::UNO_QUERY );
741*cdf0e10cSrcweir 		}
742*cdf0e10cSrcweir 		catch ( uno::Exception const & )
743*cdf0e10cSrcweir 		{
744*cdf0e10cSrcweir 		}
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir 		if( xStubFactory.is() )
747*cdf0e10cSrcweir 		{
748*cdf0e10cSrcweir 			xStubFactory->connectToCache(
749*cdf0e10cSrcweir 				this, xCache,m_sSortingInfo, NULL );
750*cdf0e10cSrcweir 			return;
751*cdf0e10cSrcweir 		}
752*cdf0e10cSrcweir 	}
753*cdf0e10cSrcweir 	throw ucb::ServiceNotFoundException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
754*cdf0e10cSrcweir }
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir //=========================================================================
757*cdf0e10cSrcweir // virtual
758*cdf0e10cSrcweir sal_Int16 SAL_CALL
759*cdf0e10cSrcweir XResultSet_impl::getCapabilities()
760*cdf0e10cSrcweir   throw( uno::RuntimeException )
761*cdf0e10cSrcweir {
762*cdf0e10cSrcweir 	// Never set ucb::ContentResultSetCapability::SORTED
763*cdf0e10cSrcweir 	// 	- Underlying content cannot provide sorted data...
764*cdf0e10cSrcweir 	return 0;
765*cdf0e10cSrcweir }
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir // XResultSetMetaDataSupplier
768*cdf0e10cSrcweir uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
769*cdf0e10cSrcweir XResultSet_impl::getMetaData(
770*cdf0e10cSrcweir 	void )
771*cdf0e10cSrcweir 	throw( sdbc::SQLException,
772*cdf0e10cSrcweir 		   uno::RuntimeException )
773*cdf0e10cSrcweir {
774*cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < m_sProperty.getLength(); ++n )
775*cdf0e10cSrcweir 	{
776*cdf0e10cSrcweir 		if ( m_sProperty.getConstArray()[ n ].Name.compareToAscii( "Title" )
777*cdf0e10cSrcweir              == 0 )
778*cdf0e10cSrcweir 		{
779*cdf0e10cSrcweir 			// @@@ #82177# - Determine correct value!
780*cdf0e10cSrcweir 			sal_Bool bCaseSensitiveChildren = sal_False;
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir 			std::vector< ::ucbhelper::ResultSetColumnData >
783*cdf0e10cSrcweir 									aColumnData( m_sProperty.getLength() );
784*cdf0e10cSrcweir 			aColumnData[ n ].isCaseSensitive = bCaseSensitiveChildren;
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 			::ucbhelper::ResultSetMetaData* p =
787*cdf0e10cSrcweir 				new ::ucbhelper::ResultSetMetaData(
788*cdf0e10cSrcweir 					m_pMyShell->m_xMultiServiceFactory,
789*cdf0e10cSrcweir                     m_sProperty,
790*cdf0e10cSrcweir                     aColumnData );
791*cdf0e10cSrcweir 			return uno::Reference< sdbc::XResultSetMetaData >( p );
792*cdf0e10cSrcweir 		}
793*cdf0e10cSrcweir 	}
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir 	::ucbhelper::ResultSetMetaData* p =
796*cdf0e10cSrcweir 			new ::ucbhelper::ResultSetMetaData(
797*cdf0e10cSrcweir 				m_pMyShell->m_xMultiServiceFactory, m_sProperty );
798*cdf0e10cSrcweir 	return uno::Reference< sdbc::XResultSetMetaData >( p );
799*cdf0e10cSrcweir }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir // XPropertySet
804*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL
805*cdf0e10cSrcweir XResultSet_impl::getPropertySetInfo()
806*cdf0e10cSrcweir 	throw( uno::RuntimeException)
807*cdf0e10cSrcweir {
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir 	uno::Sequence< beans::Property > seq(2);
810*cdf0e10cSrcweir 	seq[0].Name = rtl::OUString::createFromAscii( "RowCount" );
811*cdf0e10cSrcweir 	seq[0].Handle = -1;
812*cdf0e10cSrcweir 	seq[0].Type = getCppuType( static_cast< sal_Int32* >(0) );
813*cdf0e10cSrcweir 	seq[0].Attributes = beans::PropertyAttribute::READONLY;
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir 	seq[0].Name = rtl::OUString::createFromAscii( "IsRowCountFinal" );
816*cdf0e10cSrcweir 	seq[0].Handle = -1;
817*cdf0e10cSrcweir 	seq[0].Type = getCppuType( static_cast< sal_Bool* >(0) );
818*cdf0e10cSrcweir 	seq[0].Attributes = beans::PropertyAttribute::READONLY;
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir 	XPropertySetInfo_impl* p = new XPropertySetInfo_impl( m_pMyShell,
821*cdf0e10cSrcweir 														  seq );
822*cdf0e10cSrcweir 	return uno::Reference< beans::XPropertySetInfo > ( p );
823*cdf0e10cSrcweir }
824*cdf0e10cSrcweir 
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir void SAL_CALL XResultSet_impl::setPropertyValue(
828*cdf0e10cSrcweir 	const rtl::OUString& aPropertyName, const uno::Any& )
829*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
830*cdf0e10cSrcweir 		   beans::PropertyVetoException,
831*cdf0e10cSrcweir 		   lang::IllegalArgumentException,
832*cdf0e10cSrcweir 		   lang::WrappedTargetException,
833*cdf0e10cSrcweir 		   uno::RuntimeException)
834*cdf0e10cSrcweir {
835*cdf0e10cSrcweir 	if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) ||
836*cdf0e10cSrcweir 		aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
837*cdf0e10cSrcweir 		return;
838*cdf0e10cSrcweir 	throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
839*cdf0e10cSrcweir }
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir uno::Any SAL_CALL XResultSet_impl::getPropertyValue(
843*cdf0e10cSrcweir 	const rtl::OUString& PropertyName )
844*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
845*cdf0e10cSrcweir 		   lang::WrappedTargetException,
846*cdf0e10cSrcweir 		   uno::RuntimeException)
847*cdf0e10cSrcweir {
848*cdf0e10cSrcweir 	if( PropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
849*cdf0e10cSrcweir 	{
850*cdf0e10cSrcweir 		uno::Any aAny;
851*cdf0e10cSrcweir 		aAny <<= m_bRowCountFinal;
852*cdf0e10cSrcweir 		return aAny;
853*cdf0e10cSrcweir 	}
854*cdf0e10cSrcweir 	else if ( PropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
855*cdf0e10cSrcweir 	{
856*cdf0e10cSrcweir 		uno::Any aAny;
857*cdf0e10cSrcweir 		sal_Int32 count = sal::static_int_cast<sal_Int32>(m_aItems.size());
858*cdf0e10cSrcweir 		aAny <<= count;
859*cdf0e10cSrcweir 		return aAny;
860*cdf0e10cSrcweir 	}
861*cdf0e10cSrcweir 	else
862*cdf0e10cSrcweir 		throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
863*cdf0e10cSrcweir }
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 
866*cdf0e10cSrcweir void SAL_CALL XResultSet_impl::addPropertyChangeListener(
867*cdf0e10cSrcweir 	const rtl::OUString& aPropertyName,
868*cdf0e10cSrcweir 	const uno::Reference< beans::XPropertyChangeListener >& xListener )
869*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
870*cdf0e10cSrcweir 		   lang::WrappedTargetException,
871*cdf0e10cSrcweir 		   uno::RuntimeException)
872*cdf0e10cSrcweir {
873*cdf0e10cSrcweir 	if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) )
874*cdf0e10cSrcweir 	{
875*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
876*cdf0e10cSrcweir 		if ( ! m_pIsFinalListeners )
877*cdf0e10cSrcweir 			m_pIsFinalListeners =
878*cdf0e10cSrcweir 				new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 		m_pIsFinalListeners->addInterface( xListener );
881*cdf0e10cSrcweir 	}
882*cdf0e10cSrcweir 	else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) )
883*cdf0e10cSrcweir 	{
884*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
885*cdf0e10cSrcweir 		if ( ! m_pRowCountListeners )
886*cdf0e10cSrcweir 			m_pRowCountListeners =
887*cdf0e10cSrcweir 				new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
888*cdf0e10cSrcweir 		m_pRowCountListeners->addInterface( xListener );
889*cdf0e10cSrcweir 	}
890*cdf0e10cSrcweir 	else
891*cdf0e10cSrcweir 		throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
892*cdf0e10cSrcweir }
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir void SAL_CALL XResultSet_impl::removePropertyChangeListener(
896*cdf0e10cSrcweir 	const rtl::OUString& aPropertyName,
897*cdf0e10cSrcweir 	const uno::Reference< beans::XPropertyChangeListener >& aListener )
898*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
899*cdf0e10cSrcweir 		   lang::WrappedTargetException,
900*cdf0e10cSrcweir 		   uno::RuntimeException)
901*cdf0e10cSrcweir {
902*cdf0e10cSrcweir 	if( aPropertyName == rtl::OUString::createFromAscii( "IsRowCountFinal" ) &&
903*cdf0e10cSrcweir 		m_pIsFinalListeners )
904*cdf0e10cSrcweir 	{
905*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
906*cdf0e10cSrcweir 		m_pIsFinalListeners->removeInterface( aListener );
907*cdf0e10cSrcweir 	}
908*cdf0e10cSrcweir 	else if ( aPropertyName == rtl::OUString::createFromAscii( "RowCount" ) &&
909*cdf0e10cSrcweir 			  m_pRowCountListeners )
910*cdf0e10cSrcweir 	{
911*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir 		m_pRowCountListeners->removeInterface( aListener );
914*cdf0e10cSrcweir 	}
915*cdf0e10cSrcweir 	else
916*cdf0e10cSrcweir 		throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
917*cdf0e10cSrcweir }
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir void SAL_CALL XResultSet_impl::addVetoableChangeListener(
920*cdf0e10cSrcweir 	const rtl::OUString&,
921*cdf0e10cSrcweir 	const uno::Reference< beans::XVetoableChangeListener >& )
922*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
923*cdf0e10cSrcweir 		   lang::WrappedTargetException,
924*cdf0e10cSrcweir 		   uno::RuntimeException)
925*cdf0e10cSrcweir {
926*cdf0e10cSrcweir }
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir void SAL_CALL XResultSet_impl::removeVetoableChangeListener(
930*cdf0e10cSrcweir 	const rtl::OUString&,
931*cdf0e10cSrcweir 	const uno::Reference< beans::XVetoableChangeListener >& )
932*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
933*cdf0e10cSrcweir 		   lang::WrappedTargetException,
934*cdf0e10cSrcweir 		   uno::RuntimeException)
935*cdf0e10cSrcweir {
936*cdf0e10cSrcweir }
937