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 <osl/diagnose.h>
39*cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
41*cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
42*cdf0e10cSrcweir #include <ucbhelper/providerhelper.hxx>
43*cdf0e10cSrcweir #include "pkgdatasupplier.hxx"
44*cdf0e10cSrcweir #include "pkgcontent.hxx"
45*cdf0e10cSrcweir #include "pkgprovider.hxx"
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include "../inc/urihelper.hxx"
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir using namespace com::sun::star;
50*cdf0e10cSrcweir using namespace package_ucp;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace package_ucp
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir //=========================================================================
56*cdf0e10cSrcweir //
57*cdf0e10cSrcweir // struct ResultListEntry.
58*cdf0e10cSrcweir //
59*cdf0e10cSrcweir //=========================================================================
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir struct ResultListEntry
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir     rtl::OUString                             aURL;
64*cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId;
65*cdf0e10cSrcweir     uno::Reference< ucb::XContent >           xContent;
66*cdf0e10cSrcweir     uno::Reference< sdbc::XRow >              xRow;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     ResultListEntry( const rtl::OUString& rURL ) : aURL( rURL ) {}
69*cdf0e10cSrcweir };
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir //=========================================================================
72*cdf0e10cSrcweir //
73*cdf0e10cSrcweir // ResultList.
74*cdf0e10cSrcweir //
75*cdf0e10cSrcweir //=========================================================================
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir typedef std::vector< ResultListEntry* > ResultList;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir //=========================================================================
80*cdf0e10cSrcweir //
81*cdf0e10cSrcweir // struct DataSupplier_Impl.
82*cdf0e10cSrcweir //
83*cdf0e10cSrcweir //=========================================================================
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir struct DataSupplier_Impl
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     osl::Mutex                                   m_aMutex;
88*cdf0e10cSrcweir     ResultList                                   m_aResults;
89*cdf0e10cSrcweir     rtl::Reference< Content >                    m_xContent;
90*cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
91*cdf0e10cSrcweir     uno::Reference< container::XEnumeration >    m_xFolderEnum;
92*cdf0e10cSrcweir     sal_Int32                                    m_nOpenMode;
93*cdf0e10cSrcweir     sal_Bool                                     m_bCountFinal;
94*cdf0e10cSrcweir     sal_Bool                                     m_bThrowException;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     DataSupplier_Impl(
97*cdf0e10cSrcweir             const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
98*cdf0e10cSrcweir             const rtl::Reference< Content >& rContent,
99*cdf0e10cSrcweir             sal_Int32 nOpenMode )
100*cdf0e10cSrcweir 	: m_xContent( rContent ), m_xSMgr( rxSMgr ),
101*cdf0e10cSrcweir       m_xFolderEnum( rContent->getIterator() ), m_nOpenMode( nOpenMode ),
102*cdf0e10cSrcweir       m_bCountFinal( !m_xFolderEnum.is() ), m_bThrowException( m_bCountFinal )
103*cdf0e10cSrcweir     {}
104*cdf0e10cSrcweir 	~DataSupplier_Impl();
105*cdf0e10cSrcweir };
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir //=========================================================================
108*cdf0e10cSrcweir DataSupplier_Impl::~DataSupplier_Impl()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir 	ResultList::const_iterator it  = m_aResults.begin();
111*cdf0e10cSrcweir 	ResultList::const_iterator end = m_aResults.end();
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	while ( it != end )
114*cdf0e10cSrcweir 	{
115*cdf0e10cSrcweir 		delete (*it);
116*cdf0e10cSrcweir 		it++;
117*cdf0e10cSrcweir 	}
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir //=========================================================================
123*cdf0e10cSrcweir //=========================================================================
124*cdf0e10cSrcweir //
125*cdf0e10cSrcweir // DataSupplier Implementation.
126*cdf0e10cSrcweir //
127*cdf0e10cSrcweir //=========================================================================
128*cdf0e10cSrcweir //=========================================================================
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir DataSupplier::DataSupplier(
131*cdf0e10cSrcweir                 const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
132*cdf0e10cSrcweir                 const rtl::Reference< Content >& rContent,
133*cdf0e10cSrcweir                 sal_Int32 nOpenMode )
134*cdf0e10cSrcweir : m_pImpl( new DataSupplier_Impl( rxSMgr, rContent, nOpenMode ) )
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir //=========================================================================
139*cdf0e10cSrcweir // virtual
140*cdf0e10cSrcweir DataSupplier::~DataSupplier()
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	delete m_pImpl;
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir //=========================================================================
146*cdf0e10cSrcweir // virtual
147*cdf0e10cSrcweir rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
152*cdf0e10cSrcweir 	{
153*cdf0e10cSrcweir         rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aURL;
154*cdf0e10cSrcweir 		if ( aId.getLength() )
155*cdf0e10cSrcweir 		{
156*cdf0e10cSrcweir 			// Already cached.
157*cdf0e10cSrcweir 			return aId;
158*cdf0e10cSrcweir 		}
159*cdf0e10cSrcweir 	}
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	if ( getResult( nIndex ) )
162*cdf0e10cSrcweir 	{
163*cdf0e10cSrcweir 		// Note: getResult fills m_pImpl->m_aResults[ nIndex ]->aURL.
164*cdf0e10cSrcweir 		return m_pImpl->m_aResults[ nIndex ]->aURL;
165*cdf0e10cSrcweir 	}
166*cdf0e10cSrcweir     return rtl::OUString();
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir //=========================================================================
170*cdf0e10cSrcweir // virtual
171*cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier >
172*cdf0e10cSrcweir DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
177*cdf0e10cSrcweir 	{
178*cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > xId
179*cdf0e10cSrcweir 								= m_pImpl->m_aResults[ nIndex ]->xId;
180*cdf0e10cSrcweir 		if ( xId.is() )
181*cdf0e10cSrcweir 		{
182*cdf0e10cSrcweir 			// Already cached.
183*cdf0e10cSrcweir 			return xId;
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     rtl::OUString aId = queryContentIdentifierString( nIndex );
188*cdf0e10cSrcweir 	if ( aId.getLength() )
189*cdf0e10cSrcweir 	{
190*cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > xId
191*cdf0e10cSrcweir             = new ::ucbhelper::ContentIdentifier( aId );
192*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xId = xId;
193*cdf0e10cSrcweir 		return xId;
194*cdf0e10cSrcweir 	}
195*cdf0e10cSrcweir     return uno::Reference< ucb::XContentIdentifier >();
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir //=========================================================================
199*cdf0e10cSrcweir // virtual
200*cdf0e10cSrcweir uno::Reference< ucb::XContent > DataSupplier::queryContent(
201*cdf0e10cSrcweir                                                         sal_uInt32 nIndex )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
206*cdf0e10cSrcweir 	{
207*cdf0e10cSrcweir         uno::Reference< ucb::XContent > xContent
208*cdf0e10cSrcweir 								= m_pImpl->m_aResults[ nIndex ]->xContent;
209*cdf0e10cSrcweir 		if ( xContent.is() )
210*cdf0e10cSrcweir 		{
211*cdf0e10cSrcweir 			// Already cached.
212*cdf0e10cSrcweir 			return xContent;
213*cdf0e10cSrcweir 		}
214*cdf0e10cSrcweir 	}
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId
217*cdf0e10cSrcweir         = queryContentIdentifier( nIndex );
218*cdf0e10cSrcweir 	if ( xId.is() )
219*cdf0e10cSrcweir 	{
220*cdf0e10cSrcweir 		try
221*cdf0e10cSrcweir 		{
222*cdf0e10cSrcweir             uno::Reference< ucb::XContent > xContent
223*cdf0e10cSrcweir 				= m_pImpl->m_xContent->getProvider()->queryContent( xId );
224*cdf0e10cSrcweir 			m_pImpl->m_aResults[ nIndex ]->xContent = xContent;
225*cdf0e10cSrcweir 			return xContent;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 		}
228*cdf0e10cSrcweir         catch ( ucb::IllegalIdentifierException const & )
229*cdf0e10cSrcweir 		{
230*cdf0e10cSrcweir 		}
231*cdf0e10cSrcweir 	}
232*cdf0e10cSrcweir     return uno::Reference< ucb::XContent >();
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir //=========================================================================
236*cdf0e10cSrcweir // virtual
237*cdf0e10cSrcweir sal_Bool DataSupplier::getResult( sal_uInt32 nIndex )
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	if ( m_pImpl->m_aResults.size() > nIndex )
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		// Result already present.
244*cdf0e10cSrcweir 		return sal_True;
245*cdf0e10cSrcweir 	}
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 	// Result not (yet) present.
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	if ( m_pImpl->m_bCountFinal )
250*cdf0e10cSrcweir 		return sal_False;
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	// Try to obtain result...
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	sal_uInt32 nOldCount = m_pImpl->m_aResults.size();
255*cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
256*cdf0e10cSrcweir 	sal_uInt32 nPos = nOldCount;
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 	while ( m_pImpl->m_xFolderEnum->hasMoreElements() )
259*cdf0e10cSrcweir 	{
260*cdf0e10cSrcweir 		try
261*cdf0e10cSrcweir 		{
262*cdf0e10cSrcweir             uno::Reference< container::XNamed > xNamed;
263*cdf0e10cSrcweir 			m_pImpl->m_xFolderEnum->nextElement() >>= xNamed;
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 			if ( !xNamed.is() )
266*cdf0e10cSrcweir 			{
267*cdf0e10cSrcweir                 OSL_ENSURE( sal_False,
268*cdf0e10cSrcweir 							"DataSupplier::getResult - Got no XNamed!" );
269*cdf0e10cSrcweir 				break;
270*cdf0e10cSrcweir 			}
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir             rtl::OUString aName = xNamed->getName();
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 			if ( !aName.getLength() )
275*cdf0e10cSrcweir 			{
276*cdf0e10cSrcweir                 OSL_ENSURE( sal_False,
277*cdf0e10cSrcweir 							"DataSupplier::getResult - Empty name!" );
278*cdf0e10cSrcweir 				break;
279*cdf0e10cSrcweir 			}
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 			// Assemble URL for child.
282*cdf0e10cSrcweir 			rtl::OUString aURL = assembleChildURL( aName );
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 			m_pImpl->m_aResults.push_back( new ResultListEntry( aURL ) );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 			if ( nPos == nIndex )
287*cdf0e10cSrcweir 			{
288*cdf0e10cSrcweir 				// Result obtained.
289*cdf0e10cSrcweir 				bFound = sal_True;
290*cdf0e10cSrcweir 				break;
291*cdf0e10cSrcweir 			}
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 			nPos++;
294*cdf0e10cSrcweir 		}
295*cdf0e10cSrcweir         catch ( container::NoSuchElementException const & )
296*cdf0e10cSrcweir 		{
297*cdf0e10cSrcweir             m_pImpl->m_bThrowException = sal_True;
298*cdf0e10cSrcweir 			break;
299*cdf0e10cSrcweir 		}
300*cdf0e10cSrcweir         catch ( lang::WrappedTargetException const & )
301*cdf0e10cSrcweir 		{
302*cdf0e10cSrcweir             m_pImpl->m_bThrowException = sal_True;
303*cdf0e10cSrcweir 			break;
304*cdf0e10cSrcweir 		}
305*cdf0e10cSrcweir 	}
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	if ( !bFound )
308*cdf0e10cSrcweir 		m_pImpl->m_bCountFinal = sal_True;
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir     rtl::Reference< ::ucbhelper::ResultSet > xResultSet = getResultSet().get();
311*cdf0e10cSrcweir     if ( xResultSet.is() )
312*cdf0e10cSrcweir 	{
313*cdf0e10cSrcweir 		// Callbacks follow!
314*cdf0e10cSrcweir 		aGuard.clear();
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 		if ( nOldCount < m_pImpl->m_aResults.size() )
317*cdf0e10cSrcweir 			xResultSet->rowCountChanged(
318*cdf0e10cSrcweir 									nOldCount, m_pImpl->m_aResults.size() );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 		if ( m_pImpl->m_bCountFinal )
321*cdf0e10cSrcweir 			xResultSet->rowCountFinal();
322*cdf0e10cSrcweir 	}
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	return bFound;
325*cdf0e10cSrcweir }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir //=========================================================================
328*cdf0e10cSrcweir // virtual
329*cdf0e10cSrcweir sal_uInt32 DataSupplier::totalCount()
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 	if ( m_pImpl->m_bCountFinal )
334*cdf0e10cSrcweir 		return m_pImpl->m_aResults.size();
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 	sal_uInt32 nOldCount = m_pImpl->m_aResults.size();
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 	while ( m_pImpl->m_xFolderEnum->hasMoreElements() )
339*cdf0e10cSrcweir 	{
340*cdf0e10cSrcweir 		try
341*cdf0e10cSrcweir 		{
342*cdf0e10cSrcweir             uno::Reference< container::XNamed > xNamed;
343*cdf0e10cSrcweir 			m_pImpl->m_xFolderEnum->nextElement() >>= xNamed;
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 			if ( !xNamed.is() )
346*cdf0e10cSrcweir 			{
347*cdf0e10cSrcweir                 OSL_ENSURE( sal_False,
348*cdf0e10cSrcweir 							"DataSupplier::getResult - Got no XNamed!" );
349*cdf0e10cSrcweir 				break;
350*cdf0e10cSrcweir 			}
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir             rtl::OUString aName = xNamed->getName();
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir 			if ( !aName.getLength() )
355*cdf0e10cSrcweir 			{
356*cdf0e10cSrcweir                 OSL_ENSURE( sal_False,
357*cdf0e10cSrcweir 							"DataSupplier::getResult - Empty name!" );
358*cdf0e10cSrcweir 				break;
359*cdf0e10cSrcweir 			}
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 			// Assemble URL for child.
362*cdf0e10cSrcweir 			rtl::OUString aURL = assembleChildURL( aName );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 			m_pImpl->m_aResults.push_back( new ResultListEntry( aURL ) );
365*cdf0e10cSrcweir 		}
366*cdf0e10cSrcweir         catch ( container::NoSuchElementException const & )
367*cdf0e10cSrcweir 		{
368*cdf0e10cSrcweir             m_pImpl->m_bThrowException = sal_True;
369*cdf0e10cSrcweir 			break;
370*cdf0e10cSrcweir 		}
371*cdf0e10cSrcweir         catch ( lang::WrappedTargetException const & )
372*cdf0e10cSrcweir 		{
373*cdf0e10cSrcweir             m_pImpl->m_bThrowException = sal_True;
374*cdf0e10cSrcweir 			break;
375*cdf0e10cSrcweir 		}
376*cdf0e10cSrcweir 	}
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 	m_pImpl->m_bCountFinal = sal_True;
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     rtl::Reference< ::ucbhelper::ResultSet > xResultSet = getResultSet().get();
381*cdf0e10cSrcweir     if ( xResultSet.is() )
382*cdf0e10cSrcweir 	{
383*cdf0e10cSrcweir 		// Callbacks follow!
384*cdf0e10cSrcweir 		aGuard.clear();
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 		if ( nOldCount < m_pImpl->m_aResults.size() )
387*cdf0e10cSrcweir 			xResultSet->rowCountChanged(
388*cdf0e10cSrcweir 									nOldCount, m_pImpl->m_aResults.size() );
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 		xResultSet->rowCountFinal();
391*cdf0e10cSrcweir 	}
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 	return m_pImpl->m_aResults.size();
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir //=========================================================================
397*cdf0e10cSrcweir // virtual
398*cdf0e10cSrcweir sal_uInt32 DataSupplier::currentCount()
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir 	return m_pImpl->m_aResults.size();
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir //=========================================================================
404*cdf0e10cSrcweir // virtual
405*cdf0e10cSrcweir sal_Bool DataSupplier::isCountFinal()
406*cdf0e10cSrcweir {
407*cdf0e10cSrcweir 	return m_pImpl->m_bCountFinal;
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir //=========================================================================
411*cdf0e10cSrcweir // virtual
412*cdf0e10cSrcweir uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues(
413*cdf0e10cSrcweir                                                         sal_uInt32 nIndex  )
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
418*cdf0e10cSrcweir 	{
419*cdf0e10cSrcweir         uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow;
420*cdf0e10cSrcweir 		if ( xRow.is() )
421*cdf0e10cSrcweir 		{
422*cdf0e10cSrcweir 			// Already cached.
423*cdf0e10cSrcweir 			return xRow;
424*cdf0e10cSrcweir 		}
425*cdf0e10cSrcweir 	}
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 	if ( getResult( nIndex ) )
428*cdf0e10cSrcweir 	{
429*cdf0e10cSrcweir         uno::Reference< sdbc::XRow > xRow = Content::getPropertyValues(
430*cdf0e10cSrcweir 						m_pImpl->m_xSMgr,
431*cdf0e10cSrcweir 						getResultSet()->getProperties(),
432*cdf0e10cSrcweir 						static_cast< ContentProvider * >(
433*cdf0e10cSrcweir 							m_pImpl->m_xContent->getProvider().get() ),
434*cdf0e10cSrcweir 						queryContentIdentifierString( nIndex ) );
435*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xRow = xRow;
436*cdf0e10cSrcweir 		return xRow;
437*cdf0e10cSrcweir 	}
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     return uno::Reference< sdbc::XRow >();
440*cdf0e10cSrcweir }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir //=========================================================================
443*cdf0e10cSrcweir // virtual
444*cdf0e10cSrcweir void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
445*cdf0e10cSrcweir {
446*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
449*cdf0e10cSrcweir         m_pImpl->m_aResults[ nIndex ]->xRow = uno::Reference< sdbc::XRow >();
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir //=========================================================================
453*cdf0e10cSrcweir // virtual
454*cdf0e10cSrcweir void DataSupplier::close()
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir //=========================================================================
459*cdf0e10cSrcweir // virtual
460*cdf0e10cSrcweir void DataSupplier::validate()
461*cdf0e10cSrcweir     throw( ucb::ResultSetException )
462*cdf0e10cSrcweir {
463*cdf0e10cSrcweir     if ( m_pImpl->m_bThrowException )
464*cdf0e10cSrcweir         throw ucb::ResultSetException();
465*cdf0e10cSrcweir }
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir //=========================================================================
468*cdf0e10cSrcweir ::rtl::OUString DataSupplier::assembleChildURL( const ::rtl::OUString& aName )
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir 	rtl::OUString aURL;
471*cdf0e10cSrcweir 	rtl::OUString aContURL
472*cdf0e10cSrcweir         = m_pImpl->m_xContent->getIdentifier()->getContentIdentifier();
473*cdf0e10cSrcweir 	sal_Int32 nParam = aContURL.indexOf( '?' );
474*cdf0e10cSrcweir 	if ( nParam >= 0 )
475*cdf0e10cSrcweir 	{
476*cdf0e10cSrcweir 		aURL = aContURL.copy( 0, nParam );
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 		sal_Int32 nPackageUrlEnd = aURL.lastIndexOf( '/' );
479*cdf0e10cSrcweir 		if ( nPackageUrlEnd != aURL.getLength() - 1 )
480*cdf0e10cSrcweir 			aURL += rtl::OUString::createFromAscii( "/" );
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 		aURL += ::ucb_impl::urihelper::encodeSegment( aName );
483*cdf0e10cSrcweir 		aURL += aContURL.copy( nParam );
484*cdf0e10cSrcweir 	}
485*cdf0e10cSrcweir 	else
486*cdf0e10cSrcweir 	{
487*cdf0e10cSrcweir 		aURL = aContURL;
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 		sal_Int32 nPackageUrlEnd = aURL.lastIndexOf( '/' );
490*cdf0e10cSrcweir 		if ( nPackageUrlEnd != aURL.getLength() - 1 )
491*cdf0e10cSrcweir 			aURL += rtl::OUString::createFromAscii( "/" );
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 		aURL += ::ucb_impl::urihelper::encodeSegment( aName );
494*cdf0e10cSrcweir 	}
495*cdf0e10cSrcweir 	return aURL;
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir 
499