xref: /AOO41X/main/ucb/source/ucp/odma/odma_datasupplier.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 /**************************************************************************
32*cdf0e10cSrcweir 								TODO
33*cdf0e10cSrcweir  **************************************************************************
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir  *************************************************************************/
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <vector>
38*cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
39*cdf0e10cSrcweir #include <ucbhelper/providerhelper.hxx>
40*cdf0e10cSrcweir #include "odma_datasupplier.hxx"
41*cdf0e10cSrcweir #include "odma_content.hxx"
42*cdf0e10cSrcweir #include "odma_contentprops.hxx"
43*cdf0e10cSrcweir #include "odma_provider.hxx"
44*cdf0e10cSrcweir #include "odma_lib.hxx"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir using namespace com::sun::star::beans;
47*cdf0e10cSrcweir using namespace com::sun::star::lang;
48*cdf0e10cSrcweir using namespace com::sun::star::ucb;
49*cdf0e10cSrcweir using namespace com::sun::star::uno;
50*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir using namespace odma;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir namespace odma
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir //=========================================================================
58*cdf0e10cSrcweir //
59*cdf0e10cSrcweir // struct ResultListEntry.
60*cdf0e10cSrcweir //
61*cdf0e10cSrcweir //=========================================================================
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir struct ResultListEntry
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 	::rtl::OUString					    aId;
66*cdf0e10cSrcweir 	Reference< XContentIdentifier >     xId;
67*cdf0e10cSrcweir 	Reference< XContent > 			    xContent;
68*cdf0e10cSrcweir 	Reference< XRow > 				    xRow;
69*cdf0e10cSrcweir 	::rtl::Reference<ContentProperties>	rData;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	ResultListEntry( const ::rtl::Reference<ContentProperties>& rEntry ) : rData( rEntry ) {}
72*cdf0e10cSrcweir };
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir //=========================================================================
75*cdf0e10cSrcweir //
76*cdf0e10cSrcweir // ResultList.
77*cdf0e10cSrcweir //
78*cdf0e10cSrcweir //=========================================================================
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir typedef std::vector< ResultListEntry* > ResultList;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir //=========================================================================
83*cdf0e10cSrcweir //
84*cdf0e10cSrcweir // struct DataSupplier_Impl.
85*cdf0e10cSrcweir //
86*cdf0e10cSrcweir //=========================================================================
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir struct DataSupplier_Impl
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir 	osl::Mutex					      m_aMutex;
91*cdf0e10cSrcweir 	ResultList					      m_aResults;
92*cdf0e10cSrcweir 	rtl::Reference< Content >     	  m_xContent;
93*cdf0e10cSrcweir 	Reference< XMultiServiceFactory > m_xSMgr;
94*cdf0e10cSrcweir // @@@ The data source and an iterator for it
95*cdf0e10cSrcweir //	Entry 		 	      	  		  m_aFolder;
96*cdf0e10cSrcweir //	Entry::iterator 		  		  m_aIterator;
97*cdf0e10cSrcweir   	sal_Int32					      m_nOpenMode;
98*cdf0e10cSrcweir   	sal_Bool					      m_bCountFinal;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	DataSupplier_Impl( const Reference< XMultiServiceFactory >& rxSMgr,
101*cdf0e10cSrcweir 	                   const rtl::Reference< Content >& rContent,
102*cdf0e10cSrcweir 					   sal_Int32 nOpenMode )
103*cdf0e10cSrcweir 	: m_xContent( rContent ), m_xSMgr( rxSMgr ),
104*cdf0e10cSrcweir //	  m_aFolder( rxSMgr, rContent->getIdentifier()->getContentIdentifier() ),
105*cdf0e10cSrcweir 	  m_nOpenMode( nOpenMode ), m_bCountFinal( sal_False ) {}
106*cdf0e10cSrcweir 	~DataSupplier_Impl();
107*cdf0e10cSrcweir };
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir //=========================================================================
110*cdf0e10cSrcweir DataSupplier_Impl::~DataSupplier_Impl()
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	ResultList::const_iterator it  = m_aResults.begin();
113*cdf0e10cSrcweir 	ResultList::const_iterator end = m_aResults.end();
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	while ( it != end )
116*cdf0e10cSrcweir 	{
117*cdf0e10cSrcweir 		delete (*it);
118*cdf0e10cSrcweir 		it++;
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir //=========================================================================
125*cdf0e10cSrcweir //=========================================================================
126*cdf0e10cSrcweir //
127*cdf0e10cSrcweir // DataSupplier Implementation.
128*cdf0e10cSrcweir //
129*cdf0e10cSrcweir //=========================================================================
130*cdf0e10cSrcweir //=========================================================================
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir DataSupplier::DataSupplier( const Reference<XMultiServiceFactory >& rxSMgr,
133*cdf0e10cSrcweir 						   const rtl::Reference< ::odma::Content >& rContent,
134*cdf0e10cSrcweir 							sal_Int32 nOpenMode )
135*cdf0e10cSrcweir : m_pImpl( new DataSupplier_Impl( rxSMgr, rContent, nOpenMode ) )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir //=========================================================================
140*cdf0e10cSrcweir // virtual
141*cdf0e10cSrcweir DataSupplier::~DataSupplier()
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir 	delete m_pImpl;
144*cdf0e10cSrcweir }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir //=========================================================================
147*cdf0e10cSrcweir // virtual
148*cdf0e10cSrcweir ::rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
153*cdf0e10cSrcweir 	{
154*cdf0e10cSrcweir 		::rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aId;
155*cdf0e10cSrcweir 		if ( aId.getLength() )
156*cdf0e10cSrcweir 		{
157*cdf0e10cSrcweir 			// Already cached.
158*cdf0e10cSrcweir 			return aId;
159*cdf0e10cSrcweir 		}
160*cdf0e10cSrcweir 	}
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	if ( getResult( nIndex ) )
163*cdf0e10cSrcweir 	{
164*cdf0e10cSrcweir 		::rtl::OUString aId
165*cdf0e10cSrcweir 			= m_pImpl->m_xContent->getIdentifier()->getContentIdentifier();
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		aId += m_pImpl->m_aResults[ nIndex ]->rData->m_sTitle;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->aId = aId;
170*cdf0e10cSrcweir 		return aId;
171*cdf0e10cSrcweir 	}
172*cdf0e10cSrcweir 	return ::rtl::OUString();
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir //=========================================================================
176*cdf0e10cSrcweir // virtual
177*cdf0e10cSrcweir Reference< XContentIdentifier > DataSupplier::queryContentIdentifier(
178*cdf0e10cSrcweir 														sal_uInt32 nIndex )
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
183*cdf0e10cSrcweir 	{
184*cdf0e10cSrcweir 		Reference< XContentIdentifier > xId
185*cdf0e10cSrcweir 								= m_pImpl->m_aResults[ nIndex ]->xId;
186*cdf0e10cSrcweir 		if ( xId.is() )
187*cdf0e10cSrcweir 		{
188*cdf0e10cSrcweir 			// Already cached.
189*cdf0e10cSrcweir 			return xId;
190*cdf0e10cSrcweir 		}
191*cdf0e10cSrcweir 	}
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	::rtl::OUString aId = queryContentIdentifierString( nIndex );
194*cdf0e10cSrcweir 	if ( aId.getLength() )
195*cdf0e10cSrcweir 	{
196*cdf0e10cSrcweir 		Reference< XContentIdentifier > xId
197*cdf0e10cSrcweir             = new ucbhelper::ContentIdentifier( aId );
198*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xId = xId;
199*cdf0e10cSrcweir 		return xId;
200*cdf0e10cSrcweir 	}
201*cdf0e10cSrcweir 	return Reference< XContentIdentifier >();
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir //=========================================================================
205*cdf0e10cSrcweir // virtual
206*cdf0e10cSrcweir Reference< XContent > DataSupplier::queryContent( sal_uInt32 nIndex )
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
211*cdf0e10cSrcweir 	{
212*cdf0e10cSrcweir 		Reference< XContent > xContent
213*cdf0e10cSrcweir 								= m_pImpl->m_aResults[ nIndex ]->xContent;
214*cdf0e10cSrcweir 		if ( xContent.is() )
215*cdf0e10cSrcweir 		{
216*cdf0e10cSrcweir 			// Already cached.
217*cdf0e10cSrcweir 			return xContent;
218*cdf0e10cSrcweir 		}
219*cdf0e10cSrcweir 	}
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	Reference< XContentIdentifier > xId = queryContentIdentifier( nIndex );
222*cdf0e10cSrcweir 	if ( xId.is() )
223*cdf0e10cSrcweir 	{
224*cdf0e10cSrcweir 		try
225*cdf0e10cSrcweir 		{
226*cdf0e10cSrcweir 			Reference< XContent > xContent
227*cdf0e10cSrcweir 				= m_pImpl->m_xContent->getProvider()->queryContent( xId );
228*cdf0e10cSrcweir 			m_pImpl->m_aResults[ nIndex ]->xContent = xContent;
229*cdf0e10cSrcweir 			return xContent;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 		}
232*cdf0e10cSrcweir 		catch ( IllegalIdentifierException& )
233*cdf0e10cSrcweir 		{
234*cdf0e10cSrcweir 		}
235*cdf0e10cSrcweir 	}
236*cdf0e10cSrcweir 	return Reference< XContent >();
237*cdf0e10cSrcweir }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir //=========================================================================
240*cdf0e10cSrcweir // virtual
241*cdf0e10cSrcweir sal_Bool DataSupplier::getResult( sal_uInt32 nIndex )
242*cdf0e10cSrcweir {
243*cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	if ( m_pImpl->m_aResults.size() > nIndex )
246*cdf0e10cSrcweir 	{
247*cdf0e10cSrcweir 		// Result already present.
248*cdf0e10cSrcweir 		return sal_True;
249*cdf0e10cSrcweir 	}
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 	// Result not (yet) present.
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 	if ( m_pImpl->m_bCountFinal )
254*cdf0e10cSrcweir 		return sal_False;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	// Try to obtain result...
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 	sal_uInt32 nOldCount = m_pImpl->m_aResults.size();
259*cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
260*cdf0e10cSrcweir //	sal_uInt32 nPos = nOldCount;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	// @@@ Obtain data and put it into result list...
263*cdf0e10cSrcweir /*
264*cdf0e10cSrcweir 	while ( m_pImpl->m_aFolder.next( m_pImpl->m_aIterator ) )
265*cdf0e10cSrcweir 	{
266*cdf0e10cSrcweir 		m_pImpl->m_aResults.push_back(
267*cdf0e10cSrcweir 						new ResultListEntry( *m_pImpl->m_aIterator ) );
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 		if ( nPos == nIndex )
270*cdf0e10cSrcweir 		{
271*cdf0e10cSrcweir 			// Result obtained.
272*cdf0e10cSrcweir 			bFound = sal_True;
273*cdf0e10cSrcweir 			break;
274*cdf0e10cSrcweir 		}
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 		nPos++;
277*cdf0e10cSrcweir 	}
278*cdf0e10cSrcweir */
279*cdf0e10cSrcweir 	// now query for all documents in the DMS
280*cdf0e10cSrcweir 	OSL_ENSURE(ContentProvider::getHandle(),"No Handle!");
281*cdf0e10cSrcweir 	sal_Char* pQueryId		= new sal_Char[ODM_QUERYID_MAX];
282*cdf0e10cSrcweir 	sal_Char* lpszDMSList	= new sal_Char[ODM_DMSID_MAX];
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	ODMSTATUS odm = NODMGetDMS(ODMA_ODMA_REGNAME, lpszDMSList);
285*cdf0e10cSrcweir 	lpszDMSList[strlen(lpszDMSList)+1] = '\0';
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	::rtl::OString sQuery("SELECT ODM_DOCID, ODM_NAME");
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	DWORD dwFlags = ODM_SPECIFIC;
290*cdf0e10cSrcweir 	odm = NODMQueryExecute(ContentProvider::getHandle(), sQuery,dwFlags, lpszDMSList, pQueryId );
291*cdf0e10cSrcweir 	if(odm != ODM_SUCCESS)
292*cdf0e10cSrcweir 		return sal_False;
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 	sal_uInt16 nCount		= 10;
295*cdf0e10cSrcweir 	sal_uInt16 nMaxCount	= 10;
296*cdf0e10cSrcweir 	sal_Char* lpszDocId		= new sal_Char[ODM_DOCID_MAX * nMaxCount];
297*cdf0e10cSrcweir 	sal_Char* lpszDocName	= new sal_Char[ODM_NAME_MAX * nMaxCount];
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 	::rtl::OUString sContentType(RTL_CONSTASCII_USTRINGPARAM(ODMA_CONTENT_TYPE));
301*cdf0e10cSrcweir 	sal_uInt32 nCurrentCount = 0;
302*cdf0e10cSrcweir 	do
303*cdf0e10cSrcweir 	{
304*cdf0e10cSrcweir 		if(nCount >= nMaxCount)
305*cdf0e10cSrcweir 		{
306*cdf0e10cSrcweir 			nCount = nMaxCount;
307*cdf0e10cSrcweir 			odm = NODMQueryGetResults(ContentProvider::getHandle(), pQueryId,lpszDocId, lpszDocName, ODM_NAME_MAX, (WORD*)&nCount);
308*cdf0e10cSrcweir 			nCurrentCount += nCount;
309*cdf0e10cSrcweir 		}
310*cdf0e10cSrcweir 		if(odm == ODM_SUCCESS && nIndex < nCurrentCount)
311*cdf0e10cSrcweir 		{
312*cdf0e10cSrcweir 			bFound = sal_True;
313*cdf0e10cSrcweir 			for(sal_uInt16 i = 0; i < nCount; ++i)
314*cdf0e10cSrcweir 			{
315*cdf0e10cSrcweir 				::rtl::Reference<ContentProperties> rProps = new ContentProperties();
316*cdf0e10cSrcweir 				rProps->m_sDocumentId	= ::rtl::OString(&lpszDocId[ODM_DOCID_MAX*i]);
317*cdf0e10cSrcweir 				rProps->m_sContentType	= sContentType;
318*cdf0e10cSrcweir 				m_pImpl->m_xContent->getContentProvider()->append(rProps);
319*cdf0e10cSrcweir 				m_pImpl->m_aResults.push_back( new ResultListEntry(rProps));
320*cdf0e10cSrcweir 			}
321*cdf0e10cSrcweir 		}
322*cdf0e10cSrcweir 	}
323*cdf0e10cSrcweir 	while(nCount > nMaxCount);
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	// now close the query
327*cdf0e10cSrcweir 	odm = NODMQueryClose(ContentProvider::getHandle(), pQueryId);
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	delete [] lpszDMSList;
330*cdf0e10cSrcweir 	delete [] pQueryId;
331*cdf0e10cSrcweir 	delete [] lpszDocId;
332*cdf0e10cSrcweir 	delete [] lpszDocName;
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 	if ( !bFound )
335*cdf0e10cSrcweir 		m_pImpl->m_bCountFinal = sal_True;
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	rtl::Reference< ucbhelper::ResultSet > xResultSet = getResultSet();
338*cdf0e10cSrcweir 	if ( xResultSet.is() )
339*cdf0e10cSrcweir 	{
340*cdf0e10cSrcweir 		// Callbacks follow!
341*cdf0e10cSrcweir 		aGuard.clear();
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 		if ( nOldCount < m_pImpl->m_aResults.size() )
344*cdf0e10cSrcweir 			xResultSet->rowCountChanged(
345*cdf0e10cSrcweir 									nOldCount, m_pImpl->m_aResults.size() );
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 		if ( m_pImpl->m_bCountFinal )
348*cdf0e10cSrcweir 			xResultSet->rowCountFinal();
349*cdf0e10cSrcweir 	}
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 	return bFound;
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir //=========================================================================
355*cdf0e10cSrcweir // virtual
356*cdf0e10cSrcweir sal_uInt32 DataSupplier::totalCount()
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 	if ( m_pImpl->m_bCountFinal )
361*cdf0e10cSrcweir 		return m_pImpl->m_aResults.size();
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	sal_uInt32 nOldCount = m_pImpl->m_aResults.size();
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 	// @@@ Obtain data and put it into result list...
366*cdf0e10cSrcweir /*
367*cdf0e10cSrcweir 	while ( m_pImpl->m_aFolder.next( m_pImpl->m_aIterator ) )
368*cdf0e10cSrcweir 		m_pImpl->m_aResults.push_back(
369*cdf0e10cSrcweir 						new ResultListEntry( *m_pImpl->m_aIterator ) );
370*cdf0e10cSrcweir */
371*cdf0e10cSrcweir 	m_pImpl->m_bCountFinal = sal_True;
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 	rtl::Reference< ucbhelper::ResultSet > xResultSet = getResultSet();
374*cdf0e10cSrcweir 	if ( xResultSet.is() )
375*cdf0e10cSrcweir 	{
376*cdf0e10cSrcweir 		// Callbacks follow!
377*cdf0e10cSrcweir 		aGuard.clear();
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 		if ( nOldCount < m_pImpl->m_aResults.size() )
380*cdf0e10cSrcweir 			xResultSet->rowCountChanged(
381*cdf0e10cSrcweir 									nOldCount, m_pImpl->m_aResults.size() );
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 		xResultSet->rowCountFinal();
384*cdf0e10cSrcweir 	}
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 	return m_pImpl->m_aResults.size();
387*cdf0e10cSrcweir }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir //=========================================================================
390*cdf0e10cSrcweir // virtual
391*cdf0e10cSrcweir sal_uInt32 DataSupplier::currentCount()
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir 	return m_pImpl->m_aResults.size();
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir //=========================================================================
397*cdf0e10cSrcweir // virtual
398*cdf0e10cSrcweir sal_Bool DataSupplier::isCountFinal()
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir 	return m_pImpl->m_bCountFinal;
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir //=========================================================================
404*cdf0e10cSrcweir // virtual
405*cdf0e10cSrcweir Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex  )
406*cdf0e10cSrcweir {
407*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
410*cdf0e10cSrcweir 	{
411*cdf0e10cSrcweir 		Reference< XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow;
412*cdf0e10cSrcweir 		if ( xRow.is() )
413*cdf0e10cSrcweir 		{
414*cdf0e10cSrcweir 			// Already cached.
415*cdf0e10cSrcweir 			return xRow;
416*cdf0e10cSrcweir 		}
417*cdf0e10cSrcweir 	}
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 	if ( getResult( nIndex ) )
420*cdf0e10cSrcweir 	{
421*cdf0e10cSrcweir 		Reference< XRow > xRow = Content::getPropertyValues(
422*cdf0e10cSrcweir 									m_pImpl->m_xSMgr,
423*cdf0e10cSrcweir 									getResultSet()->getProperties(),
424*cdf0e10cSrcweir 									m_pImpl->m_aResults[ nIndex ]->rData,
425*cdf0e10cSrcweir 									m_pImpl->m_xContent->getProvider(),
426*cdf0e10cSrcweir 									queryContentIdentifierString( nIndex ) );
427*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xRow = xRow;
428*cdf0e10cSrcweir 		return xRow;
429*cdf0e10cSrcweir 	}
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 	return Reference< XRow >();
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir //=========================================================================
435*cdf0e10cSrcweir // virtual
436*cdf0e10cSrcweir void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
441*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xRow = Reference< XRow >();
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir //=========================================================================
445*cdf0e10cSrcweir // virtual
446*cdf0e10cSrcweir void DataSupplier::close()
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir //=========================================================================
451*cdf0e10cSrcweir // virtual
452*cdf0e10cSrcweir void DataSupplier::validate()
453*cdf0e10cSrcweir 	throw( ResultSetException )
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir }
456