From ece4466e4ff5f89aad0ec88b39269cfac0dc76c3 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 8 May 2015 12:27:52 +0200 Subject: loplugin:staticmethods Change-Id: Ic93e560641f1ec1c5fc316ed126617c6d99ab5b5 --- connectivity/source/drivers/evoab2/NResultSet.cxx | 70 +++++----- connectivity/source/drivers/evoab2/NStatement.cxx | 41 +++--- connectivity/source/drivers/evoab2/NStatement.hxx | 4 - connectivity/source/drivers/kab/KDriver.cxx | 151 +++++++++++----------- connectivity/source/drivers/kab/KDriver.hxx | 16 --- 5 files changed, 138 insertions(+), 144 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index 7fc072f6c6d1..077bf1690b91 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -368,6 +368,18 @@ OString OEvoabVersionHelper::getUserName( EBook *pBook ) return aName; } +namespace { + +bool isBookBackend( EBookClient *pBook, const char *backendname) +{ + if (!pBook) + return false; + ESource *pSource = e_client_get_source ((EClient *) pBook); + return isSourceBackend(pSource, backendname); +} + +} + class OEvoabVersion36Helper : public OEvoabVersionHelper { private: @@ -416,14 +428,6 @@ public: return pBook; } - bool isBookBackend( EBookClient *pBook, const char *backendname) - { - if (!pBook) - return false; - ESource *pSource = e_client_get_source ((EClient *) pBook); - return isSourceBackend(pSource, backendname); - } - virtual bool isLDAP( EBook *pBook ) SAL_OVERRIDE { return isBookBackend(pBook, "ldap"); @@ -490,37 +494,41 @@ protected: } }; -class OEvoabVersion35Helper : public OEvoabVersionHelper -{ -private: - GList *m_pContacts; +namespace { - ESource * findSource( const char *id ) - { - ESourceList *pSourceList = NULL; +ESource * findSource( const char *id ) +{ + ESourceList *pSourceList = NULL; - g_return_val_if_fail (id != NULL, NULL); + g_return_val_if_fail (id != NULL, NULL); - if (!e_book_get_addressbooks (&pSourceList, NULL)) - pSourceList = NULL; + if (!e_book_get_addressbooks (&pSourceList, NULL)) + pSourceList = NULL; - for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next) + for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next) + { + for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) { - for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) - { - ESource *pSource = E_SOURCE (s->data); - if (!strcmp (e_source_peek_name (pSource), id)) - return pSource; - } + ESource *pSource = E_SOURCE (s->data); + if (!strcmp (e_source_peek_name (pSource), id)) + return pSource; } - return NULL; } + return NULL; +} - bool isAuthRequired( EBook *pBook ) - { - return e_source_get_property( e_book_get_source( pBook ), - "auth" ) != NULL; - } +bool isAuthRequired( EBook *pBook ) +{ + return e_source_get_property( e_book_get_source( pBook ), + "auth" ) != NULL; +} + +} + +class OEvoabVersion35Helper : public OEvoabVersionHelper +{ +private: + GList *m_pContacts; public: OEvoabVersion35Helper() diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx index c82418890572..f8cb606d62b9 100644 --- a/connectivity/source/drivers/evoab2/NStatement.cxx +++ b/connectivity/source/drivers/evoab2/NStatement.cxx @@ -49,6 +49,26 @@ using namespace com::sun::star::container; using namespace com::sun::star::io; using namespace com::sun::star::util; +namespace { + +EBookQuery * createTrue() +{ // Not the world's most efficient unconditional true but ... + return e_book_query_from_string("(exists \"full_name\")"); +} + +EBookQuery * createTest( const OUString &aColumnName, + EBookQueryTest eTest, + const OUString &aMatch ) +{ + OString sMatch = OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 ); + OString sColumnName = OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 ); + + return e_book_query_field_test( e_contact_field_id( sColumnName.getStr() ), + eTest, sMatch.getStr() ); +} + +} + OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection) : OCommonStatement_IBase(m_aMutex) , ::comphelper::OPropertyContainer(OCommonStatement_IBase::rBHelper) @@ -152,27 +172,6 @@ void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException, dispose(); } - -EBookQuery * -OCommonStatement::createTrue() -{ // Not the world's most efficient unconditional true but ... - return e_book_query_from_string("(exists \"full_name\")"); -} - -EBookQuery * -OCommonStatement::createTest( const OUString &aColumnName, - EBookQueryTest eTest, - const OUString &aMatch ) -{ - OString sMatch = OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 ); - OString sColumnName = OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 ); - - return e_book_query_field_test( e_contact_field_id( sColumnName.getStr() ), - eTest, sMatch.getStr() ); -} - - - OUString OCommonStatement::impl_getColumnRefColumnName_throw( const OSQLParseNode& _rColumnRef ) { ENSURE_OR_THROW( SQL_ISRULE( &_rColumnRef, column_ref ), "internal error: only column_refs supported as LHS" ); diff --git a/connectivity/source/drivers/evoab2/NStatement.hxx b/connectivity/source/drivers/evoab2/NStatement.hxx index 7d92717d5a48..9634ae8f8c1b 100644 --- a/connectivity/source/drivers/evoab2/NStatement.hxx +++ b/connectivity/source/drivers/evoab2/NStatement.hxx @@ -180,10 +180,6 @@ namespace connectivity EBookQuery *whereAnalysis( const OSQLParseNode* parseTree ); void orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort ); OUString getTableName(); - EBookQuery *createTrue(); - EBookQuery *createTest( const OUString &aColumnName, - EBookQueryTest eTest, - const OUString &aMatch ); public: diff --git a/connectivity/source/drivers/kab/KDriver.cxx b/connectivity/source/drivers/kab/KDriver.cxx index 21bf85d24934..43e254267711 100644 --- a/connectivity/source/drivers/kab/KDriver.cxx +++ b/connectivity/source/drivers/kab/KDriver.cxx @@ -56,6 +56,82 @@ using namespace com::sun::star::sdb; using namespace com::sun::star::frame; using namespace connectivity::kab; +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 KDE installation was found + */ +void throwNoKdeException() +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceString( + STR_NO_KDE_INST + ) ); + throwGenericSQLException( sError ); +} + +/** throws an SQLException saying that the found KDE version is too old + */ +void throwKdeTooOldException() +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceStringWithSubstitution( + STR_KDE_VERSION_TOO_OLD, + "$major$",OUString::number(MIN_KDE_VERSION_MAJOR), + "$minor$",OUString::number(MIN_KDE_VERSION_MINOR) + ) ); + throwGenericSQLException( sError ); +} + +/** throws an SQLException saying that the found KDE version is too new + */ +void throwKdeTooNewException() +{ + ::connectivity::SharedResources aResources; + + SQLException aError; + aError.Message = aResources.getResourceStringWithSubstitution( + STR_KDE_VERSION_TOO_NEW, + "$major$",OUString::number(MIN_KDE_VERSION_MAJOR), + "$minor$",OUString::number(MIN_KDE_VERSION_MINOR) + ); + aError.SQLState = "S1000"; + aError.ErrorCode = 0; + + SQLContext aDetails; + OUStringBuffer aMessage; + aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) ); + + aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" ); + aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" ); + + aMessage.appendAscii( " Dim configNode as Object\n" ); + aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" ); + aMessage.append( KabDriver::impl_getConfigurationSettingsPath() ); + aMessage.appendAscii( "\", true )\n" ); + + aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" ); + aMessage.appendAscii( " configNode.commitChanges\n" ); + aMessage.appendAscii( "End Sub\n" ); + + aDetails.Message = aMessage.makeStringAndClear(); + + aError.NextException <<= aDetails; + + throw aError; +} + +} // = KabImplModule @@ -172,16 +248,16 @@ void KabImplModule::impl_unloadModule() void KabImplModule::init() { if ( !impl_loadModule() ) - impl_throwNoKdeException(); + throwNoKdeException(); // if we're not running on a supported version, throw KabImplModule::KDEVersionType eKDEVersion = matchKDEVersion(); if ( eKDEVersion == eTooOld ) - impl_throwKdeTooOldException(); + throwKdeTooOldException(); if ( ( eKDEVersion == eToNew ) && !impl_doAllowNewKDEVersion() ) - impl_throwKdeTooNewException(); + throwKdeTooNewException(); if ( !m_bAttemptedInitialize ) { @@ -221,75 +297,6 @@ bool KabImplModule::impl_doAllowNewKDEVersion() } -void KabImplModule::impl_throwNoKdeException() -{ - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceString( - STR_NO_KDE_INST - ) ); - impl_throwGenericSQLException( sError ); -} - - -void KabImplModule::impl_throwKdeTooOldException() -{ - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceStringWithSubstitution( - STR_KDE_VERSION_TOO_OLD, - "$major$",OUString::number(MIN_KDE_VERSION_MAJOR), - "$minor$",OUString::number(MIN_KDE_VERSION_MINOR) - ) ); - impl_throwGenericSQLException( sError ); -} - - -void KabImplModule::impl_throwGenericSQLException( const OUString& _rMessage ) -{ - SQLException aError; - aError.Message = _rMessage; - aError.SQLState = "S1000"; - aError.ErrorCode = 0; - throw aError; -} - - -void KabImplModule::impl_throwKdeTooNewException() -{ - ::connectivity::SharedResources aResources; - - SQLException aError; - aError.Message = aResources.getResourceStringWithSubstitution( - STR_KDE_VERSION_TOO_NEW, - "$major$",OUString::number(MIN_KDE_VERSION_MAJOR), - "$minor$",OUString::number(MIN_KDE_VERSION_MINOR) - ); - aError.SQLState = "S1000"; - aError.ErrorCode = 0; - - SQLContext aDetails; - OUStringBuffer aMessage; - aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) ); - - aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" ); - aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" ); - - aMessage.appendAscii( " Dim configNode as Object\n" ); - aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" ); - aMessage.append( KabDriver::impl_getConfigurationSettingsPath() ); - aMessage.appendAscii( "\", true )\n" ); - - aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" ); - aMessage.appendAscii( " configNode.commitChanges\n" ); - aMessage.appendAscii( "End Sub\n" ); - - aDetails.Message = aMessage.makeStringAndClear(); - - aError.NextException <<= aDetails; - - throw aError; -} - - css::uno::Reference KabImplModule::createConnection( KabDriver * driver) const { diff --git a/connectivity/source/drivers/kab/KDriver.hxx b/connectivity/source/drivers/kab/KDriver.hxx index bd53ad6a014b..429b9f8e0242 100644 --- a/connectivity/source/drivers/kab/KDriver.hxx +++ b/connectivity/source/drivers/kab/KDriver.hxx @@ -122,22 +122,6 @@ namespace connectivity */ void impl_unloadModule(); - /** throws an SQLException saying than no KDE installation was found - */ - void impl_throwNoKdeException(); - - /** throws an SQLException saying that the found KDE version is too old - */ - void impl_throwKdeTooOldException(); - - /** throws an SQLException saying that the found KDE version is too new - */ - void impl_throwKdeTooNewException(); - - /** throws a generic SQL exception with SQLState S1000 and error code 0 - */ - void impl_throwGenericSQLException( const OUString& _rMessage ); - /** determines whether it's allowed to run on a too-new (not confirmed to work) version */ bool impl_doAllowNewKDEVersion(); -- cgit