fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / sorter / sortresult.hxx
bloba225fb96986205d9ffd76d44ffdde04b4e54a5c5
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 INCLUDED_UCB_SOURCE_SORTER_SORTRESULT_HXX
21 #define INCLUDED_UCB_SOURCE_SORTER_SORTRESULT_HXX
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/sdbc/XCloseable.hpp>
29 #include <com/sun/star/sdbc/XResultSet.hpp>
30 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
31 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
32 #include <com/sun/star/sdbc/XRow.hpp>
33 #include <com/sun/star/ucb/XContentAccess.hpp>
34 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
35 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
36 #include <com/sun/star/ucb/ListAction.hpp>
37 #include <cppuhelper/implbase8.hxx>
38 #include <deque>
40 namespace cppu {
41 class OInterfaceContainerHelper;
45 struct SortInfo;
46 struct SortListData;
47 class SRSPropertySetInfo;
48 class PropertyChangeListeners_Impl;
51 class SortedEntryList
53 std::deque < SortListData* > maData;
55 public:
56 SortedEntryList(){}
57 ~SortedEntryList(){ Clear(); }
59 sal_uInt32 Count() const { return (sal_uInt32) maData.size(); }
61 void Clear();
62 void Insert( SortListData *pEntry, sal_IntPtr nPos );
63 SortListData* Remove( sal_IntPtr nPos );
64 SortListData* GetData( sal_IntPtr nPos );
66 sal_IntPtr operator [] ( sal_IntPtr nPos ) const;
71 class EventList
73 std::deque < css::ucb::ListAction* > maData;
75 public:
76 EventList(){}
77 ~EventList(){ Clear(); }
79 sal_uInt32 Count() { return (sal_uInt32) maData.size(); }
81 void AddEvent( sal_IntPtr nType, sal_IntPtr nPos, sal_IntPtr nCount );
82 void Insert( css::ucb::ListAction *pAction ) { maData.push_back( pAction ); }
83 void Clear();
84 css::ucb::ListAction* GetAction( sal_IntPtr nIndex ) { return maData[ nIndex ]; }
89 class SimpleList
91 std::deque < void* > maData;
93 public:
94 SimpleList(){}
95 ~SimpleList(){ Clear(); }
97 sal_uInt32 Count() { return (sal_uInt32) maData.size(); }
98 void Clear() { maData.clear(); }
100 void Remove( sal_uInt32 nPos );
101 void Remove( void* pData );
103 void Append( void* pData )
104 { maData.push_back( pData ); }
105 void Insert( void* pData, sal_uInt32 nPos );
106 void* GetObject( sal_uInt32 nPos ) const;
107 void Replace( void* pData, sal_uInt32 nPos );
112 #define RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedResultSet"
116 class SortedResultSet: public cppu::WeakImplHelper8 <
117 css::lang::XServiceInfo,
118 css::lang::XComponent,
119 css::ucb::XContentAccess,
120 css::sdbc::XResultSet,
121 css::sdbc::XRow,
122 css::sdbc::XCloseable,
123 css::sdbc::XResultSetMetaDataSupplier,
124 css::beans::XPropertySet >
126 cppu::OInterfaceContainerHelper *mpDisposeEventListeners;
127 PropertyChangeListeners_Impl *mpPropChangeListeners;
128 PropertyChangeListeners_Impl *mpVetoChangeListeners;
130 css::uno::Reference < css::sdbc::XResultSet > mxOriginal;
131 css::uno::Reference < css::sdbc::XResultSet > mxOther;
133 SRSPropertySetInfo* mpPropSetInfo;
134 SortInfo* mpSortInfo;
135 osl::Mutex maMutex;
136 SortedEntryList maS2O; // maps the sorted entries to the original ones
137 SimpleList maO2S; // maps the original Entries to the sorted ones
138 SimpleList maModList; // keeps track of modified entries
139 sal_IntPtr mnLastSort; // index of the last sorted entry;
140 sal_IntPtr mnCurEntry; // index of the current entry
141 sal_IntPtr mnCount; // total count of the elements
142 bool mbIsCopy;
145 private:
147 sal_IntPtr FindPos( SortListData *pEntry, sal_IntPtr nStart, sal_IntPtr nEnd )
148 throw( css::sdbc::SQLException, css::uno::RuntimeException );
149 sal_IntPtr Compare( SortListData *pOne,
150 SortListData *pTwo )
151 throw( css::sdbc::SQLException, css::uno::RuntimeException );
152 void BuildSortInfo( css::uno::Reference< css::sdbc::XResultSet > aResult,
153 const css::uno::Sequence < css::ucb::NumberedSortingInfo > &xSortInfo,
154 const css::uno::Reference< css::ucb::XAnyCompareFactory > &xCompFac );
155 static sal_IntPtr CompareImpl( css::uno::Reference < css::sdbc::XResultSet > xResultOne,
156 css::uno::Reference < css::sdbc::XResultSet > xResultTwo,
157 sal_IntPtr nIndexOne, sal_IntPtr nIndexTwo,
158 SortInfo* pSortInfo )
159 throw( css::sdbc::SQLException, css::uno::RuntimeException );
160 sal_IntPtr CompareImpl( css::uno::Reference < css::sdbc::XResultSet > xResultOne,
161 css::uno::Reference < css::sdbc::XResultSet > xResultTwo,
162 sal_IntPtr nIndexOne, sal_IntPtr nIndexTwo )
163 throw( css::sdbc::SQLException, css::uno::RuntimeException );
164 void PropertyChanged( const css::beans::PropertyChangeEvent& rEvt );
166 public:
167 SortedResultSet( css::uno::Reference< css::sdbc::XResultSet > aResult );
168 virtual ~SortedResultSet();
170 const SortedEntryList& GetS2OList() const { return maS2O; }
171 const SimpleList& GetO2SList() const { return maO2S; }
172 css::uno::Reference < css::sdbc::XResultSet > GetResultSet() const { return mxOriginal; }
173 SortInfo* GetSortInfo() const { return mpSortInfo; }
174 sal_IntPtr GetCount() const { return mnCount; }
176 void CopyData( SortedResultSet* pSource );
177 void Initialize( const css::uno::Sequence < css::ucb::NumberedSortingInfo > &xSortInfo,
178 const css::uno::Reference< css::ucb::XAnyCompareFactory > &xCompFac );
179 void CheckProperties( sal_IntPtr nOldCount, bool bWasFinal );
181 void InsertNew( sal_IntPtr nPos, sal_IntPtr nCount );
182 void SetChanged( sal_IntPtr nPos, sal_IntPtr nCount );
183 void Remove( sal_IntPtr nPos, sal_IntPtr nCount, EventList *pList );
184 void Move( sal_IntPtr nPos, sal_IntPtr nCount, sal_IntPtr nOffset );
186 void ResortModified( EventList* pList );
187 void ResortNew( EventList* pList );
189 // XServiceInfo
190 virtual OUString SAL_CALL getImplementationName()
191 throw( css::uno::RuntimeException,
192 std::exception ) SAL_OVERRIDE;
193 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
194 throw( css::uno::RuntimeException,
195 std::exception ) SAL_OVERRIDE;
196 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
197 throw( css::uno::RuntimeException,
198 std::exception ) SAL_OVERRIDE;
200 static OUString getImplementationName_Static();
201 static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
203 // XComponent
204 virtual void SAL_CALL
205 dispose() throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
207 virtual void SAL_CALL
208 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener )
209 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
211 virtual void SAL_CALL
212 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener )
213 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
215 // XContentAccess
216 virtual OUString SAL_CALL
217 queryContentIdentifierString()
218 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
219 virtual css::uno::Reference<
220 css::ucb::XContentIdentifier > SAL_CALL
221 queryContentIdentifier()
222 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
223 virtual css::uno::Reference<
224 css::ucb::XContent > SAL_CALL
225 queryContent()
226 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
228 // XResultSet
229 virtual sal_Bool SAL_CALL
230 next()
231 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
232 virtual sal_Bool SAL_CALL
233 isBeforeFirst()
234 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
235 virtual sal_Bool SAL_CALL
236 isAfterLast()
237 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
238 virtual sal_Bool SAL_CALL
239 isFirst()
240 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
241 virtual sal_Bool SAL_CALL
242 isLast()
243 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
244 virtual void SAL_CALL
245 beforeFirst()
246 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
247 virtual void SAL_CALL
248 afterLast()
249 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
250 virtual sal_Bool SAL_CALL
251 first()
252 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
253 virtual sal_Bool SAL_CALL
254 last()
255 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
256 virtual sal_Int32 SAL_CALL
257 getRow()
258 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
259 virtual sal_Bool SAL_CALL
260 absolute( sal_Int32 row )
261 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
262 virtual sal_Bool SAL_CALL
263 relative( sal_Int32 rows )
264 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
265 virtual sal_Bool SAL_CALL
266 previous()
267 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
268 virtual void SAL_CALL
269 refreshRow()
270 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
271 virtual sal_Bool SAL_CALL
272 rowUpdated()
273 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
274 virtual sal_Bool SAL_CALL
275 rowInserted()
276 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
277 virtual sal_Bool SAL_CALL
278 rowDeleted()
279 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
280 virtual css::uno::Reference<
281 css::uno::XInterface > SAL_CALL
282 getStatement()
283 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
285 // XRow
286 virtual sal_Bool SAL_CALL
287 wasNull() throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
289 virtual OUString SAL_CALL
290 getString( sal_Int32 columnIndex )
291 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
293 virtual sal_Bool SAL_CALL
294 getBoolean( sal_Int32 columnIndex )
295 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
297 virtual sal_Int8 SAL_CALL
298 getByte( sal_Int32 columnIndex )
299 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
301 virtual sal_Int16 SAL_CALL
302 getShort( sal_Int32 columnIndex )
303 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
305 virtual sal_Int32 SAL_CALL
306 getInt( sal_Int32 columnIndex )
307 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
309 virtual sal_Int64 SAL_CALL
310 getLong( sal_Int32 columnIndex )
311 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
313 virtual float SAL_CALL
314 getFloat( sal_Int32 columnIndex )
315 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
317 virtual double SAL_CALL
318 getDouble( sal_Int32 columnIndex )
319 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
321 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
322 getBytes( sal_Int32 columnIndex )
323 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
325 virtual css::util::Date SAL_CALL
326 getDate( sal_Int32 columnIndex )
327 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
329 virtual css::util::Time SAL_CALL
330 getTime( sal_Int32 columnIndex )
331 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
333 virtual css::util::DateTime SAL_CALL
334 getTimestamp( sal_Int32 columnIndex )
335 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
337 virtual css::uno::Reference<
338 css::io::XInputStream > SAL_CALL
339 getBinaryStream( sal_Int32 columnIndex )
340 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
342 virtual css::uno::Reference<
343 css::io::XInputStream > SAL_CALL
344 getCharacterStream( sal_Int32 columnIndex )
345 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
347 virtual css::uno::Any SAL_CALL
348 getObject( sal_Int32 columnIndex,
349 const css::uno::Reference<
350 css::container::XNameAccess >& typeMap )
351 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
352 virtual css::uno::Reference<
353 css::sdbc::XRef > SAL_CALL
354 getRef( sal_Int32 columnIndex )
355 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
356 virtual css::uno::Reference<
357 css::sdbc::XBlob > SAL_CALL
358 getBlob( sal_Int32 columnIndex )
359 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
360 virtual css::uno::Reference<
361 css::sdbc::XClob > SAL_CALL
362 getClob( sal_Int32 columnIndex )
363 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
364 virtual css::uno::Reference<
365 css::sdbc::XArray > SAL_CALL
366 getArray( sal_Int32 columnIndex )
367 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
369 // XCloseable
370 virtual void SAL_CALL
371 close()
372 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
374 // XResultSetMetaDataSupplier
375 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
376 getMetaData()
377 throw( css::sdbc::SQLException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
380 // XPropertySet
381 virtual css::uno::Reference<
382 css::beans::XPropertySetInfo > SAL_CALL
383 getPropertySetInfo()
384 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
386 virtual void SAL_CALL
387 setPropertyValue( const OUString& PropertyName,
388 const css::uno::Any& Value )
389 throw( css::beans::UnknownPropertyException,
390 css::beans::PropertyVetoException,
391 css::lang::IllegalArgumentException,
392 css::lang::WrappedTargetException,
393 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
395 virtual css::uno::Any SAL_CALL
396 getPropertyValue( const OUString& PropertyName )
397 throw( css::beans::UnknownPropertyException,
398 css::lang::WrappedTargetException,
399 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
401 virtual void SAL_CALL
402 addPropertyChangeListener( const OUString& PropertyName,
403 const css::uno::Reference<
404 css::beans::XPropertyChangeListener >& Listener )
405 throw( css::beans::UnknownPropertyException,
406 css::lang::WrappedTargetException,
407 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
409 virtual void SAL_CALL
410 removePropertyChangeListener( const OUString& PropertyName,
411 const css::uno::Reference<
412 css::beans::XPropertyChangeListener >& Listener )
413 throw( css::beans::UnknownPropertyException,
414 css::lang::WrappedTargetException,
415 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
417 virtual void SAL_CALL
418 addVetoableChangeListener( const OUString& PropertyName,
419 const css::uno::Reference<
420 css::beans::XVetoableChangeListener >& Listener )
421 throw( css::beans::UnknownPropertyException,
422 css::lang::WrappedTargetException,
423 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
425 virtual void SAL_CALL
426 removeVetoableChangeListener( const OUString& PropertyName,
427 const css::uno::Reference<
428 css::beans::XVetoableChangeListener >& aListener )
429 throw( css::beans::UnknownPropertyException,
430 css::lang::WrappedTargetException,
431 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
434 #endif
436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */