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 <connectivity/dbexception.hxx>
33 #include "resource/sharedresources.hxx"
34 #include "resource/macab_res.hrc"
36 using namespace connectivity::macab
;
38 using namespace css::uno
;
39 using namespace css::lang
;
40 using namespace css::beans
;
41 using namespace css::sdbc
;
42 using namespace css::sdbcx
;
43 using namespace css::io
;
44 using namespace css::util
;
46 IMPLEMENT_SERVICE_INFO(MacabResultSet
, "com.sun.star.sdbc.drivers.MacabResultSet", "com.sun.star.sdbc.ResultSet");
48 MacabResultSet::MacabResultSet(MacabCommonStatement
* pStmt
)
49 : MacabResultSet_BASE(m_aMutex
),
50 OPropertySetHelper(MacabResultSet_BASE::rBHelper
),
57 m_sTableName
= MacabAddressBook::getDefaultTableName();
60 MacabResultSet::~MacabResultSet()
64 void MacabResultSet::allMacabRecords()
66 MacabConnection
* pConnection
= static_cast< MacabConnection
*>(m_xStatement
->getConnection().get());
68 m_aMacabRecords
= pConnection
->getAddressBook()->getMacabRecords(m_sTableName
);
71 void MacabResultSet::someMacabRecords(const MacabCondition
*pCondition
)
73 MacabConnection
* pConnection
= static_cast< MacabConnection
*>(m_xStatement
->getConnection().get());
74 MacabRecords
* allRecords
;
76 allRecords
= pConnection
->getAddressBook()->getMacabRecords(m_sTableName
);
78 // Bad table!! Throw exception?
79 if(allRecords
== nullptr)
82 if(m_aMacabRecords
!= nullptr && m_aMacabRecords
!= allRecords
)
83 delete m_aMacabRecords
;
85 // The copy constructor copies everything but records (including the
86 // maximum allocated size, which means that we'll never have to resize)
87 m_aMacabRecords
= new MacabRecords(allRecords
);
89 if(pCondition
->isAlwaysFalse())
94 MacabRecords::iterator iterator
;
96 for (iterator
= allRecords
->begin();
97 iterator
!= allRecords
->end();
100 if (pCondition
->eval(*iterator
))
101 m_aMacabRecords
->insertRecord(*iterator
);
105 void MacabResultSet::sortMacabRecords(const MacabOrder
*pOrder
)
107 // I do this with ints rather than an iterator because the ids will
108 // be changing when we change the order and ints are easier to deal
110 sal_Int32 i
, j
, size
, smallest
;
111 size
= m_aMacabRecords
->size();
113 for(i
= 0; i
< size
; i
++)
116 for( j
= i
+ 1; j
< size
; j
++)
119 if(pOrder
->compare(m_aMacabRecords
->getRecord(smallest
),
120 m_aMacabRecords
->getRecord(j
) ) > 0)
129 m_aMacabRecords
->swap(i
,smallest
);
135 void MacabResultSet::setTableName(OUString
const & _sTableName
)
137 m_sTableName
= _sTableName
;
140 void MacabResultSet::disposing()
142 OPropertySetHelper::disposing();
144 ::osl::MutexGuard
aGuard(m_aMutex
);
146 m_xStatement
.clear();
150 Any SAL_CALL
MacabResultSet::queryInterface(const Type
& rType
) throw(RuntimeException
)
152 Any aRet
= OPropertySetHelper::queryInterface(rType
);
153 if (!aRet
.hasValue())
154 aRet
= MacabResultSet_BASE::queryInterface(rType
);
158 void SAL_CALL
MacabResultSet::acquire() throw()
160 MacabResultSet_BASE::acquire();
163 void SAL_CALL
MacabResultSet::release() throw()
165 MacabResultSet_BASE::release();
168 Sequence
< Type
> SAL_CALL
MacabResultSet::getTypes() throw(RuntimeException
)
170 OTypeCollection
aTypes(
171 cppu::UnoType
<css::beans::XMultiPropertySet
>::get(),
172 cppu::UnoType
<css::beans::XFastPropertySet
>::get(),
173 cppu::UnoType
<css::beans::XPropertySet
>::get());
175 return comphelper::concatSequences(aTypes
.getTypes(), MacabResultSet_BASE::getTypes());
178 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
MacabResultSet::getPropertySetInfo( ) throw(css::uno::RuntimeException
)
180 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
183 sal_Int32 SAL_CALL
MacabResultSet::findColumn(const OUString
& columnName
) throw(SQLException
, RuntimeException
)
185 ::osl::MutexGuard
aGuard( m_aMutex
);
186 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
188 // find the first column with the name columnName
189 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
190 sal_Int32 nLen
= xMeta
->getColumnCount();
192 for (sal_Int32 i
= 1; i
<= nLen
; ++i
)
194 if (xMeta
->isCaseSensitive(i
) ?
195 columnName
== xMeta
->getColumnName(i
) :
196 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
)))
200 ::dbtools::throwInvalidColumnException( columnName
, *this );
202 return 0; // Never reached
205 OUString SAL_CALL
MacabResultSet::getString(sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
207 ::osl::MutexGuard
aGuard( m_aMutex
);
208 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
211 sal_Int32 nRecords
= m_aMacabRecords
->size();
214 if (m_nRowPos
!= -1 && m_nRowPos
!= nRecords
&& m_xMetaData
.is())
216 sal_Int32 nFieldNumber
= m_xMetaData
->fieldAtColumn(columnIndex
);
217 macabfield
*aField
= m_aMacabRecords
->getField(m_nRowPos
,nFieldNumber
);
218 if(aField
!= nullptr)
220 if(aField
->type
== kABStringProperty
)
222 aRet
= CFStringToOUString(static_cast<CFStringRef
>(aField
->value
));
228 // Trigger an exception if m_bWasNull is true?
232 sal_Bool SAL_CALL
MacabResultSet::getBoolean(sal_Int32
) throw(SQLException
, RuntimeException
)
234 ::osl::MutexGuard
aGuard( m_aMutex
);
235 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
237 ::dbtools::throwFunctionNotSupportedSQLException("getBoolean", nullptr);
242 sal_Int8 SAL_CALL
MacabResultSet::getByte(sal_Int32
) throw(SQLException
, RuntimeException
)
244 ::osl::MutexGuard
aGuard( m_aMutex
);
245 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
247 ::dbtools::throwFunctionNotSupportedSQLException("getByte", nullptr);
253 sal_Int16 SAL_CALL
MacabResultSet::getShort(sal_Int32
) throw(SQLException
, RuntimeException
)
255 ::osl::MutexGuard
aGuard( m_aMutex
);
256 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
258 ::dbtools::throwFunctionNotSupportedSQLException("getShort", nullptr);
264 sal_Int32 SAL_CALL
MacabResultSet::getInt(sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
>&) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
501 ::osl::MutexGuard
aGuard( m_aMutex
);
502 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
504 ::dbtools::throwFunctionNotSupportedSQLException("getArray", nullptr);
509 Reference
< XResultSetMetaData
> SAL_CALL
MacabResultSet::getMetaData() throw(SQLException
, RuntimeException
)
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
.get();
521 sal_Bool SAL_CALL
MacabResultSet::isBeforeFirst() throw(SQLException
, RuntimeException
)
523 ::osl::MutexGuard
aGuard( m_aMutex
);
524 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
532 sal_Bool SAL_CALL
MacabResultSet::isAfterLast() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
546 ::osl::MutexGuard
aGuard( m_aMutex
);
547 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
555 sal_Bool SAL_CALL
MacabResultSet::isLast() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
569 ::osl::MutexGuard
aGuard( m_aMutex
);
570 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
572 // move before the first row
576 void SAL_CALL
MacabResultSet::afterLast() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
589 ::osl::MutexGuard
aGuard( m_aMutex
);
590 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
595 sal_Bool SAL_CALL
MacabResultSet::first() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
623 ::osl::MutexGuard
aGuard( m_aMutex
);
624 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
629 sal_Bool SAL_CALL
MacabResultSet::absolute(sal_Int32 row
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
669 ::osl::MutexGuard
aGuard( m_aMutex
);
670 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
672 Reference
< XStatement
> xStatement
= m_xStatement
.get();
676 sal_Bool SAL_CALL
MacabResultSet::rowDeleted() throw(SQLException
, RuntimeException
)
678 ::osl::MutexGuard
aGuard( m_aMutex
);
679 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
684 sal_Bool SAL_CALL
MacabResultSet::rowInserted() throw(SQLException
, RuntimeException
)
686 ::osl::MutexGuard
aGuard( m_aMutex
);
687 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
692 sal_Bool SAL_CALL
MacabResultSet::rowUpdated() throw(SQLException
, RuntimeException
)
694 ::osl::MutexGuard
aGuard( m_aMutex
);
695 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
700 sal_Bool SAL_CALL
MacabResultSet::wasNull() throw(SQLException
, RuntimeException
)
702 ::osl::MutexGuard
aGuard( m_aMutex
);
703 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
708 void SAL_CALL
MacabResultSet::cancel() throw(RuntimeException
)
710 ::osl::MutexGuard
aGuard( m_aMutex
);
711 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
714 void SAL_CALL
MacabResultSet::clearWarnings() throw(SQLException
, RuntimeException
)
718 Any SAL_CALL
MacabResultSet::getWarnings() throw(SQLException
, RuntimeException
)
723 void SAL_CALL
MacabResultSet::insertRow() throw(SQLException
, RuntimeException
)
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() throw(SQLException
, RuntimeException
)
733 ::osl::MutexGuard
aGuard( m_aMutex
);
734 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
736 // only when you allow updates
739 void SAL_CALL
MacabResultSet::deleteRow() throw(SQLException
, RuntimeException
)
741 ::osl::MutexGuard
aGuard( m_aMutex
);
742 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
745 void SAL_CALL
MacabResultSet::cancelRowUpdates() throw(SQLException
, RuntimeException
)
747 ::osl::MutexGuard
aGuard( m_aMutex
);
748 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
751 void SAL_CALL
MacabResultSet::moveToInsertRow() throw(SQLException
, RuntimeException
)
753 ::osl::MutexGuard
aGuard( m_aMutex
);
754 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
756 // only when you allow inserts
759 void SAL_CALL
MacabResultSet::moveToCurrentRow() throw(SQLException
, RuntimeException
)
761 ::osl::MutexGuard
aGuard( m_aMutex
);
762 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
765 void SAL_CALL
MacabResultSet::updateNull(sal_Int32
) throw(SQLException
, RuntimeException
)
767 ::osl::MutexGuard
aGuard( m_aMutex
);
768 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
771 void SAL_CALL
MacabResultSet::updateBoolean(sal_Int32
, sal_Bool
) throw(SQLException
, RuntimeException
)
773 ::osl::MutexGuard
aGuard( m_aMutex
);
774 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
777 void SAL_CALL
MacabResultSet::updateByte(sal_Int32
, sal_Int8
) throw(SQLException
, RuntimeException
)
779 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
780 ::osl::MutexGuard
aGuard( m_aMutex
);
783 void SAL_CALL
MacabResultSet::updateShort(sal_Int32
, sal_Int16
) throw(SQLException
, RuntimeException
)
785 ::osl::MutexGuard
aGuard( m_aMutex
);
786 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
789 void SAL_CALL
MacabResultSet::updateInt(sal_Int32
, sal_Int32
) throw(SQLException
, RuntimeException
)
791 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
792 ::osl::MutexGuard
aGuard( m_aMutex
);
795 void SAL_CALL
MacabResultSet::updateLong(sal_Int32
, sal_Int64
) throw(SQLException
, RuntimeException
)
797 ::osl::MutexGuard
aGuard( m_aMutex
);
798 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
801 void SAL_CALL
MacabResultSet::updateFloat(sal_Int32
, float) throw(SQLException
, RuntimeException
)
803 ::osl::MutexGuard
aGuard( m_aMutex
);
804 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
807 void SAL_CALL
MacabResultSet::updateDouble(sal_Int32
, double) throw(SQLException
, RuntimeException
)
809 ::osl::MutexGuard
aGuard( m_aMutex
);
810 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
813 void SAL_CALL
MacabResultSet::updateString(sal_Int32
, const OUString
&) throw(SQLException
, RuntimeException
)
815 ::osl::MutexGuard
aGuard( m_aMutex
);
816 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
819 void SAL_CALL
MacabResultSet::updateBytes(sal_Int32
, const Sequence
< sal_Int8
>&) throw(SQLException
, RuntimeException
)
821 ::osl::MutexGuard
aGuard( m_aMutex
);
822 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
825 void SAL_CALL
MacabResultSet::updateDate(sal_Int32
, const Date
&) throw(SQLException
, RuntimeException
)
827 ::osl::MutexGuard
aGuard( m_aMutex
);
828 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
831 void SAL_CALL
MacabResultSet::updateTime(sal_Int32
, const css::util::Time
&) throw(SQLException
, RuntimeException
)
833 ::osl::MutexGuard
aGuard( m_aMutex
);
834 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
837 void SAL_CALL
MacabResultSet::updateTimestamp(sal_Int32
, const DateTime
&) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
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
) throw(SQLException
, RuntimeException
)
851 ::osl::MutexGuard
aGuard( m_aMutex
);
852 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
855 void SAL_CALL
MacabResultSet::refreshRow() throw(SQLException
, RuntimeException
)
857 ::osl::MutexGuard
aGuard( m_aMutex
);
858 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
861 void SAL_CALL
MacabResultSet::updateObject(sal_Int32
, const Any
&) throw(SQLException
, RuntimeException
)
863 ::osl::MutexGuard
aGuard( m_aMutex
);
864 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
867 void SAL_CALL
MacabResultSet::updateNumericObject(sal_Int32
, const Any
&, sal_Int32
) throw(SQLException
, RuntimeException
)
869 ::osl::MutexGuard
aGuard( m_aMutex
);
870 checkDisposed(MacabResultSet_BASE::rBHelper
.bDisposed
);
874 Any SAL_CALL
MacabResultSet::getBookmark() throw( SQLException
, RuntimeException
)
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
,OUString("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
) throw( SQLException
, RuntimeException
)
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
,OUString("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
) throw( SQLException
, RuntimeException
)
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
) throw( SQLException
, RuntimeException
)
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() throw( SQLException
, RuntimeException
)
963 sal_Int32 SAL_CALL
MacabResultSet::hashBookmark(const Any
& bookmark
) throw( SQLException
, RuntimeException
)
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
>&) throw( SQLException
, RuntimeException
)
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(
1018 throw (css::lang::IllegalArgumentException
)
1022 case PROPERTY_ID_ISBOOKMARKABLE
:
1023 case PROPERTY_ID_CURSORNAME
:
1024 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1025 case PROPERTY_ID_RESULTSETTYPE
:
1026 throw css::lang::IllegalArgumentException();
1028 case PROPERTY_ID_FETCHDIRECTION
:
1029 case PROPERTY_ID_FETCHSIZE
:
1036 void MacabResultSet::setFastPropertyValue_NoBroadcast(
1043 case PROPERTY_ID_ISBOOKMARKABLE
:
1044 case PROPERTY_ID_CURSORNAME
:
1045 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1046 case PROPERTY_ID_RESULTSETTYPE
:
1049 case PROPERTY_ID_FETCHDIRECTION
:
1051 case PROPERTY_ID_FETCHSIZE
:
1058 void MacabResultSet::getFastPropertyValue(
1060 sal_Int32 nHandle
) const
1064 case PROPERTY_ID_ISBOOKMARKABLE
:
1067 case PROPERTY_ID_CURSORNAME
:
1068 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1069 case PROPERTY_ID_RESULTSETTYPE
:
1070 case PROPERTY_ID_FETCHDIRECTION
:
1071 case PROPERTY_ID_FETCHSIZE
:
1077 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */