1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cachedcontentresultset.hxx,v $
10 * $Revision: 1.5.22.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CACHED_CONTENT_RESULTSET_HXX
32 #define _CACHED_CONTENT_RESULTSET_HXX
34 #include <contentresultsetwrapper.hxx>
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/ucb/XFetchProvider.hpp>
38 #include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
39 #include <com/sun/star/ucb/FetchResult.hpp>
40 #include <com/sun/star/ucb/XContentIdentifierMapping.hpp>
41 #include <com/sun/star/ucb/XCachedContentResultSetFactory.hpp>
43 #define CACHED_CONTENT_RESULTSET_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSet"
44 #define CACHED_CONTENT_RESULTSET_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetFactory"
46 //=========================================================================
48 namespace com
{ namespace sun
{ namespace star
{ namespace script
{
52 class CCRS_PropertySetInfo
;
53 class CachedContentResultSet
54 : public ContentResultSetWrapper
55 , public com::sun::star::lang::XTypeProvider
56 , public com::sun::star::lang::XServiceInfo
58 //--------------------------------------------------------------------------
64 com::sun::star::ucb::FetchResult
* m_pResult
;
65 com::sun::star::uno::Reference
<
66 com::sun::star::ucb::XContentIdentifierMapping
>
67 m_xContentIdentifierMapping
;
68 com::sun::star::uno::Sequence
< sal_Bool
>* m_pMappedReminder
;
71 com::sun::star::uno::Any
& SAL_CALL
72 getRowAny( sal_Int32 nRow
)
73 throw( com::sun::star::sdbc::SQLException
,
74 com::sun::star::uno::RuntimeException
);
76 void SAL_CALL
clear();
79 void SAL_CALL
remindMapped( sal_Int32 nRow
);
80 sal_Bool SAL_CALL
isRowMapped( sal_Int32 nRow
);
81 void SAL_CALL
clearMappedReminder();
82 com::sun::star::uno::Sequence
< sal_Bool
>* SAL_CALL
getMappedReminder();
85 CCRS_Cache( const com::sun::star::uno::Reference
<
86 com::sun::star::ucb::XContentIdentifierMapping
> & xMapping
);
89 void SAL_CALL
loadData(
90 const com::sun::star::ucb::FetchResult
& rResult
);
93 hasRow( sal_Int32 nRow
);
96 hasCausedException( sal_Int32 nRow
);
105 const com::sun::star::uno::Any
& SAL_CALL
106 getAny( sal_Int32 nRow
, sal_Int32 nColumnIndex
)
107 throw( com::sun::star::sdbc::SQLException
,
108 com::sun::star::uno::RuntimeException
);
110 const rtl::OUString
& SAL_CALL
111 getContentIdentifierString( sal_Int32 nRow
)
112 throw( com::sun::star::uno::RuntimeException
);
114 const com::sun::star::uno::Reference
<
115 com::sun::star::ucb::XContentIdentifier
>& SAL_CALL
116 getContentIdentifier( sal_Int32 nRow
)
117 throw( com::sun::star::uno::RuntimeException
);
119 const com::sun::star::uno::Reference
<
120 com::sun::star::ucb::XContent
>& SAL_CALL
121 getContent( sal_Int32 nRow
)
122 throw( com::sun::star::uno::RuntimeException
);
124 //-----------------------------------------------------------------
127 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>
130 //different Interfaces from Origin:
131 com::sun::star::uno::Reference
< com::sun::star::ucb::XFetchProvider
>
132 m_xFetchProvider
; //XFetchProvider-interface from m_xOrigin
134 com::sun::star::uno::Reference
< com::sun::star::ucb::XFetchProviderForContentAccess
>
135 m_xFetchProviderForContentAccess
; //XFetchProviderForContentAccess-interface from m_xOrigin
138 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
>
139 m_xMyPropertySetInfo
;//holds m_pMyPropSetInfo alive
140 CCRS_PropertySetInfo
* m_pMyPropSetInfo
;
144 com::sun::star::uno::Reference
< com::sun::star::ucb::XContentIdentifierMapping
>
145 m_xContentIdentifierMapping
;// can be used for remote optimized ContentAccess
147 //some Properties and helping variables
149 sal_Bool m_bAfterLast
; // TRUE, if m_nRow is after final count; can be TRUE without knowing the exact final count
151 sal_Int32 m_nLastAppliedPos
;
152 sal_Bool m_bAfterLastApplied
;
154 sal_Int32 m_nKnownCount
; // count we know from the Origin
155 sal_Bool m_bFinalCount
; // TRUE if the Origin has reached final count and we got that count in m_nKnownCount
157 sal_Int32 m_nFetchSize
;
158 sal_Int32 m_nFetchDirection
;
160 sal_Bool m_bLastReadWasFromCache
;
161 sal_Bool m_bLastCachedReadWasNull
;
165 CCRS_Cache m_aCacheContentIdentifierString
;
166 CCRS_Cache m_aCacheContentIdentifier
;
167 CCRS_Cache m_aCacheContent
;
171 //-----------------------------------------------------------------
172 //helping XPropertySet methods.
173 virtual void SAL_CALL
impl_initPropertySetInfo();
176 //-----------------------------------------------------------------
178 applyPositionToOrigin( sal_Int32 nRow
)
179 throw( com::sun::star::sdbc::SQLException
,
180 com::sun::star::uno::RuntimeException
);
183 impl_fetchData( sal_Int32 nRow
, sal_Int32 nCount
184 , sal_Int32 nFetchDirection
)
185 throw( com::sun::star::uno::RuntimeException
);
188 impl_isKnownValidPosition( sal_Int32 nRow
);
191 impl_isKnownInvalidPosition( sal_Int32 nRow
);
194 impl_changeRowCount( sal_Int32 nOld
, sal_Int32 nNew
);
197 impl_changeIsRowCountFinal( sal_Bool bOld
, sal_Bool bNew
);
200 CachedContentResultSet(
201 const com::sun::star::uno::Reference
<
202 com::sun::star::lang::XMultiServiceFactory
> &
204 const com::sun::star::uno::Reference
<
205 com::sun::star::sdbc::XResultSet
> & xOrigin
,
206 const com::sun::star::uno::Reference
<
207 com::sun::star::ucb::XContentIdentifierMapping
> &
208 xContentIdentifierMapping
);
210 virtual ~CachedContentResultSet();
212 //-----------------------------------------------------------------
213 // XInterface inherited
214 //-----------------------------------------------------------------
216 //-----------------------------------------------------------------
218 //-----------------------------------------------------------------
220 //-----------------------------------------------------------------
222 //-----------------------------------------------------------------
223 XSERVICEINFO_NOFACTORY_DECL()
225 //-----------------------------------------------------------------
226 // XPropertySet inherited
227 //-----------------------------------------------------------------
229 virtual void SAL_CALL
230 setPropertyValue( const rtl::OUString
& aPropertyName
,
231 const com::sun::star::uno::Any
& aValue
)
232 throw( com::sun::star::beans::UnknownPropertyException
,
233 com::sun::star::beans::PropertyVetoException
,
234 com::sun::star::lang::IllegalArgumentException
,
235 com::sun::star::lang::WrappedTargetException
,
236 com::sun::star::uno::RuntimeException
);
238 virtual com::sun::star::uno::Any SAL_CALL
239 getPropertyValue( const rtl::OUString
& PropertyName
)
240 throw( com::sun::star::beans::UnknownPropertyException
,
241 com::sun::star::lang::WrappedTargetException
,
242 com::sun::star::uno::RuntimeException
);
244 //-----------------------------------------------------------------
246 //-----------------------------------------------------------------
247 virtual void SAL_CALL
248 impl_disposing( const com::sun::star::lang::EventObject
& Source
)
249 throw( com::sun::star::uno::RuntimeException
);
251 virtual void SAL_CALL
252 impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent
& evt
)
253 throw( com::sun::star::uno::RuntimeException
);
255 virtual void SAL_CALL
256 impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent
& aEvent
)
257 throw( com::sun::star::beans::PropertyVetoException
,
258 com::sun::star::uno::RuntimeException
);
260 //-----------------------------------------------------------------
261 // XContentAccess inherited
262 //-----------------------------------------------------------------
263 virtual rtl::OUString SAL_CALL
264 queryContentIdentifierString()
265 throw( com::sun::star::uno::RuntimeException
);
267 virtual com::sun::star::uno::Reference
<
268 com::sun::star::ucb::XContentIdentifier
> SAL_CALL
269 queryContentIdentifier()
270 throw( com::sun::star::uno::RuntimeException
);
272 virtual com::sun::star::uno::Reference
<
273 com::sun::star::ucb::XContent
> SAL_CALL
275 throw( com::sun::star::uno::RuntimeException
);
277 //-----------------------------------------------------------------
278 // XResultSet inherited
279 //-----------------------------------------------------------------
280 virtual sal_Bool SAL_CALL
282 throw( com::sun::star::sdbc::SQLException
,
283 com::sun::star::uno::RuntimeException
);
284 virtual sal_Bool SAL_CALL
286 throw( com::sun::star::sdbc::SQLException
,
287 com::sun::star::uno::RuntimeException
);
288 virtual sal_Bool SAL_CALL
290 throw( com::sun::star::sdbc::SQLException
,
291 com::sun::star::uno::RuntimeException
);
292 virtual sal_Bool SAL_CALL
294 throw( com::sun::star::sdbc::SQLException
,
295 com::sun::star::uno::RuntimeException
);
296 virtual sal_Bool SAL_CALL
298 throw( com::sun::star::sdbc::SQLException
,
299 com::sun::star::uno::RuntimeException
);
300 virtual void SAL_CALL
302 throw( com::sun::star::sdbc::SQLException
,
303 com::sun::star::uno::RuntimeException
);
304 virtual void SAL_CALL
306 throw( com::sun::star::sdbc::SQLException
,
307 com::sun::star::uno::RuntimeException
);
308 virtual sal_Bool SAL_CALL
310 throw( com::sun::star::sdbc::SQLException
,
311 com::sun::star::uno::RuntimeException
);
312 virtual sal_Bool SAL_CALL
314 throw( com::sun::star::sdbc::SQLException
,
315 com::sun::star::uno::RuntimeException
);
316 virtual sal_Int32 SAL_CALL
318 throw( com::sun::star::sdbc::SQLException
,
319 com::sun::star::uno::RuntimeException
);
320 virtual sal_Bool SAL_CALL
321 absolute( sal_Int32 row
)
322 throw( com::sun::star::sdbc::SQLException
,
323 com::sun::star::uno::RuntimeException
);
324 virtual sal_Bool SAL_CALL
325 relative( sal_Int32 rows
)
326 throw( com::sun::star::sdbc::SQLException
,
327 com::sun::star::uno::RuntimeException
);
328 virtual sal_Bool SAL_CALL
330 throw( com::sun::star::sdbc::SQLException
,
331 com::sun::star::uno::RuntimeException
);
332 virtual void SAL_CALL
334 throw( com::sun::star::sdbc::SQLException
,
335 com::sun::star::uno::RuntimeException
);
336 virtual sal_Bool SAL_CALL
338 throw( com::sun::star::sdbc::SQLException
,
339 com::sun::star::uno::RuntimeException
);
340 virtual sal_Bool SAL_CALL
342 throw( com::sun::star::sdbc::SQLException
,
343 com::sun::star::uno::RuntimeException
);
344 virtual sal_Bool SAL_CALL
346 throw( com::sun::star::sdbc::SQLException
,
347 com::sun::star::uno::RuntimeException
);
348 virtual com::sun::star::uno::Reference
<
349 com::sun::star::uno::XInterface
> SAL_CALL
351 throw( com::sun::star::sdbc::SQLException
,
352 com::sun::star::uno::RuntimeException
);
354 //-----------------------------------------------------------------
356 //-----------------------------------------------------------------
357 virtual sal_Bool SAL_CALL
359 throw( com::sun::star::sdbc::SQLException
,
360 com::sun::star::uno::RuntimeException
);
362 virtual rtl::OUString SAL_CALL
363 getString( sal_Int32 columnIndex
)
364 throw( com::sun::star::sdbc::SQLException
,
365 com::sun::star::uno::RuntimeException
);
367 virtual sal_Bool SAL_CALL
368 getBoolean( sal_Int32 columnIndex
)
369 throw( com::sun::star::sdbc::SQLException
,
370 com::sun::star::uno::RuntimeException
);
372 virtual sal_Int8 SAL_CALL
373 getByte( sal_Int32 columnIndex
)
374 throw( com::sun::star::sdbc::SQLException
,
375 com::sun::star::uno::RuntimeException
);
377 virtual sal_Int16 SAL_CALL
378 getShort( sal_Int32 columnIndex
)
379 throw( com::sun::star::sdbc::SQLException
,
380 com::sun::star::uno::RuntimeException
);
382 virtual sal_Int32 SAL_CALL
383 getInt( sal_Int32 columnIndex
)
384 throw( com::sun::star::sdbc::SQLException
,
385 com::sun::star::uno::RuntimeException
);
387 virtual sal_Int64 SAL_CALL
388 getLong( sal_Int32 columnIndex
)
389 throw( com::sun::star::sdbc::SQLException
,
390 com::sun::star::uno::RuntimeException
);
392 virtual float SAL_CALL
393 getFloat( sal_Int32 columnIndex
)
394 throw( com::sun::star::sdbc::SQLException
,
395 com::sun::star::uno::RuntimeException
);
397 virtual double SAL_CALL
398 getDouble( sal_Int32 columnIndex
)
399 throw( com::sun::star::sdbc::SQLException
,
400 com::sun::star::uno::RuntimeException
);
402 virtual com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
403 getBytes( sal_Int32 columnIndex
)
404 throw( com::sun::star::sdbc::SQLException
,
405 com::sun::star::uno::RuntimeException
);
407 virtual com::sun::star::util::Date SAL_CALL
408 getDate( sal_Int32 columnIndex
)
409 throw( com::sun::star::sdbc::SQLException
,
410 com::sun::star::uno::RuntimeException
);
412 virtual com::sun::star::util::Time SAL_CALL
413 getTime( sal_Int32 columnIndex
)
414 throw( com::sun::star::sdbc::SQLException
,
415 com::sun::star::uno::RuntimeException
);
417 virtual com::sun::star::util::DateTime SAL_CALL
418 getTimestamp( sal_Int32 columnIndex
)
419 throw( com::sun::star::sdbc::SQLException
,
420 com::sun::star::uno::RuntimeException
);
422 virtual com::sun::star::uno::Reference
<
423 com::sun::star::io::XInputStream
> SAL_CALL
424 getBinaryStream( sal_Int32 columnIndex
)
425 throw( com::sun::star::sdbc::SQLException
,
426 com::sun::star::uno::RuntimeException
);
428 virtual com::sun::star::uno::Reference
<
429 com::sun::star::io::XInputStream
> SAL_CALL
430 getCharacterStream( sal_Int32 columnIndex
)
431 throw( com::sun::star::sdbc::SQLException
,
432 com::sun::star::uno::RuntimeException
);
434 virtual com::sun::star::uno::Any SAL_CALL
435 getObject( sal_Int32 columnIndex
,
436 const com::sun::star::uno::Reference
<
437 com::sun::star::container::XNameAccess
>& typeMap
)
438 throw( com::sun::star::sdbc::SQLException
,
439 com::sun::star::uno::RuntimeException
);
441 virtual com::sun::star::uno::Reference
<
442 com::sun::star::sdbc::XRef
> SAL_CALL
443 getRef( sal_Int32 columnIndex
)
444 throw( com::sun::star::sdbc::SQLException
,
445 com::sun::star::uno::RuntimeException
);
447 virtual com::sun::star::uno::Reference
<
448 com::sun::star::sdbc::XBlob
> SAL_CALL
449 getBlob( sal_Int32 columnIndex
)
450 throw( com::sun::star::sdbc::SQLException
,
451 com::sun::star::uno::RuntimeException
);
453 virtual com::sun::star::uno::Reference
<
454 com::sun::star::sdbc::XClob
> SAL_CALL
455 getClob( sal_Int32 columnIndex
)
456 throw( com::sun::star::sdbc::SQLException
,
457 com::sun::star::uno::RuntimeException
);
459 virtual com::sun::star::uno::Reference
<
460 com::sun::star::sdbc::XArray
> SAL_CALL
461 getArray( sal_Int32 columnIndex
)
462 throw( com::sun::star::sdbc::SQLException
,
463 com::sun::star::uno::RuntimeException
);
465 //-----------------------------------------------------------------
466 // Type Converter support
467 //-----------------------------------------------------------------
470 sal_Bool m_bTriedToGetTypeConverter
;
471 com::sun::star::uno::Reference
<
472 com::sun::star::script::XTypeConverter
> m_xTypeConverter
;
474 const com::sun::star::uno::Reference
<
475 com::sun::star::script::XTypeConverter
>& getTypeConverter();
478 //=========================================================================
480 class CachedContentResultSetFactory
481 : public cppu::OWeakObject
482 , public com::sun::star::lang::XTypeProvider
483 , public com::sun::star::lang::XServiceInfo
484 , public com::sun::star::ucb::XCachedContentResultSetFactory
487 com::sun::star::uno::Reference
<
488 com::sun::star::lang::XMultiServiceFactory
> m_xSMgr
;
492 CachedContentResultSetFactory(
493 const com::sun::star::uno::Reference
<
494 com::sun::star::lang::XMultiServiceFactory
> & rSMgr
);
496 virtual ~CachedContentResultSetFactory();
498 //-----------------------------------------------------------------
502 //-----------------------------------------------------------------
506 //-----------------------------------------------------------------
510 //-----------------------------------------------------------------
511 // XCachedContentResultSetFactory
513 virtual com::sun::star::uno::Reference
<
514 com::sun::star::sdbc::XResultSet
> SAL_CALL
515 createCachedContentResultSet(
516 const com::sun::star::uno::Reference
<
517 com::sun::star::sdbc::XResultSet
> & xSource
,
518 const com::sun::star::uno::Reference
<
519 com::sun::star::ucb::XContentIdentifierMapping
> & xMapping
)
520 throw( com::sun::star::uno::RuntimeException
);