LibreOffice Module ucb (master) 1
sortresult.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include "sortresult.hxx"
22#include <com/sun/star/sdbc/DataType.hpp>
23#include <com/sun/star/sdbc/SQLException.hpp>
24#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
25#include <com/sun/star/ucb/ListActionType.hpp>
26#include <com/sun/star/ucb/XAnyCompare.hpp>
30#include <memory>
31
32using namespace com::sun::star::beans;
33using namespace com::sun::star::container;
34using namespace com::sun::star::io;
35using namespace com::sun::star::lang;
36using namespace com::sun::star::sdbc;
37using namespace com::sun::star::ucb;
38using namespace com::sun::star::uno;
39using namespace com::sun::star::util;
40using namespace comphelper;
41using namespace cppu;
42
43
45{
49 sal_Int32 mnColumn;
50 sal_Int32 mnType;
53};
54
55
57{
59 sal_IntPtr mnCurPos;
60 sal_IntPtr mnOldPos;
61
62 explicit SortListData( sal_IntPtr nPos );
63};
64
65
66
67
68class SRSPropertySetInfo : public cppu::WeakImplHelper <
69 XPropertySetInfo >
70{
72
73private:
74
75public:
77
78 // XPropertySetInfo
79 virtual Sequence< Property > SAL_CALL getProperties() override;
80 virtual Property SAL_CALL getPropertyByName( const OUString& aName ) override;
81 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
82};
83
84
86{
87 mxOriginal = aResult;
88 mpSortInfo = nullptr;
89 mnLastSort = 0;
90 mnCurEntry = 0;
91 mnCount = 0;
92 mbIsCopy = false;
93}
94
95
97{
98 mxOriginal.clear();
99 mxOther.clear();
100
101 if ( !mbIsCopy )
102 {
103 SortInfo *pInfo = mpSortInfo;
104 while ( pInfo )
105 {
106 mpSortInfo = pInfo->mpNext;
107 delete pInfo;
108 pInfo = mpSortInfo;
109 }
110 }
111
112 mpSortInfo = nullptr;
113
114 mpPropSetInfo.clear();
115}
116
117
118// XServiceInfo methods.
119
121{
122 return "com.sun.star.comp.ucb.SortedResultSet";
123}
124
125sal_Bool SAL_CALL SortedResultSet::supportsService( const OUString& ServiceName )
126{
127 return cppu::supportsService( this, ServiceName );
128}
129
130css::uno::Sequence< OUString > SAL_CALL SortedResultSet::getSupportedServiceNames()
131{
132 return { RESULTSET_SERVICE_NAME };
133}
134
135
136// XComponent methods.
137
139{
140 std::unique_lock aGuard( maMutex );
141
143 {
144 EventObject aEvt;
145 aEvt.Source = static_cast< XComponent * >( this );
147 }
148
150 {
151 EventObject aEvt;
152 aEvt.Source = static_cast< XPropertySet * >( this );
154 }
155
157 {
158 EventObject aEvt;
159 aEvt.Source = static_cast< XPropertySet * >( this );
161 }
162
163 mxOriginal.clear();
164 mxOther.clear();
165}
166
167
169 const Reference< XEventListener >& Listener )
170{
171 std::unique_lock aGuard( maMutex );
172
173 maDisposeEventListeners.addInterface( aGuard, Listener );
174}
175
176
178 const Reference< XEventListener >& Listener )
179{
180 std::unique_lock aGuard( maMutex );
181
182 maDisposeEventListeners.removeInterface( aGuard, Listener );
183}
184
185
186// XContentAccess methods.
187
188
189OUString SAL_CALL
191{
192 std::unique_lock aGuard( maMutex );
193 return Reference< XContentAccess >::query(mxOriginal)->queryContentIdentifierString();
194}
195
196
199{
200 std::unique_lock aGuard( maMutex );
201 return Reference< XContentAccess >::query(mxOriginal)->queryContentIdentifier();
202}
203
204
207{
208 std::unique_lock aGuard( maMutex );
209 return Reference< XContentAccess >::query(mxOriginal)->queryContent();
210}
211
212
213// XResultSet methods.
214
216{
217 std::unique_lock aGuard( maMutex );
218
219 mnCurEntry++;
220
221 if ( mnCurEntry > 0 )
222 {
223 if ( mnCurEntry <= mnCount )
224 {
225 sal_Int32 nIndex = maS2O[ mnCurEntry ];
226 return mxOriginal->absolute( nIndex );
227 }
228 else
229 {
230 mnCurEntry = mnCount + 1;
231 }
232 }
233 return false;
234}
235
236
238{
239 if ( mnCurEntry )
240 return false;
241 else
242 return true;
243}
244
245
247{
248 if ( mnCurEntry > mnCount )
249 return true;
250 else
251 return false;
252}
253
254
256{
257 if ( mnCurEntry == 1 )
258 return true;
259 else
260 return false;
261}
262
263
265{
266 if ( mnCurEntry == mnCount )
267 return true;
268 else
269 return false;
270}
271
272
274{
275 std::unique_lock aGuard( maMutex );
276 mnCurEntry = 0;
277 mxOriginal->beforeFirst();
278}
279
280
282{
283 std::unique_lock aGuard( maMutex );
285 mxOriginal->afterLast();
286}
287
288
290{
291 std::unique_lock aGuard( maMutex );
292
293 if ( mnCount )
294 {
295 mnCurEntry = 1;
296 sal_Int32 nIndex = maS2O[ mnCurEntry ];
297 return mxOriginal->absolute( nIndex );
298 }
299 else
300 {
301 mnCurEntry = 0;
302 return false;
303 }
304}
305
306
308{
309 std::unique_lock aGuard( maMutex );
310
311 if ( mnCount )
312 {
314 sal_Int32 nIndex = maS2O[ mnCurEntry ];
315 return mxOriginal->absolute( nIndex );
316 }
317 else
318 {
319 mnCurEntry = 0;
320 return false;
321 }
322}
323
324
325sal_Int32 SAL_CALL SortedResultSet::getRow()
326{
327 return mnCurEntry;
328}
329
330
356sal_Bool SAL_CALL SortedResultSet::absolute( sal_Int32 row )
357{
358 std::unique_lock aGuard( maMutex );
359
360 sal_Int32 nIndex;
361
362 if ( row > 0 )
363 {
364 if ( row <= mnCount )
365 {
366 mnCurEntry = row;
368 return mxOriginal->absolute( nIndex );
369 }
370 else
371 {
372 mnCurEntry = mnCount + 1;
373 return false;
374 }
375 }
376 else if ( row == 0 )
377 {
378 throw SQLException();
379 }
380 else
381 {
382 if ( mnCount + row + 1 > 0 )
383 {
384 mnCurEntry = mnCount + row + 1;
386 return mxOriginal->absolute( nIndex );
387 }
388 else
389 {
390 mnCurEntry = 0;
391 return false;
392 }
393 }
394}
395
396
418sal_Bool SAL_CALL SortedResultSet::relative( sal_Int32 rows )
419{
420 std::unique_lock aGuard( maMutex );
421
422 if ( ( mnCurEntry <= 0 ) || ( mnCurEntry > mnCount ) )
423 {
424 throw SQLException();
425 }
426
427 if ( rows == 0 )
428 return true;
429
430 sal_Int32 nTmp = mnCurEntry + rows;
431
432 if ( nTmp <= 0 )
433 {
434 mnCurEntry = 0;
435 return false;
436 }
437 else if ( nTmp > mnCount )
438 {
439 mnCurEntry = mnCount + 1;
440 return false;
441 }
442 else
443 {
444 mnCurEntry = nTmp;
445 nTmp = maS2O[ mnCurEntry ];
446 return mxOriginal->absolute( nTmp );
447 }
448}
449
450
463{
464 std::unique_lock aGuard( maMutex );
465
466 mnCurEntry -= 1;
467
468 if ( mnCurEntry > 0 )
469 {
470 if ( mnCurEntry <= mnCount )
471 {
472 sal_Int32 nIndex = maS2O[ mnCurEntry ];
473 return mxOriginal->absolute( nIndex );
474 }
475 }
476 else
477 mnCurEntry = 0;
478
479 return false;
480}
481
482
484{
485 std::unique_lock aGuard( maMutex );
486
487 if ( ( mnCurEntry <= 0 ) || ( mnCurEntry > mnCount ) )
488 {
489 throw SQLException();
490 }
491
492 mxOriginal->refreshRow();
493}
494
495
497{
498 std::unique_lock aGuard( maMutex );
499
500 if ( ( mnCurEntry <= 0 ) || ( mnCurEntry > mnCount ) )
501 {
502 throw SQLException();
503 }
504
505 return mxOriginal->rowUpdated();
506}
507
508
510{
511 std::unique_lock aGuard( maMutex );
512
513 if ( ( mnCurEntry <= 0 ) || ( mnCurEntry > mnCount ) )
514 {
515 throw SQLException();
516 }
517
518 return mxOriginal->rowInserted();
519}
520
521
523{
524 std::unique_lock aGuard( maMutex );
525
526 if ( ( mnCurEntry <= 0 ) || ( mnCurEntry > mnCount ) )
527 {
528 throw SQLException();
529 }
530
531 return mxOriginal->rowDeleted();
532}
533
534
536{
537 std::unique_lock aGuard( maMutex );
538
539 if ( ( mnCurEntry <= 0 ) || ( mnCurEntry > mnCount ) )
540 {
541 throw SQLException();
542 }
543
544 return mxOriginal->getStatement();
545}
546
547
548// XRow methods.
549
550
552{
553 std::unique_lock aGuard( maMutex );
554 return Reference< XRow >::query(mxOriginal)->wasNull();
555}
556
557
558OUString SAL_CALL SortedResultSet::getString( sal_Int32 columnIndex )
559{
560 std::unique_lock aGuard( maMutex );
561 return Reference< XRow >::query(mxOriginal)->getString( columnIndex );
562}
563
564
565sal_Bool SAL_CALL SortedResultSet::getBoolean( sal_Int32 columnIndex )
566{
567 std::unique_lock aGuard( maMutex );
568 return Reference< XRow >::query(mxOriginal)->getBoolean( columnIndex );
569}
570
571
572sal_Int8 SAL_CALL SortedResultSet::getByte( sal_Int32 columnIndex )
573{
574 std::unique_lock aGuard( maMutex );
575 return Reference< XRow >::query(mxOriginal)->getByte( columnIndex );
576}
577
578
579sal_Int16 SAL_CALL SortedResultSet::getShort( sal_Int32 columnIndex )
580{
581 std::unique_lock aGuard( maMutex );
582 return Reference< XRow >::query(mxOriginal)->getShort( columnIndex );
583}
584
585
586sal_Int32 SAL_CALL SortedResultSet::getInt( sal_Int32 columnIndex )
587{
588 std::unique_lock aGuard( maMutex );
589 return Reference< XRow >::query(mxOriginal)->getInt( columnIndex );
590}
591
592sal_Int64 SAL_CALL SortedResultSet::getLong( sal_Int32 columnIndex )
593{
594 std::unique_lock aGuard( maMutex );
595 return Reference< XRow >::query(mxOriginal)->getLong( columnIndex );
596}
597
598
599float SAL_CALL SortedResultSet::getFloat( sal_Int32 columnIndex )
600{
601 std::unique_lock aGuard( maMutex );
602 return Reference< XRow >::query(mxOriginal)->getFloat( columnIndex );
603}
604
605
606double SAL_CALL SortedResultSet::getDouble( sal_Int32 columnIndex )
607{
608 std::unique_lock aGuard( maMutex );
609 return Reference< XRow >::query(mxOriginal)->getDouble( columnIndex );
610}
611
612
613Sequence< sal_Int8 > SAL_CALL SortedResultSet::getBytes( sal_Int32 columnIndex )
614{
615 std::unique_lock aGuard( maMutex );
616 return Reference< XRow >::query(mxOriginal)->getBytes( columnIndex );
617}
618
619
620Date SAL_CALL SortedResultSet::getDate( sal_Int32 columnIndex )
621{
622 std::unique_lock aGuard( maMutex );
623 return Reference< XRow >::query(mxOriginal)->getDate( columnIndex );
624}
625
626
627Time SAL_CALL SortedResultSet::getTime( sal_Int32 columnIndex )
628{
629 std::unique_lock aGuard( maMutex );
630 return Reference< XRow >::query(mxOriginal)->getTime( columnIndex );
631}
632
633
634DateTime SAL_CALL SortedResultSet::getTimestamp( sal_Int32 columnIndex )
635{
636 std::unique_lock aGuard( maMutex );
637 return Reference< XRow >::query(mxOriginal)->getTimestamp( columnIndex );
638}
639
640
642SortedResultSet::getBinaryStream( sal_Int32 columnIndex )
643{
644 std::unique_lock aGuard( maMutex );
645 return Reference< XRow >::query(mxOriginal)->getBinaryStream( columnIndex );
646}
647
648
651{
652 std::unique_lock aGuard( maMutex );
653 return Reference< XRow >::query(mxOriginal)->getCharacterStream( columnIndex );
654}
655
656
657Any SAL_CALL SortedResultSet::getObject( sal_Int32 columnIndex,
658 const Reference< XNameAccess >& typeMap )
659{
660 std::unique_lock aGuard( maMutex );
661 return Reference< XRow >::query(mxOriginal)->getObject( columnIndex,
662 typeMap);
663}
664
665
666Reference< XRef > SAL_CALL SortedResultSet::getRef( sal_Int32 columnIndex )
667{
668 std::unique_lock aGuard( maMutex );
669 return Reference< XRow >::query(mxOriginal)->getRef( columnIndex );
670}
671
672
673Reference< XBlob > SAL_CALL SortedResultSet::getBlob( sal_Int32 columnIndex )
674{
675 std::unique_lock aGuard( maMutex );
676 return Reference< XRow >::query(mxOriginal)->getBlob( columnIndex );
677}
678
679
680Reference< XClob > SAL_CALL SortedResultSet::getClob( sal_Int32 columnIndex )
681{
682 std::unique_lock aGuard( maMutex );
683 return Reference< XRow >::query(mxOriginal)->getClob( columnIndex );
684}
685
686
687Reference< XArray > SAL_CALL SortedResultSet::getArray( sal_Int32 columnIndex )
688{
689 std::unique_lock aGuard( maMutex );
690 return Reference< XRow >::query(mxOriginal)->getArray( columnIndex );
691}
692
693
694// XCloseable methods.
695
696
698{
699 std::unique_lock aGuard( maMutex );
701}
702
703
704// XResultSetMetaDataSupplier methods.
705
706
708{
709 std::unique_lock aGuard( maMutex );
711}
712
713
714// XPropertySet methods.
715
716
719{
720 std::unique_lock aGuard( maMutex );
721
722 if ( !mpPropSetInfo.is() )
723 {
725 }
726
727 return mpPropSetInfo;
728}
729
730
732 const OUString& PropertyName,
733 const Any& )
734{
735 if ( PropertyName == "RowCount" || PropertyName == "IsRowCountFinal" )
736 throw IllegalArgumentException();
737 else
738 throw UnknownPropertyException(PropertyName);
739}
740
741
742Any SAL_CALL SortedResultSet::getPropertyValue( const OUString& PropertyName )
743{
744 std::unique_lock aGuard( maMutex );
745
746 Any aRet;
747
748 if ( PropertyName == "RowCount" )
749 {
750 aRet <<= maS2O.Count();
751 }
752 else if ( PropertyName == "IsRowCountFinal" )
753 {
754 bool bOrgFinal = false;
755 Any aOrgRet;
756
757 aRet <<= false;
758
760 getPropertyValue( PropertyName );
761 aOrgRet >>= bOrgFinal;
762
763 if ( bOrgFinal )
764 {
766 getPropertyValue("RowCount");
767 sal_uInt32 nOrgCount = 0;
768 aOrgRet >>= nOrgCount;
769 if ( nOrgCount == maS2O.Count() )
770 aRet <<= true;
771 }
772 }
773 else
774 throw UnknownPropertyException(PropertyName);
775
776 return aRet;
777}
778
779
781 const OUString& PropertyName,
783{
784 std::unique_lock aGuard( maMutex );
785
786 maPropChangeListeners.addInterface( aGuard, PropertyName, Listener );
787}
788
789
791 const OUString& PropertyName,
793{
794 std::unique_lock aGuard( maMutex );
795
796 maPropChangeListeners.removeInterface( aGuard, PropertyName, Listener );
797}
798
799
801 const OUString& PropertyName,
803{
804 std::unique_lock aGuard( maMutex );
805
806 maVetoChangeListeners.addInterface( aGuard, PropertyName, Listener );
807}
808
809
811 const OUString& PropertyName,
813{
814 std::unique_lock aGuard( maMutex );
815
816 maVetoChangeListeners.removeInterface( aGuard, PropertyName, Listener );
817}
818
819
820// private methods
821
822sal_Int32 SortedResultSet::CompareImpl( const Reference < XResultSet >& xResultOne,
823 const Reference < XResultSet >& xResultTwo,
824 sal_Int32 nIndexOne, sal_Int32 nIndexTwo,
825 SortInfo const * pSortInfo )
826{
827 Reference < XRow > xRowOne( xResultOne, UNO_QUERY );
828 Reference < XRow > xRowTwo( xResultTwo, UNO_QUERY );
829
830 sal_IntPtr nCompare = 0;
831 sal_Int32 nColumn = pSortInfo->mnColumn;
832
833 switch ( pSortInfo->mnType )
834 {
835 case DataType::BIT :
836 case DataType::TINYINT :
837 case DataType::SMALLINT :
838 case DataType::INTEGER :
839 {
840 sal_Int32 aOne = 0;
841 sal_Int32 aTwo = 0;
842
843 if ( xResultOne->absolute( nIndexOne ) )
844 aOne = xRowOne->getInt( nColumn );
845 if ( xResultTwo->absolute( nIndexTwo ) )
846 aTwo = xRowTwo->getInt( nColumn );
847
848 if ( aOne < aTwo )
849 nCompare = -1;
850 else if ( aOne == aTwo )
851 nCompare = 0;
852 else
853 nCompare = 1;
854
855 break;
856 }
857 case DataType::BIGINT :
858 {
859 sal_Int64 aOne = 0;
860 sal_Int64 aTwo = 0;
861
862 if ( xResultOne->absolute( nIndexOne ) )
863 aOne = xRowOne->getLong( nColumn );
864 if ( xResultTwo->absolute( nIndexTwo ) )
865 aTwo = xRowTwo->getLong( nColumn );
866
867 if ( aOne < aTwo )
868 nCompare = -1;
869 else if ( aOne == aTwo )
870 nCompare = 0;
871 else
872 nCompare = 1;
873
874 break;
875 }
876 case DataType::CHAR :
877 case DataType::VARCHAR :
878 case DataType::LONGVARCHAR :
879 {
880 OUString aOne, aTwo;
881
882 if ( xResultOne->absolute( nIndexOne ) )
883 aOne = xRowOne->getString( nColumn );
884 if ( xResultTwo->absolute( nIndexTwo ) )
885 aTwo = xRowTwo->getString( nColumn );
886
887 if ( ! pSortInfo->mbCaseSensitive )
888 {
889 aOne = aOne.toAsciiLowerCase();
890 aTwo = aTwo.toAsciiLowerCase();
891 }
892
893 nCompare = aOne.compareTo( aTwo );
894 break;
895 }
896 case DataType::DATE :
897 {
898 Date aOne, aTwo;
899 sal_Int32 nTmp;
900
901 if ( xResultOne->absolute( nIndexOne ) )
902 aOne = xRowOne->getDate( nColumn );
903 if ( xResultTwo->absolute( nIndexTwo ) )
904 aTwo = xRowTwo->getDate( nColumn );
905
906 nTmp = static_cast<sal_Int32>(aTwo.Year) - static_cast<sal_Int32>(aOne.Year);
907 if ( !nTmp ) {
908 nTmp = static_cast<sal_Int32>(aTwo.Month) - static_cast<sal_Int32>(aOne.Month);
909 if ( !nTmp )
910 nTmp = static_cast<sal_Int32>(aTwo.Day) - static_cast<sal_Int32>(aOne.Day);
911 }
912
913 if ( nTmp < 0 )
914 nCompare = -1;
915 else if ( nTmp == 0 )
916 nCompare = 0;
917 else
918 nCompare = 1;
919
920 break;
921 }
922 case DataType::TIME :
923 {
924 Time aOne, aTwo;
925 sal_Int32 nTmp;
926
927 if ( xResultOne->absolute( nIndexOne ) )
928 aOne = xRowOne->getTime( nColumn );
929 if ( xResultTwo->absolute( nIndexTwo ) )
930 aTwo = xRowTwo->getTime( nColumn );
931
932 nTmp = static_cast<sal_Int32>(aTwo.Hours) - static_cast<sal_Int32>(aOne.Hours);
933 if ( !nTmp )
934 nTmp = static_cast<sal_Int32>(aTwo.Minutes) - static_cast<sal_Int32>(aOne.Minutes);
935 if ( !nTmp )
936 nTmp = static_cast<sal_Int32>(aTwo.Seconds) - static_cast<sal_Int32>(aOne.Seconds);
937 if ( !nTmp )
938 nTmp = static_cast<sal_Int32>(aTwo.NanoSeconds)
939 - static_cast<sal_Int32>(aOne.NanoSeconds);
940
941 if ( nTmp < 0 )
942 nCompare = -1;
943 else if ( nTmp == 0 )
944 nCompare = 0;
945 else
946 nCompare = 1;
947
948 break;
949 }
950 case DataType::TIMESTAMP :
951 {
952 DateTime aOne, aTwo;
953 sal_Int32 nTmp;
954
955 if ( xResultOne->absolute( nIndexOne ) )
956 aOne = xRowOne->getTimestamp( nColumn );
957 if ( xResultTwo->absolute( nIndexTwo ) )
958 aTwo = xRowTwo->getTimestamp( nColumn );
959
960 nTmp = static_cast<sal_Int32>(aTwo.Year) - static_cast<sal_Int32>(aOne.Year);
961 if ( !nTmp )
962 nTmp = static_cast<sal_Int32>(aTwo.Month) - static_cast<sal_Int32>(aOne.Month);
963 if ( !nTmp )
964 nTmp = static_cast<sal_Int32>(aTwo.Day) - static_cast<sal_Int32>(aOne.Day);
965 if ( !nTmp )
966 nTmp = static_cast<sal_Int32>(aTwo.Hours) - static_cast<sal_Int32>(aOne.Hours);
967 if ( !nTmp )
968 nTmp = static_cast<sal_Int32>(aTwo.Minutes) - static_cast<sal_Int32>(aOne.Minutes);
969 if ( !nTmp )
970 nTmp = static_cast<sal_Int32>(aTwo.Seconds) - static_cast<sal_Int32>(aOne.Seconds);
971 if ( !nTmp )
972 nTmp = static_cast<sal_Int32>(aTwo.NanoSeconds)
973 - static_cast<sal_Int32>(aOne.NanoSeconds);
974
975 if ( nTmp < 0 )
976 nCompare = -1;
977 else if ( nTmp == 0 )
978 nCompare = 0;
979 else
980 nCompare = 1;
981
982 break;
983 }
984 case DataType::REAL :
985 {
986 float aOne = 0;
987 float aTwo = 0;
988
989 if ( xResultOne->absolute( nIndexOne ) )
990 aOne = xRowOne->getFloat( nColumn );
991 if ( xResultTwo->absolute( nIndexTwo ) )
992 aTwo = xRowTwo->getFloat( nColumn );
993
994 if ( aOne < aTwo )
995 nCompare = -1;
996 else if ( aOne == aTwo )
997 nCompare = 0;
998 else
999 nCompare = 1;
1000
1001 break;
1002 }
1003 case DataType::FLOAT :
1004 case DataType::DOUBLE :
1005 {
1006 double aOne = 0;
1007 double aTwo = 0;
1008
1009 if ( xResultOne->absolute( nIndexOne ) )
1010 aOne = xRowOne->getDouble( nColumn );
1011 if ( xResultTwo->absolute( nIndexTwo ) )
1012 aTwo = xRowTwo->getDouble( nColumn );
1013
1014 if ( aOne < aTwo )
1015 nCompare = -1;
1016 else if ( aOne == aTwo )
1017 nCompare = 0;
1018 else
1019 nCompare = 1;
1020
1021 break;
1022 }
1023 default:
1024 {
1025 OSL_FAIL( "DataType not supported for compare!" );
1026 }
1027 }
1028
1029 return nCompare;
1030}
1031
1032
1033sal_Int32 SortedResultSet::CompareImpl( const Reference < XResultSet >& xResultOne,
1034 const Reference < XResultSet >& xResultTwo,
1035 sal_Int32 nIndexOne, sal_Int32 nIndexTwo )
1036{
1037 sal_IntPtr nCompare = 0;
1038 SortInfo* pInfo = mpSortInfo;
1039
1040 while ( !nCompare && pInfo )
1041 {
1042 if ( pInfo->mbUseOwnCompare )
1043 {
1044 nCompare = CompareImpl( xResultOne, xResultTwo,
1045 nIndexOne, nIndexTwo, pInfo );
1046 }
1047 else
1048 {
1049 Any aOne, aTwo;
1050
1051 Reference < XRow > xRowOne =
1052 Reference< XRow >::query( xResultOne );
1053 Reference < XRow > xRowTwo =
1054 Reference< XRow >::query( xResultTwo );
1055
1056 if ( xResultOne->absolute( nIndexOne ) )
1057 aOne = xRowOne->getObject( pInfo->mnColumn, nullptr );
1058 if ( xResultTwo->absolute( nIndexTwo ) )
1059 aTwo = xRowTwo->getObject( pInfo->mnColumn, nullptr );
1060
1061 nCompare = pInfo->mxCompareFunction->compare( aOne, aTwo );
1062 }
1063
1064 if ( ! pInfo->mbAscending )
1065 nCompare = - nCompare;
1066
1067 pInfo = pInfo->mpNext;
1068 }
1069
1070 return nCompare;
1071}
1072
1073
1075 SortListData const *pTwo )
1076{
1077 sal_IntPtr nIndexOne;
1078 sal_IntPtr nIndexTwo;
1079
1080 Reference < XResultSet > xResultOne;
1081 Reference < XResultSet > xResultTwo;
1082
1083 if ( pOne->mbModified )
1084 {
1085 xResultOne = mxOther;
1086 nIndexOne = pOne->mnOldPos;
1087 }
1088 else
1089 {
1090 xResultOne = mxOriginal;
1091 nIndexOne = pOne->mnCurPos;
1092 }
1093
1094 if ( pTwo->mbModified )
1095 {
1096 xResultTwo = mxOther;
1097 nIndexTwo = pTwo->mnOldPos;
1098 }
1099 else
1100 {
1101 xResultTwo = mxOriginal;
1102 nIndexTwo = pTwo->mnCurPos;
1103 }
1104
1105 sal_IntPtr nCompare;
1106 nCompare = CompareImpl( xResultOne, xResultTwo,
1107 nIndexOne, nIndexTwo );
1108 return nCompare;
1109}
1110
1111
1113 sal_IntPtr _nStart, sal_IntPtr _nEnd )
1114{
1115 if ( _nStart > _nEnd )
1116 return _nStart + 1;
1117
1118 sal_IntPtr nStart = _nStart;
1119 sal_IntPtr nEnd = _nEnd;
1120 sal_IntPtr nMid = 0, nCompare = 0;
1121
1122
1123 while ( nStart <= nEnd )
1124 {
1125 nMid = ( nEnd - nStart ) / 2 + nStart;
1126 SortListData *pMid = maS2O.GetData( nMid );
1127 nCompare = Compare( pEntry, pMid );
1128
1129 if ( !nCompare )
1130 nCompare = (pEntry != pMid) ? ((pEntry < pMid) ? -1 : 1) : 0;
1131
1132 if ( nCompare < 0 ) // pEntry < pMid
1133 nEnd = nMid - 1;
1134 else
1135 nStart = nMid + 1;
1136 }
1137
1138 if ( nCompare < 0 ) // pEntry < pMid
1139 return nMid;
1140 else
1141 return nMid+1;
1142}
1143
1144
1145void SortedResultSet::PropertyChanged( const PropertyChangeEvent& rEvt )
1146{
1147 std::unique_lock aGuard( maMutex );
1148
1150 return;
1151
1152 // Notify listeners interested especially in the changed property.
1154 maPropChangeListeners.getContainer( aGuard, rEvt.PropertyName );
1155 if ( pPropsContainer )
1156 pPropsContainer->notifyEach( aGuard, &XPropertyChangeListener::propertyChange, rEvt );
1157
1158 // Notify listeners interested in all properties.
1159 pPropsContainer = maPropChangeListeners.getContainer( aGuard, OUString() );
1160 if ( pPropsContainer )
1161 pPropsContainer->notifyEach( aGuard, &XPropertyChangeListener::propertyChange, rEvt );
1162}
1163
1164
1165// public methods
1166
1167
1169{
1170 const SortedEntryList& rSrcS2O = pSource->maS2O;
1171
1172 sal_IntPtr i, nCount;
1173
1174 maS2O.Clear();
1175 m_O2S.clear();
1176 m_ModList.clear();
1177
1178 maS2O.Insert( nullptr, 0 );
1179 m_O2S.push_back(0);
1180
1181 nCount = rSrcS2O.Count();
1182
1183 for ( i=1; i<nCount; i++ )
1184 {
1185 maS2O.Insert( std::unique_ptr<SortListData>(new SortListData( rSrcS2O[ i ] )), i );
1186 m_O2S.push_back(pSource->m_O2S[i]);
1187 }
1188
1190 mxOther = pSource->mxOriginal;
1191
1192 if ( !mpSortInfo )
1193 {
1194 mpSortInfo = pSource->mpSortInfo;
1195 mbIsCopy = true;
1196 }
1197}
1198
1199
1201 const Sequence < NumberedSortingInfo > &xSortInfo,
1202 const Reference< XAnyCompareFactory > &xCompFactory )
1203{
1204 BuildSortInfo( mxOriginal, xSortInfo, xCompFactory );
1205 // Insert dummy at pos 0
1206 maS2O.Insert( std::unique_ptr<SortListData>(new SortListData( 0 )), 0 );
1207
1208 sal_IntPtr nIndex = 1;
1209
1210 // now fetch all the elements from the original result set,
1211 // get there new position in the sorted result set and insert
1212 // an entry in the sorted to original mapping list
1213 try {
1214 while ( mxOriginal->absolute( nIndex ) )
1215 {
1216 std::unique_ptr<SortListData> pData(new SortListData( nIndex ));
1217 sal_IntPtr nPos = FindPos( pData.get(), 1, nIndex-1 );
1218
1219 maS2O.Insert( std::move(pData), nPos );
1220
1221 nIndex++;
1222 }
1223 }
1224 catch (const SQLException&)
1225 {
1226 TOOLS_WARN_EXCEPTION("ucb", "");
1227 }
1228
1229 // when we have fetched all the elements, we can create the
1230 // original to sorted mapping list from the s2o list
1231 m_O2S.clear();
1232 m_O2S.push_back(0);
1233
1234 // insert some dummy entries first and replace then
1235 // the entries with the right ones
1236 size_t i;
1237
1238 for ( i=1; i<maS2O.Count(); i++ )
1239 m_O2S.push_back(0);
1240 for ( i=1; i<maS2O.Count(); i++ )
1241 m_O2S[maS2O[i]] = i;
1242
1243 mnCount = maS2O.Count() - 1;
1244}
1245
1246
1247void SortedResultSet::CheckProperties( sal_Int32 nOldCount, bool bWasFinal )
1248{
1249 std::unique_lock aGuard( maMutex );
1250
1252 return;
1253
1254 try {
1255 // check for propertyChangeEvents
1256 if ( nOldCount != GetCount() )
1257 {
1258 bool bIsFinal = false;
1259 PropertyChangeEvent aEvt;
1260
1261 aEvt.PropertyName = "RowCount";
1262 aEvt.Further = false;
1263 aEvt.PropertyHandle = -1;
1264 aEvt.OldValue <<= nOldCount;
1265 aEvt.NewValue <<= GetCount();
1266
1267 PropertyChanged( aEvt );
1268
1269 OUString aName = "IsRowCountFinal";
1270 Any aRet = getPropertyValue( aName );
1271 if ( (aRet >>= bIsFinal) && bIsFinal != bWasFinal )
1272 {
1273 aEvt.PropertyName = aName;
1274 aEvt.Further = false;
1275 aEvt.PropertyHandle = -1;
1276 aEvt.OldValue <<= bWasFinal;
1277 aEvt.NewValue <<= bIsFinal;
1278 PropertyChanged( aEvt );
1279 }
1280 }
1281 }
1282 catch (const UnknownPropertyException&) {}
1283 catch (const WrappedTargetException&) {}
1284}
1285
1286
1287void SortedResultSet::InsertNew( sal_Int32 nPos, sal_Int32 nCount )
1288{
1289 // for all entries in the msS20-list, which are >= nPos, increase by nCount
1290 sal_IntPtr i, nEnd;
1291
1292 nEnd = maS2O.Count();
1293 for ( i=1; i<=nEnd; i++ )
1294 {
1296 if ( pData->mnCurPos >= nPos )
1297 {
1298 pData->mnCurPos += nCount;
1299 }
1300 }
1301
1302 // and append the new entries at the end of the maS2O-list or insert at the
1303 // position nPos in the maS2O-list
1304 for ( i=0; i<nCount; i++ )
1305 {
1306 nEnd += 1;
1307 std::unique_ptr<SortListData> pData(new SortListData( nEnd ));
1308
1309 maS2O.Insert( std::move(pData), nEnd ); // Insert( Value, Position )
1310 m_O2S.insert(m_O2S.begin() + nPos + i, nEnd);
1311 }
1312
1313 mnCount += nCount;
1314}
1315
1316
1317void SortedResultSet::Remove( sal_Int32 nPos, sal_Int32 nCount, EventList *pEvents )
1318{
1319 sal_IntPtr nOldLastSort;
1320
1321 // correct mnLastSort first
1322 nOldLastSort = mnLastSort;
1323 if ( nPos <= mnLastSort )
1324 {
1325 if ( nPos + nCount - 1 <= mnLastSort )
1326 mnLastSort -= nCount;
1327 else
1328 mnLastSort = nPos - 1;
1329 }
1330
1331 // remove the entries from the lists and correct the positions
1332 // in the original2sorted list
1333 for ( sal_IntPtr i=0; i < nCount; i++ )
1334 {
1335 sal_IntPtr nSortPos = m_O2S[nPos];
1336 m_O2S.erase(m_O2S.begin() + nPos);
1337
1338 for (size_t j=1; j < m_O2S.size(); ++j)
1339 {
1340 sal_IntPtr nVal = m_O2S[j];
1341 if ( nVal > nSortPos )
1342 {
1343 --nVal;
1344 m_O2S[j] = nVal;
1345 }
1346 }
1347
1348 std::unique_ptr<SortListData> pData = maS2O.Remove( nSortPos );
1349 if ( pData->mbModified )
1350 m_ModList.erase(std::find(m_ModList.begin(), m_ModList.end(), pData.get()));
1351
1352 // generate remove Event, but not for new entries
1353 if ( nSortPos <= nOldLastSort )
1354 pEvents->AddEvent( ListActionType::REMOVED, nSortPos );
1355 }
1356
1357 // correct the positions in the sorted list
1358 for ( sal_uInt32 i=1; i<= maS2O.Count(); i++ )
1359 {
1361 if ( pData->mnCurPos > nPos )
1362 pData->mnCurPos -= nCount;
1363 }
1364
1365 mnCount -= nCount;
1366}
1367
1368
1369void SortedResultSet::Move( sal_Int32 nPos, sal_Int32 nCount, sal_Int32 nOffset )
1370{
1371 if ( !nOffset )
1372 return;
1373
1374 sal_IntPtr i, nSortPos, nTo;
1376
1377 for ( i=0; i<nCount; i++ )
1378 {
1379 nSortPos = m_O2S[nPos + i];
1380 pData = maS2O.GetData( nSortPos );
1381 pData->mnCurPos += nOffset;
1382 }
1383
1384 if ( nOffset < 0 )
1385 {
1386 for ( i=nPos+nOffset; i<nPos; i++ )
1387 {
1388 nSortPos = m_O2S[i];
1389 pData = maS2O.GetData( nSortPos );
1390 pData->mnCurPos += nCount;
1391 }
1392 }
1393 else
1394 {
1395 sal_IntPtr nStart = nPos + nCount;
1396 sal_IntPtr nEnd = nStart + nOffset;
1397 for ( i=nStart; i<nEnd; i++ )
1398 {
1399 nSortPos = m_O2S[i];
1400 pData = maS2O.GetData( nSortPos );
1401 pData->mnCurPos -= nCount;
1402 }
1403 }
1404
1405 // remember the to be moved entries
1406 std::unique_ptr<sal_IntPtr[]> pTmpArr(new sal_IntPtr[ nCount ]);
1407 for ( i=0; i<nCount; i++ )
1408 pTmpArr[i] = m_O2S[nPos + i];
1409
1410 // now move the entries, which are in the way
1411 if ( nOffset < 0 )
1412 {
1413 // be carefully here, because nOffset is negative here, so an
1414 // addition is a subtraction
1415 sal_IntPtr nFrom = nPos - 1;
1416 nTo = nPos + nCount - 1;
1417
1418 // same for i here
1419 for ( i=0; i>nOffset; i-- )
1420 {
1421 sal_IntPtr const nVal = m_O2S[nFrom + i];
1422 m_O2S[nTo + i] = nVal;
1423 }
1424
1425 }
1426 else
1427 {
1428 sal_IntPtr nStart = nPos + nCount;
1429 for ( i=0; i<nOffset; i++ )
1430 {
1431 sal_IntPtr const nVal = m_O2S[nStart + i];
1432 m_O2S[nPos + i] = nVal;
1433 }
1434 }
1435
1436 // finally put the remembered entries at their new location
1437 nTo = nPos + nOffset;
1438 for ( i=0; i<nCount; i++ )
1439 {
1440 m_O2S[nTo + i] = pTmpArr[i];
1441 }
1442}
1443
1444
1446 const Reference< XResultSet >& aResult,
1447 const Sequence < NumberedSortingInfo > &xSortInfo,
1448 const Reference< XAnyCompareFactory > &xCompFactory )
1449{
1450 Reference < XResultSetMetaDataSupplier > xMeta ( aResult, UNO_QUERY );
1451
1452 if ( ! xMeta.is() )
1453 {
1454 OSL_FAIL( "No MetaData, No Sorting!" );
1455 return;
1456 }
1457
1458 Reference < XResultSetMetaData > xData = xMeta->getMetaData();
1459 const NumberedSortingInfo *pSortInfo = xSortInfo.getConstArray();
1460
1461 sal_Int32 nColumn;
1462 OUString aPropName;
1463 SortInfo *pInfo;
1464
1465 for ( sal_Int32 i=xSortInfo.getLength(); i > 0; )
1466 {
1467 --i;
1468 nColumn = pSortInfo[ i ].ColumnIndex;
1469 aPropName = xData->getColumnName( nColumn );
1470 pInfo = new SortInfo;
1471
1472 if ( xCompFactory.is() )
1473 pInfo->mxCompareFunction = xCompFactory->createAnyCompareByName(
1474 aPropName );
1475
1476 if ( pInfo->mxCompareFunction.is() )
1477 {
1478 pInfo->mbUseOwnCompare = false;
1479 pInfo->mnType = 0;
1480 }
1481 else
1482 {
1483 pInfo->mbUseOwnCompare = true;
1484 pInfo->mnType = xData->getColumnType( nColumn );
1485 }
1486
1487 pInfo->mnColumn = nColumn;
1488 pInfo->mbAscending = pSortInfo[ i ].Ascending;
1489 pInfo->mbCaseSensitive = xData->isCaseSensitive( nColumn );
1490 pInfo->mpNext = mpSortInfo;
1491 mpSortInfo = pInfo;
1492 }
1493}
1494
1495
1496void SortedResultSet::SetChanged( sal_Int32 nPos, sal_Int32 nCount )
1497{
1498 for ( sal_IntPtr i=0; i<nCount; i++ )
1499 {
1500 sal_IntPtr const nSortPos = m_O2S[nPos];
1501 if ( nSortPos < mnLastSort )
1502 {
1503 SortListData *pData = maS2O.GetData( nSortPos );
1504 if ( ! pData->mbModified )
1505 {
1506 pData->mbModified = true;
1507 m_ModList.push_back(pData);
1508 }
1509 }
1510 nPos += 1;
1511 }
1512}
1513
1514
1516{
1517 sal_IntPtr nCompare, nCurPos, nNewPos;
1518 sal_IntPtr nStart, nEnd, nOffset, nVal;
1519
1520 try {
1521 for (size_t i = 0; i < m_ModList.size(); ++i)
1522 {
1523 SortListData *const pData = m_ModList[i];
1524 nCompare = CompareImpl( mxOther, mxOriginal,
1525 pData->mnOldPos, pData->mnCurPos );
1526 pData->mbModified = false;
1527 if ( nCompare != 0 )
1528 {
1529 nCurPos = m_O2S[pData->mnCurPos];
1530 if ( nCompare < 0 )
1531 {
1532 nNewPos = FindPos( pData, 1, nCurPos-1 );
1533 nStart = nNewPos;
1534 nEnd = nCurPos;
1535 nOffset = 1;
1536 }
1537 else
1538 {
1539 nNewPos = FindPos( pData, nCurPos+1, mnLastSort );
1540 nStart = nCurPos;
1541 nEnd = mnLastSort;
1542 nOffset = -1;
1543 }
1544
1545 if ( nNewPos != nCurPos )
1546 {
1547 // correct the lists!
1548 maS2O.Move( static_cast<sal_uInt32>(nCurPos), nNewPos );
1549 for (size_t j = 1; j < m_O2S.size(); ++j)
1550 {
1551 nVal = m_O2S[j];
1552 if ( ( nStart <= nVal ) && ( nVal <= nEnd ) )
1553 {
1554 nVal += nOffset;
1555 m_O2S[j] = nVal;
1556 }
1557 }
1558
1559 m_O2S[pData->mnCurPos] = nNewPos;
1560
1561 ListAction aAction;
1562 aAction.Position = nCurPos;
1563 aAction.Count = 1;
1564 aAction.ListActionType = ListActionType::MOVED;
1565 aAction.ActionInfo <<= nNewPos-nCurPos;
1566 pList->Insert( aAction );
1567 }
1568 pList->AddEvent( ListActionType::PROPERTIES_CHANGED, nNewPos );
1569 }
1570 }
1571 }
1572 catch (const SQLException&)
1573 {
1574 TOOLS_WARN_EXCEPTION("ucb", "");
1575 }
1576
1577 m_ModList.clear();
1578}
1579
1580
1582{
1583 sal_IntPtr i, nNewPos, nVal;
1584
1585 try {
1586 for ( i = mnLastSort; i<static_cast<sal_IntPtr>(maS2O.Count()); i++ )
1587 {
1588 SortListData *const pData = m_ModList[i];
1589 nNewPos = FindPos( pData, 1, mnLastSort );
1590 if ( nNewPos != i )
1591 {
1592 maS2O.Move( static_cast<sal_uInt32>(i), nNewPos );
1593 for (size_t j=1; j< m_O2S.size(); ++j)
1594 {
1595 nVal = m_O2S[j];
1596 if ( nVal >= nNewPos )
1597 m_O2S[j] = nVal + 1;
1598 }
1599 m_O2S[pData->mnCurPos] = nNewPos;
1600 }
1601 mnLastSort++;
1602 pList->AddEvent( ListActionType::INSERTED, nNewPos );
1603 }
1604 }
1605 catch (const SQLException&)
1606 {
1607 TOOLS_WARN_EXCEPTION("ucb", "");
1608 }
1609}
1610
1611
1612// SortListData
1613
1614
1616 : mbModified(false)
1617 , mnCurPos(nPos)
1618 , mnOldPos(nPos)
1619{
1620};
1621
1623{
1624}
1625
1627{
1628}
1629
1631{
1632 maData.clear();
1633}
1634
1635
1636void SortedEntryList::Insert( std::unique_ptr<SortListData> pEntry, sal_Int32 nPos )
1637{
1638 if ( nPos < static_cast<sal_IntPtr>(maData.size()) )
1639 maData.insert( maData.begin() + nPos, std::move(pEntry) );
1640 else
1641 maData.push_back( std::move(pEntry) );
1642}
1643
1644void SortedEntryList::Move( sal_Int32 nOldPos, sal_Int32 nNewPos )
1645{
1646 auto p = std::move(maData[nOldPos]);
1647 maData.erase( maData.begin() + nOldPos );
1648 maData.insert(maData.begin() + nNewPos, std::move(p));
1649}
1650
1651std::unique_ptr<SortListData> SortedEntryList::Remove( sal_Int32 nPos )
1652{
1653 std::unique_ptr<SortListData> pData;
1654
1655 if ( nPos < static_cast<sal_IntPtr>(maData.size()) )
1656 {
1657 pData = std::move(maData[ nPos ]);
1658 maData.erase( maData.begin() + nPos );
1659 }
1660
1661 return pData;
1662}
1663
1664
1666{
1668
1669 if ( nPos < static_cast<sal_IntPtr>(maData.size()) )
1670 pData = maData[ nPos ].get();
1671 else
1672 pData = nullptr;
1673
1674 return pData;
1675}
1676
1677
1678sal_Int32 SortedEntryList::operator [] ( sal_Int32 nPos ) const
1679{
1681
1682 if ( nPos < static_cast<sal_IntPtr>(maData.size()) )
1683 pData = maData[ nPos ].get();
1684 else
1685 pData = nullptr;
1686
1687 if ( pData )
1688 if ( ! pData->mbModified )
1689 return pData->mnCurPos;
1690 else
1691 {
1692 OSL_FAIL( "SortedEntryList: Can't get value for modified entry!");
1693 return 0;
1694 }
1695 else
1696 {
1697 OSL_FAIL( "SortedEntryList: invalid pos!");
1698 return 0;
1699 }
1700}
1701
1702
1704{
1705 maProps[0].Name = "RowCount";
1706 maProps[0].Handle = -1;
1708 maProps[0].Attributes = -1;
1709
1710 maProps[1].Name = "IsRowCountFinal";
1711 maProps[1].Handle = -1;
1713 maProps[1].Attributes = -1;
1714}
1715
1716// XPropertySetInfo methods.
1717
1718Sequence< Property > SAL_CALL
1720{
1721 return Sequence < Property > ( maProps, 2 );
1722}
1723
1724
1725Property SAL_CALL
1727{
1728 if ( Name == "RowCount" )
1729 return maProps[0];
1730 else if ( Name == "IsRowCountFinal" )
1731 return maProps[1];
1732 else
1733 throw UnknownPropertyException(Name);
1734}
1735
1736
1737sal_Bool SAL_CALL
1739{
1740 if ( Name == "RowCount" )
1741 return true;
1742 else if ( Name == "IsRowCountFinal" )
1743 return true;
1744 else
1745 return false;
1746}
1747
1748/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddEvent(sal_IntPtr nType, sal_Int32 nPos)
Definition: sortdynres.cxx:449
void Insert(const css::ucb::ListAction &rAction)
Definition: sortresult.hxx:79
virtual Sequence< Property > SAL_CALL getProperties() override
Property maProps[2]
Definition: sortresult.cxx:71
virtual sal_Bool SAL_CALL hasPropertyByName(const OUString &Name) override
virtual Property SAL_CALL getPropertyByName(const OUString &aName) override
std::unique_ptr< SortListData > Remove(sal_Int32 nPos)
std::deque< std::unique_ptr< SortListData > > maData
Definition: sortresult.hxx:51
sal_Int32 operator[](sal_Int32 nPos) const
SortListData * GetData(sal_Int32 nPos)
sal_uInt32 Count() const
Definition: sortresult.hxx:57
void Move(sal_Int32 nOldPos, sal_Int32 nNewPos)
void Insert(std::unique_ptr< SortListData > pEntry, sal_Int32 nPos)
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
Definition: sortresult.cxx:535
std::deque< SortListData * > m_ModList
maps the original Entries to the sorted ones
Definition: sortresult.hxx:110
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
Definition: sortresult.cxx:606
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
Definition: sortresult.cxx:680
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
Definition: sortresult.cxx:642
sal_Int32 mnCurEntry
Definition: sortresult.hxx:112
sal_Int32 FindPos(SortListData const *pEntry, sal_IntPtr nStart, sal_IntPtr nEnd)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: sortresult.cxx:168
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
Definition: sortresult.cxx:579
virtual void SAL_CALL dispose() override
Definition: sortresult.cxx:138
void ResortNew(EventList *pList)
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: sortresult.cxx:177
virtual sal_Bool SAL_CALL next() override
Definition: sortresult.cxx:215
virtual void SAL_CALL refreshRow() override
Definition: sortresult.cxx:483
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
Definition: sortresult.cxx:206
virtual sal_Bool SAL_CALL rowDeleted() override
Definition: sortresult.cxx:522
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
Definition: sortresult.cxx:572
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
Definition: sortresult.cxx:707
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
Definition: sortresult.cxx:666
void Remove(sal_Int32 nPos, sal_Int32 nCount, EventList *pList)
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
Definition: sortresult.cxx:565
virtual OUString SAL_CALL getImplementationName() override
Definition: sortresult.cxx:120
virtual sal_Bool SAL_CALL rowInserted() override
Definition: sortresult.cxx:509
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
moves the cursor a relative number of rows, either positive or negative.
Definition: sortresult.cxx:418
void ResortModified(EventList *pList)
sal_Int32 mnCount
Definition: sortresult.hxx:113
void SetChanged(sal_Int32 nPos, sal_Int32 nCount)
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
moves the cursor to the given row number in the result set.
Definition: sortresult.cxx:356
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
Definition: sortresult.cxx:198
void Move(sal_Int32 nPos, sal_Int32 nCount, sal_Int32 nOffset)
css::uno::Reference< css::sdbc::XResultSet > mxOther
Definition: sortresult.hxx:103
virtual void SAL_CALL removePropertyChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &Listener) override
Definition: sortresult.cxx:790
virtual ~SortedResultSet() override
Definition: sortresult.cxx:96
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
Definition: sortresult.cxx:673
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: sortresult.cxx:810
std::mutex maMutex
Definition: sortresult.hxx:107
virtual OUString SAL_CALL queryContentIdentifierString() override
Definition: sortresult.cxx:190
virtual sal_Bool SAL_CALL last() override
Definition: sortresult.cxx:307
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
Definition: sortresult.cxx:586
sal_Int32 Compare(SortListData const *pOne, SortListData const *pTwo)
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
Definition: sortresult.cxx:620
static sal_Int32 CompareImpl(const css::uno::Reference< css::sdbc::XResultSet > &xResultOne, const css::uno::Reference< css::sdbc::XResultSet > &xResultTwo, sal_Int32 nIndexOne, sal_Int32 nIndexTwo, SortInfo const *pSortInfo)
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
Definition: sortresult.cxx:592
virtual sal_Int32 SAL_CALL getRow() override
Definition: sortresult.cxx:325
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: sortresult.cxx:125
sal_Int32 mnLastSort
keeps track of modified entries
Definition: sortresult.hxx:111
virtual sal_Bool SAL_CALL first() override
Definition: sortresult.cxx:289
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, css::beans::XPropertyChangeListener > maPropChangeListeners
Definition: sortresult.hxx:99
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
Definition: sortresult.cxx:650
void CopyData(SortedResultSet *pSource)
void PropertyChanged(const css::beans::PropertyChangeEvent &rEvt)
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
Definition: sortresult.cxx:627
virtual void SAL_CALL close() override
Definition: sortresult.cxx:697
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: sortresult.cxx:742
void Initialize(const css::uno::Sequence< css::ucb::NumberedSortingInfo > &xSortInfo, const css::uno::Reference< css::ucb::XAnyCompareFactory > &xCompFac)
SortedResultSet(css::uno::Reference< css::sdbc::XResultSet > const &aResult)
Definition: sortresult.cxx:85
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
Definition: sortresult.cxx:613
sal_Int32 GetCount() const
Definition: sortresult.hxx:145
virtual sal_Bool SAL_CALL previous() override
moves the cursor to the previous row in the result set.
Definition: sortresult.cxx:462
void BuildSortInfo(const css::uno::Reference< css::sdbc::XResultSet > &aResult, const css::uno::Sequence< css::ucb::NumberedSortingInfo > &xSortInfo, const css::uno::Reference< css::ucb::XAnyCompareFactory > &xCompFac)
virtual sal_Bool SAL_CALL isAfterLast() override
Definition: sortresult.cxx:246
css::uno::Reference< css::sdbc::XResultSet > mxOriginal
Definition: sortresult.hxx:102
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, css::beans::XVetoableChangeListener > maVetoChangeListeners
Definition: sortresult.hxx:100
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > maDisposeEventListeners
Definition: sortresult.hxx:98
rtl::Reference< SRSPropertySetInfo > mpPropSetInfo
Definition: sortresult.hxx:105
void CheckProperties(sal_Int32 nOldCount, bool bWasFinal)
virtual sal_Bool SAL_CALL rowUpdated() override
Definition: sortresult.cxx:496
virtual void SAL_CALL afterLast() override
Definition: sortresult.cxx:281
virtual sal_Bool SAL_CALL wasNull() override
Definition: sortresult.cxx:551
virtual void SAL_CALL addPropertyChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &Listener) override
Definition: sortresult.cxx:780
virtual void SAL_CALL beforeFirst() override
Definition: sortresult.cxx:273
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: sortresult.cxx:718
virtual void SAL_CALL setPropertyValue(const OUString &PropertyName, const css::uno::Any &Value) override
Definition: sortresult.cxx:731
virtual sal_Bool SAL_CALL isBeforeFirst() override
Definition: sortresult.cxx:237
std::deque< sal_IntPtr > m_O2S
Definition: sortresult.hxx:109
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: sortresult.cxx:657
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
Definition: sortresult.cxx:558
SortInfo * mpSortInfo
Definition: sortresult.hxx:106
void InsertNew(sal_Int32 nPos, sal_Int32 nCount)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: sortresult.cxx:130
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &Listener) override
Definition: sortresult.cxx:800
SortedEntryList maS2O
Definition: sortresult.hxx:108
virtual sal_Bool SAL_CALL isFirst() override
Definition: sortresult.cxx:255
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
Definition: sortresult.cxx:687
virtual sal_Bool SAL_CALL isLast() override
Definition: sortresult.cxx:264
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
Definition: sortresult.cxx:599
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
Definition: sortresult.cxx:634
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) const
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
sal_Int32 removeInterface(::std::unique_lock<::std::mutex > &rGuard, const key &rKey, const css::uno::Reference< listener > &rListener)
bool hasContainedTypes(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 addInterface(::std::unique_lock<::std::mutex > &rGuard, const key &rKey, const css::uno::Reference< listener > &rListener)
void disposeAndClear(std::unique_lock< std::mutex > &rGuard, const css::lang::EventObject &rEvt)
OInterfaceContainerHelper4< listener > * getContainer(std::unique_lock< std::mutex > &rGuard, const key &rKey) const
css::uno::Type const & get()
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
sal_Int32 nIndex
OUString aName
void * p
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
class SAL_NO_VTABLE XPropertySet
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
OUString aPropName
constexpr OUStringLiteral RESULTSET_SERVICE_NAME
Definition: sortresult.hxx:85
bool mbAscending
Definition: sortresult.cxx:47
sal_Int32 mnColumn
Definition: sortresult.cxx:49
sal_Int32 mnType
Definition: sortresult.cxx:50
bool mbUseOwnCompare
Definition: sortresult.cxx:46
bool mbCaseSensitive
Definition: sortresult.cxx:48
Reference< XAnyCompare > mxCompareFunction
Definition: sortresult.cxx:52
SortInfo * mpNext
Definition: sortresult.cxx:51
sal_IntPtr mnCurPos
Definition: sortresult.cxx:59
sal_IntPtr mnOldPos
Definition: sortresult.cxx:60
SortListData(sal_IntPtr nPos)
bool mbModified
OUString Name
unsigned char sal_Bool
signed char sal_Int8