diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-05-11 08:38:24 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-05-11 08:38:24 +0200 |
commit | aeacebee3c3af2f632c70a4a9926d2754208d6c8 (patch) | |
tree | c3c2dd2f2984fff77064093db01d9e7286885a98 /connectivity | |
parent | 0617f87cddb2154b8d03380f0b20ecd09687fb1c (diff) |
loplugin:staticmethods
Change-Id: I1730694d8856ed009b8bf02a71657ca933bc6101
Diffstat (limited to 'connectivity')
6 files changed, 105 insertions, 106 deletions
diff --git a/connectivity/source/drivers/macab/MacabAddressBook.cxx b/connectivity/source/drivers/macab/MacabAddressBook.cxx index 9a34dd1ea3d3..14f27b39eabd 100644 --- a/connectivity/source/drivers/macab/MacabAddressBook.cxx +++ b/connectivity/source/drivers/macab/MacabAddressBook.cxx @@ -33,6 +33,49 @@ using namespace connectivity::macab; using namespace ::com::sun::star::uno; +namespace { + +void manageDuplicateGroups(::std::vector<MacabGroup *> _xGroups) +{ + /* 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() == MacabAddressBook::getDefaultTableName() ) + count = 2; + else + count = 1; + + iter2 = iter1; + for( ++iter2; iter2 != _xGroups.rend(); ++iter2) + { + if( (*iter1)->getName() == (*iter2)->getName() ) + { + count++; + } + } + + // duplicate! + if(count != 1) + { + OUString sName = (*iter1)->getName() + " (" + + OUString::number(count) + + ")"; + (*iter1)->setName(sName); + } + } +} + +} MacabAddressBook::MacabAddressBook( ) { @@ -202,45 +245,4 @@ MacabGroup *MacabAddressBook::getMacabGroupMatch(OUString const & _groupName) 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) - { - OUString sName = (*iter1)->getName() + " (" + - OUString::number(count) + - ")"; - (*iter1)->setName(sName); - } - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabAddressBook.hxx b/connectivity/source/drivers/macab/MacabAddressBook.hxx index dd5c090c0ba9..bd2070651bed 100644 --- a/connectivity/source/drivers/macab/MacabAddressBook.hxx +++ b/connectivity/source/drivers/macab/MacabAddressBook.hxx @@ -41,8 +41,7 @@ namespace connectivity MacabRecords *m_xMacabRecords; ::std::vector<MacabGroup *> m_xMacabGroups; bool m_bRetrievedGroups; - private: - void manageDuplicateGroups(::std::vector<MacabGroup *> _xGroups) const; + public: MacabAddressBook(); ~MacabAddressBook(); diff --git a/connectivity/source/drivers/macab/MacabDriver.cxx b/connectivity/source/drivers/macab/MacabDriver.cxx index b601e75485ae..0d6ac6a6302f 100644 --- a/connectivity/source/drivers/macab/MacabDriver.cxx +++ b/connectivity/source/drivers/macab/MacabDriver.cxx @@ -38,6 +38,32 @@ using namespace com::sun::star::sdb; using namespace com::sun::star::frame; using namespace connectivity::macab; +namespace { + +/** throws a generic SQL exception with SQLState S1000 and error code 0 + */ +void throwGenericSQLException( const OUString& _rMessage ) +{ + SQLException aError; + aError.Message = _rMessage; + aError.SQLState = "S1000"; + aError.ErrorCode = 0; + throw aError; +} + +/** throws an SQLException saying than no Mac OS installation was found + */ +void throwNoMacOSException() +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceString( + STR_NO_MAC_OS_FOUND + ) ); + throwGenericSQLException( sError ); +} + + +} // = MacabImplModule @@ -122,28 +148,8 @@ void MacabImplModule::impl_unloadModule() void MacabImplModule::init() { if ( !impl_loadModule() ) - impl_throwNoMacOSException(); - -} - - -void MacabImplModule::impl_throwNoMacOSException() -{ - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceString( - STR_NO_MAC_OS_FOUND - ) ); - impl_throwGenericSQLException( sError ); -} - + throwNoMacOSException(); -void MacabImplModule::impl_throwGenericSQLException( const OUString& _rMessage ) -{ - SQLException aError; - aError.Message = _rMessage; - aError.SQLState = "S1000"; - aError.ErrorCode = 0; - throw aError; } diff --git a/connectivity/source/drivers/macab/MacabDriver.hxx b/connectivity/source/drivers/macab/MacabDriver.hxx index e9dbdb5fc955..0c667e5a155a 100644 --- a/connectivity/source/drivers/macab/MacabDriver.hxx +++ b/connectivity/source/drivers/macab/MacabDriver.hxx @@ -99,15 +99,6 @@ namespace connectivity @precond m_hConnectorModule is not <NULL/> */ void impl_unloadModule(); - - /** throws an SQLException saying than no Mac OS installation was found - */ - void impl_throwNoMacOSException(); - - /** throws a generic SQL exception with SQLState S1000 and error code 0 - */ - void impl_throwGenericSQLException( const OUString& _rMessage ); - }; diff --git a/connectivity/source/drivers/macab/MacabRecords.cxx b/connectivity/source/drivers/macab/MacabRecords.cxx index bd374a14c772..56a27ff1c478 100644 --- a/connectivity/source/drivers/macab/MacabRecords.cxx +++ b/connectivity/source/drivers/macab/MacabRecords.cxx @@ -32,6 +32,40 @@ using namespace connectivity::macab; using namespace com::sun::star::util; +namespace { + +void manageDuplicateHeaders(macabfield **_headerNames, const sal_Int32 _length) +{ + /* If we have two cases of, say, phone: home, this makes it: + * phone: home (1) + * phone: home (2) + */ + sal_Int32 i, j; + sal_Int32 count; + for(i = _length-1; i >= 0; i--) + { + count = 1; + for( j = i-1; j >= 0; j--) + { + if(CFEqual(_headerNames[i]->value, _headerNames[j]->value)) + { + count++; + } + } + + // duplicate! + if(count != 1) + { + // There is probably a better way to do this... + OUString newName = CFStringToOUString(static_cast<CFStringRef>(_headerNames[i]->value)); + CFRelease(_headerNames[i]->value); + newName += " (" + OUString::number(count) + ")"; + _headerNames[i]->value = OUStringToCFString(newName); + } + } +} + +} MacabRecords::MacabRecords(const ABAddressBookRef _addressBook, MacabHeader *_header, MacabRecord **_records, sal_Int32 _numRecords) { @@ -811,38 +845,6 @@ MacabHeader *MacabRecords::createHeaderForProperty(const ABPropertyType _propert } -void MacabRecords::manageDuplicateHeaders(macabfield **_headerNames, const sal_Int32 _length) const -{ - /* If we have two cases of, say, phone: home, this makes it: - * phone: home (1) - * phone: home (2) - */ - sal_Int32 i, j; - sal_Int32 count; - for(i = _length-1; i >= 0; i--) - { - count = 1; - for( j = i-1; j >= 0; j--) - { - if(CFEqual(_headerNames[i]->value, _headerNames[j]->value)) - { - count++; - } - } - - // duplicate! - if(count != 1) - { - // There is probably a better way to do this... - OUString newName = CFStringToOUString(static_cast<CFStringRef>(_headerNames[i]->value)); - CFRelease(_headerNames[i]->value); - newName += " (" + OUString::number(count) + ")"; - _headerNames[i]->value = OUStringToCFString(newName); - } - } -} - - /* Create a MacabRecord out of an ABRecord, using a given MacabHeader and * the record's type. We go through each property for this record type * then process it much like we processed the header (above), with two diff --git a/connectivity/source/drivers/macab/MacabRecords.hxx b/connectivity/source/drivers/macab/MacabRecords.hxx index 6a43b6b15306..5a5035258990 100644 --- a/connectivity/source/drivers/macab/MacabRecords.hxx +++ b/connectivity/source/drivers/macab/MacabRecords.hxx @@ -73,7 +73,6 @@ namespace connectivity void bootstrap_requiredProperties(); MacabHeader *createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const 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; void insertPropertyIntoMacabRecord(MacabRecord *_abrecord, const MacabHeader *_header, const OUString& _propertyName, const CFTypeRef _propertyValue) const; void insertPropertyIntoMacabRecord(const ABPropertyType _propertyType, MacabRecord *_abrecord, const MacabHeader *_header, const OUString& _propertyName, const CFTypeRef _propertyValue) const; |