diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-13 09:02:48 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-14 06:00:49 +0200 |
commit | 8a017d25a62e878fdd32f189f0663b05d2ffb9cf (patch) | |
tree | c91ee53b5d9276ae30df785b52579a1b77a057df | |
parent | 17d3cacfb9675268e709cfc95771ad4ce8bde75a (diff) |
Avoid COW overhead using css::uno::Sequence
The scenarios are:
1. Calling sequence's begin() and end() in pairs to pass to algorithms
(both calls use getArray(), which does the COW checks)
2. In addition to #1, calling end() again when checking result of find
algorithms, and/or begin() to calculate result's distance
3. Using non-const sequences in range-based for loops, which internally
do #1
4. Assigning sequence to another sequence variable, and then modifying
one of them
In many cases, the sequences could be made const, or treated as const
for the purposes of the algorithms (using std::as_const, std::cbegin,
and std::cend). Where algorithm modifies the sequence, it was changed
to only call getArray() once. For that, css::uno::toNonConstRange was
introduced, which returns a struct (sublclass of std::pair) with two
iterators [begin, end], that are calculated using one call to begin()
and one call to getLength().
To handle #4, css::uno::Sequence::swap was introduced, that swaps the
internal pointer to uno_Sequence. So when a local Sequence variable
should be assigned to another variable, and the latter will be modified
further, it's now possible to use swap instead, so the two sequences
are kept independent.
The modified places were found by temporarily removing non-const end().
Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
220 files changed, 653 insertions, 603 deletions
diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 61c2747d5eb3..d0c37e89ef07 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -1213,7 +1213,8 @@ namespace basctl auto const sort = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale()); - std::sort(aModuleNames.begin(), aModuleNames.end(), + auto [begin, end] = toNonConstRange(aModuleNames); + std::sort(begin, end, [&sort](const OUString& rLHS, const OUString& rRHS) { return sort.compare(rLHS, rRHS) < 0; }); @@ -1227,7 +1228,7 @@ namespace basctl OUString aBaseName = _eType == E_SCRIPTS ? OUString("Module") : OUString("Dialog"); - Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) ); + const Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) ); std::set< OUString > aUsedNamesCheck( aUsedNames.begin(), aUsedNames.end() ); bool bValid = false; diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 682f24febca0..e908cfc57a71 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -2001,7 +2001,7 @@ void Chart2ImportTest::testTdf116163() CPPUNIT_ASSERT(xTextualDataSequence.is()); std::vector<OUString> aCategories; - Sequence<OUString> aTextData(xTextualDataSequence->getTextualData()); + const Sequence<OUString> aTextData(xTextualDataSequence->getTextualData()); ::std::copy(aTextData.begin(), aTextData.end(), ::std::back_inserter(aCategories)); diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 9094ab308afb..2aec79cfccb0 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -102,8 +102,8 @@ public: OUString findChartFile(const OUString& rDir, uno::Reference< container::XNameAccess > const & xNames ) { - uno::Sequence<OUString> aNames = xNames->getElementNames(); - OUString* pElement = std::find_if(aNames.begin(), aNames.end(), CheckForChartName(rDir)); + const uno::Sequence<OUString> aNames = xNames->getElementNames(); + const OUString* pElement = std::find_if(aNames.begin(), aNames.end(), CheckForChartName(rDir)); CPPUNIT_ASSERT(pElement != aNames.end()); return *pElement; diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index b88d1f205d5d..774e395e8951 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -473,7 +473,7 @@ std::vector< Reference< XDataSeriesContainer > > for( Reference< XCoordinateSystem > const & coords : aCooSysSeq ) { Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); + const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); std::transform( aChartTypeSeq.begin(), aChartTypeSeq.end(), std::back_inserter( aResult ), diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 1383160e2c65..7934f58fc4d0 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -246,7 +246,7 @@ void ObjectHierarchy::createAxesTree( Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ) ); if( !m_bOrderingForElementSelector ) - std::transform( aAxes.begin(), aAxes.end(), + std::transform( std::cbegin(aAxes), std::cend(aAxes), std::back_inserter( rContainer ), lcl_ObjectToOID( xChartDoc )); diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index 560332b81e98..889ca43f40e7 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -169,7 +169,7 @@ void ColumnLineChartTypeTemplate::createChartTypes( { Reference< lang::XMultiServiceFactory > xFact( GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); + const Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq )); sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength(); sal_Int32 nNumberOfLines = 0; sal_Int32 nNumberOfColumns = 0; diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index 9f17273c1607..af3c16190633 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -246,7 +246,7 @@ getAllDataSequences( const uno::Sequence<uno::Reference<chart2::XDataSeries> >& Reference< chart2::data::XDataSource > xSource( dataSeries, uno::UNO_QUERY ); if( xSource.is()) { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences()); + const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences()); aSeqVec.insert( aSeqVec.end(), aSeq.begin(), aSeq.end() ); } } diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index 7722da5e6e60..679b625948e0 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -301,7 +301,7 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData( uno::Reference< data::XDataSource > xDataSource(series, uno::UNO_QUERY); if( !xDataSource.is() ) continue; - uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); + const uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); aResult.insert( aResult.end(), aDataSequences.begin(), aDataSequences.end() ); } @@ -325,7 +325,7 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData( uno::Reference< data::XDataSource > xDataSource(series, uno::UNO_QUERY); if( !xDataSource.is() ) continue; - uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); + const uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); aResult.insert( aResult.end(), aDataSequences.begin(), aDataSequences.end() ); } diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index ae6766aecaef..3a1d06bdcf24 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -672,7 +672,7 @@ std::vector< Reference< XDataSeries > > for( Reference< XChartType> const & chartType : aChartTypeSeq ) { Reference< XDataSeriesContainer > xDSCnt( chartType, uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); + const Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() ); } } @@ -1201,7 +1201,7 @@ Sequence< Reference< XChartType > > for( Reference< XCoordinateSystem > const & coords : aCooSysSeq ) { Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); + const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); aResult.insert( aResult.end(), aChartTypeSeq.begin(), aChartTypeSeq.end() ); } } diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index ccbf8697c638..0323043dbff2 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -920,7 +920,7 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation else { // Maybe this 'else' part and the functions is not necessary anymore. - Sequence< OUString > aLabels = m_bDataInColumns ? getRowDescriptions() : getColumnDescriptions(); + const Sequence< OUString > aLabels = m_bDataInColumns ? getRowDescriptions() : getColumnDescriptions(); aResult.realloc( aLabels.getLength() ); transform( aLabels.begin(), aLabels.end(), aResult.getArray(), CommonFunctors::makeAny< OUString >() ); @@ -931,11 +931,9 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation sal_Int32 nIndex = aRange.toInt32(); if( nIndex >= 0 ) { - Sequence< double > aData; - if( m_bDataInColumns ) - aData = m_aInternalData.getColumnValues(nIndex); - else - aData = m_aInternalData.getRowValues(nIndex); + const Sequence< double > aData = m_bDataInColumns + ? m_aInternalData.getColumnValues(nIndex) + : m_aInternalData.getRowValues(nIndex); if( aData.hasElements() ) { aResult.realloc( aData.getLength()); diff --git a/chart2/source/tools/UncachedDataSequence.cxx b/chart2/source/tools/UncachedDataSequence.cxx index d10fa7da3f37..1c7394d22400 100644 --- a/chart2/source/tools/UncachedDataSequence.cxx +++ b/chart2/source/tools/UncachedDataSequence.cxx @@ -170,7 +170,7 @@ Sequence< double > SAL_CALL UncachedDataSequence::getNumericalData() MutexGuard aGuard( GetMutex() ); if( m_xDataProvider.is()) { - Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation )); + const Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation )); aResult.realloc( aValues.getLength()); std::transform( aValues.begin(), aValues.end(), aResult.getArray(), CommonFunctors::AnyToDouble()); @@ -185,7 +185,7 @@ Sequence< OUString > SAL_CALL UncachedDataSequence::getTextualData() MutexGuard aGuard( GetMutex() ); if( m_xDataProvider.is()) { - Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation )); + const Sequence< uno::Any > aValues( m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation )); aResult.realloc( aValues.getLength()); std::transform( aValues.begin(), aValues.end(), aResult.getArray(), CommonFunctors::AnyToString()); diff --git a/comphelper/qa/unit/base64_test.cxx b/comphelper/qa/unit/base64_test.cxx index dd89951e6430..31e865a370a6 100644 --- a/comphelper/qa/unit/base64_test.cxx +++ b/comphelper/qa/unit/base64_test.cxx @@ -72,18 +72,18 @@ void Base64Test::testBase64Decode() uno::Sequence<sal_Int8> expectedSequence = { 0, 0, 0, 0, 0, 1, 2, 3 }; comphelper::Base64::decode(decodedSequence, "AAAAAAABAgM="); - CPPUNIT_ASSERT( - std::equal(expectedSequence.begin(), expectedSequence.end(), decodedSequence.begin())); + CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), std::cend(expectedSequence), + std::cbegin(decodedSequence))); expectedSequence = { 5, 2, 3, 0, 0, 1, 2, 3 }; comphelper::Base64::decode(decodedSequence, "BQIDAAABAgM="); - CPPUNIT_ASSERT( - std::equal(expectedSequence.begin(), expectedSequence.end(), decodedSequence.begin())); + CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), std::cend(expectedSequence), + std::cbegin(decodedSequence))); expectedSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 }; comphelper::Base64::decode(decodedSequence, "yB9NbwABAgM="); - CPPUNIT_ASSERT( - std::equal(expectedSequence.begin(), expectedSequence.end(), decodedSequence.begin())); + CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), std::cend(expectedSequence), + std::cbegin(decodedSequence))); } void Base64Test::testBase64EncodeForOStringBuffer() diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index 62dd474c962f..f84d509847eb 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -83,14 +83,14 @@ namespace comphelper && (_rArguments[1] >>= AllowEmptyPropertyName) && (_rArguments[2] >>= AutomaticAddition)) { - m_aAllowedTypes.insert(aTypes.begin(), aTypes.end()); + m_aAllowedTypes.insert(std::cbegin(aTypes), std::cend(aTypes)); m_bAutoAddProperties = AutomaticAddition; } else { ::comphelper::NamedValueCollection aArguments( _rArguments ); if ( aArguments.get_ensureType( "AllowedTypes", aTypes ) ) - m_aAllowedTypes.insert( aTypes.begin(), aTypes.end()); + m_aAllowedTypes.insert(std::cbegin(aTypes), std::cend(aTypes)); aArguments.get_ensureType( "AutomaticAddition", m_bAutoAddProperties ); aArguments.get_ensureType( "AllowEmptyPropertyName", @@ -377,8 +377,8 @@ namespace comphelper // their names Sequence< OUString > aNames( aProperties.getLength() ); std::transform( - aProperties.begin(), - aProperties.end(), + std::cbegin(aProperties), + std::cend(aProperties), aNames.getArray(), TransformPropertyToName< Property >() ); @@ -425,17 +425,18 @@ namespace comphelper { // sort (the XMultiPropertySet interface requires this) Sequence< PropertyValue > aProperties( _rProps ); + auto [begin, end] = toNonConstRange(aProperties); std::sort( - aProperties.begin(), - aProperties.end(), + begin, + end, ComparePropertyValueByName() ); // a sequence of names Sequence< OUString > aNames( aProperties.getLength() ); std::transform( - aProperties.begin(), - aProperties.end(), + std::cbegin(aProperties), + std::cend(aProperties), aNames.getArray(), TransformPropertyToName< PropertyValue >() ); @@ -479,8 +480,8 @@ namespace comphelper // a sequence of values Sequence< Any > aValues( aProperties.getLength() ); std::transform( - aProperties.begin(), - aProperties.end(), + std::cbegin(aProperties), + std::cend(aProperties), aValues.getArray(), ExtractPropertyValue() ); diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index 1ba31ec8258f..73dcbd2e862b 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -469,15 +469,15 @@ void OPropertyContainerHelper::describeProperties(Sequence< Property >& _rProps) } // as our property vector is sorted by handles, not by name, we have to sort aOwnProps - std::sort(aOwnProps.begin(), aOwnProps.end(), PropertyCompareByName()); + auto [begin, end] = toNonConstRange(aOwnProps); + std::sort(begin, end, PropertyCompareByName()); // unfortunately the STL merge function does not allow the output range to overlap one of the input ranges, // so we need an extra sequence - Sequence< Property > aOutput; - aOutput.realloc(_rProps.getLength() + aOwnProps.getLength()); + Sequence< Property > aOutput(_rProps.getLength() + aOwnProps.getLength()); // do the merge - std::merge( _rProps.begin(), _rProps.end(), // input 1 - aOwnProps.begin(), aOwnProps.end(), // input 2 + std::merge( std::cbegin(_rProps), std::cend(_rProps), // input 1 + std::cbegin(aOwnProps), std::cend(aOwnProps), // input 2 aOutput.getArray(), // output PropertyCompareByName() // compare operator ); diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx index 264002e5dc57..252882067865 100644 --- a/connectivity/source/commontools/ConnectionWrapper.cxx +++ b/connectivity/source/commontools/ConnectionWrapper.cxx @@ -199,7 +199,8 @@ void OConnectionWrapper::createUniqueId( const OUString& _rURL if ( !_rPassword.isEmpty() ) sha1.update(reinterpret_cast<unsigned char const*>(_rPassword.getStr()), _rPassword.getLength() * sizeof(sal_Unicode)); // now we need to sort the properties - std::sort(_rInfo.begin(),_rInfo.end(),TPropertyValueLessFunctor()); + auto [begin, end] = toNonConstRange(_rInfo); + std::sort(begin,end,TPropertyValueLessFunctor()); for (PropertyValue const & prop : std::as_const(_rInfo)) { diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index c0cefeaa1b13..0adfe23bdac9 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -637,11 +637,11 @@ bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp, const OUSt { Sequence< PropertyValue > aInfo; xProp->getPropertyValue("Info") >>= aInfo; - const PropertyValue* pValue =std::find_if(aInfo.begin(), - aInfo.end(), + const PropertyValue* pValue =std::find_if(std::cbegin(aInfo), + std::cend(aInfo), [&_sProperty](const PropertyValue& lhs) { return lhs.Name == _sProperty; }); - if ( pValue != aInfo.end() ) + if ( pValue != std::cend(aInfo) ) pValue->Value >>= bEnabled; } } diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx index 40fef64ed5ac..da06ef77f2c3 100644 --- a/connectivity/source/drivers/jdbc/JStatement.cxx +++ b/connectivity/source/drivers/jdbc/JStatement.cxx @@ -124,9 +124,10 @@ Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( ) Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes(); if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() ) { - auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(), + auto [begin, end] = toNonConstRange(aOldTypes); + auto newEnd = std::remove(begin, end, cppu::UnoType<XGeneratedResultSet>::get()); - aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd)); + aOldTypes.realloc(std::distance(begin, newEnd)); } return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes); diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index c5d63ef771a8..13ffeda8e4ba 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -131,9 +131,10 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) Sequence< Type > aOldTypes = OStatement_BASE::getTypes(); if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() ) { - auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(), + auto [begin, end] = toNonConstRange(aOldTypes); + auto newEnd = std::remove(begin, end, cppu::UnoType<XGeneratedResultSet>::get()); - aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd)); + aOldTypes.realloc(std::distance(begin, newEnd)); } return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes); diff --git a/connectivity/source/sdbcx/VDescriptor.cxx b/connectivity/source/sdbcx/VDescriptor.cxx index 9023a2076a74..2392e2d5f1d2 100644 --- a/connectivity/source/sdbcx/VDescriptor.cxx +++ b/connectivity/source/sdbcx/VDescriptor.cxx @@ -74,10 +74,11 @@ namespace connectivity::sdbcx Sequence< Property > aProperties; describeProperties( aProperties ); + auto [begin, end] = toNonConstRange(aProperties); if ( isNew() ) - std::for_each( aProperties.begin(), aProperties.end(), ResetROAttribute() ); + std::for_each( begin, end, ResetROAttribute() ); else - std::for_each( aProperties.begin(), aProperties.end(), SetROAttribute() ); + std::for_each( begin, end, SetROAttribute() ); return new ::cppu::OPropertyArrayHelper( aProperties ); } diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 0cad2093070d..09535a15690f 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -773,7 +773,7 @@ Sequence< OUString > ORegistryFactoryHelper::getSupportedServiceNames() // Full qualified names like "IMPLEMENTATIONS/TEST/UNO/SERVICES/com.sun.star..." Sequence<OUString> seqKeys = xKey->getKeyNames(); - for( OUString & key : seqKeys ) + for( OUString & key : toNonConstRange(seqKeys) ) key = key.copy(nPrefixLen); aServiceNames = seqKeys; diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 8f993096fe95..c7a7238f3f97 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -1376,7 +1376,7 @@ bool ODatabaseModelImpl::hasTrustedScriptingSignature(bool bAllowUIToAddAuthor) uno::Reference<security::XDocumentDigitalSignatures> xSigner( security::DocumentDigitalSignatures::createWithVersion( comphelper::getProcessComponentContext(), aODFVersion)); - uno::Sequence<security::DocumentSignatureInformation> aInfo + const uno::Sequence<security::DocumentSignatureInformation> aInfo = xSigner->verifyScriptingContentSignatures(xStorage, uno::Reference<io::XInputStream>()); diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index d5889255523e..15054023170e 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -750,7 +750,7 @@ void OConnection::impl_checkTableQueryNames_nothrow() try { Reference< XNameAccess > xTables( getTables() ); - Sequence< OUString > aTableNames( xTables->getElementNames() ); + const Sequence< OUString > aTableNames( xTables->getElementNames() ); std::set< OUString > aSortedTableNames( aTableNames.begin(), aTableNames.end() ); Reference< XNameAccess > xQueries( getQueries() ); diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 7fc1cb6eb254..e9867def1b99 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -223,11 +223,12 @@ Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) // allowed to contain macros, too. if ( !m_bAllowDocumentScripting ) { - auto newEnd = std::remove_if( aTypes.begin(), aTypes.end(), + auto [begin, end] = toNonConstRange(aTypes); + auto newEnd = std::remove_if( begin, end, [](const Type& t) { return t == cppu::UnoType<XEmbeddedScripts>::get() || t == cppu::UnoType<XScriptInvocationContext>::get();} ); - aTypes.realloc( std::distance(aTypes.begin(), newEnd) ); + aTypes.realloc( std::distance(begin, newEnd) ); } return aTypes; diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 4f499eccc263..48039c3e6943 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -1046,13 +1046,15 @@ void ODatabaseSource::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) con // transform them so that only property values which fulfill certain // criteria survive Sequence< PropertyValue > aNonDefaultOrUserDefined( aValues.getLength() ); + auto [begin, end] = toNonConstRange(aValues); + auto pCopyStart = aNonDefaultOrUserDefined.getArray(); const PropertyValue* pCopyEnd = std::remove_copy_if( - aValues.begin(), - aValues.end(), - aNonDefaultOrUserDefined.getArray(), + begin, + end, + pCopyStart, IsDefaultAndNotRemoveable( aPropertyAttributes ) ); - aNonDefaultOrUserDefined.realloc( pCopyEnd - aNonDefaultOrUserDefined.getArray() ); + aNonDefaultOrUserDefined.realloc( pCopyEnd - pCopyStart ); rValue <<= aNonDefaultOrUserDefined; } catch( const Exception& ) diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 43f084fec020..b6bf10274b8b 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -214,10 +214,11 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" ); if ( !m_aDocScriptSupport || !*m_aDocScriptSupport ) { - auto newEnd = std::remove_if( aTypes.begin(), aTypes.end(), + auto [begin, end] = toNonConstRange(aTypes); + auto newEnd = std::remove_if( begin, end, [](const Type& type) { return type == cppu::UnoType<XScriptInvocationContext>::get(); } ); - aTypes.realloc( std::distance(aTypes.begin(), newEnd) ); + aTypes.realloc( std::distance(begin, newEnd) ); } return aTypes; } diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 4086e7b442f2..7c9a09cc8484 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -982,17 +982,17 @@ void fillAutoIncrementValue(const Reference<XPropertySet>& _xDatasource, _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo; // search the right propertyvalue - const PropertyValue* pValue =std::find_if(aInfo.begin(), aInfo.end(), + const PropertyValue* pValue =std::find_if(std::cbegin(aInfo), std::cend(aInfo), [](const PropertyValue& lhs) {return lhs.Name == PROPERTY_AUTOINCREMENTCREATION;} ); - if ( pValue != aInfo.end() ) + if ( pValue != std::cend(aInfo) ) pValue->Value >>= _rsAutoIncrementValue; - pValue =std::find_if(aInfo.begin(), aInfo.end(), + pValue =std::find_if(std::cbegin(aInfo), std::cend(aInfo), [](const PropertyValue& lhs) {return lhs.Name == "IsAutoRetrievingEnabled";} ); - if ( pValue != aInfo.end() ) + if ( pValue != std::cend(aInfo) ) pValue->Value >>= _rAutoIncrementValueEnabled; } diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index 6a6784e92dcc..82ce80f71333 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -222,10 +222,11 @@ namespace dbaui Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() ); if ( !m_pImpl->documentHasScriptSupport() ) { - auto newEnd = std::remove_if( aTypes.begin(), aTypes.end(), + auto [begin, end] = toNonConstRange(aTypes); + auto newEnd = std::remove_if( begin, end, [](const Type& type) { return type == cppu::UnoType<XScriptInvocationContext>::get(); } ); - aTypes.realloc( std::distance(aTypes.begin(), newEnd) ); + aTypes.realloc( std::distance(begin, newEnd) ); } return aTypes; } diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 8070df7a5f90..4f7bd55bde1e 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -288,9 +288,10 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i PropertyAttribute::READONLY ); + auto [begin, end] = toNonConstRange(aProps); std::sort( - aProps.begin(), - aProps.end(), + begin, + end, ::comphelper::PropertyCompareByName() ); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 60e025e3e371..156176ba023d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5883,9 +5883,9 @@ static char* lo_getFilterTypes(LibreOfficeKit* pThis) uno::Sequence<beans::PropertyValue> aValues; if (xTypeDetection->getByName(rType) >>= aValues) { - auto it = std::find_if(aValues.begin(), aValues.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "MediaType"; }); + auto it = std::find_if(std::cbegin(aValues), std::cend(aValues), [](const beans::PropertyValue& rValue) { return rValue.Name == "MediaType"; }); OUString aValue; - if (it != aValues.end() && (it->Value >>= aValue) && !aValue.isEmpty()) + if (it != std::cend(aValues) && (it->Value >>= aValue) && !aValue.isEmpty()) { auto typeNode = aJson.startNode(rType.toUtf8().getStr()); aJson.put("MediaType", aValue.toUtf8()); diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx index 193c74472ba4..41f46e854164 100644 --- a/desktop/source/lib/lokclipboard.cxx +++ b/desktop/source/lib/lokclipboard.cxx @@ -219,11 +219,11 @@ uno::Sequence<datatransfer::DataFlavor> SAL_CALL LOKTransferable::getTransferDat sal_Bool SAL_CALL LOKTransferable::isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor) { - return std::find_if(m_aFlavors.begin(), m_aFlavors.end(), + return std::find_if(std::cbegin(m_aFlavors), std::cend(m_aFlavors), [&rFlavor](const datatransfer::DataFlavor& i) { return i.MimeType == rFlavor.MimeType && i.DataType == rFlavor.DataType; }) - != m_aFlavors.end(); + != std::cend(m_aFlavors); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/bibliography/formcontrolcontainer.cxx b/extensions/source/bibliography/formcontrolcontainer.cxx index 5e9f7d37aa35..c6ec73700656 100644 --- a/extensions/source/bibliography/formcontrolcontainer.cxx +++ b/extensions/source/bibliography/formcontrolcontainer.cxx @@ -92,15 +92,16 @@ namespace bib try { Reference< XControlContainer > xControlCont = getControlContainer(); - Sequence< Reference< XControl > > aControls; if ( xControlCont.is() ) - aControls = xControlCont->getControls(); - - std::for_each( - aControls.begin(), - aControls.end(), - ControlModeSwitch( _bDesign ) - ); + { + const Sequence<Reference<XControl>> aControls = xControlCont->getControls(); + + std::for_each( + aControls.begin(), + aControls.end(), + ControlModeSwitch( _bDesign ) + ); + } } catch( const Exception&) { diff --git a/extensions/source/propctrlr/cellbindinghelper.cxx b/extensions/source/propctrlr/cellbindinghelper.cxx index e27345e7fee7..90dd8b77277b 100644 --- a/extensions/source/propctrlr/cellbindinghelper.cxx +++ b/extensions/source/propctrlr/cellbindinghelper.cxx @@ -375,15 +375,16 @@ namespace pcr Reference< XMultiServiceFactory > xDocumentFactory( m_xDocument, UNO_QUERY ); OSL_ENSURE( xDocumentFactory.is(), "CellBindingHelper::isSpreadsheetDocumentWhichSupplies: spreadsheet document, but no factory?" ); - Sequence< OUString > aAvailableServices; if ( xDocumentFactory.is() ) - aAvailableServices = xDocumentFactory->getAvailableServiceNames( ); + { + const Sequence<OUString> aAvailableServices = xDocumentFactory->getAvailableServiceNames( ); - bYesItIs = std::any_of( - aAvailableServices.begin(), - aAvailableServices.end(), - StringCompare( _rService ) - ); + bYesItIs = std::any_of( + aAvailableServices.begin(), + aAvailableServices.end(), + StringCompare( _rService ) + ); + } } return bYesItIs; diff --git a/extensions/source/propctrlr/eformshelper.cxx b/extensions/source/propctrlr/eformshelper.cxx index 36f5f2a2b44d..ff0a91e0e518 100644 --- a/extensions/source/propctrlr/eformshelper.cxx +++ b/extensions/source/propctrlr/eformshelper.cxx @@ -305,7 +305,7 @@ namespace pcr OSL_ENSURE( xForms.is(), "EFormsHelper::getFormModelNames: invalid forms container!" ); if ( xForms.is() ) { - Sequence< OUString > aModelNames = xForms->getElementNames(); + const Sequence< OUString > aModelNames = xForms->getElementNames(); _rModelNames.resize( aModelNames.getLength() ); std::copy( aModelNames.begin(), aModelNames.end(), _rModelNames.begin() ); } @@ -329,7 +329,7 @@ namespace pcr OSL_ENSURE( xBindings.is(), "EFormsHelper::getBindingNames: invalid bindings container obtained from the model!" ); if ( xBindings.is() ) { - Sequence< OUString > aNames = xBindings->getElementNames(); + const Sequence< OUString > aNames = xBindings->getElementNames(); _rBindingNames.resize( aNames.getLength() ); std::copy( aNames.begin(), aNames.end(), _rBindingNames.begin() ); } @@ -590,7 +590,7 @@ namespace pcr xInfo = _rxProps->getPropertySetInfo(); if ( xInfo.is() ) { - Sequence< Property > aProperties = xInfo->getProperties(); + const Sequence< Property > aProperties = xInfo->getProperties(); std::for_each( aProperties.begin(), aProperties.end(), PropertyBagInserter( _rBag ) ); diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 940d7d48f379..b920a4262650 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -276,7 +276,7 @@ namespace pcr Reference< XIntrospectionAccess > xIntrospectionAccess( _rxIntrospection->inspect( makeAny( _rxComponent ) ), UNO_SET_THROW ); - Sequence< Type > aListeners( xIntrospectionAccess->getSupportedListeners() ); + const Sequence< Type > aListeners( xIntrospectionAccess->getSupportedListeners() ); std::copy( aListeners.begin(), aListeners.end(), std::insert_iterator< TypeBag >( _out_rTypes, _out_rTypes.begin() ) ); @@ -770,7 +770,7 @@ namespace pcr } // the initial selection in the dialog - Sequence< OUString > aNames( pEventHolder->getElementNames() ); + const Sequence< OUString > aNames( pEventHolder->getElementNames() ); const OUString* pChosenEvent = std::find( aNames.begin(), aNames.end(), rForEvent.sListenerMethodName ); sal_uInt16 nInitialSelection = static_cast<sal_uInt16>( pChosenEvent - aNames.begin() ); diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 1bea9150f14f..92c03d54e17c 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -1329,7 +1329,7 @@ namespace pcr std::vector< OUString > aListEntries; Reference< XDatabaseContext > xDatabaseContext = sdb::DatabaseContext::create( m_xContext ); - Sequence< OUString > aDatasources = xDatabaseContext->getElementNames(); + const Sequence< OUString > aDatasources = xDatabaseContext->getElementNames(); aListEntries.resize( aDatasources.getLength() ); std::copy( aDatasources.begin(), aDatasources.end(), aListEntries.begin() ); aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx index 984f951dfd58..485c6937c2f6 100644 --- a/extensions/source/propctrlr/genericpropertyhandler.cxx +++ b/extensions/source/propctrlr/genericpropertyhandler.cxx @@ -116,7 +116,7 @@ namespace pcr TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EnumRepresentation::getDescriptions" ); } - return std::vector< OUString >( aNames.begin(), aNames.end() ); + return std::vector< OUString >( std::cbegin(aNames), std::cend(aNames) ); } void EnumRepresentation::impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const @@ -162,7 +162,7 @@ namespace pcr Sequence< sal_Int32 > aValues; impl_getValues( aValues ); - sal_Int32 index = std::find( aValues.begin(), aValues.end(), nAsInt ) - aValues.begin(); + sal_Int32 index = std::find( std::cbegin(aValues), std::cend(aValues), nAsInt ) - std::cbegin(aValues); std::vector< OUString > aDescriptions( getDescriptions() ); if ( ( index >= 0 ) && ( index < static_cast<sal_Int32>(aDescriptions.size()) ) ) diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx index 3e28295d7348..073cbbedd130 100644 --- a/extensions/source/propctrlr/stringrepresentation.cxx +++ b/extensions/source/propctrlr/stringrepresentation.cxx @@ -255,7 +255,8 @@ void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & uno::Sequence< uno::Reference< reflection::XConstantTypeDescription > > cs(m_xTypeDescription->getConstants()); - std::sort(cs.begin(), cs.end(), CompareConstants()); + auto [begin, end] = toNonConstRange(cs); + std::sort(begin, end, CompareConstants()); m_aConstants = cs; } diff --git a/extensions/source/propctrlr/xsdvalidationhelper.cxx b/extensions/source/propctrlr/xsdvalidationhelper.cxx index 12197e87d0b3..390993de6aca 100644 --- a/extensions/source/propctrlr/xsdvalidationhelper.cxx +++ b/extensions/source/propctrlr/xsdvalidationhelper.cxx @@ -83,12 +83,13 @@ namespace pcr try { Reference< XDataTypeRepository > xRepository = getDataTypeRepository(); - Sequence< OUString > aElements; if ( xRepository.is() ) - aElements = xRepository->getElementNames(); + { + const Sequence<OUString> aElements = xRepository->getElementNames(); - _rNames.resize( aElements.getLength() ); - std::copy( aElements.begin(), aElements.end(), _rNames.begin() ); + _rNames.resize( aElements.getLength() ); + std::copy( aElements.begin(), aElements.end(), _rNames.begin() ); + } } catch( const Exception& ) { diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 91a22ea4ef3d..2f95f6331f01 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -313,8 +313,8 @@ namespace frm // copy to member ValueList().swap(m_aListSourceValues); ::std::copy( - aListSource.begin(), - aListSource.end(), + std::cbegin(aListSource), + std::cend(aListSource), ::std::insert_iterator< ValueList >( m_aListSourceValues, m_aListSourceValues.end() ) ); @@ -952,7 +952,7 @@ namespace frm Reference<XNameAccess> xFieldNames = getTableFields(xConnection, sListSource); if (xFieldNames.is()) { - css::uno::Sequence<OUString> seqNames = xFieldNames->getElementNames(); + const css::uno::Sequence<OUString> seqNames = xFieldNames->getElementNames(); ::std::copy( seqNames.begin(), seqNames.end(), @@ -1378,8 +1378,8 @@ namespace frm OSL_VERIFY( _rExternalValue >>= aSelectIndexesPure ); aSelectIndexes.realloc( aSelectIndexesPure.getLength() ); ::std::copy( - aSelectIndexesPure.begin(), - aSelectIndexesPure.end(), + std::cbegin(aSelectIndexesPure), + std::cend(aSelectIndexesPure), aSelectIndexes.getArray() ); } @@ -1590,8 +1590,8 @@ namespace frm // expects int's Sequence< sal_Int32 > aTransformed( aSelectSequence.getLength() ); ::std::copy( - aSelectSequence.begin(), - aSelectSequence.end(), + std::cbegin(aSelectSequence), + std::cend(aSelectSequence), aTransformed.getArray() ); aReturn <<= aTransformed; diff --git a/forms/source/component/propertybaghelper.cxx b/forms/source/component/propertybaghelper.cxx index 134cfe6e2b10..f5c77c707a99 100644 --- a/forms/source/component/propertybaghelper.cxx +++ b/forms/source/component/propertybaghelper.cxx @@ -256,7 +256,7 @@ namespace frm Reference< XMultiPropertySet > xMe( m_rContext.getPropertiesInterface(), css::uno::UNO_SET_THROW ); Reference< XPropertySetInfo > xPSI( xMe->getPropertySetInfo(), css::uno::UNO_SET_THROW ); - Sequence< Property > aProperties( xPSI->getProperties() ); + const Sequence< Property > aProperties( xPSI->getProperties() ); Sequence< OUString > aPropertyNames( aProperties.getLength() ); ::std::transform( aProperties.begin(), aProperties.end(), aPropertyNames.getArray(), SelectNameOfProperty() ); diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 41dbd7f3c086..837baa838dab 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -394,7 +394,8 @@ void OInterfaceContainer::transformEvents() if ( aChildEvents.hasElements() ) { // do the transformation - ::std::for_each( aChildEvents.begin(), aChildEvents.end(), TransformEventTo52Format() ); + auto [begin, end] = toNonConstRange(aChildEvents); + ::std::for_each( begin, end, TransformEventTo52Format() ); // revoke the script events m_xEventAttacher->revokeScriptEvents( i ); diff --git a/framework/qa/cppunit/dispatchtest.cxx b/framework/qa/cppunit/dispatchtest.cxx index 2f21a71b005e..9d2446b56ef3 100644 --- a/framework/qa/cppunit/dispatchtest.cxx +++ b/framework/qa/cppunit/dispatchtest.cxx @@ -124,8 +124,8 @@ uno::Reference<frame::XDispatch> MyInterceptor::queryDispatch(const util::URL& r const OUString& /*rTargetFrameName*/, sal_Int32 /*SearchFlags*/) { - if (std::find(m_aDisabledCommands.begin(), m_aDisabledCommands.end(), rURL.Complete) - != m_aDisabledCommands.end()) + if (std::find(std::cbegin(m_aDisabledCommands), std::cend(m_aDisabledCommands), rURL.Complete) + != std::cend(m_aDisabledCommands)) ++m_nExpected; else ++m_nUnexpected; diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 7b66409014b9..193504354306 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -3379,7 +3379,7 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL , } // re-create all the views - ::std::vector< OUString > aViewsToRestore( rInfo.ViewNames.begin(), rInfo.ViewNames.end() ); + ::std::vector< OUString > aViewsToRestore( std::cbegin(rInfo.ViewNames), std::cend(rInfo.ViewNames) ); // if we don't have views for whatever reason, then create a default-view, at least if ( aViewsToRestore.empty() ) aViewsToRestore.emplace_back( ); diff --git a/i18npool/qa/cppunit/test_ordinalsuffix.cxx b/i18npool/qa/cppunit/test_ordinalsuffix.cxx index fb06a41fa4b2..be21f38ca531 100644 --- a/i18npool/qa/cppunit/test_ordinalsuffix.cxx +++ b/i18npool/qa/cppunit/test_ordinalsuffix.cxx @@ -46,50 +46,36 @@ void TestOrdinalSuffix::tearDown() void TestOrdinalSuffix::testFrench() { lang::Locale aLocale("fr", "LU", ""); - uno::Sequence< OUString > aSuffixes; - OUString *pStart, *pEnd, *pFind; //1er - aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale); - pStart = aSuffixes.begin(); - pEnd = aSuffixes.end(); - pFind = std::find(pStart, pEnd, OUString("er")); - CPPUNIT_ASSERT(pFind != pEnd); + uno::Sequence<OUString> aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale); + const OUString* pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), OUString("er")); + CPPUNIT_ASSERT(pFind != std::cend(aSuffixes)); //2e, 3e, etc. aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale); - pStart = aSuffixes.begin(); - pEnd = aSuffixes.end(); - pFind = std::find(pStart, pEnd, OUString("e")); - CPPUNIT_ASSERT(pFind != pEnd); + pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), OUString("e")); + CPPUNIT_ASSERT(pFind != std::cend(aSuffixes)); } void TestOrdinalSuffix::testEnglish() { lang::Locale aLocale("en", "US", ""); - uno::Sequence< OUString > aSuffixes; - OUString *pStart, *pEnd, *pFind; //1st - aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale); - pStart = aSuffixes.begin(); - pEnd = aSuffixes.end(); - pFind = std::find(pStart, pEnd, OUString("st")); - CPPUNIT_ASSERT(pFind != pEnd); + uno::Sequence<OUString> aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale); + const OUString* pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), OUString("st")); + CPPUNIT_ASSERT(pFind != std::cend(aSuffixes)); //2nd aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale); - pStart = aSuffixes.begin(); - pEnd = aSuffixes.end(); - pFind = std::find(pStart, pEnd, OUString("nd")); - CPPUNIT_ASSERT(pFind != pEnd); + pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), OUString("nd")); + CPPUNIT_ASSERT(pFind != std::cend(aSuffixes)); //3rd aSuffixes = m_xOrdinal->getOrdinalSuffix(3, aLocale); - pStart = aSuffixes.begin(); - pEnd = aSuffixes.end(); - pFind = std::find(pStart, pEnd, OUString("rd")); - CPPUNIT_ASSERT(pFind != pEnd); + pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), OUString("rd")); + CPPUNIT_ASSERT(pFind != std::cend(aSuffixes)); } diff --git a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx index 4d09e9f88ef0..5a071a3887fa 100644 --- a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx @@ -77,7 +77,8 @@ ignoreIandEfollowedByYa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 sta if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - std::iota(pOffset->begin(), pOffset->end(), startPos); + auto [begin, end] = toNonConstRange(*pOffset); + std::iota(begin, end, startPos); } diff --git a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx index 22a600d51f41..bdee0d87d6fa 100644 --- a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx @@ -95,7 +95,8 @@ ignoreIterationMark_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 startPo if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - std::iota(pOffset->begin(), pOffset->end(), startPos); + auto [begin, end] = toNonConstRange(*pOffset); + std::iota(begin, end, startPos); } diff --git a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx index f54ff822e4e1..1c64d65104d9 100644 --- a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx @@ -38,7 +38,8 @@ ignoreKiKuFollowedBySa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 star if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - std::iota(pOffset->begin(), pOffset->end(), startPos); + auto [begin, end] = toNonConstRange(*pOffset); + std::iota(begin, end, startPos); } diff --git a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx index 4d7f8241a35a..fc87d206dc3e 100644 --- a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx @@ -300,7 +300,8 @@ ignoreProlongedSoundMark_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 st if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - std::iota(pOffset->begin(), pOffset->end(), startPos); + auto [begin, end] = toNonConstRange(*pOffset); + std::iota(begin, end, startPos); } diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx index 8649eccfc807..6a04ce8cd823 100644 --- a/i18npool/source/transliteration/transliterationImpl.cxx +++ b/i18npool/source/transliteration/transliterationImpl.cxx @@ -306,7 +306,7 @@ TransliterationImpl::transliterate( const OUString& inStr, sal_Int32 startPos, s tmpStr = bodyCascade[0]->transliterate(tmpStr, 0, nCount, offset); if ( startPos ) { - for (sal_Int32 & j : offset) + for (sal_Int32 & j : toNonConstRange(offset)) j += startPos; } return tmpStr; @@ -316,31 +316,22 @@ TransliterationImpl::transliterate( const OUString& inStr, sal_Int32 startPos, s { OUString tmpStr = inStr.copy(startPos, nCount); - std::iota(offset.begin(), offset.end(), startPos); + auto [begin, end] = toNonConstRange(offset); + std::iota(begin, end, startPos); - sal_Int16 from = 0, to = 1; - Sequence<sal_Int32> off[2]; - - off[to] = offset; - off[from].realloc(nCount); + Sequence<sal_Int32> from(nCount); + Sequence<sal_Int32> to = offset; for (sal_Int32 i = 0; i < numCascade; i++) { - tmpStr = bodyCascade[i]->transliterate(tmpStr, 0, nCount, off[from]); + tmpStr = bodyCascade[i]->transliterate(tmpStr, 0, nCount, from); nCount = tmpStr.getLength(); - assert(off[from].getLength() == nCount); - std::swap(from, to); - // tdf#89665: don't use operator[] to write - too slow! - // interestingly gcc 4.9 -Os won't even inline the const operator[] - sal_Int32 const*const pFrom(off[from].getConstArray()); - sal_Int32 *const pTo(off[to].getArray()); - for (sal_Int32 j = 0; j < nCount; j++) - { - assert(pTo[j] < off[from].getLength()); - pTo[j] = pFrom[pTo[j]]; - } + assert(from.getLength() == nCount); + from.swap(to); + for (sal_Int32& ix : toNonConstRange(to)) + ix = std::as_const(from)[ix]; } - offset = off[to]; + offset = to; return tmpStr; } } @@ -375,7 +366,8 @@ TransliterationImpl::folding( const OUString& inStr, sal_Int32 startPos, sal_Int { OUString tmpStr = inStr.copy(startPos, nCount); - std::iota(offset.begin(), offset.end(), startPos); + auto [begin, end] = toNonConstRange(offset); + std::iota(begin, end, startPos); sal_Int16 from = 0, to = 1; Sequence<sal_Int32> off[2]; diff --git a/i18npool/source/transliteration/transliteration_OneToOne.cxx b/i18npool/source/transliteration/transliteration_OneToOne.cxx index a030d558d3b8..34f4902f79bb 100644 --- a/i18npool/source/transliteration/transliteration_OneToOne.cxx +++ b/i18npool/source/transliteration/transliteration_OneToOne.cxx @@ -68,7 +68,8 @@ transliteration_OneToOne::transliterateImpl( const OUString& inStr, sal_Int32 st // Allocate nCount length to offset argument. if (pOffset) { pOffset->realloc( nCount ); - std::iota(pOffset->begin(), pOffset->end(), startPos); + auto [begin, end] = toNonConstRange(*pOffset); + std::iota(begin, end, startPos); } // Translation diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx index 1f4541082435..b0c710c6c696 100644 --- a/i18npool/source/transliteration/transliteration_body.cxx +++ b/i18npool/source/transliteration/transliteration_body.cxx @@ -260,8 +260,9 @@ static OUString transliterate_titlecase_Impl( xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, rLocale ); pOffset->realloc( aRes.getLength() ); - sal_Int32* pOffsetInt = std::fill_n(pOffset->begin(), nResolvedLen, 0); - std::iota(pOffsetInt, pOffset->end(), 1); + auto [begin, end] = toNonConstRange(*pOffset); + sal_Int32* pOffsetInt = std::fill_n(begin, nResolvedLen, 0); + std::iota(pOffsetInt, end, 1); } return aRes; } diff --git a/include/com/sun/star/uno/Sequence.h b/include/com/sun/star/uno/Sequence.h index 6b19af68d8a1..39caf8ff768f 100644 --- a/include/com/sun/star/uno/Sequence.h +++ b/include/com/sun/star/uno/Sequence.h @@ -265,6 +265,16 @@ public: */ uno_Sequence * SAL_CALL get() const { return _pSequence; } + +#if defined LIBO_INTERNAL_ONLY + /** Swaps sequences efficiently exchanging their underlying representations. + + @param other another sequence of same type + + @since LibreOffice 7.3 + */ + inline void swap(Sequence& other); +#endif }; // Find uses of illegal Sequence<bool> (instead of Sequence<sal_Bool>) during diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx index 26a51350815b..08a74d73789f 100644 --- a/include/com/sun/star/uno/Sequence.hxx +++ b/include/com/sun/star/uno/Sequence.hxx @@ -30,6 +30,7 @@ #if defined LIBO_INTERNAL_ONLY # include <type_traits> # include <ostream> +# include <utility> #endif #include "osl/interlck.h" @@ -203,6 +204,13 @@ inline void Sequence< E >::realloc( sal_Int32 nSize ) throw ::std::bad_alloc(); } +#if defined LIBO_INTERNAL_ONLY +template <class E> inline void Sequence<E>::swap(Sequence& other) +{ + std::swap(_pSequence, other._pSequence); +} +#endif + inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence( const ::rtl::ByteSequence & rByteSequence ) { @@ -271,6 +279,22 @@ inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, t return os; } +template <class E> inline auto toNonConstRange(css::uno::Sequence<E>& s) +{ + // Two iterators [begin, end] representing the non-const range of the Sequence. + // It only calls Sequence::getArray once, to avoid the second COW overhead when + // Sequence::begin() and Sequence::end() are called in pairs. + // Inheriting from pair allows to use std::tie to unpack the two iterators. + struct SequenceRange : public std::pair<E*, E*> + { + SequenceRange(E* ptr, sal_Int32 len) : std::pair<E*, E*>(ptr, ptr + len) {} + // These allow to pass it as range-expression to range-based for loops + E* begin() { return std::pair<E*, E*>::first; } + E* end() { return std::pair<E*, E*>::second; } + }; + return SequenceRange(s.begin(), s.getLength()); +}; + /// @endcond #endif diff --git a/include/vcl/FilterConfigItem.hxx b/include/vcl/FilterConfigItem.hxx index f1593b4db2c3..45692fedb01f 100644 --- a/include/vcl/FilterConfigItem.hxx +++ b/include/vcl/FilterConfigItem.hxx @@ -52,8 +52,8 @@ class VCL_DLLPUBLIC FilterConfigItem void ImpInitTree( std::u16string_view rTree ); - static css::beans::PropertyValue* GetPropertyValue( - css::uno::Sequence< css::beans::PropertyValue >& rPropSeq, + static const css::beans::PropertyValue* GetPropertyValue( + const css::uno::Sequence< css::beans::PropertyValue >& rPropSeq, const OUString& rName ); static bool WritePropertyValue( css::uno::Sequence< css::beans::PropertyValue >& rPropSeq, diff --git a/include/xmloff/XMLEventExport.hxx b/include/xmloff/XMLEventExport.hxx index d37cb6717399..48198032377f 100644 --- a/include/xmloff/XMLEventExport.hxx +++ b/include/xmloff/XMLEventExport.hxx @@ -111,7 +111,7 @@ private: /// export one event (start container-element if necessary) SAL_DLLPRIVATE void ExportEvent( - css::uno::Sequence<css::beans::PropertyValue>& rEventValues, + const css::uno::Sequence<css::beans::PropertyValue>& rEventValues, const XMLEventName& rXmlEventName, bool bUseWhitespace, bool& rExported); diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx index 63712d01b3ef..0fd655ced63c 100644 --- a/oox/source/crypto/AgileEngine.cxx +++ b/oox/source/crypto/AgileEngine.cxx @@ -504,7 +504,7 @@ bool AgileEngine::readEncryptionInfo(uno::Reference<io::XInputStream> & rxInputS uno::Sequence<sal_Int8> aReadReservedBytes(sizeof(sal_uInt32)); rxInputStream->readBytes(aReadReservedBytes, aReadReservedBytes.getLength()); - if (!std::equal(aReadReservedBytes.begin(), aReadReservedBytes.end(), aExpectedReservedBytes.begin())) + if (!std::equal(std::cbegin(aReadReservedBytes), std::cend(aReadReservedBytes), aExpectedReservedBytes.begin())) return false; mInfo.spinCount = 0; diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 452b5f5ef851..32736e67fad0 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -406,7 +406,7 @@ static void lcl_fillCategoriesIntoStringVector( if( xTextualDataSequence.is()) { rOutCategories.clear(); - Sequence< OUString > aTextData( xTextualDataSequence->getTextualData()); + const Sequence< OUString > aTextData( xTextualDataSequence->getTextualData()); rOutCategories.insert( rOutCategories.end(), aTextData.begin(), aTextData.end() ); } else @@ -425,7 +425,7 @@ static ::std::vector< double > lcl_getAllValuesFromSequence( const Reference< ch Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY ); if( xNumSeq.is()) { - Sequence< double > aValues( xNumSeq->getNumericalData()); + const Sequence< double > aValues( xNumSeq->getNumericalData()); aResult.insert( aResult.end(), aValues.begin(), aValues.end() ); } else if( xSeq.is()) diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx index 987ab3b809d1..d11d145bb764 100644 --- a/oox/source/helper/zipstorage.cxx +++ b/oox/source/helper/zipstorage.cxx @@ -110,10 +110,9 @@ Reference< XStorage > ZipStorage::implGetXStorage() const void ZipStorage::implGetElementNames( ::std::vector< OUString >& orElementNames ) const { - Sequence< OUString > aNames; if( mxStorage.is() ) try { - aNames = mxStorage->getElementNames(); + const Sequence<OUString> aNames = mxStorage->getElementNames(); if( aNames.hasElements() ) orElementNames.insert( orElementNames.end(), aNames.begin(), aNames.end() ); } diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx index 82aa1cd79fe8..32673fa699af 100644 --- a/oox/source/ole/olestorage.cxx +++ b/oox/source/ole/olestorage.cxx @@ -279,10 +279,9 @@ Reference< XStorage > OleStorage::implGetXStorage() const void OleStorage::implGetElementNames( ::std::vector< OUString >& orElementNames ) const { - Sequence< OUString > aNames; if( mxStorage.is() ) try { - aNames = mxStorage->getElementNames(); + const Sequence<OUString> aNames = mxStorage->getElementNames(); if( aNames.hasElements() ) orElementNames.insert( orElementNames.end(), aNames.begin(), aNames.end() ); } diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 6c0892ceecc3..f296561bf62e 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -1919,7 +1919,7 @@ void SAL_CALL OReportDefinition::setMimeType( const OUString& _mimetype ) { ::osl::MutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); - uno::Sequence< OUString > aList = getAvailableMimeTypes(); + const uno::Sequence< OUString > aList = getAvailableMimeTypes(); if ( ::std::find(aList.begin(), aList.end(), _mimetype) == aList.end() ) throwIllegallArgumentException("getAvailableMimeTypes()" ,*this diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 0b7410dd4d52..f02a510bcdeb 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -2096,7 +2096,7 @@ void SAL_CALL ScDPLevel::setPropertyValue( const OUString& aPropertyName, const uno::Sequence<sheet::GeneralFunction> aSeq; aValue >>= aSeq; aSubTotals.realloc(aSeq.getLength()); - std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(), + std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(), [](const sheet::GeneralFunction& rFunc) -> sal_Int16 { return static_cast<sal_Int16>(rFunc); }); } diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index 0545622cd43e..1598e1b69d0d 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -1365,9 +1365,9 @@ void ScUnoAddInCall::ExecuteCall() uno::Sequence<uno::Any> aRealArgs( nDestLen ); uno::Any* pDest = aRealArgs.getArray(); - pDest = std::copy_n(aArgs.begin(), nCallPos, pDest); + pDest = std::copy_n(std::cbegin(aArgs), nCallPos, pDest); *pDest = aCallerAny; - std::copy(std::next(aArgs.begin(), nCallPos), aArgs.end(), std::next(pDest)); + std::copy(std::next(std::cbegin(aArgs), nCallPos), std::cend(aArgs), std::next(pDest)); ExecuteCallWithArgs( aRealArgs ); } diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx index c4e8cc77d942..141802e076b8 100644 --- a/sc/source/core/tool/rangeseq.cxx +++ b/sc/source/core/tool/rangeseq.cxx @@ -365,7 +365,7 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const css::uno::Any & rAny ) sal_Int32 nMaxColCount = 0; if (nRowCount) { - auto pRow = std::max_element(aSequence.begin(), aSequence.end(), + auto pRow = std::max_element(std::cbegin(aSequence), std::cend(aSequence), [](const uno::Sequence<uno::Any>& a, const uno::Sequence<uno::Any>& b) { return a.getLength() < b.getLength(); }); nMaxColCount = pRow->getLength(); diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx index bc3856bd4afc..6a5669b7866a 100644 --- a/sc/source/filter/xml/xmlcvali.cxx +++ b/sc/source/filter/xml/xmlcvali.cxx @@ -362,10 +362,10 @@ void SAL_CALL ScXMLContentValidationContext::endFastElement( sal_Int32 /*nElemen uno::Sequence<beans::PropertyValue> aValues; pEvents->GetEventSequence( "OnError", aValues ); - auto pValue = std::find_if(aValues.begin(), aValues.end(), + auto pValue = std::find_if(std::cbegin(aValues), std::cend(aValues), [](const beans::PropertyValue& rValue) { return rValue.Name == "MacroName" || rValue.Name == "Script"; }); - if (pValue != aValues.end()) + if (pValue != std::cend(aValues)) pValue->Value >>= sErrorTitle; } diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index ed7e718cc5f0..a7a8d442533d 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -522,9 +522,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScAccessibleCell::getCharacterAtt sal_uInt16 nParaIndent = mpDoc->GetAttr( maCellAddress, ATTR_INDENT )->GetValue(); if (nParaIndent > 0) { - auto pAttrib = std::find_if(aAttribs.begin(), aAttribs.end(), + auto [begin, end] = toNonConstRange(aAttribs); + auto pAttrib = std::find_if(begin, end, [](const beans::PropertyValue& rAttrib) { return "ParaLeftMargin" == rAttrib.Name; }); - if (pAttrib != aAttribs.end()) + if (pAttrib != end) pAttrib->Value <<= nParaIndent; } return aAttribs; diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index 5425a65c6c6d..c81819b3027a 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -862,10 +862,11 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) * ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 ); aVariables.realloc( nVarPos + nAdd ); + auto it = aVariables.begin() + nVarPos; for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol) - aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow ); + *it++ = table::CellAddress( nTab, nCol, nRow ); } uno::Sequence<sheet::SolverConstraint> aConstraints; @@ -969,9 +970,8 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal // copy old document values sal_Int32 nVarCount = aVariables.getLength(); - uno::Sequence<double> aOldValues; - aOldValues.realloc( nVarCount ); - std::transform(aVariables.begin(), aVariables.end(), aOldValues.begin(), + uno::Sequence<double> aOldValues( nVarCount ); + std::transform(std::cbegin(aVariables), std::cend(aVariables), aOldValues.begin(), [this](const table::CellAddress& rVariable) -> double { ScAddress aCellPos; ScUnoConversion::FillScAddress( aCellPos, rVariable ); @@ -1026,7 +1026,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal for (nVarPos=0; nVarPos<nVarCount; ++nVarPos) { ScAddress aCellPos; - ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] ); + ScUnoConversion::FillScAddress( aCellPos, std::as_const(aVariables)[nVarPos] ); rFunc.SetValueCell(aCellPos, aSolution[nVarPos], false); } mpDocShell->UnlockPaint(); @@ -1064,7 +1064,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal { ScAddress aCellPos; ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] ); - rFunc.SetValueCell(aCellPos, aOldValues[nVarPos], false); + rFunc.SetValueCell(aCellPos, std::as_const(aOldValues)[nVarPos], false); } mpDocShell->UnlockPaint(); } diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 0b945a182419..dd85f6ff8ba5 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1713,7 +1713,7 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( const OUString& aPropertyNa if( aValue >>= aSeq) { std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength()); - std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(), + std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(), [](const sheet::GeneralFunction& rValue) -> ScGeneralFunction { const int nValAsInt = static_cast<int>(rValue); return static_cast<ScGeneralFunction>(nValAsInt); @@ -1727,7 +1727,7 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( const OUString& aPropertyNa if( aValue >>= aSeq ) { std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength()); - std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(), + std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(), [](sal_Int16 nValue) -> ScGeneralFunction { return static_cast<ScGeneralFunction>(nValue); }); setSubtotals( aSubTotals ); } @@ -2691,7 +2691,7 @@ bool lclExtractGroupMembers( ScFieldGroupMembers& rMembers, const Any& rElement if( rElement >>= aSeq ) { if( aSeq.hasElements() ) - rMembers.insert( rMembers.end(), aSeq.begin(), aSeq.end() ); + rMembers.insert( rMembers.end(), std::cbegin(aSeq), std::cend(aSeq) ); return true; } diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index cabe2fe375e8..fb23ab02fcc4 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -84,9 +84,10 @@ ScVbaWorkbook::Colors( const ::uno::Any& Index ) bool ScVbaWorkbook::setFilterPropsFromFormat( sal_Int32 nFormat, uno::Sequence< beans::PropertyValue >& rProps ) { - auto pProp = std::find_if(rProps.begin(), rProps.end(), + auto [begin, end] = toNonConstRange(rProps); + auto pProp = std::find_if(begin, end, [](const beans::PropertyValue& rProp) { return rProp.Name == "FilterName"; }); - bool bRes = pProp != rProps.end(); + bool bRes = pProp != end; if (bRes) { switch( nFormat ) diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx index d053fa11b809..688b4ef2140f 100644 --- a/scripting/source/basprov/basmethnode.cxx +++ b/scripting/source/basprov/basmethnode.cxx @@ -203,7 +203,7 @@ namespace basprov sDocURL = xModel->getURL(); if ( sDocURL.isEmpty() ) { - Sequence < PropertyValue > aProps = xModel->getArgs(); + const Sequence < PropertyValue > aProps = xModel->getArgs(); // TODO: according to MBA the property 'Title' may change in future const PropertyValue* pProp = std::find_if(aProps.begin(), aProps.end(), [](const PropertyValue& rProp) { return rProp.Name == "Title"; }); diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx index d3c1c1f0b394..1366f0d24f6b 100644 --- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx +++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx @@ -102,7 +102,7 @@ public: Sequence< Reference < browse::XBrowseNode > > result( numChildren ); sal_Int32 index = 0; - for ( Sequence< Reference < browse::XBrowseNode > >& children : seqs ) + for ( const Sequence< Reference < browse::XBrowseNode > >& children : seqs ) { std::copy(children.begin(), children.end(), std::next(result.begin(), index)); index += children.getLength(); diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx index f5bdfe1ac11b..be134725635e 100644 --- a/scripting/source/provider/ProviderCache.cxx +++ b/scripting/source/provider/ProviderCache.cxx @@ -144,7 +144,7 @@ ProviderCache::populateCache() Reference< lang::XSingleComponentFactory > factory( xEnum->nextElement(), UNO_QUERY_THROW ); Reference< lang::XServiceInfo > xServiceInfo( factory, UNO_QUERY_THROW ); - Sequence< OUString > serviceNames = xServiceInfo->getSupportedServiceNames(); + const Sequence< OUString > serviceNames = xServiceInfo->getSupportedServiceNames(); if ( serviceNames.hasElements() ) { diff --git a/scripting/source/provider/URIHelper.cxx b/scripting/source/provider/URIHelper.cxx index 9247f4b9fa98..3fa98db81355 100644 --- a/scripting/source/provider/URIHelper.cxx +++ b/scripting/source/provider/URIHelper.cxx @@ -142,7 +142,7 @@ ScriptingFrameworkURIHelper::initBaseURI() return false; } - uno::Sequence< OUString > children = + const uno::Sequence< OUString > children = m_xSimpleFileAccess->getFolderContents( uri, true ); auto pChild = std::find_if(children.begin(), children.end(), [&test](const OUString& child) { diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index b6cf579bd5de..9bc86023c2e8 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -393,7 +393,7 @@ ScriptEventHelper::getEventListeners() const for ( const Type& listType : aControlListeners ) { OUString sFullTypeName = listType.getTypeName(); - Sequence< OUString > sMeths = + const Sequence< OUString > sMeths = comphelper::getEventMethodsForType( listType ); std::transform(sMeths.begin(), sMeths.end(), std::back_inserter(eventMethods), [&sFullTypeName](const OUString& rMeth) -> OUString { return sFullTypeName + DELIM + rMeth; }); diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index 359b5215860b..4fc288f116c0 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -935,10 +935,10 @@ static bool getScaleXValue(const uno::Reference<beans::XPropertySet>& xSet) uno::Sequence<beans::PropertyValue> aTextPathProperties; aIterator->Value >>= aTextPathProperties; auto aIterator2 = std::find_if( - aTextPathProperties.begin(), aTextPathProperties.end(), + std::cbegin(aTextPathProperties), std::cend(aTextPathProperties), [](const beans::PropertyValue& rValue) { return rValue.Name == "ScaleX"; }); - if (aIterator2 != aTextPathProperties.end()) + if (aIterator2 != std::cend(aTextPathProperties)) { aIterator2->Value >>= bScaleX; } diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index d82a89e65da3..83a3e674e710 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -387,7 +387,7 @@ sal_Int32 CustomAnimationEffect::get_node_type( const Reference< XAnimationNode if( xNode.is() ) { - Sequence< NamedValue > aUserData( xNode->getUserData() ); + const Sequence< NamedValue > aUserData( xNode->getUserData() ); if( aUserData.hasElements() ) { const NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), @@ -418,17 +418,18 @@ void CustomAnimationEffect::setPresetClassAndId( sal_Int16 nPresetClass, const O bool bFoundPresetId = false; if( nLength ) { - NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), + auto [begin, end] = toNonConstRange(aUserData); + NamedValue* pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "preset-class"; }); - if (pProp != aUserData.end()) + if (pProp != end) { pProp->Value <<= mnPresetClass; bFoundPresetClass = true; } - pProp = std::find_if(aUserData.begin(), aUserData.end(), + pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "preset-id"; }); - if (pProp != aUserData.end()) + if (pProp != end) { pProp->Value <<= mnPresetClass; bFoundPresetId = true; @@ -439,16 +440,18 @@ void CustomAnimationEffect::setPresetClassAndId( sal_Int16 nPresetClass, const O if( !bFoundPresetClass ) { aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "preset-class"; - aUserData[nLength].Value <<= mnPresetClass; + auto& el = aUserData[nLength]; + el.Name = "preset-class"; + el.Value <<= mnPresetClass; ++nLength; } if( !bFoundPresetId && maPresetId.getLength() > 0 ) { aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "preset-id"; - aUserData[nLength].Value <<= maPresetId; + auto& el = aUserData[nLength]; + el.Name = "preset-id"; + el.Value <<= maPresetId; } mxNode->setUserData( aUserData ); @@ -470,9 +473,10 @@ void CustomAnimationEffect::setNodeType( sal_Int16 nNodeType ) bool bFound = false; if( nLength ) { - NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), + auto [begin, end] = toNonConstRange(aUserData); + NamedValue* pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "node-type"; }); - if (pProp != aUserData.end()) + if (pProp != end) { pProp->Value <<= mnNodeType; bFound = true; @@ -483,8 +487,9 @@ void CustomAnimationEffect::setNodeType( sal_Int16 nNodeType ) if( !bFound ) { aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "node-type"; - aUserData[nLength].Value <<= mnNodeType; + auto& el = aUserData[nLength]; + el.Name = "node-type"; + el.Value <<= mnNodeType; } mxNode->setUserData( aUserData ); @@ -503,9 +508,10 @@ void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId ) bool bFound = false; if( nLength ) { - NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), + auto [begin, end] = toNonConstRange(aUserData); + NamedValue* pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "group-id"; }); - if (pProp != aUserData.end()) + if (pProp != end) { pProp->Value <<= mnGroupId; bFound = true; @@ -516,8 +522,9 @@ void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId ) if( !bFound ) { aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "group-id"; - aUserData[nLength].Value <<= mnGroupId; + auto& el = aUserData[nLength]; + el.Name = "group-id"; + el.Value <<= mnGroupId; } mxNode->setUserData( aUserData ); @@ -1677,7 +1684,7 @@ CustomAnimationEffectPtr EffectSequenceHelper::append( const CustomAnimationPres std::vector< NamedValue > aNewUserData; Sequence< NamedValue > aUserData( xNode->getUserData() ); - std::copy_if(aUserData.begin(), aUserData.end(), std::back_inserter(aNewUserData), + std::copy_if(std::cbegin(aUserData), std::cend(aUserData), std::back_inserter(aNewUserData), [](const NamedValue& rProp) { return rProp.Name != "text-only" && rProp.Name != "preset-property"; }); if( !aNewUserData.empty() ) @@ -2972,7 +2979,7 @@ void EffectSequenceHelper::processAfterEffect( const Reference< XAnimationNode > { Reference< XAnimationNode > xMaster; - Sequence< NamedValue > aUserData( xNode->getUserData() ); + const Sequence< NamedValue > aUserData( xNode->getUserData() ); const NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), [](const NamedValue& rProp) { return rProp.Name == "master-element"; }); diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index 5147cb3cf0e0..0bb74770b732 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -123,7 +123,7 @@ CustomAnimationPreset::CustomAnimationPreset( const CustomAnimationEffectPtr& pE mfDuration = pEffect->getDuration(); maDefaultSubTyp = pEffect->getPresetSubType(); - Sequence< NamedValue > aUserData( pEffect->getNode()->getUserData() ); + const Sequence< NamedValue > aUserData( pEffect->getNode()->getUserData() ); mbIsTextOnly = std::any_of(aUserData.begin(), aUserData.end(), [](const NamedValue& rProp) { return rProp.Name == "text-only"; }); diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx index 19914e3498e4..992c5a1e0b7e 100644 --- a/sd/source/core/TransitionPreset.cxx +++ b/sd/source/core/TransitionPreset.cxx @@ -61,7 +61,7 @@ namespace sd { TransitionPreset::TransitionPreset( const css::uno::Reference< css::animations::XAnimationNode >& xNode ) { // first locate preset id - Sequence< NamedValue > aUserData( xNode->getUserData() ); + const Sequence< NamedValue > aUserData( xNode->getUserData() ); const NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), [](const NamedValue& rProp) { return rProp.Name == "preset-id"; }); if (pProp != aUserData.end()) diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 67c0758ec4d6..72298f94d951 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -305,7 +305,7 @@ bool SdStyleSheet::IsUsed() const cppu::OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( cppu::UnoType<XModifyListener>::get() ); if( pContainer ) { - Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() ); + const Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() ); bResult = std::any_of(aModifyListeners.begin(), aModifyListeners.end(), [](const Reference<XInterface>& rListener) { Reference< XStyle > xStyle( rListener, UNO_QUERY ); diff --git a/sd/source/filter/eppt/pptexanimations.cxx b/sd/source/filter/eppt/pptexanimations.cxx index 1b8f314dff38..1b455036b766 100644 --- a/sd/source/filter/eppt/pptexanimations.cxx +++ b/sd/source/filter/eppt/pptexanimations.cxx @@ -374,7 +374,7 @@ void AnimationExporter::processAfterEffectNodes( const Reference< XAnimationNode { Reference< XAnimationNode > xMaster; - Sequence< NamedValue > aUserData( xChildNode3->getUserData() ); + const Sequence< NamedValue > aUserData( xChildNode3->getUserData() ); const NamedValue* p = std::find_if(aUserData.begin(), aUserData.end(), [](const NamedValue& rProp) { return rProp.Name == "master-element"; }); diff --git a/sd/source/filter/html/HtmlOptionsDialog.cxx b/sd/source/filter/html/HtmlOptionsDialog.cxx index c7d2f7a8eb09..daa5e7362a39 100644 --- a/sd/source/filter/html/HtmlOptionsDialog.cxx +++ b/sd/source/filter/html/HtmlOptionsDialog.cxx @@ -123,16 +123,17 @@ Sequence< OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames() // XPropertyAccess Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues() { - auto pProp = std::find_if(maMediaDescriptor.begin(), maMediaDescriptor.end(), + auto pProp = std::find_if(std::cbegin(maMediaDescriptor), std::cend(maMediaDescriptor), [](const PropertyValue& rProp) { return rProp.Name == "FilterData"; }); - auto i = static_cast<sal_Int32>(std::distance(maMediaDescriptor.begin(), pProp)); + auto i = static_cast<sal_Int32>(std::distance(std::cbegin(maMediaDescriptor), pProp)); sal_Int32 nCount = maMediaDescriptor.getLength(); if ( i == nCount ) maMediaDescriptor.realloc( ++nCount ); // the "FilterData" Property is an Any that will contain our PropertySequence of Values - maMediaDescriptor[ i ].Name = "FilterData"; - maMediaDescriptor[ i ].Value <<= maFilterDataSequence; + auto& el = maMediaDescriptor[ i ]; + el.Name = "FilterData"; + el.Value <<= maFilterDataSequence; return maMediaDescriptor; } @@ -140,9 +141,9 @@ void SdHtmlOptionsDialog::setPropertyValues( const Sequence< PropertyValue > & a { maMediaDescriptor = aProps; - auto pProp = std::find_if(maMediaDescriptor.begin(), maMediaDescriptor.end(), + auto pProp = std::find_if(std::cbegin(maMediaDescriptor), std::cend(maMediaDescriptor), [](const PropertyValue& rProp) { return rProp.Name == "FilterData"; }); - if (pProp != maMediaDescriptor.end()) + if (pProp != std::cend(maMediaDescriptor)) pProp->Value >>= maFilterDataSequence; } diff --git a/sd/source/ui/framework/configuration/ResourceId.cxx b/sd/source/ui/framework/configuration/ResourceId.cxx index 48a6d360f5f2..9afc594cd7e9 100644 --- a/sd/source/ui/framework/configuration/ResourceId.cxx +++ b/sd/source/ui/framework/configuration/ResourceId.cxx @@ -362,7 +362,7 @@ void SAL_CALL ResourceId::initialize (const Sequence<Any>& aArguments) if (xAnchor.is()) { maResourceURLs.push_back(xAnchor->getResourceURL()); - Sequence<OUString> aAnchorURLs (xAnchor->getAnchorURLs()); + const Sequence<OUString> aAnchorURLs (xAnchor->getAnchorURLs()); maResourceURLs.insert( maResourceURLs.end(), aAnchorURLs.begin(), aAnchorURLs.end() ); } } diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index 1a53e682eca6..d1942df124c8 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -247,7 +247,7 @@ std::vector< std::shared_ptr< ClientInfo > > RemoteServer::getClients() // TODO: we should probably add some sort of extra labelling to mark // authorised AND connected client. Reference< XNameAccess > const xConfig = officecfg::Office::Impress::Misc::AuthorisedRemotes::get(); - Sequence< OUString > aNames = xConfig->getElementNames(); + const Sequence< OUString > aNames = xConfig->getElementNames(); std::transform(aNames.begin(), aNames.end(), std::back_inserter(aClients), [](const OUString& rName) -> std::shared_ptr<ClientInfo> { return std::make_shared<ClientInfo>(rName, true); }); diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 897aed6f1524..7cc5a58b8da5 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -873,9 +873,9 @@ OUString ViewShellBase::GetInitialViewShellType() const // Search the properties for the one that tells us what page kind to // use. - auto pProperty = std::find_if(aProperties.begin(), aProperties.end(), + auto pProperty = std::find_if(std::cbegin(aProperties), std::cend(aProperties), [](const beans::PropertyValue& rProperty) { return rProperty.Name == sUNO_View_PageKind; }); - if (pProperty != aProperties.end()) + if (pProperty != std::cend(aProperties)) { sal_Int16 nPageKind = 0; pProperty->Value >>= nPageKind; diff --git a/sdext/source/minimizer/fileopendialog.cxx b/sdext/source/minimizer/fileopendialog.cxx index aab29c03907b..ef0dbf4b4a43 100644 --- a/sdext/source/minimizer/fileopendialog.cxx +++ b/sdext/source/minimizer/fileopendialog.cxx @@ -114,9 +114,9 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext if ( xTypes->getByName( rFilterEntry.maType ) >>= aTypeProperties ) { Sequence< OUString > aExtensions; - auto pProp = std::find_if(aTypeProperties.begin(), aTypeProperties.end(), + auto pProp = std::find_if(std::cbegin(aTypeProperties), std::cend(aTypeProperties), [](const PropertyValue& rProp) { return rProp.Name == "Extensions"; }); - if (pProp != aTypeProperties.end()) + if (pProp != std::cend(aTypeProperties)) pProp->Value >>= aExtensions; if ( aExtensions.hasElements() ) { diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx index ab30f08ebe90..a53f28e868ef 100644 --- a/sdext/source/presenter/PresenterScreen.cxx +++ b/sdext/source/presenter/PresenterScreen.cxx @@ -141,9 +141,9 @@ Any SAL_CALL PresenterScreenJob::execute( pArg->Value >>= lEnv; Reference<frame::XModel2> xModel; - auto pProp = std::find_if(lEnv.begin(), lEnv.end(), + auto pProp = std::find_if(std::cbegin(lEnv), std::cend(lEnv), [](const beans::NamedValue& rProp) { return rProp.Name == "Model"; }); - if (pProp != lEnv.end()) + if (pProp != std::cend(lEnv)) pProp->Value >>= xModel; Reference< XServiceInfo > xInfo( xModel, UNO_QUERY ); diff --git a/sdext/source/presenter/PresenterTheme.cxx b/sdext/source/presenter/PresenterTheme.cxx index c29e8e0de8a2..c84747d0f360 100644 --- a/sdext/source/presenter/PresenterTheme.cxx +++ b/sdext/source/presenter/PresenterTheme.cxx @@ -323,7 +323,7 @@ bool PresenterTheme::ConvertToColor ( Sequence<sal_Int8> aByteSequence; if (rColorSequence >>= aByteSequence) { - rColor = std::accumulate(aByteSequence.begin(), aByteSequence.end(), sal_uInt32(0), + rColor = std::accumulate(std::cbegin(aByteSequence), std::cend(aByteSequence), sal_uInt32(0), [](const sal_uInt32 nRes, const sal_uInt8 nByte) { return (nRes << 8) | nByte; }); return true; } diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 5936accbfedb..4bae1c14a570 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -882,7 +882,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) Sequence < OUString > aTmp; aRet >>= aTmp; - aProtocols.insert(aProtocols.end(),aTmp.begin(),aTmp.end()); + aProtocols.insert(aProtocols.end(),std::cbegin(aTmp),std::cend(aTmp)); } } @@ -1037,11 +1037,11 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) // Any Referer (that was relevant in the above call to // SvtSecurityOptions::isSecureMacroUri) is no longer relevant, assuming // this "open" request is initiated directly by the user: - auto pArg = std::find_if(aArgs.begin(), aArgs.end(), + auto pArg = std::find_if(std::cbegin(aArgs), std::cend(aArgs), [](const PropertyValue& rArg) { return rArg.Name == "Referer"; }); - if (pArg != aArgs.end()) + if (pArg != std::cend(aArgs)) { - auto nIndex = static_cast<sal_Int32>(std::distance(aArgs.begin(), pArg)); + auto nIndex = static_cast<sal_Int32>(std::distance(std::cbegin(aArgs), pArg)); comphelper::removeElementAt(aArgs, nIndex); } diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 5f0b3f7f60ff..039b85bb1e27 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -473,9 +473,9 @@ OUString SfxHelp::GetHelpModuleName_Impl(std::u16string_view rHelpID) ModuleManager::create(::comphelper::getProcessComponentContext()) ); Sequence< PropertyValue > lProps; xModuleManager->getByName( aModuleIdentifier ) >>= lProps; - auto pProp = std::find_if(lProps.begin(), lProps.end(), + auto pProp = std::find_if(std::cbegin(lProps), std::cend(lProps), [](const PropertyValue& rProp) { return rProp.Name == "ooSetupFactoryShortName"; }); - if (pProp != lProps.end()) + if (pProp != std::cend(lProps)) pProp->Value >>= aFactoryShortName; } catch (const Exception&) diff --git a/sfx2/source/control/charmapcontrol.cxx b/sfx2/source/control/charmapcontrol.cxx index b86cc52111ee..032306b8a85f 100644 --- a/sfx2/source/control/charmapcontrol.cxx +++ b/sfx2/source/control/charmapcontrol.cxx @@ -119,11 +119,11 @@ SfxCharmapCtrl::~SfxCharmapCtrl() void SfxCharmapCtrl::getFavCharacterList() { //retrieve recent character list - css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() ); + const css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() ); m_aFavCharList.insert( m_aFavCharList.end(), rFavCharList.begin(), rFavCharList.end() ); //retrieve recent character font list - css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() ); + const css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() ); m_aFavCharFontList.insert( m_aFavCharFontList.end(), rFavCharFontList.begin(), rFavCharFontList.end() ); // tdf#135997: make sure that the two lists are same length @@ -158,11 +158,11 @@ void SfxCharmapCtrl::updateFavCharControl() void SfxCharmapCtrl::getRecentCharacterList() { //retrieve recent character list - css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() ); + const css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() ); m_aRecentCharList.insert( m_aRecentCharList.end(), rRecentCharList.begin(), rRecentCharList.end() ); //retrieve recent character font list - css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() ); + const css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() ); m_aRecentCharFontList.insert( m_aRecentCharFontList.end(), rRecentCharFontList.begin(), rRecentCharFontList.end() ); // tdf#135997: make sure that the two lists are same length diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index 53f622554d62..253932bb2632 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -68,7 +68,7 @@ OUString enumValueToEnumName(uno::Any const& aValue, xTypeDescription.set(xManager->getByHierarchicalName(aValue.getValueType().getTypeName()), uno::UNO_QUERY); - uno::Sequence<sal_Int32> aValues = xTypeDescription->getEnumValues(); + const uno::Sequence<sal_Int32> aValues = xTypeDescription->getEnumValues(); sal_Int32 nValuesIndex = std::find(aValues.begin(), aValues.end(), nIntValue) - aValues.begin(); uno::Sequence<OUString> aNames = xTypeDescription->getEnumNames(); return aNames[nValuesIndex]; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 6bf8fc9b6036..1cede475db43 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -608,7 +608,7 @@ void FileDialogHelper_Impl::updateVersions() if ( !xStorage.is() ) throw uno::RuntimeException(); - uno::Sequence < util::RevisionTag > xVersions = SfxMedium::GetVersionList( xStorage ); + const uno::Sequence < util::RevisionTag > xVersions = SfxMedium::GetVersionList( xStorage ); aEntries.realloc( xVersions.getLength() + 1 ); aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ); diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx index 86946325c8f9..aa2a8a930e8f 100644 --- a/sfx2/source/dialog/filtergrouping.cxx +++ b/sfx2/source/dialog/filtergrouping.cxx @@ -241,8 +241,8 @@ namespace sfx2 // are returned from the configuration - it is completely undefined, and we need a _defined_ order. FilterClassReferrer aClassReferrer; ::std::for_each( - aGlobalClasses.begin(), - aGlobalClasses.end(), + std::cbegin(aGlobalClasses), + std::cend(aGlobalClasses), CreateEmptyClassRememberPos( _rGlobalClasses, aClassReferrer ) ); // now _rGlobalClasses contains a dummy entry for each global class, @@ -253,7 +253,7 @@ namespace sfx2 // go for all the single class entries OConfigurationNode aFilterClassesNode = _rFilterClassification.openNode( "GlobalFilters/Classes" ); - Sequence< OUString > aFilterClasses = aFilterClassesNode.getNodeNames(); + const Sequence< OUString > aFilterClasses = aFilterClassesNode.getNodeNames(); ::std::for_each( aFilterClasses.begin(), aFilterClasses.end(), @@ -297,7 +297,7 @@ namespace sfx2 // the node for the local classes OConfigurationNode aFilterClassesNode = _rFilterClassification.openNode( "LocalFilters/Classes" ); - Sequence< OUString > aFilterClasses = aFilterClassesNode.getNodeNames(); + const Sequence< OUString > aFilterClasses = aFilterClassesNode.getNodeNames(); ::std::for_each( aFilterClasses.begin(), diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index f361d92b858d..503efaae7ecf 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -175,7 +175,7 @@ SfxMailModel::SaveResult SfxMailModel::ShowFilterOptionsDialog( if( xFilterDialog->execute() ) { //get the filter data - uno::Sequence< beans::PropertyValue > aPropsFromDialog = xFilterProperties->getPropertyValues(); + const uno::Sequence< beans::PropertyValue > aPropsFromDialog = xFilterProperties->getPropertyValues(); //add them to the args auto pProp = std::find_if(aPropsFromDialog.begin(), aPropsFromDialog.end(), diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 4e21ee41d1c6..43730796eb3e 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3723,11 +3723,11 @@ void SfxMedium::RemoveVersion_Impl( const OUString& rName ) if ( !pImpl->aVersions.hasElements() ) return; - auto pVersion = std::find_if(pImpl->aVersions.begin(), pImpl->aVersions.end(), + auto pVersion = std::find_if(std::cbegin(pImpl->aVersions), std::cend(pImpl->aVersions), [&rName](const auto& rVersion) { return rVersion.Identifier == rName; }); - if (pVersion != pImpl->aVersions.end()) + if (pVersion != std::cend(pImpl->aVersions)) { - auto nIndex = static_cast<sal_Int32>(std::distance(pImpl->aVersions.begin(), pVersion)); + auto nIndex = static_cast<sal_Int32>(std::distance(std::cbegin(pImpl->aVersions), pVersion)); comphelper::removeElementAt(pImpl->aVersions, nIndex); } } diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index f9b757bac8ed..04fbea3cce7c 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -170,7 +170,7 @@ static void impl_FillURLList( sfx2::FileDialogHelper const * _pFileDlg, std::vec { DBG_ASSERT( _pFileDlg, "DocumentInserter::fillURLList(): invalid file dialog" ); - Sequence < OUString > aPathSeq = _pFileDlg->GetSelectedFiles(); + const Sequence < OUString > aPathSeq = _pFileDlg->GetSelectedFiles(); if ( aPathSeq.hasElements() ) { diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 57865df82b43..3a2b5a7b3da9 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -545,9 +545,9 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName ) uno::Any aAny = m_pOwner->GetFilterConfiguration()->getByName( aFilterName ); if ( aAny >>= aProps ) { - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const beans::PropertyValue& rProp) { return rProp.Name == "UIComponent"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) { OUString aServiceName; pProp->Value >>= aServiceName; diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 91e338413410..07d889a4f47b 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1807,7 +1807,7 @@ bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor || nScriptingSignatureState == SignatureState::OK || nScriptingSignatureState == SignatureState::NOTVALIDATED ) { - uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.GetDocumentSignatureInformation( true, xSigner ); + const uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.GetDocumentSignatureInformation( true, xSigner ); if ( aInfo.hasElements() ) { diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 66f730af70b3..1182ad519d22 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1297,7 +1297,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) { bool bShow = false; Reference< XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY ); - uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties( ); + const uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties( ); if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) ) { diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index e7c9001e5b49..3b8f347d7250 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -872,9 +872,9 @@ ErrCode SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell const * Any aAny = xFilterCFG->getByName( pFilter->GetName() ); if ( aAny >>= aProps ) { - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const PropertyValue& rProp) { return rProp.Name == "UIComponent"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) { OUString aServiceName; pProp->Value >>= aServiceName; @@ -2179,9 +2179,9 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, } OUString aFilterImplName; - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const beans::PropertyValue& rFilterProp) { return rFilterProp.Name == "FilterService"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) pProp->Value >>= aFilterImplName; uno::Reference< document::XFilter > xLoader; @@ -2358,9 +2358,9 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) xFilters->getByName( aFilterName ) >>= aProps; OUString aFilterImplName; - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const beans::PropertyValue& rFilterProp) { return rFilterProp.Name == "FilterService"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) pProp->Value >>= aFilterImplName; if ( !aFilterImplName.isEmpty() ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 75a5c732eecc..254ccec4e3c7 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -534,8 +534,8 @@ namespace { Sequence< uno::Type > aStrippedTypes( io_rTypes.getLength() - 1 ); ::std::remove_copy_if( - io_rTypes.begin(), - io_rTypes.end(), + std::cbegin(io_rTypes), + std::cend(io_rTypes), aStrippedTypes.getArray(), [&i_rTypeToStrip](const uno::Type& aType) { return aType == i_rTypeToStrip; } ); @@ -1026,7 +1026,7 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< for ( const auto& rOrg : std::as_const(m_pData->m_seqArguments) ) { - auto bNew = std::none_of(seqArgsOld.begin(), seqArgsOld.end(), + auto bNew = std::none_of(std::cbegin(seqArgsOld), std::cend(seqArgsOld), [&rOrg](const beans::PropertyValue& rOld){ return rOld.Name == rOrg.Name; }); if ( bNew ) { @@ -2792,9 +2792,10 @@ SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium ) static void addTitle_Impl( Sequence < beans::PropertyValue >& rSeq, const OUString& rTitle ) { - auto pProp = std::find_if(rSeq.begin(), rSeq.end(), + auto [begin, end] = toNonConstRange(rSeq); + auto pProp = std::find_if(begin, end, [](const beans::PropertyValue& rProp) { return rProp.Name == "Title"; }); - if (pProp != rSeq.end()) + if (pProp != end) { pProp->Value <<= rTitle; } @@ -2802,8 +2803,9 @@ static void addTitle_Impl( Sequence < beans::PropertyValue >& rSeq, const OUStri { sal_Int32 nCount = rSeq.getLength(); rSeq.realloc( nCount+1 ); - rSeq[nCount].Name = "Title"; - rSeq[nCount].Value <<= rTitle; + auto& el = rSeq[nCount]; + el.Name = "Title"; + el.Value <<= rTitle; } } diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index 6c3452e70fc3..51a48642586e 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -740,7 +740,7 @@ void ResourceManager::GetToolPanelNodeNames ( std::vector<OUString>& rMatchingNames, const utl::OConfigurationTreeRoot& aRoot) { - Sequence<OUString> aChildNodeNames (aRoot.getNodeNames()); + const Sequence<OUString> aChildNodeNames (aRoot.getNodeNames()); std::copy_if(aChildNodeNames.begin(), aChildNodeNames.end(), std::back_inserter(rMatchingNames), [](const OUString& rChildNodeName) { return rChildNodeName.startsWith( "private:resource/toolpanel/" ); }); } diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index 0d7ba20396b8..476d384f897c 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -523,7 +523,7 @@ void SmXMLExport::GetConfigurationSettings(Sequence<PropertyValue>& rProps) if (!xPropertySetInfo.is()) return; - Sequence<Property> aProps = xPropertySetInfo->getProperties(); + const Sequence<Property> aProps = xPropertySetInfo->getProperties(); const sal_Int32 nCount = aProps.getLength(); if (!nCount) return; @@ -533,7 +533,7 @@ void SmXMLExport::GetConfigurationSettings(Sequence<PropertyValue>& rProps) const bool bUsedSymbolsOnly = pConfig && pConfig->IsSaveOnlyUsedSymbols(); std::transform(aProps.begin(), aProps.end(), rProps.begin(), - [bUsedSymbolsOnly, &xProps](Property& prop) { + [bUsedSymbolsOnly, &xProps](const Property& prop) { PropertyValue aRet; if (prop.Name != "Formula" && prop.Name != "BasicLibraries" && prop.Name != "DialogLibraries" && prop.Name != "RuntimeUID") diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index 90c9d462db71..bfd19ccd07e4 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -254,7 +254,7 @@ OUString searchLinkTargetForImpl(const Reference < XRegistryKey >& xRootKey, if (xKey.is()) { - Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys(); + const Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys(); OUString qualifiedLinkName( slash_UNO + linkName ); @@ -283,7 +283,7 @@ void createUniqueSubEntry(const Reference < XRegistryKey > & xSuperKey, if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST) { - Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); + const Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); bool bReady = comphelper::findValue(implEntries, value) != -1; @@ -320,7 +320,7 @@ bool deleteSubEntry(const Reference < XRegistryKey >& xSuperKey, const OUString& { if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST) { - Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); + const Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); sal_Int32 equals = static_cast<sal_Int32>(std::count(implEntries.begin(), implEntries.end(), value)); bool hasNoImplementations = false; @@ -423,7 +423,7 @@ void deleteUserLink(const Reference < XRegistryKey >& xRootKey, { if (xOldKey->getValueType() == RegistryValueType_ASCIILIST) { - Sequence<OUString> implEntries = xOldKey->getAsciiListValue(); + const Sequence<OUString> implEntries = xOldKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); sal_Int32 equals = static_cast<sal_Int32>(std::count(implEntries.begin(), implEntries.end(), implName)); bool hasNoImplementations = false; @@ -438,20 +438,21 @@ void deleteUserLink(const Reference < XRegistryKey >& xRootKey, if (length > equals + 1) { Sequence<OUString> implEntriesNew(length - equals - 1); + auto pNewArray = implEntriesNew.getArray(); sal_Int32 j = 0; bool first = true; for (sal_Int32 i = 0; i < length; i++) { - if (implEntries.getConstArray()[i] != implName) + if (implEntries[i] != implName) { if (first) { - oldImpl = implEntries.getConstArray()[i]; + oldImpl = implEntries[i]; first = false; } else { - implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i]; + pNewArray[j++] = implEntries[i]; } } } @@ -459,7 +460,7 @@ void deleteUserLink(const Reference < XRegistryKey >& xRootKey, xOldKey->setAsciiListValue(implEntriesNew); } else { - oldImpl = implEntries.getConstArray()[0]; + oldImpl = implEntries[0]; OUString path(xOldKey->getKeyName()); xOldKey->closeKey(); xRootKey->deleteKey(path); @@ -727,7 +728,7 @@ void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xReg, { if (xServiceKey->getValueType() == RegistryValueType_ASCIILIST) { - Sequence<OUString> implEntries = xServiceKey->getAsciiListValue(); + const Sequence<OUString> implEntries = xServiceKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); sal_Int32 equals = static_cast<sal_Int32>(std::count(implEntries.begin(), implEntries.end(), implName)); @@ -779,7 +780,7 @@ bool is_supported_service( { if (xService_td->getName() == service_name) return true; - Sequence< Reference< reflection::XServiceTypeDescription > > seq( + const Sequence< Reference< reflection::XServiceTypeDescription > > seq( xService_td->getMandatoryServices() ); return std::any_of(seq.begin(), seq.end(), [&service_name](const auto& rService) { return is_supported_service( service_name, rService ); }); diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index d07cb9c906d5..aa1440bb4b7d 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -92,7 +92,7 @@ typedef WeakImplHelper< XIntrospectionAccess, XMaterialHolder, XExactName, // Method to assert, if a class is derived from another class bool isDerivedFrom( const Reference<XIdlClass>& xToTestClass, const Reference<XIdlClass>& xDerivedFromClass ) { - Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses(); + const Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses(); return std::any_of(aClassesSeq.begin(), aClassesSeq.end(), [&xDerivedFromClass](const Reference<XIdlClass>& rxClass) { @@ -2275,7 +2275,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( // Option 1: Search for parameters for a listener class // Disadvantage: Superclasses should be searched recursively - Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes(); + const Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes(); css::uno::Reference<css::reflection::XIdlClass> xEventListenerClass( diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 4874c20750ce..6d4db16effe3 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -669,7 +669,7 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& OutIndices.realloc( nOutIndex ); OutParams.realloc( nOutIndex ); - std::transform(OutIndices.begin(), OutIndices.end(), OutParams.begin(), + std::transform(std::cbegin(OutIndices), std::cend(OutIndices), OutParams.begin(), [&pInvokeParams](const sal_Int16 nIndex) -> Any { return pInvokeParams[nIndex]; }); return aRet; diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index e38b9db609ae..3e50aed3953a 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -81,7 +81,7 @@ Sequence< OUString > retrieveAsciiValueList( xEnum->nextElement() >>= xTempReg; if( xTempReg.is() ) { - Sequence< OUString > seq2 = retrieveAsciiValueList( xTempReg, keyName ); + const Sequence< OUString > seq2 = retrieveAsciiValueList( xTempReg, keyName ); if( seq2.hasElements() ) { @@ -194,7 +194,7 @@ beans::Property PropertySetInfo_Impl::getPropertyByName( OUString const & name ) sal_Bool PropertySetInfo_Impl::hasPropertyByName( OUString const & name ) { - return std::any_of(m_properties.begin(), m_properties.end(), + return std::any_of(std::cbegin(m_properties), std::cend(m_properties), [&name](const beans::Property& rProp) { return rProp.Name == name; }); } @@ -1327,7 +1327,7 @@ void ORegistryServiceManager::fillAllNamesFromRegistry( HashSet_OWString & rSet if( xServicesKey.is() ) { sal_Int32 nPrefix = xServicesKey->getKeyName().getLength() +1; - Sequence<Reference<XRegistryKey > > aKeys = xServicesKey->openKeys(); + const Sequence<Reference<XRegistryKey > > aKeys = xServicesKey->openKeys(); std::transform(aKeys.begin(), aKeys.end(), std::inserter(rSet, rSet.end()), [nPrefix](const Reference<XRegistryKey>& rKey) -> OUString { return rKey->getKeyName().copy( nPrefix ); }); diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx index 43a6d19351c2..3e6affd8b83d 100644 --- a/svl/source/config/asiancfg.cxx +++ b/svl/source/config/asiancfg.cxx @@ -98,7 +98,7 @@ void SvxAsianConfig::SetCharDistanceCompression(CharCompressType value) { css::uno::Sequence< css::lang::Locale > SvxAsianConfig::GetStartEndCharLocales() const { - css::uno::Sequence< OUString > ns( + const css::uno::Sequence< OUString > ns( officecfg::Office::Common::AsianLayout::StartEndCharacters::get( impl_->context)-> getElementNames()); diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index ed3499210e02..6b385f4e7854 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -2351,10 +2351,10 @@ sal_Int32 SvNumberFormatter::ImpGetFormatCodeIndex( css::uno::Sequence< css::i18n::NumberFormatCode >& rSeq, const NfIndexTableOffset nTabOff ) { - auto pSeq = std::find_if(rSeq.begin(), rSeq.end(), + auto pSeq = std::find_if(std::cbegin(rSeq), std::cend(rSeq), [nTabOff](const css::i18n::NumberFormatCode& rCode) { return rCode.Index == nTabOff; }); - if (pSeq != rSeq.end()) - return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq)); + if (pSeq != std::cend(rSeq)) + return static_cast<sal_Int32>(std::distance(std::cbegin(rSeq), pSeq)); if (LocaleDataWrapper::areChecksEnabled() && (nTabOff < NF_CURRENCY_START || NF_CURRENCY_END < nTabOff || nTabOff == NF_CURRENCY_1000INT || nTabOff == NF_CURRENCY_1000INT_RED @@ -2367,24 +2367,24 @@ sal_Int32 SvNumberFormatter::ImpGetFormatCodeIndex( if ( rSeq.hasElements() ) { // look for a preset default - pSeq = std::find_if(rSeq.begin(), rSeq.end(), + pSeq = std::find_if(std::cbegin(rSeq), std::cend(rSeq), [](const css::i18n::NumberFormatCode& rCode) { return rCode.Default; }); - if (pSeq != rSeq.end()) - return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq)); + if (pSeq != std::cend(rSeq)) + return static_cast<sal_Int32>(std::distance(std::cbegin(rSeq), pSeq)); // currencies are special, not all format codes must exist, but all // builtin number format key index positions must have a format assigned if ( NF_CURRENCY_START <= nTabOff && nTabOff <= NF_CURRENCY_END ) { // look for a format with decimals - pSeq = std::find_if(rSeq.begin(), rSeq.end(), + pSeq = std::find_if(std::cbegin(rSeq), std::cend(rSeq), [](const css::i18n::NumberFormatCode& rCode) { return rCode.Index == NF_CURRENCY_1000DEC2; }); - if (pSeq != rSeq.end()) - return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq)); + if (pSeq != std::cend(rSeq)) + return static_cast<sal_Int32>(std::distance(std::cbegin(rSeq), pSeq)); // last resort: look for a format without decimals - pSeq = std::find_if(rSeq.begin(), rSeq.end(), + pSeq = std::find_if(std::cbegin(rSeq), std::cend(rSeq), [](const css::i18n::NumberFormatCode& rCode) { return rCode.Index == NF_CURRENCY_1000INT; }); - if (pSeq != rSeq.end()) - return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq)); + if (pSeq != std::cend(rSeq)) + return static_cast<sal_Int32>(std::distance(std::cbegin(rSeq), pSeq)); } } else @@ -4044,7 +4044,7 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( bool & bFoundBank, void SvNumberFormatter::GetCompatibilityCurrency( OUString& rSymbol, OUString& rAbbrev ) const { ::osl::MutexGuard aGuard( GetInstanceMutex() ); - css::uno::Sequence< css::i18n::Currency2 > + const css::uno::Sequence< css::i18n::Currency2 > xCurrencies( xLocaleData->getAllCurrencies() ); auto pCurrency = std::find_if(xCurrencies.begin(), xCurrencies.end(), diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index c7364e4bc995..34e439ee4921 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -3405,7 +3405,7 @@ void SvNumberformat::SwitchToOtherCalendar( OUString& rOrgCalendar, return; using namespace ::com::sun::star::i18n; - css::uno::Sequence< OUString > xCals = rCal.getAllCalendars( + const css::uno::Sequence< OUString > xCals = rCal.getAllCalendars( rLoc().getLanguageTag().getLocale() ); sal_Int32 nCnt = xCals.getLength(); if ( nCnt <= 1 ) diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx index cbe36add1bb2..c483a78b75cd 100644 --- a/svl/source/passwordcontainer/passwordcontainer.cxx +++ b/svl/source/passwordcontainer/passwordcontainer.cxx @@ -182,7 +182,7 @@ PasswordMap StorageItem::getInfo() { PasswordMap aResult; - Sequence< OUString > aNodeNames = ConfigItem::GetNodeNames( "Store" ); + const Sequence< OUString > aNodeNames = ConfigItem::GetNodeNames( "Store" ); sal_Int32 aNodeCount = aNodeNames.getLength(); Sequence< OUString > aPropNames( aNodeCount ); diff --git a/svl/source/passwordcontainer/syscreds.cxx b/svl/source/passwordcontainer/syscreds.cxx index 156d4f0857a2..c4fb701ae8bc 100644 --- a/svl/source/passwordcontainer/syscreds.cxx +++ b/svl/source/passwordcontainer/syscreds.cxx @@ -169,7 +169,7 @@ void SysCredentialsConfig::initCfg() osl::MutexGuard aGuard( m_aMutex ); if ( !m_bCfgInited ) { - uno::Sequence< OUString > aURLs( + const uno::Sequence< OUString > aURLs( m_aConfigItem.getSystemCredentialsURLs() ); m_aCfgContainer.insert( aURLs.begin(), aURLs.end() ); m_bCfgInited = true; diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index e95d127f2147..b7d787b53aae 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -288,7 +288,7 @@ void AssignmentPersistentData::ImplCommit() AssignmentPersistentData::AssignmentPersistentData() :ConfigItem("Office.DataAccess/AddressBook") { - Sequence< OUString > aStoredNames = GetNodeNames("Fields"); + const Sequence< OUString > aStoredNames = GetNodeNames("Fields"); m_aStoredFields.insert(aStoredNames.begin(), aStoredNames.end()); } @@ -846,7 +846,7 @@ void AssignmentPersistentData::ImplCommit() // for quicker access - ::std::set< OUString > aColumnNameSet(aColumnNames.begin(), aColumnNames.end()); + ::std::set< OUString > aColumnNameSet(std::cbegin(aColumnNames), std::cend(aColumnNames)); std::vector<OUString>::iterator aInitialSelection = m_pImpl->aFieldAssignments.begin() + m_pImpl->nFieldScrollPos; diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx index ada6aafecbd3..698e49e0725a 100644 --- a/svtools/source/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter/SvFilterOptionsDialog.cxx @@ -148,16 +148,17 @@ uno::Sequence< OUString > SAL_CALL SvFilterOptionsDialog::getSupportedServiceNam // XPropertyAccess uno::Sequence< beans::PropertyValue > SvFilterOptionsDialog::getPropertyValues() { - auto pProp = std::find_if(maMediaDescriptor.begin(), maMediaDescriptor.end(), + auto pProp = std::find_if(std::cbegin(maMediaDescriptor), std::cend(maMediaDescriptor), [](const beans::PropertyValue& rProp) { return rProp.Name == "FilterData"; }); - auto i = static_cast<sal_Int32>(std::distance(maMediaDescriptor.begin(), pProp)); + auto i = static_cast<sal_Int32>(std::distance(std::cbegin(maMediaDescriptor), pProp)); sal_Int32 nCount = maMediaDescriptor.getLength(); if ( i == nCount ) maMediaDescriptor.realloc( ++nCount ); // the "FilterData" Property is an Any that will contain our PropertySequence of Values - maMediaDescriptor[ i ].Name = "FilterData"; - maMediaDescriptor[ i ].Value <<= maFilterDataSequence; + auto& item = maMediaDescriptor[ i ]; + item.Name = "FilterData"; + item.Value <<= maFilterDataSequence; return maMediaDescriptor; } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 96f3722b994c..14f9c6977fca 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -652,7 +652,7 @@ namespace svt::table else { ::std::vector< ::Color > aColors( aAPIColors.getLength() ); - std::transform(aAPIColors.begin(), aAPIColors.end(), aColors.begin(), + std::transform(std::cbegin(aAPIColors), std::cend(aAPIColors), aColors.begin(), [](const css::util::Color& rAPIColor) -> ::Color { return Color(ColorTransparency, rAPIColor); }); m_aRowColors = aColors; } diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx index 5fbf4f4ebdec..0ed06acab198 100644 --- a/svx/source/accessibility/AccessibleShape.cxx +++ b/svx/source/accessibility/AccessibleShape.cxx @@ -418,7 +418,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL xTempAccContext->getAccessibleStateSet(); if (rState.is()) { - css::uno::Sequence<short> aStates = rState->getStates(); + const css::uno::Sequence<short> aStates = rState->getStates(); if (std::find(aStates.begin(), aStates.end(), AccessibleStateType::EDITABLE) != aStates.end()) { pStateSet->AddState (AccessibleStateType::EDITABLE); @@ -787,7 +787,7 @@ sal_Bool SAL_CALL AccessibleShape::isAccessibleChildSelected( sal_Int32 nChildIn if( !pRState.is() ) return false; - uno::Sequence<short> aStates = pRState->getStates(); + const uno::Sequence<short> aStates = pRState->getStates(); return std::find(aStates.begin(), aStates.end(), AccessibleStateType::SELECTED) != aStates.end(); } } diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 43fa3c399725..d7f5ee2e0a64 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -1296,7 +1296,7 @@ void FmGridControl::DeleteSelectedRows() SetUpdateMode( true ); // how many rows are deleted? - sal_Int32 nDeletedRows = static_cast<sal_Int32>(std::count_if(aDeletedRows.begin(), aDeletedRows.end(), + sal_Int32 nDeletedRows = static_cast<sal_Int32>(std::count_if(std::cbegin(aDeletedRows), std::cend(aDeletedRows), [](const sal_Int32 nRow) { return nRow != 0; })); // have rows been deleted? @@ -1344,10 +1344,10 @@ void FmGridControl::DeleteSelectedRows() // not all the rows where deleted, so move to the first row which remained in the resultset else { - auto pRow = std::find(aDeletedRows.begin(), aDeletedRows.end(), 0); - if (pRow != aDeletedRows.end()) + auto pRow = std::find(std::cbegin(aDeletedRows), std::cend(aDeletedRows), 0); + if (pRow != std::cend(aDeletedRows)) { - auto i = static_cast<sal_Int32>(std::distance(aDeletedRows.begin(), pRow)); + auto i = static_cast<sal_Int32>(std::distance(std::cbegin(aDeletedRows), pRow)); getDataSource()->moveToBookmark(aBookmarks[i]); } } diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 3134c0ce67a9..ab52cb90864a 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -2535,7 +2535,7 @@ void FmXGridPeer::statusChanged(const css::frame::FeatureStateEvent& Event) DBG_ASSERT(m_pStateCache, "FmXGridPeer::statusChanged : invalid call !"); DBG_ASSERT(m_pDispatchers, "FmXGridPeer::statusChanged : invalid call !"); - Sequence< css::util::URL>& aUrls = getSupportedURLs(); + const Sequence< css::util::URL>& aUrls = getSupportedURLs(); const std::vector<DbGridControlNavigationBarState>& aSlots = getSupportedGridSlots(); diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 3b5a070e4dee..3571e2e71f05 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -1184,7 +1184,7 @@ bool FmXFormShell::executeControlConversionSlot_Lock(const Reference<XFormCompon // find the control for the model Reference<XControlContainer> xControlContainer(getControlContainerForView_Lock()); - Sequence< Reference< XControl> > aControls( xControlContainer->getControls() ); + const Sequence< Reference< XControl> > aControls( xControlContainer->getControls() ); Reference< XControl> xControl; auto pControl = std::find_if(aControls.begin(), aControls.end(), diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index eb292abd8ce4..ed6899c6fa9c 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -674,7 +674,7 @@ void FmSearchEngine::Init(const OUString& sVisibleFields) Reference< css::sdbcx::XColumnsSupplier > xSupplyCols(IFACECAST(m_xSearchCursor), UNO_QUERY); DBG_ASSERT(xSupplyCols.is(), "FmSearchEngine::Init : invalid cursor (no columns supplier) !"); Reference< css::container::XNameAccess > xAllFieldNames = xSupplyCols->getColumns(); - Sequence< OUString > seqFieldNames = xAllFieldNames->getElementNames(); + const Sequence< OUString > seqFieldNames = xAllFieldNames->getElementNames(); OUString sCurrentField; sal_Int32 nIndex = 0; diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 67d43d734b7f..eb13c53a4848 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -1068,7 +1068,7 @@ namespace svx try { - Sequence< Reference< css::awt::XControl > > aControls( _rxController->getControls() ); + const Sequence< Reference< css::awt::XControl > > aControls( _rxController->getControls() ); m_aControlObservers.resize( 0 ); m_aControlObservers.reserve( aControls.getLength() ); diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx index 678e00052de3..513c0cc0d751 100644 --- a/svx/source/form/formcontrolfactory.cxx +++ b/svx/source/form/formcontrolfactory.cxx @@ -514,7 +514,7 @@ namespace svxform // let's see if the data source which the form belongs to (if any) // has a setting for the preferred line end format bool bDosLineEnds = false; - Sequence< PropertyValue > aInfo = lcl_getDataSourceIndirectProperties( _rxModel, m_xContext ); + const Sequence< PropertyValue > aInfo = lcl_getDataSourceIndirectProperties( _rxModel, m_xContext ); const PropertyValue* pInfo = std::find_if(aInfo.begin(), aInfo.end(), [](const PropertyValue& rInfo) { return rInfo.Name == "PreferDosLikeLineEnds"; }); if (pInfo != aInfo.end()) diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index ebaa1cc86939..e84ac41a33d0 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -1275,7 +1275,7 @@ bool FormController::replaceControl( const Reference< XControl >& _rxExistentCon if ( xContainer.is() ) { // look up the ID of _rxExistentControl - Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() ); + const Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() ); const sal_Int32* pIdentifiers = std::find_if(aIdentifiers.begin(), aIdentifiers.end(), [&xContainer, &_rxExistentControl](const sal_Int32 nId) { Reference< XControl > xCheck( xContainer->getByIdentifier( nId ), UNO_QUERY ); @@ -2320,19 +2320,17 @@ Reference< XControl > FormController::findControl(Sequence< Reference< XControl OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); DBG_ASSERT( xCtrlModel.is(), "findControl - which ?!" ); - Reference< XControl >* pControls = std::find_if(_rControls.begin(), _rControls.end(), + const Reference< XControl >* pControls = std::find_if(std::cbegin(_rControls), std::cend(_rControls), [&xCtrlModel](const Reference< XControl >& rControl) { return rControl.is() && rControl->getModel().get() == xCtrlModel.get(); }); - if (pControls != _rControls.end()) + if (pControls != std::cend(_rControls)) { Reference< XControl > xControl( *pControls ); + auto i = static_cast<sal_Int32>(std::distance(std::cbegin(_rControls), pControls)); if ( _bRemove ) - { - auto i = static_cast<sal_Int32>(std::distance(_rControls.begin(), pControls)); ::comphelper::removeElementAt( _rControls, i ); - } else if ( _bOverWrite ) - pControls->clear(); + _rControls[i].clear(); return xControl; } return Reference< XControl > (); @@ -2449,11 +2447,11 @@ void FormController::insertControl(const Reference< XControl > & xControl) void FormController::removeControl(const Reference< XControl > & xControl) { OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - auto pControl = std::find_if(m_aControls.begin(), m_aControls.end(), + auto pControl = std::find_if(std::cbegin(m_aControls), std::cend(m_aControls), [&xControl](const Reference< XControl >& rControl) { return xControl.get() == rControl.get(); }); - if (pControl != m_aControls.end()) + if (pControl != std::cend(m_aControls)) { - auto nIndex = static_cast<sal_Int32>(std::distance(m_aControls.begin(), pControl)); + auto nIndex = static_cast<sal_Int32>(std::distance(std::cbegin(m_aControls), pControl)); ::comphelper::removeElementAt( m_aControls, nIndex ); } diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx index 9a86a3bdb4aa..a2cd8c8d32b2 100644 --- a/svx/source/items/customshapeitem.cxx +++ b/svx/source/items/customshapeitem.cxx @@ -141,7 +141,7 @@ void SdrCustomShapeGeometryItem::SetPropertyValue( const css::beans::PropertyVal } else { // it's a new property - assert(std::none_of(aPropSeq.begin(), aPropSeq.end(), + assert(std::none_of(std::cbegin(aPropSeq), std::cend(aPropSeq), [&rPropVal](beans::PropertyValue const& rVal) { return rVal.Name == rPropVal.Name; } )); sal_uInt32 nIndex = aPropSeq.getLength(); @@ -167,7 +167,7 @@ void SdrCustomShapeGeometryItem::SetPropertyValue( const OUString& rSequenceName aValue.Name = rSequenceName; aValue.Value <<= aSeq; - assert(std::none_of(aPropSeq.begin(), aPropSeq.end(), + assert(std::none_of(std::cbegin(aPropSeq), std::cend(aPropSeq), [&rSequenceName](beans::PropertyValue const& rV) { return rV.Name == rSequenceName; } )); sal_uInt32 nIndex = aPropSeq.getLength(); @@ -279,7 +279,7 @@ bool SdrCustomShapeGeometryItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMe for (sal_Int32 i = 0; i < aPropSeq.getLength(); ++i) { const auto& rName = aPropSeq[i].Name; - bool isDuplicated = std::any_of(std::next(aPropSeq.begin(), i + 1), aPropSeq.end(), + bool isDuplicated = std::any_of(std::next(std::cbegin(aPropSeq), i + 1), std::cend(aPropSeq), [&rName](const css::beans::PropertyValue& rProp) { return rProp.Name == rName; }); if (isDuplicated) { diff --git a/svx/source/table/accessiblecell.cxx b/svx/source/table/accessiblecell.cxx index 71d0bdf59555..d298555734ba 100644 --- a/svx/source/table/accessiblecell.cxx +++ b/svx/source/table/accessiblecell.cxx @@ -222,7 +222,7 @@ Reference<XAccessibleStateSet> SAL_CALL AccessibleCell::getAccessibleStateSet() xTempAccContext->getAccessibleStateSet(); if( rState.is() ) { - css::uno::Sequence<short> aStates = rState->getStates(); + const css::uno::Sequence<short> aStates = rState->getStates(); if (std::find(aStates.begin(), aStates.end(), AccessibleStateType::EDITABLE) != aStates.end()) { pStateSet->AddState (AccessibleStateType::EDITABLE); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index b364d1314278..be18f7b47d86 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -940,7 +940,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89702, "tdf89702.docx") auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); uno::Sequence<beans::PropertyValue> aLevel; xLevels->getByIndex(1) >>= aLevel; // 2nd level - OUString aCharStyleName = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); + OUString aCharStyleName = std::find_if(std::cbegin(aLevel), std::cend(aLevel), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); // Make sure that the font name is Arial, this was Verdana. uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY); @@ -1052,7 +1052,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf92124, "tdf92124.docx") auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); uno::Sequence<beans::PropertyValue> aLevel; xLevels->getByIndex(0) >>= aLevel; // 1st level - OUString aSuffix = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "Suffix"; })->Value.get<OUString>(); + OUString aSuffix = std::find_if(std::cbegin(aLevel), std::cend(aLevel), [](const beans::PropertyValue& rValue) { return rValue.Name == "Suffix"; })->Value.get<OUString>(); // Make sure it's empty as the source document contains <w:suff w:val="nothing"/>. CPPUNIT_ASSERT(aSuffix.isEmpty()); } @@ -1165,7 +1165,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95213, "tdf95213.docx") auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); uno::Sequence<beans::PropertyValue> aLevel; xLevels->getByIndex(1) >>= aLevel; // 2nd level - OUString aName = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); + OUString aName = std::find_if(std::cbegin(aLevel), std::cend(aLevel), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName(aName), uno::UNO_QUERY); // This was awt::FontWeight::BOLD. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index d485c094ce15..102c50e95d30 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -993,7 +993,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf94628, "tdf94628.docx") uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(0) >>= aProps; // 1st level - OUString sBulletChar = std::find_if(aProps.begin(), aProps.end(), + OUString sBulletChar = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const beans::PropertyValue& rValue) { return rValue.Name == "BulletChar"; }) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 3e7b38f8df75..1eeb60366093 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -174,7 +174,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95848_2, "tdf95848_2.docx") auto xLevels = getProperty<uno::Reference<container::XIndexAccess>>(xPara, "NumberingRules"); uno::Sequence<beans::PropertyValue> aLevel; xLevels->getByIndex(0) >>= aLevel; // top level - sal_Int32 nIndent = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "FirstLineIndent"; })->Value.get<sal_Int32>(); + sal_Int32 nIndent = std::find_if(std::cbegin(aLevel), std::cend(aLevel), [](const beans::PropertyValue& rValue) { return rValue.Name == "FirstLineIndent"; })->Value.get<sal_Int32>(); CPPUNIT_ASSERT_EQUAL(sal_Int32(-635), nIndent); } { @@ -192,7 +192,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95848_2, "tdf95848_2.docx") auto xLevels = getProperty<uno::Reference<container::XIndexAccess>>(xPara, "NumberingRules"); uno::Sequence<beans::PropertyValue> aLevel; xLevels->getByIndex(0) >>= aLevel; // top level - sal_Int32 nIndent = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "FirstLineIndent"; })->Value.get<sal_Int32>(); + sal_Int32 nIndent = std::find_if(std::cbegin(aLevel), std::cend(aLevel), [](const beans::PropertyValue& rValue) { return rValue.Name == "FirstLineIndent"; })->Value.get<sal_Int32>(); CPPUNIT_ASSERT_EQUAL(sal_Int32(9366), nIndent); } { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index cf5ad5e41fc8..608a4a7bc9f0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -482,7 +482,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf134619_numberingProps, "tdf134619_num auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); uno::Sequence<beans::PropertyValue> aLevel; xLevels->getByIndex(0) >>= aLevel; // 1st level - OUString aCharStyleName = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); + OUString aCharStyleName = std::find_if(std::cbegin(aLevel), std::cend(aLevel), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); // Make sure that the blue bullet's font size is 72 points, not 12 points. uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY); diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index 1cadbdd7aa44..8336f6bad8ca 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -357,9 +357,9 @@ sal_Int16 SwModelTestBase::getNumberingTypeOfParagraph(int nPara) uno::Sequence<beans::PropertyValue> aPropertyValue; xLevels->getByIndex(nNumberingLevel) >>= aPropertyValue; auto pProp = std::find_if( - aPropertyValue.begin(), aPropertyValue.end(), + std::cbegin(aPropertyValue), std::cend(aPropertyValue), [](const beans::PropertyValue& rProp) { return rProp.Name == "NumberingType"; }); - if (pProp != aPropertyValue.end()) + if (pProp != std::cend(aPropertyValue)) nNumberingType = pProp->Value.get<sal_Int16>(); } } diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 9bcec4e19cd5..08a4886044c1 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -124,7 +124,7 @@ static bool lcl_getSelectedState(const SwAccessibleChild& aChild, Reference<XAccessibleStateSet> pRStateSet = pRContext->getAccessibleStateSet(); if( pRStateSet.is() ) { - Sequence<short> aStates = pRStateSet->getStates(); + const Sequence<short> aStates = pRStateSet->getStates(); if (std::find(aStates.begin(), aStates.end(), AccessibleStateType::SELECTED) != aStates.end()) return true; } diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index 76d9e8899934..a393afdb225c 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -1020,14 +1020,14 @@ bool SwEditShell::GetGrammarCorrection( // get suggestions to use for the specific error position rSuggestions.realloc( 0 ); // return suggestions for first error that includes the given error position - auto pError = std::find_if(rResult.aErrors.begin(), rResult.aErrors.end(), + auto pError = std::find_if(std::cbegin(rResult.aErrors), std::cend(rResult.aErrors), [rErrorPosInText, nLen](const linguistic2::SingleProofreadingError &rError) { return rError.nErrorStart <= rErrorPosInText && rErrorPosInText + nLen <= rError.nErrorStart + rError.nErrorLength; }); - if (pError != rResult.aErrors.end()) + if (pError != std::cend(rResult.aErrors)) { rSuggestions = pError->aSuggestions; - rErrorIndexInResult = static_cast<sal_Int32>(std::distance(rResult.aErrors.begin(), pError)); + rErrorIndexInResult = static_cast<sal_Int32>(std::distance(std::cbegin(rResult.aErrors), pError)); } } @@ -1544,9 +1544,9 @@ void SwSpellIter::CreatePortion(uno::Reference< XSpellAlternatives > const & xAl aPortion.aGrammarError = pGrammarResult->aErrors[0]; aPortion.sText = pGrammarResult->aText.copy( aPortion.aGrammarError.nErrorStart, aPortion.aGrammarError.nErrorLength ); aPortion.xGrammarChecker = pGrammarResult->xProofreader; - auto pProperty = std::find_if(pGrammarResult->aProperties.begin(), pGrammarResult->aProperties.end(), + auto pProperty = std::find_if(std::cbegin(pGrammarResult->aProperties), std::cend(pGrammarResult->aProperties), [](const beans::PropertyValue& rProperty) { return rProperty.Name == "DialogTitle"; }); - if (pProperty != pGrammarResult->aProperties.end()) + if (pProperty != std::cend(pGrammarResult->aProperties)) pProperty->Value >>= aPortion.sDialogTitle; } } diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index b40a42a49a41..1e04b4d8848d 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1233,15 +1233,16 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume // build value for 'SequenceMapping' uno::Sequence< sal_Int32 > aSortedMapping( aSequenceMapping ); - std::sort( aSortedMapping.begin(), aSortedMapping.end() ); + auto [begin, end] = toNonConstRange(aSortedMapping); + std::sort(begin, end); bool bNeedSequenceMapping = false; for (sal_Int32 i = 0; i < aSequenceMapping.getLength(); ++i) { - auto it = std::find( aSortedMapping.begin(), aSortedMapping.end(), + auto it = std::find( std::cbegin(aSortedMapping), std::cend(aSortedMapping), aSequenceMapping[i] ); - aSequenceMapping[i] = std::distance(aSortedMapping.begin(), it); + aSequenceMapping[i] = std::distance(std::cbegin(aSortedMapping), it); - if (i != aSequenceMapping[i]) + if (i != std::as_const(aSequenceMapping)[i]) bNeedSequenceMapping = true; } diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index b54f1779e3f8..10cff85a4a34 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -112,7 +112,7 @@ public: sProjectName = mpDocShell->GetBasicManager()->GetName(); } uno::Reference< container::XNameAccess > xLib( xLibContainer->getByName( sProjectName ), uno::UNO_QUERY_THROW ); - uno::Sequence< OUString > sModuleNames = xLib->getElementNames(); + const uno::Sequence< OUString > sModuleNames = xLib->getElementNames(); uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); auto pModuleName = std::find_if(sModuleNames.begin(), sModuleNames.end(), [&xVBAModuleInfo](const OUString& rName) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 85b38f9053e5..dd540870d8c3 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2385,7 +2385,7 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( { SolarMutexGuard aGuard; uno::Sequence< beans::PropertyState > aStates(aPropertyNames.getLength()); - beans::PropertyState* pStates = aStates.getArray(); + auto [pStates, end] = toNonConstRange(aStates); SwFrameFormat* pFormat = GetFrameFormat(); if(pFormat) { @@ -2458,7 +2458,7 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( } else if(IsDescriptor()) { - std::fill(aStates.begin(), aStates.end(), beans::PropertyState_DIRECT_VALUE); + std::fill(pStates, end, beans::PropertyState_DIRECT_VALUE); } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 9f74a4f7daa1..326f8cc2a6ea 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -705,7 +705,7 @@ SwXParagraph::getPropertyValuesTolerant( { SolarMutexGuard aGuard; - uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( + const uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) ); // copy temporary result to final result type diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index fea1e27749ef..a76af4e240fc 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -548,7 +548,7 @@ uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXTextPortion::getPr { SolarMutexGuard aGuard; - uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( + const uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( GetPropertyValuesTolerant_Impl( rPropertyNames, false ) ); // copy temporary result to final result type diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 868196d654e0..f94baf8806a7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -651,9 +651,9 @@ bool DocxAttributeOutput::TextBoxIsFramePr(const SwFrameFormat& rFrameFormat) { uno::Sequence< beans::PropertyValue > propList; xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; - auto pProp = std::find_if(propList.begin(), propList.end(), + auto pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "ParaFrameProperties"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) aFrameProperties = pProp->Value; } bool bFrameProperties = false; @@ -2820,10 +2820,10 @@ void DocxAttributeOutput::GetSdtEndBefore(const SdrObject* pSdrObj) xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag; } - auto pProp = std::find_if(aGrabBag.begin(), aGrabBag.end(), + auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag), [this](const beans::PropertyValue& rProp) { return "SdtEndBefore" == rProp.Name && m_bStartedCharSdt && !m_bEndCharSdt; }); - if (pProp != aGrabBag.end()) + if (pProp != std::cend(aGrabBag)) pProp->Value >>= m_bEndCharSdt; } @@ -4701,9 +4701,9 @@ void DocxAttributeOutput::LatentStyles() uno::Sequence<beans::PropertyValue> aInteropGrabBag; xPropertySet->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag; uno::Sequence<beans::PropertyValue> aLatentStyles; - auto pProp = std::find_if(aInteropGrabBag.begin(), aInteropGrabBag.end(), + auto pProp = std::find_if(std::cbegin(aInteropGrabBag), std::cend(aInteropGrabBag), [](const beans::PropertyValue& rProp) { return rProp.Name == "latentStyles"; }); - if (pProp != aInteropGrabBag.end()) + if (pProp != std::cend(aInteropGrabBag)) pProp->Value >>= aLatentStyles; if (!aLatentStyles.hasElements()) return; @@ -5736,9 +5736,9 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S uno::Reference< beans::XPropertySet > xPropSet( m_rExport.m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW ); uno::Sequence< beans::PropertyValue > aGrabBag, aObjectsInteropList,aObjectInteropAttributes; xPropSet->getPropertyValue( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) >>= aGrabBag; - auto pProp = std::find_if(aGrabBag.begin(), aGrabBag.end(), + auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag), [](const beans::PropertyValue& rProp) { return rProp.Name == "EmbeddedObjects"; }); - if (pProp != aGrabBag.end()) + if (pProp != std::cend(aGrabBag)) pProp->Value >>= aObjectsInteropList; SwOLEObj& aObject = rNode.GetOLEObj(); @@ -5757,9 +5757,9 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S default: SAL_WARN("sw.ww8", "DocxAttributeOutput::WriteOLE: invalid aspect value"); } - auto pObjectsInterop = std::find_if(aObjectsInteropList.begin(), aObjectsInteropList.end(), + auto pObjectsInterop = std::find_if(std::cbegin(aObjectsInteropList), std::cend(aObjectsInteropList), [&sObjectName](const beans::PropertyValue& rProp) { return rProp.Name == sObjectName; }); - if (pObjectsInterop != aObjectsInteropList.end()) + if (pObjectsInterop != std::cend(aObjectsInteropList)) pObjectsInterop->Value >>= aObjectInteropAttributes; for( const auto& rObjectInteropAttribute : std::as_const(aObjectInteropAttributes) ) diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index e4531e421796..b610adf30f7d 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1369,9 +1369,9 @@ void DocxExport::WriteTheme() uno::Reference<xml::dom::XDocument> themeDom; uno::Sequence< beans::PropertyValue > propList; xPropSet->getPropertyValue( aName ) >>= propList; - auto pProp = std::find_if(propList.begin(), propList.end(), + auto pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXTheme"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) pProp->Value >>= themeDom; // no theme dom to write @@ -1472,14 +1472,14 @@ void DocxExport::WriteCustomXml() uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomPropslist; uno::Sequence< beans::PropertyValue > propList; xPropSet->getPropertyValue( aName ) >>= propList; - auto pProp = std::find_if(propList.begin(), propList.end(), + auto pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXCustomXml"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) pProp->Value >>= customXmlDomlist; - pProp = std::find_if(propList.begin(), propList.end(), + pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXCustomXmlProps"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) pProp->Value >>= customXmlDomPropslist; for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++) @@ -1589,9 +1589,9 @@ void DocxExport::WriteEmbeddings() uno::Sequence< beans::PropertyValue > embeddingsList; uno::Sequence< beans::PropertyValue > propList; xPropSet->getPropertyValue( aName ) >>= propList; - auto pProp = std::find_if(propList.begin(), propList.end(), + auto pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXEmbeddings"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) pProp->Value >>= embeddingsList; for (const auto& rEmbedding : std::as_const(embeddingsList)) { diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 1e1ac6bd66c3..ae5b7ca94fb1 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -83,7 +83,7 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) aGrabBagName = "FrameInteropGrabBag"; else aGrabBagName = "InteropGrabBag"; - uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, aGrabBagName); + const uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, aGrabBagName); auto pProp = std::find_if(propList.begin(), propList.end(), [](const beans::PropertyValue& rProp) { return rProp.Name == "AnchorId"; }); @@ -1385,7 +1385,7 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat static bool lcl_isLockedCanvas(const uno::Reference<drawing::XShape>& xShape) { - uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, "InteropGrabBag"); + const uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, "InteropGrabBag"); /* * Export as Locked Canvas only if the property * is in the PropertySet @@ -1835,11 +1835,11 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho { uno::Sequence<beans::PropertyValue> propList; xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; - auto pProp = std::find_if(propList.begin(), propList.end(), + auto pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "mso-rotation-angle"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) aRotation = pProp->Value; } sal_Int32 nTmp; @@ -1867,11 +1867,11 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho { uno::Sequence<beans::PropertyValue> propList; xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; - auto pProp = std::find_if(propList.begin(), propList.end(), + auto pProp = std::find_if(std::cbegin(propList), std::cend(propList), [](const beans::PropertyValue& rProp) { return rProp.Name == "mso-orig-shape-type"; }); - if (pProp != propList.end()) + if (pProp != std::cend(propList)) pProp->Value >>= shapeType; } //Empty shapeType will lead to corruption so to avoid that shapeType is set to default i.e. "rect" diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx index 4ad89587eda1..570c43130778 100644 --- a/sw/source/filter/ww8/docxtablestyleexport.cxx +++ b/sw/source/filter/ww8/docxtablestyleexport.cxx @@ -130,9 +130,9 @@ void DocxTableStyleExport::TableStyles(sal_Int32 nCountStylesToWrite) xPropertySet->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag; uno::Sequence<beans::PropertyValue> aTableStyles; auto pProp = std::find_if( - aInteropGrabBag.begin(), aInteropGrabBag.end(), + std::cbegin(aInteropGrabBag), std::cend(aInteropGrabBag), [](const beans::PropertyValue& rProp) { return rProp.Name == "tableStyles"; }); - if (pProp != aInteropGrabBag.end()) + if (pProp != std::cend(aInteropGrabBag)) pProp->Value >>= aTableStyles; if (!aTableStyles.hasElements()) return; diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 0ba034aa6564..6e6ed96981f7 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -4253,7 +4253,8 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) { uno::Sequence< OUString > vListEntries; pListEntries->second >>= vListEntries; - copy(vListEntries.begin(), vListEntries.end(), back_inserter(aListItems)); + aListItems.reserve(vListEntries.getLength()); + copy(std::cbegin(vListEntries), std::cend(vListEntries), back_inserter(aListItems)); } } diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index efe108b2d5dc..2a902d85a2b0 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -361,10 +361,11 @@ const uno::Sequence< OUString >& SwSelectAddressBlockDialog::GetAddressBlocks const sal_Int32 nSelect = static_cast<sal_Int32>(m_xPreview->GetSelectedAddress()); if(nSelect) { - uno::Sequence< OUString >aTemp = m_aAddressBlocks; - aTemp[0] = m_aAddressBlocks[nSelect]; - std::copy(m_aAddressBlocks.begin(), std::next(m_aAddressBlocks.begin(), nSelect), std::next(aTemp.begin())); - std::copy(std::next(m_aAddressBlocks.begin(), nSelect + 1), m_aAddressBlocks.end(), std::next(aTemp.begin(), nSelect + 1)); + uno::Sequence< OUString >aTemp(m_aAddressBlocks.getLength()); + auto it = aTemp.begin(); + *it = std::as_const(m_aAddressBlocks)[nSelect]; + it = std::copy_n(std::cbegin(m_aAddressBlocks), nSelect - 1, std::next(it)); + std::copy(std::next(std::cbegin(m_aAddressBlocks), nSelect + 1), std::cend(m_aAddressBlocks), it); m_aAddressBlocks = aTemp; } return m_aAddressBlocks; diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index 27621d74e0ef..63a05e81bd7b 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -326,9 +326,9 @@ SwMailMergeDlg::SwMailMergeDlg(weld::Window* pParent, SwWrtShell& rShell, uno::Sequence< beans::PropertyValue > aFilterProperties; aProps >>= aFilterProperties; OUString sUIName2; - auto pProp = std::find_if(aFilterProperties.begin(), aFilterProperties.end(), + auto pProp = std::find_if(std::cbegin(aFilterProperties), std::cend(aFilterProperties), [](const beans::PropertyValue& rProp) { return rProp.Name == "UIName"; }); - if (pProp != aFilterProperties.end()) + if (pProp != std::cend(aFilterProperties)) pProp->Value >>= sUIName2; if( !sUIName2.isEmpty() ) { if( sFilter == "writer8" ) diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx index 78f553ed0365..846c8c999304 100644 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ b/sw/source/ui/vba/vbadocumentproperties.cxx @@ -338,9 +338,10 @@ public: uno::Sequence< beans::NamedValue > stats( m_xDocProps->getDocumentStatistics()); - auto pStat = std::find_if(stats.begin(), stats.end(), + auto [begin, end] = toNonConstRange(stats); + auto pStat = std::find_if(begin, end, [&rPropName](const beans::NamedValue& rStat) { return rPropName == rStat.Name; }); - if (pStat != stats.end()) + if (pStat != end) { pStat->Value = aValue; m_xDocProps->setDocumentStatistics(stats); @@ -838,7 +839,7 @@ public: virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override { - uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties(); + const uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties(); uno::Sequence< OUString > aNames( aProps.getLength() ); std::transform(aProps.begin(), aProps.end(), aNames.begin(), [](const beans::Property& rProp) -> OUString { return rProp.Name; }); diff --git a/sw/source/ui/vba/vbafilterpropsfromformat.hxx b/sw/source/ui/vba/vbafilterpropsfromformat.hxx index 01fd93be5555..dbf07b155955 100644 --- a/sw/source/ui/vba/vbafilterpropsfromformat.hxx +++ b/sw/source/ui/vba/vbafilterpropsfromformat.hxx @@ -31,11 +31,11 @@ namespace inline bool setFilterPropsFromFormat(sal_Int32 nFormat, css::uno::Sequence<css::beans::PropertyValue>& rProps) { - auto pProp - = std::find_if(rProps.begin(), rProps.end(), [](const css::beans::PropertyValue& rProp) { - return rProp.Name == "FilterName"; - }); - if (pProp != rProps.end()) + auto[begin, end] = toNonConstRange(rProps); + auto pProp = std::find_if(begin, end, [](const css::beans::PropertyValue& rProp) { + return rProp.Name == "FilterName"; + }); + if (pProp != end) { switch (nFormat) { diff --git a/sw/source/ui/vba/vbastyles.cxx b/sw/source/ui/vba/vbastyles.cxx index a65f2750f95a..f14758eb8810 100644 --- a/sw/source/ui/vba/vbastyles.cxx +++ b/sw/source/ui/vba/vbastyles.cxx @@ -222,7 +222,7 @@ public: } else { - uno::Sequence< OUString > sElementNames = mxParaStyles->getElementNames(); + const uno::Sequence< OUString > sElementNames = mxParaStyles->getElementNames(); auto pStyleName = std::find_if(sElementNames.begin(), sElementNames.end(), [&aName](const OUString& rStyleName) { return rStyleName.equalsIgnoreAsciiCase( aName ); }); if (pStyleName != sElementNames.end()) diff --git a/sw/source/ui/vba/vbatabstops.cxx b/sw/source/ui/vba/vbatabstops.cxx index c7e6655b5b8d..0046814305d9 100644 --- a/sw/source/ui/vba/vbatabstops.cxx +++ b/sw/source/ui/vba/vbatabstops.cxx @@ -202,10 +202,11 @@ uno::Reference< word::XTabStop > SAL_CALL SwVbaTabStops::Add( float Position, co aTab.FillChar = cLeader; uno::Sequence< style::TabStop > aOldTabs = lcl_getTabStops( mxParaProps ); + auto [begin, end] = toNonConstRange(aOldTabs); - style::TabStop* pOldTab = std::find_if(aOldTabs.begin(), aOldTabs.end(), + style::TabStop* pOldTab = std::find_if(begin, end, [nPosition](const style::TabStop& rTab) { return rTab.Position == nPosition; }); - bool bOverWriter = pOldTab != aOldTabs.end(); + bool bOverWriter = pOldTab != end; if( bOverWriter ) { *pOldTab = aTab; @@ -216,8 +217,9 @@ uno::Reference< word::XTabStop > SAL_CALL SwVbaTabStops::Add( float Position, co sal_Int32 nTabs = aOldTabs.getLength(); uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 ); - aNewTabs[0] = aTab; - std::copy(aOldTabs.begin(), aOldTabs.end(), std::next(aNewTabs.begin())); + auto it = aNewTabs.begin(); + *it = aTab; + std::copy(begin, end, std::next(it)); lcl_setTabStops( mxParaProps, aNewTabs ); } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 532a142ca809..81acb18b3e15 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2044,7 +2044,7 @@ bool SwDBManager::GetColumnCnt(const OUString& rSourceName, const OUString& rTab if(pFound->aSelection.hasElements()) { //the destination has to be an element of the selection - bool bFound = std::any_of(pFound->aSelection.begin(), pFound->aSelection.end(), + bool bFound = std::any_of(std::cbegin(pFound->aSelection), std::cend(pFound->aSelection), [nAbsRecordId](const uno::Any& rSelection) { sal_Int32 nSelection = 0; rSelection >>= nSelection; diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx index 8b3692f8da31..0af160098e08 100644 --- a/sw/source/uibase/dbui/dbtree.cxx +++ b/sw/source/uibase/dbui/dbtree.cxx @@ -150,8 +150,9 @@ void SwDBTreeList::InitTreeList() auto const sort = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale()); + auto [begin, end] = toNonConstRange(aDBNames); std::sort( - aDBNames.begin(), aDBNames.end(), + begin, end, [&sort](OUString const & x, OUString const & y) { return sort.compare(x, y) < 0; }); diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index 744373edefc3..4dd6d7e0a5c4 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -333,12 +333,13 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() : if(m_aSavedDocuments.hasElements()) { uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength()); - OUString* pTempDocuments = std::copy_if(m_aSavedDocuments.begin(), m_aSavedDocuments.end(), aTempDocuments.begin(), + auto begin = aTempDocuments.begin(); + OUString* pTempDocuments = std::copy_if(std::cbegin(m_aSavedDocuments), std::cend(m_aSavedDocuments), begin, [](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); }); - sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(aTempDocuments.begin(), pTempDocuments)); + sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(begin, pTempDocuments)); if(nIndex < m_aSavedDocuments.getLength()) { - m_aSavedDocuments = aTempDocuments; + m_aSavedDocuments.swap(aTempDocuments); m_aSavedDocuments.realloc(nIndex); } } diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 9996117b9488..634bedb8c1c0 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -701,7 +701,7 @@ sal_uInt16 SwFieldMgr::GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) GetNumberingInfo(); if(m_xNumberingInfo.is()) { - Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes(); + const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes(); // #i28073# it's not necessarily a sorted sequence //skip all values below or equal to CHARS_LOWER_LETTER_N nCount += std::count_if(aTypes.begin(), aTypes.end(), diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx index 5136bed3d4c1..5f4c45bb8dfc 100644 --- a/sw/source/uibase/misc/numberingtypelistbox.cxx +++ b/sw/source/uibase/misc/numberingtypelistbox.cxx @@ -88,7 +88,8 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags) if (nValue > style::NumberingType::CHARS_LOWER_LETTER_N) { // Insert only if offered by i18n framework per configuration. - bInsert = std::find(aTypes.begin(), aTypes.end(), nValue) != aTypes.end(); + bInsert = std::find(std::cbegin(aTypes), std::cend(aTypes), nValue) + != std::cend(aTypes); } } if (bInsert) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 39bea8b26d89..2f2189456f3e 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -4101,7 +4101,7 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames() } else { - Sequence< OUString > aOrg = m_xRealAccess->getElementNames(); + const Sequence< OUString > aOrg = m_xRealAccess->getElementNames(); aRet.realloc(aOrg.getLength()); std::transform(aOrg.begin(), aOrg.end(), aRet.begin(), [this](const OUString& rOrg) -> OUString { return rOrg + m_sLinkSuffix; }); diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx index f894743dc8a1..eccd132f6af7 100644 --- a/test/source/sheet/xdatapilottable2.cxx +++ b/test/source/sheet/xdatapilottable2.cxx @@ -73,7 +73,7 @@ void XDataPilotTable2::testGetDrillDownData() sheet::DataResult aRes = aResData.Result; double nVal = aRes.Value; - Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(rResultCell); + const Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(rResultCell); double sum = 0; if( aData.getLength() > 1 ) diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx index 1a24fd417bc4..ad738a24c00c 100644 --- a/toolkit/source/controls/geometrycontrolmodel.cxx +++ b/toolkit/source/controls/geometrycontrolmodel.cxx @@ -155,8 +155,8 @@ constexpr OUStringLiteral GCM_PROPERTY_RESOURCERESOLVER = u"ResourceResolver"; sal_Int32 nOldSize = aTypes.getLength(); aTypes.realloc( nOldSize + aAggTypes.getLength() ); ::std::copy( - aAggTypes.begin(), - aAggTypes.end(), + std::cbegin(aAggTypes), + std::cend(aAggTypes), aTypes.getArray() + nOldSize ); } @@ -522,9 +522,10 @@ constexpr OUStringLiteral GCM_PROPERTY_RESOURCERESOLVER = u"ResourceResolver"; // look for duplicates, and remember them IntArrayArray::value_type& rDuplicateIds = gAmbiguousPropertyIds[ _nId ]; // for this, sort the aggregate properties + auto [begin, end] = toNonConstRange(aAggregateProps); ::std::sort( - aAggregateProps.begin(), - aAggregateProps.end(), + begin, + end, PropertyNameLess() ); @@ -532,11 +533,11 @@ constexpr OUStringLiteral GCM_PROPERTY_RESOURCERESOLVER = u"ResourceResolver"; for ( const Property& rProp : std::as_const(aProps) ) { // look for the current property in the properties of our aggregate - const Property* pAggPropPos = ::std::find_if( aAggregateProps.begin(), aAggregateProps.end(), PropertyNameEqual( rProp.Name ) ); - if ( pAggPropPos != aAggregateProps.end() ) + const Property* pAggPropPos = ::std::find_if( std::cbegin(aAggregateProps), std::cend(aAggregateProps), PropertyNameEqual( rProp.Name ) ); + if ( pAggPropPos != std::cend(aAggregateProps) ) { // found a duplicate // -> remove from the aggregate property sequence - ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - aAggregateProps.begin() ); + ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - std::cbegin(aAggregateProps) ); // and additionally, remember the id of this property rDuplicateIds.push_back( rProp.Handle ); diff --git a/toolkit/source/controls/stdtabcontroller.cxx b/toolkit/source/controls/stdtabcontroller.cxx index d4f5d64b04ef..1f9a3955770a 100644 --- a/toolkit/source/controls/stdtabcontroller.cxx +++ b/toolkit/source/controls/stdtabcontroller.cxx @@ -212,7 +212,7 @@ Sequence< Reference< XControl > > StdTabController::getControls( ) if ( mxControlContainer.is() ) { - Sequence< Reference< XControlModel > > aModels = mxModel->getControlModels(); + const Sequence< Reference< XControlModel > > aModels = mxModel->getControlModels(); Sequence< Reference< XControl > > xCtrls = mxControlContainer->getControls(); @@ -389,14 +389,14 @@ Reference< XControl > StdTabController::FindControl( Sequence< Reference< XCont throw lang::IllegalArgumentException("No valid XControlModel", uno::Reference<uno::XInterface>(), 0); - auto pCtrl = std::find_if(rCtrls.begin(), rCtrls.end(), + auto pCtrl = std::find_if(std::cbegin(rCtrls), std::cend(rCtrls), [&rxCtrlModel](const Reference< XControl >& rCtrl) { Reference< XControlModel > xModel(rCtrl.is() ? rCtrl->getModel() : Reference< XControlModel > ()); return xModel.get() == rxCtrlModel.get(); }); - if (pCtrl != rCtrls.end()) + if (pCtrl != std::cend(rCtrls)) { - auto n = static_cast<sal_Int32>(std::distance(rCtrls.begin(), pCtrl)); + auto n = static_cast<sal_Int32>(std::distance(std::cbegin(rCtrls), pCtrl)); Reference< XControl > xCtrl( *pCtrl ); ::comphelper::removeElementAt( rCtrls, n ); return xCtrl; diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 0546801f2146..91b8dd756aa6 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -83,7 +83,7 @@ static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiProp DBG_ASSERT( xPSInf.is(), "UpdateFromModel: No PropertySetInfo!" ); if ( xPSInf.is() ) { - Sequence< Property> aProps = xPSInf->getProperties(); + const Sequence< Property> aProps = xPSInf->getProperties(); sal_Int32 nLen = aProps.getLength(); aNames = Sequence< OUString>( nLen ); std::transform(aProps.begin(), aProps.end(), aNames.begin(), diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx index e9a146e32087..30854ba16a6f 100644 --- a/toolkit/source/controls/unocontrolcontainer.cxx +++ b/toolkit/source/controls/unocontrolcontainer.cxx @@ -700,12 +700,12 @@ void UnoControlContainer::removeTabController( const uno::Reference< awt::XTabCo { ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - auto pTabController = std::find_if(maTabControllers.begin(), maTabControllers.end(), + auto pTabController = std::find_if(std::cbegin(maTabControllers), std::cend(maTabControllers), [&TabController](const uno::Reference< awt::XTabController >& rTabController) { return rTabController.get() == TabController.get(); }); - if (pTabController != maTabControllers.end()) + if (pTabController != std::cend(maTabControllers)) { - auto n = static_cast<sal_Int32>(std::distance(maTabControllers.begin(), pTabController)); + auto n = static_cast<sal_Int32>(std::distance(std::cbegin(maTabControllers), pTabController)); ::comphelper::removeElementAt( maTabControllers, n ); } } diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 0107262bf5b9..02ecedeb0389 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -2125,8 +2125,8 @@ void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int3 ::std::vector< ListItem > aItems( aStringItemList.getLength() ); ::std::transform( - aStringItemList.begin(), - aStringItemList.end(), + std::cbegin(aStringItemList), + std::cend(aStringItemList), aItems.begin(), CreateListItem() ); @@ -2605,13 +2605,13 @@ void UnoListBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_In nPos = nOldLen; // Items before the Paste-Position - std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); // New Items - std::copy(aItems.begin(), aItems.end(), std::next(aNewSeq.begin(), nPos)); + it = std::copy(aItems.begin(), aItems.end(), it); // Rest of old Items - std::copy(std::next(aSeq.begin(), nPos), aSeq.end(), std::next(aNewSeq.begin(), nPos + nNewItems)); + std::copy(std::next(std::cbegin(aSeq), nPos), std::cend(aSeq), it); ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true ); } @@ -2633,10 +2633,10 @@ void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) uno::Sequence< OUString> aNewSeq( nNewLen ); // Items before the Remove-Position - std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); // Rest of Items - std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos)); + std::copy(std::next(std::cbegin(aSeq), nPos + nCount), std::cend(aSeq), it); ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true ); } @@ -2932,8 +2932,8 @@ void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int ::std::vector< ListItem > aItems( aStringItemList.getLength() ); ::std::transform( - aStringItemList.begin(), - aStringItemList.end(), + std::cbegin(aStringItemList), + std::cend(aStringItemList), aItems.begin(), CreateListItem() ); @@ -3197,13 +3197,13 @@ void UnoComboBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_I nPos = nOldLen; // items before the insert position - std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); // New items - std::copy(aItems.begin(), aItems.end(), std::next(aNewSeq.begin(), nPos)); + it = std::copy(aItems.begin(), aItems.end(), it); // remainder of old items - std::copy(std::next(aSeq.begin(), nPos), aSeq.end(), std::next(aNewSeq.begin(), nPos + nNewItems)); + std::copy(std::next(std::cbegin(aSeq), nPos), std::cend(aSeq), it); ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), Any(aNewSeq), true ); } @@ -3225,10 +3225,10 @@ void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) uno::Sequence< OUString> aNewSeq( nNewLen ); // items before the deletion position - std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); // remainder of old items - std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos)); + std::copy(std::next(std::cbegin(aSeq), nPos + nCount), std::cend(aSeq), it); ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true ); } diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index 39c9915f77ac..9061d3ec7bce 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -270,7 +270,7 @@ namespace toolkitform if( ! (_rxModel->getPropertyValue( "StringItemList" ) >>= aListEntries) ) { SAL_WARN("toolkit.helper", "getStringItemVector: unable to get property StringItemList"); } - _rVector.insert( _rVector.end(), aListEntries.begin(), aListEntries.end() ); + _rVector.insert( _rVector.end(), std::cbegin(aListEntries), std::cend(aListEntries) ); } } @@ -611,7 +611,7 @@ namespace toolkitform { pListWidget->SelectedEntries.resize( 0 ); auto nEntriesSize = static_cast<sal_Int16>(pListWidget->Entries.size()); - std::copy_if(aSelectIndices.begin(), aSelectIndices.end(), std::back_inserter(pListWidget->SelectedEntries), + std::copy_if(std::cbegin(aSelectIndices), std::cend(aSelectIndices), std::back_inserter(pListWidget->SelectedEntries), [&nEntriesSize](const sal_Int16 nIndex) { return nIndex >= 0 && nIndex < nEntriesSize; }); } } diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx index bece903b57b3..8fbda792c435 100644 --- a/ucb/source/cacher/cachedcontentresultset.cxx +++ b/ucb/source/cacher/cachedcontentresultset.cxx @@ -249,7 +249,7 @@ Sequence< sal_Bool >& CachedContentResultSet::CCRS_Cache { sal_Int32 nCount = m_pResult->Rows.getLength(); m_pMappedReminder.emplace( nCount ); - std::fill(m_pMappedReminder->begin(), m_pMappedReminder->end(), false); + std::fill_n(m_pMappedReminder->begin(), m_pMappedReminder->getLength(), false); } return *m_pMappedReminder; } diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx index 7323cd78e94b..d3a08c695a6f 100644 --- a/ucb/source/core/ucbcmds.cxx +++ b/ucb/source/core/ucbcmds.cxx @@ -243,9 +243,9 @@ CommandProcessorInfo::getCommands() ucb::CommandInfo SAL_CALL CommandProcessorInfo::getCommandInfoByName( const OUString& Name ) { - auto pInfo = std::find_if(m_xInfo->begin(), m_xInfo->end(), + auto pInfo = std::find_if(std::cbegin(*m_xInfo), std::cend(*m_xInfo), [&Name](const ucb::CommandInfo& rInfo) { return rInfo.Name == Name; }); - if (pInfo != m_xInfo->end()) + if (pInfo != std::cend(*m_xInfo)) return *pInfo; throw ucb::UnsupportedCommandException(); @@ -256,9 +256,9 @@ CommandProcessorInfo::getCommandInfoByName( const OUString& Name ) ucb::CommandInfo SAL_CALL CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle ) { - auto pInfo = std::find_if(m_xInfo->begin(), m_xInfo->end(), + auto pInfo = std::find_if(std::cbegin(*m_xInfo), std::cend(*m_xInfo), [&Handle](const ucb::CommandInfo& rInfo) { return rInfo.Handle == Handle; }); - if (pInfo != m_xInfo->end()) + if (pInfo != std::cend(*m_xInfo)) return *pInfo; throw ucb::UnsupportedCommandException(); @@ -269,7 +269,7 @@ CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle ) sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByName( const OUString& Name ) { - return std::any_of(m_xInfo->begin(), m_xInfo->end(), + return std::any_of(std::cbegin(*m_xInfo), std::cend(*m_xInfo), [&Name](const ucb::CommandInfo& rInfo) { return rInfo.Name == Name; }); } @@ -277,7 +277,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByName( // virtual sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle ) { - return std::any_of(m_xInfo->begin(), m_xInfo->end(), + return std::any_of(std::cbegin(*m_xInfo), std::cend(*m_xInfo), [&Handle](const ucb::CommandInfo& rInfo) { return rInfo.Handle == Handle; }); } @@ -604,9 +604,9 @@ uno::Reference< ucb::XContent > createNew( } uno::Reference< ucb::XContent > xNew; - auto pTypeInfo = std::find_if(aTypesInfo.begin(), aTypesInfo.end(), + auto pTypeInfo = std::find_if(std::cbegin(aTypesInfo), std::cend(aTypesInfo), [&lCompare](const ucb::ContentInfo& rTypeInfo) { return lCompare(rTypeInfo.Attributes); }); - if (pTypeInfo != aTypesInfo.end()) + if (pTypeInfo != std::cend(aTypesInfo)) { // (3) Create a new, empty object of matched type. diff --git a/ucb/source/core/ucbprops.cxx b/ucb/source/core/ucbprops.cxx index 604b8983bc42..1260e406c1e1 100644 --- a/ucb/source/core/ucbprops.cxx +++ b/ucb/source/core/ucbprops.cxx @@ -254,9 +254,9 @@ sal_Bool SAL_CALL UcbPropertiesManager::hasPropertyByName( const OUString& Name bool UcbPropertiesManager::queryProperty( const OUString& rName, Property& rProp ) { - auto pProp = std::find_if(m_pProps.begin(), m_pProps.end(), + auto pProp = std::find_if(std::cbegin(m_pProps), std::cend(m_pProps), [&rName](const Property& rCurrProp) { return rCurrProp.Name == rName; }); - if (pProp != m_pProps.end()) + if (pProp != std::cend(m_pProps)) { rProp = *pProp; return true; diff --git a/ucb/source/ucp/file/filcmd.cxx b/ucb/source/ucp/file/filcmd.cxx index 6742f693d0e7..7bbfca94e080 100644 --- a/ucb/source/ucp/file/filcmd.cxx +++ b/ucb/source/ucp/file/filcmd.cxx @@ -81,9 +81,9 @@ CommandInfo SAL_CALL XCommandInfo_impl::getCommandInfoByName( const OUString& aName ) { - auto pCommand = std::find_if(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(), + auto pCommand = std::find_if(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; }); - if (pCommand != m_pMyShell->m_sCommandInfo.end()) + if (pCommand != std::cend(m_pMyShell->m_sCommandInfo)) return *pCommand; throw UnsupportedCommandException( THROW_WHERE ); @@ -94,9 +94,9 @@ CommandInfo SAL_CALL XCommandInfo_impl::getCommandInfoByHandle( sal_Int32 Handle ) { - auto pCommand = std::find_if(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(), + auto pCommand = std::find_if(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; }); - if (pCommand != m_pMyShell->m_sCommandInfo.end()) + if (pCommand != std::cend(m_pMyShell->m_sCommandInfo)) return *pCommand; throw UnsupportedCommandException( THROW_WHERE ); @@ -107,7 +107,7 @@ sal_Bool SAL_CALL XCommandInfo_impl::hasCommandByName( const OUString& aName ) { - return std::any_of(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(), + return std::any_of(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; }); } @@ -116,7 +116,7 @@ sal_Bool SAL_CALL XCommandInfo_impl::hasCommandByHandle( sal_Int32 Handle ) { - return std::any_of(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(), + return std::any_of(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; }); } diff --git a/ucb/source/ucp/file/filprp.cxx b/ucb/source/ucp/file/filprp.cxx index 7f64caa145e0..3cab28c70ddf 100644 --- a/ucb/source/ucp/file/filprp.cxx +++ b/ucb/source/ucp/file/filprp.cxx @@ -68,9 +68,9 @@ XPropertySetInfo_impl::~XPropertySetInfo_impl() beans::Property SAL_CALL XPropertySetInfo_impl::getPropertyByName( const OUString& aName ) { - auto pProp = std::find_if(m_seq.begin(), m_seq.end(), + auto pProp = std::find_if(std::cbegin(m_seq), std::cend(m_seq), [&aName](const beans::Property& rProp) { return rProp.Name == aName; }); - if (pProp != m_seq.end()) + if (pProp != std::cend(m_seq)) return *pProp; throw beans::UnknownPropertyException( aName ); @@ -87,7 +87,7 @@ XPropertySetInfo_impl::getProperties() sal_Bool SAL_CALL XPropertySetInfo_impl::hasPropertyByName( const OUString& aName ) { - return std::any_of(m_seq.begin(), m_seq.end(), + return std::any_of(std::cbegin(m_seq), std::cend(m_seq), [&aName](const beans::Property& rProp) { return rProp.Name == aName; }); } diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx index 74531e226a23..2d954a8c6d7f 100644 --- a/ucb/source/ucp/file/filrset.cxx +++ b/ucb/source/ucp/file/filrset.cxx @@ -590,13 +590,13 @@ XResultSet_impl::getCapabilities() uno::Reference< sdbc::XResultSetMetaData > SAL_CALL XResultSet_impl::getMetaData() { - auto pProp = std::find_if(m_sProperty.begin(), m_sProperty.end(), + auto pProp = std::find_if(std::cbegin(m_sProperty), std::cend(m_sProperty), [](const beans::Property& rProp) { return rProp.Name == "Title"; }); - if (pProp != m_sProperty.end()) + if (pProp != std::cend(m_sProperty)) { std::vector< ::ucbhelper::ResultSetColumnData > aColumnData( m_sProperty.getLength() ); - auto n = std::distance(m_sProperty.begin(), pProp); + auto n = std::distance(std::cbegin(m_sProperty), pProp); // @@@ #82177# - Determine correct value! aColumnData[ n ].isCaseSensitive = false; diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx index dfc4e373d7b8..f3ed2e84ca70 100644 --- a/ucb/source/ucp/file/prov.cxx +++ b/ucb/source/ucp/file/prov.cxx @@ -280,9 +280,9 @@ XPropertySetInfoImpl2::queryInterface( const Type& rType ) Property SAL_CALL XPropertySetInfoImpl2::getPropertyByName( const OUString& aName ) { - auto pProp = std::find_if(m_seq.begin(), m_seq.end(), + auto pProp = std::find_if(std::cbegin(m_seq), std::cend(m_seq), [&aName](const Property& rProp) { return rProp.Name == aName; }); - if (pProp != m_seq.end()) + if (pProp != std::cend(m_seq)) return *pProp; throw UnknownPropertyException( aName ); @@ -300,7 +300,7 @@ sal_Bool SAL_CALL XPropertySetInfoImpl2::hasPropertyByName( const OUString& aName ) { - return std::any_of(m_seq.begin(), m_seq.end(), + return std::any_of(std::cbegin(m_seq), std::cend(m_seq), [&aName](const Property& rProp) { return rProp.Name == aName; }); } diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx index eb9219b9a5c1..ec74d7aeca8b 100644 --- a/ucb/source/ucp/ftp/ftpcontent.cxx +++ b/ucb/source/ucp/ftp/ftpcontent.cxx @@ -807,7 +807,7 @@ Sequence<Any> FTPContent::setPropertyValues( ret[i] <<= excep; } } else { - Sequence<Property> props = + const Sequence<Property> props = getProperties(Reference<XCommandEnvironment>(nullptr)); // either unknown or read-only diff --git a/ucb/source/ucp/ftp/ftpresultsetbase.cxx b/ucb/source/ucp/ftp/ftpresultsetbase.cxx index 66af1c4a8479..5a9a3326062d 100644 --- a/ucb/source/ucp/ftp/ftpresultsetbase.cxx +++ b/ucb/source/ucp/ftp/ftpresultsetbase.cxx @@ -374,16 +374,16 @@ public: beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override { - auto pProp = std::find_if(m_aSeq.begin(), m_aSeq.end(), + auto pProp = std::find_if(std::cbegin(m_aSeq), std::cend(m_aSeq), [&aName](const beans::Property& rProp) { return aName == rProp.Name; }); - if (pProp != m_aSeq.end()) + if (pProp != std::cend(m_aSeq)) return *pProp; throw beans::UnknownPropertyException(aName); } sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override { - return std::any_of(m_aSeq.begin(), m_aSeq.end(), + return std::any_of(std::cbegin(m_aSeq), std::cend(m_aSeq), [&Name](const beans::Property& rProp) { return Name == rProp.Name; }); } diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx index 0ef3028b6be9..c613926e445d 100644 --- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx @@ -3025,7 +3025,7 @@ Content::ResourceType Content::resourceTypeForLocks( uno::Sequence< ucb::LockEntry > aSupportedLocks; if ( rProp.Value >>= aSupportedLocks ) { - bool isSupported = std::any_of(aSupportedLocks.begin(), aSupportedLocks.end(), + bool isSupported = std::any_of(std::cbegin(aSupportedLocks), std::cend(aSupportedLocks), [](const ucb::LockEntry& rLock) { // TODO: if the lock type is changed from 'exclusive write' to 'shared write' // e.g. to implement 'Calc shared file feature', the ucb::LockScope_EXCLUSIVE diff --git a/ucbhelper/source/provider/providerhelper.cxx b/ucbhelper/source/provider/providerhelper.cxx index 95fbe6a68453..438468a36c90 100644 --- a/ucbhelper/source/provider/providerhelper.cxx +++ b/ucbhelper/source/provider/providerhelper.cxx @@ -385,7 +385,7 @@ bool ContentProviderImplHelper::copyAdditionalPropertySet( const uno::Sequence< beans::PropertyValue > aValues = xOldPropAccess->getPropertyValues(); - uno::Sequence< beans::Property > aProps + const uno::Sequence< beans::Property > aProps = xPropSetInfo->getProperties(); if ( aValues.hasElements() ) diff --git a/ucbhelper/source/provider/resultsetmetadata.cxx b/ucbhelper/source/provider/resultsetmetadata.cxx index ef4f678b9f5f..ee3196d85426 100644 --- a/ucbhelper/source/provider/resultsetmetadata.cxx +++ b/ucbhelper/source/provider/resultsetmetadata.cxx @@ -284,7 +284,7 @@ sal_Int32 SAL_CALL ResultSetMetaData::getColumnType( sal_Int32 column ) Reference< XPropertySetInfo > xInfo = PropertiesManager::create( m_xContext ); // Less (remote) calls... - Sequence< Property > aProps = xInfo->getProperties(); + const Sequence< Property > aProps = xInfo->getProperties(); for ( Property& rProp : m_aProps ) { diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx index 5826eb0ac082..ed1d45fb984d 100644 --- a/unotools/source/config/cmdoptions.cxx +++ b/unotools/source/config/cmdoptions.cxx @@ -281,9 +281,8 @@ Sequence< OUString > SvtCommandOptions_Impl::impl_GetPropertyNames() Sequence< OUString > lDisabledItems = GetNodeNames( SETNODE_DISABLED, utl::ConfigNameFormat::LocalPath ); // Expand all keys - std::transform(lDisabledItems.begin(), lDisabledItems.end(), lDisabledItems.begin(), - [](const OUString& rItem) -> OUString { - return SETNODE_DISABLED PATHDELIMITER + rItem + PATHDELIMITER PROPERTYNAME_CMD; }); + for (OUString& rItem : toNonConstRange(lDisabledItems)) + rItem = SETNODE_DISABLED PATHDELIMITER + rItem + PATHDELIMITER PROPERTYNAME_CMD; // Return result. return lDisabledItems; diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index 152730cec0b1..cf0384ad3651 100644 --- a/unotools/source/config/configitem.cxx +++ b/unotools/source/config/configitem.cxx @@ -316,7 +316,7 @@ Sequence< sal_Bool > ConfigItem::GetReadOnlyStates(const css::uno::Sequence< OUS // We must be sure to return a valid information every time! // Set default to non readonly... similar to the configuration handling of this property. - std::fill(lStates.begin(), lStates.end(), false); + std::fill_n(lStates.begin(), lStates.getLength(), false); // no access - no information... Reference< XHierarchicalNameAccess > xHierarchyAccess = GetTree(); @@ -655,7 +655,7 @@ static void lcl_normalizeLocalNames(Sequence< OUString >& _rNames, ConfigNameFor OUString sTypeName = xTypeContainer->getElementTemplateName(); sTypeName = sTypeName.copy(sTypeName.lastIndexOf('/')+1); - std::transform(_rNames.begin(), _rNames.end(), _rNames.begin(), + std::transform(std::cbegin(_rNames), std::cend(_rNames), _rNames.begin(), [&sTypeName](const OUString& rName) -> OUString { return wrapConfigurationElementName(rName,sTypeName); }); } else @@ -663,7 +663,7 @@ static void lcl_normalizeLocalNames(Sequence< OUString >& _rNames, ConfigNameFor Reference<XServiceInfo> xSVI(_xParentNode, UNO_QUERY); if (xSVI.is() && xSVI->supportsService("com.sun.star.configuration.SetAccess")) { - std::transform(_rNames.begin(), _rNames.end(), _rNames.begin(), + std::transform(std::cbegin(_rNames), std::cend(_rNames), _rNames.begin(), [](const OUString& rName) -> OUString { return wrapConfigurationElementName(rName); }); } } diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index f7722d6fdf25..f8bfb4c06418 100644 --- a/unotools/source/config/confignode.cxx +++ b/unotools/source/config/confignode.cxx @@ -192,7 +192,7 @@ namespace utl { aReturn = m_xDirectAccess->getElementNames(); // normalize the names - std::transform(aReturn.begin(), aReturn.end(), aReturn.begin(), + std::transform(std::cbegin(aReturn), std::cend(aReturn), aReturn.begin(), [this](const OUString& rName) -> OUString { return normalizeName(rName, NO_CONFIGURATION); }); } catch(Exception&) diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx index a4f4c509e839..26bdb65e4638 100644 --- a/unotools/source/config/moduleoptions.cxx +++ b/unotools/source/config/moduleoptions.cxx @@ -738,16 +738,14 @@ void SvtModuleOptions_Impl::MakeReadonlyStatesAvailable() return; css::uno::Sequence< OUString > lFactories = GetNodeNames(OUString()); - std::transform(lFactories.begin(), lFactories.end(), lFactories.begin(), - [](const OUString& rFactory) -> OUString { - return rFactory + PATHSEPARATOR PROPERTYNAME_DEFAULTFILTER; - }); + for (OUString& rFactory : toNonConstRange(lFactories)) + rFactory += PATHSEPARATOR PROPERTYNAME_DEFAULTFILTER; css::uno::Sequence< sal_Bool > lReadonlyStates = GetReadOnlyStates(lFactories); sal_Int32 c = lFactories.getLength(); for (sal_Int32 i=0; i<c; ++i) { - OUString& rFactoryName = lFactories[i]; + const OUString& rFactoryName = std::as_const(lFactories)[i]; SvtModuleOptions::EFactory eFactory; if (!ClassifyFactoryByName(rFactoryName, eFactory)) diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index 9d67f1913887..782ae724c6f4 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -100,7 +100,7 @@ void LocaleDataWrapper::loadData() const css::lang::Locale& rMyLocale = maLanguageTag.getLocale(); { - Sequence< Currency2 > aCurrSeq = getAllCurrencies(); + const Sequence< Currency2 > aCurrSeq = getAllCurrencies(); if ( !aCurrSeq.hasElements() ) { if (areChecksEnabled()) @@ -133,7 +133,7 @@ void LocaleDataWrapper::loadData() { xDefaultCalendar.reset(); xSecondaryCalendar.reset(); - Sequence< Calendar2 > xCals = getAllCalendars(); + const Sequence< Calendar2 > xCals = getAllCalendars(); if (xCals.getLength() > 1) { auto pCal = std::find_if(xCals.begin(), xCals.end(), diff --git a/uui/source/iahndl-filter.cxx b/uui/source/iahndl-filter.cxx index 706c568aa40a..b2f0bf71be9c 100644 --- a/uui/source/iahndl-filter.cxx +++ b/uui/source/iahndl-filter.cxx @@ -214,9 +214,9 @@ handleFilterOptionsRequest_( uno::Sequence < beans::PropertyValue > aProps; if ( xFilterCFG->getByName( aFilterName ) >>= aProps ) { - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const beans::PropertyValue& rProp) { return rProp.Name == "UIComponent"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) { OUString aServiceName; pProp->Value >>= aServiceName; diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx index ac7560aa4935..136907da7cc2 100644 --- a/uui/source/iahndl-ssl.cxx +++ b/uui/source/iahndl-ssl.cxx @@ -255,7 +255,7 @@ handleCertificateValidationRequest_( rRequest.Certificate ); } - uno::Sequence< uno::Reference< security::XCertificateExtension > > extensions = rRequest.Certificate->getExtensions(); + const uno::Sequence< uno::Reference< security::XCertificateExtension > > extensions = rRequest.Certificate->getExtensions(); uno::Reference< security::XSanExtension > sanExtension; auto pExtension = std::find_if(extensions.begin(), extensions.end(), [](const uno::Reference< security::XCertificateExtension >& element) { diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx index 9dcef8a77225..cfa9e54a6134 100644 --- a/vbahelper/source/msforms/vbalistbox.cxx +++ b/vbahelper/source/msforms/vbalistbox.cxx @@ -227,7 +227,7 @@ ScVbaListBox::getValueEvent() uno::Sequence< sal_Int16 > nList; m_xProps->getPropertyValue( "SelectedItems" ) >>= nList; sal_Int32 nIndex = m_nIndex; - bool bRet = std::find(nList.begin(), nList.end(), nIndex) != nList.end(); + bool bRet = std::find(std::cbegin(nList), std::cend(nList), nIndex) != std::cend(nList); return uno::makeAny( bRet ); } diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx index 3fffbd5b1941..8f3ff6b45601 100644 --- a/vbahelper/source/msforms/vbalistcontrolhelper.cxx +++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx @@ -120,7 +120,7 @@ ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargInde sVec.push_back( sString ); // point at first element to copy - sVec.insert( sVec.end(), std::next(sList.begin(), nIndex), sList.end() ); + sVec.insert( sVec.end(), std::next(std::cbegin(sList), nIndex), std::cend(sList) ); sList.realloc( sList.getLength() + 1 ); diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx index 01de54cd8244..562205451839 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx @@ -182,7 +182,7 @@ OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< css: if( !sResourceUrl.isEmpty() ) return sResourceUrl; - uno::Sequence< OUString > allNames = xNameAccess->getElementNames(); + const uno::Sequence< OUString > allNames = xNameAccess->getElementNames(); auto pName = std::find_if(allNames.begin(), allNames.end(), [this, &sName](const OUString& rName) { return rName.startsWith( ITEM_TOOLBAR_URL ) diff --git a/vbahelper/source/vbahelper/vbacommandbars.cxx b/vbahelper/source/vbahelper/vbacommandbars.cxx index a864339fd38d..4cc3d28e0cf5 100644 --- a/vbahelper/source/vbahelper/vbacommandbars.cxx +++ b/vbahelper/source/vbahelper/vbacommandbars.cxx @@ -184,7 +184,7 @@ ScVbaCommandBars::getCount() { // Filter out all toolbars from the window collection sal_Int32 nCount = 1; // there is a Menubar in OOo - uno::Sequence< ::OUString > allNames = m_xNameAccess->getElementNames(); + const uno::Sequence< ::OUString > allNames = m_xNameAccess->getElementNames(); nCount += std::count_if(allNames.begin(), allNames.end(), [](const OUString& rName) { return rName.indexOf( "private:resource/toolbar/" ) != -1; }); return nCount; diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 389a13352e6a..2eaa7e9f5a38 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -734,9 +734,10 @@ uno::Any getPropertyValue( const uno::Sequence< beans::PropertyValue >& aProp, c bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName, const uno::Any& aValue ) { - auto pProp = std::find_if(aProp.begin(), aProp.end(), + auto [begin, end] = toNonConstRange(aProp); + auto pProp = std::find_if(begin, end, [&aName](const beans::PropertyValue& rProp) { return rProp.Name == aName; }); - if (pProp != aProp.end()) + if (pProp != end) { pProp->Value = aValue; return true; diff --git a/vcl/source/filter/FilterConfigItem.cxx b/vcl/source/filter/FilterConfigItem.cxx index 90933bbcc2cc..7a2e98aba8bb 100644 --- a/vcl/source/filter/FilterConfigItem.cxx +++ b/vcl/source/filter/FilterConfigItem.cxx @@ -217,7 +217,7 @@ bool FilterConfigItem::ImplGetPropertyValue( Any& rAny, const Reference< XProper // if property is available it returns a pointer, // otherwise the result is null -PropertyValue* FilterConfigItem::GetPropertyValue( Sequence< PropertyValue >& rPropSeq, const OUString& rName ) +const PropertyValue* FilterConfigItem::GetPropertyValue( const Sequence< PropertyValue >& rPropSeq, const OUString& rName ) { auto pProp = std::find_if(rPropSeq.begin(), rPropSeq.end(), [&rName](const PropertyValue& rProp) { return rProp.Name == rName; }); @@ -235,9 +235,9 @@ bool FilterConfigItem::WritePropertyValue( Sequence< PropertyValue >& rPropSeq, bool bRet = false; if ( !rPropValue.Name.isEmpty() ) { - auto pProp = std::find_if(rPropSeq.begin(), rPropSeq.end(), + auto pProp = std::find_if(std::cbegin(rPropSeq), std::cend(rPropSeq), [&rPropValue](const PropertyValue& rProp) { return rProp.Name == rPropValue.Name; }); - sal_Int32 i = std::distance(rPropSeq.begin(), pProp); + sal_Int32 i = std::distance(std::cbegin(rPropSeq), pProp); sal_Int32 nCount = rPropSeq.getLength(); if ( i == nCount ) rPropSeq.realloc( ++nCount ); @@ -253,7 +253,7 @@ bool FilterConfigItem::ReadBool( const OUString& rKey, bool bDefault ) { Any aAny; bool bRetValue = bDefault; - PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey ); + const PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey ); if ( pPropVal ) { pPropVal->Value >>= bRetValue; @@ -273,7 +273,7 @@ sal_Int32 FilterConfigItem::ReadInt32( const OUString& rKey, sal_Int32 nDefault { Any aAny; sal_Int32 nRetValue = nDefault; - PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey ); + const PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey ); if ( pPropVal ) { pPropVal->Value >>= nRetValue; @@ -293,7 +293,7 @@ OUString FilterConfigItem::ReadString( const OUString& rKey, const OUString& rDe { Any aAny; OUString aRetValue( rDefault ); - PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey ); + const PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey ); if ( pPropVal ) { pPropVal->Value >>= aRetValue; diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 3ff7de43e2fb..8bacefd777d8 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1059,7 +1059,7 @@ ErrCode GraphicFilter::readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkTy // Make a uncompressed copy for GfxLink rGraphicContentSize = nMemoryLength; rpGraphicContent.reset(new sal_uInt8[rGraphicContentSize]); - std::copy(aNewData.begin(), aNewData.end(), rpGraphicContent.get()); + std::copy(std::cbegin(aNewData), std::cend(aNewData), rpGraphicContent.get()); if (!aMemStream.GetError()) { diff --git a/vcl/source/gdi/configsettings.cxx b/vcl/source/gdi/configsettings.cxx index 18d93b4e7fd0..67e3b89ebfcc 100644 --- a/vcl/source/gdi/configsettings.cxx +++ b/vcl/source/gdi/configsettings.cxx @@ -93,19 +93,17 @@ void SettingsConfigItem::getValues() #if OSL_DEBUG_LEVEL > 2 SAL_INFO( "vcl", "found settings data for " << aKeyName ); #endif - Sequence< OUString > aKeys( GetNodeNames( aKeyName ) ); + const Sequence< OUString > aKeys( GetNodeNames( aKeyName ) ); Sequence< OUString > aSettingsKeys( aKeys.getLength() ); std::transform(aKeys.begin(), aKeys.end(), aSettingsKeys.begin(), [&aKeyName](const OUString& rKey) -> OUString { return aKeyName + "/" + rKey; }); - Sequence< Any > aValues( GetProperties( aSettingsKeys ) ); - const OUString* pFrom = aKeys.getConstArray(); - const Any* pValue = aValues.getConstArray(); - for( int i = 0; i < aValues.getLength(); i++, pValue++ ) + const Sequence< Any > aValues( GetProperties( aSettingsKeys ) ); + for( int i = 0; i < aValues.getLength(); i++ ) { - if( auto pLine = o3tl::tryAccess<OUString>(*pValue) ) + if( auto pLine = o3tl::tryAccess<OUString>(aValues[i]) ) { if( !pLine->isEmpty() ) - m_aSettings[ aKeyName ][ pFrom[i] ] = *pLine; + m_aSettings[ aKeyName ][ aKeys[i] ] = *pLine; #if OSL_DEBUG_LEVEL > 2 SAL_INFO( "vcl", " \"" << aKeys.getConstArray()[i] << "\"=\"" << *pLine << "\"" ); #endif diff --git a/vcl/source/graphic/UnoGraphic.cxx b/vcl/source/graphic/UnoGraphic.cxx index 9d6d79532fb8..fde322d94b7e 100644 --- a/vcl/source/graphic/UnoGraphic.cxx +++ b/vcl/source/graphic/UnoGraphic.cxx @@ -97,7 +97,7 @@ sal_Bool SAL_CALL Graphic::supportsService( const OUString& rServiceName ) uno::Sequence< OUString > SAL_CALL Graphic::getSupportedServiceNames() { uno::Sequence< OUString > aRet( ::unographic::GraphicDescriptor::getSupportedServiceNames() ); - uno::Sequence< OUString > aNew { "com.sun.star.graphic.Graphic" }; + const uno::Sequence< OUString > aNew { "com.sun.star.graphic.Graphic" }; sal_Int32 nOldCount = aRet.getLength(); aRet.realloc( nOldCount + aNew.getLength() ); diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 805aa7ad693f..5c280bb663c3 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -439,9 +439,9 @@ bool IsExperimental(const OUString& rsCommandName, const OUString& rModuleName) if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels ) xUICommandLabels->getByName(rsCommandName) >>= aProperties; - auto pProp = std::find_if(aProperties.begin(), aProperties.end(), + auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), [](const beans::PropertyValue& rProp) { return rProp.Name == "IsExperimental"; }); - if (pProp != aProperties.end()) + if (pProp != std::cend(aProperties)) { bool bValue; return (pProp->Value >>= bValue) && bValue; diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index b3d77b6a3887..5278206552f8 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1024,7 +1024,7 @@ static bool lcl_emptyRow(std::vector<RowSequence_t>& rTableRanges, sal_Int32 nRo return false; } - RowSequence_t rRowSeq = rTableRanges[nRow]; + const RowSequence_t rRowSeq = rTableRanges[nRow]; if (!rRowSeq.hasElements()) { SAL_WARN("writerfilter.dmapper", "m_aCellProperties not in sync with rTableRanges?"); @@ -1107,7 +1107,7 @@ css::uno::Sequence<css::beans::PropertyValues> DomainMapperTableHandler::endTabl // table style has got bigger precedence than docDefault style, // but lower precedence than the paragraph styles and direct paragraph formatting -void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParagraph rParaProp, std::vector< PropertyIds > aAllTableParaProperties, css::beans::PropertyValues rCellProperties) +void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParagraph rParaProp, std::vector< PropertyIds > aAllTableParaProperties, const css::beans::PropertyValues rCellProperties) { for( auto const& eId : aAllTableParaProperties ) { diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx index 5a2a37acd90f..4e396b6b23fc 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx @@ -90,7 +90,7 @@ public: */ void startTable(const TablePropertyMapPtr& pProps); - void ApplyParagraphPropertiesFromTableStyle(TableParagraph rParaProp, std::vector< PropertyIds > aAllTableProperties, css::beans::PropertyValues rCellProperties); + void ApplyParagraphPropertiesFromTableStyle(TableParagraph rParaProp, std::vector< PropertyIds > aAllTableProperties, const css::beans::PropertyValues rCellProperties); /// Handle end of table. void endTable(unsigned int nestedTableLevel, bool bTableStartsAtCellStart); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 65550495b1e1..c8e5ee0fb912 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -7832,9 +7832,9 @@ uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharSt } uno::Sequence<beans::PropertyValue> aProps; xLevels->getByIndex(nListLevel) >>= aProps; - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const beans::PropertyValue& rProp) { return rProp.Name == "CharStyleName"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) { OUString aCharStyle; pProp->Value >>= aCharStyle; @@ -7903,9 +7903,9 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const sal_Int32 nListId, sal_I { uno::Sequence<beans::PropertyValue> aProps; xNumberingRules->getByIndex(nNumberingLevel) >>= aProps; - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [&aProp](const beans::PropertyValue& rProp) { return rProp.Name == aProp; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) pProp->Value >>= nRet; } } @@ -7934,9 +7934,9 @@ sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(const OUString& aProp) { uno::Sequence<beans::PropertyValue> aProps; xNumberingRules->getByIndex(nNumberingLevel) >>= aProps; - auto pPropVal = std::find_if(aProps.begin(), aProps.end(), + auto pPropVal = std::find_if(std::cbegin(aProps), std::cend(aProps), [&aProp](const beans::PropertyValue& rProp) { return rProp.Name == aProp; }); - if (pPropVal != aProps.end()) + if (pPropVal != std::cend(aProps)) pPropVal->Value >>= nRet; } diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index e0a2828b5606..ec16cdd3b36e 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -803,7 +803,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) xShapeProps->getPropertyValue("InteropGrabBag") >>= aGrabBag; // if the shape contains effects in the grab bag, we should not transform it // in a XTextContent so those effects can be preserved - bool bContainsEffects = std::any_of(aGrabBag.begin(), aGrabBag.end(), [](const auto& rProp) { + bool bContainsEffects = std::any_of(std::cbegin(aGrabBag), std::cend(aGrabBag), [](const auto& rProp) { return rProp.Name == "EffectProperties" || rProp.Name == "3DEffectProperties" || rProp.Name == "ArtisticEffectProperties"; diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index 51484b74408f..852d5e611750 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -172,13 +172,11 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetCharStyleProperties( ) { PropertyValueVector_t rProperties; - uno::Sequence< beans::PropertyValue > vPropVals = PropertyMap::GetPropertyValues(); - beans::PropertyValue* aValIter = vPropVals.begin(); - beans::PropertyValue* aEndIter = vPropVals.end(); + const uno::Sequence< beans::PropertyValue > vPropVals = PropertyMap::GetPropertyValues(); const bool bIsSymbol(GetBulletChar().getLength() <= 1); - for( ; aValIter != aEndIter; ++aValIter ) - if (! IgnoreForCharStyle(aValIter->Name, bIsSymbol)) - rProperties.emplace_back(aValIter->Name, 0, aValIter->Value, beans::PropertyState_DIRECT_VALUE); + for( const auto& rPropNal : vPropVals ) + if (! IgnoreForCharStyle(rPropNal.Name, bIsSymbol)) + rProperties.emplace_back(rPropNal.Name, 0, rPropNal.Value, beans::PropertyState_DIRECT_VALUE); return comphelper::containerToSequence(rProperties); } diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 920874afa39d..393d49839cc9 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -168,7 +168,7 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues( bool bChar { uno::Sequence< beans::PropertyValue > aSeq; rPropPair.second.getValue() >>= aSeq; - std::copy(aSeq.begin(), aSeq.end(), pCellGrabBagValues + nCellGrabBagValue); + std::copy(std::cbegin(aSeq), std::cend(aSeq), pCellGrabBagValues + nCellGrabBagValue); nCellGrabBagValue += aSeq.getLength(); } else @@ -1988,19 +1988,19 @@ void SectionPropertyMap::ApplyProperties_( const uno::Reference< beans::XPropert std::vector< uno::Any > vValues; { // Convert GetPropertyValues() value into something useful - uno::Sequence< beans::PropertyValue > vPropVals = GetPropertyValues(); + const uno::Sequence< beans::PropertyValue > vPropVals = GetPropertyValues(); //Temporarily store the items that are in grab bags uno::Sequence< beans::PropertyValue > vCharVals; uno::Sequence< beans::PropertyValue > vParaVals; - beans::PropertyValue* pCharGrabBag = std::find_if( vPropVals.begin(), vPropVals.end(), NamedPropertyValue( "CharInteropGrabBag" ) ); + const beans::PropertyValue* pCharGrabBag = std::find_if( vPropVals.begin(), vPropVals.end(), NamedPropertyValue( "CharInteropGrabBag" ) ); if ( pCharGrabBag != vPropVals.end() ) (pCharGrabBag->Value) >>= vCharVals; - beans::PropertyValue* pParaGrabBag = std::find_if( vPropVals.begin(), vPropVals.end(), NamedPropertyValue( "ParaInteropGrabBag" ) ); + const beans::PropertyValue* pParaGrabBag = std::find_if( vPropVals.begin(), vPropVals.end(), NamedPropertyValue( "ParaInteropGrabBag" ) ); if ( pParaGrabBag != vPropVals.end() ) (pParaGrabBag->Value) >>= vParaVals; - for ( beans::PropertyValue* pIter = vPropVals.begin(); pIter != vPropVals.end(); ++pIter ) + for ( const beans::PropertyValue* pIter = vPropVals.begin(); pIter != vPropVals.end(); ++pIter ) { if ( pIter != pCharGrabBag && pIter != pParaGrabBag && pIter->Name != "IsProtected" //section-only property diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 4e51aa0aecbb..0074fb948a12 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -350,7 +350,7 @@ void StyleSheetTable_Impl::SetPropertiesToDefault(const uno::Reference<style::XS // See if the existing style has any non-default properties. If so, reset them back to default. uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY); uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); - uno::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties(); + const uno::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties(); std::vector<OUString> aPropertyNames; aPropertyNames.reserve(aProperties.getLength()); std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aPropertyNames), diff --git a/writerperfect/qa/unit/WpftLoader.cxx b/writerperfect/qa/unit/WpftLoader.cxx index 3338e72c3b0b..c5e7b7b60700 100644 --- a/writerperfect/qa/unit/WpftLoader.cxx +++ b/writerperfect/qa/unit/WpftLoader.cxx @@ -179,7 +179,7 @@ void WpftLoader::impl_detectFilterName(uno::Sequence<beans::PropertyValue>& rDes const OUString& rTypeName) { bool bHasFilterName - = std::any_of(rDescriptor.begin(), rDescriptor.end(), + = std::any_of(std::cbegin(rDescriptor), std::cend(rDescriptor), [](const beans::PropertyValue& rProp) { return "FilterName" == rProp.Name; }); if (bHasFilterName) return; @@ -194,8 +194,9 @@ void WpftLoader::impl_detectFilterName(uno::Sequence<beans::PropertyValue>& rDes { const sal_Int32 nDescriptorLen = rDescriptor.getLength(); rDescriptor.realloc(nDescriptorLen + 1); - rDescriptor[nDescriptorLen].Name = "FilterName"; - rDescriptor[nDescriptorLen].Value <<= aFilterName; + auto& el = rDescriptor[nDescriptorLen]; + el.Name = "FilterName"; + el.Value <<= aFilterName; return; } } diff --git a/xmlhelp/source/cxxhelp/provider/content.cxx b/xmlhelp/source/cxxhelp/provider/content.cxx index 1dc5347f2d1e..c1dd7486f4dc 100644 --- a/xmlhelp/source/cxxhelp/provider/content.cxx +++ b/xmlhelp/source/cxxhelp/provider/content.cxx @@ -230,9 +230,9 @@ uno::Any SAL_CALL Content::execute( } uno::Sequence< uno::Any > ret(propertyValues.getLength()); - uno::Sequence< beans::Property > props(getProperties(Environment)); + const uno::Sequence< beans::Property > props(getProperties(Environment)); // No properties can be set - std::transform(propertyValues.begin(), propertyValues.end(), ret.begin(), + std::transform(std::cbegin(propertyValues), std::cend(propertyValues), ret.begin(), [&props](const beans::PropertyValue& rPropVal) { if (std::any_of(props.begin(), props.end(), [&rPropVal](const beans::Property& rProp) { return rProp.Name == rPropVal.Name; })) diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 37eb36b78d43..b5ca5ade2d11 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -1156,7 +1156,7 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromP OUString aHelpMediaType( "application/vnd.sun.star.help" ); if( xPackage->isBundle() ) { - Sequence< Reference< deployment::XPackage > > aPkgSeq = xPackage->getBundle + const Sequence< Reference< deployment::XPackage > > aPkgSeq = xPackage->getBundle ( Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>() ); auto pSubPkg = std::find_if(aPkgSeq.begin(), aPkgSeq.end(), [&aHelpMediaType](const Reference< deployment::XPackage >& xSubPkg) { diff --git a/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx b/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx index ddb982985c65..b1f6219af4b7 100644 --- a/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx +++ b/xmlhelp/source/cxxhelp/provider/resultsetbase.cxx @@ -368,16 +368,16 @@ public: beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override { - auto pProp = std::find_if(m_aSeq.begin(), m_aSeq.end(), + auto pProp = std::find_if(std::cbegin(m_aSeq), std::cend(m_aSeq), [&aName](const beans::Property& rProp) { return aName == rProp.Name; }); - if (pProp != m_aSeq.end()) + if (pProp != std::cend(m_aSeq)) return *pProp; throw beans::UnknownPropertyException(aName); } sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override { - return std::any_of(m_aSeq.begin(), m_aSeq.end(), + return std::any_of(std::cbegin(m_aSeq), std::cend(m_aSeq), [&Name](const beans::Property& rProp) { return Name == rProp.Name; }); } diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx index 852101bb52ad..a2e3afd50769 100644 --- a/xmlhelp/source/treeview/tvread.cxx +++ b/xmlhelp/source/treeview/tvread.cxx @@ -877,7 +877,7 @@ Reference< deployment::XPackage > TreeFileIterator::implGetHelpPackageFromPackag if( xPackage->isBundle() ) { - Sequence< Reference< deployment::XPackage > > aPkgSeq = xPackage->getBundle + const Sequence< Reference< deployment::XPackage > > aPkgSeq = xPackage->getBundle ( Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>() ); auto pSubPkg = std::find_if(aPkgSeq.begin(), aPkgSeq.end(), [](const Reference< deployment::XPackage >& xSubPkg) { diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 54a2879d4f2d..d8a91ff49659 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -958,7 +958,7 @@ void SchXMLChartContext::MergeSeriesForStockChart() for( const auto& rCooSys : aCooSysSeq ) { uno::Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + const uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); auto pChartType = std::find_if(aChartTypes.begin(), aChartTypes.end(), [](const auto& rChartType) { return rChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType"; }); if (pChartType != aChartTypes.end()) diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index b230a924472c..372cd9cdaf9a 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -458,7 +458,7 @@ Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequ Reference< chart2::data::XDataSource > xDataSource( rSeries, uno::UNO_QUERY ); if( !xDataSource.is() ) continue; - uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); + const uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); aContainer.insert( aContainer.end(), aDataSequences.begin(), aDataSequences.end() ); } } @@ -495,7 +495,7 @@ Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( c aLabeledSeqVector.push_back( xCategories ); rOutSourceHasCategoryLabels = xCategories.is(); - Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector( + const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector( lcl_getAllSeriesSequences( xChartDoc ) ); //the first x-values is always the next sequence //todo ... other x-values get lost for old format @@ -690,24 +690,25 @@ uno::Sequence< OUString > lcl_DataSequenceToStringSequence( if( aRole.match("values-x") ) { //lcl_clearIfNoValuesButTextIsContained - replace by indices if the values are not appropriate - bool bHasValue = std::any_of(aValuesSequence.begin(), aValuesSequence.end(), + bool bHasValue = std::any_of(std::cbegin(aValuesSequence), std::cend(aValuesSequence), [](double fValue) { return !std::isnan( fValue ); }); if(!bHasValue) { //no double value is contained //is there any text? - uno::Sequence< OUString > aStrings( lcl_DataSequenceToStringSequence( xSeq ) ); + const uno::Sequence< OUString > aStrings( lcl_DataSequenceToStringSequence( xSeq ) ); bool bHasText = std::any_of(aStrings.begin(), aStrings.end(), [](const OUString& rString) { return !rString.isEmpty(); }); if( bHasText ) { - std::iota(aValuesSequence.begin(), aValuesSequence.end(), 1); + auto [begin, end] = toNonConstRange(aValuesSequence); + std::iota(begin, end, 1); } } } } - aResult.insert( aResult.end(), aValuesSequence.begin(), aValuesSequence.end() ); + aResult.insert( aResult.end(), std::cbegin(aValuesSequence), std::cend(aValuesSequence) ); return aResult; } @@ -855,7 +856,7 @@ lcl_TableData lcl_getDataForLocalTable( //categories rCategories.clear(); - rCategories.insert( rCategories.begin(), aSimpleCategories.begin(), aSimpleCategories.end() ); + rCategories.insert( rCategories.begin(), std::cbegin(aSimpleCategories), std::cend(aSimpleCategories) ); if( !rCategoriesRange.isEmpty() ) { OUString aRange(rCategoriesRange); @@ -2553,7 +2554,7 @@ namespace Reference< chart2::data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY ); if( xNumericalDataSequence.is() ) { - Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() ); + const Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() ); if (std::any_of(aDoubles.begin(), aDoubles.end(), [](double fDouble) { return !std::isnan( fDouble ); })) return false;//have double value } @@ -2561,7 +2562,7 @@ namespace { aData = xDataSequence->getData(); double fDouble = 0.0; - bool bHaveDouble = std::any_of(aData.begin(), aData.end(), + bool bHaveDouble = std::any_of(std::cbegin(aData), std::cend(aData), [&fDouble](const uno::Any& rData) { return (rData >>= fDouble) && !std::isnan( fDouble ); }); if (bHaveDouble) return false;//have double value @@ -2571,7 +2572,7 @@ namespace Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY ); if( xTextualDataSequence.is() ) { - uno::Sequence< OUString > aStrings( xTextualDataSequence->getTextualData() ); + const uno::Sequence< OUString > aStrings( xTextualDataSequence->getTextualData() ); if (std::any_of(aStrings.begin(), aStrings.end(), [](const OUString& rString) { return !rString.isEmpty(); })) return true;//have text } @@ -2580,7 +2581,7 @@ namespace if( !aData.hasElements() ) aData = xDataSequence->getData(); OUString aString; - bool bHaveText = std::any_of(aData.begin(), aData.end(), + bool bHaveText = std::any_of(std::cbegin(aData), std::cend(aData), [&aString](const uno::Any& rData) { return (rData >>= aString) && !aString.isEmpty(); }); if (bHaveText) return true;//have text diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index d0523a39dc02..e1a19dc1b71a 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -143,7 +143,7 @@ void SchXMLImportHelper::DeleteDataSeries( for( const auto& rChartType : aChartTypes ) { Reference< chart2::XDataSeriesContainer > xSeriesCnt( rChartType, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries()); + const Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries()); if (std::find(aSeriesSeq.begin(), aSeriesSeq.end(), xSeries) != aSeriesSeq.end()) { diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index 1d91af151317..6739bab69197 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -230,7 +230,7 @@ Reference< chart2::data::XLabeledDataSequence2 > lcl_createAndAddSequenceToSerie xLabeledSeq->setValues( xSeq ); // add new sequence to data series / push to front to have the correct sequence order if charttype is changed afterwards - Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeq( xSeriesSource->getDataSequences()); + const Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeq( xSeriesSource->getDataSequences()); sal_Int32 nOldCount = aOldSeq.getLength(); Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 ); aNewSeq[0].set(xLabeledSeq, uno::UNO_QUERY_THROW); diff --git a/xmloff/source/chart/SchXMLSeriesHelper.cxx b/xmloff/source/chart/SchXMLSeriesHelper.cxx index 9bccc3f83950..31a197596607 100644 --- a/xmloff/source/chart/SchXMLSeriesHelper.cxx +++ b/xmloff/source/chart/SchXMLSeriesHelper.cxx @@ -52,7 +52,7 @@ using ::com::sun::star::uno::Sequence; for( const auto& rChartType : aChartTypeSeq ) { Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); + const Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() ); } } @@ -118,7 +118,7 @@ uno::Reference< chart2::XChartType > lcl_getChartTypeOfSeries( if( !xDataSeriesContainer.is() ) continue; - uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + const uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); if (std::find(aSeriesList.begin(), aSeriesList.end(), xSeries) != aSeriesList.end()) return xChartType; } diff --git a/xmloff/source/draw/SignatureLineContext.cxx b/xmloff/source/draw/SignatureLineContext.cxx index d85acded8226..0217156e35fb 100644 --- a/xmloff/source/draw/SignatureLineContext.cxx +++ b/xmloff/source/draw/SignatureLineContext.cxx @@ -92,7 +92,7 @@ SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_Int32 /*nEl security::DocumentDigitalSignatures::createWithVersion( comphelper::getProcessComponentContext(), aODFVersion)); - Sequence<DocumentSignatureInformation> xSignatureInfo + const Sequence<DocumentSignatureInformation> xSignatureInfo = xSignatures->verifyDocumentContentSignatures(xStorage, Reference<XInputStream>()); // Try to find matching signature line image - if none exists that is fine, diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 8c94cd738c65..e4f4f6aed753 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -371,7 +371,7 @@ namespace xmloff "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" ); - std::transform(aXMLValueList.begin(), aXMLValueList.end(), aPropertyValueList.begin(), + std::transform(std::cbegin(aXMLValueList), std::cend(aXMLValueList), aPropertyValueList.begin(), [](const Any& rXMLValue) -> sal_Int16 { // only value sequences of numeric types implemented so far. double nVal( 0 ); diff --git a/xmloff/source/forms/formcellbinding.cxx b/xmloff/source/forms/formcellbinding.cxx index 21b09fc6b1cd..31c8e19c4d53 100644 --- a/xmloff/source/forms/formcellbinding.cxx +++ b/xmloff/source/forms/formcellbinding.cxx @@ -243,11 +243,12 @@ bool FormCellBindingHelper::isSpreadsheetDocumentWhichSupplies( const Reference< Reference< XMultiServiceFactory > xDocumentFactory( _rxDocument, UNO_QUERY ); OSL_ENSURE( xDocumentFactory.is(), "FormCellBindingHelper::isSpreadsheetDocumentWhichSupplies: spreadsheet document, but no factory?" ); - Sequence< OUString > aAvailableServices; if ( xDocumentFactory.is() ) - aAvailableServices = xDocumentFactory->getAvailableServiceNames( ); + { + const Sequence<OUString> aAvailableServices = xDocumentFactory->getAvailableServiceNames( ); - bYesItIs = std::any_of( aAvailableServices.begin(), aAvailableServices.end(), StringCompare( _rService ) ); + bYesItIs = std::any_of( aAvailableServices.begin(), aAvailableServices.end(), StringCompare( _rService ) ); + } } } catch( const Exception& ) diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx index 877edf198ab9..285bd487c35b 100644 --- a/xmloff/source/script/XMLEventExport.cxx +++ b/xmloff/source/script/XMLEventExport.cxx @@ -180,7 +180,7 @@ void XMLEventExport::ExportSingleEvent( /// export a single event void XMLEventExport::ExportEvent( - Sequence<PropertyValue>& rEventValues, + const Sequence<PropertyValue>& rEventValues, const XMLEventName& rXmlEventName, bool bUseWhitespace, bool& rExported ) diff --git a/xmloff/source/style/tabsthdl.cxx b/xmloff/source/style/tabsthdl.cxx index fc1edd5aa2b5..2e497f3eabaf 100644 --- a/xmloff/source/style/tabsthdl.cxx +++ b/xmloff/source/style/tabsthdl.cxx @@ -39,7 +39,7 @@ bool XMLTabStopPropHdl::equals( const uno::Any& r1, const uno::Any& r2 ) const uno::Sequence< style::TabStop> aSeq2; if( r2 >>= aSeq2 ) { - return std::equal(aSeq1.begin(), aSeq1.end(), aSeq2.begin(), aSeq2.end(), + return std::equal(std::cbegin(aSeq1), std::cend(aSeq1), std::cbegin(aSeq2), std::cend(aSeq2), [](const style::TabStop& a, const style::TabStop& b) { return a.Position == b.Position && a.Alignment == b.Alignment diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 1f0639febaa5..14400f04785a 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -930,7 +930,7 @@ static OUString lcl_GetDefaultCalendar( SvNumberFormatter const * pFormatter, La { lang::Locale aLocale( LanguageTag::convertToLocale( nLang ) ); - uno::Sequence<OUString> aCals = pCalendar->getAllCalendars( aLocale ); + const uno::Sequence<OUString> aCals = pCalendar->getAllCalendars( aLocale ); auto pCal = std::find_if(aCals.begin(), aCals.end(), [](const OUString& rCal) { return rCal != "gregorian"; }); if (pCal != aCals.end()) diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index 81488ec62543..cac07330f7bf 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -167,7 +167,7 @@ XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExp Reference< XMultiServiceFactory > xFac( rExp.GetModel(), UNO_QUERY ); if( xFac.is() ) try { - Sequence< OUString > sSNS( xFac->getAvailableServiceNames() ); + const Sequence< OUString > sSNS( xFac->getAvailableServiceNames() ); const OUString* pSNS = std::find_if(sSNS.begin(), sSNS.end(), [](const OUString& rSNS) { return rSNS == "com.sun.star.drawing.TableShape" diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index ca9ab26a9d42..d97e30c0c6fa 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -1798,9 +1798,9 @@ void XMLSectionExport::ExportMasterDocHeadingDummies() OUString sStyle; Sequence<PropertyValue> aProperties; xChapterNumbering->getByIndex( nLevel ) >>= aProperties; - auto pProp = std::find_if(aProperties.begin(), aProperties.end(), + auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; }); - if (pProp != aProperties.end()) + if (pProp != std::cend(aProperties)) pProp->Value >>= sStyle; if( !sStyle.isEmpty() ) diff --git a/xmloff/source/text/XMLTextNumRuleInfo.cxx b/xmloff/source/text/XMLTextNumRuleInfo.cxx index 07586ba53de6..c6889abbbc9e 100644 --- a/xmloff/source/text/XMLTextNumRuleInfo.cxx +++ b/xmloff/source/text/XMLTextNumRuleInfo.cxx @@ -175,9 +175,9 @@ void XMLTextNumRuleInfo::Set( Sequence<PropertyValue> aProps; mxNumRules->getByIndex( mnListLevel ) >>= aProps; - auto pProp = std::find_if(aProps.begin(), aProps.end(), + auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), [](const PropertyValue& rProp) { return rProp.Name == "StartWith"; }); - if (pProp != aProps.end()) + if (pProp != std::cend(aProps)) { pProp->Value >>= mnListLevelStartValue; } diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 813e66ed8083..8d4a96058f40 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -1479,9 +1479,9 @@ void XMLTextImportHelper::FindOutlineStyleName( OUString& rStyleName, Sequence<PropertyValue> aProperties; m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel ) >>= aProperties; - auto pProp = std::find_if(aProperties.begin(), aProperties.end(), + auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; }); - if (pProp != aProperties.end()) + if (pProp != std::cend(aProperties)) { OUString aOutlineStyle; pProp->Value >>= aOutlineStyle; diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index ef4766c696b2..2068c9b934a6 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -663,8 +663,8 @@ bool XMLTextColumnsPropertyHandler::equals( xColumns1->getReferenceValue() != xColumns2->getReferenceValue() ) return false; - Sequence < TextColumn > aColumns1 = xColumns1->getColumns(); - Sequence < TextColumn > aColumns2 = xColumns2->getColumns(); + const Sequence < TextColumn > aColumns1 = xColumns1->getColumns(); + const Sequence < TextColumn > aColumns2 = xColumns2->getColumns(); return std::equal(aColumns1.begin(), aColumns1.end(), aColumns2.begin(), aColumns2.end(), [](const TextColumn& a, const TextColumn& b) { diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 40e085349403..aeb401328429 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -464,7 +464,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testOOXMLRemoveAll) uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream(); uno::Sequence<uno::Sequence<beans::StringPair>> aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxComponentContext); - uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1]; + const uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1]; CPPUNIT_ASSERT( std::none_of(rOverrides.begin(), rOverrides.end(), [](const beans::StringPair& rPair) { return rPair.First.startsWith("/_xmlsignatures/sig"); diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx index 5852d16afd39..c222824376a5 100644 --- a/xmlsecurity/source/helper/documentsignaturehelper.cxx +++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx @@ -303,8 +303,8 @@ void DocumentSignatureHelper::AppendContentTypes(const uno::Reference<embed::XSt SAL_WARN("xmlsecurity.helper", "no defaults or overrides in aContentTypeInfo"); return; } - uno::Sequence<beans::StringPair>& rDefaults = aContentTypeInfo[0]; - uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1]; + const uno::Sequence<beans::StringPair>& rDefaults = aContentTypeInfo[0]; + const uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1]; for (OUString& rElement : rElements) { diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 78ba5246cba9..f97de99c537f 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -511,10 +511,10 @@ void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<c // Append rels and sigs to defaults, if it's not there already. uno::Sequence<beans::StringPair>& rDefaults = aContentTypeInfo[0]; auto aDefaults = comphelper::sequenceToContainer< std::vector<beans::StringPair> >(rDefaults); - if (std::none_of(rDefaults.begin(), rDefaults.end(), [](const beans::StringPair& rPair) { return rPair.First == "rels"; })) + if (std::none_of(std::cbegin(rDefaults), std::cend(rDefaults), [](const beans::StringPair& rPair) { return rPair.First == "rels"; })) aDefaults.emplace_back("rels", "application/vnd.openxmlformats-package.relationships+xml"); - if (std::none_of(rDefaults.begin(), rDefaults.end(), [](const beans::StringPair& rPair) { return rPair.First == "sigs"; })) + if (std::none_of(std::cbegin(rDefaults), std::cend(rDefaults), [](const beans::StringPair& rPair) { return rPair.First == "sigs"; })) aDefaults.emplace_back("sigs", "application/vnd.openxmlformats-package.digital-signature-origin"); rDefaults = comphelper::containerToSequence(aDefaults); |