diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-25 08:04:03 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-02-25 13:50:25 +0200 |
commit | 761e55d3683845606fcb94cfdf32450051b67a9d (patch) | |
tree | d38edef369f5e16311720258fc764f3450aacdda | |
parent | 4dd65f861d3179538b58512a10c6c9482d85d0ee (diff) |
convert SQLExceptionInfo::TYPE to scoped enum
Change-Id: I2f21a742bc649fc42f89aebac2691c6054cd20d8
-rw-r--r-- | connectivity/source/commontools/dbexception.cxx | 56 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/sqlmessage.cxx | 26 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/TokenWriter.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCPage.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx | 2 | ||||
-rw-r--r-- | include/connectivity/dbexception.hxx | 6 |
7 files changed, 48 insertions, 48 deletions
diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index 48be847eecc2..c46a0d807a5d 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -40,7 +40,7 @@ namespace dbtools using namespace ::connectivity; SQLExceptionInfo::SQLExceptionInfo() - :m_eType(UNDEFINED) + :m_eType(TYPE::Undefined) { } @@ -141,14 +141,14 @@ void SQLExceptionInfo::implDetermineType() const Type& aSQLContextType = ::cppu::UnoType<SQLContext>::get(); if ( isAssignableFrom( aSQLContextType, m_aContent.getValueType() ) ) - m_eType = SQL_CONTEXT; + m_eType = TYPE::SQLContext; else if ( isAssignableFrom( aSQLWarningType, m_aContent.getValueType() ) ) - m_eType = SQL_WARNING; + m_eType = TYPE::SQLWarning; else if ( isAssignableFrom( aSQLExceptionType, m_aContent.getValueType() ) ) - m_eType = SQL_EXCEPTION; + m_eType = TYPE::SQLException; else { - m_eType = UNDEFINED; + m_eType = TYPE::Undefined; m_aContent.clear(); } } @@ -158,14 +158,14 @@ bool SQLExceptionInfo::isKindOf(TYPE _eType) const { switch (_eType) { - case SQL_CONTEXT: - return (m_eType == SQL_CONTEXT); - case SQL_WARNING: - return (m_eType == SQL_CONTEXT) || (m_eType == SQL_WARNING); - case SQL_EXCEPTION: - return (m_eType == SQL_CONTEXT) || (m_eType == SQL_WARNING) || (m_eType == SQL_EXCEPTION); - case UNDEFINED: - return (m_eType == UNDEFINED); + case TYPE::SQLContext: + return (m_eType == TYPE::SQLContext); + case TYPE::SQLWarning: + return (m_eType == TYPE::SQLContext) || (m_eType == TYPE::SQLWarning); + case TYPE::SQLException: + return (m_eType == TYPE::SQLContext) || (m_eType == TYPE::SQLWarning) || (m_eType == TYPE::SQLException); + case TYPE::Undefined: + return (m_eType == TYPE::Undefined); } return false; } @@ -173,14 +173,14 @@ bool SQLExceptionInfo::isKindOf(TYPE _eType) const SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLException*() const { - OSL_ENSURE(isKindOf(SQL_EXCEPTION), "SQLExceptionInfo::operator SQLException* : invalid call !"); + OSL_ENSURE(isKindOf(TYPE::SQLException), "SQLExceptionInfo::operator SQLException* : invalid call !"); return static_cast<const ::com::sun::star::sdbc::SQLException*>(m_aContent.getValue()); } SQLExceptionInfo::operator const ::com::sun::star::sdb::SQLContext*() const { - OSL_ENSURE(isKindOf(SQL_CONTEXT), "SQLExceptionInfo::operator SQLException* : invalid call !"); + OSL_ENSURE(isKindOf(TYPE::SQLContext), "SQLExceptionInfo::operator SQLException* : invalid call !"); return static_cast<const ::com::sun::star::sdb::SQLContext*>(m_aContent.getValue()); } @@ -194,7 +194,7 @@ void SQLExceptionInfo::prepend( const OUString& _rErrorMessage, const OUString& aException.NextException = m_aContent; m_aContent <<= aException; - m_eType = SQL_EXCEPTION; + m_eType = TYPE::SQLException; } @@ -204,9 +204,9 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons Any aAppend; switch ( _eType ) { - case SQL_EXCEPTION: aAppend <<= SQLException(); break; - case SQL_WARNING: aAppend <<= SQLWarning(); break; - case SQL_CONTEXT: aAppend <<= SQLContext(); break; + case TYPE::SQLException: aAppend <<= SQLException(); break; + case TYPE::SQLWarning: aAppend <<= SQLWarning(); break; + case TYPE::SQLContext: aAppend <<= SQLContext(); break; default: OSL_FAIL( "SQLExceptionInfo::append: invalid exception type: this will crash!" ); break; @@ -253,7 +253,7 @@ void SQLExceptionInfo::doThrow() SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const SQLExceptionInfo& _rChainStart ) :m_pCurrent( nullptr ) - ,m_eCurrentType( SQLExceptionInfo::UNDEFINED ) + ,m_eCurrentType( SQLExceptionInfo::TYPE::Undefined ) { if ( _rChainStart.isValid() ) { @@ -265,7 +265,7 @@ SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const SQLExceptionInfo& SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const ::com::sun::star::sdbc::SQLException& _rChainStart ) :m_pCurrent( &_rChainStart ) - ,m_eCurrentType( SQLExceptionInfo::SQL_EXCEPTION ) + ,m_eCurrentType( SQLExceptionInfo::TYPE::SQLException ) { } @@ -274,15 +274,15 @@ void SQLExceptionIteratorHelper::current( SQLExceptionInfo& _out_rInfo ) const { switch ( m_eCurrentType ) { - case SQLExceptionInfo::SQL_EXCEPTION: + case SQLExceptionInfo::TYPE::SQLException: _out_rInfo = *m_pCurrent; break; - case SQLExceptionInfo::SQL_WARNING: + case SQLExceptionInfo::TYPE::SQLWarning: _out_rInfo = *static_cast< const SQLWarning* >( m_pCurrent ); break; - case SQLExceptionInfo::SQL_CONTEXT: + case SQLExceptionInfo::TYPE::SQLContext: _out_rInfo = *static_cast< const SQLContext* >( m_pCurrent ); break; @@ -309,7 +309,7 @@ const ::com::sun::star::sdbc::SQLException* SQLExceptionIteratorHelper::next() { // no SQLException at all in the next chain element m_pCurrent = nullptr; - m_eCurrentType = SQLExceptionInfo::UNDEFINED; + m_eCurrentType = SQLExceptionInfo::TYPE::Undefined; return pReturn; } @@ -319,19 +319,19 @@ const ::com::sun::star::sdbc::SQLException* SQLExceptionIteratorHelper::next() const Type aTypeContext( ::cppu::UnoType< SQLContext >::get() ); if ( isAssignableFrom( aTypeContext, aNextElementType ) ) { - m_eCurrentType = SQLExceptionInfo::SQL_CONTEXT; + m_eCurrentType = SQLExceptionInfo::TYPE::SQLContext; return pReturn; } const Type aTypeWarning( ::cppu::UnoType< SQLWarning >::get() ); if ( isAssignableFrom( aTypeWarning, aNextElementType ) ) { - m_eCurrentType = SQLExceptionInfo::SQL_WARNING; + m_eCurrentType = SQLExceptionInfo::TYPE::SQLWarning; return pReturn; } // a simple SQLException - m_eCurrentType = SQLExceptionInfo::SQL_EXCEPTION; + m_eCurrentType = SQLExceptionInfo::TYPE::SQLException; return pReturn; } diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index ae66546c4521..e4a51b828558 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -1658,7 +1658,7 @@ void ORowSet::impl_ensureStatement_throw() try { OUString sInfo(DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sCommandToExecute ) ); - aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo ); + aError.append( SQLExceptionInfo::TYPE::SQLContext, sInfo ); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index bae6b8dfe07e..db8ba6a7894d 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -114,12 +114,12 @@ namespace switch ( _eType ) { - case SQLExceptionInfo::SQL_WARNING: + case SQLExceptionInfo::TYPE::SQLWarning: ppProvider = &m_pWarningsImage; nNormalImageID = BMP_EXCEPTION_WARNING; break; - case SQLExceptionInfo::SQL_CONTEXT: + case SQLExceptionInfo::TYPE::SQLContext: ppProvider = &m_pInfoImage; nNormalImageID = BMP_EXCEPTION_INFO; break; @@ -140,12 +140,12 @@ namespace switch ( _eType ) { - case SQLExceptionInfo::SQL_WARNING: + case SQLExceptionInfo::TYPE::SQLWarning: ppProvider = &m_pWarningsLabel; nLabelID = STR_EXCEPTION_WARNING; break; - case SQLExceptionInfo::SQL_CONTEXT: + case SQLExceptionInfo::TYPE::SQLContext: ppProvider = &m_pInfoLabel; nLabelID = _bSubLabel ? STR_EXCEPTION_DETAILS : STR_EXCEPTION_INFO; break; @@ -174,7 +174,7 @@ namespace OUString sSQLState; OUString sErrorCode; - ExceptionDisplayInfo() : eType( SQLExceptionInfo::UNDEFINED ), bSubEntry( false ) { } + ExceptionDisplayInfo() : eType( SQLExceptionInfo::TYPE::Undefined ), bSubEntry( false ) { } explicit ExceptionDisplayInfo( SQLExceptionInfo::TYPE _eType ) : eType( _eType ), bSubEntry( false ) { } }; @@ -247,7 +247,7 @@ namespace _out_rChain.push_back( aDisplayInfo ); - if ( aCurrentElement.getType() == SQLExceptionInfo::SQL_CONTEXT ) + if ( aCurrentElement.getType() == SQLExceptionInfo::TYPE::SQLContext ) { const SQLContext* pContext = static_cast<const SQLContext*>(aCurrentElement); if ( !pContext->Details.isEmpty() ) @@ -342,8 +342,8 @@ OExceptionChainDialog::OExceptionChainDialog(vcl::Window* pParent, const Excepti ExceptionDisplayInfo aInfo22018; aInfo22018.sMessage = ModuleRes( STR_EXPLAN_STRINGCONVERSION_ERROR ); - aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::SQL_CONTEXT, false ); - aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::SQL_CONTEXT ); + aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::TYPE::SQLContext, false ); + aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::TYPE::SQLContext ); m_aExceptions.push_back( aInfo22018 ); lcl_insertExceptionEntry( *m_pExceptionList, m_aExceptions.size() - 1, aInfo22018 ); @@ -449,8 +449,8 @@ void OSQLMessageBox::impl_positionControls() // element denotes its sub entry // - the first and the second element are both independent (i.e. the second // is no sub entry), and none of them is a context. - bool bFirstElementIsContext = ( rFirstInfo.eType == SQLExceptionInfo::SQL_CONTEXT ); - bool bSecondElementIsContext = ( pSecondInfo->eType == SQLExceptionInfo::SQL_CONTEXT ); + bool bFirstElementIsContext = ( rFirstInfo.eType == SQLExceptionInfo::TYPE::SQLContext ); + bool bSecondElementIsContext = ( pSecondInfo->eType == SQLExceptionInfo::TYPE::SQLContext ); if ( bFirstElementIsContext && pSecondInfo->bSubEntry ) sSecondary = pSecondInfo->sMessage; @@ -638,9 +638,9 @@ void OSQLMessageBox::Construct( WinBits _nStyle, MessageType _eImage ) { switch ( m_pImpl->aDisplayInfo[0].eType ) { - case SQLExceptionInfo::SQL_EXCEPTION: eType = Error; break; - case SQLExceptionInfo::SQL_WARNING: eType = Warning; break; - case SQLExceptionInfo::SQL_CONTEXT: eType = Info; break; + case SQLExceptionInfo::TYPE::SQLException: eType = Error; break; + case SQLExceptionInfo::TYPE::SQLWarning: eType = Warning; break; + case SQLExceptionInfo::TYPE::SQLContext: eType = Info; break; default: OSL_FAIL( "OSQLMessageBox::Construct: invalid type!" ); } } diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index 1c4b3c596f43..b9780c6dbb68 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -262,7 +262,7 @@ void ODatabaseImportExport::initialize() SQLExceptionInfo aInfo = ::dbaui::createConnection( m_sDataSourceName, xDatabaseContext, m_xContext, xEvt, xConnection ); m_xConnection.reset( xConnection ); - if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::SQL_EXCEPTION) + if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::TYPE::SQLException) throw *static_cast<const SQLException*>(aInfo); } diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index e3fffb1ffb54..f764dcf3486e 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -176,7 +176,7 @@ bool OCopyTable::LeavePage() SQLExceptionInfo aErrorInfo; if ( !aNameCheck.isNameValid( m_pEdTableName->GetText(), aErrorInfo ) ) { - aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ); + aErrorInfo.append( SQLExceptionInfo::TYPE::SQLContext, ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ); m_pParent->showError(aErrorInfo.get()); return false; diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index 70154bbfcf18..03c6e0235467 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -375,7 +375,7 @@ namespace dbaui void DBSubComponentController::appendError( const OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState, const sal_Int32 _nErrorCode ) { - m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLState( _eSQLState ), + m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::TYPE::SQLException, _rErrorMessage, getStandardSQLState( _eSQLState ), _nErrorCode ); } void DBSubComponentController::clearError() diff --git a/include/connectivity/dbexception.hxx b/include/connectivity/dbexception.hxx index 58614d66947c..83caae02e9ef 100644 --- a/include/connectivity/dbexception.hxx +++ b/include/connectivity/dbexception.hxx @@ -61,7 +61,7 @@ enum OOoBaseErrorCode class OOO_DLLPUBLIC_DBTOOLS SQLExceptionInfo { public: - enum TYPE { SQL_EXCEPTION, SQL_WARNING, SQL_CONTEXT, UNDEFINED }; + enum class TYPE { SQLException, SQLWarning, SQLContext, Undefined }; private: css::uno::Any m_aContent; @@ -128,7 +128,7 @@ public: bool isKindOf(TYPE _eType) const; // not just a simple comparisation ! e.g. getType() == SQL_CONTEXT implies isKindOf(SQL_EXCEPTION) == sal_True ! - bool isValid() const { return m_eType != UNDEFINED; } + bool isValid() const { return m_eType != TYPE::Undefined; } TYPE getType() const { return m_eType; } operator const css::sdbc::SQLException* () const; @@ -139,7 +139,7 @@ public: void clear() { m_aContent.clear(); - m_eType = UNDEFINED; + m_eType = TYPE::Undefined; } protected: |