cppuhelper/source/implbase_ex.cxx | 9 cppuhelper/source/implementationentry.cxx | 6 cppuhelper/source/propertysetmixin.cxx | 7 cppuhelper/source/propshlp.cxx | 31 +-- cppuhelper/source/tdmgr.cxx | 30 +-- cpputools/source/unoexe/unoexe.cxx | 3 cui/source/customize/cfgutil.cxx | 6 cui/source/dialogs/AdditionsDialog.cxx | 8 cui/source/dialogs/SpellDialog.cxx | 32 +-- cui/source/dialogs/cuifmsearch.cxx | 6 cui/source/dialogs/hangulhanjadlg.cxx | 23 -- cui/source/dialogs/hlmarkwn.cxx | 11 - cui/source/dialogs/hyphen.cxx | 40 +--- cui/source/dialogs/thesdlg.cxx | 19 - cui/source/options/connpoolconfig.cxx | 7 cui/source/options/dbregisterednamesconfig.cxx | 20 -- cui/source/options/optdict.cxx | 50 +---- cui/source/options/optgdlg.cxx | 25 -- cui/source/options/optlingu.cxx | 104 ++-------- cui/source/options/optpath.cxx | 14 - cui/source/options/optsave.cxx | 19 - cui/source/tabpages/numpages.cxx | 34 +-- dbaccess/source/core/api/FilteredContainer.cxx | 33 +-- dbaccess/source/core/api/KeySet.cxx | 39 +-- dbaccess/source/core/api/OptimisticSet.cxx | 7 dbaccess/source/core/api/RowSet.cxx | 28 +- dbaccess/source/core/api/RowSetCache.cxx | 9 dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 45 +--- dbaccess/source/core/api/View.cxx | 10 - dbaccess/source/core/api/column.cxx | 29 +- dbaccess/source/core/api/querycontainer.cxx | 9 dbaccess/source/core/api/table.cxx | 8 dbaccess/source/core/api/tablecontainer.cxx | 19 - dbaccess/source/core/dataaccess/ContentHelper.cxx | 51 +---- dbaccess/source/core/dataaccess/ModelImpl.cxx | 128 ++++++------- dbaccess/source/core/dataaccess/datasource.cxx | 95 +++------ dbaccess/source/core/dataaccess/documentcontainer.cxx | 26 -- dbaccess/source/core/dataaccess/documentdefinition.cxx | 16 - dbaccess/source/core/dataaccess/intercept.cxx | 14 - dbaccess/source/core/dataaccess/myucp_datasupplier.cxx | 25 -- dbaccess/source/core/inc/ModelImpl.hxx | 29 +- dbaccess/source/core/misc/DatabaseDataProvider.cxx | 24 +- dbaccess/source/core/misc/dsntypes.cxx | 20 -- dbaccess/source/filter/xml/xmlExport.cxx | 79 +++----- dbaccess/source/filter/xml/xmlfilter.cxx | 28 +- dbaccess/source/ui/app/AppController.cxx | 51 ++--- dbaccess/source/ui/app/AppControllerDnD.cxx | 7 dbaccess/source/ui/app/AppDetailPageHelper.cxx | 17 - dbaccess/source/ui/app/AppDetailView.cxx | 20 -- dbaccess/source/ui/browser/brwctrlr.cxx | 7 dbaccess/source/ui/browser/dbloader.cxx | 8 dbaccess/source/ui/browser/genericcontroller.cxx | 42 +--- dbaccess/source/ui/browser/sbagrid.cxx | 4 dbaccess/source/ui/control/RelationControl.cxx | 7 dbaccess/source/ui/dlg/ConnectionHelper.cxx | 7 dbaccess/source/ui/dlg/UserAdmin.cxx | 7 dbaccess/source/ui/dlg/UserAdmin.hxx | 1 dbaccess/source/ui/dlg/adtabdlg.cxx | 16 - dbaccess/source/ui/dlg/dbwizsetup.cxx | 13 - dbaccess/source/ui/dlg/indexfieldscontrol.cxx | 6 dbaccess/source/ui/dlg/queryfilter.cxx | 49 +--- dbaccess/source/ui/dlg/queryorder.cxx | 9 dbaccess/source/ui/inc/indexes.hxx | 4 dbaccess/source/ui/misc/DExport.cxx | 6 dbaccess/source/ui/misc/RowSetDrop.cxx | 17 - dbaccess/source/ui/misc/TokenWriter.cxx | 30 +-- dbaccess/source/ui/misc/WCopyTable.cxx | 39 +-- dbaccess/source/ui/misc/dsmeta.cxx | 9 dbaccess/source/ui/misc/indexcollection.cxx | 34 +-- dbaccess/source/ui/querydesign/JoinController.cxx | 9 dbaccess/source/ui/querydesign/QueryDesignView.cxx | 9 dbaccess/source/ui/querydesign/TableWindow.cxx | 12 - dbaccess/source/ui/querydesign/querydlg.cxx | 9 dbaccess/source/ui/relationdesign/RTableConnectionData.cxx | 35 +-- dbaccess/source/ui/uno/copytablewizard.cxx | 4 dbaccess/source/ui/uno/dbinteraction.cxx | 15 - 76 files changed, 633 insertions(+), 1145 deletions(-)
New commits: commit af5a1b5925dbc816dced8813282d953fd5adbaaa Author: Mike Kaganski <[email protected]> AuthorDate: Mon Apr 29 01:31:19 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Apr 29 23:15:48 2024 +0200 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 <[email protected]> Tested-by: Jenkins 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; -e ... etc. - the rest is truncated
