1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "MacabResultSet.hxx"
22 #include "MacabAddressBook.hxx"
23 #include "MacabRecords.hxx"
24 #include "macabutilities.hxx"
25 #include "MacabResultSetMetaData.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>
32 #include <cppuhelper/typeprovider.hxx>
33 #include <comphelper/types.hxx>
34 #include <connectivity/dbexception.hxx>
35 #include <resource/sharedresources.hxx>
36 #include <rtl/ref.hxx>
37 #include <strings.hrc>
39 using namespace connectivity::macab
;
41 using namespace css::uno
;
42 using namespace css::lang
;
43 using namespace css::beans
;
44 using namespace css::sdbc
;
45 using namespace css::sdbcx
;
46 using namespace css::io
;
47 using namespace css::util
;
49 IMPLEMENT_SERVICE_INFO(MacabResultSet
, "com.sun.star.sdbc.drivers.MacabResultSet", "com.sun.star.sdbc.ResultSet");
51 MacabResultSet::MacabResultSet(MacabCommonStatement
* pStmt
)
52 : MacabResultSet_BASE(m_aMutex
),
53 OPropertySetHelper(MacabResultSet_BASE::rBHelper
),
58 m_sTableName(MacabAddressBook::getDefaultTableName())
62 MacabResultSet::~MacabResultSet()
66 void MacabResultSet::allMacabRecords()
68 rtl::Reference
<MacabConnection
> pConnection
= static_cast< MacabConnection
*>(m_xStatement
->getConnection().get());
70 m_aMacabRecords
= pConnection
->getAddressBook()->getMacabRecords(m_sTableName
);
73 void MacabResultSet::someMacabRecords(const MacabCondition
*pCondition
)
75 rtl::Reference
<MacabConnection
> pConnection
= static_cast< MacabConnection
*>(m_xStatement
->getConnection().get());
76 MacabRecords
* allRecords
;
78 allRecords
= pConnection
->getAddressBook()->getMacabRecords(m_sTableName
);
80 // Bad table!! Throw exception?
81 if(allRecords
== nullptr)
84 if(m_aMacabRecords
!= nullptr && m_aMacabRecords
!= allRecords
)
85 delete m_aMacabRecords
;
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
);
91 if(pCondition
->isAlwaysFalse())
96 MacabRecords::iterator iterator
;
98 for (iterator
= allRecords
->begin();
99 iterator
!= allRecords
->end();
102 if (pCondition
->eval(*iterator
))
103 m_aMacabRecords
->insertRecord(*iterator
);
107 void MacabResultSet::sortMacabRecords(const MacabOrder
*pOrder
)
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
112 sal_Int32 i
, j
, size
, smallest
;
113 size
= m_aMacabRecords
->size();
115 for(i
= 0; i
< size
; i
++)
118 for( j
= i
+ 1; j
< size
; j
++)
121 if(pOrder
->compare(m_aMacabRecords
->getRecord(smallest
),
122 m_aMacabRecords
->getRecord(j
) ) > 0)
131 m_aMacabRecords
->swap(i
,smallest
);
137 void MacabResultSet::setTableName(OUString
const & _sTableName
)
139 m_sTableName
= _sTableName
;
142 void MacabResultSet::disposing()
144 OPropertySetHelper::disposing();
146 ::osl::MutexGuard
aGuard(m_aMutex
);
148 m_xStatement
.clear();
152 Any SAL_CALL
MacabResultSet::queryInterface(const Type
& rType
)
154 Any aRet
= OPropertySetHelper::queryInterface(rType
);
155 if (!aRet
.hasValue())
156 aRet
= MacabResultSet_BASE::queryInterface(rType
);
160 void SAL_CALL
MacabResultSet::acquire() noexcept
162 MacabResultSet_BASE::acquire();
165 void SAL_CALL
MacabResultSet::release() noexcept
167 MacabResultSet_BASE::release();
170 Sequence
< Type
> SAL_CALL
MacabResultSet::getTypes()
172 OTypeCollection
aTypes(
173 cppu::UnoType
<css::beans::XMultiPropertySet
>::get(),
174 cppu::UnoType
<css::beans::XFastPropertySet
>::get(),
175 cppu::UnoType
<css::beans::XPropertySet
>::get());
177 return comphelper::concatSequences(aTypes
.getTypes(), MacabResultSet_BASE::getTypes());
180 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
MacabResultSet::getPropertySetInfo( )
182 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
185 sal_Int32 SAL_CALL
MacabResultSet::findColumn(const OUString
& columnName
)
187 ::osl::MutexGuard
aGuard( m_aMutex
);
188 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
190 // find the first column with the name columnName
191 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
192 sal_Int32 nLen
= xMeta
->getColumnCount();
194 for (sal_Int32 i
= 1; i
<= nLen
; ++i
)
196 if (xMeta
->isCaseSensitive(i
) ?
197 columnName
== xMeta
->getColumnName(i
) :
198 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
)))
202 ::dbtools::throwInvalidColumnException( columnName
, *this );
204 return 0; // Never reached
207 OUString SAL_CALL
MacabResultSet::getString(sal_Int32 columnIndex
)
209 ::osl::MutexGuard
aGuard( m_aMutex
);
210 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
213 sal_Int32 nRecords
= m_aMacabRecords
->size();
216 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
218 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
219 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
220 if(aField
!= nullptr)
222 if(aField
->type
== kABStringProperty
)
224 aRet
= CFStringToOUString(static_cast<CFStringRef
>(aField
->value
));
230 // Trigger an exception if m_bWasNull is true?
234 sal_Bool SAL_CALL
MacabResultSet::getBoolean(sal_Int32
)
236 ::osl::MutexGuard
aGuard( m_aMutex
);
237 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
239 ::dbtools::throwFunctionNotSupportedSQLException("getBoolean", nullptr);
244 sal_Int8 SAL_CALL
MacabResultSet::getByte(sal_Int32
)
246 ::osl::MutexGuard
aGuard( m_aMutex
);
247 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
249 ::dbtools::throwFunctionNotSupportedSQLException("getByte", nullptr);
254 sal_Int16 SAL_CALL
MacabResultSet::getShort(sal_Int32
)
256 ::osl::MutexGuard
aGuard( m_aMutex
);
257 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
259 ::dbtools::throwFunctionNotSupportedSQLException("getShort", nullptr);
264 sal_Int32 SAL_CALL
MacabResultSet::getInt(sal_Int32 columnIndex
)
266 ::osl::MutexGuard
aGuard( m_aMutex
);
267 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
270 sal_Int32 nRecords
= m_aMacabRecords
->size();
273 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
275 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
276 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
277 if(aField
!= nullptr)
279 if(aField
->type
== kABIntegerProperty
)
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
);
289 // Trigger an exception if m_bWasNull is true?
293 sal_Int64 SAL_CALL
MacabResultSet::getLong(sal_Int32 columnIndex
)
295 ::osl::MutexGuard
aGuard( m_aMutex
);
296 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
299 sal_Int32 nRecords
= m_aMacabRecords
->size();
302 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
304 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
305 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
306 if(aField
!= nullptr)
308 if(aField
->type
== kABIntegerProperty
)
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
);
318 // Trigger an exception if m_bWasNull is true?
322 float SAL_CALL
MacabResultSet::getFloat(sal_Int32 columnIndex
)
324 ::osl::MutexGuard
aGuard( m_aMutex
);
325 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
328 sal_Int32 nRecords
= m_aMacabRecords
->size();
331 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
333 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
334 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
335 if(aField
!= nullptr)
337 if(aField
->type
== kABRealProperty
)
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
);
347 // Trigger an exception if m_bWasNull is true?
351 double SAL_CALL
MacabResultSet::getDouble(sal_Int32 columnIndex
)
353 ::osl::MutexGuard
aGuard( m_aMutex
);
354 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
357 sal_Int32 nRecords
= m_aMacabRecords
->size();
360 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
362 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
363 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
364 if(aField
!= nullptr)
366 if(aField
->type
== kABRealProperty
)
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
);
376 // Trigger an exception if m_bWasNull is true?
380 Sequence
< sal_Int8
> SAL_CALL
MacabResultSet::getBytes(sal_Int32
)
382 ::osl::MutexGuard
aGuard( m_aMutex
);
383 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
385 ::dbtools::throwFunctionNotSupportedSQLException("getBytes", nullptr);
387 return Sequence
< sal_Int8
>();
390 Date SAL_CALL
MacabResultSet::getDate(sal_Int32
)
392 ::osl::MutexGuard
aGuard( m_aMutex
);
393 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
395 ::dbtools::throwFunctionNotSupportedSQLException("getDate", nullptr);
401 Time SAL_CALL
MacabResultSet::getTime(sal_Int32
)
403 ::osl::MutexGuard
aGuard( m_aMutex
);
404 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
406 ::dbtools::throwFunctionNotSupportedSQLException("getTime", nullptr);
408 css::util::Time nRet
;
412 DateTime SAL_CALL
MacabResultSet::getTimestamp(sal_Int32 columnIndex
)
414 ::osl::MutexGuard
aGuard( m_aMutex
);
415 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
418 sal_Int32 nRecords
= m_aMacabRecords
->size();
421 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
423 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
424 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
425 if(aField
!= nullptr)
427 if(aField
->type
== kABDateProperty
)
429 nRet
= CFDateToDateTime(static_cast<CFDateRef
>(aField
->value
));
435 // Trigger an exception if m_bWasNull is true?
439 Reference
< XInputStream
> SAL_CALL
MacabResultSet::getBinaryStream(sal_Int32
)
441 ::osl::MutexGuard
aGuard( m_aMutex
);
442 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
444 ::dbtools::throwFunctionNotSupportedSQLException("getBinaryStream", nullptr);
449 Reference
< XInputStream
> SAL_CALL
MacabResultSet::getCharacterStream(sal_Int32
)
451 ::osl::MutexGuard
aGuard( m_aMutex
);
452 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
454 ::dbtools::throwFunctionNotSupportedSQLException("getCharacterStream", nullptr);
459 Any SAL_CALL
MacabResultSet::getObject(sal_Int32
, const Reference
< css::container::XNameAccess
>&)
461 ::osl::MutexGuard
aGuard( m_aMutex
);
462 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
464 ::dbtools::throwFunctionNotSupportedSQLException("getObject", nullptr);
469 Reference
< XRef
> SAL_CALL
MacabResultSet::getRef(sal_Int32
)
471 ::osl::MutexGuard
aGuard( m_aMutex
);
472 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
474 ::dbtools::throwFunctionNotSupportedSQLException("getRef", nullptr);
479 Reference
< XBlob
> SAL_CALL
MacabResultSet::getBlob(sal_Int32
)
481 ::osl::MutexGuard
aGuard( m_aMutex
);
482 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
484 ::dbtools::throwFunctionNotSupportedSQLException("getBlob", nullptr);
489 Reference
< XClob
> SAL_CALL
MacabResultSet::getClob(sal_Int32
)
491 ::osl::MutexGuard
aGuard( m_aMutex
);
492 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
494 ::dbtools::throwFunctionNotSupportedSQLException("getClob", nullptr);
499 Reference
< XArray
> SAL_CALL
MacabResultSet::getArray(sal_Int32
)
501 ::osl::MutexGuard
aGuard( m_aMutex
);
502 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
504 ::dbtools::throwFunctionNotSupportedSQLException("getArray", nullptr);
509 Reference
< XResultSetMetaData
> SAL_CALL
MacabResultSet::getMetaData()
511 ::osl::MutexGuard
aGuard( m_aMutex
);
512 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
514 if (!m_xMetaData
.is())
515 m_xMetaData
= new MacabResultSetMetaData(m_xStatement
->getOwnConnection(), m_sTableName
);
517 Reference
< XResultSetMetaData
> xMetaData
= m_xMetaData
;
521 sal_Bool SAL_CALL
MacabResultSet::isBeforeFirst()
523 ::osl::MutexGuard
aGuard( m_aMutex
);
524 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
532 sal_Bool SAL_CALL
MacabResultSet::isAfterLast()
534 ::osl::MutexGuard
aGuard( m_aMutex
);
535 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
537 sal_Int32 nRecords
= m_aMacabRecords
->size();
538 if (m_nRowPos
== nRecords
)
544 sal_Bool SAL_CALL
MacabResultSet::isFirst()
546 ::osl::MutexGuard
aGuard( m_aMutex
);
547 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
555 sal_Bool SAL_CALL
MacabResultSet::isLast()
557 ::osl::MutexGuard
aGuard( m_aMutex
);
558 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
560 sal_Int32 nRecords
= m_aMacabRecords
->size();
561 if (m_nRowPos
== nRecords
- 1)
567 void SAL_CALL
MacabResultSet::beforeFirst()
569 ::osl::MutexGuard
aGuard( m_aMutex
);
570 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
572 // move before the first row
576 void SAL_CALL
MacabResultSet::afterLast()
578 ::osl::MutexGuard
aGuard( m_aMutex
);
579 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
581 // move after the last row
582 sal_Int32 nRecords
= m_aMacabRecords
->size();
583 m_nRowPos
= nRecords
;
586 void SAL_CALL
MacabResultSet::close()
589 ::osl::MutexGuard
aGuard( m_aMutex
);
590 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
595 sal_Bool SAL_CALL
MacabResultSet::first()
597 ::osl::MutexGuard
aGuard( m_aMutex
);
598 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
600 sal_Int32 nRecords
= m_aMacabRecords
->size();
608 sal_Bool SAL_CALL
MacabResultSet::last()
610 ::osl::MutexGuard
aGuard( m_aMutex
);
611 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
613 sal_Int32 nRecords
= m_aMacabRecords
->size();
617 m_nRowPos
= nRecords
- 1;
621 sal_Int32 SAL_CALL
MacabResultSet::getRow()
623 ::osl::MutexGuard
aGuard( m_aMutex
);
624 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
629 sal_Bool SAL_CALL
MacabResultSet::absolute(sal_Int32 row
)
631 ::osl::MutexGuard
aGuard( m_aMutex
);
632 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
634 sal_Int32 nRecords
= m_aMacabRecords
->size();
643 sal_Bool SAL_CALL
MacabResultSet::relative(sal_Int32 row
)
645 ::osl::MutexGuard
aGuard( m_aMutex
);
646 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
648 return absolute(m_nRowPos
+ row
);
651 sal_Bool SAL_CALL
MacabResultSet::next()
653 ::osl::MutexGuard
aGuard( m_aMutex
);
654 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
656 return absolute(m_nRowPos
+ 1);
659 sal_Bool SAL_CALL
MacabResultSet::previous()
661 ::osl::MutexGuard
aGuard( m_aMutex
);
662 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
664 return absolute(m_nRowPos
- 1);
667 Reference
< XInterface
> SAL_CALL
MacabResultSet::getStatement()
669 ::osl::MutexGuard
aGuard( m_aMutex
);
670 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
672 Reference
< XStatement
> xStatement
= m_xStatement
;
676 sal_Bool SAL_CALL
MacabResultSet::rowDeleted()
678 ::osl::MutexGuard
aGuard( m_aMutex
);
679 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
684 sal_Bool SAL_CALL
MacabResultSet::rowInserted()
686 ::osl::MutexGuard
aGuard( m_aMutex
);
687 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
692 sal_Bool SAL_CALL
MacabResultSet::rowUpdated()
694 ::osl::MutexGuard
aGuard( m_aMutex
);
695 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
700 sal_Bool SAL_CALL
MacabResultSet::wasNull()
702 ::osl::MutexGuard
aGuard( m_aMutex
);
703 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
708 void SAL_CALL
MacabResultSet::cancel()
710 ::osl::MutexGuard
aGuard( m_aMutex
);
711 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
714 void SAL_CALL
MacabResultSet::clearWarnings()
718 Any SAL_CALL
MacabResultSet::getWarnings()
723 void SAL_CALL
MacabResultSet::insertRow()
725 ::osl::MutexGuard
aGuard( m_aMutex
);
726 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
728 // you only have to implement this if you want to insert new rows
731 void SAL_CALL
MacabResultSet::updateRow()
733 ::osl::MutexGuard
aGuard( m_aMutex
);
734 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
736 // only when you allow updates
739 void SAL_CALL
MacabResultSet::deleteRow()
741 ::osl::MutexGuard
aGuard( m_aMutex
);
742 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
745 void SAL_CALL
MacabResultSet::cancelRowUpdates()
747 ::osl::MutexGuard
aGuard( m_aMutex
);
748 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
751 void SAL_CALL
MacabResultSet::moveToInsertRow()
753 ::osl::MutexGuard
aGuard( m_aMutex
);
754 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
756 // only when you allow inserts
759 void SAL_CALL
MacabResultSet::moveToCurrentRow()
761 ::osl::MutexGuard
aGuard( m_aMutex
);
762 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
765 void SAL_CALL
MacabResultSet::updateNull(sal_Int32
)
767 ::osl::MutexGuard
aGuard( m_aMutex
);
768 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
771 void SAL_CALL
MacabResultSet::updateBoolean(sal_Int32
, sal_Bool
)
773 ::osl::MutexGuard
aGuard( m_aMutex
);
774 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
777 void SAL_CALL
MacabResultSet::updateByte(sal_Int32
, sal_Int8
)
779 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
780 ::osl::MutexGuard
aGuard( m_aMutex
);
783 void SAL_CALL
MacabResultSet::updateShort(sal_Int32
, sal_Int16
)
785 ::osl::MutexGuard
aGuard( m_aMutex
);
786 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
789 void SAL_CALL
MacabResultSet::updateInt(sal_Int32
, sal_Int32
)
791 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
792 ::osl::MutexGuard
aGuard( m_aMutex
);
795 void SAL_CALL
MacabResultSet::updateLong(sal_Int32
, sal_Int64
)
797 ::osl::MutexGuard
aGuard( m_aMutex
);
798 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
801 void SAL_CALL
MacabResultSet::updateFloat(sal_Int32
, float)
803 ::osl::MutexGuard
aGuard( m_aMutex
);
804 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
807 void SAL_CALL
MacabResultSet::updateDouble(sal_Int32
, double)
809 ::osl::MutexGuard
aGuard( m_aMutex
);
810 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
813 void SAL_CALL
MacabResultSet::updateString(sal_Int32
, const OUString
&)
815 ::osl::MutexGuard
aGuard( m_aMutex
);
816 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
819 void SAL_CALL
MacabResultSet::updateBytes(sal_Int32
, const Sequence
< sal_Int8
>&)
821 ::osl::MutexGuard
aGuard( m_aMutex
);
822 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
825 void SAL_CALL
MacabResultSet::updateDate(sal_Int32
, const Date
&)
827 ::osl::MutexGuard
aGuard( m_aMutex
);
828 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
831 void SAL_CALL
MacabResultSet::updateTime(sal_Int32
, const css::util::Time
&)
833 ::osl::MutexGuard
aGuard( m_aMutex
);
834 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
837 void SAL_CALL
MacabResultSet::updateTimestamp(sal_Int32
, const DateTime
&)
839 ::osl::MutexGuard
aGuard( m_aMutex
);
840 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
843 void SAL_CALL
MacabResultSet::updateBinaryStream(sal_Int32
, const Reference
< XInputStream
>&, sal_Int32
)
845 ::osl::MutexGuard
aGuard( m_aMutex
);
846 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
849 void SAL_CALL
MacabResultSet::updateCharacterStream(sal_Int32
, const Reference
< XInputStream
>&, sal_Int32
)
851 ::osl::MutexGuard
aGuard( m_aMutex
);
852 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
855 void SAL_CALL
MacabResultSet::refreshRow()
857 ::osl::MutexGuard
aGuard( m_aMutex
);
858 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
861 void SAL_CALL
MacabResultSet::updateObject(sal_Int32
, const Any
&)
863 ::osl::MutexGuard
aGuard( m_aMutex
);
864 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
867 void SAL_CALL
MacabResultSet::updateNumericObject(sal_Int32
, const Any
&, sal_Int32
)
869 ::osl::MutexGuard
aGuard( m_aMutex
);
870 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
874 Any SAL_CALL
MacabResultSet::getBookmark()
876 ::osl::MutexGuard
aGuard( m_aMutex
);
877 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
879 sal_Int32 nRecords
= m_aMacabRecords
->size();
881 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
)
883 macabfield
*uidField
= m_aMacabRecords
->getField(m_nRowPos
,u
"UID");
884 if(uidField
!= nullptr)
886 if(uidField
->type
== kABStringProperty
)
888 return makeAny(CFStringToOUString( static_cast<CFStringRef
>(uidField
->value
) ));
895 sal_Bool SAL_CALL
MacabResultSet::moveToBookmark(const Any
& bookmark
)
897 ::osl::MutexGuard
aGuard( m_aMutex
);
898 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
900 OUString sBookmark
= comphelper::getString(bookmark
);
901 sal_Int32 nRecords
= m_aMacabRecords
->size();
903 for (sal_Int32 nRow
= 0; nRow
< nRecords
; nRow
++)
905 macabfield
*uidField
= m_aMacabRecords
->getField(m_nRowPos
,u
"UID");
906 if(uidField
!= nullptr)
908 if(uidField
->type
== kABStringProperty
)
910 OUString sUniqueIdentifier
= CFStringToOUString( static_cast<CFStringRef
>(uidField
->value
) );
911 if (sUniqueIdentifier
== sBookmark
)
922 sal_Bool SAL_CALL
MacabResultSet::moveRelativeToBookmark(const Any
& bookmark
, sal_Int32 rows
)
924 ::osl::MutexGuard
aGuard( m_aMutex
);
925 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
927 sal_Int32 nRowSave
= m_nRowPos
;
929 if (moveToBookmark(bookmark
))
931 sal_Int32 nRecords
= m_aMacabRecords
->size();
935 if (-1 < m_nRowPos
&& m_nRowPos
< nRecords
)
939 m_nRowPos
= nRowSave
;
943 sal_Int32 SAL_CALL
MacabResultSet::compareBookmarks(const Any
& firstItem
, const Any
& secondItem
)
945 ::osl::MutexGuard
aGuard( m_aMutex
);
946 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
948 OUString sFirst
= comphelper::getString(firstItem
);
949 OUString sSecond
= comphelper::getString(secondItem
);
951 if (sFirst
< sSecond
)
952 return CompareBookmark::LESS
;
953 if (sFirst
> sSecond
)
954 return CompareBookmark::GREATER
;
955 return CompareBookmark::EQUAL
;
958 sal_Bool SAL_CALL
MacabResultSet::hasOrderedBookmarks()
963 sal_Int32 SAL_CALL
MacabResultSet::hashBookmark(const Any
& bookmark
)
965 ::osl::MutexGuard
aGuard( m_aMutex
);
966 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
968 OUString sBookmark
= comphelper::getString(bookmark
);
970 return sBookmark
.hashCode();
974 Sequence
< sal_Int32
> SAL_CALL
MacabResultSet::deleteRows(const Sequence
< Any
>&)
976 ::osl::MutexGuard
aGuard( m_aMutex
);
977 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
979 return Sequence
< sal_Int32
>();
982 IPropertyArrayHelper
* MacabResultSet::createArrayHelper() const
984 Sequence
< Property
> aProps(6);
985 Property
* pProperties
= aProps
.getArray();
987 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME
),
988 PROPERTY_ID_CURSORNAME
, cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
);
990 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION
),
991 PROPERTY_ID_FETCHDIRECTION
, cppu::UnoType
<sal_Int32
>::get(), 0);
993 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE
),
994 PROPERTY_ID_FETCHSIZE
, cppu::UnoType
<sal_Int32
>::get(), 0);
996 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE
),
997 PROPERTY_ID_ISBOOKMARKABLE
, cppu::UnoType
<bool>::get(), PropertyAttribute::READONLY
);
999 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY
),
1000 PROPERTY_ID_RESULTSETCONCURRENCY
, cppu::UnoType
<sal_Int32
>::get(), PropertyAttribute::READONLY
);
1002 pProperties
[nPos
++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE
),
1003 PROPERTY_ID_RESULTSETTYPE
, cppu::UnoType
<sal_Int32
>::get(), PropertyAttribute::READONLY
);
1005 return new OPropertyArrayHelper(aProps
);
1008 IPropertyArrayHelper
& MacabResultSet::getInfoHelper()
1010 return *getArrayHelper();
1013 sal_Bool
MacabResultSet::convertFastPropertyValue(
1021 case PROPERTY_ID_ISBOOKMARKABLE
:
1022 case PROPERTY_ID_CURSORNAME
:
1023 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1024 case PROPERTY_ID_RESULTSETTYPE
:
1025 throw css::lang::IllegalArgumentException();
1027 case PROPERTY_ID_FETCHDIRECTION
:
1028 case PROPERTY_ID_FETCHSIZE
:
1035 void MacabResultSet::setFastPropertyValue_NoBroadcast(
1041 case PROPERTY_ID_ISBOOKMARKABLE
:
1042 case PROPERTY_ID_CURSORNAME
:
1043 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1044 case PROPERTY_ID_RESULTSETTYPE
:
1045 throw Exception("cannot set prop " + OUString::number(nHandle
), nullptr);
1047 case PROPERTY_ID_FETCHDIRECTION
:
1049 case PROPERTY_ID_FETCHSIZE
:
1056 void MacabResultSet::getFastPropertyValue(
1058 sal_Int32 nHandle
) const
1062 case PROPERTY_ID_ISBOOKMARKABLE
:
1065 case PROPERTY_ID_CURSORNAME
:
1066 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1067 case PROPERTY_ID_RESULTSETTYPE
:
1068 case PROPERTY_ID_FETCHDIRECTION
:
1069 case PROPERTY_ID_FETCHSIZE
:
1075 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */