From 865eb18f0faa94b260518526d44bbac2b6ca97b9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 15 Dec 2017 09:28:52 +0200 Subject: use ColumnPositions name more consistently mostly so I can track down more accurately what values are being stored in this vector> Change-Id: I3755a098a577facef1c1af62c5583f0e2f7ca90b Reviewed-on: https://gerrit.libreoffice.org/46500 Tested-by: Jenkins Reviewed-by: Noel Grandin --- dbaccess/source/ui/inc/DExport.hxx | 4 ++-- dbaccess/source/ui/inc/WCopyTable.hxx | 4 ++-- dbaccess/source/ui/misc/DExport.cxx | 20 ++++++++++---------- dbaccess/source/ui/misc/WCPage.cxx | 4 ++-- dbaccess/source/ui/misc/WCopyTable.cxx | 20 ++++++++++---------- dbaccess/source/ui/misc/WNameMatch.cxx | 14 +++++++------- dbaccess/source/ui/uno/copytablewizard.cxx | 17 ++++++++--------- 7 files changed, 41 insertions(+), 42 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/inc/DExport.hxx b/dbaccess/source/ui/inc/DExport.hxx index 40a7a15431ef..5cc28b790f0d 100644 --- a/dbaccess/source/ui/inc/DExport.hxx +++ b/dbaccess/source/ui/inc/DExport.hxx @@ -64,7 +64,7 @@ namespace dbaui typedef std::vector< std::pair > TPositions; protected: - TPositions m_vColumns; ///< columns to be used + TPositions m_vColumnPositions; ///< columns to be used std::vector m_vColumnTypes; ///< ColumnTypes for faster access std::vector m_vColumnSize; std::vector m_vNumberFormat; @@ -161,7 +161,7 @@ namespace dbaui static css::uno::Reference< css::sdbc::XPreparedStatement > createPreparedStatment( const css::uno::Reference< css::sdbc::XDatabaseMetaData>& _xMetaData ,const css::uno::Reference< css::beans::XPropertySet>& _xDestTable - ,const TPositions& _rvColumns); + ,const TPositions& _rvColumnPositions); }; } diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx index 0d411c15cd04..db3dfbe38e98 100644 --- a/dbaccess/source/ui/inc/WCopyTable.hxx +++ b/dbaccess/source/ui/inc/WCopyTable.hxx @@ -250,7 +250,7 @@ namespace dbaui std::vector m_aDestTypeInfoIndex; TNameMapping m_mNameMapping; - ODatabaseExport::TPositions m_vColumnPos; + ODatabaseExport::TPositions m_vColumnPositions; std::vector m_vColumnTypes; css::uno::Reference< css::sdbc::XConnection > m_xDestConnection; @@ -332,7 +332,7 @@ namespace dbaui // returns a vector where the position of a column and if the column is in the selection // when not the value is COLUMN_POSITION_NOT_FOUND == (sal_uInt32)-1 - const ODatabaseExport::TPositions& GetColumnPositions() const { return m_vColumnPos; } + const ODatabaseExport::TPositions& GetColumnPositions() const { return m_vColumnPositions; } const std::vector& GetColumnTypes() const { return m_vColumnTypes; } bool UseHeaderLine() const { return m_bUseHeaderLine; } void setUseHeaderLine(bool _bUseHeaderLine) { m_bUseHeaderLine = _bUseHeaderLine; } diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index d83f0f74ff85..81afc5b43bc7 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -89,7 +89,7 @@ ODatabaseExport::ODatabaseExport(sal_Int32 nRows, const OTypeInfoMap* _pInfoMap, bool _bAutoIncrementEnabled, SvStream& _rInputStream) - :m_vColumns(_rColumnPositions) + :m_vColumnPositions(_rColumnPositions) ,m_aDestColumns(true) ,m_xFormatter(_rxNumberF) ,m_xContext(_rxContext) @@ -112,7 +112,7 @@ ODatabaseExport::ODatabaseExport(sal_Int32 nRows, { m_nRows += nRows; sal_Int32 nCount = 0; - for(const std::pair & rPair : m_vColumns) + for(const std::pair & rPair : m_vColumnPositions) if ( rPair.first != COLUMN_POSITION_NOT_FOUND ) ++nCount; @@ -298,11 +298,11 @@ void ODatabaseExport::insertValueIntoColumn() if(pField) { sal_Int32 nNewPos = m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos; - OSL_ENSURE(nNewPos < static_cast(m_vColumns.size()),"m_vColumns: Illegal index for vector"); + OSL_ENSURE(nNewPos < static_cast(m_vColumnPositions.size()),"m_vColumnPositions: Illegal index for vector"); - if ( nNewPos < static_cast(m_vColumns.size() ) ) + if ( nNewPos < static_cast(m_vColumnPositions.size() ) ) { - sal_Int32 nPos = m_vColumns[nNewPos].first; + sal_Int32 nPos = m_vColumnPositions[nNewPos].first; if ( nPos != COLUMN_POSITION_NOT_FOUND ) { if ( m_sTextToken.isEmpty() && pField->IsNullable() ) @@ -672,7 +672,7 @@ void ODatabaseExport::CreateDefaultColumn(const OUString& _rColumnName) bool ODatabaseExport::createRowSet() { - m_pUpdateHelper.reset(new OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumns))); + m_pUpdateHelper.reset(new OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumnPositions))); return m_pUpdateHelper.get() != nullptr; } @@ -713,7 +713,7 @@ bool ODatabaseExport::executeWizard(const OUString& _rTableName, const Any& _aTe m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,_aTextColor); } m_bIsAutoIncrement = aWizard->shouldCreatePrimaryKey(); - m_vColumns = aWizard->GetColumnPositions(); + m_vColumnPositions = aWizard->GetColumnPositions(); m_vColumnTypes = aWizard->GetColumnTypes(); m_bAppendFirstLine = !aWizard->UseHeaderLine(); } @@ -762,10 +762,10 @@ void ODatabaseExport::adjustFormat() if ( !m_sTextToken.isEmpty() ) { sal_Int32 nNewPos = m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos; - OSL_ENSURE(nNewPos < static_cast(m_vColumns.size()),"Illegal index for vector"); - if ( nNewPos < static_cast(m_vColumns.size()) ) + OSL_ENSURE(nNewPos < static_cast(m_vColumnPositions.size()),"Illegal index for vector"); + if ( nNewPos < static_cast(m_vColumnPositions.size()) ) { - sal_Int32 nColPos = m_vColumns[nNewPos].first; + sal_Int32 nColPos = m_vColumnPositions[nNewPos].first; if( nColPos != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND)) { --nColPos; diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 6f164463fda4..715972f0d443 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -267,7 +267,7 @@ bool OCopyTable::checkAppendData() { const ODatabaseExport::TColumnVector& rSrcColumns = m_pParent->getSrcVector(); const sal_uInt32 nSrcSize = rSrcColumns.size(); - m_pParent->m_vColumnPos.resize( nSrcSize, ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) ); + m_pParent->m_vColumnPositions.resize( nSrcSize, ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) ); m_pParent->m_vColumnTypes.resize( nSrcSize , COLUMN_POSITION_NOT_FOUND ); // set new destination @@ -282,7 +282,7 @@ bool OCopyTable::checkAppendData() for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i) { bool bNotConvert = true; - m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos); + m_pParent->m_vColumnPositions[i] = ODatabaseExport::TPositions::value_type(nPos,nPos); TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert); if ( !bNotConvert ) { diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index abc1205d998b..2bc3a85a00d8 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -755,7 +755,7 @@ IMPL_LINK_NOARG(OCopyTableWizard, ImplNextHdl, Button*, void) bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) { bool bRet = true; - m_vColumnPos.clear(); + m_vColumnPositions.clear(); m_vColumnTypes.clear(); OSL_ENSURE( m_xDestConnection.is(), "OCopyTableWizard::CheckColumns: No connection!" ); @@ -781,7 +781,7 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) m_bAddPKFirstTime = false; insertColumn(0,pField); } - m_vColumnPos.emplace_back(1,1); + m_vColumnPositions.emplace_back(1,1); m_vColumnTypes.push_back(pTypeInfo->nType); } } @@ -798,12 +798,12 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) { ODatabaseExport::TColumnVector::const_iterator aFind = std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter); sal_Int32 nPos = (aFind - m_aDestVec.begin())+1; - m_vColumnPos.emplace_back(nPos,nPos); + m_vColumnPositions.emplace_back(nPos,nPos); m_vColumnTypes.push_back((*aFind)->second->GetType()); } else { - m_vColumnPos.emplace_back( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ); + m_vColumnPositions.emplace_back( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ); m_vColumnTypes.push_back(0); } } @@ -827,7 +827,7 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) // now create a column insertColumn(m_vDestColumns.size(),pField); - m_vColumnPos.emplace_back(m_vDestColumns.size(),m_vDestColumns.size()); + m_vColumnPositions.emplace_back(m_vDestColumns.size(),m_vDestColumns.size()); m_vColumnTypes.push_back((*aSrcIter)->second->GetType()); } } @@ -1274,19 +1274,19 @@ Reference< XPropertySet > OCopyTableWizard::createTable() sal_Int32 nPos = (aFind - m_aDestVec.begin())+1; ODatabaseExport::TPositions::iterator aPosFind = std::find_if( - m_vColumnPos.begin(), - m_vColumnPos.end(), + m_vColumnPositions.begin(), + m_vColumnPositions.end(), [nPos] (const ODatabaseExport::TPositions::value_type& tPos) { return tPos.first == nPos; } ); - if ( m_vColumnPos.end() != aPosFind ) + if ( m_vColumnPositions.end() != aPosFind ) { aPosFind->second = nNewPos; - OSL_ENSURE( m_vColumnTypes.size() > size_t( aPosFind - m_vColumnPos.begin() ), + OSL_ENSURE( m_vColumnTypes.size() > size_t( aPosFind - m_vColumnPositions.begin() ), "Invalid index for vector!" ); - m_vColumnTypes[ aPosFind - m_vColumnPos.begin() ] = (*aFind)->second->GetType(); + m_vColumnTypes[ aPosFind - m_vColumnPositions.begin() ] = (*aFind)->second->GetType(); } } } diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index 6099824c165e..efc6671fcd93 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -141,9 +141,9 @@ bool OWizNameMatching::LeavePage() const ODatabaseExport::TColumnVector& rSrcColumns = m_pParent->getSrcVector(); - m_pParent->m_vColumnPos.clear(); + m_pParent->m_vColumnPositions.clear(); m_pParent->m_vColumnTypes.clear(); - m_pParent->m_vColumnPos.resize( rSrcColumns.size(), ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) ); + m_pParent->m_vColumnPositions.resize( rSrcColumns.size(), ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) ); m_pParent->m_vColumnTypes.resize( rSrcColumns.size(), COLUMN_POSITION_NOT_FOUND ); sal_Int32 nParamPos = 0; @@ -171,9 +171,9 @@ bool OWizNameMatching::LeavePage() for(;aDestIter != aDestEnd && (*aDestIter)->second != pDestField;++aDestIter) ; - OSL_ENSURE((nPos) < static_cast(m_pParent->m_vColumnPos.size()),"m_pParent->m_vColumnPos: Illegal index for vector"); - m_pParent->m_vColumnPos[nPos].first = ++nParamPos; - m_pParent->m_vColumnPos[nPos].second = std::distance(rDestColumns.begin(),aDestIter) + 1; + OSL_ENSURE((nPos) < static_cast(m_pParent->m_vColumnPositions.size()),"m_pParent->m_vColumnPositions: Illegal index for vector"); + m_pParent->m_vColumnPositions[nPos].first = ++nParamPos; + m_pParent->m_vColumnPositions[nPos].second = std::distance(rDestColumns.begin(),aDestIter) + 1; TOTypeInfoSP pTypeInfo; @@ -191,8 +191,8 @@ bool OWizNameMatching::LeavePage() } else { - m_pParent->m_vColumnPos[nPos].first = COLUMN_POSITION_NOT_FOUND; - m_pParent->m_vColumnPos[nPos].second = COLUMN_POSITION_NOT_FOUND; + m_pParent->m_vColumnPositions[nPos].first = COLUMN_POSITION_NOT_FOUND; + m_pParent->m_vColumnPositions[nPos].second = COLUMN_POSITION_NOT_FOUND; } pLeftEntry = m_pCTRL_LEFT->GetModel()->Next(pLeftEntry); diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index 43abd33ce95b..636cd7124947 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -1097,7 +1097,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_QUERY_THROW ); const OCopyTableWizard& rWizard = impl_getDialog_throw(); - ODatabaseExport::TPositions aColumnMapping = rWizard.GetColumnPositions(); + ODatabaseExport::TPositions aColumnPositions = rWizard.GetColumnPositions(); bool bAutoIncrement = rWizard.shouldCreatePrimaryKey(); Reference< XRow > xRow ( _rxSourceResultSet, UNO_QUERY_THROW ); @@ -1123,7 +1123,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou } // now create, fill and execute the prepared statement - Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnMapping ), UNO_SET_THROW ); + Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnPositions ), UNO_SET_THROW ); Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW ); const bool bSelectedRecordsOnly = m_aSourceSelection.getLength() != 0; @@ -1166,8 +1166,8 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou } ++nRowCount; - ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin(); - ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnMapping.end(); + ODatabaseExport::TPositions::const_iterator aPosIter = aColumnPositions.begin(); + ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnPositions.end(); aCopyEvent.Error.clear(); try @@ -1433,15 +1433,14 @@ OUString CopyTableWizard::impl_getServerSideCopyStatement_throw(const Reference< OUStringBuffer sColumns; // 1st check if the columns matching const OCopyTableWizard& rWizard = impl_getDialog_throw(); - ODatabaseExport::TPositions aColumnMapping = rWizard.GetColumnPositions(); - ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin(); - for ( sal_Int32 i = 0; aPosIter != aColumnMapping.end() ; ++aPosIter,++i ) + ODatabaseExport::TPositions const & rColumnPositions = rWizard.GetColumnPositions(); + for ( auto const & rColumnPositionPair : rColumnPositions ) { - if ( COLUMN_POSITION_NOT_FOUND != aPosIter->second ) + if ( COLUMN_POSITION_NOT_FOUND != rColumnPositionPair.second ) { if ( !sColumns.isEmpty() ) sColumns.append(","); - sColumns.append(sQuote + aDestColumnNames[aPosIter->second - 1] + sQuote); + sColumns.append(sQuote + aDestColumnNames[rColumnPositionPair.second - 1] + sQuote); } } const OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, _xTable, ::dbtools::EComposeRule::InDataManipulation, true ); -- cgit