Tag: cws_src680_kaddrbook User: ebischoff Date: 05/12/02 14:21:29 Modified: /dba/connectivity/source/drivers/kab/ KDatabaseMetaData.cxx, KResultSet.cxx, KResultSetMetaData.cxx, kcondition.cxx, kfields.cxx, kfields.hxx, korder.cxx
Log: Issue number: Submitted by: Reviewed by: Making "Unique identifier" a bookmark. This is not a field anymore. File Changes: Directory: /dba/connectivity/source/drivers/kab/ ================================================ File [changed]: KDatabaseMetaData.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KDatabaseMetaData.cxx?r1=1.1.2.13&r2=1.1.2.14 Delta lines: +2 -14 -------------------- --- KDatabaseMetaData.cxx 2 Dec 2005 20:19:11 -0000 1.1.2.13 +++ KDatabaseMetaData.cxx 2 Dec 2005 22:21:24 -0000 1.1.2.14 @@ -4,9 +4,9 @@ * * $RCSfile: KDatabaseMetaData.cxx,v $ * - * $Revision: 1.1.2.13 $ + * $Revision: 1.1.2.14 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:11 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:24 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -916,18 +916,6 @@ sal_Int32 nPosition = 1; QString aQtName; ::rtl::OUString sName; - - aQtName = ::KABC::Addressee::uidLabel(); - sName = (const sal_Unicode *) aQtName.ucs2(); - if (match(columnNamePattern, sName, '\0')) - { - aRow[4] = new ORowSetValueDecorator(sName); - aRow[5] = new ORowSetValueDecorator(DataType::CHAR); - aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR")); - aRow[7] = new ORowSetValueDecorator((sal_Int32) 16); - aRow[17] = new ORowSetValueDecorator(nPosition++); - aRows.push_back(aRow); - } aQtName = ::KABC::Addressee::revisionLabel(); sName = (const sal_Unicode *) aQtName.ucs2(); File [changed]: KResultSet.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KResultSet.cxx?r1=1.1.2.12&r2=1.1.2.13 Delta lines: +50 -8 -------------------- --- KResultSet.cxx 2 Dec 2005 20:19:13 -0000 1.1.2.12 +++ KResultSet.cxx 2 Dec 2005 22:21:25 -0000 1.1.2.13 @@ -4,9 +4,9 @@ * * $RCSfile: KResultSet.cxx,v $ * - * $Revision: 1.1.2.12 $ + * $Revision: 1.1.2.13 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:13 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -219,9 +219,6 @@ switch (nFieldNumber) { - case KAB_FIELD_UID: - aQtName = m_aKabAddressees[m_nRowPos].uid(); - break; case KAB_FIELD_REVISION: // trigger an exception here m_bWasNull = true; @@ -829,8 +826,14 @@ ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - // if you don't want to support bookmark you must remove the XRowLocate interface + sal_Int32 nAddressees = m_aKabAddressees.size(); + if (m_nRowPos != -1 && m_nRowPos != nAddressees) + { + QString aQtName = m_aKabAddressees[m_nRowPos].uid(); + ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + return makeAny(sUniqueIdentifier); + } return Any(); } // ------------------------------------------------------------------------- @@ -839,6 +842,20 @@ ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + ::rtl::OUString sBookmark = comphelper::getString(bookmark); + sal_Int32 nAddressees = m_aKabAddressees.size(); + + for (sal_Int32 nRow = 0; nRow < nAddressees; nRow++) + { + QString aQtName = m_aKabAddressees[nRow].uid(); + ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + + if (sUniqueIdentifier == sBookmark) + { + m_nRowPos = nRow; + return sal_True; + } + } return sal_False; } // ------------------------------------------------------------------------- @@ -847,6 +864,19 @@ ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + sal_Int32 nRowSave = m_nRowPos; + + if (moveToBookmark(bookmark)) + { + sal_Int32 nAddressees = m_aKabAddressees.size(); + + m_nRowPos += rows; + + if (-1 < m_nRowPos && m_nRowPos < nAddressees) + return sal_True; + } + + m_nRowPos = nRowSave; return sal_False; } // ------------------------------------------------------------------------- @@ -855,7 +885,14 @@ ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - return CompareBookmark::NOT_EQUAL; + ::rtl::OUString sFirst = comphelper::getString(first); + ::rtl::OUString sSecond = comphelper::getString(second); + + if (sFirst < sSecond) + return CompareBookmark::LESS; + if (sFirst > sSecond) + return CompareBookmark::GREATER; + return CompareBookmark::EQUAL; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL KabResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException) @@ -865,7 +902,12 @@ // ------------------------------------------------------------------------- sal_Int32 SAL_CALL KabResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException) { - throw SQLException(); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + ::rtl::OUString sBookmark = comphelper::getString(bookmark); + + return sBookmark.hashCode(); } // ------------------------------------------------------------------------- // XDeleteRows File [changed]: KResultSetMetaData.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KResultSetMetaData.cxx?r1=1.1.2.5&r2=1.1.2.6 Delta lines: +7 -10 -------------------- --- KResultSetMetaData.cxx 2 Dec 2005 20:19:14 -0000 1.1.2.5 +++ KResultSetMetaData.cxx 2 Dec 2005 22:21:25 -0000 1.1.2.6 @@ -4,9 +4,9 @@ * * $RCSfile: KResultSetMetaData.cxx,v $ * - * $Revision: 1.1.2.5 $ + * $Revision: 1.1.2.6 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:14 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -110,9 +110,6 @@ switch (nFieldNumber) { - case KAB_FIELD_UID: - aQtName = KABC::Addressee::uidLabel(); - break; case KAB_FIELD_REVISION: aQtName = KABC::Addressee::revisionLabel(); break; File [changed]: kcondition.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/kcondition.cxx?r1=1.1.2.5&r2=1.1.2.6 Delta lines: +12 -26 --------------------- --- kcondition.cxx 2 Dec 2005 20:19:17 -0000 1.1.2.5 +++ kcondition.cxx 2 Dec 2005 22:21:25 -0000 1.1.2.6 @@ -4,9 +4,9 @@ * * $RCSfile: kcondition.cxx,v $ * - * $Revision: 1.1.2.5 $ + * $Revision: 1.1.2.6 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:17 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -34,6 +34,7 @@ ************************************************************************/ #include "kcondition.hxx" + #ifndef _CONNECTIVITY_KAB_FIELDS_HXX_ #include "kfields.hxx" #endif @@ -76,25 +77,6 @@ { } // ----------------------------------------------------------------------------- -QString KabConditionColumn::value(const ::KABC::Addressee &aAddressee) const -{ - switch (m_nFieldNumber) - { - case KAB_FIELD_UID: - return aAddressee.uid(); - case KAB_FIELD_REVISION: -return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss"); -// That's not the correct way to do it. -// Timestamps deserve a KabCondition class of their own. -// The syntax for such queries should be like -// {ts '2004-03-29 12:55:00.000000'} -// They should also support operators like '<' or '>=' - default: - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - return aFields[m_nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee); - } -} -// ----------------------------------------------------------------------------- sal_Bool KabConditionColumn::isAlwaysTrue() const { // Sometimes true, sometimes false @@ -114,7 +96,7 @@ // ----------------------------------------------------------------------------- sal_Bool KabConditionNull::eval(const ::KABC::Addressee &aAddressee) const { - QString aQtName(value(aAddressee)); + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); return aQtName.isNull(); // KDE address book currently does not use NULL values. @@ -128,7 +110,7 @@ // ----------------------------------------------------------------------------- sal_Bool KabConditionNotNull::eval(const ::KABC::Addressee &aAddressee) const { - QString aQtName(value(aAddressee)); + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); return !aQtName.isNull(); // KDE address book currently does not use NULL values. @@ -148,7 +130,11 @@ // ----------------------------------------------------------------------------- sal_Bool KabConditionEqual::eval(const ::KABC::Addressee &aAddressee) const { - QString aQtName(value(aAddressee)); + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); +// Timestamps should not be compared according to their string value +// The syntax for such queries should be like +// {ts '2004-03-29 12:55:00.000000'} +// They should also support operators like '<' or '>=' if (aQtName.isNull()) return sal_False; @@ -163,7 +149,7 @@ // ----------------------------------------------------------------------------- sal_Bool KabConditionDifferent::eval(const ::KABC::Addressee &aAddressee) const { - QString aQtName(value(aAddressee)); + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); if (aQtName.isNull()) return sal_False; @@ -178,7 +164,7 @@ // ----------------------------------------------------------------------------- sal_Bool KabConditionSimilar::eval(const ::KABC::Addressee &aAddressee) const { - QString aQtName(value(aAddressee)); + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); if (aQtName.isNull()) return sal_False; File [changed]: kfields.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/kfields.cxx?r1=1.1.2.3&r2=1.1.2.4 Delta lines: +15 -7 -------------------- --- kfields.cxx 2 Dec 2005 20:19:18 -0000 1.1.2.3 +++ kfields.cxx 2 Dec 2005 22:21:26 -0000 1.1.2.4 @@ -4,9 +4,9 @@ * * $RCSfile: kfields.cxx,v $ * - * $Revision: 1.1.2.3 $ + * $Revision: 1.1.2.4 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:18 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:26 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,17 +42,25 @@ { namespace kab { +// ----------------------------------------------------------------------------- +// return the value of a KDE address book field, given an addressee and a field number +QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber) +{ + switch (nFieldNumber) + { + case KAB_FIELD_REVISION: + return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss"); + default: + ::KABC::Field::List aFields = ::KABC::Field::allFields(); + return aFields[nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee); + } +} // ------------------------------------------------------------------------------ // search the KDE address book field number of a given column name sal_uInt32 findKabField(const ::rtl::OUString& columnName) throw(SQLException) { QString aQtName; ::rtl::OUString aName; - - aQtName = KABC::Addressee::uidLabel(); - aName = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); - if (columnName == aName) - return KAB_FIELD_UID; aQtName = KABC::Addressee::revisionLabel(); aName = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); File [changed]: kfields.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/kfields.hxx?r1=1.1.2.3&r2=1.1.2.4 Delta lines: +5 -5 ------------------- --- kfields.hxx 2 Dec 2005 20:19:18 -0000 1.1.2.3 +++ kfields.hxx 2 Dec 2005 22:21:26 -0000 1.1.2.4 @@ -4,9 +4,9 @@ * * $RCSfile: kfields.hxx,v $ * - * $Revision: 1.1.2.3 $ + * $Revision: 1.1.2.4 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:18 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:26 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -46,14 +46,14 @@ #include "ustring.hxx" #endif -#define KAB_FIELD_UID 0 -#define KAB_FIELD_REVISION 1 -#define KAB_DATA_FIELDS 2 +#define KAB_FIELD_REVISION 0 +#define KAB_DATA_FIELDS 1 namespace connectivity { namespace kab { + QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber); sal_uInt32 findKabField(const ::rtl::OUString& columnName) throw(::com::sun::star::sdbc::SQLException); } } File [changed]: korder.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/korder.cxx?r1=1.1.2.4&r2=1.1.2.5 Delta lines: +5 -17 -------------------- --- korder.cxx 2 Dec 2005 20:19:19 -0000 1.1.2.4 +++ korder.cxx 2 Dec 2005 22:21:27 -0000 1.1.2.5 @@ -4,9 +4,9 @@ * * $RCSfile: korder.cxx,v $ * - * $Revision: 1.1.2.4 $ + * $Revision: 1.1.2.5 $ * - * last change: $Author: ebischoff $ $Date: 2005/12/02 20:19:19 $ + * last change: $Author: ebischoff $ $Date: 2005/12/02 22:21:27 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -52,25 +52,13 @@ { } // ----------------------------------------------------------------------------- -QString KabSimpleOrder::value(const ::KABC::Addressee &aAddressee) const -{ - switch (m_nFieldNumber) - { - case KAB_FIELD_UID: - return aAddressee.uid(); - case KAB_FIELD_REVISION: - return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss"); - default: - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - return aFields[m_nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee); - } -} -// ----------------------------------------------------------------------------- sal_Int32 KabSimpleOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const { sal_Int32 result; - result = QString::compare(value(aAddressee1), value(aAddressee2)); + result = QString::compare( + valueOfKabField(aAddressee1, m_nFieldNumber), + valueOfKabField(aAddressee2, m_nFieldNumber)); // Timestamps should be compared differently than with their string value if (!m_bAscending) result = -result; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
