LibreOffice Module connectivity (master) 1
MacabResultSet.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 "MacabResultSet.hxx"
22#include "MacabAddressBook.hxx"
23#include "MacabRecords.hxx"
24#include "macabutilities.hxx"
26#include "MacabConnection.hxx"
27#include "macabcondition.hxx"
28#include "macaborder.hxx"
29#include <com/sun/star/beans/PropertyAttribute.hpp>
30#include <com/sun/star/sdbcx/CompareBookmark.hpp>
31#include <TConnection.hxx>
33#include <comphelper/types.hxx>
36#include <rtl/ref.hxx>
37#include <strings.hrc>
38
39using namespace connectivity::macab;
40using namespace cppu;
41using namespace css::uno;
42using namespace css::lang;
43using namespace css::beans;
44using namespace css::sdbc;
45using namespace css::sdbcx;
46using namespace css::io;
47using namespace css::util;
48
49IMPLEMENT_SERVICE_INFO(MacabResultSet, "com.sun.star.sdbc.drivers.MacabResultSet", "com.sun.star.sdbc.ResultSet");
50
51MacabResultSet::MacabResultSet(MacabCommonStatement* pStmt)
54 m_xStatement(pStmt),
55 m_aMacabRecords(),
56 m_nRowPos(-1),
57 m_bWasNull(true),
58 m_sTableName(MacabAddressBook::getDefaultTableName())
59{
60}
61
63{
64}
65
67{
68 rtl::Reference<MacabConnection> pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get());
69
70 m_aMacabRecords = pConnection->getAddressBook()->getMacabRecords(m_sTableName);
71}
72
74{
75 rtl::Reference<MacabConnection> pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get());
76 MacabRecords* allRecords;
77
78 allRecords = pConnection->getAddressBook()->getMacabRecords(m_sTableName);
79
80 // Bad table!! Throw exception?
81 if(allRecords == nullptr)
82 return;
83
84 if(m_aMacabRecords != nullptr && m_aMacabRecords != allRecords)
85 delete m_aMacabRecords;
86
87 // The copy constructor copies everything but records (including the
88 // maximum allocated size, which means that we'll never have to resize)
89 m_aMacabRecords = new MacabRecords(allRecords);
90
91 if(pCondition->isAlwaysFalse())
92 {
93 return;
94 }
95
97
98 for (iterator = allRecords->begin();
99 iterator != allRecords->end();
100 ++iterator)
101 {
102 if (pCondition->eval(*iterator))
103 m_aMacabRecords->insertRecord(*iterator);
104 }
105}
106
108{
109 // I do this with ints rather than an iterator because the ids will
110 // be changing when we change the order and ints are easier to deal
111 // with (for me).
112 sal_Int32 i, j, size, smallest;
114
115 for(i = 0; i < size; i++)
116 {
117 smallest = i;
118 for( j = i + 1; j < size; j++)
119 {
120 // if smallest > j
121 if(pOrder->compare(m_aMacabRecords->getRecord(smallest),
122 m_aMacabRecords->getRecord(j) ) > 0)
123 {
124 smallest = j;
125 }
126
127 }
128
129 if(smallest != i)
130 {
131 m_aMacabRecords->swap(i,smallest);
132 }
133 }
134
135}
136
137void MacabResultSet::setTableName(OUString const & _sTableName)
138{
139 m_sTableName = _sTableName;
140}
141
143{
145
146 ::osl::MutexGuard aGuard(m_aMutex);
147
148 m_xStatement.clear();
149 m_xMetaData.clear();
150}
151
153{
155 if (!aRet.hasValue())
156 aRet = MacabResultSet_BASE::queryInterface(rType);
157 return aRet;
158}
159
160void SAL_CALL MacabResultSet::acquire() noexcept
161{
162 MacabResultSet_BASE::acquire();
163}
164
165void SAL_CALL MacabResultSet::release() noexcept
166{
167 MacabResultSet_BASE::release();
168}
169
170Sequence< Type > SAL_CALL MacabResultSet::getTypes()
171{
176
177 return comphelper::concatSequences(aTypes.getTypes(), MacabResultSet_BASE::getTypes());
178}
179
180css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL MacabResultSet::getPropertySetInfo( )
181{
182 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
183}
184
185sal_Int32 SAL_CALL MacabResultSet::findColumn(const OUString& columnName)
186{
187 ::osl::MutexGuard aGuard( m_aMutex );
188 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
189
190 // find the first column with the name columnName
191 Reference< XResultSetMetaData > xMeta = getMetaData();
192 sal_Int32 nLen = xMeta->getColumnCount();
193
194 for (sal_Int32 i = 1; i <= nLen; ++i)
195 {
196 if (xMeta->isCaseSensitive(i) ?
197 columnName == xMeta->getColumnName(i) :
198 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
199 return i;
200 }
201
203 assert(false);
204 return 0; // Never reached
205}
206
207OUString SAL_CALL MacabResultSet::getString(sal_Int32 columnIndex)
208{
209 ::osl::MutexGuard aGuard( m_aMutex );
210 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
211
212 OUString aRet;
213 sal_Int32 nRecords = m_aMacabRecords->size();
214 m_bWasNull = true;
215
216 if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
217 {
218 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
219 macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
220 if(aField != nullptr)
221 {
222 if(aField->type == kABStringProperty)
223 {
224 aRet = CFStringToOUString(static_cast<CFStringRef>(aField->value));
225 m_bWasNull = false;
226 }
227 }
228 }
229
230// Trigger an exception if m_bWasNull is true?
231 return aRet;
232}
233
235{
236 ::osl::MutexGuard aGuard( m_aMutex );
237 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
238
240
241 return false;
242}
243
245{
246 ::osl::MutexGuard aGuard( m_aMutex );
247 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
248
250
251 return 0;
252}
253
254sal_Int16 SAL_CALL MacabResultSet::getShort(sal_Int32)
255{
256 ::osl::MutexGuard aGuard( m_aMutex );
257 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
258
260
261 return 0;
262}
263
264sal_Int32 SAL_CALL MacabResultSet::getInt(sal_Int32 columnIndex)
265{
266 ::osl::MutexGuard aGuard( m_aMutex );
267 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
268
269 sal_Int32 nRet = 0;
270 sal_Int32 nRecords = m_aMacabRecords->size();
271 m_bWasNull = true;
272
273 if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
274 {
275 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
276 macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
277 if(aField != nullptr)
278 {
279 if(aField->type == kABIntegerProperty)
280 {
281 CFNumberType numberType = CFNumberGetType( static_cast<CFNumberRef>(aField->value) );
282 // m_bWasNull now becomes whether getting the value was successful
283 // Should we check for the wrong type here, e.g., a float or a 64 bit int?
284 m_bWasNull = !CFNumberGetValue(static_cast<CFNumberRef>(aField->value), numberType, &nRet);
285 }
286 }
287 }
288
289// Trigger an exception if m_bWasNull is true?
290 return nRet;
291}
292
293sal_Int64 SAL_CALL MacabResultSet::getLong(sal_Int32 columnIndex)
294{
295 ::osl::MutexGuard aGuard( m_aMutex );
296 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
297
298 sal_Int64 nRet = 0;
299 sal_Int32 nRecords = m_aMacabRecords->size();
300 m_bWasNull = true;
301
302 if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
303 {
304 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
305 macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
306 if(aField != nullptr)
307 {
308 if(aField->type == kABIntegerProperty)
309 {
310 CFNumberType numberType = CFNumberGetType( static_cast<CFNumberRef>(aField->value) );
311 // m_bWasNull now becomes whether getting the value was successful
312 // Should we check for the wrong type here, e.g., a float or a 32 bit int?
313 m_bWasNull = !CFNumberGetValue(static_cast<CFNumberRef>(aField->value), numberType, &nRet);
314 }
315 }
316 }
317
318// Trigger an exception if m_bWasNull is true?
319 return nRet;
320}
321
322float SAL_CALL MacabResultSet::getFloat(sal_Int32 columnIndex)
323{
324 ::osl::MutexGuard aGuard( m_aMutex );
325 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
326
327 float nVal = 0;
328 sal_Int32 nRecords = m_aMacabRecords->size();
329 m_bWasNull = true;
330
331 if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
332 {
333 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
334 macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
335 if(aField != nullptr)
336 {
337 if(aField->type == kABRealProperty)
338 {
339 CFNumberType numberType = CFNumberGetType( static_cast<CFNumberRef>(aField->value) );
340 // m_bWasNull now becomes whether getting the value was successful
341 // Should we check for the wrong type here, e.g., an int or a double?
342 m_bWasNull = !CFNumberGetValue(static_cast<CFNumberRef>(aField->value), numberType, &nVal);
343 }
344 }
345 }
346
347// Trigger an exception if m_bWasNull is true?
348 return nVal;
349}
350
351double SAL_CALL MacabResultSet::getDouble(sal_Int32 columnIndex)
352{
353 ::osl::MutexGuard aGuard( m_aMutex );
354 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
355
356 double nVal = 0;
357 sal_Int32 nRecords = m_aMacabRecords->size();
358 m_bWasNull = true;
359
360 if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
361 {
362 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
363 macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
364 if(aField != nullptr)
365 {
366 if(aField->type == kABRealProperty)
367 {
368 CFNumberType numberType = CFNumberGetType( static_cast<CFNumberRef>(aField->value) );
369 // m_bWasNull now becomes whether getting the value was successful
370 // Should we check for the wrong type here, e.g., an int or a float?
371 m_bWasNull = !CFNumberGetValue(static_cast<CFNumberRef>(aField->value), numberType, &nVal);
372 }
373 }
374 }
375
376// Trigger an exception if m_bWasNull is true?
377 return nVal;
378}
379
380Sequence< sal_Int8 > SAL_CALL MacabResultSet::getBytes(sal_Int32)
381{
382 ::osl::MutexGuard aGuard( m_aMutex );
383 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
384
386
387 return Sequence< sal_Int8 >();
388}
389
390Date SAL_CALL MacabResultSet::getDate(sal_Int32)
391{
392 ::osl::MutexGuard aGuard( m_aMutex );
393 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
394
396
397 Date aRet;
398 return aRet;
399}
400
401Time SAL_CALL MacabResultSet::getTime(sal_Int32)
402{
403 ::osl::MutexGuard aGuard( m_aMutex );
404 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
405
407
408 css::util::Time nRet;
409 return nRet;
410}
411
412DateTime SAL_CALL MacabResultSet::getTimestamp(sal_Int32 columnIndex)
413{
414 ::osl::MutexGuard aGuard( m_aMutex );
415 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
416
417 DateTime nRet;
418 sal_Int32 nRecords = m_aMacabRecords->size();
419 m_bWasNull = true;
420
421 if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
422 {
423 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
424 macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
425 if(aField != nullptr)
426 {
427 if(aField->type == kABDateProperty)
428 {
429 nRet = CFDateToDateTime(static_cast<CFDateRef>(aField->value));
430 m_bWasNull = false;
431 }
432 }
433 }
434
435// Trigger an exception if m_bWasNull is true?
436 return nRet;
437}
438
439Reference< XInputStream > SAL_CALL MacabResultSet::getBinaryStream(sal_Int32)
440{
441 ::osl::MutexGuard aGuard( m_aMutex );
442 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
443
444 ::dbtools::throwFunctionNotSupportedSQLException("getBinaryStream", nullptr);
445
446 return nullptr;
447}
448
449Reference< XInputStream > SAL_CALL MacabResultSet::getCharacterStream(sal_Int32)
450{
451 ::osl::MutexGuard aGuard( m_aMutex );
452 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
453
454 ::dbtools::throwFunctionNotSupportedSQLException("getCharacterStream", nullptr);
455
456 return nullptr;
457}
458
459Any SAL_CALL MacabResultSet::getObject(sal_Int32, const Reference< css::container::XNameAccess >&)
460{
461 ::osl::MutexGuard aGuard( m_aMutex );
462 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
463
465
466 return Any();
467}
468
469Reference< XRef > SAL_CALL MacabResultSet::getRef(sal_Int32)
470{
471 ::osl::MutexGuard aGuard( m_aMutex );
472 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
473
475
476 return nullptr;
477}
478
479Reference< XBlob > SAL_CALL MacabResultSet::getBlob(sal_Int32)
480{
481 ::osl::MutexGuard aGuard( m_aMutex );
482 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
483
485
486 return nullptr;
487}
488
489Reference< XClob > SAL_CALL MacabResultSet::getClob(sal_Int32)
490{
491 ::osl::MutexGuard aGuard( m_aMutex );
492 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
493
495
496 return nullptr;
497}
498
499Reference< XArray > SAL_CALL MacabResultSet::getArray(sal_Int32)
500{
501 ::osl::MutexGuard aGuard( m_aMutex );
502 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
503
505
506 return nullptr;
507}
508
509Reference< XResultSetMetaData > SAL_CALL MacabResultSet::getMetaData()
510{
511 ::osl::MutexGuard aGuard( m_aMutex );
512 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
513
514 if (!m_xMetaData.is())
516
517 Reference< XResultSetMetaData > xMetaData = m_xMetaData;
518 return xMetaData;
519}
520
522{
523 ::osl::MutexGuard aGuard( m_aMutex );
524 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
525
526 if (m_nRowPos == -1)
527 return true;
528
529 return false;
530}
531
533{
534 ::osl::MutexGuard aGuard( m_aMutex );
535 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
536
537 sal_Int32 nRecords = m_aMacabRecords->size();
538 if (m_nRowPos == nRecords)
539 return true;
540
541 return false;
542}
543
545{
546 ::osl::MutexGuard aGuard( m_aMutex );
547 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
548
549 if (m_nRowPos == 0)
550 return true;
551
552 return false;
553}
554
556{
557 ::osl::MutexGuard aGuard( m_aMutex );
558 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
559
560 sal_Int32 nRecords = m_aMacabRecords->size();
561 if (m_nRowPos == nRecords - 1)
562 return true;
563
564 return false;
565}
566
568{
569 ::osl::MutexGuard aGuard( m_aMutex );
570 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
571
572 // move before the first row
573 m_nRowPos = -1;
574}
575
577{
578 ::osl::MutexGuard aGuard( m_aMutex );
579 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
580
581 // move after the last row
582 sal_Int32 nRecords = m_aMacabRecords->size();
583 m_nRowPos = nRecords;
584}
585
587{
588 {
589 ::osl::MutexGuard aGuard( m_aMutex );
590 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
591 }
592 dispose();
593}
594
596{
597 ::osl::MutexGuard aGuard( m_aMutex );
598 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
599
600 sal_Int32 nRecords = m_aMacabRecords->size();
601 if (nRecords == 0)
602 return false;
603
604 m_nRowPos = 0;
605 return true;
606}
607
609{
610 ::osl::MutexGuard aGuard( m_aMutex );
611 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
612
613 sal_Int32 nRecords = m_aMacabRecords->size();
614 if (nRecords == 0)
615 return false;
616
617 m_nRowPos = nRecords - 1;
618 return true;
619}
620
621sal_Int32 SAL_CALL MacabResultSet::getRow()
622{
623 ::osl::MutexGuard aGuard( m_aMutex );
624 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
625
626 return m_nRowPos;
627}
628
629sal_Bool SAL_CALL MacabResultSet::absolute(sal_Int32 row)
630{
631 ::osl::MutexGuard aGuard( m_aMutex );
632 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
633
634 sal_Int32 nRecords = m_aMacabRecords->size();
635 if (row <= -1 ||
636 row >= nRecords)
637 return false;
638
639 m_nRowPos = row;
640 return true;
641}
642
643sal_Bool SAL_CALL MacabResultSet::relative(sal_Int32 row)
644{
645 ::osl::MutexGuard aGuard( m_aMutex );
646 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
647
648 return absolute(m_nRowPos + row);
649}
650
652{
653 ::osl::MutexGuard aGuard( m_aMutex );
654 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
655
656 return absolute(m_nRowPos + 1);
657}
658
660{
661 ::osl::MutexGuard aGuard( m_aMutex );
662 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
663
664 return absolute(m_nRowPos - 1);
665}
666
667Reference< XInterface > SAL_CALL MacabResultSet::getStatement()
668{
669 ::osl::MutexGuard aGuard( m_aMutex );
670 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
671
672 Reference< XStatement > xStatement = m_xStatement;
673 return xStatement;
674}
675
677{
678 ::osl::MutexGuard aGuard( m_aMutex );
679 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
680
681 return false;
682}
683
685{
686 ::osl::MutexGuard aGuard( m_aMutex );
687 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
688
689 return false;
690}
691
693{
694 ::osl::MutexGuard aGuard( m_aMutex );
695 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
696
697 return false;
698}
699
701{
702 ::osl::MutexGuard aGuard( m_aMutex );
703 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
704
705 return m_bWasNull;
706}
707
709{
710 ::osl::MutexGuard aGuard( m_aMutex );
711 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
712}
713
715{
716}
717
719{
720 return Any();
721}
722
724{
725 ::osl::MutexGuard aGuard( m_aMutex );
726 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
727
728 // you only have to implement this if you want to insert new rows
729}
730
732{
733 ::osl::MutexGuard aGuard( m_aMutex );
734 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
735
736 // only when you allow updates
737}
738
740{
741 ::osl::MutexGuard aGuard( m_aMutex );
742 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
743}
744
746{
747 ::osl::MutexGuard aGuard( m_aMutex );
748 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
749}
750
752{
753 ::osl::MutexGuard aGuard( m_aMutex );
754 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
755
756 // only when you allow inserts
757}
758
760{
761 ::osl::MutexGuard aGuard( m_aMutex );
762 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
763}
764
765void SAL_CALL MacabResultSet::updateNull(sal_Int32)
766{
767 ::osl::MutexGuard aGuard( m_aMutex );
768 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
769}
770
772{
773 ::osl::MutexGuard aGuard( m_aMutex );
774 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
775}
776
777void SAL_CALL MacabResultSet::updateByte(sal_Int32, sal_Int8)
778{
779 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
780 ::osl::MutexGuard aGuard( m_aMutex );
781}
782
783void SAL_CALL MacabResultSet::updateShort(sal_Int32, sal_Int16)
784{
785 ::osl::MutexGuard aGuard( m_aMutex );
786 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
787}
788
789void SAL_CALL MacabResultSet::updateInt(sal_Int32, sal_Int32)
790{
791 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
792 ::osl::MutexGuard aGuard( m_aMutex );
793}
794
795void SAL_CALL MacabResultSet::updateLong(sal_Int32, sal_Int64)
796{
797 ::osl::MutexGuard aGuard( m_aMutex );
798 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
799}
800
801void SAL_CALL MacabResultSet::updateFloat(sal_Int32, float)
802{
803 ::osl::MutexGuard aGuard( m_aMutex );
804 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
805}
806
807void SAL_CALL MacabResultSet::updateDouble(sal_Int32, double)
808{
809 ::osl::MutexGuard aGuard( m_aMutex );
810 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
811}
812
813void SAL_CALL MacabResultSet::updateString(sal_Int32, const OUString&)
814{
815 ::osl::MutexGuard aGuard( m_aMutex );
816 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
817}
818
819void SAL_CALL MacabResultSet::updateBytes(sal_Int32, const Sequence< sal_Int8 >&)
820{
821 ::osl::MutexGuard aGuard( m_aMutex );
822 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
823}
824
825void SAL_CALL MacabResultSet::updateDate(sal_Int32, const Date&)
826{
827 ::osl::MutexGuard aGuard( m_aMutex );
828 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
829}
830
831void SAL_CALL MacabResultSet::updateTime(sal_Int32, const css::util::Time&)
832{
833 ::osl::MutexGuard aGuard( m_aMutex );
834 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
835}
836
837void SAL_CALL MacabResultSet::updateTimestamp(sal_Int32, const DateTime&)
838{
839 ::osl::MutexGuard aGuard( m_aMutex );
840 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
841}
842
843void SAL_CALL MacabResultSet::updateBinaryStream(sal_Int32, const Reference< XInputStream >&, sal_Int32)
844{
845 ::osl::MutexGuard aGuard( m_aMutex );
846 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
847}
848
849void SAL_CALL MacabResultSet::updateCharacterStream(sal_Int32, const Reference< XInputStream >&, sal_Int32)
850{
851 ::osl::MutexGuard aGuard( m_aMutex );
852 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
853}
854
856{
857 ::osl::MutexGuard aGuard( m_aMutex );
858 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
859}
860
861void SAL_CALL MacabResultSet::updateObject(sal_Int32, const Any&)
862{
863 ::osl::MutexGuard aGuard( m_aMutex );
864 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
865}
866
867void SAL_CALL MacabResultSet::updateNumericObject(sal_Int32, const Any&, sal_Int32)
868{
869 ::osl::MutexGuard aGuard( m_aMutex );
870 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
871}
872
873// XRowLocate
875{
876 ::osl::MutexGuard aGuard( m_aMutex );
877 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
878
879 sal_Int32 nRecords = m_aMacabRecords->size();
880
881 if (m_nRowPos != -1 && m_nRowPos != nRecords)
882 {
883 macabfield *uidField = m_aMacabRecords->getField(m_nRowPos,u"UID");
884 if(uidField != nullptr)
885 {
886 if(uidField->type == kABStringProperty)
887 {
888 return Any(CFStringToOUString( static_cast<CFStringRef>(uidField->value) ));
889 }
890 }
891 }
892 return Any();
893}
894
895sal_Bool SAL_CALL MacabResultSet::moveToBookmark(const Any& bookmark)
896{
897 ::osl::MutexGuard aGuard( m_aMutex );
898 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
899
900 OUString sBookmark = comphelper::getString(bookmark);
901 sal_Int32 nRecords = m_aMacabRecords->size();
902
903 for (sal_Int32 nRow = 0; nRow < nRecords; nRow++)
904 {
905 macabfield *uidField = m_aMacabRecords->getField(m_nRowPos,u"UID");
906 if(uidField != nullptr)
907 {
908 if(uidField->type == kABStringProperty)
909 {
910 OUString sUniqueIdentifier = CFStringToOUString( static_cast<CFStringRef>(uidField->value) );
911 if (sUniqueIdentifier == sBookmark)
912 {
913 m_nRowPos = nRow;
914 return true;
915 }
916 }
917 }
918 }
919 return false;
920}
921
922sal_Bool SAL_CALL MacabResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows)
923{
924 ::osl::MutexGuard aGuard( m_aMutex );
925 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
926
927 sal_Int32 nRowSave = m_nRowPos;
928
929 if (moveToBookmark(bookmark))
930 {
931 sal_Int32 nRecords = m_aMacabRecords->size();
932
933 m_nRowPos += rows;
934
935 if (-1 < m_nRowPos && m_nRowPos < nRecords)
936 return true;
937 }
938
939 m_nRowPos = nRowSave;
940 return false;
941}
942
943sal_Int32 SAL_CALL MacabResultSet::compareBookmarks(const Any& firstItem, const Any& secondItem)
944{
945 ::osl::MutexGuard aGuard( m_aMutex );
946 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
947
948 OUString sFirst = comphelper::getString(firstItem);
949 OUString sSecond = comphelper::getString(secondItem);
950
951 if (sFirst < sSecond)
952 return CompareBookmark::LESS;
953 if (sFirst > sSecond)
954 return CompareBookmark::GREATER;
955 return CompareBookmark::EQUAL;
956}
957
959{
960 return false;
961}
962
963sal_Int32 SAL_CALL MacabResultSet::hashBookmark(const Any& bookmark)
964{
965 ::osl::MutexGuard aGuard( m_aMutex );
966 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
967
968 OUString sBookmark = comphelper::getString(bookmark);
969
970 return sBookmark.hashCode();
971}
972
973// XDeleteRows
974Sequence< sal_Int32 > SAL_CALL MacabResultSet::deleteRows(const Sequence< Any >&)
975{
976 ::osl::MutexGuard aGuard( m_aMutex );
977 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
978
979 return Sequence< sal_Int32 >();
980}
981
983{
984 return new OPropertyArrayHelper
985 {
986 {
987 {
991 PropertyAttribute::READONLY
992 },
993 {
997 0
998 },
999 {
1003 0
1004 },
1005 {
1009 PropertyAttribute::READONLY
1010 },
1011 {
1015 PropertyAttribute::READONLY
1016 },
1017 {
1021 PropertyAttribute::READONLY
1022 }
1023 }
1024 };
1025}
1026
1028{
1029 return *getArrayHelper();
1030}
1031
1033 Any &,
1034 Any &,
1035 sal_Int32 nHandle,
1036 const Any& )
1037{
1038 switch (nHandle)
1039 {
1044 throw css::lang::IllegalArgumentException();
1045 break;
1048 default:
1049 ;
1050 }
1051 return false;
1052}
1053
1055 sal_Int32 nHandle,
1056 const Any& )
1057{
1058 switch (nHandle)
1059 {
1064 throw Exception("cannot set prop " + OUString::number(nHandle), nullptr);
1065 break;
1067 break;
1069 break;
1070 default:
1071 ;
1072 }
1073}
1074
1076 Any& _rValue,
1077 sal_Int32 nHandle) const
1078{
1079 switch (nHandle)
1080 {
1082 _rValue <<= false;
1083 break;
1089 ;
1090 }
1091}
1092
1093
1094/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPLEMENT_SERVICE_INFO(MacabResultSet, "com.sun.star.sdbc.drivers.MacabResultSet", "com.sun.star.sdbc.ResultSet")
OUString m_sTableName
void disposing(std::unique_lock< std::mutex > &rGuard)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
virtual bool isAlwaysFalse() const =0
virtual bool eval(const MacabRecord *aRecord) const =0
virtual sal_Int32 compare(const MacabRecord *record1, const MacabRecord *record2) const =0
void swap(const sal_Int32 _id1, const sal_Int32 _id2)
macabfield * getField(const sal_Int32 _recordNumber, const sal_Int32 _columnNumber) const
MacabRecord * insertRecord(MacabRecord *_newRecord, const sal_Int32 _location)
MacabRecord * getRecord(const sal_Int32 _location) const
virtual void SAL_CALL updateBoolean(sal_Int32 columnIndex, sal_Bool x) override
void sortMacabRecords(const class MacabOrder *pOrder)
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
virtual void SAL_CALL updateRow() override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL isLast() override
virtual void SAL_CALL updateNumericObject(sal_Int32 columnIndex, const css::uno::Any &x, sal_Int32 scale) override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL isAfterLast() override
virtual sal_Bool SAL_CALL previous() override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual void SAL_CALL updateObject(sal_Int32 columnIndex, const css::uno::Any &x) override
virtual void SAL_CALL clearWarnings() override
void someMacabRecords(const class MacabCondition *pCondition)
virtual void SAL_CALL updateFloat(sal_Int32 columnIndex, float x) override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual void SAL_CALL moveToInsertRow() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
void setTableName(const OUString &_sTableName)
virtual void SAL_CALL release() noexcept override
virtual sal_Int32 SAL_CALL getRow() override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
::rtl::Reference< MacabCommonStatement > m_xStatement
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual void SAL_CALL updateByte(sal_Int32 columnIndex, sal_Int8 x) override
virtual void SAL_CALL beforeFirst() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL updateNull(sal_Int32 columnIndex) override
virtual void SAL_CALL moveToCurrentRow() override
virtual sal_Bool SAL_CALL rowDeleted() override
virtual void SAL_CALL updateTimestamp(sal_Int32 columnIndex, const css::util::DateTime &x) override
virtual void SAL_CALL updateShort(sal_Int32 columnIndex, sal_Int16 x) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL updateLong(sal_Int32 columnIndex, sal_Int64 x) override
virtual void SAL_CALL updateBytes(sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 > &x) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows(const css::uno::Sequence< css::uno::Any > &rows) override
virtual void SAL_CALL cancelRowUpdates() override
virtual void SAL_CALL updateInt(sal_Int32 columnIndex, sal_Int32 x) override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void SAL_CALL refreshRow() override
virtual sal_Bool SAL_CALL moveRelativeToBookmark(const css::uno::Any &bookmark, sal_Int32 rows) override
virtual sal_Int32 SAL_CALL compareBookmarks(const css::uno::Any &firstItem, const css::uno::Any &secondItem) override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL afterLast() override
virtual sal_Bool SAL_CALL isFirst() override
virtual sal_Bool SAL_CALL wasNull() override
virtual sal_Int32 SAL_CALL hashBookmark(const css::uno::Any &bookmark) override
::rtl::Reference< MacabResultSetMetaData > m_xMetaData
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
virtual void SAL_CALL updateTime(sal_Int32 columnIndex, const css::util::Time &x) override
virtual sal_Bool SAL_CALL hasOrderedBookmarks() override
virtual sal_Bool SAL_CALL moveToBookmark(const css::uno::Any &bookmark) override
virtual void SAL_CALL insertRow() override
virtual void SAL_CALL close() override
virtual void SAL_CALL updateDouble(sal_Int32 columnIndex, double x) override
virtual void SAL_CALL updateBinaryStream(sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual sal_Bool SAL_CALL isBeforeFirst() override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual void SAL_CALL updateString(sal_Int32 columnIndex, const OUString &x) override
virtual sal_Bool SAL_CALL next() override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual void SAL_CALL updateDate(sal_Int32 columnIndex, const css::util::Date &x) override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual css::uno::Any SAL_CALL getWarnings() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual void SAL_CALL cancel() override
virtual css::uno::Any SAL_CALL getBookmark() override
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual sal_Bool SAL_CALL rowUpdated() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL last() override
virtual void SAL_CALL acquire() noexcept override
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual sal_Bool SAL_CALL rowInserted() override
virtual void SAL_CALL updateCharacterStream(sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual sal_Bool SAL_CALL first() override
virtual void SAL_CALL deleteRow() override
mutable::osl::Mutex m_aMutex
css::uno::Type const & get()
const OUString & getNameByIndex(sal_Int32 _nIndex) const
Definition: propertyids.cxx:95
float u
std::mutex m_aMutex
size
@ Exception
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
OUString getString(const Any &_rAny)
Type
::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier, css::util::XCancellable, css::sdbc::XWarningsSupplier, css::sdbc::XResultSetUpdate, css::sdbc::XRowUpdate, css::sdbcx::XRowLocate, css::sdbcx::XDeleteRows, css::sdbc::XCloseable, css::sdbc::XColumnLocate, css::lang::XServiceInfo > MacabResultSet_BASE
css::util::DateTime CFDateToDateTime(const CFDateRef _cfDate)
OUString CFStringToOUString(const CFStringRef sOrig)
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
void throwFunctionNotSupportedSQLException(const OUString &_rFunctionName, const css::uno::Reference< css::uno::XInterface > &_rxContext)
throws an exception with SQL state IM001, saying that a certain function is not supported
void throwInvalidColumnException(const OUString &_rColumnName, const Reference< XInterface > &_rxContext)
int i
void dispose()
const char * columnName
Definition: pq_statics.cxx:56
#define PROPERTY_ID_ISBOOKMARKABLE
Definition: propertyids.hxx:82
#define PROPERTY_ID_RESULTSETTYPE
Definition: propertyids.hxx:44
#define PROPERTY_ID_CURSORNAME
Definition: propertyids.hxx:42
#define PROPERTY_ID_RESULTSETCONCURRENCY
Definition: propertyids.hxx:43
#define PROPERTY_ID_FETCHSIZE
Definition: propertyids.hxx:46
#define PROPERTY_ID_FETCHDIRECTION
Definition: propertyids.hxx:45
sal_Int32 nHandle
unsigned char sal_Bool
signed char sal_Int8
const SvXMLTokenMapEntry aTypes[]