update dev300-m58
[ooovba.git] / connectivity / source / drivers / kab / KResultSet.cxx
blob91ef3f6caecec16d0e839d065651b5dbb76623a1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: KResultSet.cxx,v $
10 * $Revision: 1.9.46.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #include "KResultSet.hxx"
35 #include "KResultSetMetaData.hxx"
36 #include "KConnection.hxx"
37 #include "kcondition.hxx"
38 #include "korder.hxx"
39 #include "kfields.hxx"
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
42 #include "TConnection.hxx"
43 #include <connectivity/dbexception.hxx>
44 #include "resource/kab_res.hrc"
45 #include "resource/sharedresources.hxx"
47 using namespace connectivity::kab;
48 using namespace cppu;
49 using namespace com::sun::star::uno;
50 using namespace com::sun::star::lang;
51 using namespace com::sun::star::beans;
52 using namespace com::sun::star::sdbc;
53 using namespace com::sun::star::sdbcx;
54 using namespace com::sun::star::io;
55 using namespace com::sun::star::util;
57 IMPLEMENT_SERVICE_INFO(KabResultSet, "com.sun.star.sdbc.drivers.KabResultSet", "com.sun.star.sdbc.ResultSet");
58 // -------------------------------------------------------------------------
59 KabResultSet::KabResultSet(KabCommonStatement* pStmt)
60 : KabResultSet_BASE(m_aMutex),
61 OPropertySetHelper(KabResultSet_BASE::rBHelper),
62 m_xStatement(pStmt),
63 m_xMetaData(NULL),
64 m_aKabAddressees(),
65 m_nRowPos(-1),
66 m_bWasNull(sal_True)
69 // -------------------------------------------------------------------------
70 KabResultSet::~KabResultSet()
73 // -------------------------------------------------------------------------
74 void KabResultSet::allKabAddressees()
76 KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get());
77 KABC::AddressBook* pAddressBook = pConnection->getAddressBook();
79 m_aKabAddressees = pAddressBook->allAddressees();
81 // -------------------------------------------------------------------------
82 void KabResultSet::someKabAddressees(const KabCondition *pCondition)
84 KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get());
85 KABC::AddressBook* pAddressBook = pConnection->getAddressBook();
87 KABC::AddressBook::Iterator iterator;
89 for (iterator = pAddressBook->begin();
90 iterator != pAddressBook->end();
91 ++iterator)
93 if (pCondition->eval(*iterator))
94 m_aKabAddressees.push_back(*iterator);
97 // -------------------------------------------------------------------------
98 void KabResultSet::sortKabAddressees(const KabOrder *pOrder)
100 // We do not use class KAddresseeList, which has a sorting algorithm in it, because
101 // it uses templates. It would expand to more or less the same code as the one
102 // which follows, but it would need not be called in a much less convenient way.
104 KABC::Addressee::List::Iterator
105 begin = m_aKabAddressees.begin(),
106 end = m_aKabAddressees.end(),
107 iterator;
109 // Bubble sort. Feel free to implement a better algorithm.
110 while (begin != end)
112 end--;
113 for (iterator = begin; iterator != end; ++iterator)
115 if (pOrder->compare(*iterator, *end) > 0)
116 qSwap(*iterator, *end);
120 // -------------------------------------------------------------------------
121 void KabResultSet::disposing()
123 OPropertySetHelper::disposing();
125 ::osl::MutexGuard aGuard(m_aMutex);
127 m_xStatement.clear();
128 m_xMetaData.clear();
130 // -------------------------------------------------------------------------
131 Any SAL_CALL KabResultSet::queryInterface(const Type & rType) throw(RuntimeException)
133 Any aRet = OPropertySetHelper::queryInterface(rType);
134 if (!aRet.hasValue())
135 aRet = KabResultSet_BASE::queryInterface(rType);
136 return aRet;
138 // -------------------------------------------------------------------------
139 void SAL_CALL KabResultSet::acquire() throw()
141 KabResultSet_BASE::acquire();
143 // -------------------------------------------------------------------------
144 void SAL_CALL KabResultSet::release() throw()
146 KabResultSet_BASE::release();
148 // -------------------------------------------------------------------------
149 Sequence< Type > SAL_CALL KabResultSet::getTypes() throw(RuntimeException)
151 OTypeCollection aTypes(
152 ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet >*) 0),
153 ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet >*) 0),
154 ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet >*) 0));
156 return comphelper::concatSequences(aTypes.getTypes(), KabResultSet_BASE::getTypes());
158 // -------------------------------------------------------------------------
159 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL KabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
161 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
163 // -------------------------------------------------------------------------
164 sal_Int32 SAL_CALL KabResultSet::findColumn(const ::rtl::OUString& columnName) throw(SQLException, RuntimeException)
166 ::osl::MutexGuard aGuard( m_aMutex );
167 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
169 // find the first column with the name columnName
170 Reference< XResultSetMetaData > xMeta = getMetaData();
171 sal_Int32 nLen = xMeta->getColumnCount();
173 for (sal_Int32 i = 1; i <= nLen; ++i)
174 if (xMeta->isCaseSensitive(i) ?
175 columnName == xMeta->getColumnName(i) :
176 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
177 return i;
179 ::connectivity::SharedResources aResources;
180 const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
181 STR_INVALID_COLUMNNAME,
182 "$columnname$",columnName
183 ) );
184 ::dbtools::throwGenericSQLException(sError,NULL);
186 // Unreachable:
187 OSL_ASSERT(false);
188 return 0;
190 // -------------------------------------------------------------------------
191 ::rtl::OUString SAL_CALL KabResultSet::getString(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
193 ::osl::MutexGuard aGuard( m_aMutex );
194 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
196 ::rtl::OUString aRet;
197 sal_Int32 nAddressees = m_aKabAddressees.size();
198 ::KABC::Field::List aFields = ::KABC::Field::allFields();
200 if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is())
202 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
203 QString aQtName;
205 switch (nFieldNumber)
207 case KAB_FIELD_REVISION:
208 // trigger an exception here
209 m_bWasNull = true;
210 return aRet;
211 default:
212 aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->value(m_aKabAddressees[m_nRowPos]);
214 // KDE address book currently does not use NULL values.
215 // But it might do it someday
216 if (!aQtName.isNull())
218 m_bWasNull = false;
219 aRet = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
220 return aRet;
223 // Trigger an exception ?
224 m_bWasNull = true;
225 return aRet;
227 // -------------------------------------------------------------------------
228 sal_Bool SAL_CALL KabResultSet::getBoolean(sal_Int32) throw(SQLException, RuntimeException)
230 ::osl::MutexGuard aGuard( m_aMutex );
231 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
233 ::dbtools::throwFunctionNotSupportedException("getBoolean", NULL);
235 return sal_False;
237 // -------------------------------------------------------------------------
238 sal_Int8 SAL_CALL KabResultSet::getByte(sal_Int32) throw(SQLException, RuntimeException)
240 ::osl::MutexGuard aGuard( m_aMutex );
241 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
243 ::dbtools::throwFunctionNotSupportedException("getByte", NULL);
245 sal_Int8 nRet = 0;
246 return nRet;
248 // -------------------------------------------------------------------------
249 sal_Int16 SAL_CALL KabResultSet::getShort(sal_Int32) throw(SQLException, RuntimeException)
251 ::osl::MutexGuard aGuard( m_aMutex );
252 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
254 ::dbtools::throwFunctionNotSupportedException("getShort", NULL);
256 sal_Int16 nRet = 0;
257 return nRet;
259 // -------------------------------------------------------------------------
260 sal_Int32 SAL_CALL KabResultSet::getInt(sal_Int32) throw(SQLException, RuntimeException)
262 ::osl::MutexGuard aGuard( m_aMutex );
263 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
265 ::dbtools::throwFunctionNotSupportedException("getInt", NULL);
267 sal_Int32 nRet = 0;
268 return nRet;
270 // -------------------------------------------------------------------------
271 sal_Int64 SAL_CALL KabResultSet::getLong(sal_Int32) throw(SQLException, RuntimeException)
273 ::osl::MutexGuard aGuard( m_aMutex );
274 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
276 ::dbtools::throwFunctionNotSupportedException("getLong", NULL);
278 return sal_Int64();
280 // -------------------------------------------------------------------------
281 float SAL_CALL KabResultSet::getFloat(sal_Int32) throw(SQLException, RuntimeException)
283 ::osl::MutexGuard aGuard( m_aMutex );
284 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
286 ::dbtools::throwFunctionNotSupportedException("getFloat", NULL);
288 float nVal(0);
289 return nVal;
291 // -------------------------------------------------------------------------
292 double SAL_CALL KabResultSet::getDouble(sal_Int32) throw(SQLException, RuntimeException)
294 ::osl::MutexGuard aGuard( m_aMutex );
295 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
297 ::dbtools::throwFunctionNotSupportedException("getDouble", NULL);
299 double nRet = 0;
300 return nRet;
302 // -------------------------------------------------------------------------
303 Sequence< sal_Int8 > SAL_CALL KabResultSet::getBytes(sal_Int32) throw(SQLException, RuntimeException)
305 ::osl::MutexGuard aGuard( m_aMutex );
306 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
308 ::dbtools::throwFunctionNotSupportedException("", NULL);
310 return Sequence< sal_Int8 >();
312 // -------------------------------------------------------------------------
313 Date SAL_CALL KabResultSet::getDate(sal_Int32) throw(SQLException, RuntimeException)
315 ::osl::MutexGuard aGuard( m_aMutex );
316 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
318 ::dbtools::throwFunctionNotSupportedException("getDate", NULL);
320 Date aRet;
321 return aRet;
323 // -------------------------------------------------------------------------
324 Time SAL_CALL KabResultSet::getTime(sal_Int32) throw(SQLException, RuntimeException)
326 ::osl::MutexGuard aGuard( m_aMutex );
327 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
329 ::dbtools::throwFunctionNotSupportedException("getTime", NULL);
331 Time nRet;
332 return nRet;
334 // -------------------------------------------------------------------------
335 DateTime SAL_CALL KabResultSet::getTimestamp(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
337 ::osl::MutexGuard aGuard( m_aMutex );
338 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
340 DateTime nRet;
341 sal_Int32 nAddressees = m_aKabAddressees.size();
343 if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is())
345 KabResultSetMetaData *pMeta = static_cast<KabResultSetMetaData *>(m_xMetaData.get());
346 sal_Int32 nFieldNumber = pMeta->fieldAtColumn(columnIndex);
348 if (nFieldNumber == KAB_FIELD_REVISION)
350 QDateTime nRevision(m_aKabAddressees[m_nRowPos].revision());
352 if (!nRevision.isNull())
354 m_bWasNull = false;
355 nRet.Year = nRevision.date().year();
356 nRet.Month = nRevision.date().month();
357 nRet.Day = nRevision.date().day();
358 nRet.Hours = nRevision.time().hour();
359 nRet.Minutes = nRevision.time().minute();
360 nRet.Seconds = nRevision.time().second();
361 nRet.HundredthSeconds = nRevision.time().msec() / 10;
362 return nRet;
365 else {
368 // trigger an exception here
370 // Trigger an exception ?
371 m_bWasNull = true;
372 return nRet;
374 // -------------------------------------------------------------------------
375 Reference< XInputStream > SAL_CALL KabResultSet::getBinaryStream(sal_Int32) throw(SQLException, RuntimeException)
377 ::osl::MutexGuard aGuard( m_aMutex );
378 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
380 ::dbtools::throwFunctionNotSupportedException("getBinaryStream", NULL);
382 return NULL;
384 // -------------------------------------------------------------------------
385 Reference< XInputStream > SAL_CALL KabResultSet::getCharacterStream(sal_Int32) throw(SQLException, RuntimeException)
387 ::osl::MutexGuard aGuard( m_aMutex );
388 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
390 ::dbtools::throwFunctionNotSupportedException("getCharacterStream", NULL);
392 return NULL;
394 // -------------------------------------------------------------------------
395 Any SAL_CALL KabResultSet::getObject(sal_Int32, const Reference< ::com::sun::star::container::XNameAccess >&) throw(SQLException, RuntimeException)
397 ::osl::MutexGuard aGuard( m_aMutex );
398 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
400 ::dbtools::throwFunctionNotSupportedException("getObject", NULL);
402 return Any();
404 // -------------------------------------------------------------------------
405 Reference< XRef > SAL_CALL KabResultSet::getRef(sal_Int32) throw(SQLException, RuntimeException)
407 ::osl::MutexGuard aGuard( m_aMutex );
408 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
410 ::dbtools::throwFunctionNotSupportedException("getRef", NULL);
412 return NULL;
414 // -------------------------------------------------------------------------
415 Reference< XBlob > SAL_CALL KabResultSet::getBlob(sal_Int32) throw(SQLException, RuntimeException)
417 ::osl::MutexGuard aGuard( m_aMutex );
418 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
420 ::dbtools::throwFunctionNotSupportedException("getBlob", NULL);
422 return NULL;
424 // -------------------------------------------------------------------------
425 Reference< XClob > SAL_CALL KabResultSet::getClob(sal_Int32) throw(SQLException, RuntimeException)
427 ::osl::MutexGuard aGuard( m_aMutex );
428 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
430 ::dbtools::throwFunctionNotSupportedException("getClob", NULL);
432 return NULL;
434 // -------------------------------------------------------------------------
435 Reference< XArray > SAL_CALL KabResultSet::getArray(sal_Int32) throw(SQLException, RuntimeException)
437 ::osl::MutexGuard aGuard( m_aMutex );
438 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
440 ::dbtools::throwFunctionNotSupportedException("getArray", NULL);
442 return NULL;
444 // -------------------------------------------------------------------------
445 Reference< XResultSetMetaData > SAL_CALL KabResultSet::getMetaData() throw(SQLException, RuntimeException)
447 ::osl::MutexGuard aGuard( m_aMutex );
448 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
450 if (!m_xMetaData.is())
451 m_xMetaData = new KabResultSetMetaData(m_xStatement->getOwnConnection());
453 Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
454 return xMetaData;
456 // -------------------------------------------------------------------------
457 sal_Bool SAL_CALL KabResultSet::isBeforeFirst() throw(SQLException, RuntimeException)
459 ::osl::MutexGuard aGuard( m_aMutex );
460 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
462 if (m_nRowPos == -1)
463 return sal_True;
465 return sal_False;
467 // -------------------------------------------------------------------------
468 sal_Bool SAL_CALL KabResultSet::isAfterLast() throw(SQLException, RuntimeException)
470 ::osl::MutexGuard aGuard( m_aMutex );
471 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
473 sal_Int32 nAddressees = m_aKabAddressees.size();
474 if (m_nRowPos == nAddressees)
475 return sal_True;
477 return sal_False;
479 // -------------------------------------------------------------------------
480 sal_Bool SAL_CALL KabResultSet::isFirst() throw(SQLException, RuntimeException)
482 ::osl::MutexGuard aGuard( m_aMutex );
483 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
485 if (m_nRowPos == 0)
486 return sal_True;
488 return sal_False;
490 // -------------------------------------------------------------------------
491 sal_Bool SAL_CALL KabResultSet::isLast() throw(SQLException, RuntimeException)
493 ::osl::MutexGuard aGuard( m_aMutex );
494 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
496 sal_Int32 nAddressees = m_aKabAddressees.size();
497 if (m_nRowPos == nAddressees - 1)
498 return sal_True;
500 return sal_False;
502 // -------------------------------------------------------------------------
503 void SAL_CALL KabResultSet::beforeFirst() throw(SQLException, RuntimeException)
505 ::osl::MutexGuard aGuard( m_aMutex );
506 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
508 // move before the first row
509 m_nRowPos = -1;
511 // -------------------------------------------------------------------------
512 void SAL_CALL KabResultSet::afterLast() throw(SQLException, RuntimeException)
514 ::osl::MutexGuard aGuard( m_aMutex );
515 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
517 // move after the last row
518 sal_Int32 nAddressees = m_aKabAddressees.size();
519 m_nRowPos = nAddressees;
521 // -------------------------------------------------------------------------
522 void SAL_CALL KabResultSet::close() throw(SQLException, RuntimeException)
525 ::osl::MutexGuard aGuard( m_aMutex );
526 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
528 dispose();
530 // -------------------------------------------------------------------------
531 sal_Bool SAL_CALL KabResultSet::first() throw(SQLException, RuntimeException)
533 ::osl::MutexGuard aGuard( m_aMutex );
534 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
536 sal_Int32 nAddressees = m_aKabAddressees.size();
537 if (nAddressees == 0)
538 return sal_False;
540 m_nRowPos = 0;
541 return sal_True;
543 // -------------------------------------------------------------------------
544 sal_Bool SAL_CALL KabResultSet::last() throw(SQLException, RuntimeException)
546 ::osl::MutexGuard aGuard( m_aMutex );
547 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
549 sal_Int32 nAddressees = m_aKabAddressees.size();
550 if (nAddressees == 0)
551 return sal_False;
553 m_nRowPos = nAddressees - 1;
554 return sal_True;
556 // -------------------------------------------------------------------------
557 sal_Int32 SAL_CALL KabResultSet::getRow() throw(SQLException, RuntimeException)
559 ::osl::MutexGuard aGuard( m_aMutex );
560 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
562 return m_nRowPos;
564 // -------------------------------------------------------------------------
565 sal_Bool SAL_CALL KabResultSet::absolute(sal_Int32 row) throw(SQLException, RuntimeException)
567 ::osl::MutexGuard aGuard( m_aMutex );
568 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
570 sal_Int32 nAddressees = m_aKabAddressees.size();
571 if (row <= -1 ||
572 row >= nAddressees)
573 return sal_False;
575 m_nRowPos = row;
576 return sal_True;
578 // -------------------------------------------------------------------------
579 sal_Bool SAL_CALL KabResultSet::relative(sal_Int32 row) throw(SQLException, RuntimeException)
581 ::osl::MutexGuard aGuard( m_aMutex );
582 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
584 return absolute(m_nRowPos + row);
586 // -------------------------------------------------------------------------
587 sal_Bool SAL_CALL KabResultSet::next() throw(SQLException, RuntimeException)
589 ::osl::MutexGuard aGuard( m_aMutex );
590 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
592 return absolute(m_nRowPos + 1);
594 // -------------------------------------------------------------------------
595 sal_Bool SAL_CALL KabResultSet::previous() throw(SQLException, RuntimeException)
597 ::osl::MutexGuard aGuard( m_aMutex );
598 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
600 return absolute(m_nRowPos - 1);
602 // -------------------------------------------------------------------------
603 Reference< XInterface > SAL_CALL KabResultSet::getStatement() throw(SQLException, RuntimeException)
605 ::osl::MutexGuard aGuard( m_aMutex );
606 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
608 Reference< XStatement > xStatement = m_xStatement.get();
609 return xStatement;
611 // -------------------------------------------------------------------------
612 sal_Bool SAL_CALL KabResultSet::rowDeleted() throw(SQLException, RuntimeException)
614 ::osl::MutexGuard aGuard( m_aMutex );
615 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
617 return sal_False;
619 // -------------------------------------------------------------------------
620 sal_Bool SAL_CALL KabResultSet::rowInserted() throw(SQLException, RuntimeException)
622 ::osl::MutexGuard aGuard( m_aMutex );
623 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
625 return sal_False;
627 // -------------------------------------------------------------------------
628 sal_Bool SAL_CALL KabResultSet::rowUpdated() throw(SQLException, RuntimeException)
630 ::osl::MutexGuard aGuard( m_aMutex );
631 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
633 return sal_False;
635 // -------------------------------------------------------------------------
636 sal_Bool SAL_CALL KabResultSet::wasNull() throw(SQLException, RuntimeException)
638 ::osl::MutexGuard aGuard( m_aMutex );
639 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
641 return m_bWasNull;
643 // -------------------------------------------------------------------------
644 void SAL_CALL KabResultSet::cancel() throw(RuntimeException)
646 ::osl::MutexGuard aGuard( m_aMutex );
647 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
649 // -------------------------------------------------------------------------
650 void SAL_CALL KabResultSet::clearWarnings() throw(SQLException, RuntimeException)
653 // -------------------------------------------------------------------------
654 Any SAL_CALL KabResultSet::getWarnings() throw(SQLException, RuntimeException)
656 return Any();
658 // -------------------------------------------------------------------------
659 void SAL_CALL KabResultSet::insertRow() throw(SQLException, RuntimeException)
661 ::osl::MutexGuard aGuard( m_aMutex );
662 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
664 // you only have to implement this if you want to insert new rows
666 // -------------------------------------------------------------------------
667 void SAL_CALL KabResultSet::updateRow() throw(SQLException, RuntimeException)
669 ::osl::MutexGuard aGuard( m_aMutex );
670 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
672 // only when you allow updates
674 // -------------------------------------------------------------------------
675 void SAL_CALL KabResultSet::deleteRow() throw(SQLException, RuntimeException)
677 ::osl::MutexGuard aGuard( m_aMutex );
678 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
680 // -------------------------------------------------------------------------
681 void SAL_CALL KabResultSet::cancelRowUpdates() throw(SQLException, RuntimeException)
683 ::osl::MutexGuard aGuard( m_aMutex );
684 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
686 // -------------------------------------------------------------------------
687 void SAL_CALL KabResultSet::moveToInsertRow() throw(SQLException, RuntimeException)
689 ::osl::MutexGuard aGuard( m_aMutex );
690 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
692 // only when you allow inserts
694 // -------------------------------------------------------------------------
695 void SAL_CALL KabResultSet::moveToCurrentRow() throw(SQLException, RuntimeException)
697 ::osl::MutexGuard aGuard( m_aMutex );
698 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
700 // -------------------------------------------------------------------------
701 void SAL_CALL KabResultSet::updateNull(sal_Int32) throw(SQLException, RuntimeException)
703 ::osl::MutexGuard aGuard( m_aMutex );
704 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
706 // -------------------------------------------------------------------------
707 void SAL_CALL KabResultSet::updateBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException)
709 ::osl::MutexGuard aGuard( m_aMutex );
710 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
712 // -------------------------------------------------------------------------
713 void SAL_CALL KabResultSet::updateByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException)
715 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
716 ::osl::MutexGuard aGuard( m_aMutex );
718 // -------------------------------------------------------------------------
719 void SAL_CALL KabResultSet::updateShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException)
721 ::osl::MutexGuard aGuard( m_aMutex );
722 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
724 // -------------------------------------------------------------------------
725 void SAL_CALL KabResultSet::updateInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
727 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
728 ::osl::MutexGuard aGuard( m_aMutex );
730 // -------------------------------------------------------------------------
731 void SAL_CALL KabResultSet::updateLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException)
733 ::osl::MutexGuard aGuard( m_aMutex );
734 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
736 // -----------------------------------------------------------------------
737 void SAL_CALL KabResultSet::updateFloat(sal_Int32, float) throw(SQLException, RuntimeException)
739 ::osl::MutexGuard aGuard( m_aMutex );
740 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
742 // -------------------------------------------------------------------------
743 void SAL_CALL KabResultSet::updateDouble(sal_Int32, double) throw(SQLException, RuntimeException)
745 ::osl::MutexGuard aGuard( m_aMutex );
746 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
748 // -------------------------------------------------------------------------
749 void SAL_CALL KabResultSet::updateString(sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException)
751 ::osl::MutexGuard aGuard( m_aMutex );
752 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
754 // -------------------------------------------------------------------------
755 void SAL_CALL KabResultSet::updateBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException)
757 ::osl::MutexGuard aGuard( m_aMutex );
758 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
760 // -------------------------------------------------------------------------
761 void SAL_CALL KabResultSet::updateDate(sal_Int32, const Date&) throw(SQLException, RuntimeException)
763 ::osl::MutexGuard aGuard( m_aMutex );
764 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
766 // -------------------------------------------------------------------------
767 void SAL_CALL KabResultSet::updateTime(sal_Int32, const Time&) throw(SQLException, RuntimeException)
769 ::osl::MutexGuard aGuard( m_aMutex );
770 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
772 // -------------------------------------------------------------------------
773 void SAL_CALL KabResultSet::updateTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException)
775 ::osl::MutexGuard aGuard( m_aMutex );
776 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
778 // -------------------------------------------------------------------------
779 void SAL_CALL KabResultSet::updateBinaryStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
781 ::osl::MutexGuard aGuard( m_aMutex );
782 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
784 // -------------------------------------------------------------------------
785 void SAL_CALL KabResultSet::updateCharacterStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
787 ::osl::MutexGuard aGuard( m_aMutex );
788 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
790 // -------------------------------------------------------------------------
791 void SAL_CALL KabResultSet::refreshRow() throw(SQLException, RuntimeException)
793 ::osl::MutexGuard aGuard( m_aMutex );
794 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
796 // -------------------------------------------------------------------------
797 void SAL_CALL KabResultSet::updateObject(sal_Int32, const Any&) throw(SQLException, RuntimeException)
799 ::osl::MutexGuard aGuard( m_aMutex );
800 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
802 // -------------------------------------------------------------------------
803 void SAL_CALL KabResultSet::updateNumericObject(sal_Int32, const Any&, sal_Int32) throw(SQLException, RuntimeException)
805 ::osl::MutexGuard aGuard( m_aMutex );
806 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
808 // -------------------------------------------------------------------------
809 // XRowLocate
810 Any SAL_CALL KabResultSet::getBookmark() throw( SQLException, RuntimeException)
812 ::osl::MutexGuard aGuard( m_aMutex );
813 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
815 sal_Int32 nAddressees = m_aKabAddressees.size();
817 if (m_nRowPos != -1 && m_nRowPos != nAddressees)
819 QString aQtName = m_aKabAddressees[m_nRowPos].uid();
820 ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
821 return makeAny(sUniqueIdentifier);
823 return Any();
825 // -------------------------------------------------------------------------
826 sal_Bool SAL_CALL KabResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException)
828 ::osl::MutexGuard aGuard( m_aMutex );
829 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
831 ::rtl::OUString sBookmark = comphelper::getString(bookmark);
832 sal_Int32 nAddressees = m_aKabAddressees.size();
834 for (sal_Int32 nRow = 0; nRow < nAddressees; nRow++)
836 QString aQtName = m_aKabAddressees[nRow].uid();
837 ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
839 if (sUniqueIdentifier == sBookmark)
841 m_nRowPos = nRow;
842 return sal_True;
845 return sal_False;
847 // -------------------------------------------------------------------------
848 sal_Bool SAL_CALL KabResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException)
850 ::osl::MutexGuard aGuard( m_aMutex );
851 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
853 sal_Int32 nRowSave = m_nRowPos;
855 if (moveToBookmark(bookmark))
857 sal_Int32 nAddressees = m_aKabAddressees.size();
859 m_nRowPos += rows;
861 if (-1 < m_nRowPos && m_nRowPos < nAddressees)
862 return sal_True;
865 m_nRowPos = nRowSave;
866 return sal_False;
868 // -------------------------------------------------------------------------
869 sal_Int32 SAL_CALL KabResultSet::compareBookmarks(const Any& firstItem, const Any& secondItem) throw( SQLException, RuntimeException)
871 ::osl::MutexGuard aGuard( m_aMutex );
872 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
874 ::rtl::OUString sFirst = comphelper::getString(firstItem);
875 ::rtl::OUString sSecond = comphelper::getString(secondItem);
877 if (sFirst < sSecond)
878 return CompareBookmark::LESS;
879 if (sFirst > sSecond)
880 return CompareBookmark::GREATER;
881 return CompareBookmark::EQUAL;
883 // -------------------------------------------------------------------------
884 sal_Bool SAL_CALL KabResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException)
886 return sal_False;
888 // -------------------------------------------------------------------------
889 sal_Int32 SAL_CALL KabResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException)
891 ::osl::MutexGuard aGuard( m_aMutex );
892 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
894 ::rtl::OUString sBookmark = comphelper::getString(bookmark);
896 return sBookmark.hashCode();
898 // -------------------------------------------------------------------------
899 // XDeleteRows
900 Sequence< sal_Int32 > SAL_CALL KabResultSet::deleteRows(const Sequence< Any >&) throw( SQLException, RuntimeException)
902 ::osl::MutexGuard aGuard( m_aMutex );
903 checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
905 return Sequence< sal_Int32 >();
907 // -------------------------------------------------------------------------
908 IPropertyArrayHelper* KabResultSet::createArrayHelper() const
910 Sequence< Property > aProps(6);
911 Property* pProperties = aProps.getArray();
912 sal_Int32 nPos = 0;
913 DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
914 DECL_PROP0(FETCHDIRECTION, sal_Int32);
915 DECL_PROP0(FETCHSIZE, sal_Int32);
916 DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
917 DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
918 DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
920 return new OPropertyArrayHelper(aProps);
922 // -------------------------------------------------------------------------
923 IPropertyArrayHelper & KabResultSet::getInfoHelper()
925 return *static_cast<KabResultSet*>(this)->getArrayHelper();
927 // -------------------------------------------------------------------------
928 sal_Bool KabResultSet::convertFastPropertyValue(
929 Any &,
930 Any &,
931 sal_Int32 nHandle,
932 const Any& )
933 throw (::com::sun::star::lang::IllegalArgumentException)
935 switch (nHandle)
937 case PROPERTY_ID_ISBOOKMARKABLE:
938 case PROPERTY_ID_CURSORNAME:
939 case PROPERTY_ID_RESULTSETCONCURRENCY:
940 case PROPERTY_ID_RESULTSETTYPE:
941 throw ::com::sun::star::lang::IllegalArgumentException();
942 break;
943 case PROPERTY_ID_FETCHDIRECTION:
944 case PROPERTY_ID_FETCHSIZE:
945 default:
948 return sal_False;
950 // -------------------------------------------------------------------------
951 void KabResultSet::setFastPropertyValue_NoBroadcast(
952 sal_Int32 nHandle,
953 const Any& )
954 throw (Exception)
956 switch (nHandle)
958 case PROPERTY_ID_ISBOOKMARKABLE:
959 case PROPERTY_ID_CURSORNAME:
960 case PROPERTY_ID_RESULTSETCONCURRENCY:
961 case PROPERTY_ID_RESULTSETTYPE:
962 throw Exception();
963 break;
964 case PROPERTY_ID_FETCHDIRECTION:
965 break;
966 case PROPERTY_ID_FETCHSIZE:
967 break;
968 default:
972 // -------------------------------------------------------------------------
973 void KabResultSet::getFastPropertyValue(
974 Any& _rValue,
975 sal_Int32 nHandle) const
977 switch (nHandle)
979 case PROPERTY_ID_ISBOOKMARKABLE:
980 _rValue <<= (sal_Bool)sal_False;
981 break;
982 case PROPERTY_ID_CURSORNAME:
983 case PROPERTY_ID_RESULTSETCONCURRENCY:
984 case PROPERTY_ID_RESULTSETTYPE:
985 case PROPERTY_ID_FETCHDIRECTION:
986 case PROPERTY_ID_FETCHSIZE:
990 // -----------------------------------------------------------------------------