diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-20 16:14:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-21 15:41:50 +0200 |
commit | 2a612907aef4c9987f906c6b98aa9b400f58f617 (patch) | |
tree | 6170f363054cabb1cd33af9208145827b22c83a1 /connectivity/source/drivers/file | |
parent | 3a481dde031ba416ec4ef0351130e26e49417418 (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 'connectivity/source/drivers/file')
-rw-r--r-- | connectivity/source/drivers/file/FStatement.cxx | 110 |
1 files changed, 54 insertions, 56 deletions
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index ec86d0a28603..e275e7d1aa19 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -372,74 +372,72 @@ void OStatement_Base::construct(const OUString& sql) { OUString aErr; m_pParseTree = m_aParser.parseTree(aErr,sql); - if(m_pParseTree) - { - m_aSQLIterator.setParseTree(m_pParseTree); - m_aSQLIterator.traverseAll(); - const OSQLTables& rTabs = m_aSQLIterator.getTables(); + if(!m_pParseTree) + throw SQLException(aErr,*this,OUString(),0,Any()); - // sanity checks - if ( rTabs.empty() ) - // no tables -> nothing to operate on -> error - m_pConnection->throwGenericSQLException(STR_QUERY_NO_TABLE,*this); + m_aSQLIterator.setParseTree(m_pParseTree); + m_aSQLIterator.traverseAll(); + const OSQLTables& rTabs = m_aSQLIterator.getTables(); - if ( rTabs.size() > 1 || m_aSQLIterator.hasErrors() ) - // more than one table -> can't operate on them -> error - m_pConnection->throwGenericSQLException(STR_QUERY_MORE_TABLES,*this); + // sanity checks + if ( rTabs.empty() ) + // no tables -> nothing to operate on -> error + m_pConnection->throwGenericSQLException(STR_QUERY_NO_TABLE,*this); - if ( (m_aSQLIterator.getStatementType() == OSQLStatementType::Select) && m_aSQLIterator.getSelectColumns()->get().empty() ) - // SELECT statement without columns -> error - m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this); + if ( rTabs.size() > 1 || m_aSQLIterator.hasErrors() ) + // more than one table -> can't operate on them -> error + m_pConnection->throwGenericSQLException(STR_QUERY_MORE_TABLES,*this); - switch(m_aSQLIterator.getStatementType()) - { - case OSQLStatementType::CreateTable: - case OSQLStatementType::OdbcCall: - case OSQLStatementType::Unknown: - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - break; - default: - break; - } + if ( (m_aSQLIterator.getStatementType() == OSQLStatementType::Select) && m_aSQLIterator.getSelectColumns()->get().empty() ) + // SELECT statement without columns -> error + m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this); - // at this moment we support only one table per select statement - Reference< css::lang::XUnoTunnel> xTunnel(rTabs.begin()->second,UNO_QUERY); - if(xTunnel.is()) - { - m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId())); - } - OSL_ENSURE(m_pTable.is(),"No table!"); - if ( m_pTable.is() ) - m_xColNames = m_pTable->getColumns(); - Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); - // set the binding of the resultrow - m_aRow = new OValueRefVector(xNames->getCount()); - (m_aRow->get())[0]->setBound(true); - std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetRefBound(false)); + switch(m_aSQLIterator.getStatementType()) + { + case OSQLStatementType::CreateTable: + case OSQLStatementType::OdbcCall: + case OSQLStatementType::Unknown: + m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + break; + default: + break; + } - // set the binding of the resultrow - m_aEvaluateRow = new OValueRefVector(xNames->getCount()); + // at this moment we support only one table per select statement + Reference< css::lang::XUnoTunnel> xTunnel(rTabs.begin()->second,UNO_QUERY); + if(xTunnel.is()) + { + m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId())); + } + OSL_ENSURE(m_pTable.is(),"No table!"); + if ( m_pTable.is() ) + m_xColNames = m_pTable->getColumns(); + Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); + // set the binding of the resultrow + m_aRow = new OValueRefVector(xNames->getCount()); + (m_aRow->get())[0]->setBound(true); + std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetRefBound(false)); - (m_aEvaluateRow->get())[0]->setBound(true); - std::for_each(m_aEvaluateRow->get().begin()+1,m_aEvaluateRow->get().end(),TSetRefBound(false)); + // set the binding of the resultrow + m_aEvaluateRow = new OValueRefVector(xNames->getCount()); - // set the select row - m_aSelectRow = new OValueRefVector(m_aSQLIterator.getSelectColumns()->get().size()); - std::for_each(m_aSelectRow->get().begin(),m_aSelectRow->get().end(),TSetRefBound(true)); + (m_aEvaluateRow->get())[0]->setBound(true); + std::for_each(m_aEvaluateRow->get().begin()+1,m_aEvaluateRow->get().end(),TSetRefBound(false)); - // create the column mapping - createColumnMapping(); + // set the select row + m_aSelectRow = new OValueRefVector(m_aSQLIterator.getSelectColumns()->get().size()); + std::for_each(m_aSelectRow->get().begin(),m_aSelectRow->get().end(),TSetRefBound(true)); - m_pSQLAnalyzer = new OSQLAnalyzer(m_pConnection.get()); + // create the column mapping + createColumnMapping(); - Reference<XIndexesSupplier> xIndexSup(xTunnel,UNO_QUERY); - if(xIndexSup.is()) - m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes()); + m_pSQLAnalyzer = new OSQLAnalyzer(m_pConnection.get()); - anylizeSQL(); - } - else - throw SQLException(aErr,*this,OUString(),0,Any()); + Reference<XIndexesSupplier> xIndexSup(xTunnel,UNO_QUERY); + if(xIndexSup.is()) + m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes()); + + anylizeSQL(); } void OStatement_Base::createColumnMapping() |