update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / macab / MacabResultSet.cxx
bloba9d98fb8f6a360cdc5352047edcdc6136c9d2747
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
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;
37 using namespace cppu;
38 using namespace com::sun::star::uno;
39 using namespace com::sun::star::lang;
40 using namespace com::sun::star::beans;
41 using namespace com::sun::star::sdbc;
42 using namespace com::sun::star::sdbcx;
43 using namespace com::sun::star::io;
44 using namespace com::sun::star::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),
51 m_xStatement(pStmt),
52 m_xMetaData(NULL),
53 m_aMacabRecords(),
54 m_nRowPos(-1),
55 m_bWasNull(true)
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 == NULL)
80 return;
82 if(m_aMacabRecords != NULL && m_aMacabRecords != allRecords)
83 delete m_aMacabRecords;
85 // The copy constructor copies everything but records (including the
86 // maximum alloted size, which means that we'll never have to resize)
87 m_aMacabRecords = new MacabRecords(allRecords);
89 if(pCondition->isAlwaysFalse())
91 return;
94 MacabRecords::iterator iterator;
96 for (iterator = allRecords->begin();
97 iterator != allRecords->end();
98 ++iterator)
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
109 // with (for me).
110 sal_Int32 i, j, size, smallest;
111 size = m_aMacabRecords->size();
113 for(i = 0; i < size; i++)
115 smallest = i;
116 for( j = i + 1; j < size; j++)
118 // if smallest > j
119 if(pOrder->compare(m_aMacabRecords->getRecord(smallest),
120 m_aMacabRecords->getRecord(j) ) > 0)
122 smallest = j;
127 if(smallest != i)
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();
147 m_xMetaData.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);
155 return aRet;
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<com::sun::star::beans::XMultiPropertySet>::get(),
172 cppu::UnoType<com::sun::star::beans::XFastPropertySet>::get(),
173 cppu::UnoType<com::sun::star::beans::XPropertySet>::get());
175 return comphelper::concatSequences(aTypes.getTypes(), MacabResultSet_BASE::getTypes());
178 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL MacabResultSet::getPropertySetInfo( ) throw(::com::sun::star::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)))
197 return i;
200 ::dbtools::throwInvalidColumnException( columnName, *this );
201 assert(false);
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);
210 OUString aRet;
211 sal_Int32 nRecords = m_aMacabRecords->size();
212 m_bWasNull = true;
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 != NULL)
220 if(aField->type == kABStringProperty)
222 aRet = CFStringToOUString(static_cast<CFStringRef>(aField->value));
223 m_bWasNull = false;
228 // Trigger an exception if m_bWasNull is true?
229 return aRet;
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", NULL);
239 return sal_False;
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", NULL);
249 sal_Int8 nRet = 0;
250 return nRet;
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", NULL);
260 sal_Int16 nRet = 0;
261 return nRet;
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);
269 sal_Int32 nRet = 0;
270 sal_Int32 nRecords = m_aMacabRecords->size();
271 m_bWasNull = true;
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 != NULL)
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?
290 return nRet;
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);
298 sal_Int64 nRet = 0;
299 sal_Int32 nRecords = m_aMacabRecords->size();
300 m_bWasNull = true;
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 != NULL)
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?
319 return nRet;
322 float SAL_CALL MacabResultSet::getFloat(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
324 ::osl::MutexGuard aGuard( m_aMutex );
325 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
327 float nVal = 0;
328 sal_Int32 nRecords = m_aMacabRecords->size();
329 m_bWasNull = true;
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 != NULL)
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?
348 return nVal;
351 double SAL_CALL MacabResultSet::getDouble(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
353 ::osl::MutexGuard aGuard( m_aMutex );
354 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
356 double nVal = 0;
357 sal_Int32 nRecords = m_aMacabRecords->size();
358 m_bWasNull = true;
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 != NULL)
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?
377 return nVal;
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", NULL);
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", NULL);
397 Date aRet;
398 return aRet;
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", NULL);
408 css::util::Time nRet;
409 return 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);
417 DateTime nRet;
418 sal_Int32 nRecords = m_aMacabRecords->size();
419 m_bWasNull = true;
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 != NULL)
427 if(aField->type == kABDateProperty)
429 nRet = CFDateToDateTime(static_cast<CFDateRef>(aField->value));
430 m_bWasNull = false;
435 // Trigger an exception if m_bWasNull is true?
436 return nRet;
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", NULL);
446 return NULL;
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", NULL);
456 return NULL;
459 Any SAL_CALL MacabResultSet::getObject(sal_Int32, const Reference< ::com::sun::star::container::XNameAccess >&) throw(SQLException, RuntimeException)
461 ::osl::MutexGuard aGuard( m_aMutex );
462 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
464 ::dbtools::throwFunctionNotSupportedSQLException("getObject", NULL);
466 return Any();
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", NULL);
476 return NULL;
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", NULL);
486 return NULL;
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", NULL);
496 return NULL;
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", NULL);
506 return NULL;
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();
518 return xMetaData;
521 sal_Bool SAL_CALL MacabResultSet::isBeforeFirst() throw(SQLException, RuntimeException)
523 ::osl::MutexGuard aGuard( m_aMutex );
524 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
526 if (m_nRowPos == -1)
527 return sal_True;
529 return sal_False;
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)
539 return sal_True;
541 return sal_False;
544 sal_Bool SAL_CALL MacabResultSet::isFirst() throw(SQLException, RuntimeException)
546 ::osl::MutexGuard aGuard( m_aMutex );
547 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
549 if (m_nRowPos == 0)
550 return sal_True;
552 return sal_False;
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)
562 return sal_True;
564 return sal_False;
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
573 m_nRowPos = -1;
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);
592 dispose();
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();
601 if (nRecords == 0)
602 return sal_False;
604 m_nRowPos = 0;
605 return sal_True;
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();
614 if (nRecords == 0)
615 return sal_False;
617 m_nRowPos = nRecords - 1;
618 return sal_True;
621 sal_Int32 SAL_CALL MacabResultSet::getRow() throw(SQLException, RuntimeException)
623 ::osl::MutexGuard aGuard( m_aMutex );
624 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
626 return m_nRowPos;
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();
635 if (row <= -1 ||
636 row >= nRecords)
637 return sal_False;
639 m_nRowPos = row;
640 return sal_True;
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();
673 return xStatement;
676 sal_Bool SAL_CALL MacabResultSet::rowDeleted() throw(SQLException, RuntimeException)
678 ::osl::MutexGuard aGuard( m_aMutex );
679 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
681 return sal_False;
684 sal_Bool SAL_CALL MacabResultSet::rowInserted() throw(SQLException, RuntimeException)
686 ::osl::MutexGuard aGuard( m_aMutex );
687 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
689 return sal_False;
692 sal_Bool SAL_CALL MacabResultSet::rowUpdated() throw(SQLException, RuntimeException)
694 ::osl::MutexGuard aGuard( m_aMutex );
695 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
697 return sal_False;
700 sal_Bool SAL_CALL MacabResultSet::wasNull() throw(SQLException, RuntimeException)
702 ::osl::MutexGuard aGuard( m_aMutex );
703 checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
705 return m_bWasNull;
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)
720 return Any();
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);
873 // XRowLocate
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 != NULL)
886 if(uidField->type == kABStringProperty)
888 return makeAny(CFStringToOUString( static_cast<CFStringRef>(uidField->value) ));
892 return Any();
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 != NULL)
908 if(uidField->type == kABStringProperty)
910 OUString sUniqueIdentifier = CFStringToOUString( static_cast<CFStringRef>(uidField->value) );
911 if (sUniqueIdentifier == sBookmark)
913 m_nRowPos = nRow;
914 return sal_True;
919 return sal_False;
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();
933 m_nRowPos += rows;
935 if (-1 < m_nRowPos && m_nRowPos < nRecords)
936 return sal_True;
939 m_nRowPos = nRowSave;
940 return sal_False;
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)
960 return sal_False;
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();
973 // XDeleteRows
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();
986 sal_Int32 nPos = 0;
987 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
988 PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY);
990 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
991 PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
993 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
994 PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
996 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),
997 PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY);
999 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
1000 PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
1002 pProperties[nPos++] = ::com::sun::star::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 *static_cast<MacabResultSet*>(this)->getArrayHelper();
1013 sal_Bool MacabResultSet::convertFastPropertyValue(
1014 Any &,
1015 Any &,
1016 sal_Int32 nHandle,
1017 const Any& )
1018 throw (::com::sun::star::lang::IllegalArgumentException)
1020 switch (nHandle)
1022 case PROPERTY_ID_ISBOOKMARKABLE:
1023 case PROPERTY_ID_CURSORNAME:
1024 case PROPERTY_ID_RESULTSETCONCURRENCY:
1025 case PROPERTY_ID_RESULTSETTYPE:
1026 throw ::com::sun::star::lang::IllegalArgumentException();
1027 break;
1028 case PROPERTY_ID_FETCHDIRECTION:
1029 case PROPERTY_ID_FETCHSIZE:
1030 default:
1033 return sal_False;
1036 void MacabResultSet::setFastPropertyValue_NoBroadcast(
1037 sal_Int32 nHandle,
1038 const Any& )
1039 throw (Exception)
1041 switch (nHandle)
1043 case PROPERTY_ID_ISBOOKMARKABLE:
1044 case PROPERTY_ID_CURSORNAME:
1045 case PROPERTY_ID_RESULTSETCONCURRENCY:
1046 case PROPERTY_ID_RESULTSETTYPE:
1047 throw Exception();
1048 break;
1049 case PROPERTY_ID_FETCHDIRECTION:
1050 break;
1051 case PROPERTY_ID_FETCHSIZE:
1052 break;
1053 default:
1058 void MacabResultSet::getFastPropertyValue(
1059 Any& _rValue,
1060 sal_Int32 nHandle) const
1062 switch (nHandle)
1064 case PROPERTY_ID_ISBOOKMARKABLE:
1065 _rValue <<= false;
1066 break;
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: */