diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-29 01:31:19 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-29 23:15:48 +0200 |
commit | af5a1b5925dbc816dced8813282d953fd5adbaaa (patch) | |
tree | 44dc7a7f158828d2a17078c6d881fbfb8786f04d /dbaccess | |
parent | 00e2762c664614a1b33f54dfc990ba29f0f81a07 (diff) |
Drop uses of css::uno::Sequence::getConstArray in dbaccess
where it was obsoleted by commits 2484de6728bd11bb7949003d112f1ece2223c7a1
(Remove non-const Sequence::begin()/end() in internal code, 2021-10-15) and
fb3c04bd1930eedacd406874e1a285d62bbf27d9 (Drop non-const Sequence::operator[]
in internal code 2021-11-05).
Change-Id: I4f8dc4f430dc49fa29012b8f064094daceb5e1b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166818
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'dbaccess')
54 files changed, 476 insertions, 798 deletions
diff --git a/dbaccess/source/core/api/FilteredContainer.cxx b/dbaccess/source/core/api/FilteredContainer.cxx index 955a7f1c222f..0314c36b8696 100644 --- a/dbaccess/source/core/api/FilteredContainer.cxx +++ b/dbaccess/source/core/api/FilteredContainer.cxx @@ -71,15 +71,11 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: return nShiftPos; } - static bool lcl_isElementAllowed( const OUString& _rName, + static bool lcl_isElementAllowed(std::u16string_view _rName, const Sequence< OUString >& _rTableFilter, const std::vector< WildCard >& _rWCSearch ) { - sal_Int32 nTableFilterLen = _rTableFilter.getLength(); - - const OUString* tableFilter = _rTableFilter.getConstArray(); - const OUString* tableFilterEnd = _rTableFilter.getConstArray() + nTableFilterLen; - bool bFilterMatch = std::find( tableFilter, tableFilterEnd, _rName ) != tableFilterEnd; + bool bFilterMatch = std::find(_rTableFilter.begin(), _rTableFilter.end(), _rName) != _rTableFilter.end(); // the table is allowed to "pass" if we had no filters at all or any of the non-wildcard filters matches if (!bFilterMatch && !_rWCSearch.empty()) { // or if one of the wildcard expression matches @@ -207,15 +203,12 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: TableInfos aUnfilteredTables; aUnfilteredTables.swap( aFilteredTables ); - const OUString* pTableTypeFilterBegin = _tableTypeFilter.getConstArray(); - const OUString* pTableTypeFilterEnd = pTableTypeFilterBegin + _tableTypeFilter.getLength(); - for (auto & unfilteredTable : aUnfilteredTables) { // ensure that we know the table type lcl_ensureType( unfilteredTable, _metaData, _masterContainer ); - if ( std::find( pTableTypeFilterBegin, pTableTypeFilterEnd, *unfilteredTable.sType ) != pTableTypeFilterEnd ) + if (std::find(_tableTypeFilter.begin(), _tableTypeFilter.end(), *unfilteredTable.sType) != _tableTypeFilter.end()) aFilteredTables.push_back(unfilteredTable); } } @@ -267,11 +260,10 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: TableInfos aUnfilteredTables; - Sequence< OUString > aNames = m_xMasterContainer->getElementNames(); - const OUString* name = aNames.getConstArray(); - const OUString* nameEnd = name + aNames.getLength(); - for ( ; name != nameEnd; ++name ) - aUnfilteredTables.emplace_back( *name ); + Sequence<OUString> aNames = m_xMasterContainer->getElementNames(); + aUnfilteredTables.reserve(aNames.getLength()); + for (auto& name : aNames) + aUnfilteredTables.emplace_back(name); reFill( lcl_filter( std::move(aUnfilteredTables), _rTableFilter, _rTableTypeFilter, m_xMetaData, m_xMasterContainer ) ); @@ -308,14 +300,9 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: { if ( _rTableTypeFilter.hasElements() ) { - const OUString* tableType = _rTableTypeFilter.getConstArray(); - const OUString* tableTypeEnd = tableType + _rTableTypeFilter.getLength(); - for ( ; tableType != tableTypeEnd; ++tableType ) - { - if ( *tableType == sInherentTableTypeRestriction ) - break; - } - if ( tableType == tableTypeEnd ) + if (std::find(_rTableTypeFilter.begin(), _rTableTypeFilter.end(), + sInherentTableTypeRestriction) + == _rTableTypeFilter.end()) { // the only table type which can be part of this container is not allowed // by the externally provided table type filter. m_bConstructed = true; diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 4ef85e0ce1af..e54c5fb39210 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -293,13 +293,11 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet, const OUStrin const Sequence< OUString> aSeq = xSelectTables->getElementNames(); if ( aSeq.getLength() > 1 ) // special handling for join { - const OUString* pIter = aSeq.getConstArray(); - const OUString* const pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : aSeq) { - if ( *pIter != m_sUpdateTableName ) + if (name != m_sUpdateTableName) { - connectivity::OSQLTable xSelColSup(xSelectTables->getByName(*pIter),uno::UNO_QUERY); + connectivity::OSQLTable xSelColSup(xSelectTables->getByName(name), uno::UNO_QUERY); Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY); OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::EComposeRule::InDataManipulation, false ); @@ -375,19 +373,14 @@ void OKeySet::executeStatement(OUStringBuffer& io_aFilter, Reference<XSingleSele io_xAnalyzer->setFilter(io_aFilter.makeStringAndClear()); if ( bFilterSet ) { - Sequence< Sequence< PropertyValue > > aFilter2 = io_xAnalyzer->getStructuredFilter(); - const Sequence< PropertyValue >* pOr = aFilter2.getConstArray(); - const Sequence< PropertyValue >* pOrEnd = pOr + aFilter2.getLength(); - for(;pOr != pOrEnd;++pOr) + for (auto& rOr : io_xAnalyzer->getStructuredFilter()) { - const PropertyValue* pAnd = pOr->getConstArray(); - const PropertyValue* pAndEnd = pAnd + pOr->getLength(); - for(;pAnd != pAndEnd;++pAnd) + for (auto& rAnd : rOr) { OUString sValue; - if ( !(pAnd->Value >>= sValue) || !( sValue == "?" || sValue.startsWith( ":" ) ) ) + if (!(rAnd.Value >>= sValue) || !(sValue == "?" || sValue.startsWith(":"))) { // we have a criteria which has to be taken into account for updates - m_aFilterColumns.push_back(pAnd->Name); + m_aFilterColumns.push_back(rAnd.Name); } } } @@ -1386,27 +1379,22 @@ void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, bool i_bAppendTableName) { // get the real name of the columns - Sequence< OUString> aSelNames(_rxQueryColumns->getElementNames()); - const OUString* pSelIter = aSelNames.getConstArray(); - const OUString* pSelEnd = pSelIter + aSelNames.getLength(); - - const OUString* pTblColumnIter = _aColumnNames.getConstArray(); - const OUString* pTblColumnEnd = pTblColumnIter + _aColumnNames.getLength(); - ::comphelper::UStringMixEqual bCase(o_rColumnNames.key_comp().isCaseSensitive()); - for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos) + sal_Int32 nPos = 0; + for (auto& queryColumnName : _rxQueryColumns->getElementNames()) { - Reference<XPropertySet> xQueryColumnProp(_rxQueryColumns->getByName(*pSelIter),UNO_QUERY_THROW); + ++nPos; + Reference<XPropertySet> xQueryColumnProp(_rxQueryColumns->getByName(queryColumnName),UNO_QUERY_THROW); OUString sRealName,sTableName; OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!"); OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!"); xQueryColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; xQueryColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; - for(;pTblColumnIter != pTblColumnEnd;++pTblColumnIter) + for (auto& tableColumnName : _aColumnNames) { - if(bCase(sRealName,*pTblColumnIter) && bCase(_rsUpdateTableName,sTableName) && o_rColumnNames.find(*pTblColumnIter) == o_rColumnNames.end()) + if(bCase(sRealName,tableColumnName) && bCase(_rsUpdateTableName,sTableName) && o_rColumnNames.find(tableColumnName) == o_rColumnNames.end()) { sal_Int32 nType = 0; xQueryColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType; @@ -1436,7 +1424,6 @@ void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, break; } } - pTblColumnIter = _aColumnNames.getConstArray(); } } } diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index df09d7b77588..946ec3f67a95 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -96,13 +96,10 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const OU const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns(); const Reference<XTablesSupplier> xTabSup(m_xComposer,UNO_QUERY); const Reference<XNameAccess> xTables = xTabSup->getTables(); - const Sequence< OUString> aTableNames = xTables->getElementNames(); - const OUString* pTableNameIter = aTableNames.getConstArray(); - const OUString* pTableNameEnd = pTableNameIter + aTableNames.getLength(); - for( ; pTableNameIter != pTableNameEnd ; ++pTableNameIter) + for (auto& tableName : xTables->getElementNames()) { std::unique_ptr<SelectColumnsMetaData> pKeyColumNames(new SelectColumnsMetaData(bCase)); - findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),*pTableNameIter,xMeta,xQueryColumns,pKeyColumNames); + findTableColumnsMatching_throw(xTables->getByName(tableName),tableName,xMeta,xQueryColumns,pKeyColumNames); m_pKeyColumnNames->insert(pKeyColumNames->begin(),pKeyColumNames->end()); } diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index d9904071d64b..547edec23b6f 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -1927,7 +1927,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi Sequence< OUString> aSeq = m_xColumns->getElementNames(); if( i <= aSeq.getLength()) { - m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn; + m_xColumns->getByName(aSeq[i-1]) >>= xColumn; } } } @@ -2085,25 +2085,23 @@ Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows notifyAllListenersRowBeforeChange(aGuard,aEvt); Sequence< sal_Int32 > aResults( rows.getLength() ); - const Any* row = rows.getConstArray(); - const Any* rowEnd = rows.getConstArray() + rows.getLength(); sal_Int32* result = aResults.getArray(); - for ( ; row != rowEnd; ++row, ++result ) + for (sal_Int32 i = 0; i < rows.getLength(); ++i) { - *result = 0; - if ( !m_pCache->moveToBookmark( *row ) ) + result[i] = 0; + if (!m_pCache->moveToBookmark(rows[i])) continue; sal_Int32 nDeletePosition = m_pCache->getRow(); // first notify the clones so that they can save their position - notifyRowSetAndClonesRowDelete( *row ); + notifyRowSetAndClonesRowDelete(rows[i]); // now delete the row if ( !m_pCache->deleteRow() ) continue; - *result = 1; + result[i] = 1; // now notify that we have deleted - notifyRowSetAndClonesRowDeleted( *row, nDeletePosition ); + notifyRowSetAndClonesRowDeleted(rows[i], nDeletePosition); } aEvt.Rows = aResults.getLength(); @@ -2752,13 +2750,13 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS if ( rParent.m_pColumns ) { Sequence< OUString> aSeq = rParent.m_pColumns->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); aColumns->reserve(aSeq.getLength()+1); - for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i) + sal_Int32 i = 0; + for (auto& columnName : aSeq) { + ++i; Reference<XPropertySet> xColumn; - rParent.m_pColumns->getByName(*pIter) >>= xColumn; + rParent.m_pColumns->getByName(columnName) >>= xColumn; if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); @@ -2774,8 +2772,8 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS return this->getValue(column); }); aColumns->emplace_back(pColumn); - pColumn->setName(*pIter); - aNames.push_back(*pIter); + pColumn->setName(columnName); + aNames.push_back(columnName); m_aDataColumns.push_back(pColumn.get()); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN)); diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index a41d9e991964..3ff599c6fa49 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -279,18 +279,15 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, m_nPrivileges = Privilege::SELECT; bool bNoInsert = false; - Sequence< OUString> aNames(xColumns->getElementNames()); - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& columnName : xColumns->getElementNames()) { - Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xColumn(xColumns->getByName(columnName), UNO_QUERY); OSL_ENSURE(xColumn.is(),"Column in table is null!"); if(xColumn.is()) { sal_Int32 nNullable = 0; xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable; - if(nNullable == ColumnValue::NO_NULLS && aColumnNames.find(*pIter) == aColumnNames.end()) + if(nNullable == ColumnValue::NO_NULLS && aColumnNames.find(columnName) == aColumnNames.end()) { // we found a column where null is not allowed so we can't insert new values bNoInsert = true; break; // one column is enough diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index f6dffbd1314a..f881220f69a2 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1364,8 +1364,8 @@ OUString OSingleSelectQueryComposer::getTableAlias(const Reference< XPropertySet column->getPropertyValue(PROPERTY_NAME) >>= aColumnName; Sequence< OUString> aNames(m_pTables->getElementNames()); - const OUString* pBegin = aNames.getConstArray(); - const OUString* const pEnd = pBegin + aNames.getLength(); + const OUString* pBegin = aNames.begin(); + const OUString* const pEnd = aNames.end(); if(aTable.isEmpty()) { // we haven't found a table name, now we must search every table for this column @@ -1564,21 +1564,22 @@ namespace std::u16string_view rQuoteString) { OUStringBuffer sRet; - const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); - const Sequence< PropertyValue >* pOrEnd = pOrIter + filter.getLength(); - while ( pOrIter != pOrEnd ) + for (auto& rOr : filter) { - if ( pOrIter->hasElements() ) + if (rOr.hasElements()) { + if (!sRet.isEmpty()) + sRet.append(STR_OR); sRet.append(L_BRACKET); - const PropertyValue* pAndIter = pOrIter->getConstArray(); - const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength(); - while ( pAndIter != pAndEnd ) + OUStringBuffer sAnd; + for (auto& rAnd : rOr) { - sRet.append(pAndIter->Name); + if (!sAnd.isEmpty()) + sAnd.append(STR_AND); + sAnd.append(rAnd.Name); OUString sValue; - pAndIter->Value >>= sValue; - const OUString sColumnName = lcl_getDecomposedColumnName( pAndIter->Name, rQuoteString ); + rAnd.Value >>= sValue; + const OUString sColumnName = lcl_getDecomposedColumnName( rAnd.Name, rQuoteString ); if ( i_xSelectColumns.is() && i_xSelectColumns->hasByName(sColumnName) ) { Reference<XPropertySet> xColumn(i_xSelectColumns->getByName(sColumnName),UNO_QUERY); @@ -1586,18 +1587,12 @@ namespace } else { - sValue = i_aPredicateInputController.getPredicateValueStr(pAndIter->Name,sValue); + sValue = i_aPredicateInputController.getPredicateValueStr(rAnd.Name,sValue); } - lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet); - ++pAndIter; - if ( pAndIter != pAndEnd ) - sRet.append(STR_AND); + lcl_addFilterCriteria_throw(rAnd.Handle, sValue, sAnd); } - sRet.append(R_BRACKET); + sRet.append(OUString::unacquired(sAnd) + R_BRACKET); } - ++pOrIter; - if ( pOrIter != pOrEnd && !sRet.isEmpty() ) - sRet.append(STR_OR); } return sRet.makeStringAndClear(); } @@ -1726,12 +1721,8 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert aSQL.append( "\'" ); } aSQL.append( "0x" ); - const sal_Int8* pBegin = aSeq.getConstArray(); - const sal_Int8* pEnd = pBegin + aSeq.getLength(); - for(;pBegin != pEnd;++pBegin) - { - aSQL.append( static_cast<sal_Int32>(*pBegin), 16 ); - } + for (sal_Int32 byte : aSeq) + aSQL.append(byte, 16); if(nSearchable == ColumnSearch::CHAR) aSQL.append( "\'" ); } diff --git a/dbaccess/source/core/api/View.cxx b/dbaccess/source/core/api/View.cxx index ce813b29ee82..2e2ecda0f775 100644 --- a/dbaccess/source/core/api/View.cxx +++ b/dbaccess/source/core/api/View.cxx @@ -85,13 +85,9 @@ namespace dbaccess std::vector<Type> aOwnTypes; aOwnTypes.reserve(aTypes.getLength()); - const Type* pIter = aTypes.getConstArray(); - const Type* pEnd = pIter + aTypes.getLength(); - for(;pIter != pEnd ;++pIter) - { - if( *pIter != aAlterType || m_xViewAccess.is() ) - aOwnTypes.push_back(*pIter); - } + for (auto& type : aTypes) + if (m_xViewAccess || type != aAlterType) + aOwnTypes.push_back(type); return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size()); } diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx index ad205c3248fa..127620b1d650 100644 --- a/dbaccess/source/core/api/column.cxx +++ b/dbaccess/source/core/api/column.cxx @@ -280,21 +280,18 @@ Sequence< Type > SAL_CALL OColumns::getTypes( ) { bool bAppendFound = false,bDropFound = false; - sal_Int32 nSize = 0; + sal_Int32 nSize; Type aAppendType = cppu::UnoType<XAppend>::get(); Type aDropType = cppu::UnoType<XDrop>::get(); if(m_xDrvColumns.is()) { Reference<XTypeProvider> xTypes(m_xDrvColumns,UNO_QUERY); - Sequence< Type > aTypes(xTypes->getTypes()); - const Type* pBegin = aTypes.getConstArray(); - const Type* pEnd = pBegin + aTypes.getLength(); - for (;pBegin != pEnd ; ++pBegin) + for (auto& type : xTypes->getTypes()) { - if(aAppendType == *pBegin) + if (aAppendType == type) bAppendFound = true; - else if(aDropType == *pBegin) + else if (aDropType == type) bDropFound = true; } nSize = (bDropFound ? (bAppendFound ? 0 : 1) : (bAppendFound ? 1 : 2)); @@ -312,17 +309,17 @@ Sequence< Type > SAL_CALL OColumns::getTypes( ) } Sequence< Type > aTypes(::comphelper::concatSequences(OColumns_BASE::getTypes(),TXChild::getTypes())); Sequence< Type > aRet(aTypes.getLength() - nSize); + auto* pRet = aRet.getArray(); - const Type* pBegin = aTypes.getConstArray(); - const Type* pEnd = pBegin + aTypes.getLength(); - for(sal_Int32 i=0;pBegin != pEnd ;++pBegin) + sal_Int32 i = 0; + for (auto& type : aTypes) { - if(*pBegin != aAppendType && *pBegin != aDropType) - aRet.getArray()[i++] = *pBegin; - else if(bDropFound && *pBegin == aDropType) - aRet.getArray()[i++] = *pBegin; - else if(bAppendFound && *pBegin == aAppendType) - aRet.getArray()[i++] = *pBegin; + if (type != aAppendType && type != aDropType) + pRet[i++] = type; + else if (bDropFound && type == aDropType) + pRet[i++] = type; + else if (bAppendFound && type == aAppendType) + pRet[i++] = type; } return aRet; } diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx index 8e386dc411cd..c308bf9d6f9d 100644 --- a/dbaccess/source/core/api/querycontainer.cxx +++ b/dbaccess/source/core/api/querycontainer.cxx @@ -78,13 +78,10 @@ void OQueryContainer::init() // fill my structures ODefinitionContainer_Impl& rDefinitions( getDefinitions() ); - Sequence< OUString > sDefinitionNames = m_xCommandDefinitions->getElementNames(); - const OUString* pDefinitionName = sDefinitionNames.getConstArray(); - const OUString* pEnd = pDefinitionName + sDefinitionNames.getLength(); - for ( ; pDefinitionName != pEnd; ++pDefinitionName ) + for (auto& definitionName : m_xCommandDefinitions->getElementNames()) { - rDefinitions.insert( *pDefinitionName, TContentPtr() ); - m_aDocuments.push_back(m_aDocumentMap.emplace( *pDefinitionName,Documents::mapped_type()).first); + rDefinitions.insert(definitionName, TContentPtr()); + m_aDocuments.push_back(m_aDocumentMap.emplace(definitionName, Documents::mapped_type()).first); } setElementApproval( std::make_shared<ObjectNameApproval>( m_xConnection, ObjectNameApproval::TypeQuery ) ); diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx index bb2a6f832dea..8bc4aececf1b 100644 --- a/dbaccess/source/core/api/table.cxx +++ b/dbaccess/source/core/api/table.cxx @@ -268,12 +268,10 @@ Sequence< Type > SAL_CALL ODBTable::getTypes( ) std::vector<Type> aOwnTypes; aOwnTypes.reserve(aTypes.getLength()); - const Type* pIter = aTypes.getConstArray(); - const Type* pEnd = pIter + aTypes.getLength(); - for(;pIter != pEnd ;++pIter) + for (auto& type : aTypes) { - if( (*pIter != aRenameType || getRenameService().is()) && (*pIter != aAlterType || getAlterService().is())) - aOwnTypes.push_back(*pIter); + if( (type != aRenameType || getRenameService().is()) && (type != aAlterType || getAlterService().is())) + aOwnTypes.push_back(type); } return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size()); diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx index 1a7e2a261609..2ec9ce796166 100644 --- a/dbaccess/source/core/api/tablecontainer.cxx +++ b/dbaccess/source/core/api/tablecontainer.cxx @@ -63,22 +63,20 @@ namespace Reference<XPropertyState> xState(_xProp,UNO_QUERY); if ( !xState ) return false; - const OUString* pIter = _aNames.getConstArray(); - const OUString* pEnd = pIter + _aNames.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : _aNames) { try { - PropertyState aState = xState->getPropertyState(*pIter); + PropertyState aState = xState->getPropertyState(name); if ( aState != PropertyState_DEFAULT_VALUE ) - break; + return false; } catch(const Exception&) { TOOLS_WARN_EXCEPTION("dbaccess", "" ); } } - return ( pIter == pEnd ); + return true; } } @@ -312,14 +310,11 @@ ObjectType OTableContainer::appendObject( const OUString& _rForName, const Refer if ( xNames.is() ) { Reference<XPropertySet> xProp = xFac->createDataDescriptor(); - Sequence< OUString> aSeq = xNames->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : xNames->getElementNames()) { - if ( !xColumnDefinitions->hasByName(*pIter) ) + if (!xColumnDefinitions->hasByName(name)) { - Reference<XPropertySet> xColumn(xNames->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xColumn(xNames->getByName(name), UNO_QUERY); if ( !OColumnSettings::hasDefaultSettings( xColumn ) ) { ::comphelper::copyProperties( xColumn, xProp ); diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx index 7dd40092fe52..e624eb709c43 100644 --- a/dbaccess/source/core/dataaccess/ContentHelper.cxx +++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx @@ -260,44 +260,32 @@ void SAL_CALL OContentHelper::abort( sal_Int32 /*CommandId*/ ) void SAL_CALL OContentHelper::addPropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) { ::osl::MutexGuard aGuard(m_aMutex); - sal_Int32 nCount = PropertyNames.getLength(); - if ( !nCount ) + if (!PropertyNames.hasElements()) { // Note: An empty sequence means a listener for "all" properties. m_aPropertyChangeListeners.addInterface(OUString(), Listener ); } else { - const OUString* pSeq = PropertyNames.getConstArray(); - - for ( sal_Int32 n = 0; n < nCount; ++n ) - { - const OUString& rName = pSeq[ n ]; + for (auto& rName : PropertyNames) if ( !rName.isEmpty() ) m_aPropertyChangeListeners.addInterface(rName, Listener ); - } } } void SAL_CALL OContentHelper::removePropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener ) { ::osl::MutexGuard aGuard(m_aMutex); - sal_Int32 nCount = PropertyNames.getLength(); - if ( !nCount ) + if (!PropertyNames.hasElements()) { // Note: An empty sequence means a listener for "all" properties. m_aPropertyChangeListeners.removeInterface( OUString(), Listener ); } else { - const OUString* pSeq = PropertyNames.getConstArray(); - - for ( sal_Int32 n = 0; n < nCount; ++n ) - { - const OUString& rName = pSeq[ n ]; + for (auto& rName : PropertyNames) if ( !rName.isEmpty() ) m_aPropertyChangeListeners.removeInterface( rName, Listener ); - } } } @@ -315,12 +303,10 @@ void SAL_CALL OContentHelper::removeProperty( const OUString& /*Name*/ ) // XInitialization void SAL_CALL OContentHelper::initialize( const Sequence< Any >& _aArguments ) { - const Any* pBegin = _aArguments.getConstArray(); - const Any* pEnd = pBegin + _aArguments.getLength(); - PropertyValue aValue; - for(;pBegin != pEnd;++pBegin) + for (auto& arg : _aArguments) { - *pBegin >>= aValue; + PropertyValue aValue; + arg >>= aValue; if ( aValue.Name == "Parent" ) { m_xParentContainer.set(aValue.Value,UNO_QUERY); @@ -350,12 +336,9 @@ Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue aEvent.Further = false; aEvent.PropertyHandle = -1; - const PropertyValue* pValues = rValues.getConstArray(); - sal_Int32 nCount = rValues.getLength(); - - for ( sal_Int32 n = 0; n < nCount; ++n ) + for (sal_Int32 n = 0; n < rValues.getLength(); ++n) { - const PropertyValue& rValue = pValues[ n ]; + const PropertyValue& rValue = rValues[n]; if ( rValue.Name == "ContentType" || rValue.Name == "IsDocument" || rValue.Name == "IsFolder" ) { @@ -424,14 +407,10 @@ Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_aContext ); - sal_Int32 nCount = rProperties.getLength(); - if ( nCount ) + if (rProperties.hasElements()) { - const Property* pProps = rProperties.getConstArray(); - for ( sal_Int32 n = 0; n < nCount; ++n ) + for (auto& rProp : rProperties) { - const Property& rProp = pProps[ n ]; - // Process Core properties. if ( rProp.Name == "ContentType" ) @@ -502,11 +481,9 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent typedef std::map< XPropertiesChangeListener*, Sequence< PropertyChangeEvent > > PropertiesEventListenerMap; PropertiesEventListenerMap aListeners; - const PropertyChangeEvent* propertyChangeEvent = evt.getConstArray(); - - for ( sal_Int32 n = 0; n < nCount; ++n, ++propertyChangeEvent ) + for (sal_Int32 n = 0; n < nCount; ++n) { - const PropertyChangeEvent& rEvent = *propertyChangeEvent; + const PropertyChangeEvent& rEvent = evt[n]; const OUString& rName = rEvent.PropertyName; comphelper::OInterfaceContainerHelper3<XPropertiesChangeListener>* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName ); @@ -528,7 +505,7 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent else propertyEvents = &(*it).second; - propertyEvents->getArray()[n] = rEvent; + asNonConstRange(*propertyEvents)[n] = rEvent; } } } diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 818e70b5433b..8067ef32e30a 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -426,25 +426,22 @@ void ODatabaseModelImpl::impl_construct_nothrow() // insert the default settings Reference< XPropertyContainer > xContainer( m_xSettings, UNO_QUERY_THROW ); Reference< XSet > xSettingsSet( m_xSettings, UNO_QUERY_THROW ); - const AsciiPropertyValue* pSettings = getDefaultDataSourceSettings(); - for ( ; pSettings->AsciiName; ++pSettings ) + for (auto& setting : getDefaultDataSourceSettings()) { - if ( !pSettings->DefaultValue.hasValue() ) + if (!setting.DefaultValue.hasValue()) { - Property aProperty( - OUString::createFromAscii( pSettings->AsciiName ), + Property aProperty(setting.Name, -1, - pSettings->ValueType, + setting.ValueType, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID ); xSettingsSet->insert( Any( aProperty ) ); } else { - xContainer->addProperty( - OUString::createFromAscii( pSettings->AsciiName ), + xContainer->addProperty(setting.Name, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, - pSettings->DefaultValue + setting.DefaultValue ); } } @@ -1024,75 +1021,74 @@ Reference< XStorage > ODatabaseModelImpl::getStorage( const ObjectType _eType ) css::embed::ElementModes::READWRITE ); } -const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() +// static +std::span<const DefaultPropertyValue> ODatabaseModelImpl::getDefaultDataSourceSettings() { - static const AsciiPropertyValue aKnownSettings[] = + static const DefaultPropertyValue aKnownSettings[] = { // known JDBC settings - AsciiPropertyValue( "JavaDriverClass", Any( OUString() ) ), - AsciiPropertyValue( "JavaDriverClassPath", Any( OUString() ) ), - AsciiPropertyValue( "IgnoreCurrency", Any( false ) ), + { u"JavaDriverClass"_ustr, Any( OUString() ) }, + { u"JavaDriverClassPath"_ustr, Any( OUString() ) }, + { u"IgnoreCurrency"_ustr, Any( false ) }, // known settings for file-based drivers - AsciiPropertyValue( "Extension", Any( OUString() ) ), - AsciiPropertyValue( "CharSet", Any( OUString() ) ), - AsciiPropertyValue( "HeaderLine", Any( true ) ), - AsciiPropertyValue( "FieldDelimiter", Any( OUString( "," ) ) ), - AsciiPropertyValue( "StringDelimiter", Any( OUString( "\"" ) ) ), - AsciiPropertyValue( "DecimalDelimiter", Any( OUString( "." ) ) ), - AsciiPropertyValue( "ThousandDelimiter", Any( OUString() ) ), - AsciiPropertyValue( "ShowDeleted", Any( false ) ), + { u"Extension"_ustr, Any( OUString() ) }, + { u"CharSet"_ustr, Any( OUString() ) }, + { u"HeaderLine"_ustr, Any( true ) }, + { u"FieldDelimiter"_ustr, Any( OUString( "," ) ) }, + { u"StringDelimiter"_ustr, Any( OUString( "\"" ) ) }, + { u"DecimalDelimiter"_ustr, Any( OUString( "." ) ) }, + { u"ThousandDelimiter"_ustr, Any( OUString() ) }, + { u"ShowDeleted"_ustr, Any( false ) }, // known ODBC settings - AsciiPropertyValue( "SystemDriverSettings", Any( OUString() ) ), - AsciiPropertyValue( "UseCatalog", Any( false ) ), - AsciiPropertyValue( "TypeInfoSettings", Any( Sequence< Any >()) ), + { u"SystemDriverSettings"_ustr, Any( OUString() ) }, + { u"UseCatalog"_ustr, Any( false ) }, + { u"TypeInfoSettings"_ustr, Any( Sequence< Any >()) }, // settings related to auto increment handling - AsciiPropertyValue( "AutoIncrementCreation", Any( OUString() ) ), - AsciiPropertyValue( "AutoRetrievingStatement", Any( OUString() ) ), - AsciiPropertyValue( "IsAutoRetrievingEnabled", Any( false ) ), + { u"AutoIncrementCreation"_ustr, Any( OUString() ) }, + { u"AutoRetrievingStatement"_ustr, Any( OUString() ) }, + { u"IsAutoRetrievingEnabled"_ustr, Any( false ) }, // known LDAP driver settings - AsciiPropertyValue( "HostName", Any( OUString() ) ), - AsciiPropertyValue( "PortNumber", Any( sal_Int32(389) ) ), - AsciiPropertyValue( "BaseDN", Any( OUString() ) ), - AsciiPropertyValue( "MaxRowCount", Any( sal_Int32(100) ) ), + { u"HostName"_ustr, Any( OUString() ) }, + { u"PortNumber"_ustr, Any( sal_Int32(389) ) }, + { u"BaseDN"_ustr, Any( OUString() ) }, + { u"MaxRowCount"_ustr, Any( sal_Int32(100) ) }, // known MySQLNative driver settings - AsciiPropertyValue( "LocalSocket", Any( OUString() ) ), - AsciiPropertyValue( "NamedPipe", Any( OUString() ) ), + { u"LocalSocket"_ustr, Any( OUString() ) }, + { u"NamedPipe"_ustr, Any( OUString() ) }, // misc known driver settings - AsciiPropertyValue( "ParameterNameSubstitution", Any( false ) ), - AsciiPropertyValue( "AddIndexAppendix", Any( true ) ), - AsciiPropertyValue( "IgnoreDriverPrivileges", Any( true ) ), - AsciiPropertyValue( "ImplicitCatalogRestriction", ::cppu::UnoType< OUString >::get() ), - AsciiPropertyValue( "ImplicitSchemaRestriction", ::cppu::UnoType< OUString >::get() ), - AsciiPropertyValue( "PrimaryKeySupport", ::cppu::UnoType< sal_Bool >::get() ), - AsciiPropertyValue( "ShowColumnDescription", Any( false ) ), + { u"ParameterNameSubstitution"_ustr, Any( false ) }, + { u"AddIndexAppendix"_ustr, Any( true ) }, + { u"IgnoreDriverPrivileges"_ustr, Any( true ) }, + { u"ImplicitCatalogRestriction"_ustr, ::cppu::UnoType< OUString >::get() }, + { u"ImplicitSchemaRestriction"_ustr, ::cppu::UnoType< OUString >::get() }, + { u"PrimaryKeySupport"_ustr, ::cppu::UnoType< sal_Bool >::get() }, + { u"ShowColumnDescription"_ustr, Any( false ) }, // known SDB level settings - AsciiPropertyValue( "NoNameLengthLimit", Any( false ) ), - AsciiPropertyValue( "AppendTableAliasName", Any( false ) ), - AsciiPropertyValue( "GenerateASBeforeCorrelationName", Any( false ) ), - AsciiPropertyValue( "ColumnAliasInOrderBy", Any( true ) ), - AsciiPropertyValue( "EnableSQL92Check", Any( false ) ), - AsciiPropertyValue( "BooleanComparisonMode", Any( BooleanComparisonMode::EQUAL_INTEGER ) ), - AsciiPropertyValue( "TableTypeFilterMode", Any( sal_Int32(3) ) ), - AsciiPropertyValue( "RespectDriverResultSetType", Any( false ) ), - AsciiPropertyValue( "UseSchemaInSelect", Any( true ) ), - AsciiPropertyValue( "UseCatalogInSelect", Any( true ) ), - AsciiPropertyValue( "EnableOuterJoinEscape", Any( true ) ), - AsciiPropertyValue( "PreferDosLikeLineEnds", Any( false ) ), - AsciiPropertyValue( "FormsCheckRequiredFields", Any( true ) ), - AsciiPropertyValue( "EscapeDateTime", Any( true ) ), + { u"NoNameLengthLimit"_ustr, Any( false ) }, + { u"AppendTableAliasName"_ustr, Any( false ) }, + { u"GenerateASBeforeCorrelationName"_ustr, Any( false ) }, + { u"ColumnAliasInOrderBy"_ustr, Any( true ) }, + { u"EnableSQL92Check"_ustr, Any( false ) }, + { u"BooleanComparisonMode"_ustr, Any( BooleanComparisonMode::EQUAL_INTEGER ) }, + { u"TableTypeFilterMode"_ustr, Any( sal_Int32(3) ) }, + { u"RespectDriverResultSetType"_ustr, Any( false ) }, + { u"UseSchemaInSelect"_ustr, Any( true ) }, + { u"UseCatalogInSelect"_ustr, Any( true ) }, + { u"EnableOuterJoinEscape"_ustr, Any( true ) }, + { u"PreferDosLikeLineEnds"_ustr, Any( false ) }, + { u"FormsCheckRequiredFields"_ustr, Any( true ) }, + { u"EscapeDateTime"_ustr, Any( true ) }, // known services to handle database tasks - AsciiPropertyValue( "TableAlterationServiceName", Any( OUString() ) ), - AsciiPropertyValue( "TableRenameServiceName", Any( OUString() ) ), - AsciiPropertyValue( "ViewAlterationServiceName", Any( OUString() ) ), - AsciiPropertyValue( "ViewAccessServiceName", Any( OUString() ) ), - AsciiPropertyValue( "CommandDefinitions", Any( OUString() ) ), - AsciiPropertyValue( "Forms", Any( OUString() ) ), - AsciiPropertyValue( "Reports", Any( OUString() ) ), - AsciiPropertyValue( "KeyAlterationServiceName", Any( OUString() ) ), - AsciiPropertyValue( "IndexAlterationServiceName", Any( OUString() ) ), - - AsciiPropertyValue() + { u"TableAlterationServiceName"_ustr, Any( OUString() ) }, + { u"TableRenameServiceName"_ustr, Any( OUString() ) }, + { u"ViewAlterationServiceName"_ustr, Any( OUString() ) }, + { u"ViewAccessServiceName"_ustr, Any( OUString() ) }, + { u"CommandDefinitions"_ustr, Any( OUString() ) }, + { u"Forms"_ustr, Any( OUString() ) }, + { u"Reports"_ustr, Any( OUString() ) }, + { u"KeyAlterationServiceName"_ustr, Any( OUString() ) }, + { u"IndexAlterationServiceName"_ustr, Any( OUString() ) }, }; return aKnownSettings; } diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index fbb0ac1bd86b..62cacc3b1f44 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -336,43 +336,29 @@ void OSharedConnectionManager::addEventListener(const Reference<XConnection>& _r namespace { Sequence< PropertyValue > lcl_filterDriverProperties( const Reference< XDriver >& _xDriver, const OUString& _sUrl, - const Sequence< PropertyValue >& _rDataSourceSettings, const AsciiPropertyValue* _pKnownSettings ) + const Sequence< PropertyValue >& _rDataSourceSettings ) { if ( _xDriver.is() ) { Sequence< DriverPropertyInfo > aDriverInfo(_xDriver->getPropertyInfo(_sUrl,_rDataSourceSettings)); - const PropertyValue* pDataSourceSetting = _rDataSourceSettings.getConstArray(); - const PropertyValue* pEnd = pDataSourceSetting + _rDataSourceSettings.getLength(); - std::vector< PropertyValue > aRet; - for ( ; pDataSourceSetting != pEnd ; ++pDataSourceSetting ) + for (auto& dataSourceSetting : _rDataSourceSettings) { - bool bAllowSetting = false; - const AsciiPropertyValue* pSetting = _pKnownSettings; - for ( ; pSetting->AsciiName; ++pSetting ) - { - if ( pDataSourceSetting->Name.equalsAscii( pSetting->AsciiName ) ) - { // the particular data source setting is known - - const DriverPropertyInfo* pAllowedDriverSetting = aDriverInfo.getConstArray(); - const DriverPropertyInfo* pDriverSettingsEnd = pAllowedDriverSetting + aDriverInfo.getLength(); - for ( ; pAllowedDriverSetting != pDriverSettingsEnd; ++pAllowedDriverSetting ) - { - if ( pAllowedDriverSetting->Name.equalsAscii( pSetting->AsciiName ) ) - { // the driver also allows this setting - bAllowSetting = true; - break; - } - } - break; - } - } - if ( bAllowSetting || !pSetting->AsciiName ) + auto knownSettings = dbaccess::ODatabaseModelImpl::getDefaultDataSourceSettings(); + bool isSettingKnown = std::any_of(knownSettings.begin(), knownSettings.end(), + [name = dataSourceSetting.Name](auto& setting) + { return name == setting.Name; }); + // Allow if the particular data source setting is unknown or allowed by the driver + bool bAllowSetting = !isSettingKnown + || std::any_of(aDriverInfo.begin(), aDriverInfo.end(), + [name = dataSourceSetting.Name](auto& setting) + { return name == setting.Name; }); + if (bAllowSetting) { // if the driver allows this particular setting, or if the setting is completely unknown, // we pass it to the driver - aRet.push_back( *pDataSourceSetting ); + aRet.push_back(dataSourceSetting); } } if ( !aRet.empty() ) @@ -659,8 +645,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString Sequence< PropertyValue > aDriverInfo = lcl_filterDriverProperties( xDriver, m_pImpl->m_sConnectURL, - m_pImpl->m_xSettings->getPropertyValues(), - dbaccess::ODatabaseModelImpl::getDefaultDataSourceSettings() + m_pImpl->m_xSettings->getPropertyValues() ); if ( m_pImpl->isEmbeddedDatabase() ) @@ -762,36 +747,26 @@ Reference< XPropertySetInfo > ODatabaseSource::getPropertySetInfo() sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) { - bool bModified(false); if ( m_pImpl.is() ) { switch (nHandle) { case PROPERTY_ID_TABLEFILTER: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aTableFilter); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aTableFilter); case PROPERTY_ID_TABLETYPEFILTER: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aTableTypeFilter); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aTableTypeFilter); case PROPERTY_ID_USER: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_sUser); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_sUser); case PROPERTY_ID_PASSWORD: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aPassword); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aPassword); case PROPERTY_ID_ISPASSWORDREQUIRED: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_bPasswordRequired); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_bPasswordRequired); case PROPERTY_ID_SUPPRESSVERSIONCL: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_bSuppressVersionColumns); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_bSuppressVersionColumns); case PROPERTY_ID_LAYOUTINFORMATION: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aLayoutInformation); - break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_aLayoutInformation); case PROPERTY_ID_URL: - { - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_sConnectURL); - } break; + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_pImpl->m_sConnectURL); case PROPERTY_ID_INFO: { Sequence<PropertyValue> aValues; @@ -805,30 +780,26 @@ sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & } Sequence< PropertyValue > aSettings = m_pImpl->m_xSettings->getPropertyValues(); - bModified = aSettings.getLength() != aValues.getLength(); - if ( !bModified ) - { - const PropertyValue* pInfoIter = aSettings.getConstArray(); - const PropertyValue* checkValue = aValues.getConstArray(); - for ( ;!bModified && checkValue != std::cend(aValues) ; ++checkValue,++pInfoIter) - { - bModified = checkValue->Name != pInfoIter->Name; - if ( !bModified ) - { - bModified = checkValue->Value != pInfoIter->Value; - } - } - } rConvertedValue = rValue; rOldValue <<= aSettings; + + if (aSettings.getLength() != aValues.getLength()) + return true; + + for (sal_Int32 i = 0; i < aSettings.getLength(); ++i) + { + if (aValues[i].Name != aSettings[i].Name + || aValues[i].Value != aSettings[i].Value) + return true; + } } break; default: SAL_WARN("dbaccess", "ODatabaseSource::convertFastPropertyValue: unknown or readonly Property!" ); } } - return bModified; + return false; } namespace diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 48971a3c74f5..e8ea1dd63869 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -324,14 +324,12 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments } else if ( ServiceSpecifier == SERVICE_NAME_FORM_COLLECTION || SERVICE_NAME_REPORT_COLLECTION == ServiceSpecifier ) { - const Any* pBegin = _aArguments.getConstArray(); - const Any* pEnd = pBegin + _aArguments.getLength(); - PropertyValue aValue; OUString sName; Reference<XNameAccess> xCopyFrom; - for(;pBegin != pEnd;++pBegin) + for (auto& arg : _aArguments) { - *pBegin >>= aValue; + PropertyValue aValue; + arg >>= aValue; if ( aValue.Name == PROPERTY_NAME) { aValue.Value >>= sName; @@ -359,21 +357,18 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments // copy children if ( xCopyFrom.is() ) { - Sequence< OUString> aSeq = xCopyFrom->getElementNames(); - const OUString* elements = aSeq.getConstArray(); - const OUString* elementsEnd = elements + aSeq.getLength(); Reference<XContent> xObjectToCopy; Reference<XMultiServiceFactory> xORB(xContent,UNO_QUERY); OSL_ENSURE(xORB.is(),"No service factory given"); if ( xORB.is() ) { - for(;elements != elementsEnd;++elements) + for (auto& element : xCopyFrom->getElementNames()) { - xCopyFrom->getByName(*elements) >>= xObjectToCopy; + xCopyFrom->getByName(element) >>= xObjectToCopy; Sequence<Any> aArguments(comphelper::InitAnyPropertySequence( { - {"Name", Any(*elements)}, // set as folder + {"Name", Any(element)}, // set as folder {"Parent", Any(xContent)}, {PROPERTY_EMBEDDEDOBJECT, Any(xObjectToCopy)}, })); @@ -392,7 +387,7 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments Reference<XContent > xNew(xORB->createInstanceWithArguments(sServiceName,aArguments),UNO_QUERY); Reference<XNameContainer> xNameContainer(xContent,UNO_QUERY); if ( xNameContainer.is() ) - xNameContainer->insertByName(*elements,Any(xNew)); + xNameContainer->insertByName(element, Any(xNew)); } } } @@ -477,11 +472,8 @@ Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 Com else if ( aCommand.Name == "delete" ) { // delete - Sequence< OUString> aSeq = getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) - removeByName(*pIter); + for (auto& name : getElementNames()) + removeByName(name); dispose(); } diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index 227bde4cde1b..922d10c3b595 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -791,29 +791,27 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons Sequence< PropertyValue > aArguments; if ( _rOpenArgument >>= aArguments ) { - const PropertyValue* pIter = aArguments.getConstArray(); - const PropertyValue* pEnd = pIter + aArguments.getLength(); - for ( ;pIter != pEnd; ++pIter ) + for (auto& arg : aArguments) { - if ( pIter->Name == PROPERTY_ACTIVE_CONNECTION ) + if (arg.Name == PROPERTY_ACTIVE_CONNECTION) { - xConnection.set( pIter->Value, UNO_QUERY ); + xConnection.set(arg.Value, UNO_QUERY); continue; } - if ( lcl_extractOpenMode( pIter->Value, nOpenMode ) ) + if (lcl_extractOpenMode(arg.Value, nOpenMode)) continue; - if ( pIter->Name == "MacroExecutionMode" ) + if (arg.Name == "MacroExecutionMode") { sal_Int16 nMacroExecMode( !aDocumentMacroMode ? MacroExecMode::USE_CONFIG : *aDocumentMacroMode ); - OSL_VERIFY( pIter->Value >>= nMacroExecMode ); + OSL_VERIFY(arg.Value >>= nMacroExecMode); aDocumentMacroMode = nMacroExecMode; continue; } // unknown argument -> pass to the loaded document - aDocumentArgs.put( pIter->Name, pIter->Value ); + aDocumentArgs.put(arg.Name, arg.Value); } } } diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx index 26b85cbb8f3b..2fce725582d3 100644 --- a/dbaccess/source/core/dataaccess/intercept.cxx +++ b/dbaccess/source/core/dataaccess/intercept.cxx @@ -285,13 +285,9 @@ Sequence< OUString > SAL_CALL OInterceptor::getInterceptedURLs( ) Reference< XDispatch > SAL_CALL OInterceptor::queryDispatch( const URL& URL,const OUString& TargetFrameName,sal_Int32 SearchFlags ) { osl::MutexGuard aGuard(m_aMutex); - const OUString* pIter = m_aInterceptedURL.getConstArray(); - const OUString* pEnd = pIter + m_aInterceptedURL.getLength(); - for(;pIter != pEnd;++pIter) - { - if ( URL.Complete == *pIter ) + for (auto& interceptedUrl : m_aInterceptedURL) + if (URL.Complete == interceptedUrl) return static_cast<XDispatch*>(this); - } if(m_xSlaveDispatchProvider.is()) return m_xSlaveDispatchProvider->queryDispatch(URL,TargetFrameName,SearchFlags); @@ -310,11 +306,9 @@ Sequence< Reference< XDispatch > > SAL_CALL OInterceptor::queryDispatches( cons auto aRetRange = asNonConstRange(aRet); for(sal_Int32 i = 0; i < Requests.getLength(); ++i) { - const OUString* pIter = m_aInterceptedURL.getConstArray(); - const OUString* pEnd = pIter + m_aInterceptedURL.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& interceptedUrl : m_aInterceptedURL) { - if ( Requests[i].FeatureURL.Complete == *pIter ) + if (Requests[i].FeatureURL.Complete == interceptedUrl) { aRetRange[i] = static_cast<XDispatch*>(this); break; diff --git a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx index 495f4868851e..1b04127cf67f 100644 --- a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx +++ b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx @@ -152,26 +152,19 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) sal_uInt32 nOldCount = m_aResults.size(); bool bFound = false; - sal_uInt32 nPos = nOldCount; // @@@ Obtain data and put it into result list... Sequence< OUString> aSeq = m_xContent->getElementNames(); if ( nIndex < sal::static_int_cast< sal_uInt32 >( aSeq.getLength() ) ) { - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(pIter = pIter + nPos;pIter != pEnd;++pIter,++nPos) - { + m_aResults.reserve(nIndex + 1); + const OUString* pEnd = aSeq.begin() + nIndex + 1; + for (const OUString* pIter = aSeq.begin() + nOldCount; pIter != pEnd; ++pIter) m_aResults.emplace_back( new ResultListEntry( m_xContent->getContent(*pIter)->getContentProperties() ) ); - if ( nPos == nIndex ) - { - // Result obtained. - bFound = true; - break; - } - } + // Result obtained. + bFound = true; } if ( !bFound ) @@ -204,11 +197,11 @@ sal_uInt32 DataSupplier::totalCount() // @@@ Obtain data and put it into result list... Sequence< OUString> aSeq = m_xContent->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + // FIXME: this adds everything from aSeq to m_aResults, unlike similar code in getResult, + // which skips nOldCount entries in aSeq - which is correct? + for (auto& name : aSeq) m_aResults.emplace_back( - new ResultListEntry( m_xContent->getContent(*pIter)->getContentProperties() ) ); + new ResultListEntry( m_xContent->getContent(name)->getContentProperties() ) ); m_bCountFinal = true; diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx index 2fc19830ca42..2978867d8eea 100644 --- a/dbaccess/source/core/inc/ModelImpl.hxx +++ b/dbaccess/source/core/inc/ModelImpl.hxx @@ -45,6 +45,8 @@ #include <rtl/ref.hxx> #include <o3tl/enumarray.hxx> +#include <span> + namespace comphelper { class NamedValueCollection; @@ -55,33 +57,22 @@ namespace dbaccess typedef std::vector< css::uno::WeakReference< css::sdbc::XConnection > > OWeakConnectionArray; -struct AsciiPropertyValue +struct DefaultPropertyValue { - // note: the canonic member order would be AsciiName / DefaultValue, but - // this crashes on unxlngi6.pro, since there's a bug which somehow results in - // getDefaultDataSourceSettings returning corrupted Any instances then. + OUString Name; css::uno::Any DefaultValue; - const char* AsciiName; const css::uno::Type& ValueType; - AsciiPropertyValue() - :DefaultValue( ) - ,AsciiName( nullptr ) - ,ValueType( ::cppu::UnoType<void>::get() ) - { - } - - AsciiPropertyValue( const char* _pAsciiName, const css::uno::Any& _rDefaultValue ) - :DefaultValue( _rDefaultValue ) - ,AsciiName( _pAsciiName ) + DefaultPropertyValue(const OUString& _aName, const css::uno::Any& _rDefaultValue) + :Name( _aName ) + ,DefaultValue( _rDefaultValue ) ,ValueType( _rDefaultValue.getValueType() ) { OSL_ENSURE( ValueType.getTypeClass() != css::uno::TypeClass_VOID, "AsciiPropertyValue::AsciiPropertyValue: NULL values not allowed here, use the other CTOR for this!" ); } - AsciiPropertyValue( const char* _pAsciiName, const css::uno::Type& _rValeType ) - :DefaultValue() - ,AsciiName( _pAsciiName ) + DefaultPropertyValue(const OUString& _aName, const css::uno::Type& _rValeType) + :Name( _aName ) ,ValueType( _rValeType ) { OSL_ENSURE( ValueType.getTypeClass() != css::uno::TypeClass_VOID, @@ -386,7 +377,7 @@ public: void release(); /// returns all known data source settings, including their default values - static const AsciiPropertyValue* getDefaultDataSourceSettings(); + static std::span<const DefaultPropertyValue> getDefaultDataSourceSettings(); /** retrieves the requested container of objects (forms/reports/tables/queries) */ diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index d2aa735fa8ba..444c8459bddd 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -115,14 +115,12 @@ uno::Sequence< OUString > SAL_CALL DatabaseDataProvider::getSupportedServiceName void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & aArguments) { osl::MutexGuard g(m_aMutex); - const uno::Any* pIter = aArguments.getConstArray(); - const uno::Any* pEnd = pIter + aArguments.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& arg : aArguments) { if ( !m_xActiveConnection.is() ) - (*pIter) >>= m_xActiveConnection; + arg >>= m_xActiveConnection; else if ( !m_xHandler.is() ) - (*pIter) >>= m_xHandler; + arg >>= m_xHandler; } m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::Any( m_xActiveConnection ) ); } @@ -130,28 +128,26 @@ void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & // chart2::data::XDataProvider: sal_Bool SAL_CALL DatabaseDataProvider::createDataSourcePossible(const uno::Sequence< beans::PropertyValue > & _aArguments) { - const beans::PropertyValue* pArgIter = _aArguments.getConstArray(); - const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength(); - for(;pArgIter != pArgEnd;++pArgIter) + for (auto& arg : _aArguments) { - if ( pArgIter->Name == "DataRowSource" ) + if (arg.Name == "DataRowSource") { css::chart::ChartDataRowSource eRowSource = css::chart::ChartDataRowSource_COLUMNS; - pArgIter->Value >>= eRowSource; + arg.Value >>= eRowSource; if ( eRowSource != css::chart::ChartDataRowSource_COLUMNS ) return false; } - else if ( pArgIter->Name == "CellRangeRepresentation" ) + else if (arg.Name == "CellRangeRepresentation") { OUString sRange; - pArgIter->Value >>= sRange; + arg.Value >>= sRange; if ( sRange != "all" ) return false; } - else if ( pArgIter->Name == "FirstCellAsLabel" ) + else if (arg.Name == "FirstCellAsLabel") { bool bFirstCellAsLabel = true; - pArgIter->Value >>= bFirstCellAsLabel; + arg.Value >>= bFirstCellAsLabel; if ( !bFirstCellAsLabel ) return false; } diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 6a081c47a1f7..65beb4470c8c 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -55,13 +55,10 @@ ODsnTypeCollection::ODsnTypeCollection(const css::uno::Reference< css::uno::XCom ,m_nLivingIterators(0) #endif { - const uno::Sequence< OUString > aURLs = m_aDriverConfig.getURLs(); - const OUString* pIter = aURLs.getConstArray(); - const OUString* pEnd = pIter + aURLs.getLength(); - for(;pIter != pEnd;++pIter ) + for (auto& url : m_aDriverConfig.getURLs()) { - m_aDsnPrefixes.push_back(*pIter); - m_aDsnTypesDisplayNames.push_back(m_aDriverConfig.getDriverTypeDisplayName(*pIter)); + m_aDsnPrefixes.push_back(url); + m_aDsnTypesDisplayNames.push_back(m_aDriverConfig.getDriverTypeDisplayName(url)); } OSL_ENSURE(m_aDsnTypesDisplayNames.size() == m_aDsnPrefixes.size(), @@ -158,22 +155,19 @@ OUString ODsnTypeCollection::getMediaType(std::u16string_view _sURL) const OUString ODsnTypeCollection::getDatasourcePrefixFromMediaType(std::u16string_view _sMediaType,std::u16string_view _sExtension) { OUString sURL, sFallbackURL; - const uno::Sequence< OUString > aURLs = m_aDriverConfig.getURLs(); - const OUString* pIter = aURLs.getConstArray(); - const OUString* pEnd = pIter + aURLs.getLength(); - for(;pIter != pEnd;++pIter ) + for (auto& url : m_aDriverConfig.getURLs()) { - const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(*pIter); + const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(url); if ( aFeatures.getOrDefault("MediaType",OUString()) == _sMediaType ) { const OUString sFileExtension = aFeatures.getOrDefault("Extension",OUString()); if ( _sExtension == sFileExtension ) { - sURL = *pIter; + sURL = url; break; } if ( sFileExtension.isEmpty() && !_sExtension.empty() ) - sFallbackURL = *pIter; + sFallbackURL = url; } } diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index 13d0887b0caa..8b96604e85d2 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -245,13 +245,10 @@ void ODBExport::exportDataSource() { } - Sequence< Property > aProperties = xSettingsInfo->getProperties(); - const Property* pProperties = aProperties.getConstArray(); - const Property* pPropertiesEnd = pProperties + aProperties.getLength(); - for ( ; pProperties != pPropertiesEnd; ++pProperties ) + for (auto& property : xSettingsInfo->getProperties()) { OUString sValue; - Any aValue = xDataSourceSettings->getPropertyValue( pProperties->Name ); + Any aValue = xDataSourceSettings->getPropertyValue(property.Name); switch ( aValue.getValueTypeClass() ) { case TypeClass_STRING: @@ -315,7 +312,7 @@ void ODBExport::exportDataSource() bool bIsXMLDefault = false; for (const auto & aToken : aTokens) { - if ( pProperties->Name == aToken.sPropertyName ) + if (property.Name == aToken.sPropertyName) { eToken = aToken.eAttributeToken; @@ -337,15 +334,15 @@ void ODBExport::exportDataSource() { // for properties which are not REMOVABLE, we care for their state, and // only export them if they're not DEFAULTed - if ( ( pProperties->Attributes & PropertyAttribute::REMOVABLE ) == 0 ) + if ((property.Attributes & PropertyAttribute::REMOVABLE) == 0) { - PropertyState ePropertyState = xSettingsState->getPropertyState( pProperties->Name ); + PropertyState ePropertyState = xSettingsState->getPropertyState(property.Name); if ( PropertyState_DEFAULT_VALUE == ePropertyState ) continue; } // special handlings - if ( pProperties->Name == PROPERTY_BOOLEANCOMPARISONMODE ) + if (property.Name == PROPERTY_BOOLEANCOMPARISONMODE) { if ( sValue == "0" ) sValue = "equal-integer"; @@ -359,56 +356,55 @@ void ODBExport::exportDataSource() continue; eToken = XML_BOOLEAN_COMPARISON_MODE; } - else if ( pProperties->Name == INFO_AUTORETRIEVEENABLED ) + else if (property.Name == INFO_AUTORETRIEVEENABLED) { aValue >>= bAutoIncrementEnabled; continue; } - else if ( pProperties->Name == INFO_AUTORETRIEVEVALUE ) + else if (property.Name == INFO_AUTORETRIEVEVALUE) { aAutoIncrement.first = sValue; continue; } - else if ( pProperties->Name == PROPERTY_AUTOINCREMENTCREATION ) + else if (property.Name == PROPERTY_AUTOINCREMENTCREATION) { aAutoIncrement.second = sValue; continue; } - else if ( pProperties->Name == INFO_TEXTDELIMITER ) + else if (property.Name == INFO_TEXTDELIMITER) { aDelimiter.sText = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_FIELDDELIMITER ) + else if (property.Name == INFO_FIELDDELIMITER) { aDelimiter.sField = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_DECIMALDELIMITER ) + else if (property.Name == INFO_DECIMALDELIMITER) { aDelimiter.sDecimal = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_THOUSANDSDELIMITER ) + else if (property.Name == INFO_THOUSANDSDELIMITER) { aDelimiter.sThousand = sValue; aDelimiter.bUsed = true; continue; } - else if ( pProperties->Name == INFO_CHARSET ) + else if (property.Name == INFO_CHARSET) { m_sCharSet = sValue; continue; } else { - if ( !aDriverSupportedProperties.has(pProperties->Name) || aDriverSupportedProperties.get(pProperties->Name) != aValue ) + if ( !aDriverSupportedProperties.has(property.Name) || aDriverSupportedProperties.get(property.Name) != aValue ) { - m_aDataSourceSettings.emplace_back( - pProperties->Name, pProperties->Type, aValue ); + m_aDataSourceSettings.emplace_back(property.Name, property.Type, aValue); } continue; } @@ -715,12 +711,10 @@ void ODBExport::exportSequence(const Sequence< OUString>& _aValue { SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, _eTokenFilter, true, true); - const OUString* pIter = _aValue.getConstArray(); - const OUString* pEnd = pIter + _aValue.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& string : _aValue) { SvXMLElementExport aDataSource(*this,XML_NAMESPACE_DB, _eTokenType, true, false); - Characters(*pIter); + Characters(string); } } } @@ -756,14 +750,11 @@ void ODBExport::exportCollection(const Reference< XNameAccess >& _xCollection std::unique_ptr<SvXMLElementExport> pComponents; if ( _bExportContext ) pComponents.reset( new SvXMLElementExport(*this,XML_NAMESPACE_DB, _eComponents, true, true)); - Sequence< OUString> aSeq = _xCollection->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : _xCollection->getElementNames()) { - Reference<XPropertySet> xProp(_xCollection->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(_xCollection->getByName(name), UNO_QUERY); if ( _bExportContext && XML_TABLE_REPRESENTATIONS != _eComponents ) - AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); + AddAttribute(XML_NAMESPACE_DB, XML_NAME, name); Reference< XNameAccess > xSub(xProp,UNO_QUERY); if ( xSub.is() ) { @@ -921,12 +912,9 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) } SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, true, true); - Sequence< OUString> aSeq = xNameAccess->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for( ; pIter != pEnd ; ++pIter) + for (auto& name : xNameAccess->getElementNames()) { - Reference<XPropertySet> xProp(xNameAccess->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(xNameAccess->getByName(name), UNO_QUERY); if ( xProp.is() ) { rtl::Reference<comphelper::AttributeList> pAtt = new comphelper::AttributeList; @@ -940,7 +928,7 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) if ( bHidden || !sValue.isEmpty() || aColumnDefault.hasValue() || pAtt->getLength() ) { - AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); + AddAttribute(XML_NAMESPACE_DB, XML_NAME, name); if ( bHidden ) AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE); @@ -1193,26 +1181,23 @@ void ODBExport::GetViewSettings(Sequence<PropertyValue>& aProps) try { - sal_Int32 nLength = aProps.getLength(); - aProps.realloc(nLength + 1); - auto pProps = aProps.getArray(); - pProps[nLength].Name = "Queries"; Sequence< OUString> aSeq = xCollection->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - Sequence<PropertyValue> aQueries(aSeq.getLength()); auto aQueriesRange = asNonConstRange(aQueries); - for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i) + for (sal_Int32 i = 0; i < aSeq.getLength(); ++i) { - Reference<XPropertySet> xProp(xCollection->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(xCollection->getByName(aSeq[i]), UNO_QUERY); if ( xProp.is() ) { - aQueriesRange[i].Name = *pIter; + aQueriesRange[i].Name = aSeq[i]; aQueriesRange[i].Value = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION); } } - pProps[nLength].Value <<= aQueries; + sal_Int32 nLength = aProps.getLength(); + aProps.realloc(nLength + 1); + auto& prop = asNonConstRange(aProps)[nLength]; + prop.Name = "Queries"; + prop.Value <<= aQueries; } catch(const Exception&) { diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 975044623258..a41e7b43022b 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -492,17 +492,15 @@ SvXMLImportContext* ODBFilter::CreateFastContext(sal_Int32 nElement, void ODBFilter::SetViewSettings(const Sequence<PropertyValue>& aViewProps) { - const PropertyValue *pIter = aViewProps.getConstArray(); - const PropertyValue *pEnd = pIter + aViewProps.getLength(); - for (; pIter != pEnd; ++pIter) + for (auto& prop : aViewProps) { - if ( pIter->Name == "Queries" ) + if (prop.Name == "Queries") { - fillPropertyMap(pIter->Value,m_aQuerySettings); + fillPropertyMap(prop.Value, m_aQuerySettings); } - else if ( pIter->Name == "Tables" ) + else if (prop.Name == "Tables") { - fillPropertyMap(pIter->Value,m_aTablesSettings); + fillPropertyMap(prop.Value, m_aTablesSettings); } } } @@ -510,14 +508,12 @@ void ODBFilter::SetViewSettings(const Sequence<PropertyValue>& aViewProps) void ODBFilter::SetConfigurationSettings(const Sequence<PropertyValue>& aConfigProps) { - const PropertyValue *pIter = aConfigProps.getConstArray(); - const PropertyValue *pEnd = pIter + aConfigProps.getLength(); - for (; pIter != pEnd; ++pIter) + for (auto& prop : aConfigProps) { - if ( pIter->Name == "layout-settings" ) + if (prop.Name == "layout-settings") { Sequence<PropertyValue> aWindows; - pIter->Value >>= aWindows; + prop.Value >>= aWindows; uno::Reference<XPropertySet> xProp(getDataSource()); if ( xProp.is() ) xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,Any(aWindows)); @@ -530,13 +526,11 @@ void ODBFilter::fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap) { Sequence<PropertyValue> aWindows; _rValue >>= aWindows; - const PropertyValue *pIter = aWindows.getConstArray(); - const PropertyValue *pEnd = pIter + aWindows.getLength(); - for (; pIter != pEnd; ++pIter) + for (auto& window : aWindows) { Sequence<PropertyValue> aValue; - pIter->Value >>= aValue; - _rMap.emplace( pIter->Name,aValue ); + window.Value >>= aValue; + _rMap.emplace(window.Name, aValue); } } diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index fbe2c395633f..9ec5f3c1a501 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -1027,14 +1027,12 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa } else { - const PropertyValue* pIter = aArgs.getConstArray(); - const PropertyValue* pEnd = pIter + aArgs.getLength(); - for( ; pIter != pEnd ; ++pIter) + for (auto& arg : aArgs) { - if ( pIter->Name == "FormatStringId" ) + if (arg.Name == "FormatStringId") { sal_uInt32 nTmp; - if ( pIter->Value >>= nTmp ) + if (arg.Value >>= nTmp) pasteFormat(static_cast<SotClipboardFormatId>(nTmp)); break; } @@ -2703,20 +2701,18 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.hasElements() ) { ElementType eType = E_NONE; - const NamedValue* pIter = aCurrentSelection.getConstArray(); - const NamedValue* pEnd = pIter + aCurrentSelection.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& item : aCurrentSelection) { - if ( pIter->Name == "Type" ) + if (item.Name == "Type") { sal_Int32 nType = 0; - pIter->Value >>= nType; + item.Value >>= nType; if ( nType < DatabaseObject::TABLE || nType > DatabaseObject::REPORT ) throw IllegalArgumentException(); eType = static_cast< ElementType >( nType ); } - else if ( pIter->Name == "Selection" ) - pIter->Value >>= aSelection; + else if (item.Name == "Selection") + item.Value >>= aSelection; } m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running @@ -2736,42 +2732,37 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) SelectionByElementType aSelectedElements; ElementType eSelectedCategory = E_NONE; - for ( const NamedDatabaseObject* pObject = aSelectedObjects.getConstArray(); - pObject != aSelectedObjects.getConstArray() + aSelectedObjects.getLength(); - ++pObject - ) + for (sal_Int32 i = 0; i < aSelectedObjects.getLength(); ++i) { - switch ( pObject->Type ) + switch (aSelectedObjects[i].Type) { case DatabaseObject::TABLE: case DatabaseObjectContainer::SCHEMA: case DatabaseObjectContainer::CATALOG: - aSelectedElements[ E_TABLE ].push_back( pObject->Name ); + aSelectedElements[E_TABLE].push_back(aSelectedObjects[i].Name); break; case DatabaseObject::QUERY: - aSelectedElements[ E_QUERY ].push_back( pObject->Name ); + aSelectedElements[E_QUERY].push_back(aSelectedObjects[i].Name); break; case DatabaseObject::FORM: case DatabaseObjectContainer::FORMS_FOLDER: - aSelectedElements[ E_FORM ].push_back( pObject->Name ); + aSelectedElements[E_FORM].push_back(aSelectedObjects[i].Name); break; case DatabaseObject::REPORT: case DatabaseObjectContainer::REPORTS_FOLDER: - aSelectedElements[ E_REPORT ].push_back( pObject->Name ); + aSelectedElements[E_REPORT].push_back(aSelectedObjects[i].Name); break; case DatabaseObjectContainer::TABLES: case DatabaseObjectContainer::QUERIES: case DatabaseObjectContainer::FORMS: case DatabaseObjectContainer::REPORTS: if ( eSelectedCategory != E_NONE ) - throw IllegalArgumentException( - DBA_RES(RID_STR_NO_DIFF_CAT), - *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) ); + throw IllegalArgumentException(DBA_RES(RID_STR_NO_DIFF_CAT), *this, i); eSelectedCategory = - ( pObject->Type == DatabaseObjectContainer::TABLES ) ? E_TABLE - : ( pObject->Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY - : ( pObject->Type == DatabaseObjectContainer::FORMS ) ? E_FORM - : ( pObject->Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT + ( aSelectedObjects[i].Type == DatabaseObjectContainer::TABLES ) ? E_TABLE + : ( aSelectedObjects[i].Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY + : ( aSelectedObjects[i].Type == DatabaseObjectContainer::FORMS ) ? E_FORM + : ( aSelectedObjects[i].Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT : E_NONE; break; @@ -2780,8 +2771,8 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) { OUString sMessage( DBA_RES(RID_STR_UNSUPPORTED_OBJECT_TYPE). - replaceFirst("$type$", OUString::number(pObject->Type))); - throw IllegalArgumentException(sMessage, *this, sal_Int16( pObject - aSelectedObjects.getConstArray() )); + replaceFirst("$type$", OUString::number(aSelectedObjects[i].Type))); + throw IllegalArgumentException(sMessage, *this, i); } } } diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx index a46bfad409fd..38c3e67dbc24 100644 --- a/dbaccess/source/ui/app/AppControllerDnD.cxx +++ b/dbaccess/source/ui/app/AppControllerDnD.cxx @@ -764,12 +764,9 @@ bool OApplicationController::paste( ElementType _eType, const svx::ODataAccessDe { Reference<XPropertySet> xDstProp(xFac->createDataDescriptor()); - Sequence< OUString> aSeq = xSrcNameAccess->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for( ; pIter != pEnd ; ++pIter) + for (auto& name : xSrcNameAccess->getElementNames()) { - Reference<XPropertySet> xSrcProp(xSrcNameAccess->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xSrcProp(xSrcNameAccess->getByName(name),UNO_QUERY); ::comphelper::copyProperties(xSrcProp,xDstProp); xAppend->appendByDescriptor(xDstProp); } diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index c4adb2f45935..6c244f202956 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -383,11 +383,9 @@ void OAppDetailPageHelper::selectElements(const Sequence< OUString>& _aNames) DBTreeViewBase& rTree = *m_aLists[nPos]; weld::TreeView& rTreeView = rTree.GetWidget(); rTreeView.unselect_all(); - const OUString* pIter = _aNames.getConstArray(); - const OUString* pEnd = pIter + _aNames.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : _aNames) { - auto xEntry = rTree.getListBox().GetEntryPosByName(*pIter); + auto xEntry = rTree.getListBox().GetEntryPosByName(name); if (!xEntry) continue; rTreeView.select(*xEntry); @@ -644,18 +642,15 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine std::unique_ptr<weld::TreeIter> xRet = rTreeView.make_iterator(); const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType ); - Sequence< OUString> aSeq = _xContainer->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& name : _xContainer->getElementNames()) { - Reference<XNameAccess> xSubElements(_xContainer->getByName(*pIter),UNO_QUERY); + Reference<XNameAccess> xSubElements(_xContainer->getByName(name), UNO_QUERY); if ( xSubElements.is() ) { OUString sId(OUString::number(nFolderIndicator)); rTreeView.insert(_pParent, -1, nullptr, &sId, nullptr, nullptr, false, xRet.get()); - rTreeView.set_text(*xRet, *pIter, 0); + rTreeView.set_text(*xRet, name, 0); rTreeView.set_text_emphasis(*xRet, false, 0); getBorderWin().getView()->getAppController().containerFound( Reference< XContainer >( xSubElements, UNO_QUERY ) ); fillNames( xSubElements, _eType, rImageId, xRet.get()); @@ -663,7 +658,7 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine else { rTreeView.insert(_pParent, -1, nullptr, nullptr, nullptr, nullptr, false, xRet.get()); - rTreeView.set_text(*xRet, *pIter, 0); + rTreeView.set_text(*xRet, name, 0); rTreeView.set_text_emphasis(*xRet, false, 0); rTreeView.set_image(*xRet, rImageId); } diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx index 9ea7dcd4e6da..9b445d382dea 100644 --- a/dbaccess/source/ui/app/AppDetailView.cxx +++ b/dbaccess/source/ui/app/AppDetailView.cxx @@ -156,26 +156,20 @@ void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) // copy the commands so we can use them with the config managers Sequence< OUString > aCommands( _rList.size() ); - OUString* pCommands = aCommands.getArray(); - for (auto const& copyTask : _rList) - { - *pCommands = copyTask.sUNOCommand; - ++pCommands; - } + std::transform(_rList.begin(), _rList.end(), aCommands.getArray(), + [](auto& copyTask) { return copyTask.sUNOCommand; }); Sequence< Reference< XGraphic> > aImages = xImageMgr->getImages( ImageType::SIZE_DEFAULT | ImageType::COLOR_NORMAL , aCommands ); + assert(aImages.size() == _rList.size()); - const Reference< XGraphic >* pImages( aImages.getConstArray() ); - - size_t nIndex = 0; - for (auto const& task : _rList) + for (size_t nIndex = 0; nIndex < _rList.size(); ++nIndex) { - OUString sId = weld::toId(new TaskEntry(task)); - m_xTreeView->append(sId, task.sTitle); - m_xTreeView->set_image(nIndex++, *pImages++); + OUString sId = weld::toId(new TaskEntry(_rList[nIndex])); + m_xTreeView->append(sId, _rList[nIndex].sTitle); + m_xTreeView->set_image(nIndex, aImages[nIndex]); } } catch(Exception&) diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 8a316b331d1e..d9116be91886 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -1292,8 +1292,7 @@ sal_Bool SbaXDataBrowserController::approveParameter(const css::form::DatabasePa setLoadingCancelled(); return false; } - const PropertyValue* pFinalValues = aFinalValues.getConstArray(); - for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues) + for (sal_Int32 i = 0; i < aFinalValues.getLength(); ++i) { Reference< XPropertySet > xParam( aRequest.Parameters->getByIndex(i), css::uno::UNO_QUERY); @@ -1303,9 +1302,9 @@ sal_Bool SbaXDataBrowserController::approveParameter(const css::form::DatabasePa #ifdef DBG_UTIL OUString sName; xParam->getPropertyValue(PROPERTY_NAME) >>= sName; - OSL_ENSURE(sName == pFinalValues->Name, "SbaXDataBrowserController::approveParameter: suspicious value names!"); + OSL_ENSURE(sName == aFinalValues[i].Name, "SbaXDataBrowserController::approveParameter: suspicious value names!"); #endif - try { xParam->setPropertyValue(PROPERTY_VALUE, pFinalValues->Value); } + try { xParam->setPropertyValue(PROPERTY_VALUE, aFinalValues[i].Value); } catch(Exception&) { SAL_WARN("dbaccess.ui", "SbaXDataBrowserController::approveParameter: setting one of the properties failed!"); diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx index 0eeba92634a5..4199683b44d2 100644 --- a/dbaccess/source/ui/browser/dbloader.cxx +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -219,13 +219,9 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU Sequence< Any > aInitArgs(m_aArgs.getLength()+1); Any* pBegin = aInitArgs.getArray(); - Any* pEnd = pBegin + aInitArgs.getLength(); *pBegin <<= aFrame; - const PropertyValue* pIter = m_aArgs.getConstArray(); - for(++pBegin;pBegin != pEnd;++pBegin,++pIter) - { - *pBegin <<= *pIter; - } + std::transform(m_aArgs.begin(), m_aArgs.end(), ++pBegin, + [](auto& val) { return Any(val); }); xIni->initialize(aInitArgs); } diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 8bde54b54549..189432f70abf 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -177,20 +177,20 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen Reference< XFrame > xFrame; - PropertyValue aValue; - const Any* pIter = aArguments.getConstArray(); - const Any* pEnd = pIter + aArguments.getLength(); - - for ( ; pIter != pEnd; ++pIter ) + for (auto& arg : aArguments) { - if ( ( *pIter >>= aValue ) && aValue.Name == "Frame" ) - { - xFrame.set(aValue.Value,UNO_QUERY_THROW); - } - else if ( ( *pIter >>= aValue ) && aValue.Name == "Preview" ) + PropertyValue aValue; + if (arg >>= aValue) { - aValue.Value >>= m_bPreview; - m_bReadOnly = true; + if (aValue.Name == "Frame") + { + xFrame.set(aValue.Value, UNO_QUERY_THROW); + } + else if (aValue.Name == "Preview") + { + aValue.Value >>= m_bPreview; + m_bReadOnly = true; + } } } try @@ -542,19 +542,13 @@ Reference< XDispatch > OGenericUnoController::queryDispatch(const URL& aURL, co Sequence< Reference< XDispatch > > OGenericUnoController::queryDispatches(const Sequence< DispatchDescriptor >& aDescripts) { - Sequence< Reference< XDispatch > > aReturn; - sal_Int32 nLen = aDescripts.getLength(); - if ( nLen ) + Sequence< Reference< XDispatch > > aReturn(aDescripts.getLength()); + if (aDescripts.hasElements()) { - aReturn.realloc( nLen ); - Reference< XDispatch >* pReturn = aReturn.getArray(); - const Reference< XDispatch >* pReturnEnd = aReturn.getArray() + nLen; - const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); - - for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts ) - { - *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags ); - } + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), + [this](auto& desc) { + return queryDispatch(desc.FeatureURL, desc.FrameName, desc.SearchFlags); + }); } return aReturn; diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index f433eaa3b47b..132488ec0af4 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -1090,10 +1090,10 @@ void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos) OUString sCellText; Reference< XGridFieldDataSupplier > xFieldData(GetPeer()); Sequence<sal_Bool> aSupportingText = xFieldData->queryFieldDataType(cppu::UnoType<decltype(sCellText)>::get()); - if (aSupportingText.getConstArray()[nColumnPos]) + if (aSupportingText[nColumnPos]) { Sequence< Any> aCellContents = xFieldData->queryFieldData(nRowPos, cppu::UnoType<decltype(sCellText)>::get()); - sCellText = ::comphelper::getString(aCellContents.getConstArray()[nColumnPos]); + sCellText = ::comphelper::getString(aCellContents[nColumnPos]); ::svt::OStringTransfer::StartStringDrag(sCellText, this, DND_ACTION_COPY); } } diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx index cedd116575b2..e0c5b54f0627 100644 --- a/dbaccess/source/ui/control/RelationControl.cxx +++ b/dbaccess/source/ui/control/RelationControl.cxx @@ -358,12 +358,9 @@ namespace dbaui //sal_Int32 nRows = GetRowCount(); Reference<XColumnsSupplier> xSup(_xDest,UNO_QUERY); Reference<XNameAccess> xColumns = xSup->getColumns(); - Sequence< OUString> aNames = xColumns->getElementNames(); - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& text : xColumns->getElementNames()) { - rList.append_text(*pIter); + rList.append_text(text); } rList.insert_text(0, OUString()); } diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index 66db8dc37ab3..c3310e2a29c0 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -281,13 +281,8 @@ namespace dbaui css::uno::Sequence< OUString > list; xMozillaBootstrap->getProfileList( profileType, list ); - const OUString * pArray = list.getConstArray(); - sal_Int32 count = list.getLength(); - - std::set<OUString> aProfiles; - for (sal_Int32 index=0; index < count; index++) - aProfiles.insert(pArray[index]); + std::set<OUString> aProfiles(list.begin(), list.end()); // execute the select dialog ODatasourceSelectDialog aSelector(GetFrameWeld(), aProfiles); diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx index 40e33f41da78..82f901715461 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.cxx +++ b/dbaccess/source/ui/dlg/UserAdmin.cxx @@ -222,11 +222,8 @@ void OUserAdmin::FillUserNames() { m_xUSER->clear(); - m_aUserNames = m_xUsers->getElementNames(); - const OUString* pBegin = m_aUserNames.getConstArray(); - const OUString* pEnd = pBegin + m_aUserNames.getLength(); - for(;pBegin != pEnd;++pBegin) - m_xUSER->append_text(*pBegin); + for (auto& name : m_xUsers->getElementNames()) + m_xUSER->append_text(name); m_xUSER->set_active(0); if(m_xUsers->hasByName(m_UserName)) diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx index 76460a8468e7..9c376511351b 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.hxx +++ b/dbaccess/source/ui/dlg/UserAdmin.hxx @@ -40,7 +40,6 @@ class OUserAdmin final : public OGenericAdministrationPage css::uno::Reference< css::sdbc::XConnection> m_xConnection; css::uno::Reference< css::container::XNameAccess > m_xUsers; - css::uno::Sequence< OUString> m_aUserNames; OUString m_UserName; diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx index 2d98688f5b6c..a5056b1a8a4f 100644 --- a/dbaccess/source/ui/dlg/adtabdlg.cxx +++ b/dbaccess/source/ui/dlg/adtabdlg.cxx @@ -188,17 +188,11 @@ void TableListFacade::updateTableObjectList( bool _bAllowViews ) // if no views are allowed remove the views also out the table name filter if ( !_bAllowViews ) { - const OUString* pTableBegin = sTables.getConstArray(); - const OUString* pTableEnd = pTableBegin + sTables.getLength(); - std::vector< OUString > aTables(pTableBegin,pTableEnd); - - const OUString* pViewBegin = sViews.getConstArray(); - const OUString* pViewEnd = pViewBegin + sViews.getLength(); - ::comphelper::UStringMixEqual aEqualFunctor; - for(;pViewBegin != pViewEnd;++pViewBegin) - std::erase_if(aTables, - [&aEqualFunctor, pViewBegin](const OUString& lhs) - { return aEqualFunctor(lhs, *pViewBegin); } ); + std::vector<OUString> aTables(sTables.begin(), sTables.end()); + + for (auto& view : sViews) + std::erase_if(aTables, [Equal = comphelper::UStringMixEqual(), &view](auto& s) + { return Equal(s, view); }); sTables = Sequence< OUString>(aTables.data(), aTables.size()); sViews = Sequence< OUString>(); } diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 8fb43e3d2fc2..8aa4c3e22ffd 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -261,16 +261,9 @@ IMPL_LINK_NOARG(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage&, void) static void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo) { _rDSInfo.merge(_aNew,true); - uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues(); - const beans::NamedValue* pIter = aOldValues.getConstArray(); - const beans::NamedValue* pEnd = pIter + aOldValues.getLength(); - for(;pIter != pEnd;++pIter) - { - if ( !_aNew.has(pIter->Name) ) - { - _rDSInfo.remove(pIter->Name); - } - } + for (auto& val : _aOld.getNamedValues()) + if (!_aNew.has(val.Name)) + _rDSInfo.remove(val.Name); } void DataSourceInfoConverter::convert(const Reference<XComponentContext> & xContext, const ::dbaccess::ODsnTypeCollection* _pCollection, std::u16string_view _sOldURLPrefix, std::u16string_view _sNewURLPrefix,const css::uno::Reference< css::beans::XPropertySet >& _xDatasource) diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx index 35b0e3f02a27..d8c1c962809b 100644 --- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx +++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx @@ -228,10 +228,8 @@ constexpr auto BROWSER_STANDARD_FLAGS = BrowserMode::COLUMNSELECTION | BrowserMo weld::ComboBox& rNameListBox = m_pFieldNameCell->get_widget(); rNameListBox.append_text(OUString()); rNameListBox.set_help_id(HID_DLGINDEX_INDEXDETAILS_FIELD); - const OUString* pFields = _rAvailableFields.getConstArray(); - const OUString* pFieldsEnd = pFields + _rAvailableFields.getLength(); - for (;pFields < pFieldsEnd; ++pFields) - rNameListBox.append_text(*pFields); + for (auto& text : _rAvailableFields) + rNameListBox.append_text(text); } CellController* IndexFieldsControl::GetController(sal_Int32 _nRow, sal_uInt16 _nColumnId) diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index 84f2c774c6e2..077200349497 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -89,15 +89,12 @@ DlgFilterCrit::DlgFilterCrit(weld::Window * pParent, m_xLB_WHERECOMP1->clear(); // ... also write it into the remaining fields - Sequence< OUString> aNames = m_xColumns->getElementNames(); - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); Reference<XPropertySet> xColumn; - for(;pIter != pEnd;++pIter) + for (auto& colName : m_xColumns->getElementNames()) { try { - xColumn.set( m_xColumns->getByName( *pIter ), UNO_QUERY_THROW ); + xColumn.set(m_xColumns->getByName(colName), UNO_QUERY_THROW); sal_Int32 nDataType( 0 ); OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= nDataType ); @@ -114,21 +111,18 @@ DlgFilterCrit::DlgFilterCrit(weld::Window * pParent, { DBG_UNHANDLED_EXCEPTION("dbaccess"); } - m_xLB_WHEREFIELD1->append_text( *pIter ); - m_xLB_WHEREFIELD2->append_text( *pIter ); - m_xLB_WHEREFIELD3->append_text( *pIter ); + m_xLB_WHEREFIELD1->append_text(colName); + m_xLB_WHEREFIELD2->append_text(colName); + m_xLB_WHEREFIELD3->append_text(colName); } Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY_THROW)->getColumns(); - aNames = xSelectColumns->getElementNames(); - pIter = aNames.getConstArray(); - pEnd = pIter + aNames.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& colName : xSelectColumns->getElementNames()) { // don't insert a column name twice - if ( !m_xColumns->hasByName(*pIter) ) + if (!m_xColumns->hasByName(colName)) { - xColumn.set(xSelectColumns->getByName(*pIter),UNO_QUERY); + xColumn.set(xSelectColumns->getByName(colName), UNO_QUERY); OSL_ENSURE(xColumn.is(),"DlgFilterCrit::DlgFilterCrit: Column is null!"); sal_Int32 nDataType(0); xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType; @@ -137,9 +131,9 @@ DlgFilterCrit::DlgFilterCrit(weld::Window * pParent, // !pColumn->IsFunction() if(eColumnSearch != ColumnSearch::NONE) { - m_xLB_WHEREFIELD1->append_text( *pIter ); - m_xLB_WHEREFIELD2->append_text( *pIter ); - m_xLB_WHEREFIELD3->append_text( *pIter ); + m_xLB_WHEREFIELD1->append_text(colName); + m_xLB_WHEREFIELD2->append_text(colName); + m_xLB_WHEREFIELD3->append_text(colName); } } } @@ -345,20 +339,17 @@ Reference< XPropertySet > DlgFilterCrit::getColumn( const OUString& _rFieldName Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY_THROW)->getColumns(); if ( xColumns.is() && !xColumn.is() ) { - Sequence< OUString> aSeq = xColumns->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& colName : xColumns->getElementNames()) { - Reference<XPropertySet> xProp(xColumns->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xProp(xColumns->getByName(colName), UNO_QUERY); if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME) ) { OUString sRealName; xProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; if ( sRealName == _rFieldName ) { - if ( m_xColumns.is() && m_xColumns->hasByName( *pIter ) ) - m_xColumns->getByName( *pIter ) >>= xColumn; + if (m_xColumns.is() && m_xColumns->hasByName(colName)) + m_xColumns->getByName(colName) >>= xColumn; break; } } @@ -726,16 +717,12 @@ void DlgFilterCrit::BuildWherePart() void DlgFilterCrit::fillLines(int &i, const Sequence< Sequence< PropertyValue > >& _aValues) { - const Sequence<PropertyValue >* pOrIter = _aValues.getConstArray(); - const Sequence<PropertyValue >* pOrEnd = pOrIter + _aValues.getLength(); bool bOr(i != 0); // WHERE clause and HAVING clause are always ANDed, nor ORed - for(; pOrIter != pOrEnd; ++pOrIter) + for (auto& rOr : _aValues) { - const PropertyValue* pAndIter = pOrIter->getConstArray(); - const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength(); - for(;pAndIter != pAndEnd; ++pAndIter) + for (auto& rAnd : rOr) { - SetLine( i++,*pAndIter,bOr); + SetLine(i++, rAnd, bOr); bOr = false; } bOr=true; diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx index 5799fff7d68c..ee320e4650c8 100644 --- a/dbaccess/source/ui/dlg/queryorder.cxx +++ b/dbaccess/source/ui/dlg/queryorder.cxx @@ -74,13 +74,10 @@ DlgOrderCrit::DlgOrderCrit(weld::Window * pParent, try { // ... also the remaining fields - Sequence< OUString> aNames = m_xColumns->getElementNames(); - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); Reference<XPropertySet> xColumn; - for(;pIter != pEnd;++pIter) + for (auto& name : m_xColumns->getElementNames()) { - xColumn.set(m_xColumns->getByName(*pIter),UNO_QUERY); + xColumn.set(m_xColumns->getByName(name), UNO_QUERY); OSL_ENSURE(xColumn.is(),"Column is null!"); if ( xColumn.is() ) { @@ -91,7 +88,7 @@ DlgOrderCrit::DlgOrderCrit(weld::Window * pParent, { for (auto j : m_aColumnList) { - j->append_text(*pIter); + j->append_text(name); } } } diff --git a/dbaccess/source/ui/inc/indexes.hxx b/dbaccess/source/ui/inc/indexes.hxx index 75bd5b44ba63..068a5dec5026 100644 --- a/dbaccess/source/ui/inc/indexes.hxx +++ b/dbaccess/source/ui/inc/indexes.hxx @@ -31,9 +31,7 @@ namespace dbaui struct OIndexField { OUString sFieldName; - bool bSortAscending; - - OIndexField() : bSortAscending(true) { } + bool bSortAscending = true; }; typedef std::vector<OIndexField> IndexFields; 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); } } diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index 5ef77a5ebc18..abfe67fd7288 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -314,14 +314,9 @@ void OJoinController::loadTableWindows( const ::comphelper::NamedValueCollection m_aMinimumTableViewSize = Point(); - Sequence< PropertyValue > aWindowData; - aWindowData = i_rViewSettings.getOrDefault( "Tables", aWindowData ); - - const PropertyValue* pTablesIter = aWindowData.getConstArray(); - const PropertyValue* pTablesEnd = pTablesIter + aWindowData.getLength(); - for ( ; pTablesIter != pTablesEnd; ++pTablesIter ) + for (auto& table : i_rViewSettings.getOrDefault("Tables", Sequence<PropertyValue>())) { - ::comphelper::NamedValueCollection aSingleTableData( pTablesIter->Value ); + ::comphelper::NamedValueCollection aSingleTableData(table.Value); loadTableWindow( aSingleTableData ); } if ( m_aMinimumTableViewSize != Point() ) diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 7de007624f3d..430748a25b0c 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -134,13 +134,10 @@ namespace try { Reference<XNameAccess> xReferencedTableColumns(xInfoData->getReferencedTable()->getColumns()); - Sequence< OUString> aSeq = xInfoData->getReferencingTable()->getColumns()->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& column : xInfoData->getReferencingTable()->getColumns()->getElementNames()) { - if ( xReferencedTableColumns->hasByName(*pIter) ) - xInfoData->AppendConnLine(*pIter,*pIter); + if (xReferencedTableColumns->hasByName(column)) + xInfoData->AppendConnLine(column, column); } } catch( const Exception& ) diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index a1e4d34c1d56..8fee333fc3eb 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -206,20 +206,16 @@ void OTableWindow::FillListBox() Reference< XNameAccess > xColumns = m_pData->getColumns(); if( xColumns.is() ) { - Sequence< OUString> aColumns = xColumns->getElementNames(); - const OUString* pIter = aColumns.getConstArray(); - const OUString* pEnd = pIter + aColumns.getLength(); - - for (; pIter != pEnd; ++pIter) + for (auto& column : xColumns->getElementNames()) { - bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName( *pIter ); + bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName(column); OUString sId; - Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY); + Reference<XPropertySet> xColumn(xColumns->getByName(column), UNO_QUERY); if (xColumn.is()) sId = weld::toId(createUserData(xColumn, bPrimaryKeyColumn)); - rTreeView.append(sId, *pIter); + rTreeView.append(sId, column); // is this column in the primary key if ( bPrimaryKeyColumn ) diff --git a/dbaccess/source/ui/querydesign/querydlg.cxx b/dbaccess/source/ui/querydesign/querydlg.cxx index a54b78e24353..1a00dd11576b 100644 --- a/dbaccess/source/ui/querydesign/querydlg.cxx +++ b/dbaccess/source/ui/querydesign/querydlg.cxx @@ -238,13 +238,10 @@ IMPL_LINK_NOARG(DlgQryJoin, NaturalToggleHdl, weld::Toggleable&, void) try { Reference<XNameAccess> xReferencedTableColumns(m_pConnData->getReferencedTable()->getColumns()); - Sequence< OUString> aSeq = m_pConnData->getReferencingTable()->getColumns()->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& column : m_pConnData->getReferencingTable()->getColumns()->getElementNames()) { - if ( xReferencedTableColumns->hasByName(*pIter) ) - m_pConnData->AppendConnLine(*pIter,*pIter); + if (xReferencedTableColumns->hasByName(column)) + m_pConnData->AppendConnLine(column, column); } } catch( const Exception& ) diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 46b3671c40e2..7cb7bb577c0a 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -144,15 +144,13 @@ bool ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet if ( xKeyColumns.is() ) { Sequence< OUString> aKeyColumns = xKeyColumns->getElementNames(); - const OUString* pKeyIter = aKeyColumns.getConstArray(); - const OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength(); - for(;pKeyIter != pKeyEnd;++pKeyIter) + for (auto& keyColumn : aKeyColumns) { for (auto const& elem : m_vConnLineData) { ++nValidLinesCount; - if ( elem->GetFieldName(_eEConnectionSide) == *pKeyIter ) + if (elem->GetFieldName(_eEConnectionSide) == keyColumn) { ++nPrimKeysCount; break; @@ -307,28 +305,21 @@ bool ORelationTableConnectionData::Update() { Reference<XNameAccess> xColumns = xColSup->getColumns(); Sequence< OUString> aNames = xColumns->getElementNames(); - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); + const OUString* pIter = aNames.begin(); + const OUString* pEnd = aNames.end(); - Reference<XPropertySet> xColumn; OUString sName,sRelatedColumn; for ( ; pIter != pEnd ; ++pIter ) { - xColumn.set(xColumns->getByName(*pIter),UNO_QUERY_THROW); + Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY_THROW); xColumn->getPropertyValue(PROPERTY_NAME) >>= sName; xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn; - bool bFoundElem = false; - for (auto const& elem : m_vConnLineData) - { - if( elem->GetSourceFieldName() == sName - && elem->GetDestFieldName() == sRelatedColumn ) - { - bFoundElem = true; - break; - } - } - if (!bFoundElem) + if (std::none_of(m_vConnLineData.begin(), m_vConnLineData.end(), + [&sName, &sRelatedColumn](auto& elem) { + return elem->GetSourceFieldName() == sName + && elem->GetDestFieldName() == sRelatedColumn; + })) break; } if ( pIter == pEnd ) @@ -361,16 +352,14 @@ bool ORelationTableConnectionData::Update() OConnectionLineDataVec().swap(m_vConnLineData); Reference<XNameAccess> xColumns = xColSup->getColumns(); Sequence< OUString> aNames = xColumns->getElementNames(); - const OUString* pIter = aNames.getConstArray(); - const OUString* pEnd = pIter + aNames.getLength(); m_vConnLineData.reserve( aNames.getLength() ); Reference<XPropertySet> xColumn; OUString sName,sRelatedColumn; - for(;pIter != pEnd;++pIter) + for (auto& colName : aNames) { - xColumns->getByName(*pIter) >>= xColumn; + xColumns->getByName(colName) >>= xColumn; if ( xColumn.is() ) { OConnectionLineDataRef pNewData = new OConnectionLineData(); diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index 880600342dea..b1e5832f049c 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -1090,8 +1090,8 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW ); const bool bSelectedRecordsOnly = m_aSourceSelection.hasElements(); - const Any* pSelectedRow = m_aSourceSelection.getConstArray(); - const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength(); + const Any* pSelectedRow = m_aSourceSelection.begin(); + const Any* pSelEnd = m_aSourceSelection.end(); sal_Int32 nRowCount = 0; bool bContinue = false; diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx index 8b6b5abe178d..2277f5c09386 100644 --- a/dbaccess/source/ui/uno/dbinteraction.cxx +++ b/dbaccess/source/ui/uno/dbinteraction.cxx @@ -307,33 +307,32 @@ namespace dbaui sal_Int32 BasicInteractionHandler::getContinuation(Continuation _eCont, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) { - const Reference< XInteractionContinuation >* pContinuations = _rContinuations.getConstArray(); - for (sal_Int32 i=0; i<_rContinuations.getLength(); ++i, ++pContinuations) + for (sal_Int32 i = 0; i < _rContinuations.getLength(); ++i) { switch (_eCont) { case APPROVE: - if (Reference< XInteractionApprove >(*pContinuations, UNO_QUERY).is()) + if (Reference<XInteractionApprove>(_rContinuations[i], UNO_QUERY).is()) return i; break; case DISAPPROVE: - if (Reference< XInteractionDisapprove >(*pContinuations, UNO_QUERY).is()) + if (Reference<XInteractionDisapprove>(_rContinuations[i], UNO_QUERY).is()) return i; break; case RETRY: - if (Reference< XInteractionRetry >(*pContinuations, UNO_QUERY).is()) + if (Reference<XInteractionRetry>(_rContinuations[i], UNO_QUERY).is()) return i; break; case ABORT: - if (Reference< XInteractionAbort >(*pContinuations, UNO_QUERY).is()) + if (Reference<XInteractionAbort>(_rContinuations[i], UNO_QUERY).is()) return i; break; case SUPPLY_PARAMETERS: - if (Reference< XInteractionSupplyParameters >(*pContinuations, UNO_QUERY).is()) + if (Reference<XInteractionSupplyParameters>(_rContinuations[i], UNO_QUERY).is()) return i; break; case SUPPLY_DOCUMENTSAVE: - if (Reference< XInteractionDocumentSave >(*pContinuations, UNO_QUERY).is()) + if (Reference<XInteractionDocumentSave>(_rContinuations[i], UNO_QUERY).is()) return i; break; } |