summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-20 16:14:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 15:41:50 +0200
commit2a612907aef4c9987f906c6b98aa9b400f58f617 (patch)
tree6170f363054cabb1cd33af9208145827b22c83a1 /dbaccess
parent3a481dde031ba416ec4ef0351130e26e49417418 (diff)
loplugin:flatten in connectivity..desktop
Change-Id: Iff59d3049ba40b4338ef8eec67d08a96b0834d2b Reviewed-on: https://gerrit.libreoffice.org/42578 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/api/RowSet.cxx58
-rw-r--r--dbaccess/source/core/api/SingleSelectQueryComposer.cxx29
-rw-r--r--dbaccess/source/core/api/TableDeco.cxx27
-rw-r--r--dbaccess/source/ui/querydesign/JAccess.cxx25
4 files changed, 60 insertions, 79 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 03aa81dab5f3..063c37318e5a 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -2391,40 +2391,37 @@ bool ORowSet::impl_buildActiveCommand_throw()
case CommandType::QUERY:
{
Reference< XQueriesSupplier > xQueriesAccess(m_xActiveConnection, UNO_QUERY);
- if (xQueriesAccess.is())
+ if (!xQueriesAccess.is())
+ throw SQLException(DBA_RES(RID_STR_NO_XQUERIESSUPPLIER),*this,OUString(),0,Any());
+ Reference< css::container::XNameAccess > xQueries(xQueriesAccess->getQueries());
+ if (xQueries->hasByName(m_aCommand))
{
- Reference< css::container::XNameAccess > xQueries(xQueriesAccess->getQueries());
- if (xQueries->hasByName(m_aCommand))
+ Reference< XPropertySet > xQuery(xQueries->getByName(m_aCommand),UNO_QUERY);
+ OSL_ENSURE(xQuery.is(),"ORowSet::impl_buildActiveCommand_throw: Query is NULL!");
+ if ( xQuery.is() )
{
- Reference< XPropertySet > xQuery(xQueries->getByName(m_aCommand),UNO_QUERY);
- OSL_ENSURE(xQuery.is(),"ORowSet::impl_buildActiveCommand_throw: Query is NULL!");
- if ( xQuery.is() )
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+ xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bDoEscapeProcessing;
+ if ( bDoEscapeProcessing != m_bUseEscapeProcessing )
{
- xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
- xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bDoEscapeProcessing;
- if ( bDoEscapeProcessing != m_bUseEscapeProcessing )
- {
- bool bOldValue = m_bUseEscapeProcessing;
- m_bUseEscapeProcessing = bDoEscapeProcessing;
- fireProperty(PROPERTY_ID_ESCAPE_PROCESSING,bOldValue,bDoEscapeProcessing);
- }
-
- OUString aCatalog,aSchema,aTable;
- xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= aCatalog;
- xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME) >>= aSchema;
- xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable;
- if(!aTable.isEmpty())
- m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, false, ::dbtools::EComposeRule::InDataManipulation );
+ bool bOldValue = m_bUseEscapeProcessing;
+ m_bUseEscapeProcessing = bDoEscapeProcessing;
+ fireProperty(PROPERTY_ID_ESCAPE_PROCESSING,bOldValue,bDoEscapeProcessing);
}
- }
- else
- {
- OUString sMessage( DBA_RES( RID_STR_QUERY_DOES_NOT_EXIST ) );
- throwGenericSQLException(sMessage.replaceAll( "$table$", m_aCommand ),*this);
+
+ OUString aCatalog,aSchema,aTable;
+ xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= aCatalog;
+ xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME) >>= aSchema;
+ xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable;
+ if(!aTable.isEmpty())
+ m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, false, ::dbtools::EComposeRule::InDataManipulation );
}
}
else
- throw SQLException(DBA_RES(RID_STR_NO_XQUERIESSUPPLIER),*this,OUString(),0,Any());
+ {
+ OUString sMessage( DBA_RES( RID_STR_QUERY_DOES_NOT_EXIST ) );
+ throwGenericSQLException(sMessage.replaceAll( "$table$", m_aCommand ),*this);
+ }
}
break;
@@ -2626,14 +2623,11 @@ void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Refer
void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x )
{
- if ( ::dbtools::implSetObject( this, parameterIndex, x ) )
- {
- m_bParametersDirty = true;
- }
- else
+ if ( !::dbtools::implSetObject( this, parameterIndex, x ) )
{ // there is no other setXXX call which can handle the value in x
throw SQLException();
}
+ m_bParametersDirty = true;
}
void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ )
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index f51b8f2b0177..3a5490d07585 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1632,24 +1632,21 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
case DataType::LONGVARBINARY:
{
Sequence<sal_Int8> aSeq;
- if(aValue >>= aSeq)
+ if(!(aValue >>= aSeq))
+ throw SQLException(DBA_RES(RID_STR_NOT_SEQUENCE_INT8),*this,SQLSTATE_GENERAL,1000,Any() );
+ if(nSearchable == ColumnSearch::CHAR)
{
- if(nSearchable == ColumnSearch::CHAR)
- {
- aSQL.append( "\'" );
- }
- aSQL.append( "0x" );
- const sal_Int8* pBegin = aSeq.getConstArray();
- const sal_Int8* pEnd = pBegin + aSeq.getLength();
- for(;pBegin != pEnd;++pBegin)
- {
- aSQL.append( (sal_Int32)*pBegin, 16 );
- }
- if(nSearchable == ColumnSearch::CHAR)
- aSQL.append( "\'" );
+ aSQL.append( "\'" );
}
- else
- throw SQLException(DBA_RES(RID_STR_NOT_SEQUENCE_INT8),*this,SQLSTATE_GENERAL,1000,Any() );
+ aSQL.append( "0x" );
+ const sal_Int8* pBegin = aSeq.getConstArray();
+ const sal_Int8* pEnd = pBegin + aSeq.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ aSQL.append( (sal_Int32)*pBegin, 16 );
+ }
+ if(nSearchable == ColumnSearch::CHAR)
+ aSQL.append( "\'" );
}
break;
case DataType::BIT:
diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx
index dd167c116d3e..a8dd84297af8 100644
--- a/dbaccess/source/core/api/TableDeco.cxx
+++ b/dbaccess/source/core/api/TableDeco.cxx
@@ -387,12 +387,10 @@ void SAL_CALL ODBTableDecorator::rename( const OUString& _rNewName )
::osl::MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
Reference<XRename> xRename(m_xTable,UNO_QUERY);
- if(xRename.is())
- {
- xRename->rename(_rNewName);
- }
- else // not supported
+ if(!xRename.is())
throw SQLException(DBA_RES(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
+ // not supported
+ xRename->rename(_rNewName);
}
// XAlterTable,
@@ -401,12 +399,9 @@ void SAL_CALL ODBTableDecorator::alterColumnByName( const OUString& _rName, cons
::osl::MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
- if(xAlter.is())
- {
- xAlter->alterColumnByName(_rName,_rxDescriptor);
- }
- else
+ if(!xAlter.is())
throw SQLException(DBA_RES(RID_STR_COLUMN_ALTER_BY_NAME),*this,SQLSTATE_GENERAL,1000,Any() );
+ xAlter->alterColumnByName(_rName,_rxDescriptor);
if(m_pColumns)
m_pColumns->refresh();
}
@@ -416,14 +411,12 @@ void SAL_CALL ODBTableDecorator::alterColumnByIndex( sal_Int32 _nIndex, const Re
::osl::MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
- if(xAlter.is())
- {
- xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
- if(m_pColumns)
- m_pColumns->refresh();
- }
- else // not supported
+ if(!xAlter.is())
throw SQLException(DBA_RES(RID_STR_COLUMN_ALTER_BY_INDEX),*this,SQLSTATE_GENERAL,1000,Any() );
+ // not supported
+ xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
+ if(m_pColumns)
+ m_pColumns->refresh();
}
Reference< XNameAccess> ODBTableDecorator::getIndexes()
diff --git a/dbaccess/source/ui/querydesign/JAccess.cxx b/dbaccess/source/ui/querydesign/JAccess.cxx
index d4a63176b8ee..70f152588e85 100644
--- a/dbaccess/source/ui/querydesign/JAccess.cxx
+++ b/dbaccess/source/ui/querydesign/JAccess.cxx
@@ -62,22 +62,19 @@ namespace dbaui
{
Reference< XAccessible > aRet;
::osl::MutexGuard aGuard( m_aMutex );
- if(i >= 0 && i < getAccessibleChildCount() && m_pTableView )
+ if(i < 0 || i >= getAccessibleChildCount() || !m_pTableView)
+ throw IndexOutOfBoundsException();
+ // check if we should return a table window or a connection
+ sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount();
+ if( i < nTableWindowCount )
{
- // check if we should return a table window or a connection
- sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount();
- if( i < nTableWindowCount )
- {
- OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableView->GetTabWinMap().begin();
- for (sal_Int32 j=i; j; ++aIter,--j)
- ;
- aRet = aIter->second->GetAccessible();
- }
- else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections().size() )
- aRet = m_pTableView->getTableConnections()[i - nTableWindowCount]->GetAccessible();
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableView->GetTabWinMap().begin();
+ for (sal_Int32 j=i; j; ++aIter,--j)
+ ;
+ aRet = aIter->second->GetAccessible();
}
- else
- throw IndexOutOfBoundsException();
+ else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections().size() )
+ aRet = m_pTableView->getTableConnections()[i - nTableWindowCount]->GetAccessible();
return aRet;
}
sal_Int16 SAL_CALL OJoinDesignViewAccess::getAccessibleRole( )