Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / ucb / source / cacher / cachedcontentresultset.hxx
blob1f15bc5017a7049ea4717bec4eb1940522757b59
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _CACHED_CONTENT_RESULTSET_HXX
21 #define _CACHED_CONTENT_RESULTSET_HXX
23 #include <contentresultsetwrapper.hxx>
24 #include <com/sun/star/lang/XTypeProvider.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/ucb/XFetchProvider.hpp>
27 #include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
28 #include <com/sun/star/ucb/FetchResult.hpp>
29 #include <com/sun/star/ucb/XContentIdentifierMapping.hpp>
30 #include <com/sun/star/ucb/XCachedContentResultSetFactory.hpp>
32 #define CACHED_CONTENT_RESULTSET_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSet"
33 #define CACHED_CONTENT_RESULTSET_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetFactory"
35 //=========================================================================
37 namespace com { namespace sun { namespace star { namespace script {
38 class XTypeConverter;
39 } } } }
41 class CCRS_PropertySetInfo;
42 class CachedContentResultSet
43 : public ContentResultSetWrapper
44 , public com::sun::star::lang::XTypeProvider
45 , public com::sun::star::lang::XServiceInfo
47 //--------------------------------------------------------------------------
48 // class CCRS_Cache
50 class CCRS_Cache
52 private:
53 com::sun::star::ucb::FetchResult* m_pResult;
54 com::sun::star::uno::Reference<
55 com::sun::star::ucb::XContentIdentifierMapping >
56 m_xContentIdentifierMapping;
57 com::sun::star::uno::Sequence< sal_Bool >* m_pMappedReminder;
59 private:
60 com::sun::star::uno::Any& SAL_CALL
61 getRowAny( sal_Int32 nRow )
62 throw( com::sun::star::sdbc::SQLException,
63 com::sun::star::uno::RuntimeException );
65 void SAL_CALL clear();
68 void SAL_CALL remindMapped( sal_Int32 nRow );
69 sal_Bool SAL_CALL isRowMapped( sal_Int32 nRow );
70 void SAL_CALL clearMappedReminder();
71 com::sun::star::uno::Sequence< sal_Bool >* SAL_CALL getMappedReminder();
73 public:
74 CCRS_Cache( const com::sun::star::uno::Reference<
75 com::sun::star::ucb::XContentIdentifierMapping > & xMapping );
76 ~CCRS_Cache();
78 void SAL_CALL loadData(
79 const com::sun::star::ucb::FetchResult& rResult );
81 sal_Bool SAL_CALL
82 hasRow( sal_Int32 nRow );
84 sal_Bool SAL_CALL
85 hasCausedException( sal_Int32 nRow );
87 sal_Int32 SAL_CALL
88 getMaxRow();
90 sal_Bool SAL_CALL
91 hasKnownLast();
93 //---
94 const com::sun::star::uno::Any& SAL_CALL
95 getAny( sal_Int32 nRow, sal_Int32 nColumnIndex )
96 throw( com::sun::star::sdbc::SQLException,
97 com::sun::star::uno::RuntimeException );
99 const rtl::OUString& SAL_CALL
100 getContentIdentifierString( sal_Int32 nRow )
101 throw( com::sun::star::uno::RuntimeException );
103 const com::sun::star::uno::Reference<
104 com::sun::star::ucb::XContentIdentifier >& SAL_CALL
105 getContentIdentifier( sal_Int32 nRow )
106 throw( com::sun::star::uno::RuntimeException );
108 const com::sun::star::uno::Reference<
109 com::sun::star::ucb::XContent >& SAL_CALL
110 getContent( sal_Int32 nRow )
111 throw( com::sun::star::uno::RuntimeException );
113 //-----------------------------------------------------------------
114 //members
116 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
117 m_xContext;
119 //different Interfaces from Origin:
120 com::sun::star::uno::Reference< com::sun::star::ucb::XFetchProvider >
121 m_xFetchProvider; //XFetchProvider-interface from m_xOrigin
123 com::sun::star::uno::Reference< com::sun::star::ucb::XFetchProviderForContentAccess >
124 m_xFetchProviderForContentAccess; //XFetchProviderForContentAccess-interface from m_xOrigin
126 //my PropertySetInfo
127 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
128 m_xMyPropertySetInfo;//holds m_pMyPropSetInfo alive
129 CCRS_PropertySetInfo* m_pMyPropSetInfo;
133 com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifierMapping >
134 m_xContentIdentifierMapping;// can be used for remote optimized ContentAccess
136 //some Properties and helping variables
137 sal_Int32 m_nRow;
138 sal_Bool m_bAfterLast; // TRUE, if m_nRow is after final count; can be TRUE without knowing the exact final count
140 sal_Int32 m_nLastAppliedPos;
141 sal_Bool m_bAfterLastApplied;
143 sal_Int32 m_nKnownCount; // count we know from the Origin
144 sal_Bool m_bFinalCount; // TRUE if the Origin has reached final count and we got that count in m_nKnownCount
146 sal_Int32 m_nFetchSize;
147 sal_Int32 m_nFetchDirection;
149 sal_Bool m_bLastReadWasFromCache;
150 sal_Bool m_bLastCachedReadWasNull;
152 //cache:
153 CCRS_Cache m_aCache;
154 CCRS_Cache m_aCacheContentIdentifierString;
155 CCRS_Cache m_aCacheContentIdentifier;
156 CCRS_Cache m_aCacheContent;
159 private:
160 //-----------------------------------------------------------------
161 //helping XPropertySet methods.
162 virtual void SAL_CALL impl_initPropertySetInfo();
165 //-----------------------------------------------------------------
166 sal_Bool SAL_CALL
167 applyPositionToOrigin( sal_Int32 nRow )
168 throw( com::sun::star::sdbc::SQLException,
169 com::sun::star::uno::RuntimeException );
171 void SAL_CALL
172 impl_fetchData( sal_Int32 nRow, sal_Int32 nCount
173 , sal_Int32 nFetchDirection )
174 throw( com::sun::star::uno::RuntimeException );
176 sal_Bool SAL_CALL
177 impl_isKnownValidPosition( sal_Int32 nRow );
179 sal_Bool SAL_CALL
180 impl_isKnownInvalidPosition( sal_Int32 nRow );
182 void SAL_CALL
183 impl_changeRowCount( sal_Int32 nOld, sal_Int32 nNew );
185 void SAL_CALL
186 impl_changeIsRowCountFinal( sal_Bool bOld, sal_Bool bNew );
188 public:
189 CachedContentResultSet(
190 const com::sun::star::uno::Reference<
191 com::sun::star::uno::XComponentContext > &
192 rxContext,
193 const com::sun::star::uno::Reference<
194 com::sun::star::sdbc::XResultSet > & xOrigin,
195 const com::sun::star::uno::Reference<
196 com::sun::star::ucb::XContentIdentifierMapping > &
197 xContentIdentifierMapping );
199 virtual ~CachedContentResultSet();
201 //-----------------------------------------------------------------
202 // XInterface inherited
203 //-----------------------------------------------------------------
204 XINTERFACE_DECL()
205 //-----------------------------------------------------------------
206 // XTypeProvider
207 //-----------------------------------------------------------------
208 XTYPEPROVIDER_DECL()
209 //-----------------------------------------------------------------
210 // XServiceInfo
211 //-----------------------------------------------------------------
212 XSERVICEINFO_NOFACTORY_DECL()
214 //-----------------------------------------------------------------
215 // XPropertySet inherited
216 //-----------------------------------------------------------------
218 virtual void SAL_CALL
219 setPropertyValue( const rtl::OUString& aPropertyName,
220 const com::sun::star::uno::Any& aValue )
221 throw( com::sun::star::beans::UnknownPropertyException,
222 com::sun::star::beans::PropertyVetoException,
223 com::sun::star::lang::IllegalArgumentException,
224 com::sun::star::lang::WrappedTargetException,
225 com::sun::star::uno::RuntimeException );
227 virtual com::sun::star::uno::Any SAL_CALL
228 getPropertyValue( const rtl::OUString& PropertyName )
229 throw( com::sun::star::beans::UnknownPropertyException,
230 com::sun::star::lang::WrappedTargetException,
231 com::sun::star::uno::RuntimeException );
233 //-----------------------------------------------------------------
234 // own inherited
235 //-----------------------------------------------------------------
236 virtual void SAL_CALL
237 impl_disposing( const com::sun::star::lang::EventObject& Source )
238 throw( com::sun::star::uno::RuntimeException );
240 virtual void SAL_CALL
241 impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
242 throw( com::sun::star::uno::RuntimeException );
244 virtual void SAL_CALL
245 impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
246 throw( com::sun::star::beans::PropertyVetoException,
247 com::sun::star::uno::RuntimeException );
249 //-----------------------------------------------------------------
250 // XContentAccess inherited
251 //-----------------------------------------------------------------
252 virtual rtl::OUString SAL_CALL
253 queryContentIdentifierString()
254 throw( com::sun::star::uno::RuntimeException );
256 virtual com::sun::star::uno::Reference<
257 com::sun::star::ucb::XContentIdentifier > SAL_CALL
258 queryContentIdentifier()
259 throw( com::sun::star::uno::RuntimeException );
261 virtual com::sun::star::uno::Reference<
262 com::sun::star::ucb::XContent > SAL_CALL
263 queryContent()
264 throw( com::sun::star::uno::RuntimeException );
266 //-----------------------------------------------------------------
267 // XResultSet inherited
268 //-----------------------------------------------------------------
269 virtual sal_Bool SAL_CALL
270 next()
271 throw( com::sun::star::sdbc::SQLException,
272 com::sun::star::uno::RuntimeException );
273 virtual sal_Bool SAL_CALL
274 isBeforeFirst()
275 throw( com::sun::star::sdbc::SQLException,
276 com::sun::star::uno::RuntimeException );
277 virtual sal_Bool SAL_CALL
278 isAfterLast()
279 throw( com::sun::star::sdbc::SQLException,
280 com::sun::star::uno::RuntimeException );
281 virtual sal_Bool SAL_CALL
282 isFirst()
283 throw( com::sun::star::sdbc::SQLException,
284 com::sun::star::uno::RuntimeException );
285 virtual sal_Bool SAL_CALL
286 isLast()
287 throw( com::sun::star::sdbc::SQLException,
288 com::sun::star::uno::RuntimeException );
289 virtual void SAL_CALL
290 beforeFirst()
291 throw( com::sun::star::sdbc::SQLException,
292 com::sun::star::uno::RuntimeException );
293 virtual void SAL_CALL
294 afterLast()
295 throw( com::sun::star::sdbc::SQLException,
296 com::sun::star::uno::RuntimeException );
297 virtual sal_Bool SAL_CALL
298 first()
299 throw( com::sun::star::sdbc::SQLException,
300 com::sun::star::uno::RuntimeException );
301 virtual sal_Bool SAL_CALL
302 last()
303 throw( com::sun::star::sdbc::SQLException,
304 com::sun::star::uno::RuntimeException );
305 virtual sal_Int32 SAL_CALL
306 getRow()
307 throw( com::sun::star::sdbc::SQLException,
308 com::sun::star::uno::RuntimeException );
309 virtual sal_Bool SAL_CALL
310 absolute( sal_Int32 row )
311 throw( com::sun::star::sdbc::SQLException,
312 com::sun::star::uno::RuntimeException );
313 virtual sal_Bool SAL_CALL
314 relative( sal_Int32 rows )
315 throw( com::sun::star::sdbc::SQLException,
316 com::sun::star::uno::RuntimeException );
317 virtual sal_Bool SAL_CALL
318 previous()
319 throw( com::sun::star::sdbc::SQLException,
320 com::sun::star::uno::RuntimeException );
321 virtual void SAL_CALL
322 refreshRow()
323 throw( com::sun::star::sdbc::SQLException,
324 com::sun::star::uno::RuntimeException );
325 virtual sal_Bool SAL_CALL
326 rowUpdated()
327 throw( com::sun::star::sdbc::SQLException,
328 com::sun::star::uno::RuntimeException );
329 virtual sal_Bool SAL_CALL
330 rowInserted()
331 throw( com::sun::star::sdbc::SQLException,
332 com::sun::star::uno::RuntimeException );
333 virtual sal_Bool SAL_CALL
334 rowDeleted()
335 throw( com::sun::star::sdbc::SQLException,
336 com::sun::star::uno::RuntimeException );
337 virtual com::sun::star::uno::Reference<
338 com::sun::star::uno::XInterface > SAL_CALL
339 getStatement()
340 throw( com::sun::star::sdbc::SQLException,
341 com::sun::star::uno::RuntimeException );
343 //-----------------------------------------------------------------
344 // XRow inherited
345 //-----------------------------------------------------------------
346 virtual sal_Bool SAL_CALL
347 wasNull()
348 throw( com::sun::star::sdbc::SQLException,
349 com::sun::star::uno::RuntimeException );
351 virtual rtl::OUString SAL_CALL
352 getString( sal_Int32 columnIndex )
353 throw( com::sun::star::sdbc::SQLException,
354 com::sun::star::uno::RuntimeException );
356 virtual sal_Bool SAL_CALL
357 getBoolean( sal_Int32 columnIndex )
358 throw( com::sun::star::sdbc::SQLException,
359 com::sun::star::uno::RuntimeException );
361 virtual sal_Int8 SAL_CALL
362 getByte( sal_Int32 columnIndex )
363 throw( com::sun::star::sdbc::SQLException,
364 com::sun::star::uno::RuntimeException );
366 virtual sal_Int16 SAL_CALL
367 getShort( sal_Int32 columnIndex )
368 throw( com::sun::star::sdbc::SQLException,
369 com::sun::star::uno::RuntimeException );
371 virtual sal_Int32 SAL_CALL
372 getInt( sal_Int32 columnIndex )
373 throw( com::sun::star::sdbc::SQLException,
374 com::sun::star::uno::RuntimeException );
376 virtual sal_Int64 SAL_CALL
377 getLong( sal_Int32 columnIndex )
378 throw( com::sun::star::sdbc::SQLException,
379 com::sun::star::uno::RuntimeException );
381 virtual float SAL_CALL
382 getFloat( sal_Int32 columnIndex )
383 throw( com::sun::star::sdbc::SQLException,
384 com::sun::star::uno::RuntimeException );
386 virtual double SAL_CALL
387 getDouble( sal_Int32 columnIndex )
388 throw( com::sun::star::sdbc::SQLException,
389 com::sun::star::uno::RuntimeException );
391 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
392 getBytes( sal_Int32 columnIndex )
393 throw( com::sun::star::sdbc::SQLException,
394 com::sun::star::uno::RuntimeException );
396 virtual com::sun::star::util::Date SAL_CALL
397 getDate( sal_Int32 columnIndex )
398 throw( com::sun::star::sdbc::SQLException,
399 com::sun::star::uno::RuntimeException );
401 virtual com::sun::star::util::Time SAL_CALL
402 getTime( sal_Int32 columnIndex )
403 throw( com::sun::star::sdbc::SQLException,
404 com::sun::star::uno::RuntimeException );
406 virtual com::sun::star::util::DateTime SAL_CALL
407 getTimestamp( sal_Int32 columnIndex )
408 throw( com::sun::star::sdbc::SQLException,
409 com::sun::star::uno::RuntimeException );
411 virtual com::sun::star::uno::Reference<
412 com::sun::star::io::XInputStream > SAL_CALL
413 getBinaryStream( sal_Int32 columnIndex )
414 throw( com::sun::star::sdbc::SQLException,
415 com::sun::star::uno::RuntimeException );
417 virtual com::sun::star::uno::Reference<
418 com::sun::star::io::XInputStream > SAL_CALL
419 getCharacterStream( sal_Int32 columnIndex )
420 throw( com::sun::star::sdbc::SQLException,
421 com::sun::star::uno::RuntimeException );
423 virtual com::sun::star::uno::Any SAL_CALL
424 getObject( sal_Int32 columnIndex,
425 const com::sun::star::uno::Reference<
426 com::sun::star::container::XNameAccess >& typeMap )
427 throw( com::sun::star::sdbc::SQLException,
428 com::sun::star::uno::RuntimeException );
430 virtual com::sun::star::uno::Reference<
431 com::sun::star::sdbc::XRef > SAL_CALL
432 getRef( sal_Int32 columnIndex )
433 throw( com::sun::star::sdbc::SQLException,
434 com::sun::star::uno::RuntimeException );
436 virtual com::sun::star::uno::Reference<
437 com::sun::star::sdbc::XBlob > SAL_CALL
438 getBlob( sal_Int32 columnIndex )
439 throw( com::sun::star::sdbc::SQLException,
440 com::sun::star::uno::RuntimeException );
442 virtual com::sun::star::uno::Reference<
443 com::sun::star::sdbc::XClob > SAL_CALL
444 getClob( sal_Int32 columnIndex )
445 throw( com::sun::star::sdbc::SQLException,
446 com::sun::star::uno::RuntimeException );
448 virtual com::sun::star::uno::Reference<
449 com::sun::star::sdbc::XArray > SAL_CALL
450 getArray( sal_Int32 columnIndex )
451 throw( com::sun::star::sdbc::SQLException,
452 com::sun::star::uno::RuntimeException );
454 //-----------------------------------------------------------------
455 // Type Converter support
456 //-----------------------------------------------------------------
458 private:
459 sal_Bool m_bTriedToGetTypeConverter;
460 com::sun::star::uno::Reference<
461 com::sun::star::script::XTypeConverter > m_xTypeConverter;
463 const com::sun::star::uno::Reference<
464 com::sun::star::script::XTypeConverter >& getTypeConverter();
467 //=========================================================================
469 class CachedContentResultSetFactory
470 : public cppu::OWeakObject
471 , public com::sun::star::lang::XTypeProvider
472 , public com::sun::star::lang::XServiceInfo
473 , public com::sun::star::ucb::XCachedContentResultSetFactory
475 protected:
476 com::sun::star::uno::Reference<
477 com::sun::star::uno::XComponentContext > m_xContext;
479 public:
481 CachedContentResultSetFactory(
482 const com::sun::star::uno::Reference<
483 com::sun::star::uno::XComponentContext > & rxContext);
485 virtual ~CachedContentResultSetFactory();
487 //-----------------------------------------------------------------
488 // XInterface
489 XINTERFACE_DECL()
491 //-----------------------------------------------------------------
492 // XTypeProvider
493 XTYPEPROVIDER_DECL()
495 //-----------------------------------------------------------------
496 // XServiceInfo
497 XSERVICEINFO_DECL()
499 //-----------------------------------------------------------------
500 // XCachedContentResultSetFactory
502 virtual com::sun::star::uno::Reference<
503 com::sun::star::sdbc::XResultSet > SAL_CALL
504 createCachedContentResultSet(
505 const com::sun::star::uno::Reference<
506 com::sun::star::sdbc::XResultSet > & xSource,
507 const com::sun::star::uno::Reference<
508 com::sun::star::ucb::XContentIdentifierMapping > & xMapping )
509 throw( com::sun::star::uno::RuntimeException );
512 #endif
514 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */