Tag: cws_src680_macaddressbook01 User: cremlae Date: 2007-07-13 20:02:35+0000 Modified: dba/connectivity/source/drivers/macab/MacabRecords.cxx dba/connectivity/source/drivers/macab/MacabRecords.hxx dba/connectivity/source/drivers/macab/MacabHeader.cxx dba/connectivity/source/drivers/macab/MacabAddressBook.cxx dba/connectivity/source/drivers/macab/MacabAddressBook.hxx
Log: #79512# #79513# #79514# Applied patches for the Mac OS X Address Book Integration: to fix null headers crash, to handle multiple groups of the same name, and to be optimized for mail merge File Changes: Directory: /dba/connectivity/source/drivers/macab/ ================================================== File [changed]: MacabRecords.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/macab/MacabRecords.cxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +145 -16 ---------------------- --- MacabRecords.cxx 2007-07-13 18:17:42+0000 1.1.2.2 +++ MacabRecords.cxx 2007-07-13 20:02:32+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: MacabRecords.cxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: cremlae $ $Date: 2007/07/13 18:17:42 $ + * last change: $Author: cremlae $ $Date: 2007/07/13 20:02:32 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -72,6 +72,7 @@ addressBook = _addressBook; recordType = kABPersonRecordType; bootstrap_CF_types(); + bootstrap_requiredProperties(); } // ------------------------------------------------------------------------- @@ -87,6 +88,7 @@ recordType = kABPersonRecordType; bootstrap_CF_types(); + bootstrap_requiredProperties(); } // ------------------------------------------------------------------------- @@ -99,11 +101,13 @@ addressBook = _addressBook; recordType = kABPersonRecordType; bootstrap_CF_types(); + bootstrap_requiredProperties(); } // ------------------------------------------------------------------------- void MacabRecords::initialize() { + if(records != NULL) { sal_Int32 i; @@ -129,7 +133,6 @@ records = new MacabRecord *[recordsSize]; header = createHeaderForRecordType(allRecords, recordType); - header->sortRecord(); for(i = 0; i < recordsSize; i++) { @@ -279,45 +282,145 @@ } // ------------------------------------------------------------------------- +/* This is based on the possible fields required in the mail merge template + * in sw. If the fields possible there change, it would be optimal to + * change these fields as well. + */ +void MacabRecords::bootstrap_requiredProperties() +{ + numRequiredProperties = 7; + requiredProperties = new CFStringRef[numRequiredProperties]; + requiredProperties[0] = kABTitleProperty; + requiredProperties[1] = kABFirstNameProperty; + requiredProperties[2] = kABLastNameProperty; + requiredProperties[3] = kABOrganizationProperty; + requiredProperties[4] = kABAddressProperty; + requiredProperties[5] = kABPhoneProperty; + requiredProperties[6] = kABEmailProperty; +} + +// ------------------------------------------------------------------------- MacabHeader *MacabRecords::createHeaderForRecordType(const CFArrayRef _records, const CFStringRef _recordType) const { - CFArrayRef recordProperties = ABCopyArrayOfPropertiesForRecordType(addressBook, _recordType); + CFArrayRef allProperties = ABCopyArrayOfPropertiesForRecordType(addressBook, _recordType); + CFStringRef *nonRequiredProperties; ABRecordRef record; sal_Int32 numRecords = (sal_Int32) CFArrayGetCount(_records); - sal_Int32 numProperties = (sal_Int32) CFArrayGetCount(recordProperties); - sal_Int32 i, j; + sal_Int32 numProperties = (sal_Int32) CFArrayGetCount(allProperties); + sal_Int32 i, j, k; CFStringRef property; MacabHeader *headerDataForProperty; MacabHeader *lcl_header = new MacabHeader(); + MacabHeader *nonRequiredHeader = new MacabHeader(); + + sal_Int32 numNonRequiredProperties = numProperties - numRequiredProperties; + sal_Bool bFoundProperty; + sal_Bool bFoundRequiredProperties[numRequiredProperties]; + nonRequiredProperties = new CFStringRef[numNonRequiredProperties]; + k = 0; + + for(i = 0; i < numRequiredProperties; i++) + bFoundRequiredProperties[i] = sal_False; + + /* Determine the non-required properties... */ + for(i = 0; i < numProperties; i++) + { + property = (CFStringRef) CFArrayGetValueAtIndex(allProperties, i); + bFoundProperty = sal_False; + for(j = 0; j < numRequiredProperties; j++) + { + if(CFEqual(property, requiredProperties[j])) + { + bFoundProperty = sal_True; + bFoundRequiredProperties[j] = sal_True; + break; + } + } + + if(bFoundProperty == sal_False) + { + if(k == numNonRequiredProperties) + { + k++; // so that the OSL_ENSURE below fails + break; + } + nonRequiredProperties[k] = property; + k++; + } + } + + // Somehow, we got too many or too few non-requird properties... + // Most likely, one of the required properties no longer exists, which + // we also test later. + OSL_ENSURE(k == numNonRequiredProperties, "MacabRecords::createHeaderForRecordType: Found an unexpected number of non-required properties"); - /* Go through the array... */ + /* Fill in required headers first... */ + for(i = 0; i < numRequiredProperties; i++) + { + if(bFoundRequiredProperties[i] == sal_True) + { + /* The order of these matters (we want all address properties + * before any phone properties, or else things will look weird), + * so we get all possibilitities for each property, going through + * each record, and then go onto the next property. + * (Note: the reason that we have to go through all records + * in the first place is that properties like address, phone, and + * e-mail are multi-value properties with an unknown number of + * values. A user could specify thirteen different kinds of + * e-mail addresses for one of her or his contacts, and we need to + * get all of them. + */ + for(j = 0; j < numRecords; j++) + { + record = (ABRecordRef) CFArrayGetValueAtIndex(_records, j); + headerDataForProperty = createHeaderForProperty(record,requiredProperties[i],_recordType,sal_True); + if(headerDataForProperty != NULL) + { + (*lcl_header) += headerDataForProperty; + delete headerDataForProperty; + } + } + } + else + { + // Couldn't find a required property... + OSL_ENSURE(false, ::rtl::OString("MacabRecords::createHeaderForRecordType: could not find required property: ") + + ::rtl::OUStringToOString(CFStringToOUString(requiredProperties[i]), RTL_TEXTENCODING_ASCII_US)); + } + } + + /* And now, non-required ones... */ for(i = 0; i < numRecords; i++) { /* This is the record */ record = (ABRecordRef) CFArrayGetValueAtIndex(_records, i); /* Go through the properties array... */ - for(j = 0; j < numProperties; j++) + for(j = 0; j < numNonRequiredProperties; j++) { - /* Get the Property's string name */ - property = (CFStringRef) CFArrayGetValueAtIndex(recordProperties, j); - headerDataForProperty = createHeaderForProperty(record,property,_recordType); + property = nonRequiredProperties[j]; + headerDataForProperty = createHeaderForProperty(record,property,_recordType,sal_False); if(headerDataForProperty != NULL) { - (*lcl_header) += headerDataForProperty; + (*nonRequiredHeader) += headerDataForProperty; delete headerDataForProperty; } } } // end of for loop through records + nonRequiredHeader->sortRecord(); - CFRelease(recordProperties); + (*lcl_header) += nonRequiredHeader; + delete nonRequiredHeader; + + CFRelease(allProperties); + delete [] nonRequiredProperties; return lcl_header; } // ------------------------------------------------------------------------- -MacabHeader *MacabRecords::createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType) const +MacabHeader *MacabRecords::createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const sal_Bool _isPropertyRequired) const { // local variables CFTypeRef propertyValue; @@ -326,13 +429,16 @@ /* Get the property's value */ propertyValue = ABRecordCopyValue(_record,_propertyName); - if(propertyValue == NULL) + if(propertyValue == NULL && _isPropertyRequired == sal_False) return NULL; propertyType = ABTypeOfProperty(addressBook, _recordType, _propertyName); result = createHeaderForProperty(propertyType, propertyValue, _propertyName); + + if(propertyValue != NULL) CFRelease(propertyValue); + return result; } @@ -360,8 +466,13 @@ case kABMultiStringProperty: case kABMultiRealProperty: case kABMultiDataProperty: + /* For non-scalars, we can only get more information if the property + * actually exists. + */ + if(_propertyValue != NULL) { sal_Int32 i; + sal_Int32 multiLength = ABMultiValueCount((ABMutableMultiValueRef) _propertyValue); CFStringRef multiLabel; ::rtl::OUString multiLabelString; @@ -390,6 +501,10 @@ case kABMultiArrayProperty: case kABMultiDictionaryProperty: + /* For non-scalars, we can only get more information if the property + * actually exists. + */ + if(_propertyValue != NULL) { sal_Int32 i,j,k; sal_Int32 multiLengthFirstLevel = ABMultiValueCount((ABMutableMultiValueRef) _propertyValue); @@ -415,6 +530,8 @@ CFRelease(multiLabel); multiLabel = OUStringToCFString(multiLabelString); multiHeaders[i] = createHeaderForProperty(multiType, multiValue, multiLabel); + if (!multiHeaders[i]) + multiHeaders[i] = new MacabHeader(); multiLengthSecondLevel += multiHeaders[i]->getSize(); } else @@ -446,6 +563,10 @@ break; case kABDictionaryProperty: + /* For non-scalars, we can only get more information if the property + * actually exists. + */ + if(_propertyValue != NULL) { /* Assume all keys are strings */ sal_Int32 numRecords = (sal_Int32) CFDictionaryGetCount((CFDictionaryRef) _propertyValue); @@ -473,6 +594,8 @@ dictLabelString = propertyNameString + ::rtl::OUString::createFromAscii(": ") + fixLabel(dictKeyString); dictLabel = OUStringToCFString(dictLabelString); dictHeaders[i] = createHeaderForProperty(dictType, dictValues[i], dictLabel); + if (!dictHeaders[i]) + dictHeaders[i] = new MacabHeader(); length += dictHeaders[i]->getSize(); CFRelease(dictLabel); } @@ -499,6 +622,10 @@ break; case kABArrayProperty: + /* For non-scalars, we can only get more information if the property + * actually exists. + */ + if(_propertyValue != NULL) { sal_Int32 arrLength = (sal_Int32) CFArrayGetCount( (CFArrayRef) _propertyValue); sal_Int32 i,j,k; @@ -517,6 +644,8 @@ arrLabelString = propertyNameString + ::rtl::OUString::valueOf(i); arrLabel = OUStringToCFString(arrLabelString); arrHeaders[i] = createHeaderForProperty(arrType, arrValue, arrLabel); + if (!arrHeaders[i]) + arrHeaders[i] = new MacabHeader(); length += arrHeaders[i]->getSize(); CFRelease(arrLabel); } File [changed]: MacabRecords.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/macab/MacabRecords.hxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +7 -3 ------------------- --- MacabRecords.hxx 2007-07-13 18:17:42+0000 1.1.2.2 +++ MacabRecords.hxx 2007-07-13 20:02:33+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: MacabRecords.hxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: cremlae $ $Date: 2007/07/13 18:17:42 $ + * last change: $Author: cremlae $ $Date: 2007/07/13 20:02:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -73,9 +73,13 @@ MacabRecord **records; ABAddressBookRef addressBook; ::rtl::OUString m_sName; + // cremlae, fill me + CFStringRef *requiredProperties; + sal_Int32 numRequiredProperties; private: void bootstrap_CF_types(); - MacabHeader *createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType) const; + void bootstrap_requiredProperties(); + MacabHeader *createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const sal_Bool _isPropertyRequired) const; MacabHeader *createHeaderForProperty(const ABPropertyType _propertyType, const CFTypeRef _propertyValue, const CFStringRef _propertyName) const; void manageDuplicateHeaders(macabfield **_headerNames, const sal_Int32 _length) const; ABPropertyType getABTypeFromCFType(const CFTypeID cf_type ) const; File [changed]: MacabHeader.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/macab/MacabHeader.cxx?r1=1.1.2.1&r2=1.1.2.2 Delta lines: +2 -338 --------------------- --- MacabHeader.cxx 2007-07-08 19:20:58+0000 1.1.2.1 +++ MacabHeader.cxx 2007-07-13 20:02:33+0000 1.1.2.2 @@ -4,9 +4,9 @@ * * $RCSfile: MacabHeader.cxx,v $ * - * $Revision: 1.1.2.1 $ + * $Revision: 1.1.2.2 $ * - * last change: $Author: msicotte $ $Date: 2007/07/08 19:20:58 $ + * last change: $Author: cremlae $ $Date: 2007/07/13 20:02:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -239,49 +239,8 @@ return sorted; } -// ------------------------------------------------------------------------- sal_Int32 MacabHeader::compareFields(const macabfield *_field1, const macabfield *_field2) { - /* In the header, all values are of type CFStringRefs, but the type - * refers to the type expected for data in this column. So, we always - * compare strings. - * - * Also: we do the comparison in two steps. First, if both fields are - * from the same category (e.g., address), and at least one of them has - * a counter (value ends with (%d)), then we put the one with the smallest - * counter first (if there is no counter, that basically means that the - * counter is 1). - * - * Second, if there is no counter, or the two fields are from different - * categories, we go through a hard-coded ordering scheme, basically - * checking each possibility in order and returning the appropriate - * comparison if we find a match. (So, we first check if either field is - * a first name. If the first field is, it is smaller than the second, - * no matter what, so we return -1. If the second field is, it is smaller - * than the first, no matter what, so we return 1. Then, we proceed to - * middle name... &c. This is not a very intelligent way of doing the - * ordering, but I honestly could not think of a better one, given: - * - * a) Different fields need to be compared in different ways. Single - * labels (like first name, last name, &c.) can be checked for - * equality (is the label equal to "first"?). Labels with multiple - * parts (e.g., address) must check only the first part of the string - * (e.g., does the label _start with_ "address," so that - * "address: city" matches). - * - * b) The ordering scheme is fairly arbitrary, based on my own opinion - * of what would be most useful first (names and addresses) and what - * would be least useful (UIDs, creation/modification dates). - * - * If you can think of a better system, please implement it! - * - * Final note: because OUStrings are easier to work with than CFStrings, - * and are more powerful, we have two ways of refering to the same - * string: _field1->value is the CFString, while string1 is the OUString. - * We use the former whenever we have to (inside a Carbon function) and - * the latter whenever we can. - */ - if(_field1 == _field2) return 0; if(_field1 == NULL) @@ -289,301 +248,6 @@ if(_field2 == NULL) return -1; - ::rtl::OUString string1 = CFStringToOUString((CFStringRef) _field1->value); - ::rtl::OUString string2 = CFStringToOUString((CFStringRef) _field2->value); - - // If they start with the same word (are the same category of data), but - // at least one has a (%d), it means that we're dealing with counters, - // and the highest counter is always last. - if(string1.endsWithIgnoreAsciiCaseAsciiL(")",1) ) - { - sal_Int32 lastOpeningParen = string1.lastIndexOf('(')+1; - ::rtl::OUString sCounter1 = string1.copy(lastOpeningParen,string1.getLength()-1-lastOpeningParen); - sal_Int32 nCounter1 = 0; - - try - { - nCounter1 = sCounter1.toInt32(); - } - catch(...) - { - // If it wasn't a number, this label (for some reason) just - // ends in a parenthesis. - } - - if(nCounter1 != 0) - { - sal_Int32 firstSpace = string1.indexOf(' '); - - // Same category of data - if(string2.indexOf(string1.copy(0,firstSpace)) == 0) - { - if(string2.endsWithIgnoreAsciiCaseAsciiL(")",1) ) - { - lastOpeningParen = string2.lastIndexOf('(')+1; - ::rtl::OUString sCounter2 = string2.copy(lastOpeningParen,string2.getLength()-1-lastOpeningParen); - sal_Int32 nCounter2 = 0; - - try - { - nCounter2 = sCounter2.toInt32(); - if(nCounter2 != 0 && nCounter1 != nCounter2) - { - return nCounter1 - nCounter2; - } - } - catch(...) - { - // If it wasn't a number, this label (for some reason) just - // ends in a parenthesis, but the first label really had a - // number, so it must go after this one. - return 1; - } - - } - else - { - return 1; - } - - } - } - } - else if(string2.endsWithIgnoreAsciiCaseAsciiL(")",1) ) - { - sal_Int32 lastOpeningParen = string2.lastIndexOf('(')+1; - ::rtl::OUString sCounter2 = string2.copy(lastOpeningParen,string2.getLength()-1-lastOpeningParen); - sal_Int32 nCounter2 = 0; - - try - { - nCounter2 = sCounter2.toInt32(); - } - catch(...) - { - // If it wasn't a number, this label (for some reason) just - // ends in a parenthesis - } - - if(nCounter2 != 0) - { - sal_Int32 firstSpace = string1.indexOf(' '); - - // Same category of data - if(string2.indexOf(string1.copy(0,firstSpace)) == 0) - { - // We know that the first string didn't have a counter, but the - // second one does, so the second must go after the first - return -1; - } - - } - - } - - // Done dealing with counters... - - /* Now, we order the fields manually. The order is: - * first, middle, last, organization, address, phone, e-mail, <x>, ABPersonFlags, Notes, modification, creation, UID - * Where <x> is everything not covered by the above. - */ - - // FIRST NAME - if(CFStringCompare( - (CFStringRef) _field1->value, - kABFirstNameProperty, - 0) == kCFCompareEqualTo) - return -1; - - if(CFStringCompare( - (CFStringRef) _field2->value, - kABFirstNameProperty, - 0) == kCFCompareEqualTo) - return 1; - - // MIDDLE NAME - if(CFStringCompare( - (CFStringRef) _field1->value, - kABMiddleNameProperty, - 0) == kCFCompareEqualTo) - return -1; - - if(CFStringCompare( - (CFStringRef) _field2->value, - kABMiddleNameProperty, - 0) == kCFCompareEqualTo) - return 1; - - // LAST NAME - if(CFStringCompare( - (CFStringRef) _field1->value, - kABLastNameProperty, - 0) == kCFCompareEqualTo) - return -1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABLastNameProperty, - 0) == kCFCompareEqualTo) - return 1; - - // ORGANIZATION - if(CFStringCompare( - (CFStringRef) _field1->value, - kABOrganizationProperty, - 0) == kCFCompareEqualTo) - return -1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABOrganizationProperty, - 0) == kCFCompareEqualTo) - return 1; - - // ADDRESS - if(CFStringHasPrefix( - (CFStringRef) _field1->value, - kABAddressProperty) ) - { - // If both are addresses, for now, display them in alphabetical order - if(CFStringHasPrefix( - (CFStringRef) _field2->value, - kABAddressProperty) ) - { - } - - // Otherwise, the address goes first - else - return -1; - } - - // If the first is not an address and the second is, the second goes - // first. - else if(CFStringHasPrefix( - (CFStringRef) _field2->value, - kABAddressProperty) ) - { - return 1; - } - - - // PHONE - if(CFStringHasPrefix( - (CFStringRef) _field1->value, - kABPhoneProperty) ) - { - // If both are phone numbers, for now, display them in alphabetical order - if(CFStringHasPrefix( - (CFStringRef) _field2->value, - kABPhoneProperty) ) - { - } - - // Otherwise, the phone number goes first - else - return -1; - } - - // If the first is not a phone number and the second is, the second goes - // first. - else if(CFStringHasPrefix( - (CFStringRef) _field2->value, - kABPhoneProperty) ) - { - return 1; - } - - // EMAIL - if(CFStringHasPrefix( - (CFStringRef) _field1->value, - kABEmailProperty) ) - { - // If both are e-mail address, for now, display them in alphabetical order - if(CFStringHasPrefix( - (CFStringRef) _field2->value, - kABEmailProperty) ) - { - } - - // Otherwise, the e-mail address goes first - else - return -1; - } - - // If the first is not an e-mail address and the second is, the second goes - // first. - else if(CFStringHasPrefix( - (CFStringRef) _field2->value, - kABEmailProperty) ) - { - return 1; - } - - // The following all go at the end. The order they are presented here - // is the order in which they will appear (from the end of the list) - - ::rtl::OUString sVal; - - // UID - if(CFStringCompare( - (CFStringRef) _field1->value, - kABUIDProperty, - 0) == kCFCompareEqualTo) - return 1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABUIDProperty, - 0) == kCFCompareEqualTo) - return -1; - - // MODIFICATION - if(CFStringCompare( - (CFStringRef) _field1->value, - kABModificationDateProperty, - 0) == kCFCompareEqualTo) - return 1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABModificationDateProperty, - 0) == kCFCompareEqualTo) - return -1; - - // CREATION - if(CFStringCompare( - (CFStringRef) _field1->value, - kABCreationDateProperty, - 0) == kCFCompareEqualTo) - return 1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABCreationDateProperty, - 0) == kCFCompareEqualTo) - return -1; - - // NOTE - if(CFStringCompare( - (CFStringRef) _field1->value, - kABNoteProperty, - 0) == kCFCompareEqualTo) - return 1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABNoteProperty, - 0) == kCFCompareEqualTo) - return -1; - - // PERSONFLAGS - if(CFStringCompare( - (CFStringRef) _field1->value, - kABPersonFlags, - 0) == kCFCompareEqualTo) - return 1; - if(CFStringCompare( - (CFStringRef) _field2->value, - kABPersonFlags, - 0) == kCFCompareEqualTo) - return -1; - - // If it wasn't one of the above, we don't have a rule for it. Compare - // the strings using the (alphabetical) CFStringCompare function. CFComparisonResult result = CFStringCompare( (CFStringRef) _field1->value, (CFStringRef) _field2->value, File [changed]: MacabAddressBook.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/macab/MacabAddressBook.cxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +46 -2 -------------------- --- MacabAddressBook.cxx 2007-07-13 18:17:42+0000 1.1.2.2 +++ MacabAddressBook.cxx 2007-07-13 20:02:33+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: MacabAddressBook.cxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: cremlae $ $Date: 2007/07/13 18:17:42 $ + * last change: $Author: cremlae $ $Date: 2007/07/13 20:02:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -156,6 +156,7 @@ m_xMacabGroups[i] = new MacabGroup(m_aAddressBook, m_xMacabRecords, xGroup); } CFRelease(allGroups); + manageDuplicateGroups(m_xMacabGroups); m_bRetrievedGroups = sal_True; } @@ -209,3 +210,46 @@ return NULL; } + +// ------------------------------------------------------------------------- +void MacabAddressBook::manageDuplicateGroups(::std::vector<MacabGroup *> _xGroups) const +{ + /* If we have two cases of groups, say, family, this makes it: + * family + * family (2) + */ + ::std::vector<MacabGroup *>::reverse_iterator iter1, iter2; + sal_Int32 count; + + for(iter1 = _xGroups.rbegin(); iter1 != _xGroups.rend(); ++iter1) + { + /* If the name matches the default table name, there is already + * (obviously) a conflict. So, start the count of groups with this + * name at 2 instead of 1. + */ + if( (*iter1)->getName() == getDefaultTableName() ) + count = 2; + else + count = 1; + + iter2 = iter1; + for( ++iter2; iter2 != _xGroups.rend(); ++iter2) + { + if( (*iter1)->getName() == (*iter2)->getName() ) + { + count++; + } + } + + // duplicate! + if(count != 1) + { + ::rtl::OUString sName = (*iter1)->getName(); + sName += ::rtl::OUString::createFromAscii(" (") + + ::rtl::OUString::valueOf(count) + + ::rtl::OUString::createFromAscii(")"); + (*iter1)->setName(sName); + } + } +} + File [changed]: MacabAddressBook.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/macab/MacabAddressBook.hxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +4 -2 ------------------- --- MacabAddressBook.hxx 2007-07-13 18:17:42+0000 1.1.2.2 +++ MacabAddressBook.hxx 2007-07-13 20:02:33+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: MacabAddressBook.hxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: cremlae $ $Date: 2007/07/13 18:17:42 $ + * last change: $Author: cremlae $ $Date: 2007/07/13 20:02:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -62,6 +62,8 @@ MacabRecords *m_xMacabRecords; ::std::vector<MacabGroup *> m_xMacabGroups; sal_Bool m_bRetrievedGroups; + private: + void manageDuplicateGroups(::std::vector<MacabGroup *> _xGroups) const; public: MacabAddressBook(); ~MacabAddressBook(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
