diff options
Diffstat (limited to 'dbaccess/source/ui/misc')
-rw-r--r-- | dbaccess/source/ui/misc/DExport.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/RowSetDrop.cxx | 17 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/TokenWriter.cxx | 30 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCopyTable.cxx | 39 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/dsmeta.cxx | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/indexcollection.cxx | 34 |
6 files changed, 49 insertions, 86 deletions
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index a1e02b8745be..fa618fb11b32 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -803,9 +803,7 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatement( const { return Reference< XPreparedStatement > (); } - const OUString* pIter = aDestColumnNames.getConstArray(); - std::vector< OUString> aInsertList; - aInsertList.resize(aDestColumnNames.getLength()+1); + std::vector<OUString> aInsertList(aDestColumnNames.getLength() + 1); for(size_t j=0; j < aInsertList.size(); ++j) { ODatabaseExport::TPositions::const_iterator aFind = std::find_if(_rvColumns.begin(),_rvColumns.end(), @@ -814,7 +812,7 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatement( const if ( _rvColumns.end() != aFind && aFind->second != COLUMN_POSITION_NOT_FOUND && aFind->first != COLUMN_POSITION_NOT_FOUND ) { OSL_ENSURE((aFind->first) < static_cast<sal_Int32>(aInsertList.size()),"aInsertList: Illegal index for vector"); - aInsertList[aFind->first] = ::dbtools::quoteName( aQuote,*(pIter+j)); + aInsertList[aFind->first] = ::dbtools::quoteName(aQuote, aDestColumnNames[j]); } } diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx index 6fced2dfc16f..a7dd0e817cfc 100644 --- a/dbaccess/source/ui/misc/RowSetDrop.cxx +++ b/dbaccess/source/ui/misc/RowSetDrop.cxx @@ -95,21 +95,21 @@ bool ORowSetImportExport::Write() bool ORowSetImportExport::Read() { + if (!m_xResultSet) + return false; // check if there is any column to copy if(std::none_of(m_aColumnMapping.begin(),m_aColumnMapping.end(), [](sal_Int32 n) { return n > 0; })) return false; - bool bContinue = true; if(m_aSelection.hasElements()) { - const Any* pBegin = m_aSelection.getConstArray(); - const Any* pEnd = pBegin + m_aSelection.getLength(); - for(;pBegin != pEnd && bContinue;++pBegin) + for (auto& any : m_aSelection) { sal_Int32 nPos = -1; - *pBegin >>= nPos; + any >>= nPos; OSL_ENSURE(nPos != -1,"Invalid position!"); - bContinue = (m_xResultSet.is() && m_xResultSet->absolute(nPos) && insertNewRow()); + if (!m_xResultSet->absolute(nPos) || !insertNewRow()) + break; } } else @@ -131,10 +131,11 @@ bool ORowSetImportExport::Read() } OSL_ENSURE(nRowCount,"RowCount is 0!"); m_xResultSet->beforeFirst(); - while(m_xResultSet.is() && m_xResultSet->next() && bContinue && nRowCount ) + while(m_xResultSet.is() && m_xResultSet->next() && nRowCount ) { --nRowCount; - bContinue = insertNewRow(); + if (!insertNewRow()) + break; } } return true; diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index fd2f098db4d0..fb25922e6804 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -382,7 +382,6 @@ bool ORTFImportExport::Write() Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY); Reference<XNameAccess> xColumns = xColSup->getColumns(); Sequence< OUString> aNames(xColumns->getElementNames()); - const OUString* pIter = aNames.getConstArray(); sal_Int32 nCount = aNames.getLength(); bool bUseResultMetaData = false; @@ -413,11 +412,10 @@ bool ORTFImportExport::Write() sColumnName = m_xResultSetMetaData->getColumnName(i); else { - sColumnName = *pIter; + sColumnName = aNames[i]; Reference<XPropertySet> xColumn; xColumns->getByName(sColumnName) >>= xColumn; xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; - ++pIter; } const char* pChar; @@ -458,25 +456,22 @@ bool ORTFImportExport::Write() sal_Int32 kk=0; if ( m_aSelection.hasElements() ) { - const Any* pSelIter = m_aSelection.getConstArray(); - const Any* pEnd = pSelIter + m_aSelection.getLength(); - - bool bContinue = true; - for( ; pSelIter != pEnd && bContinue; ++pSelIter ) + for (auto& any : m_aSelection) { if ( m_bBookmarkSelection ) { - bContinue = m_xRowLocate->moveToBookmark( *pSelIter ); + if (!m_xRowLocate->moveToBookmark(any)) + break; } else { sal_Int32 nPos = -1; - OSL_VERIFY( *pSelIter >>= nPos ); - bContinue = ( m_xResultSet->absolute( nPos ) ); + OSL_VERIFY(any >>= nPos); + if (!m_xResultSet->absolute(nPos)) + break; } - if ( bContinue ) - appendRow( pHorzChar.get(), nCount, k, kk ); + appendRow(pHorzChar.get(), nCount, k, kk); } } else @@ -755,10 +750,7 @@ void OHTMLImportExport::WriteTables() m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight; // 1. writing the column description - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); - - for( sal_Int32 i=0;pIter != pEnd; ++pIter,++i ) + for (sal_Int32 i = 0; i < aNames.getLength(); ++i) { sal_Int32 nAlign = 0; pFormat[i] = 0; @@ -766,7 +758,7 @@ void OHTMLImportExport::WriteTables() if ( !bUseResultMetaData ) { Reference<XPropertySet> xColumn; - xColumns->getByName(*pIter) >>= xColumn; + xColumns->getByName(aNames[i]) >>= xColumn; xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY)); pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH)); @@ -782,7 +774,7 @@ void OHTMLImportExport::WriteTables() if(i == aNames.getLength()-1) IncIndent(-1); - WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pIter,OOO_STRING_SVTOOLS_HTML_tableheader); + WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],aNames[i],OOO_STRING_SVTOOLS_HTML_tableheader); } IncIndent(-1); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index a2737543c705..756f60f857a1 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -220,19 +220,14 @@ OUString ObjectCopySource::getSelectStatement() const const OUString sQuote = m_xMetaData->getIdentifierQuoteString(); Sequence< OUString > aColumnNames = getColumnNames(); - const OUString* pColumnName = aColumnNames.getConstArray(); - const OUString* pEnd = pColumnName + aColumnNames.getLength(); - for ( ; pColumnName != pEnd; ) + for (sal_Int32 i = 0; i < aColumnNames.getLength(); ++i) { - aSQL.append( ::dbtools::quoteName( sQuote, *pColumnName++ ) ); - - if ( pColumnName == pEnd ) - aSQL.append( " " ); - else - aSQL.append( ", " ); + if (i > 0) + aSQL.append(", "); + aSQL.append(::dbtools::quoteName(sQuote, aColumnNames[i])); } - aSQL.append( "FROM " + ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) ); + aSQL.append( " FROM " + ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) ); sSelectStatement = aSQL.makeStringAndClear(); } @@ -997,14 +992,10 @@ void OCopyTableWizard::loadData( const ICopyTableSourceObject& _rSourceObject, // On drop no line must be editable. // On add only empty lines must be editable. // On Add and Drop all lines can be edited. - Sequence< OUString > aColumns( _rSourceObject.getColumnNames() ); - const OUString* pColumn = aColumns.getConstArray(); - const OUString* pColumnEnd = pColumn + aColumns.getLength(); - - for ( ; pColumn != pColumnEnd; ++pColumn ) + for (auto& column : _rSourceObject.getColumnNames()) { // get the properties of the column - pActFieldDescr = _rSourceObject.createFieldDescription( *pColumn ); + pActFieldDescr = _rSourceObject.createFieldDescription(column); OSL_ENSURE( pActFieldDescr, "OCopyTableWizard::loadData: illegal field description!" ); if ( !pActFieldDescr ) continue; @@ -1026,13 +1017,9 @@ void OCopyTableWizard::loadData( const ICopyTableSourceObject& _rSourceObject, } // determine which columns belong to the primary key - Sequence< OUString > aPrimaryKeyColumns( _rSourceObject.getPrimaryKeyColumnNames() ); - const OUString* pKeyColName = aPrimaryKeyColumns.getConstArray(); - const OUString* pKeyColEnd = pKeyColName + aPrimaryKeyColumns.getLength(); - - for( ; pKeyColName != pKeyColEnd; ++pKeyColName ) + for (auto& keyColName : _rSourceObject.getPrimaryKeyColumnNames()) { - ODatabaseExport::TColumns::const_iterator keyPos = _rColumns.find( *pKeyColName ); + ODatabaseExport::TColumns::const_iterator keyPos = _rColumns.find(keyColName); if ( keyPos != _rColumns.end() ) { keyPos->second->SetPrimaryKey( true ); @@ -1248,12 +1235,10 @@ Reference< XPropertySet > OCopyTableWizard::createTable() // set column mappings Reference<XNameAccess> xNameAccess = xSuppDestinationColumns->getColumns(); Sequence< OUString> aSeq = xNameAccess->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(sal_Int32 nNewPos=1;pIter != pEnd;++pIter,++nNewPos) + for (sal_Int32 i = 0; i < aSeq.getLength(); ++i) { - ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(*pIter); + ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(aSeq[i]); if ( aDestIter != m_vDestColumns.end() ) { @@ -1270,7 +1255,7 @@ Reference< XPropertySet > OCopyTableWizard::createTable() if ( m_vColumnPositions.end() != aPosFind ) { - aPosFind->second = nNewPos; + aPosFind->second = i + 1; OSL_ENSURE( m_vColumnTypes.size() > o3tl::make_unsigned( aPosFind - m_vColumnPositions.begin() ), "Invalid index for vector!" ); m_vColumnTypes[ aPosFind - m_vColumnPositions.begin() ] = (*aFind)->second->GetType(); diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx index 3673d4d3d9bb..f098a95900c9 100644 --- a/dbaccess/source/ui/misc/dsmeta.cxx +++ b/dbaccess/source/ui/misc/dsmeta.cxx @@ -115,13 +115,10 @@ namespace dbaui { std::map< OUString, FeatureSupport > tmp; ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessComponentContext()); - const uno::Sequence< OUString > aURLs = aDriverConfig.getURLs(); - const OUString* pIter = aURLs.getConstArray(); - const OUString* pEnd = pIter + aURLs.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& url : aDriverConfig.getURLs()) { FeatureSupport aInit( AuthNone ); - const ::comphelper::NamedValueCollection& aMetaData = aDriverConfig.getMetaData(*pIter); + const ::comphelper::NamedValueCollection& aMetaData = aDriverConfig.getMetaData(url); if ( aMetaData.has("Authentication") ) { OUString sAuth; @@ -131,7 +128,7 @@ namespace dbaui else if ( sAuth == "Password" ) aInit = FeatureSupport(AuthPwd); } - tmp.insert(std::make_pair(*pIter,aInit)); + tmp.insert(std::make_pair(url, aInit)); } return tmp; }(); diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx index 169512ce723b..dd275b80fda4 100644 --- a/dbaccess/source/ui/misc/indexcollection.cxx +++ b/dbaccess/source/ui/misc/indexcollection.cxx @@ -233,32 +233,25 @@ namespace dbaui return; Sequence< OUString > aFieldNames = xCols->getElementNames(); - _rIndex.aFields.resize(aFieldNames.getLength()); + _rIndex.aFields.clear(); + _rIndex.aFields.reserve(aFieldNames.getLength()); - const OUString* pFieldNames = aFieldNames.getConstArray(); - const OUString* pFieldNamesEnd = pFieldNames + aFieldNames.getLength(); - IndexFields::iterator aCopyTo = _rIndex.aFields.begin(); - - Reference< XPropertySet > xIndexColumn; - for (;pFieldNames < pFieldNamesEnd; ++pFieldNames, ++aCopyTo) + for (auto& fieldName : aFieldNames) { // extract the column - xIndexColumn.clear(); - xCols->getByName(*pFieldNames) >>= xIndexColumn; + Reference<XPropertySet> xIndexColumn; + xCols->getByName(fieldName) >>= xIndexColumn; if (!xIndexColumn.is()) { OSL_FAIL("OIndexCollection::implFillIndexInfo: invalid index column!"); - --aCopyTo; continue; } // get the relevant properties - aCopyTo->sFieldName = *pFieldNames; - aCopyTo->bSortAscending = ::cppu::any2bool(xIndexColumn->getPropertyValue("IsAscending")); + _rIndex.aFields.push_back({ .sFieldName = fieldName, + .bSortAscending = cppu::any2bool( + xIndexColumn->getPropertyValue("IsAscending")) }); } - - _rIndex.aFields.resize(aCopyTo - _rIndex.aFields.begin()); - // (just in case some fields were invalid ...) } void OIndexCollection::resetIndex(const Indexes::iterator& _rPos) @@ -302,14 +295,11 @@ namespace dbaui return; // loop through all the indexes - Sequence< OUString > aNames = m_xIndexes->getElementNames(); - const OUString* pNames = aNames.getConstArray(); - const OUString* pEnd = pNames + aNames.getLength(); - for (; pNames < pEnd; ++pNames) + for (auto& name : m_xIndexes->getElementNames()) { // extract the index object Reference< XPropertySet > xIndex; - m_xIndexes->getByName(*pNames) >>= xIndex; + m_xIndexes->getByName(name) >>= xIndex; if (!xIndex.is()) { OSL_FAIL("OIndexCollection::implConstructFrom: got an invalid index object ... ignoring!"); @@ -317,8 +307,8 @@ namespace dbaui } // fill the OIndex structure - OIndex aCurrentIndex(*pNames); - implFillIndexInfo(aCurrentIndex); + OIndex aCurrentIndex(name); + implFillIndexInfo(aCurrentIndex, xIndex); m_aIndexes.push_back(aCurrentIndex); } } |