diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-14 09:25:24 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-15 10:36:36 +0200 |
commit | 2484de6728bd11bb7949003d112f1ece2223c7a1 (patch) | |
tree | 1296534e396da284b38d2c478dcd2b31c4714179 | |
parent | 88375fd36899d21d3309cf8333712e02a87d3a91 (diff) |
Remove non-const Sequence::begin()/end() in internal code
... to avoid hidden cost of multiple COW checks, because they
call getArray() internally.
This obsoletes [loplugin:sequenceloop].
Also rename toNonConstRange to asNonConstRange, to reflect that
the result is a view of the sequence, not an independent object.
TODO: also drop non-const operator[], but introduce operator[]
in SequenceRange.
Change-Id: Idd5fd7a3400fe65274d2a6343025e2ef8911635d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123518
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
217 files changed, 372 insertions, 511 deletions
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx index a20059d100b8..20eea9eb315f 100644 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -123,7 +123,7 @@ void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& // create peers at all children Sequence< Reference< XControl > > seqControlList = getControls(); - for ( auto& rxControl : seqControlList ) + for ( auto& rxControl : asNonConstRange(seqControlList) ) { rxControl->createPeer( xToolkit, getPeer() ); } diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx index 56fe32010939..87cfcdb62f30 100644 --- a/accessibility/source/standard/vclxaccessibleedit.cxx +++ b/accessibility/source/standard/vclxaccessibleedit.cxx @@ -301,6 +301,7 @@ Sequence< PropertyValue > VCLXAccessibleEdit::getCharacterAttributes( sal_Int32 { OExternalLockGuard aGuard( this ); Sequence< PropertyValue > aProperties = VCLXAccessibleTextComponent::getCharacterAttributes( nIndex, aRequestedAttributes ); + auto aNonConstRange = asNonConstRange(aProperties); // Handle multiline edit character properties VclPtr<VclMultiLineEdit> pMulitLineEdit = GetAsDynamic< VclMultiLineEdit >(); @@ -311,7 +312,7 @@ Sequence< PropertyValue > VCLXAccessibleEdit::getCharacterAttributes( sal_Int32 const TextAttribFontColor* pFontColor = static_cast<const TextAttribFontColor* >(pTextEngine->FindAttrib( aCursor, TEXTATTR_FONTCOLOR )); if ( pFontColor ) { - for (PropertyValue& aValue : aProperties ) + for (PropertyValue& aValue : aNonConstRange ) { if (aValue.Name == "CharColor") { @@ -323,7 +324,7 @@ Sequence< PropertyValue > VCLXAccessibleEdit::getCharacterAttributes( sal_Int32 } // Set default character color if it is not set yet to a valid value - for (PropertyValue& aValue : aProperties ) + for (PropertyValue& aValue : aNonConstRange ) { if (aValue.Name == "CharColor") { diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index d0c37e89ef07..fcef9e78802b 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -1213,7 +1213,7 @@ namespace basctl auto const sort = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale()); - auto [begin, end] = toNonConstRange(aModuleNames); + auto [begin, end] = asNonConstRange(aModuleNames); std::sort(begin, end, [&sort](const OUString& rLHS, const OUString& rRHS) { return sort.compare(rLHS, rRHS) < 0; diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index adaa328e636d..e48ba0b3f443 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -219,7 +219,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if(!bGroupBarsPerAxis) { //set the same value for all axes - for( auto & pos : aBarPositionSequence ) + for( auto & pos : asNonConstRange(aBarPositionSequence) ) pos = rBarPosition; } else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx b/chart2/source/model/template/ColumnLineDataInterpreter.cxx index f59c98c489b6..6069255d3f1d 100644 --- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx +++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx @@ -64,8 +64,8 @@ InterpretedData SAL_CALL ColumnLineDataInterpreter::interpretDataSource( Sequence< Reference< XDataSeries > > & rColumnDataSeries = aResult.Series[0]; Sequence< Reference< XDataSeries > > & rLineDataSeries = aResult.Series[1]; rLineDataSeries.realloc( nNumOfLines ); - std::copy( rColumnDataSeries.begin() + nNumberOfSeries - nNumOfLines, - rColumnDataSeries.begin() + nNumberOfSeries, + std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines, + std::cbegin(rColumnDataSeries) + nNumberOfSeries, rLineDataSeries.getArray() ); rColumnDataSeries.realloc( nNumberOfSeries - nNumOfLines ); } diff --git a/chart2/source/tools/ReferenceSizeProvider.cxx b/chart2/source/tools/ReferenceSizeProvider.cxx index b5b928e9e843..b409c1730e39 100644 --- a/chart2/source/tools/ReferenceSizeProvider.cxx +++ b/chart2/source/tools/ReferenceSizeProvider.cxx @@ -108,7 +108,7 @@ void ReferenceSizeProvider::setValuesAtAllDataSeries() { if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes ) { - for( sal_Int32 idx : aPointIndexes ) + for( sal_Int32 idx : std::as_const(aPointIndexes) ) setValuesAtPropertySet( elem->getDataPointByIndex( idx ) ); } @@ -282,7 +282,7 @@ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState { if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes ) { - for( sal_Int32 idx : aPointIndexes ) + for( sal_Int32 idx : std::as_const(aPointIndexes) ) { getAutoResizeFromPropSet( elem->getDataPointByIndex( idx ), eResult ); diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index 7259f3e92043..a320c85cb497 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -141,7 +141,7 @@ uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution( uno::Sequence<sal_Int32> aResolution( std::max<sal_Int32>(m_xCooSysModel->getDimension(), 2)); - for( auto& i : aResolution ) + for( auto& i : asNonConstRange(aResolution) ) i = 1000; ::basegfx::B3DTuple aScale( BaseGFXHelper::GetScaleFromMatrix( @@ -177,7 +177,7 @@ uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution( //this maybe can be optimized further ... sal_Int32 nMaxResolution = std::max( nXResolution, nYResolution ); nMaxResolution*=2; - for( auto& i : aResolution ) + for( auto& i : asNonConstRange(aResolution) ) i = nMaxResolution; } diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index b3047d4126b3..0d3123a8cb13 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -582,7 +582,7 @@ sal_Int32 VDataSeries::getLabelPlacement( sal_Int32 nPointIndex, const uno::Refe if( xPointProps.is() ) xPointProps->getPropertyValue("LabelPlacement") >>= nLabelPlacement; - uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( + const uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, m_xDataSeries ) ); for( sal_Int32 n : aAvailablePlacements ) diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index f84d509847eb..e0b389c19199 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -425,7 +425,7 @@ namespace comphelper { // sort (the XMultiPropertySet interface requires this) Sequence< PropertyValue > aProperties( _rProps ); - auto [begin, end] = toNonConstRange(aProperties); + auto [begin, end] = asNonConstRange(aProperties); std::sort( begin, end, diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx index 75208c2c51b4..49a7a108f09a 100644 --- a/comphelper/source/property/property.cxx +++ b/comphelper/source/property/property.cxx @@ -138,31 +138,25 @@ bool hasProperty(const OUString& _rName, const Reference<XPropertySet>& _rxSet) void RemoveProperty(Sequence<Property>& _rProps, const OUString& _rPropName) { - sal_Int32 nLen = _rProps.getLength(); - // binary search - const Property* pProperties = _rProps.getConstArray(); Property aNameProp(_rPropName, 0, Type(), 0); - const Property* pResult = std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName()); + const Property* pResult = std::lower_bound(std::cbegin(_rProps), std::cend(_rProps), aNameProp, PropertyCompareByName()); - if ( pResult != _rProps.end() && pResult->Name == _rPropName ) + if ( pResult != std::cend(_rProps) && pResult->Name == _rPropName) { - OSL_ENSURE(pResult->Name == _rPropName, "::RemoveProperty Properties not sorted"); - removeElementAt(_rProps, pResult - pProperties); + removeElementAt(_rProps, pResult - std::cbegin(_rProps)); } } void ModifyPropertyAttributes(Sequence<Property>& seqProps, const OUString& sPropName, sal_Int16 nAddAttrib, sal_Int16 nRemoveAttrib) { - sal_Int32 nLen = seqProps.getLength(); - // binary search - Property* pProperties = seqProps.getArray(); + auto [begin, end] = asNonConstRange(seqProps); Property aNameProp(sPropName, 0, Type(), 0); - Property* pResult = std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName()); + Property* pResult = std::lower_bound(begin, end, aNameProp, PropertyCompareByName()); - if ( (pResult != seqProps.end()) && (pResult->Name == sPropName) ) + if ( (pResult != end) && (pResult->Name == sPropName) ) { pResult->Attributes |= nAddAttrib; pResult->Attributes &= ~nRemoveAttrib; diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index 73dcbd2e862b..5fd6053ce100 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -469,7 +469,7 @@ void OPropertyContainerHelper::describeProperties(Sequence< Property >& _rProps) } // as our property vector is sorted by handles, not by name, we have to sort aOwnProps - auto [begin, end] = toNonConstRange(aOwnProps); + auto [begin, end] = asNonConstRange(aOwnProps); std::sort(begin, end, PropertyCompareByName()); // unfortunately the STL merge function does not allow the output range to overlap one of the input ranges, diff --git a/compilerplugins/clang/sequenceloop.cxx b/compilerplugins/clang/sequenceloop.cxx deleted file mode 100644 index 8c931d70d5d1..000000000000 --- a/compilerplugins/clang/sequenceloop.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -#ifndef LO_CLANG_SHARED_PLUGINS - -#include <cassert> -#include <string> -#include <iostream> -#include <fstream> -#include <set> - -#include <clang/AST/CXXInheritance.h> -#include "plugin.hxx" -#include "check.hxx" - -/** - When used in "for" loops, css::uno::Sequence objects tend to end up calling the non-const begin()/end(), - which is considerably more expensive than the const variants because it forces a local copy - of the internal ref-counted impl object. -*/ - -namespace -{ -class SequenceLoop : public loplugin::FilteringPlugin<SequenceLoop> -{ -public: - explicit SequenceLoop(loplugin::InstantiationData const& data) - : FilteringPlugin(data) - { - } - - virtual void run() override - { - if (preRun()) - TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); - } - - bool VisitCXXForRangeStmt(CXXForRangeStmt const*); -}; - -bool SequenceLoop::VisitCXXForRangeStmt(CXXForRangeStmt const* forStmt) -{ - if (ignoreLocation(forStmt)) - return true; - - auto tc = loplugin::TypeCheck(forStmt->getRangeInit()->getType()); - if (tc.Const()) - return true; - if (!tc.Class("Sequence") - .Namespace("uno") - .Namespace("star") - .Namespace("sun") - .Namespace("com") - .GlobalNamespace() - // B2DPolyPolygon is similar in that accessing the non-const begin()/end() methods - // might trigger unnecessary copying - && !tc.Class("B2DPolyPolygon").Namespace("basegfx").GlobalNamespace()) - return true; - const VarDecl* varDecl = forStmt->getLoopVariable(); - auto tc2 = loplugin::TypeCheck(varDecl->getType()); - if (!tc2.LvalueReference().Const()) - return true; - - report(DiagnosticsEngine::Warning, - ("use std::as_const, or otherwise make the for-range-initializer expression const, to" - " avoid creating a copy of the Sequence"), - compat::getBeginLoc(forStmt->getRangeInit())) - << forStmt->getSourceRange(); - return true; -} - -loplugin::Plugin::Registration<SequenceLoop> sequenceloop("sequenceloop"); - -} // namespace - -#endif // LO_CLANG_SHARED_PLUGINS - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/test/constvars.cxx b/compilerplugins/clang/test/constvars.cxx index dc3c1ecb9c6b..88df50f8e199 100644 --- a/compilerplugins/clang/test/constvars.cxx +++ b/compilerplugins/clang/test/constvars.cxx @@ -12,7 +12,6 @@ #else #include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/XInterface.hpp> #include <map> #include <list> @@ -79,20 +78,8 @@ void foo(std::list<Struct1*> aList) } }; -namespace test6 -{ -void foo(css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& aSeq) -{ - // expected-error@+1 {{var can be const [loplugin:constvars]}} - for (css::uno::Reference<css::uno::XInterface>& x : aSeq) - { - x.get(); - } -} -}; - // no warning expected -namespace test7 +namespace test6 { void foo(std::vector<std::vector<int>> aVecVec) { diff --git a/compilerplugins/clang/test/sequenceloop.cxx b/compilerplugins/clang/test/sequenceloop.cxx deleted file mode 100644 index e124fda27093..000000000000 --- a/compilerplugins/clang/test/sequenceloop.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/XInterface.hpp> -#include <utility> - -namespace test1 -{ -void foo(css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& aSeq) -{ - // expected-error@+1 {{use std::as_const, or otherwise make the for-range-initializer expression const, to avoid creating a copy of the Sequence [loplugin:sequenceloop]}} - for (const auto& x : aSeq) - x.get(); - // no warning expected - for (auto& x : aSeq) - x.get(); - for (const auto& x : std::as_const(aSeq)) - x.get(); -} -// no warning expected -void foo2(const css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& aSeq) -{ - for (const auto& x : aSeq) - x.get(); -} -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx index 759959ab3bb7..359b5d7a9a06 100644 --- a/configmgr/source/writemodfile.cxx +++ b/configmgr/source/writemodfile.cxx @@ -209,7 +209,7 @@ template< typename T > void writeListValue( if (i != 0) { handle.writeString(" "); } - writeValueContent_(handle, val[i]); + writeValueContent_(handle, std::as_const(val)[i]); } handle.writeString("</value>"); } @@ -220,7 +220,7 @@ template< typename T > void writeItemListValue( handle.writeString(">"); css::uno::Sequence< T > val; value >>= val; - for (const auto & i : val) { + for (const auto & i : std::as_const(val)) { handle.writeString("<it>"); writeValueContent_(handle, i); handle.writeString("</it>"); diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx index 252882067865..8a0cc852ed98 100644 --- a/connectivity/source/commontools/ConnectionWrapper.cxx +++ b/connectivity/source/commontools/ConnectionWrapper.cxx @@ -199,7 +199,7 @@ 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 - auto [begin, end] = toNonConstRange(_rInfo); + auto [begin, end] = asNonConstRange(_rInfo); std::sort(begin,end,TPropertyValueLessFunctor()); for (PropertyValue const & prop : std::as_const(_rInfo)) diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 40a07679ba96..88f9e37760c0 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -947,10 +947,7 @@ try Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo()); const Sequence< Property> aOldProperties = xOldInfo->getProperties(); - Sequence< Property> aNewProperties = xNewInfo->getProperties(); - int nNewLen = aNewProperties.getLength(); - - Property* pNewProps = aNewProperties.getArray(); + const Sequence< Property> aNewProperties = xNewInfo->getProperties(); static constexpr OUStringLiteral sPropFormatsSupplier(u"FormatsSupplier"); static constexpr OUStringLiteral sPropCurrencySymbol(u"CurrencySymbol"); @@ -972,8 +969,8 @@ try if ( rOldProp.Name != "DefaultControl" && rOldProp.Name != "LabelControl" ) { // binary search - Property* pResult = std::lower_bound( - pNewProps, pNewProps + nNewLen, rOldProp, ::comphelper::PropertyCompareByName()); + const Property* pResult = std::lower_bound( + aNewProperties.begin(), aNewProperties.end(), rOldProp, ::comphelper::PropertyCompareByName()); if ( ( pResult != aNewProperties.end() ) && ( pResult->Name == rOldProp.Name ) diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx index da06ef77f2c3..df9d660f554c 100644 --- a/connectivity/source/drivers/jdbc/JStatement.cxx +++ b/connectivity/source/drivers/jdbc/JStatement.cxx @@ -124,7 +124,7 @@ 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 [begin, end] = toNonConstRange(aOldTypes); + auto [begin, end] = asNonConstRange(aOldTypes); auto newEnd = std::remove(begin, end, cppu::UnoType<XGeneratedResultSet>::get()); aOldTypes.realloc(std::distance(begin, newEnd)); diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index 13ffeda8e4ba..d44f86e58469 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -131,7 +131,7 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) Sequence< Type > aOldTypes = OStatement_BASE::getTypes(); if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() ) { - auto [begin, end] = toNonConstRange(aOldTypes); + auto [begin, end] = asNonConstRange(aOldTypes); auto newEnd = std::remove(begin, end, cppu::UnoType<XGeneratedResultSet>::get()); aOldTypes.realloc(std::distance(begin, newEnd)); diff --git a/connectivity/source/sdbcx/VDescriptor.cxx b/connectivity/source/sdbcx/VDescriptor.cxx index 2392e2d5f1d2..7800aaf075be 100644 --- a/connectivity/source/sdbcx/VDescriptor.cxx +++ b/connectivity/source/sdbcx/VDescriptor.cxx @@ -74,7 +74,7 @@ namespace connectivity::sdbcx Sequence< Property > aProperties; describeProperties( aProperties ); - auto [begin, end] = toNonConstRange(aProperties); + auto [begin, end] = asNonConstRange(aProperties); if ( isNew() ) std::for_each( begin, end, ResetROAttribute() ); else diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 09535a15690f..8768d9817ab7 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 : toNonConstRange(seqKeys) ) + for( OUString & key : asNonConstRange(seqKeys) ) key = key.copy(nPrefixLen); aServiceNames = seqKeys; diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index eb7f4ce17c62..dbf17c120e4d 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -2057,7 +2057,7 @@ void ToolbarSaveInData::SetSystemStyle( if ( a >>= aProps ) { - for ( beans::PropertyValue& prop : aProps ) + for ( beans::PropertyValue& prop : asNonConstRange(aProps) ) { if ( prop.Name == ITEM_DESCRIPTOR_STYLE ) { diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx index 8fcea1b99f0e..ac633177ef36 100644 --- a/cui/source/dialogs/AdditionsDialog.cxx +++ b/cui/source/dialogs/AdditionsDialog.cxx @@ -374,7 +374,7 @@ void SearchAndParseThread::Search() void SearchAndParseThread::CheckInstalledExtensions() { - uno::Sequence<uno::Sequence<uno::Reference<deployment::XPackage>>> xAllPackages + const uno::Sequence<uno::Sequence<uno::Reference<deployment::XPackage>>> xAllPackages = m_pAdditionsDialog->getInstalledExtensions(); if (!xAllPackages.hasElements()) diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 39abfbedbadb..8a976277ca7c 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -352,7 +352,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } else if( sType == "[]byte" ) { - uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >(); + const uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >(); for( sal_Int8 j : seq ) { OUString s = OUString::number( @@ -366,7 +366,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } else if( sType == "[][]byte" ) { - uno::Sequence< uno::Sequence<sal_Int8> > seq = aNode.get< uno::Sequence< uno::Sequence<sal_Int8> > >(); + const uno::Sequence< uno::Sequence<sal_Int8> > seq = aNode.get< uno::Sequence< uno::Sequence<sal_Int8> > >(); for( sal_Int32 j = 0; j != seq.getLength(); ++j ) { if( j != 0 ) diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx index df31ee10522d..9c657176527f 100644 --- a/cui/source/options/optgenrl.cxx +++ b/cui/source/options/optgenrl.cxx @@ -302,7 +302,7 @@ void SvxGeneralTabPage::InitCryptography() if (xCertificates.hasElements()) { - for (auto& xCert : xCertificates) + for (auto& xCert : asNonConstRange(xCertificates)) { m_xSigningKeyLB->append_text( xCert->getIssuerName()); m_xEncryptionKeyLB->append_text( xCert->getIssuerName()); diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx index f40593b8598d..1448c657abd4 100644 --- a/dbaccess/source/core/api/TableDeco.cxx +++ b/dbaccess/source/core/api/TableDeco.cxx @@ -310,7 +310,7 @@ void ODBTableDecorator::construct() Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo(); Sequence< Property > aTableProps = xInfo->getProperties(); - for (Property & prop : aTableProps) + for (Property & prop : asNonConstRange(aTableProps)) { if (prop.Name == PROPERTY_CATALOGNAME) prop.Handle = PROPERTY_ID_CATALOGNAME; diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index 7854a97f1816..beff8adf7f03 100644 --- a/dbaccess/source/core/api/definitioncolumn.cxx +++ b/dbaccess/source/core/api/definitioncolumn.cxx @@ -487,7 +487,7 @@ Sequence< OUString > OTableColumnDescriptorWrapper::getSupportedServiceNames( ) if ( !m_bIsDescriptor ) { - for ( auto & prop : aDescriptor ) + for ( auto & prop : asNonConstRange(aDescriptor) ) { prop.Attributes |= PropertyAttribute::READONLY; } diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx index f11008555ca9..b4b6e47cd57d 100644 --- a/dbaccess/source/core/api/table.cxx +++ b/dbaccess/source/core/api/table.cxx @@ -211,7 +211,7 @@ void ODBTable::construct() describeProperties(aProps); if(!_nId) { - for(Property & prop : aProps) + for(Property & prop : asNonConstRange(aProps)) { if (prop.Name == PROPERTY_CATALOGNAME) prop.Attributes = PropertyAttribute::READONLY; diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index e9867def1b99..c38dc9429cfc 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -223,7 +223,7 @@ Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) // allowed to contain macros, too. if ( !m_bAllowDocumentScripting ) { - auto [begin, end] = toNonConstRange(aTypes); + auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, [](const Type& t) { return t == cppu::UnoType<XEmbeddedScripts>::get() || diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 48039c3e6943..b36ac6ea67b6 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -866,7 +866,7 @@ sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & { const PropertyValue* pInfoIter = aSettings.getConstArray(); const PropertyValue* checkValue = aValues.getConstArray(); - for ( ;!bModified && checkValue != aValues.end() ; ++checkValue,++pInfoIter) + for ( ;!bModified && checkValue != std::cend(aValues) ; ++checkValue,++pInfoIter) { bModified = checkValue->Name != pInfoIter->Name; if ( !bModified ) @@ -1046,7 +1046,7 @@ 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 [begin, end] = asNonConstRange(aValues); auto pCopyStart = aNonDefaultOrUserDefined.getArray(); const PropertyValue* pCopyEnd = std::remove_copy_if( begin, diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index e0c1304c8cc6..b2b6ae0ce395 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -595,7 +595,7 @@ template< typename T > void ODBExport::exportDataSourceSettingsSequence( css::uno::Sequence<T> anySeq; bool bSuccess = in->Value >>= anySeq; assert(bSuccess); (void)bSuccess; - for (T const & i : anySeq ) + for (T const & i : std::as_const(anySeq) ) { SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false); // (no whitespace inside the tag) diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx index 7a07f0a9d206..37f35a0472ee 100644 --- a/dbaccess/source/ui/browser/formadapter.cxx +++ b/dbaccess/source/ui/browser/formadapter.cxx @@ -1326,7 +1326,7 @@ Sequence< css::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates // set them all to DEFAULT Sequence< css::beans::PropertyState> aReturn(aPropertyName.getLength()); - for (css::beans::PropertyState& rState : aReturn) + for (css::beans::PropertyState& rState : asNonConstRange(aReturn)) rState = css::beans::PropertyState_DEFAULT_VALUE; return aReturn; } diff --git a/dbaccess/source/ui/browser/sbamultiplex.cxx b/dbaccess/source/ui/browser/sbamultiplex.cxx index 68673fd06ff2..f31b4c7ac27f 100644 --- a/dbaccess/source/ui/browser/sbamultiplex.cxx +++ b/dbaccess/source/ui/browser/sbamultiplex.cxx @@ -85,7 +85,7 @@ void SbaXPropertiesChangeMultiplexer::propertiesChange(const css::uno::Sequence< // forwards _all_ changes to _all_ listeners css::uno::Sequence< css::beans::PropertyChangeEvent> aMulti(aEvts); - for (css::beans::PropertyChangeEvent & rEvent : aMulti) + for (css::beans::PropertyChangeEvent & rEvent : asNonConstRange(aMulti)) rEvent.Source = &m_rParent; ::comphelper::OInterfaceIteratorHelper2 aIt(*this); diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index b6bf10274b8b..035a0e1ef8c2 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -214,7 +214,7 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" ); if ( !m_aDocScriptSupport || !*m_aDocScriptSupport ) { - auto [begin, end] = toNonConstRange(aTypes); + auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, [](const Type& type) { return type == cppu::UnoType<XScriptInvocationContext>::get(); } ); diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index 82ce80f71333..b77953316ec7 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -222,7 +222,7 @@ namespace dbaui Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() ); if ( !m_pImpl->documentHasScriptSupport() ) { - auto [begin, end] = toNonConstRange(aTypes); + auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, [](const Type& type) { return type == cppu::UnoType<XScriptInvocationContext>::get(); } ); diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 4f7bd55bde1e..9500281a7275 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -288,7 +288,7 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i PropertyAttribute::READONLY ); - auto [begin, end] = toNonConstRange(aProps); + auto [begin, end] = asNonConstRange(aProps); std::sort( begin, end, diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1d9c482c8f14..63795517a812 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2548,7 +2548,7 @@ static bool lo_signDocument(LibreOfficeKit* /*pThis*/, else { aCertificateSequence.realloc(nCertificateBinarySize); - std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.begin()); + std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray()); } uno::Sequence<sal_Int8> aPrivateKeySequence; @@ -2562,7 +2562,7 @@ static bool lo_signDocument(LibreOfficeKit* /*pThis*/, else { aPrivateKeySequence.realloc(nPrivateKeyBinarySize); - std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeyBinarySize, aPrivateKeySequence.begin()); + std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeyBinarySize, aPrivateKeySequence.getArray()); } uno::Reference<xml::crypto::XSEInitializer> xSEInitializer = xml::crypto::SEInitializer::create(xContext); @@ -5624,7 +5624,7 @@ static bool doc_insertCertificate(LibreOfficeKitDocument* pThis, else { aCertificateSequence.realloc(nCertificateBinarySize); - std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.begin()); + std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray()); } uno::Sequence<sal_Int8> aPrivateKeySequence; @@ -5638,7 +5638,7 @@ static bool doc_insertCertificate(LibreOfficeKitDocument* pThis, else { aPrivateKeySequence.realloc(nPrivateKeySize); - std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeySize, aPrivateKeySequence.begin()); + std::copy(pPrivateKeyBinary, pPrivateKeyBinary + nPrivateKeySize, aPrivateKeySequence.getArray()); } uno::Reference<security::XCertificate> xCertificate = xCertificateCreator->createDERCertificateWithPrivateKey(aCertificateSequence, aPrivateKeySequence); @@ -5696,7 +5696,7 @@ static bool doc_addCertificate(LibreOfficeKitDocument* pThis, else { aCertificateSequence.realloc(nCertificateBinarySize); - std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.begin()); + std::copy(pCertificateBinary, pCertificateBinary + nCertificateBinarySize, aCertificateSequence.getArray()); } uno::Reference<security::XCertificate> xCertificate = xCertificateCreator->addDERCertificateToTheDatabase(aCertificateSequence, "TCu,Cu,Tu"); @@ -6080,7 +6080,7 @@ static void preloadData() std::cerr << "Preloading dictionaries: "; css::uno::Reference<linguistic2::XSupportedLocales> xSpellLocales(xSpellChecker, css::uno::UNO_QUERY_THROW); uno::Sequence< css::lang::Locale > aLocales = xSpellLocales->getLocales(); - for (auto &it : aLocales) + for (auto &it : std::as_const(aLocales)) { std::cerr << LanguageTag::convertToBcp47(it) << " "; css::beans::PropertyValues aNone; @@ -6101,7 +6101,7 @@ static void preloadData() css::uno::Reference<linguistic2::XSupportedLocales> xThesLocales(xSpellChecker, css::uno::UNO_QUERY_THROW); aLocales = xThesLocales->getLocales(); std::cerr << "Preloading thesauri: "; - for (auto &it : aLocales) + for (auto &it : std::as_const(aLocales)) { std::cerr << LanguageTag::convertToBcp47(it) << " "; css::beans::PropertyValues aNone; diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index b2c672234137..79fb443c6d85 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -1229,7 +1229,7 @@ namespace accessibility // since SequenceAsHashMap ignores property handles and property state // we have to restore the property state here (property handles are // of no use to the accessibility API). - for (beans::PropertyValue & rRes : aRes) + for (beans::PropertyValue & rRes : asNonConstRange(aRes)) { bool bIsDirectVal = false; for (auto const& rRunAttrib : aRunAttribs) diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 933ddb60a3db..0b1154394651 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -453,7 +453,7 @@ void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState ) StateChangeNotification_Impl( true, nOldState, nNewState,aGuard ); try { - for ( sal_Int32 state : aIntermediateStates ) + for ( sal_Int32 state : std::as_const(aIntermediateStates) ) SwitchStateTo_Impl( state ); SwitchStateTo_Impl( nNewState ); diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index a005a33e7019..bf3feb4acb1a 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -814,7 +814,7 @@ namespace pcr PropertyId nPropId( 0 ); OUString sDisplayName; - for ( Property & rProperty : aAllProperties ) + for ( Property & rProperty : asNonConstRange(aAllProperties) ) { nPropId = m_pInfoService->getPropertyId( rProperty.Name ); if ( nPropId == -1 ) diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx index 073cbbedd130..da468e5b51ef 100644 --- a/extensions/source/propctrlr/stringrepresentation.cxx +++ b/extensions/source/propctrlr/stringrepresentation.cxx @@ -255,7 +255,7 @@ void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & uno::Sequence< uno::Reference< reflection::XConstantTypeDescription > > cs(m_xTypeDescription->getConstants()); - auto [begin, end] = toNonConstRange(cs); + auto [begin, end] = asNonConstRange(cs); std::sort(begin, end, CompareConstants()); m_aConstants = cs; } diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx index 4d8580420670..8c115b1018b5 100644 --- a/filter/source/pdf/pdffilter.cxx +++ b/filter/source/pdf/pdffilter.cxx @@ -132,7 +132,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) { bool bFound = false; - for (PropertyValue& rProp : aFilterData) + for (PropertyValue& rProp : asNonConstRange(aFilterData)) { if (rProp.Name == "IsRedactMode") { diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 837baa838dab..61d1265aa4be 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -394,7 +394,7 @@ void OInterfaceContainer::transformEvents() if ( aChildEvents.hasElements() ) { // do the transformation - auto [begin, end] = toNonConstRange(aChildEvents); + auto [begin, end] = asNonConstRange(aChildEvents); ::std::for_each( begin, end, TransformEventTo52Format() ); // revoke the script events diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx index 6ef5f46f440c..cd638a979522 100644 --- a/framework/source/fwe/classes/addonsoptions.cxx +++ b/framework/source/fwe/classes/addonsoptions.cxx @@ -997,7 +997,7 @@ void AddonsOptions_Impl::ReadMergeMenuData( std::u16string_view aMergeAddonInstr aMergeMenuBaseNode += m_aPathDelimiter; // extend the node names to have full path strings - for ( OUString& rName : aSubMenuNodeNames ) + for ( OUString& rName : asNonConstRange(aSubMenuNodeNames) ) rName = aMergeMenuBaseNode + rName; ReadSubMenuEntries( aSubMenuNodeNames, rMergeMenu ); @@ -1302,7 +1302,7 @@ bool AddonsOptions_Impl::ReadMenuItem( std::u16string_view aMenuNodeName, Sequen // Continue to read the sub menu nodes Sequence< Sequence< PropertyValue > > aSubMenuSeq; OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter ); - for ( OUString& rName : aRootSubMenuNodeNames ) + for ( OUString& rName : asNonConstRange(aRootSubMenuNodeNames) ) rName = aSubMenuRootNodeName + rName; ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq ); aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= aSubMenuSeq; @@ -1366,7 +1366,7 @@ bool AddonsOptions_Impl::ReadPopupMenu( std::u16string_view aPopupMenuNodeName, // Continue to read the sub menu nodes Sequence< Sequence< PropertyValue > > aSubMenuSeq; OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter ); - for ( OUString& rName : aRootSubMenuNodeNames ) + for ( OUString& rName : asNonConstRange(aRootSubMenuNodeNames) ) rName = aSubMenuRootNodeName + rName; ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq ); aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aSubMenuSeq; diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx index c3ac0d54460a..4e364696cf20 100644 --- a/i18npool/source/calendar/calendarImpl.cxx +++ b/i18npool/source/calendar/calendarImpl.cxx @@ -139,7 +139,7 @@ CalendarImpl::getAllCalendars( const css::lang::Locale& rLocale ) { const Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale); Sequence< OUString > xSeq( xC.getLength() ); - std::transform(xC.begin(), xC.end(), xSeq.begin(), + std::transform(xC.begin(), xC.end(), xSeq.getArray(), [](const Calendar2& rCal) { return rCal.Name; }); return xSeq; } diff --git a/i18npool/source/collator/collatorImpl.cxx b/i18npool/source/collator/collatorImpl.cxx index 56fb4bf90502..fff944d6ff7e 100644 --- a/i18npool/source/collator/collatorImpl.cxx +++ b/i18npool/source/collator/collatorImpl.cxx @@ -107,7 +107,7 @@ CollatorImpl::listCollatorAlgorithms( const lang::Locale& rLocale ) nLocale = rLocale; const Sequence< Implementation > &imp = mxLocaleData->getCollatorImplementations(rLocale); Sequence< OUString > list(imp.getLength()); - auto pBegin = list.begin(); + auto pBegin = list.getArray(); auto pId = pBegin; for (const auto& rImpl : imp) { @@ -126,7 +126,7 @@ CollatorImpl::listCollatorOptions( const OUString& /*collatorAlgorithmName*/ ) const Sequence< OUString > option_str = mxLocaleData->getCollationOptions(nLocale); Sequence< sal_Int32 > option_int(option_str.getLength()); - std::transform(option_str.begin(), option_str.end(), option_int.begin(), [](const OUString& rOpt) { + std::transform(option_str.begin(), option_str.end(), option_int.getArray(), [](const OUString& rOpt) { return rOpt == "IGNORE_CASE" ? CollatorOptions::CollatorOptions_IGNORE_CASE : rOpt == "IGNORE_KANA" ? CollatorOptions::CollatorOptions_IGNORE_KANA : rOpt == "IGNORE_WIDTH" ? CollatorOptions::CollatorOptions_IGNORE_WIDTH : 0; }); diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 3dc113fe7eed..145b576f16fc 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -719,7 +719,7 @@ Sequence< CalendarItem2 > LocaleDataImpl::getCalendarItems( case REF_MONTHS: case REF_GMONTHS: case REF_PMONTHS: - for (CalendarItem2& rItem : aItems) + for (CalendarItem2& rItem : asNonConstRange(aItems)) { rItem = CalendarItem2{ OUString(allCalendars[rnOffset]), OUString(allCalendars[rnOffset+1]), @@ -729,7 +729,7 @@ Sequence< CalendarItem2 > LocaleDataImpl::getCalendarItems( break; case REF_ERAS: // Absent narrow name. - for (CalendarItem2& rItem : aItems) + for (CalendarItem2& rItem : asNonConstRange(aItems)) { rItem = CalendarItem2{ OUString(allCalendars[rnOffset]), OUString(allCalendars[rnOffset+1]), @@ -1260,7 +1260,7 @@ LocaleDataImpl::getContinuousNumberingLevels( const lang::Locale& rLocale ) // allocate memory for nAttributes attributes for each of the nStyles styles. Sequence< Sequence<beans::PropertyValue> > pv( nStyles ); - for( auto& i : pv ) { + for( auto& i : asNonConstRange(pv) ) { i = Sequence<beans::PropertyValue>( nAttributes ); } diff --git a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx index 5a071a3887fa..5e8659027992 100644 --- a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx @@ -77,7 +77,7 @@ ignoreIandEfollowedByYa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 sta if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - auto [begin, end] = toNonConstRange(*pOffset); + auto [begin, end] = asNonConstRange(*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 bdee0d87d6fa..c5a3cb04565c 100644 --- a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx @@ -95,7 +95,7 @@ ignoreIterationMark_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 startPo if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - auto [begin, end] = toNonConstRange(*pOffset); + auto [begin, end] = asNonConstRange(*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 1c64d65104d9..113c80f9aeeb 100644 --- a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx @@ -38,7 +38,7 @@ ignoreKiKuFollowedBySa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 star if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - auto [begin, end] = toNonConstRange(*pOffset); + auto [begin, end] = asNonConstRange(*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 fc87d206dc3e..3291afa9ba7d 100644 --- a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx +++ b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx @@ -300,7 +300,7 @@ ignoreProlongedSoundMark_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 st if (pOffset) { // Allocate nCount length to offset argument. pOffset->realloc( nCount ); - auto [begin, end] = toNonConstRange(*pOffset); + auto [begin, end] = asNonConstRange(*pOffset); std::iota(begin, end, startPos); } diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx index 4a1e2eab6147..55236ec3dfa9 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 : toNonConstRange(offset)) + for (sal_Int32 & j : asNonConstRange(offset)) j += startPos; } return tmpStr; @@ -316,7 +316,7 @@ TransliterationImpl::transliterate( const OUString& inStr, sal_Int32 startPos, s { OUString tmpStr = inStr.copy(startPos, nCount); - auto [begin, end] = toNonConstRange(offset); + auto [begin, end] = asNonConstRange(offset); std::iota(begin, end, startPos); Sequence<sal_Int32> from(nCount); @@ -328,7 +328,7 @@ TransliterationImpl::transliterate( const OUString& inStr, sal_Int32 startPos, s assert(from.getLength() == nCount); from.swap(to); - for (sal_Int32& ix : toNonConstRange(to)) + for (sal_Int32& ix : asNonConstRange(to)) ix = std::as_const(from)[ix]; } offset = to; @@ -356,7 +356,7 @@ TransliterationImpl::folding( const OUString& inStr, sal_Int32 startPos, sal_Int tmpStr = bodyCascade[0]->folding(tmpStr, 0, nCount, offset); if ( startPos ) { - for (sal_Int32 & j : offset) + for (sal_Int32 & j : asNonConstRange(offset)) j += startPos; } return tmpStr; @@ -366,7 +366,7 @@ TransliterationImpl::folding( const OUString& inStr, sal_Int32 startPos, sal_Int { OUString tmpStr = inStr.copy(startPos, nCount); - auto [begin, end] = toNonConstRange(offset); + auto [begin, end] = asNonConstRange(offset); std::iota(begin, end, startPos); sal_Int16 from = 0, to = 1; diff --git a/i18npool/source/transliteration/transliteration_OneToOne.cxx b/i18npool/source/transliteration/transliteration_OneToOne.cxx index 34f4902f79bb..233f3dfe7051 100644 --- a/i18npool/source/transliteration/transliteration_OneToOne.cxx +++ b/i18npool/source/transliteration/transliteration_OneToOne.cxx @@ -68,7 +68,7 @@ transliteration_OneToOne::transliterateImpl( const OUString& inStr, sal_Int32 st // Allocate nCount length to offset argument. if (pOffset) { pOffset->realloc( nCount ); - auto [begin, end] = toNonConstRange(*pOffset); + auto [begin, end] = asNonConstRange(*pOffset); std::iota(begin, end, startPos); } diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx index b0c710c6c696..a64c8050bb79 100644 --- a/i18npool/source/transliteration/transliteration_body.cxx +++ b/i18npool/source/transliteration/transliteration_body.cxx @@ -260,7 +260,7 @@ static OUString transliterate_titlecase_Impl( xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, rLocale ); pOffset->realloc( aRes.getLength() ); - auto [begin, end] = toNonConstRange(*pOffset); + auto [begin, end] = asNonConstRange(*pOffset); sal_Int32* pOffsetInt = std::fill_n(begin, nResolvedLen, 0); std::iota(pOffsetInt, end, 1); } diff --git a/include/com/sun/star/uno/Sequence.h b/include/com/sun/star/uno/Sequence.h index 39caf8ff768f..cc2c515f1322 100644 --- a/include/com/sun/star/uno/Sequence.h +++ b/include/com/sun/star/uno/Sequence.h @@ -185,12 +185,14 @@ public: */ inline E * SAL_CALL getArray(); +#if !defined LIBO_INTERNAL_ONLY /** This function allows to use Sequence in standard algorithms, like std::find and others. @since LibreOffice 4.2 */ inline E * begin(); +#endif /** This function allows to use Sequence in standard algorithms, like std::find and others. @@ -199,12 +201,14 @@ public: */ inline E const * begin() const; +#if !defined LIBO_INTERNAL_ONLY /** This function allows to use Sequence in standard algorithms, like std::find and others. @since LibreOffice 4.2 */ inline E * end(); +#endif /** This function allows to use Sequence in standard algorithms, like std::find and others. diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx index 08a74d73789f..5356872b1378 100644 --- a/include/com/sun/star/uno/Sequence.hxx +++ b/include/com/sun/star/uno/Sequence.hxx @@ -166,12 +166,16 @@ inline E * Sequence< E >::getArray() return reinterpret_cast< E * >( _pSequence->elements ); } +#if !defined LIBO_INTERNAL_ONLY template<class E> E * Sequence<E>::begin() { return getArray(); } +#endif template<class E> E const * Sequence<E>::begin() const { return getConstArray(); } +#if !defined LIBO_INTERNAL_ONLY template<class E> E * Sequence<E>::end() { return begin() + getLength(); } +#endif template<class E> E const * Sequence<E>::end() const { return begin() + getLength(); } @@ -279,7 +283,7 @@ 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) +template <class E> inline auto asNonConstRange(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 @@ -292,7 +296,7 @@ template <class E> inline auto toNonConstRange(css::uno::Sequence<E>& s) E* begin() { return std::pair<E*, E*>::first; } E* end() { return std::pair<E*, E*>::second; } }; - return SequenceRange(s.begin(), s.getLength()); + return SequenceRange(s.getArray(), s.getLength()); }; /// @endcond diff --git a/include/comphelper/basicio.hxx b/include/comphelper/basicio.hxx index 96e185d78838..62260e3da360 100644 --- a/include/comphelper/basicio.hxx +++ b/include/comphelper/basicio.hxx @@ -65,7 +65,7 @@ template <class ELEMENT> const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, css::uno::Sequence<ELEMENT>& _rSeq) { _rSeq.realloc(_rxInStream->readLong()); - for (ELEMENT& rElement : _rSeq) + for (ELEMENT& rElement : asNonConstRange(_rSeq)) _rxInStream >> rElement; return _rxInStream; } diff --git a/include/comphelper/propertysequence.hxx b/include/comphelper/propertysequence.hxx index 3f9838f9ab8f..2c143aa9ed7a 100644 --- a/include/comphelper/propertysequence.hxx +++ b/include/comphelper/propertysequence.hxx @@ -24,7 +24,7 @@ namespace comphelper ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit) { css::uno::Sequence< css::beans::PropertyValue> vResult{static_cast<sal_Int32>(vInit.size())}; - std::transform(vInit.begin(), vInit.end(), vResult.begin(), + std::transform(vInit.begin(), vInit.end(), vResult.getArray(), [](const std::pair<OUString, css::uno::Any>& rInit) { return css::beans::PropertyValue(rInit.first, -1, rInit.second, css::beans::PropertyState_DIRECT_VALUE); @@ -40,7 +40,7 @@ namespace comphelper ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit) { css::uno::Sequence<css::uno::Any> vResult{static_cast<sal_Int32>(vInit.size())}; - std::transform(vInit.begin(), vInit.end(), vResult.begin(), + std::transform(vInit.begin(), vInit.end(), vResult.getArray(), [](const std::pair<OUString, css::uno::Any>& rInit) { return css::uno::Any( css::beans::PropertyValue(rInit.first, -1, rInit.second, diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx index 18e269173627..7c999ec25059 100644 --- a/include/comphelper/sequence.hxx +++ b/include/comphelper/sequence.hxx @@ -50,7 +50,7 @@ namespace comphelper { // unary fold to disallow empty parameter pack: at least have one sequence in rSn css::uno::Sequence<T> aReturn(std::size(rS1) + (... + std::size(rSn))); - T* pReturn = std::copy(std::begin(rS1), std::end(rS1), aReturn.begin()); + T* pReturn = std::copy(std::begin(rS1), std::end(rS1), aReturn.getArray()); (..., (pReturn = std::copy(std::begin(rSn), std::end(rSn), pReturn))); return aReturn; } diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index 278e7942828b..2ae09ee4d16e 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -1145,7 +1145,7 @@ void LngSvcMgr::SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp ) // append path prefix need for 'GetProperties' call below OUString aPrefix = aNode + "/"; - for (OUString & name : aNames) + for (OUString & name : asNonConstRange(aNames)) { name = aPrefix + name; } @@ -1178,7 +1178,7 @@ void LngSvcMgr::SetCfgServiceLists( GrammarCheckingIterator &rGrammarDsp ) // append path prefix need for 'GetProperties' call below OUString aPrefix = aNode + "/"; - for (OUString & name : aNames) + for (OUString & name : asNonConstRange(aNames)) { name = aPrefix + name; } @@ -1215,7 +1215,7 @@ void LngSvcMgr::SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp ) // append path prefix need for 'GetProperties' call below OUString aPrefix = aNode + "/"; - for (OUString & name : aNames) + for (OUString & name : asNonConstRange(aNames)) { name = aPrefix + name; } @@ -1252,7 +1252,7 @@ void LngSvcMgr::SetCfgServiceLists( ThesaurusDispatcher &rThesDsp ) // append path prefix need for 'GetProperties' call below OUString aPrefix = aNode + "/"; - for (OUString & name : aNames) + for (OUString & name : asNonConstRange(aNames)) { name = aPrefix + name; } diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 1066b67aac76..62bc860ee7b2 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -180,7 +180,7 @@ void CustomShapeProperties::pushToPropSet( static const OUStringLiteral sType = u"Type"; if ( aGeoPropSet >>= aGeoPropSeq ) { - for ( auto& rGeoProp : aGeoPropSeq ) + for ( auto& rGeoProp : asNonConstRange(aGeoPropSeq) ) { if ( rGeoProp.Name == sAdjustmentValues ) { diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 32736e67fad0..e78ca42af24f 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -702,7 +702,7 @@ Sequence< Sequence< OUString > > ChartExport::getSplitCategoriesList( const OUSt //sort the categories name Sequence<Sequence<OUString>> aFinalSplitSource(aCategories.getLength()); std::transform(aCategories.begin(), aCategories.end(), - std::reverse_iterator(aFinalSplitSource.end()), + std::reverse_iterator(asNonConstRange(aFinalSplitSource).end()), [](const Reference<chart2::data::XLabeledDataSequence>& xCat) { return lcl_getLabelSequence(xCat->getValues()); }); return aFinalSplitSource; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 4326ce2fa01d..6b05b15546cc 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -4471,7 +4471,7 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) } else { - for( auto& rOuterShdwProp : aOuterShdwProps ) + for( auto& rOuterShdwProp : asNonConstRange(aOuterShdwProps) ) { if( rOuterShdwProp.Name == "Attribs" ) { @@ -4485,7 +4485,7 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) rXPropSet->getPropertyValue( "ShadowBlur" ) >>= nBlur; - for( auto& rAttribsProp : aAttribsProps ) + for( auto& rAttribsProp : asNonConstRange(aAttribsProps) ) { if( rAttribsProp.Name == "dist" ) { diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 94f87a772c00..72c967d103c4 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -927,7 +927,7 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aGeomPropSeq = xPropertySet->getPropertyValue("CustomShapeGeometry").get< uno::Sequence<beans::PropertyValue> >(); bool bFound = false; - for (beans::PropertyValue& rProp : aGeomPropSeq) + for (beans::PropertyValue& rProp : asNonConstRange(aGeomPropSeq)) { if (rProp.Name == "TextPath") { diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index f821fd2494c8..c91996d0756c 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -423,7 +423,7 @@ void OWriteStream_Impl::SetDecrypted() m_bHasCachedEncryptionData = false; m_aEncryptionData.clear(); - for ( auto& rProp : m_aProps ) + for ( auto& rProp : asNonConstRange(m_aProps) ) { if ( rProp.Name == "Encrypted" ) rProp.Value <<= false; @@ -446,7 +446,7 @@ void OWriteStream_Impl::SetEncrypted( const ::comphelper::SequenceAsHashMap& aEn m_bHasDataToFlush = true; // introduce encryption info - for ( auto& rProp : m_aProps ) + for ( auto& rProp : asNonConstRange(m_aProps) ) { if ( rProp.Name == "Encrypted" ) rProp.Value <<= true; @@ -735,7 +735,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt // if there are cached properties update them if ( rProp.Name == aMedTypePropName || rProp.Name == aComprPropName ) - for ( auto& rMemProp : m_aProps ) + for ( auto& rMemProp : asNonConstRange(m_aProps) ) { if ( rProp.Name == rMemProp.Name ) rMemProp.Value = rProp.Value; @@ -825,7 +825,7 @@ void OWriteStream_Impl::Commit() // copy properties to the package stream uno::Reference< beans::XPropertySet > xPropertySet( xNewPackageStream, uno::UNO_QUERY_THROW ); - for ( auto& rProp : m_aProps ) + for ( auto& rProp : asNonConstRange(m_aProps) ) { if ( rProp.Name == "Size" ) { @@ -1053,7 +1053,7 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::ReadPackageStreamProper // TODO: may be also raw stream should be marked uno::Reference< beans::XPropertySet > xPropSet( m_xPackageStream, uno::UNO_QUERY_THROW ); - for ( auto& rProp : aResult ) + for ( auto& rProp : asNonConstRange(aResult) ) { try { rProp.Value = xPropSet->getPropertyValue( rProp.Name ); @@ -2177,7 +2177,7 @@ void OWriteStream::CloseOutput_Impl() if ( !m_xSeekable.is() ) throw uno::RuntimeException(); - for ( auto& rProp : m_pImpl->m_aProps ) + for ( auto& rProp : asNonConstRange(m_pImpl->m_aProps) ) { if ( rProp.Name == "Size" ) rProp.Value <<= m_xSeekable->getLength(); @@ -2785,7 +2785,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con bCompressedValueFromType = false; } - for ( auto& rProp : m_pImpl->m_aProps ) + for ( auto& rProp : asNonConstRange(m_pImpl->m_aProps) ) { if ( aPropertyName == rProp.Name ) rProp.Value = aValue; @@ -2797,7 +2797,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con { // if the "Compressed" property is not set explicitly, the MediaType can change the default value m_pImpl->m_bCompressedSetExplicit = true; - for ( auto& rProp : m_pImpl->m_aProps ) + for ( auto& rProp : asNonConstRange(m_pImpl->m_aProps) ) { if ( aPropertyName == rProp.Name ) rProp.Value = aValue; @@ -2828,7 +2828,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con } else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == aMediaTypeString ) { - for ( auto& rProp : m_pImpl->m_aProps ) + for ( auto& rProp : asNonConstRange(m_pImpl->m_aProps) ) { if ( aPropertyName == rProp.Name ) rProp.Value = aValue; diff --git a/package/source/zipapi/ThreadedDeflater.cxx b/package/source/zipapi/ThreadedDeflater.cxx index 73725c580c02..f574105ad4ef 100644 --- a/package/source/zipapi/ThreadedDeflater.cxx +++ b/package/source/zipapi/ThreadedDeflater.cxx @@ -114,8 +114,8 @@ void ThreadedDeflater::deflateWrite( if (!lastBatch) { assert(inputBytes == batchSize); - std::copy_n(inBuffer.begin() + (batchSize - MaxBlockSize), MaxBlockSize, - prevDataBlock.begin()); + std::copy_n(std::cbegin(inBuffer) + (batchSize - MaxBlockSize), MaxBlockSize, + prevDataBlock.getArray()); } processDeflatedBuffers(); @@ -130,7 +130,7 @@ void ThreadedDeflater::processDeflatedBuffers() css::uno::Sequence<sal_Int8> outBuffer(batchOutputSize); - auto pos = outBuffer.begin(); + auto pos = outBuffer.getArray(); for (auto& buffer : outBuffers) { pos = std::copy(buffer.begin(), buffer.end(), pos); diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx index daef59488cc2..4d31da9dadb2 100644 --- a/pyuno/source/module/pyuno_adapter.cxx +++ b/pyuno/source/module/pyuno_adapter.cxx @@ -273,8 +273,8 @@ Any Adapter::invoke( const OUString &aFunctionName, } aOutParam.realloc( nOutLength ); - ret = seq[0]; - std::copy_n(std::next(seq.begin()), nOutLength, aOutParam.begin()); + ret = std::as_const(seq)[0]; + std::copy_n(std::next(std::cbegin(seq)), nOutLength, aOutParam.getArray()); } // else { sequence is a return value !} } diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index f296561bf62e..82776672d8ee 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -443,7 +443,7 @@ void SAL_CALL OStyle::setPropertiesToDefault( const uno::Sequence< OUString >& a uno::Sequence< uno::Any > SAL_CALL OStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) { uno::Sequence< uno::Any > aRet(aPropertyNames.getLength()); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> uno::Any { return getPropertyDefault(rName); }); return aRet; } @@ -1512,8 +1512,9 @@ bool OReportDefinition::WriteThroughComponent( // prepare arguments (prepend doc handler to given arguments) uno::Sequence<uno::Any> aArgs( 1 + rArguments.getLength() ); - aArgs[0] <<= xSaxWriter; - std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin())); + auto pArgs = aArgs.getArray(); + *pArgs <<= xSaxWriter; + std::copy(rArguments.begin(), rArguments.end(), std::next(pArgs)); // get filter component uno::Reference< document::XExporter > xExporter( diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index 933b00dc2fe0..3d8b2c1be603 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -261,7 +261,7 @@ void SAL_CALL ImportDocumentHandler::startElement(const OUString & _sName, const break; } } - for(beans::PropertyValue & propVal : m_aArguments) + for(beans::PropertyValue & propVal : asNonConstRange(m_aArguments)) { if ( propVal.Name == "HasCategories" ) { diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 056951c82216..d757fce2de3d 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -759,7 +759,7 @@ sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt ) else aValues = svx::OMultiColumnTransferable::extractDescriptor(aDropped); - for(beans::PropertyValue & propVal : aValues) + for(beans::PropertyValue & propVal : asNonConstRange(aValues)) { uno::Sequence<beans::PropertyValue> aCurrent; propVal.Value >>= aCurrent; diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index db2291da0edf..754aa687c7c5 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -2597,7 +2597,7 @@ void ScFiltersTest2::testTextBoxBodyUpright() { uno::Sequence<beans::PropertyValue> aGrabBag; xShapeProperties->getPropertyValue("InteropGrabBag") >>= aGrabBag; - for (auto& aProp : aGrabBag) + for (auto& aProp : std::as_const(aGrabBag)) { if (aProp.Name == "Upright") { diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index f46bf21d5694..1bab5ce8ba40 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2118,7 +2118,7 @@ static PivotFunc lcl_FirstSubTotal( const uno::Reference<beans::XPropertySet>& x if ( aSubAny >>= aSeq ) { PivotFunc nMask = PivotFunc::NONE; - for (const sal_Int16 nElem : aSeq) + for (const sal_Int16 nElem : std::as_const(aSeq)) nMask |= ScDataPilotConversion::FunctionBit(nElem); return nMask; } diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index f02a510bcdeb..03b3d2280e79 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(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(), + std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.getArray(), [](const sheet::GeneralFunction& rFunc) -> sal_Int16 { return static_cast<sal_Int16>(rFunc); }); } @@ -2124,9 +2124,8 @@ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const OUString& aPropertyName ) else if ( aPropertyName == SC_UNO_DP_SUBTOTAL ) { const uno::Sequence<sal_Int16> aSeq = getSubTotals(); - uno::Sequence<sheet::GeneralFunction> aNewSeq; - aNewSeq.realloc(aSeq.getLength()); - std::transform(aSeq.begin(), aSeq.end(), aNewSeq.begin(), + uno::Sequence<sheet::GeneralFunction> aNewSeq(aSeq.getLength()); + std::transform(aSeq.begin(), aSeq.end(), aNewSeq.getArray(), [](const sal_Int16 nFunc) -> sheet::GeneralFunction { if (nFunc == sheet::GeneralFunction2::MEDIAN) return sheet::GeneralFunction_NONE; diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx index aeb3c53bdc80..b3bda1c529f0 100644 --- a/sc/source/core/tool/charthelper.cxx +++ b/sc/source/core/tool/charthelper.cxx @@ -232,7 +232,7 @@ void ScChartHelper::SetChartRanges( const uno::Reference< chart2::XChartDocument uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() ); sal_Int32 nRange=0; - for( uno::Reference<chart2::data::XLabeledDataSequence>& xLabeledSequence : aLabeledDataSequences ) + for( uno::Reference<chart2::data::XLabeledDataSequence>& xLabeledSequence : asNonConstRange(aLabeledDataSequences) ) { if( nRange >= rRanges.getLength() ) break; diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index fb1a5f35d793..089f578b3e10 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -1935,7 +1935,7 @@ bool XclExpChSeries::ConvertDataSeries( Sequence< sal_Int32 > aPointIndexes; if( aSeriesProp.GetProperty( aPointIndexes, EXC_CHPROP_ATTRIBDATAPOINTS ) && aPointIndexes.hasElements() ) { - for( const sal_Int32 nPointIndex : aPointIndexes ) + for( const sal_Int32 nPointIndex : std::as_const(aPointIndexes) ) { if (nPointIndex >= nMaxPointCount) break; diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx index a1271eb81602..b08f3bed1c5a 100644 --- a/sc/source/filter/ftools/fapihelper.cxx +++ b/sc/source/filter/ftools/fapihelper.cxx @@ -219,7 +219,7 @@ void ScfPropertySet::GetProperties( Sequence< Any >& rValues, const Sequence< OU { sal_Int32 nLen = rPropNames.getLength(); rValues.realloc( nLen ); - std::transform(rPropNames.begin(), rPropNames.end(), rValues.begin(), + std::transform(rPropNames.begin(), rPropNames.end(), rValues.getArray(), [this](const OUString& rPropName) -> Any { return mxPropSet->getPropertyValue(rPropName); }); } } diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index a7a8d442533d..ed1dbd8ebeda 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -522,7 +522,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScAccessibleCell::getCharacterAtt sal_uInt16 nParaIndent = mpDoc->GetAttr( maCellAddress, ATTR_INDENT )->GetValue(); if (nParaIndent > 0) { - auto [begin, end] = toNonConstRange(aAttribs); + auto [begin, end] = asNonConstRange(aAttribs); auto pAttrib = std::find_if(begin, end, [](const beans::PropertyValue& rAttrib) { return "ParaLeftMargin" == rAttrib.Name; }); if (pAttrib != end) diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index c81819b3027a..c331dddcb539 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -862,11 +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; + auto pVariables = aVariables.getArray(); for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol) - *it++ = table::CellAddress( nTab, nCol, nRow ); + pVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow ); } uno::Sequence<sheet::SolverConstraint> aConstraints; @@ -971,7 +971,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal sal_Int32 nVarCount = aVariables.getLength(); uno::Sequence<double> aOldValues( nVarCount ); - std::transform(std::cbegin(aVariables), std::cend(aVariables), aOldValues.begin(), + std::transform(std::cbegin(aVariables), std::cend(aVariables), aOldValues.getArray(), [this](const table::CellAddress& rVariable) -> double { ScAddress aCellPos; ScUnoConversion::FillScAddress( aCellPos, rVariable ); diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx index 4c849959399a..770520785b39 100644 --- a/sc/source/ui/miscdlgs/solveroptions.cxx +++ b/sc/source/ui/miscdlgs/solveroptions.cxx @@ -171,7 +171,7 @@ void ScSolverOptionsDialog::FillListBox() uno::Sequence<beans::PropertyValue> aNewSeq; aNewSeq.realloc( nCount ); - std::transform(aDescriptions.begin(), aDescriptions.end(), aNewSeq.begin(), + std::transform(aDescriptions.begin(), aDescriptions.end(), aNewSeq.getArray(), [this](const ScSolverOptionsEntry& rDescr) -> beans::PropertyValue { return maProperties[ rDescr.nPosition ]; }); maProperties = aNewSeq; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 30b41197dc55..6720b9823929 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1834,7 +1834,7 @@ uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength()); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(), [this, &rPropertyMap](const auto& rName) -> beans::PropertyState { sal_uInt16 nItemWhich = 0; const SfxItemPropertyMapEntry* pEntry = rPropertyMap.getByName( rName ); diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 5eb7f2cc75e0..7f9d23a7d143 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -1549,7 +1549,7 @@ ScChart2DataProvider::createDataSource( aSeqVector.push_back(aSeq); } - for( const sal_Int32 nNewIndex : aSequenceMapping ) + for( const sal_Int32 nNewIndex : std::as_const(aSequenceMapping) ) { // note: assuming that the values in the sequence mapping are always non-negative ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >::size_type nOldIndex( static_cast< sal_uInt32 >( nNewIndex ) ); @@ -2579,7 +2579,7 @@ void ScChart2DataSequence::BuildDataCache() // convert the hidden cell list to sequence. m_aHiddenValues.realloc(aHiddenValues.size()); std::copy( - aHiddenValues.begin(), aHiddenValues.end(), m_aHiddenValues.begin()); + aHiddenValues.begin(), aHiddenValues.end(), m_aHiddenValues.getArray()); // Clear the data series cache when the array is re-built. m_aMixedDataCache.realloc(0); diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index dd85f6ff8ba5..99de5a326b62 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1843,9 +1843,8 @@ Any SAL_CALL ScDataPilotFieldObj::getPropertyValue( const OUString& aPropertyNam else if ( aPropertyName == SC_UNONAME_SUBTOTALS ) { const uno::Sequence<sal_Int16> aSeq = getSubtotals(); - uno::Sequence<sheet::GeneralFunction> aNewSeq; - aNewSeq.realloc(aSeq.getLength()); - std::transform(aSeq.begin(), aSeq.end(), aNewSeq.begin(), + uno::Sequence<sheet::GeneralFunction> aNewSeq(aSeq.getLength()); + std::transform(aSeq.begin(), aSeq.end(), aNewSeq.getArray(), [](sal_Int16 nFunc) -> sheet::GeneralFunction { if (nFunc == sheet::GeneralFunction2::MEDIAN) return sheet::GeneralFunction_NONE; diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index 7015985e5a74..62a399b6b3c8 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -284,7 +284,7 @@ uno::Sequence<beans::PropertyState> SAL_CALL ScDocDefaultsObj::getPropertyStates SolarMutexGuard aGuard; uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength()); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); }); return aRet; } diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx index 0a5d29c2a467..93ea182a05b3 100644 --- a/sc/source/ui/unoobj/dispuno.cxx +++ b/sc/source/ui/unoobj/dispuno.cxx @@ -119,7 +119,7 @@ uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL SolarMutexGuard aGuard; uno::Sequence< uno::Reference< frame::XDispatch> > aReturn(aDescripts.getLength()); - std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return aReturn; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index d1131d6f967b..6a9d0d890556 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -344,7 +344,7 @@ void ScPrintUIOptions::SetDefaults() uno::Sequence<beans::PropertyValue> aUIProp; if ( rPropValue.Value >>= aUIProp ) { - for (auto& rProp : aUIProp) + for (auto& rProp : asNonConstRange(aUIProp)) { OUString aName = rProp.Name; if ( aName == "Property" ) diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 4c0dacb079ab..18cfd2eef580 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -410,15 +410,14 @@ public: sal_Int32 nStartRow = mrDocRow; sal_Int32 nRowCount = maSeq.getLength(); sal_Int32 nMaxColCount = 0; - for ( const uno::Sequence< seq >& rRow : maSeq ) + for ( const uno::Sequence< seq >& rRow : std::as_const(maSeq) ) { sal_Int32 nColCount = rRow.getLength(); if ( nColCount > nMaxColCount ) nMaxColCount = nColCount; - const seq* pColArr = rRow.getConstArray(); for (sal_Int32 nCol=0; nCol<nColCount; nCol++) if ( nCol <= mpDoc->MaxCol() && mrDocRow <= mpDoc->MaxRow() ) - aVisitor.visitElem( nCol, mrDocRow, pColArr[ nCol ] ); + aVisitor.visitElem( nCol, mrDocRow, rRow[ nCol ] ); else mbOverflow=true; mrDocRow++; diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx index 97fcb17b01b7..5649fe26060a 100644 --- a/sc/source/ui/unoobj/shapeuno.cxx +++ b/sc/source/ui/unoobj/shapeuno.cxx @@ -936,7 +936,7 @@ uno::Sequence<beans::PropertyState> SAL_CALL ScShapeObj::getPropertyStates( // simple loop to get own and aggregated states uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength()); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); }); return aRet; } diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 58924e653e46..4baa85a35476 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -1212,7 +1212,7 @@ uno::Sequence<beans::PropertyState> SAL_CALL ScStyleObj::getPropertyStates( cons GetStyle_Impl(); uno::Sequence<beans::PropertyState> aRet( aPropertyNames.getLength() ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> beans::PropertyState { return getPropertyState_Impl(rName); }); return aRet; } @@ -1326,7 +1326,7 @@ uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyDefaults( const uno::Seq GetStyle_Impl(); uno::Sequence<uno::Any> aSequence( aPropertyNames.getLength() ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aSequence.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aSequence.getArray(), [this](const OUString& rName) -> uno::Any { return getPropertyDefault_Impl(rName); }); return aSequence; } @@ -1358,7 +1358,7 @@ uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyValues( const uno::Seque GetStyle_Impl(); uno::Sequence<uno::Any> aSequence( aPropertyNames.getLength() ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aSequence.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aSequence.getArray(), [this](const OUString& rName) -> uno::Any { return getPropertyValue_Impl(rName); }); return aSequence; } diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx index 09c061a36ced..adc1b7f4467e 100644 --- a/sc/source/ui/vba/vbachart.cxx +++ b/sc/source/ui/vba/vbachart.cxx @@ -624,7 +624,7 @@ uno::Sequence< OUString > ScVbaChart::getDefaultSeriesDescriptions( sal_Int32 _nCount ) { uno::Sequence< OUString > sDescriptions ( _nCount ); - std::generate_n(sDescriptions.begin(), _nCount, + std::generate_n(sDescriptions.getArray(), _nCount, [i = 1]() mutable -> OUString { return DEFAULTSERIESPREFIX + OUString::number(i++); }); return sDescriptions; } diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 8eec39dca899..e5acba5fff5f 100644 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -771,8 +771,9 @@ uno::Sequence< uno::Any > ScVbaEventsHelper::implBuildArgumentList( const EventH { sal_Int32 nLength = aVbaArgs.getLength(); uno::Sequence< uno::Any > aVbaArgs2( nLength + 1 ); - aVbaArgs2[ 0 ] = createWorksheet( rArgs, 0 ); - std::copy_n(aVbaArgs.begin(), nLength, std::next(aVbaArgs2.begin())); + auto pVbaArgs2 = aVbaArgs2.getArray(); + *pVbaArgs2 = createWorksheet( rArgs, 0 ); + std::copy_n(std::cbegin(aVbaArgs), nLength, std::next(pVbaArgs2)); aVbaArgs = aVbaArgs2; } diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index fb23ab02fcc4..8b2b9fbc724f 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -48,11 +48,6 @@ using namespace ::com::sun::star; uno::Sequence< sal_Int32 > ScVbaWorkbook::ColorData; -void ScVbaWorkbook::initColorData( const uno::Sequence< sal_Int32 >& sColors ) -{ - std::copy(sColors.begin(), sColors.end(), ColorData.begin()); -} - void SAL_CALL ScVbaWorkbook::ResetColors( ) { @@ -60,11 +55,9 @@ ScVbaWorkbook::ResetColors( ) sal_Int32 nLen = xIndexAccess->getCount(); ColorData.realloc( nLen ); - uno::Sequence< sal_Int32 > dDefaultColors( nLen ); - sal_Int32* pDest = dDefaultColors.getArray(); + sal_Int32* pDest = ColorData.getArray(); for ( sal_Int32 index=0; index < nLen; ++pDest, ++index ) xIndexAccess->getByIndex( index ) >>= *pDest; - initColorData( dDefaultColors ); } ::uno::Any SAL_CALL @@ -84,7 +77,7 @@ ScVbaWorkbook::Colors( const ::uno::Any& Index ) bool ScVbaWorkbook::setFilterPropsFromFormat( sal_Int32 nFormat, uno::Sequence< beans::PropertyValue >& rProps ) { - auto [begin, end] = toNonConstRange(rProps); + auto [begin, end] = asNonConstRange(rProps); auto pProp = std::find_if(begin, end, [](const beans::PropertyValue& rProp) { return rProp.Name == "FilterName"; }); bool bRes = pProp != end; diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx index 0afc88a3c17f..886f771bf5e7 100644 --- a/sc/source/ui/vba/vbaworkbook.hxx +++ b/sc/source/ui/vba/vbaworkbook.hxx @@ -29,7 +29,6 @@ class ScVbaWorkbook : public ScVbaWorkbook_BASE { static css::uno::Sequence< sal_Int32 > ColorData; static bool setFilterPropsFromFormat( sal_Int32 nFormat, css::uno::Sequence< css::beans::PropertyValue >& rProps ); - static void initColorData( const css::uno::Sequence< sal_Int32 >& sColors ); void init(); public: diff --git a/sc/source/ui/vba/vbawsfunction.cxx b/sc/source/ui/vba/vbawsfunction.cxx index 350be038192b..e9119c67a0ba 100644 --- a/sc/source/ui/vba/vbawsfunction.cxx +++ b/sc/source/ui/vba/vbawsfunction.cxx @@ -76,7 +76,7 @@ ScVbaWSFunction::invoke(const OUString& FunctionName, const uno::Sequence< uno:: uno::Sequence< uno::Any > aParamTemp( Params ); if( aParamTemp.hasElements() ) { - for( uno::Any & rArray : aParamTemp ) + for( uno::Any & rArray : asNonConstRange(aParamTemp) ) { switch( rArray.getValueType().getTypeClass() ) { @@ -186,8 +186,8 @@ ScVbaWSFunction::invoke(const OUString& FunctionName, const uno::Sequence< uno:: if( aRet.has< AnySeqSeq >() ) { AnySeqSeq aAnySeqSeq = aRet.get< AnySeqSeq >(); - for( auto& rAnySeq : aAnySeqSeq ) - for( auto& rAny : rAnySeq ) + for( auto& rAnySeq : asNonConstRange(aAnySeqSeq) ) + for( auto& rAny : asNonConstRange(rAnySeq) ) lclConvertDoubleToBoolean( rAny ); aRet <<= aAnySeqSeq; } diff --git a/sccomp/source/solver/SwarmSolver.cxx b/sccomp/source/solver/SwarmSolver.cxx index c0dad8a4471d..4aac9f81e23e 100644 --- a/sccomp/source/solver/SwarmSolver.cxx +++ b/sccomp/source/solver/SwarmSolver.cxx @@ -582,7 +582,7 @@ void SAL_CALL SwarmSolver::solve() mbSuccess = true; maSolution.realloc(aSolution.size()); - std::copy(aSolution.begin(), aSolution.end(), maSolution.begin()); + std::copy(aSolution.begin(), aSolution.end(), maSolution.getArray()); } extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index e8fe67a1c502..db9d746c81be 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -107,7 +107,7 @@ const Sequence < DispatchDescriptor >& seqDescriptor ) { sal_Int32 nCount = seqDescriptor.getLength(); Sequence< Reference< XDispatch > > lDispatcher( nCount ); - std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(), + std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.getArray(), [this](const DispatchDescriptor& rDescr) -> Reference<XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return lDispatcher; diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx index 1366f0d24f6b..6caa71c406b6 100644 --- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx +++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx @@ -104,7 +104,7 @@ public: sal_Int32 index = 0; for ( const Sequence< Reference < browse::XBrowseNode > >& children : seqs ) { - std::copy(children.begin(), children.end(), std::next(result.begin(), index)); + std::copy(children.begin(), children.end(), std::next(result.getArray(), index)); index += children.getLength(); if (index >= numChildren) diff --git a/sd/source/core/CustomAnimationCloner.cxx b/sd/source/core/CustomAnimationCloner.cxx index f81e7f522e63..7f8d79ce7c89 100644 --- a/sd/source/core/CustomAnimationCloner.cxx +++ b/sd/source/core/CustomAnimationCloner.cxx @@ -190,7 +190,7 @@ namespace sd Sequence< NamedValue > aUserData( xNode->getUserData() ); if( aUserData.hasElements() ) { - for( NamedValue & namedValue : aUserData ) + for( NamedValue & namedValue : asNonConstRange(aUserData) ) { namedValue.Value = transformValue( namedValue.Value ); } @@ -223,7 +223,7 @@ namespace sd Sequence<Any> aSequence; rValue >>= aSequence; - for( Any& rAny : aSequence ) + for( Any& rAny : asNonConstRange(aSequence) ) rAny = transformValue( rAny ); return makeAny( aSequence ); diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index 83a3e674e710..cb4e7db67b92 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -418,7 +418,7 @@ void CustomAnimationEffect::setPresetClassAndId( sal_Int16 nPresetClass, const O bool bFoundPresetId = false; if( nLength ) { - auto [begin, end] = toNonConstRange(aUserData); + auto [begin, end] = asNonConstRange(aUserData); NamedValue* pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "preset-class"; }); if (pProp != end) @@ -473,7 +473,7 @@ void CustomAnimationEffect::setNodeType( sal_Int16 nNodeType ) bool bFound = false; if( nLength ) { - auto [begin, end] = toNonConstRange(aUserData); + auto [begin, end] = asNonConstRange(aUserData); NamedValue* pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "node-type"; }); if (pProp != end) @@ -508,7 +508,7 @@ void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId ) bool bFound = false; if( nLength ) { - auto [begin, end] = toNonConstRange(aUserData); + auto [begin, end] = asNonConstRange(aUserData); NamedValue* pProp = std::find_if(begin, end, [](const NamedValue& rProp) { return rProp.Name == "group-id"; }); if (pProp != end) diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 72298f94d951..30b4bc38eee8 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -1332,7 +1332,7 @@ Sequence< PropertyState > SAL_CALL SdStyleSheet::getPropertyStates( const Sequen Sequence< PropertyState > aPropertyStateSequence( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aPropertyStateSequence.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aPropertyStateSequence.getArray(), [this](const OUString& rName) -> PropertyState { return getPropertyState(rName); }); return aPropertyStateSequence; diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 9070b6135259..c06c109cd0d4 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -2069,7 +2069,7 @@ bool PowerPointExport::WriteColorSchemes(const FSHelperPtr& pFS, const OUString& OUString sName = PredefinedClrNames[static_cast<PredefinedClrSchemeId>(nId)]; sal_Int32 nColor = 0; - for (auto aIt = aCurrentTheme.begin(); aIt != aCurrentTheme.end(); aIt++) + for (auto aIt = std::cbegin(aCurrentTheme); aIt != std::cend(aCurrentTheme); aIt++) { if (aIt->Name == sName) { diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx index edf39df51513..4e3fefb797ea 100644 --- a/sd/source/filter/grf/sdgrffilter.cxx +++ b/sd/source/filter/grf/sdgrffilter.cxx @@ -246,7 +246,7 @@ bool SdGRFFilter::Export() OUString sShortName( rGraphicFilter.GetExportFormatShortName( nFilter ) ); bool bFilterNameFound = false; - for ( auto& rArg : aArgs ) + for ( auto& rArg : asNonConstRange(aArgs) ) { OUString& rStr = rArg.Name; if ( rStr == sFilterName ) diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx index b6f40b20356e..2d8a5ef17103 100644 --- a/sd/source/filter/ppt/pptinanimations.cxx +++ b/sd/source/filter/ppt/pptinanimations.cxx @@ -535,7 +535,7 @@ bool AnimationImporter::convertAnimationNode( const Reference< XAnimationNode >& Sequence< Any > aValues( xAnimate->getValues() ); if( aValues.hasElements() ) { - for( Any& rValue : aValues ) + for( Any& rValue : asNonConstRange(aValues) ) oox::ppt::convertAnimationValue(eAttribute, rValue); xAnimate->setValues( aValues ); diff --git a/sd/source/ui/unoidl/unomodule.cxx b/sd/source/ui/unoidl/unomodule.cxx index 0ea5527b3548..d862f7c9dd36 100644 --- a/sd/source/ui/unoidl/unomodule.cxx +++ b/sd/source/ui/unoidl/unomodule.cxx @@ -81,7 +81,7 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SdUnoModule::queryD sal_Int32 nCount = seqDescripts.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); - std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(), [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index d1284cf46789..984b5fd0df2c 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -1324,7 +1324,7 @@ Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< O { sal_Int32 nCount = aPropertyNames.getLength(); Sequence< Any > aValues( nCount ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.getArray(), [this](const OUString& rName) -> Any { Any aValue; try diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index 7faba9b450b6..508b1f8662fc 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -348,7 +348,7 @@ uno::Sequence< beans::PropertyState > SAL_CALL SdUnoPageBackground::getPropertyS uno::Sequence< beans::PropertyState > aPropertyStateSequence( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aPropertyStateSequence.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aPropertyStateSequence.getArray(), [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); }); return aPropertyStateSequence; diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx index 30e1b621f2b0..74a89bfbac1a 100644 --- a/sdext/source/minimizer/pppoptimizerdialog.cxx +++ b/sdext/source/minimizer/pppoptimizerdialog.cxx @@ -78,7 +78,7 @@ Sequence< Reference< css::frame::XDispatch > > SAL_CALL PPPOptimizerDialog::quer const Sequence< css::frame::DispatchDescriptor >& aDescripts ) { Sequence< Reference< css::frame::XDispatch> > aReturn( aDescripts.getLength() ); - std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), [this](const css::frame::DispatchDescriptor& rDescr) -> Reference<css::frame::XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return aReturn; diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index af86f8bcc02c..d3f64e1d4f34 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -146,7 +146,7 @@ Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispat { sal_Int32 nCount = seqDescriptor.getLength(); uno::Sequence< uno::Reference < frame::XDispatch > > lDispatcher(nCount); - std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(), + std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.getArray(), [this](const DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return lDispatcher; diff --git a/sfx2/source/appl/helpinterceptor.cxx b/sfx2/source/appl/helpinterceptor.cxx index 7fd631b05951..a9ff76101510 100644 --- a/sfx2/source/appl/helpinterceptor.cxx +++ b/sfx2/source/appl/helpinterceptor.cxx @@ -125,7 +125,7 @@ Sequence < Reference < XDispatch > > SAL_CALL HelpInterceptor_Impl::queryDispatc { Sequence< Reference< XDispatch > > aReturn( aDescripts.getLength() ); - std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), [this](const DispatchDescriptor& rDescr) -> Reference<XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return aReturn; diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index f77d557f09f4..3f8fb33636ad 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -106,7 +106,7 @@ uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL { sal_Int32 nCount = seqDescriptor.getLength(); uno::Sequence< uno::Reference<frame::XDispatch> > lDispatcher(nCount); - std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(), + std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.getArray(), [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return lDispatcher; diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 4d0571eeaca1..45802f71996e 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -909,7 +909,7 @@ bool TemplateLocalView::IsInternalTemplate(const OUString& rPath) uno::Any aAny = xPathSettings->getPropertyValue("Template_internal"); aAny >>= aInternalTemplateDirs; SfxURLRelocator_Impl aRelocator(xContext); - for (auto& rInternalTemplateDir : aInternalTemplateDirs) + for (OUString& rInternalTemplateDir : asNonConstRange(aInternalTemplateDirs)) { aRelocator.makeRelocatableURL(rInternalTemplateDir); aRelocator.makeAbsoluteURL(rInternalTemplateDir); diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 2ab7e28dc2d7..a20056c15fff 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -597,7 +597,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, sal_uInt32 nIndex( lNewArgs.getLength() ); lNewArgs.realloc( nIndex + nAddArgs ); - std::copy(aAddArgs.begin(), aAddArgs.end(), std::next(lNewArgs.begin(), nIndex)); + std::copy(aAddArgs.begin(), aAddArgs.end(), std::next(lNewArgs.getArray(), nIndex)); } // Overwrite possible detected synchron argument, if real listener exists (currently no other way) @@ -609,9 +609,9 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, // we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document // so we must retrieve this as an argument from the parsed URL lNewArgs.realloc( lNewArgs.getLength()+1 ); - nMarkArg = lNewArgs.getLength()-1; - lNewArgs[nMarkArg].Name = "Bookmark"; - lNewArgs[nMarkArg].Value <<= aURL.Mark; + auto& el = lNewArgs[lNewArgs.getLength()-1]; + el.Name = "Bookmark"; + el.Value <<= aURL.Mark; } css::uno::Reference< css::frame::XFrame > xFrameRef(xFrame.get(), css::uno::UNO_QUERY); diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index 8863a752ed45..845435ddc4f4 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -683,7 +683,7 @@ css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL Bac sal_Int32 nCount = seqDescripts.getLength(); css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount ); - std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(), [this](const css::frame::DispatchDescriptor& rDesc) -> css::uno::Reference<XDispatch> { return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); }); diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 1a3cdec7e08f..7462f840d1ec 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -2322,7 +2322,7 @@ bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet* rSet ) aOldProps[i].Value >>= oldValue; // We only edit hours and minutes // don't compare NanoSeconds and Seconds - for ( auto& rDateTime : oldValue ) + for ( auto& rDateTime : asNonConstRange(oldValue) ) { rDateTime.NanoSeconds = 0; rDateTime.Seconds = 0; @@ -2357,7 +2357,7 @@ void SfxCmisPropertiesPage::Reset( const SfxItemSet* rItemSet ) m_xPropertiesCtrl->ClearAllLines(); const SfxDocumentInfoItem& rInfoItem = rItemSet->Get(SID_DOCINFO); uno::Sequence< document::CmisProperty > aCmisProps = rInfoItem.GetCmisProperties(); - for ( auto& rCmisProp : aCmisProps ) + for ( auto& rCmisProp : asNonConstRange(aCmisProps) ) { m_xPropertiesCtrl->AddLine(rCmisProp.Id, rCmisProp.Name, diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 7765793c8a13..99e0de639070 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -613,7 +613,7 @@ void FileDialogHelper_Impl::updateVersions() aEntries.realloc( xVersions.getLength() + 1 ); aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ); - std::transform(xVersions.begin(), xVersions.end(), std::next(aEntries.begin()), + std::transform(xVersions.begin(), xVersions.end(), std::next(aEntries.getArray()), [](const util::RevisionTag& rVersion) -> OUString { return rVersion.Identifier; }); } catch( const uno::Exception& ) diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx index aa2a8a930e8f..dcdc1a1a32c3 100644 --- a/sfx2/source/dialog/filtergrouping.cxx +++ b/sfx2/source/dialog/filtergrouping.cxx @@ -818,7 +818,7 @@ namespace sfx2 Sequence< StringPair > aFilters( comphelper::containerToSequence(_rGroup) ); if ( _bAddExtension ) { - for ( StringPair & filter : aFilters ) + for ( StringPair & filter : asNonConstRange(aFilters) ) filter.First = addExtension( filter.First, filter.Second, true, *m_pFileDlgImpl ); } m_xFilterGroupManager->appendFilterGroup( OUString(), aFilters ); diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index f381b8b7bcf1..7a036226bbec 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -547,7 +547,7 @@ void SfxDocTplService_Impl::getDirList() u"vnd.sun.star.expand:" ); sal_Int32 nIdx{ 0 }; - for (auto& rTemplateDir : maTemplateDirs) + for (auto& rTemplateDir : asNonConstRange(maTemplateDirs)) { aURL.SetSmartProtocol( INetProtocol::File ); aURL.SetURL( aDirs.getToken( 0, C_DELIM, nIdx ) ); @@ -573,7 +573,7 @@ void SfxDocTplService_Impl::getDirList() Any aAny = xPathSettings->getPropertyValue( "Template_internal" ); aAny >>= maInternalTemplateDirs; - for (auto& rInternalTemplateDir : maInternalTemplateDirs) + for (auto& rInternalTemplateDir : asNonConstRange(maInternalTemplateDirs)) { //expand vnd.sun.star.expand: and remove "..." from them //to normalize into the expected url patterns @@ -967,7 +967,7 @@ bool SfxDocTplService_Impl::setProperty( Content& rContent, Sequence< OUString > aValues; if ( rPropValue >>= aValues ) { - for ( auto& rValue : aValues ) + for ( auto& rValue : asNonConstRange(aValues) ) { maRelocator.makeRelocatableURL( rValue ); } @@ -1026,7 +1026,7 @@ bool SfxDocTplService_Impl::getProperty(Content& rContent, const OUString& rProp Sequence< OUString > aValues; if ( rPropValue >>= aValues ) { - for ( auto& rValue : aValues ) + for ( auto& rValue : asNonConstRange(aValues) ) { maRelocator.makeAbsoluteURL( rValue ); } diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 254ccec4e3c7..e0fdd4caab63 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -398,7 +398,7 @@ SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell const * pObjectShell ) SfxOwnFramesLocker::~SfxOwnFramesLocker() { - for ( auto& rFrame : m_aLockedFrames ) + for ( auto& rFrame : asNonConstRange(m_aLockedFrames) ) { try { @@ -1615,7 +1615,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > nSlotId = SID_CHECKIN; sal_Int32 nLength = aSeqArgs.getLength( ); aArgs = Sequence< beans::PropertyValue >( nLength - 1 ); - std::copy_if(aSeqArgs.begin(), aSeqArgs.end(), aArgs.begin(), + std::copy_if(aSeqArgs.begin(), aSeqArgs.end(), aArgs.getArray(), [](const beans::PropertyValue& rProp) { return rProp.Name != "CheckIn"; }); } @@ -2792,7 +2792,7 @@ SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium ) static void addTitle_Impl( Sequence < beans::PropertyValue >& rSeq, const OUString& rTitle ) { - auto [begin, end] = toNonConstRange(rSeq); + auto [begin, end] = asNonConstRange(rSeq); auto pProp = std::find_if(begin, end, [](const beans::PropertyValue& rProp) { return rProp.Name == "Title"; }); if (pProp != end) diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 49653b4546cf..354f4b3ad96e 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -835,7 +835,7 @@ uno::Sequence< Reference< frame::XDispatch > > SAL_CALL SfxBaseController::query sal_Int32 nCount = seqDescripts.getLength(); uno::Sequence< Reference< frame::XDispatch > > lDispatcher( nCount ); - std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(), [this](const frame::DispatchDescriptor& rDesc) -> Reference< frame::XDispatch > { return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); }); diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 1be88db77133..603d31d41b33 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -702,7 +702,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) // the TransformItems function overwrite aProps TransformItems( nId, *rReq.GetArgs(), aProps, GetInterface()->GetSlot(nId) ); - for ( auto& rProp : aProps ) + for ( auto& rProp : asNonConstRange(aProps) ) { if ( rProp.Name == "Copies" ) { diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx index 3bba744a7fb0..fcf859b40d93 100644 --- a/slideshow/source/engine/opengl/TransitionerImpl.cxx +++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx @@ -617,7 +617,7 @@ private: static_cast<rendering::XColorSpace*>(this), 0); uno::Sequence<double> aRes(nLen); - std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(), + std::transform(deviceColor.begin(), deviceColor.end(), aRes.getArray(), vcl::unotools::toDoubleColor); return aRes; } diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index 0521606ebe63..b2dd397bbf46 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -75,7 +75,6 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/sallogareas \ compilerplugins/clang/test/salunicodeliteral \ compilerplugins/clang/test/selfinit \ - compilerplugins/clang/test/sequenceloop \ compilerplugins/clang/test/sequentialassign \ compilerplugins/clang/test/shouldreturnbool \ compilerplugins/clang/test/simplifybool \ diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 814e4101ed29..233b5fb7f351 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -372,7 +372,7 @@ void SmMathConfig::ReadSymbol( SmSym &rSymbol, sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); - for (auto& rName : aNames) + for (auto& rName : asNonConstRange(aNames)) rName = rBaseNode + aDelim + rSymbolName + aDelim + rName; const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames); @@ -578,7 +578,7 @@ void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat, sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); - for (auto& rName : aNames) + for (auto& rName : asNonConstRange(aNames)) rName = rBaseNode + aDelim + rSymbolName + aDelim + rName; const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames); diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index 476d384f897c..a6efe93ec69a 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -532,7 +532,7 @@ void SmXMLExport::GetConfigurationSettings(Sequence<PropertyValue>& rProps) SmMathConfig* pConfig = SM_MOD()->GetConfig(); const bool bUsedSymbolsOnly = pConfig && pConfig->IsSaveOnlyUsedSymbols(); - std::transform(aProps.begin(), aProps.end(), rProps.begin(), + std::transform(aProps.begin(), aProps.end(), rProps.getArray(), [bUsedSymbolsOnly, &xProps](const Property& prop) { PropertyValue aRet; if (prop.Name != "Formula" && prop.Name != "BasicLibraries" diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index bfd19ccd07e4..912ed434d29e 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -291,17 +291,19 @@ void createUniqueSubEntry(const Reference < XRegistryKey > & xSuperKey, if (bReady) { Sequence<OUString> implEntriesNew(length); - implEntriesNew.getArray()[0] = value; + auto it = implEntriesNew.getArray(); + *it = value; - std::copy_if(implEntries.begin(), implEntries.end(), std::next(implEntriesNew.begin()), + std::copy_if(implEntries.begin(), implEntries.end(), std::next(it), [&value](const OUString& rEntry) { return rEntry != value; }); xSuperKey->setAsciiListValue(implEntriesNew); } else { Sequence<OUString> implEntriesNew(length+1); - implEntriesNew.getArray()[0] = value; + auto it = implEntriesNew.getArray(); + *it = value; - std::copy(implEntries.begin(), implEntries.end(), std::next(implEntriesNew.begin())); + std::copy(implEntries.begin(), implEntries.end(), std::next(it)); xSuperKey->setAsciiListValue(implEntriesNew); } } else @@ -332,7 +334,7 @@ bool deleteSubEntry(const Reference < XRegistryKey >& xSuperKey, const OUString& { Sequence<OUString> implEntriesNew(length - equals); - std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.begin(), + std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.getArray(), [&value](const OUString& rEntry) { return rEntry != value; }); xSuperKey->setAsciiListValue(implEntriesNew); } @@ -741,7 +743,7 @@ void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xReg, { Sequence<OUString> implEntriesNew(length-equals); - std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.begin(), + std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.getArray(), [&implName](const OUString& rEntry) { return rEntry != implName; }); xServiceKey->setAsciiListValue(implEntriesNew); diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 6d4db16effe3..ab8a10fa1ef6 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(std::cbegin(OutIndices), std::cend(OutIndices), OutParams.begin(), + std::transform(std::cbegin(OutIndices), std::cend(OutIndices), OutParams.getArray(), [&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 3e50aed3953a..82f0335a0808 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -89,7 +89,7 @@ Sequence< OUString > retrieveAsciiValueList( sal_Int32 n2Len = seq2.getLength(); seq.realloc( n1Len + n2Len ); - std::copy(seq2.begin(), seq2.end(), std::next(seq.begin(), n1Len)); + std::copy(seq2.begin(), seq2.end(), std::next(seq.getArray(), n1Len)); } } } diff --git a/svl/qa/unit/lockfiles/test_lockfiles.cxx b/svl/qa/unit/lockfiles/test_lockfiles.cxx index b2bba0f9ce3c..d66c301be4e7 100644 --- a/svl/qa/unit/lockfiles/test_lockfiles.cxx +++ b/svl/qa/unit/lockfiles/test_lockfiles.cxx @@ -81,7 +81,7 @@ OUString readLockFile(const OUString& aSource) std::unique_ptr<sal_Int8[]> pBuffer(new sal_Int8[nSize]); aFileStream.ReadBytes(pBuffer.get(), nSize); - css::uno::Sequence<sal_Int8> aData(pBuffer.get(), nSize); + const css::uno::Sequence<sal_Int8> aData(pBuffer.get(), nSize); OStringBuffer aResult(static_cast<int>(nSize)); for (sal_Int8 nByte : aData) { diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx index 3e6affd8b83d..5f179447839d 100644 --- a/svl/source/config/asiancfg.cxx +++ b/svl/source/config/asiancfg.cxx @@ -103,7 +103,7 @@ css::uno::Sequence< css::lang::Locale > SvxAsianConfig::GetStartEndCharLocales() impl_->context)-> getElementNames()); css::uno::Sequence< css::lang::Locale > ls(ns.getLength()); - std::transform(ns.begin(), ns.end(), ls.begin(), + std::transform(ns.begin(), ns.end(), ls.getArray(), [](const OUString& rName) -> css::lang::Locale { return LanguageTag::convertToLocale( rName, false); }); return ls; diff --git a/svl/source/misc/PasswordHelper.cxx b/svl/source/misc/PasswordHelper.cxx index 617aeafdae1b..047d0b09b88b 100644 --- a/svl/source/misc/PasswordHelper.cxx +++ b/svl/source/misc/PasswordHelper.cxx @@ -32,7 +32,7 @@ void SvPasswordHelper::GetHashPasswordSHA256(uno::Sequence<sal_Int8>& rPassHash, reinterpret_cast<unsigned char const*>(tmp.getStr()), tmp.getLength(), ::comphelper::HashType::SHA256)); rPassHash.realloc(hash.size()); - ::std::copy(hash.begin(), hash.end(), rPassHash.begin()); + ::std::copy(hash.begin(), hash.end(), rPassHash.getArray()); rtl_secureZeroMemory(const_cast<char *>(tmp.getStr()), tmp.getLength()); } @@ -43,7 +43,7 @@ void SvPasswordHelper::GetHashPasswordSHA1UTF8(uno::Sequence<sal_Int8>& rPassHas reinterpret_cast<unsigned char const*>(tmp.getStr()), tmp.getLength(), ::comphelper::HashType::SHA1)); rPassHash.realloc(hash.size()); - ::std::copy(hash.begin(), hash.end(), rPassHash.begin()); + ::std::copy(hash.begin(), hash.end(), rPassHash.getArray()); rtl_secureZeroMemory(const_cast<char *>(tmp.getStr()), tmp.getLength()); } diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 6b385f4e7854..d2340bf2d968 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -3053,8 +3053,9 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, // ImpGenerateFormats for old "automatic" currency formats. uno::Sequence< i18n::NumberFormatCode > aFormatSeq = rNumberFormatCode->getAllFormatCode( i18n::KNumberFormatUsage::CURRENCY, aLocale ); sal_Int32 nCodes = aFormatSeq.getLength(); - ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), nCodes ); - for ( i18n::NumberFormatCode& rFormat : aFormatSeq ) + auto aNonConstRange = asNonConstRange(aFormatSeq); + ImpAdjustFormatCodeDefault( aNonConstRange.begin(), nCodes); + for ( i18n::NumberFormatCode& rFormat : aNonConstRange ) { if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET ) { diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx index c483a78b75cd..a5621e0ee4b2 100644 --- a/svl/source/passwordcontainer/passwordcontainer.cxx +++ b/svl/source/passwordcontainer/passwordcontainer.cxx @@ -186,7 +186,7 @@ PasswordMap StorageItem::getInfo() sal_Int32 aNodeCount = aNodeNames.getLength(); Sequence< OUString > aPropNames( aNodeCount ); - std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.begin(), + std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.getArray(), [](const OUString& rName) -> OUString { return "Store/Passwordstorage['" + rName + "']/Password"; }); diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx index 499c41f4324e..e5767b0b1453 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -132,7 +132,7 @@ public: uno::Sequence< OUString> ExtendedColorConfig_Impl::GetPropertyNames(const OUString& rScheme) { uno::Sequence< OUString> aNames(GetNodeNames(rScheme)); - for(OUString & i : aNames) + for(OUString & i : asNonConstRange(aNames)) { i = rScheme + "/" + i; } @@ -219,7 +219,7 @@ void ExtendedColorConfig_Impl::EnableBroadcast() static void lcl_addString(uno::Sequence < OUString >& _rSeq,std::u16string_view _sAdd) { - for(OUString & i : _rSeq) + for(OUString & i : asNonConstRange(_rSeq)) i += _sAdd; } @@ -233,7 +233,7 @@ void ExtendedColorConfig_Impl::Load(const OUString& rScheme) TDisplayNames aDisplayNameMap; uno::Sequence < OUString > aComponentNames = GetPropertyNames("EntryNames"); OUString sDisplayName("/DisplayName"); - for(OUString & componentName : aComponentNames) + for(OUString & componentName : asNonConstRange(aComponentNames)) { uno::Sequence< uno::Any > aComponentDisplayNamesValue = GetProperties( { componentName + sDisplayName } ); OUString sComponentDisplayName; diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index b5d69c88713a..3e5d47c362c1 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -221,7 +221,7 @@ Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispat uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); // Step over all descriptors and try to get any dispatcher for it. - std::transform(lDescriptor.begin(), lDescriptor.end(), lDispatcher.begin(), + std::transform(lDescriptor.begin(), lDescriptor.end(), lDispatcher.getArray(), [this](const DispatchDescriptor& rDesc) -> uno::Reference< frame::XDispatch > { return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); }); diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx index 94e3aab617fe..f2714a8ab9b0 100644 --- a/svx/source/accessibility/AccessibleControlShape.cxx +++ b/svx/source/accessibility/AccessibleControlShape.cxx @@ -784,7 +784,7 @@ void AccessibleControlShape::initializeComposedState() #if OSL_DEBUG_LEVEL > 0 // now, only states which are not in the responsibility of the UNO control should be part of this state set { - Sequence< sal_Int16 > aInitStates = pComposedStates->getStates(); + const Sequence< sal_Int16 > aInitStates = pComposedStates->getStates(); for ( sal_Int16 state : aInitStates ) OSL_ENSURE( !isComposedState( state ), "AccessibleControlShape::initializeComposedState: invalid initial composed state (should be controlled by the UNO-control)!" ); @@ -805,7 +805,7 @@ void AccessibleControlShape::initializeComposedState() aInnerStates = xInnerStates->getStates(); // look which one are to be propagated to the composed context - for ( const sal_Int16 nState : aInnerStates ) + for ( const sal_Int16 nState : std::as_const(aInnerStates) ) { if ( isComposedState( nState ) && !pComposedStates->contains( nState ) ) { diff --git a/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx b/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx index 7c6e010e9c2f..0236c88353db 100644 --- a/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx +++ b/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx @@ -53,7 +53,7 @@ void SvxNumOptionsTabPageHelper::GetI18nNumbering(weld::ComboBox& rFmtLB, sal_uI } if (xInfo.is()) { - Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes(); + const Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes(); for (const sal_Int16 nCurrent : aTypes) { if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N) diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx index 845ea5b74140..b10e6deb580e 100644 --- a/svx/source/dialog/rubydialog.cxx +++ b/svx/source/dialog/rubydialog.cxx @@ -387,8 +387,7 @@ void SvxRubyDialog::GetRubyText() Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); DBG_ASSERT(aRubyValues.getLength() > (i / 2 + nTempLastPos), "wrong index"); SetModified(true); - Sequence<PropertyValue>& rProps = aRubyValues.getArray()[i / 2 + nTempLastPos]; - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(aRubyValues[i / 2 + nTempLastPos])) { if (propVal.Name == cRubyBaseText) propVal.Value <<= aEditArr[i]->get_text(); @@ -547,10 +546,9 @@ IMPL_LINK(SvxRubyDialog, AdjustHdl_Impl, weld::ComboBox&, rBox, void) { AssertOneEntry(); sal_Int16 nAdjust = rBox.get_active(); - Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); - for (PropertyValues& rProps : aRubyValues) + for (PropertyValues& rProps : asNonConstRange(m_pImpl->GetRubyValues())) { - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(rProps)) { if (propVal.Name == cRubyAdjust) propVal.Value <<= nAdjust; @@ -564,10 +562,9 @@ IMPL_LINK(SvxRubyDialog, PositionHdl_Impl, weld::ComboBox&, rBox, void) { AssertOneEntry(); sal_Int16 nPosition = rBox.get_active(); - Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); - for (PropertyValues& rProps : aRubyValues) + for (PropertyValues& rProps : asNonConstRange(m_pImpl->GetRubyValues())) { - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(rProps)) { if (propVal.Name == cRubyPosition) propVal.Value <<= nPosition; @@ -583,10 +580,9 @@ IMPL_LINK_NOARG(SvxRubyDialog, CharStyleHdl_Impl, weld::ComboBox&, void) OUString sStyleName; if (m_xCharStyleLB->get_active() != -1) sStyleName = m_xCharStyleLB->get_active_id(); - Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); - for (PropertyValues& rProps : aRubyValues) + for (PropertyValues& rProps : asNonConstRange(m_pImpl->GetRubyValues())) { - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(rProps)) { if (propVal.Name == cRubyCharStyleName) { diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index d7f5ee2e0a64..dc9fa4100814 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -1381,7 +1381,7 @@ void FmGridControl::DeleteSelectedRows() else { // select the remaining rows - for (const sal_Int32 nSuccess : aDeletedRows) + for (const sal_Int32 nSuccess : std::as_const(aDeletedRows)) { try { diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index ab52cb90864a..40e4eefd7d44 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -2653,7 +2653,7 @@ Sequence< css::util::URL>& FmXGridPeer::getSupportedURLs() // let a css::util::URL-transformer normalize the URLs Reference< css::util::XURLTransformer > xTransformer( util::URLTransformer::create(::comphelper::getProcessComponentContext()) ); - for (css::util::URL & rURL : tmp) + for (css::util::URL & rURL : asNonConstRange(tmp)) xTransformer->parseStrict(rURL); return tmp; }(); diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx index 0b84e57d9d1a..cc75b0b01f30 100644 --- a/svx/source/form/formdispatchinterceptor.cxx +++ b/svx/source/form/formdispatchinterceptor.cxx @@ -89,7 +89,7 @@ namespace svxform { ::osl::MutexGuard aGuard( *m_pMutex ); Sequence< Reference< XDispatch> > aReturn(aDescripts.getLength()); - std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), [this](const DispatchDescriptor& rDescript) -> Reference< XDispatch> { return queryDispatch(rDescript.FeatureURL, rDescript.FrameName, rDescript.SearchFlags); }); return aReturn; diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 3abce7c4d820..134becd88e8b 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -1462,7 +1462,7 @@ Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUSt const sal_Int32 nCount = aPropertyName.getLength(); Sequence< PropertyState > aRet( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.getArray(), [this](const OUString& rName) -> PropertyState { try { @@ -1602,7 +1602,7 @@ Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& sal_Int32 nCount = aPropertyNames.getLength(); Sequence< Any > aDefaults( nCount ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aDefaults.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aDefaults.getArray(), [this](const OUString& rName) -> Any { return getPropertyDefault(rName); }); return aDefaults; diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index d315e79f9b3b..75a08ed16973 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -1504,7 +1504,7 @@ css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL Fin sal_Int32 nCount = seqDescripts.getLength(); css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount ); - std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(), [this](const css::frame::DispatchDescriptor& rDescript) -> css::uno::Reference < XDispatch > { return queryDispatch( rDescript.FeatureURL, rDescript.FrameName, rDescript.SearchFlags ); }); diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 843bca3967b5..2fc756fa0fdb 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -495,7 +495,7 @@ void GraphicExporter::ParseSettings( const Sequence< PropertyValue >& aDescripto { rValue.Value >>= rSettings.maFilterData; - for( PropertyValue& rDataValue : rSettings.maFilterData ) + for( PropertyValue& rDataValue : asNonConstRange(rSettings.maFilterData) ) { if ( rDataValue.Name == "Translucent" ) { diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 47676618c106..c7fc27260744 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -3016,7 +3016,7 @@ uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( cons const sal_Int32 nCount = aPropertyName.getLength(); uno::Sequence< beans::PropertyState > aRet( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.getArray(), [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); }); return aRet; diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 01f36765a18a..761cfdf7d4b7 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -771,7 +771,7 @@ void Test::testMSCharBackgroundEditing() xRun->setPropertyValue("CharHighlight", uno::makeAny(static_cast<sal_Int32>(COL_TRANSPARENT))); // Remove shading marker uno::Sequence<beans::PropertyValue> aGrabBag = getProperty<uno::Sequence<beans::PropertyValue> >(xRun,"CharInteropGrabBag"); - for (beans::PropertyValue& rProp : aGrabBag) + for (beans::PropertyValue& rProp : asNonConstRange(aGrabBag)) { if (rProp.Name == "CharShadingMarker") { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 31631d7d1579..eb48b60262c0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -861,7 +861,7 @@ CPPUNIT_TEST_FIXTURE(SwModelTestBase, testHighlightEdit_numbering) uno::Sequence<beans::PropertyValue> aGrabBag; aMap["CharInteropGrabBag"] >>= aGrabBag; - for (beans::PropertyValue& rProp : aGrabBag) + for (beans::PropertyValue& rProp : asNonConstRange(aGrabBag)) { // The shading is no longer defined from import, so clear that flag. // BackColor 0xff00ff will now attempt to export as highlight, since we set that in SvtFilterOptions. diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 3b59da527c3f..62808b697d49 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1717,7 +1717,7 @@ CPPUNIT_TEST_FIXTURE(Test, testVmlAdjustments) uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues = aGeometry["AdjustmentValues"].get<uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue>>(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aAdjustmentValues.getLength()); - drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue = *aAdjustmentValues.begin(); + drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue = *std::cbegin(aAdjustmentValues); CPPUNIT_ASSERT_EQUAL(sal_Int32(17639), aAdjustmentValue.Value.get<sal_Int32>()); } diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index e31c343d321d..6be041d8c585 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1604,7 +1604,8 @@ uno::Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes( uno::Sequence< PropertyValue > aValues( aDefAttrSeq.size() + ( bProvideMMToPixelRatio ? 1 : 0 ) ); - std::transform(aDefAttrSeq.begin(), aDefAttrSeq.end(), aValues.begin(), + auto pValues = aValues.getArray(); + std::transform(aDefAttrSeq.begin(), aDefAttrSeq.end(), pValues, [](const auto& rEntry) -> PropertyValue { return rEntry.second; }); // #i92233# @@ -1618,7 +1619,7 @@ uno::Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes( rPropVal.Value <<= fRatio; rPropVal.Handle = -1; rPropVal.State = beans::PropertyState_DEFAULT_VALUE; - aValues[ aValues.getLength() - 1 ] = rPropVal; + pValues[ aValues.getLength() - 1 ] = rPropVal; } return aValues; diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index cc6177bbb154..b4107f5f15a6 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -175,7 +175,7 @@ Sequence< PropertyState > SAL_CALL SwXTextDefaults::getPropertyStates( const Seq const sal_Int32 nCount = rPropertyNames.getLength(); Sequence < PropertyState > aRet ( nCount ); - std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(), + std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> PropertyState { return getPropertyState(rName); }); return aRet; diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 1e04b4d8848d..4c096178bab4 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -872,7 +872,7 @@ uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createData uno::Reference<chart2::data::XLabeledDataSequence>* pOld_LDS = aOld_LDS.getArray(); sal_Int32 nNewCnt = 0; - for (sal_Int32 nIdx : aSequenceMapping) + for (sal_Int32 nIdx : std::as_const(aSequenceMapping)) { // check that index to be used is valid // and has not yet been used @@ -1233,7 +1233,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume // build value for 'SequenceMapping' uno::Sequence< sal_Int32 > aSortedMapping( aSequenceMapping ); - auto [begin, end] = toNonConstRange(aSortedMapping); + auto [begin, end] = asNonConstRange(aSortedMapping); std::sort(begin, end); bool bNeedSequenceMapping = false; for (sal_Int32 i = 0; i < aSequenceMapping.getLength(); ++i) @@ -2038,7 +2038,7 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData() uno::Sequence< OUString > vTextData(vCells.size()); std::transform(vCells.begin(), vCells.end(), - vTextData.begin(), + vTextData.getArray(), [] (decltype(vCells)::value_type& xCell) { return static_cast<SwXCell*>(xCell.get())->getString(); }); return vTextData; @@ -2051,7 +2051,7 @@ uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData() uno::Sequence< uno::Any > vAnyData(vCells.size()); std::transform(vCells.begin(), vCells.end(), - vAnyData.begin(), + vAnyData.getArray(), [] (decltype(vCells)::value_type& xCell) { return static_cast<SwXCell*>(xCell.get())->GetAny(); }); return vAnyData; @@ -2064,7 +2064,7 @@ uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData() uno::Sequence< double > vNumData(vCells.size()); std::transform(vCells.begin(), vCells.end(), - vNumData.begin(), + vNumData.getArray(), [] (decltype(vCells)::value_type& xCell) { return static_cast<SwXCell*>(xCell.get())->GetForcedNumericalValue(); }); return vNumData; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 56111d9817ef..4d04857e7199 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2647,9 +2647,9 @@ css::drawing::PolyPolygonBezierCoords SwXShape::ConvertPolyPolygonBezierToLayout const basegfx::B2DHomMatrix aMatrix(basegfx::utils::createTranslateB2DHomMatrix( aTranslateDiff.X, aTranslateDiff.Y)); - for(drawing::PointSequence& rInnerSequence : aConvertedPath.Coordinates) + for(drawing::PointSequence& rInnerSequence : asNonConstRange(aConvertedPath.Coordinates)) { - for(awt::Point& rPoint : rInnerSequence) + for(awt::Point& rPoint : asNonConstRange(rInnerSequence)) { basegfx::B2DPoint aNewCoordinatePair(rPoint.X, rPoint.Y); aNewCoordinatePair *= aMatrix; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index a68a3b167b85..729a2581075a 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -825,7 +825,7 @@ SwXFieldMaster::getPropertyValue(const OUString& rPropertyName) std::vector<SwFormatField*> vpFields; pType->GatherFields(vpFields); uno::Sequence<uno::Reference <text::XDependentTextField> > aSeq(vpFields.size()); - std::transform(vpFields.begin(), vpFields.end(), aSeq.begin(), + std::transform(vpFields.begin(), vpFields.end(), aSeq.getArray(), [this](SwFormatField* pF) { return uno::Reference<text::XDependentTextField>(SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pF), uno::UNO_QUERY); }); aRet <<= aSeq; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index dd540870d8c3..dd6de80c47af 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()); - auto [pStates, end] = toNonConstRange(aStates); + auto [pStates, end] = asNonConstRange(aStates); SwFrameFormat* pFormat = GetFrameFormat(); if(pFormat) { diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index f56fd117c395..4e4c95b177d2 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -50,7 +50,7 @@ GetSupportedServiceNamesImpl( { uno::Sequence< OUString > ret(static_cast<sal_Int32>(nServices)); - std::transform(pServices, pServices + nServices, ret.begin(), + std::transform(pServices, pServices + nServices, ret.getArray(), [](const char* pService) -> OUString { return OUString::createFromAscii(pService); }); return ret; diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index c5e28f738dbb..0f12e6f84c6c 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -2238,7 +2238,7 @@ SwXTextCursor::getPropertyValues( const uno::Sequence< OUString >& aPropertyName { // a banal implementation for now uno::Sequence< uno::Any > aValues( aPropertyNames.getLength() ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.getArray(), [this](const OUString& rName) -> uno::Any { return getPropertyValue( rName ); }); return aValues; } diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 326f8cc2a6ea..ea35d6140ed6 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -711,7 +711,7 @@ SwXParagraph::getPropertyValuesTolerant( // copy temporary result to final result type const sal_Int32 nLen = aTmpRes.getLength(); uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen ); - std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.begin()); + std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.getArray()); return aRes; } diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index a76af4e240fc..1e3ec60182e1 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -554,7 +554,7 @@ uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXTextPortion::getPr // copy temporary result to final result type sal_Int32 nLen = aTmpRes.getLength(); uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen ); - std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.begin()); + std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.getArray()); return aRes; } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a0de46793064..2401c17322cd 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -510,7 +510,7 @@ uno::Sequence< OUString > SwXStyleFamilies::getElementNames() auto pEntries(lcl_GetStyleFamilyEntries()); uno::Sequence<OUString> aNames(pEntries->size()); std::transform(pEntries->begin(), pEntries->end(), - aNames.begin(), [] (const StyleFamilyEntry& e) { return e.m_sName; }); + aNames.getArray(), [] (const StyleFamilyEntry& e) { return e.m_sName; }); return aNames; } @@ -2257,7 +2257,7 @@ uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(const SfxItemP static_assert(COND_COMMAND_COUNT == 28, "invalid size of command count?"); uno::Sequence<beans::NamedValue> aSeq(COND_COMMAND_COUNT); sal_uInt16 nIndex = 0; - for(auto& rNV : aSeq) + for(auto& rNV : asNonConstRange(aSeq)) { rNV.Name = GetCommandContextByIndex(nIndex++); rNV.Value <<= OUString(); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 5c8f9ae31ba8..cb370088e713 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3562,10 +3562,10 @@ uno::Sequence<uno::Sequence<uno::Any>> SAL_CALL SwXCellRange::getDataArray() uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount); auto vCells(GetCells()); auto pCurrentCell(vCells.begin()); - for(auto& rRow : aRowSeq) + for(auto& rRow : asNonConstRange(aRowSeq)) { rRow = uno::Sequence< uno::Any >(nColCount); - for(auto& rCellAny : rRow) + for(auto& rCellAny : asNonConstRange(rRow)) { auto pCell(static_cast<SwXCell*>(pCurrentCell->get())); if(!pCell) @@ -3631,10 +3631,10 @@ SwXCellRange::getData() uno::Sequence< uno::Sequence< double > > vRows(nRowCount); auto vCells(GetCells()); auto pCurrentCell(vCells.begin()); - for(auto& rRow : vRows) + for(auto& rRow : asNonConstRange(vRows)) { rRow = uno::Sequence<double>(nColCount); - for(auto& rValue : rRow) + for(auto& rValue : asNonConstRange(rRow)) { if(!(*pCurrentCell)) throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); @@ -3710,7 +3710,7 @@ SwXCellRange::Impl::GetLabelDescriptions(SwXCellRange & rThis, bool bRow) auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom)); auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells()); uno::Sequence<OUString> vResult(vCells.size()); - std::transform(vCells.begin(), vCells.end(), vResult.begin(), + std::transform(vCells.begin(), vCells.end(), vResult.getArray(), [](uno::Reference<table::XCell> xCell) -> OUString { return uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString(); }); return vResult; } diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 73d720e9ed79..f8bf63264e62 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -302,7 +302,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr) if ( pFieldmark != nullptr ) { uno::Sequence< OUString > vListEntries(aFormula.maListEntries.size()); - std::copy(aFormula.maListEntries.begin(), aFormula.maListEntries.end(), vListEntries.begin()); + std::copy(aFormula.maListEntries.begin(), aFormula.maListEntries.end(), vListEntries.getArray()); (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] <<= vListEntries; sal_Int32 nIndex = aFormula.mfDropdownIndex < aFormula.maListEntries.size() ? aFormula.mfDropdownIndex : 0; (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] <<= nIndex; diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 1bbee52b77aa..a1f9625c6936 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -558,8 +558,9 @@ bool SwXMLWriter::WriteThroughComponent( // prepare arguments (prepend doc handler to given arguments) Sequence<Any> aArgs( 1 + rArguments.getLength() ); - aArgs[0] <<= xSaxWriter; - std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin())); + auto pArgs = aArgs.getArray(); + *pArgs <<= xSaxWriter; + std::copy(rArguments.begin(), rArguments.end(), std::next(pArgs)); // get filter component uno::Reference< document::XExporter > xExporter( diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index 2a902d85a2b0..45875291acff 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -362,7 +362,7 @@ const uno::Sequence< OUString >& SwSelectAddressBlockDialog::GetAddressBlocks if(nSelect) { uno::Sequence< OUString >aTemp(m_aAddressBlocks.getLength()); - auto it = aTemp.begin(); + auto it = aTemp.getArray(); *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); diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index 63a05e81bd7b..a2e899a77910 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -528,7 +528,7 @@ bool SwMailMergeDlg::ExecQryShell() uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY); pImpl->xSelSupp->getSelection() >>= m_aSelection; if ( xRowLocate.is() ) { - for (Any& rRow : m_aSelection) { + for (Any& rRow : asNonConstRange(m_aSelection)) { if ( xRowLocate->moveToBookmark(rRow) ) rRow <<= xRes->getRow(); } diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx index 846c8c999304..931890a9848f 100644 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ b/sw/source/ui/vba/vbadocumentproperties.cxx @@ -338,7 +338,7 @@ public: uno::Sequence< beans::NamedValue > stats( m_xDocProps->getDocumentStatistics()); - auto [begin, end] = toNonConstRange(stats); + auto [begin, end] = asNonConstRange(stats); auto pStat = std::find_if(begin, end, [&rPropName](const beans::NamedValue& rStat) { return rPropName == rStat.Name; }); if (pStat != end) @@ -841,7 +841,7 @@ public: { const uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties(); uno::Sequence< OUString > aNames( aProps.getLength() ); - std::transform(aProps.begin(), aProps.end(), aNames.begin(), + std::transform(aProps.begin(), aProps.end(), aNames.getArray(), [](const beans::Property& rProp) -> OUString { return rProp.Name; }); return aNames; } diff --git a/sw/source/ui/vba/vbafilterpropsfromformat.hxx b/sw/source/ui/vba/vbafilterpropsfromformat.hxx index dbf07b155955..cde1da0b4dc0 100644 --- a/sw/source/ui/vba/vbafilterpropsfromformat.hxx +++ b/sw/source/ui/vba/vbafilterpropsfromformat.hxx @@ -31,7 +31,7 @@ namespace inline bool setFilterPropsFromFormat(sal_Int32 nFormat, css::uno::Sequence<css::beans::PropertyValue>& rProps) { - auto[begin, end] = toNonConstRange(rProps); + auto[begin, end] = asNonConstRange(rProps); auto pProp = std::find_if(begin, end, [](const css::beans::PropertyValue& rProp) { return rProp.Name == "FilterName"; }); diff --git a/sw/source/ui/vba/vbatabstops.cxx b/sw/source/ui/vba/vbatabstops.cxx index 0046814305d9..b790db76805b 100644 --- a/sw/source/ui/vba/vbatabstops.cxx +++ b/sw/source/ui/vba/vbatabstops.cxx @@ -202,7 +202,7 @@ 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); + auto [begin, end] = asNonConstRange(aOldTabs); style::TabStop* pOldTab = std::find_if(begin, end, [nPosition](const style::TabStop& rTab) { return rTab.Position == nPosition; }); @@ -217,7 +217,7 @@ uno::Reference< word::XTabStop > SAL_CALL SwVbaTabStops::Add( float Position, co sal_Int32 nTabs = aOldTabs.getLength(); uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 ); - auto it = aNewTabs.begin(); + auto it = aNewTabs.getArray(); *it = aTab; std::copy(begin, end, std::next(it)); lcl_setTabStops( mxParaProps, aNewTabs ); diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx index 0af160098e08..941df07e1ec7 100644 --- a/sw/source/uibase/dbui/dbtree.cxx +++ b/sw/source/uibase/dbui/dbtree.cxx @@ -150,7 +150,7 @@ void SwDBTreeList::InitTreeList() auto const sort = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale()); - auto [begin, end] = toNonConstRange(aDBNames); + auto [begin, end] = asNonConstRange(aDBNames); std::sort( begin, end, [&sort](OUString const & x, OUString const & y) diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index 4dd6d7e0a5c4..36986ba59f5e 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -333,7 +333,7 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() : if(m_aSavedDocuments.hasElements()) { uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength()); - auto begin = aTempDocuments.begin(); + auto begin = aTempDocuments.getArray(); 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(begin, pTempDocuments)); @@ -585,7 +585,7 @@ Sequence< OUString> SwMailMergeConfigItem_Impl::GetAddressBlocks( bool bConvertToConfig) const { Sequence< OUString> aRet(m_aAddressBlocks.size()); - std::transform(m_aAddressBlocks.begin(), m_aAddressBlocks.end(), aRet.begin(), + std::transform(m_aAddressBlocks.begin(), m_aAddressBlocks.end(), aRet.getArray(), [this, bConvertToConfig](const OUString& rBlock) -> OUString { OUString sBlock = rBlock; if(bConvertToConfig) @@ -619,7 +619,7 @@ Sequence< OUString> SwMailMergeConfigItem_Impl::GetGreetings( eType == SwMailMergeConfigItem::MALE ? m_aMaleGreetingLines : m_aNeutralGreetingLines; Sequence< OUString> aRet(rGreetings.size()); - std::transform(rGreetings.begin(), rGreetings.end(), aRet.begin(), + std::transform(rGreetings.begin(), rGreetings.end(), aRet.getArray(), [this, bConvertToConfig](const OUString& rGreeting) -> OUString { OUString sGreeting = rGreeting; if(bConvertToConfig) diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 634bedb8c1c0..013c65198f1f 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -738,7 +738,7 @@ OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId { if (m_xNumberingInfo.is()) { - Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes(); + const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes(); sal_Int32 nOffset = aSwFields[nPos].nFormatLength; sal_uInt32 nValidEntry = 0; for (const sal_Int16 nCurrent : aTypes) @@ -818,7 +818,7 @@ sal_uInt16 SwFieldMgr::GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatI } else if (m_xNumberingInfo.is()) { - Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes(); + const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes(); sal_Int32 nOffset = aSwFields[nPos].nFormatLength; sal_Int32 nValidEntry = 0; for (const sal_Int16 nCurrent : aTypes) diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx index 5f4c45bb8dfc..94a26bcb9ffc 100644 --- a/sw/source/uibase/misc/numberingtypelistbox.cxx +++ b/sw/source/uibase/misc/numberingtypelistbox.cxx @@ -101,7 +101,7 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags) if (!(nTypeFlags & SwInsertNumTypes::Extended)) return; - for (sal_Int16 nCurrent : aTypes) + for (sal_Int16 nCurrent : std::as_const(aTypes)) { if (nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N) { diff --git a/sw/source/uibase/uno/unodispatch.cxx b/sw/source/uibase/uno/unodispatch.cxx index d185f982ccfc..e21810038ccc 100644 --- a/sw/source/uibase/uno/unodispatch.cxx +++ b/sw/source/uibase/uno/unodispatch.cxx @@ -105,7 +105,7 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SwXDispatchProviderIntercept { DispatchMutexLock_Impl aLock; uno::Sequence< uno::Reference< frame::XDispatch> > aReturn(aDescripts.getLength()); - std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return aReturn; diff --git a/sw/source/uibase/uno/unomodule.cxx b/sw/source/uibase/uno/unomodule.cxx index a64f1951e0f5..da821aece71a 100644 --- a/sw/source/uibase/uno/unomodule.cxx +++ b/sw/source/uibase/uno/unomodule.cxx @@ -107,7 +107,7 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SwUnoModule::queryD sal_Int32 nCount = seqDescripts.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); - std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(), [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference< frame::XDispatch > { return queryDispatch( rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags ); }); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 2f2189456f3e..f74d07f0398c 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -2210,7 +2210,7 @@ Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Seq const sal_Int32 nCount = rPropertyNames.getLength(); Sequence < PropertyState > aRet ( nCount ); - std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(), + std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> PropertyState { return getPropertyState(rName); }); return aRet; @@ -4103,7 +4103,7 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames() { const Sequence< OUString > aOrg = m_xRealAccess->getElementNames(); aRet.realloc(aOrg.getLength()); - std::transform(aOrg.begin(), aOrg.end(), aRet.begin(), + std::transform(aOrg.begin(), aOrg.end(), aRet.getArray(), [this](const OUString& rOrg) -> OUString { return rOrg + m_sLinkSuffix; }); } return aRet; diff --git a/test/source/sheet/databaseimportdescriptor.cxx b/test/source/sheet/databaseimportdescriptor.cxx index ea17b871b734..132f88817f8d 100644 --- a/test/source/sheet/databaseimportdescriptor.cxx +++ b/test/source/sheet/databaseimportdescriptor.cxx @@ -30,7 +30,7 @@ void DatabaseImportDescriptor::testDatabaseImportDescriptorProperties() uno::Reference<util::XImportable> xImportable(getXImportable(), UNO_QUERY_THROW); uno::Sequence<beans::PropertyValue> aPropValues = xImportable->createImportDescriptor(true); - for (auto& rPropValue : aPropValues) + for (auto& rPropValue : asNonConstRange(aPropValues)) { uno::Any aOldValue; uno::Any aNewValue; diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx index c99c74dfb6c1..96599f3089bb 100644 --- a/toolkit/source/controls/controlmodelcontainerbase.cxx +++ b/toolkit/source/controls/controlmodelcontainerbase.cxx @@ -1471,7 +1471,7 @@ void ControlContainerBase::setDesignMode( sal_Bool bOn ) UnoControl::setDesignMode( bOn ); Sequence< Reference< XControl > > xCtrls = getControls(); - for ( Reference< XControl >& rControl : xCtrls ) + for ( Reference< XControl >& rControl : asNonConstRange(xCtrls) ) rControl->setDesignMode( bOn ); // #109067# in design mode the tab controller is not notified about diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx index ad738a24c00c..c201d9b15918 100644 --- a/toolkit/source/controls/geometrycontrolmodel.cxx +++ b/toolkit/source/controls/geometrycontrolmodel.cxx @@ -522,7 +522,7 @@ 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); + auto [begin, end] = asNonConstRange(aAggregateProps); ::std::sort( begin, end, diff --git a/toolkit/source/controls/stdtabcontroller.cxx b/toolkit/source/controls/stdtabcontroller.cxx index 1f9a3955770a..54d8a6a93782 100644 --- a/toolkit/source/controls/stdtabcontroller.cxx +++ b/toolkit/source/controls/stdtabcontroller.cxx @@ -218,7 +218,7 @@ Sequence< Reference< XControl > > StdTabController::getControls( ) sal_Int32 nCtrls = aModels.getLength(); aSeq = Sequence< Reference< XControl > >( nCtrls ); - std::transform(aModels.begin(), aModels.end(), aSeq.begin(), + std::transform(aModels.begin(), aModels.end(), aSeq.getArray(), [&xCtrls](const Reference< XControlModel >& xCtrlModel) -> Reference< XControl > { return FindControl( xCtrls, xCtrlModel ); }); } @@ -284,7 +284,7 @@ void StdTabController::autoTabOrder( ) } Sequence< Reference< XControlModel > > aNewSeq( nCtrls ); - std::transform(aCtrls.begin(), aCtrls.end(), aNewSeq.begin(), + std::transform(aCtrls.begin(), aCtrls.end(), aNewSeq.getArray(), [](const ComponentEntry& rEntry) -> Reference< XControlModel > { Reference< XControl > xUC( rEntry.pComponent, UNO_QUERY ); return xUC->getModel(); diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 91b8dd756aa6..251c6261c8d4 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -86,7 +86,7 @@ static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiProp const Sequence< Property> aProps = xPSInf->getProperties(); sal_Int32 nLen = aProps.getLength(); aNames = Sequence< OUString>( nLen ); - std::transform(aProps.begin(), aProps.end(), aNames.begin(), + std::transform(aProps.begin(), aProps.end(), aNames.getArray(), [](const Property& rProp) -> OUString { return rProp.Name; }); } return aNames; @@ -278,7 +278,7 @@ void UnoControl::ImplSetPeerProperty( const OUString& rPropName, const Any& rVal } else if ( aConvertedValue >>= aSeqValue ) { - for ( auto& rValue : aSeqValue ) + for ( auto& rValue : asNonConstRange(aSeqValue) ) ImplCheckLocalize( rValue ); aConvertedValue <<= aSeqValue; } diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx index 30854ba16a6f..ae48bbe3c859 100644 --- a/toolkit/source/controls/unocontrolcontainer.cxx +++ b/toolkit/source/controls/unocontrolcontainer.cxx @@ -382,7 +382,7 @@ UnoControlContainer::~UnoControlContainer() void UnoControlContainer::ImplActivateTabControllers() { - for ( auto& rTabController : maTabControllers ) + for ( auto& rTabController : asNonConstRange(maTabControllers) ) { rTabController->setContainer( this ); rTabController->activateTabOrder(); @@ -750,7 +750,7 @@ void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxT } uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls(); - for( auto& rCtrl : aCtrls ) + for( auto& rCtrl : asNonConstRange(aCtrls) ) rCtrl->createPeer( rxToolkit, getPeer() ); uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY ); diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index 9f62a1ebc241..0bb8ca566368 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -496,7 +496,7 @@ css::uno::Sequence< css::beans::PropertyState > UnoControlModel::getPropertyStat css::uno::Sequence< css::beans::PropertyState > aStates( nNames ); - std::transform(PropertyNames.begin(), PropertyNames.end(), aStates.begin(), + std::transform(PropertyNames.begin(), PropertyNames.end(), aStates.getArray(), [this](const OUString& rName) -> css::beans::PropertyState { return getPropertyState(rName); }); return aStates; @@ -665,7 +665,7 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt rValue >>= aSeq; tools::Long nEntries = aSeq.getLength(); OutStream->writeLong( nEntries ); - for ( const auto nVal : aSeq ) + for ( const auto nVal : std::as_const(aSeq) ) OutStream->writeShort( nVal ); } else if ( rType == cppu::UnoType< css::uno::Sequence<sal_Int16> >::get() ) @@ -674,7 +674,7 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt rValue >>= aSeq; tools::Long nEntries = aSeq.getLength(); OutStream->writeLong( nEntries ); - for ( const auto nVal : aSeq ) + for ( const auto nVal : std::as_const(aSeq) ) OutStream->writeShort( nVal ); } else if ( rType.getTypeClass() == TypeClass_ENUM ) diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 02ecedeb0389..034be82a3d7c 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -2605,7 +2605,7 @@ void UnoListBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_In nPos = nOldLen; // Items before the Paste-Position - auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray()); // New Items it = std::copy(aItems.begin(), aItems.end(), it); @@ -2633,7 +2633,7 @@ void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) uno::Sequence< OUString> aNewSeq( nNewLen ); // Items before the Remove-Position - auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray()); // Rest of Items std::copy(std::next(std::cbegin(aSeq), nPos + nCount), std::cend(aSeq), it); @@ -3197,7 +3197,7 @@ void UnoComboBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_I nPos = nOldLen; // items before the insert position - auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray()); // New items it = std::copy(aItems.begin(), aItems.end(), it); @@ -3225,7 +3225,7 @@ void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) uno::Sequence< OUString> aNewSeq( nNewLen ); // items before the deletion position - auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin()); + auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray()); // remainder of old items std::copy(std::next(std::cbegin(aSeq), nPos + nCount), std::cend(aSeq), it); diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx index 8fbda792c435..3adfcc45a225 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_n(m_pMappedReminder->begin(), m_pMappedReminder->getLength(), false); + std::fill_n(m_pMappedReminder->getArray(), m_pMappedReminder->getLength(), false); } return *m_pMappedReminder; } diff --git a/ucb/source/cacher/dynamicresultsetwrapper.cxx b/ucb/source/cacher/dynamicresultsetwrapper.cxx index 12bac33b5f57..e465bbe6da0c 100644 --- a/ucb/source/cacher/dynamicresultsetwrapper.cxx +++ b/ucb/source/cacher/dynamicresultsetwrapper.cxx @@ -220,7 +220,7 @@ void DynamicResultSetWrapper::impl_notify( const ListEvent& Changes ) { osl::Guard< osl::Mutex > aGuard( m_aMutex ); - for( ListAction& rAction : aNewEvent.Changes ) + for( ListAction& rAction : asNonConstRange(aNewEvent.Changes) ) { if (m_bGotWelcome) break; diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 57dd60f998cb..202e0a07b169 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -182,7 +182,7 @@ namespace { uno::Sequence< OUString > seqValue; value >>= seqValue; - std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values), + std::transform(std::cbegin(seqValue), std::cend(seqValue), std::back_inserter(values), [](const OUString& rValue) -> std::string { return OUSTR_TO_STDSTR( rValue ); }); type = libcmis::PropertyType::String; } @@ -190,7 +190,7 @@ namespace { uno::Sequence< sal_Bool > seqValue; value >>= seqValue; - std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values), + std::transform(std::cbegin(seqValue), std::cend(seqValue), std::back_inserter(values), [](const bool nValue) -> std::string { return OUSTR_TO_STDSTR( OUString::boolean( nValue ) ); }); type = libcmis::PropertyType::Bool; } @@ -198,7 +198,7 @@ namespace { uno::Sequence< sal_Int64 > seqValue; value >>= seqValue; - std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values), + std::transform(std::cbegin(seqValue), std::cend(seqValue), std::back_inserter(values), [](const sal_Int64 nValue) -> std::string { return OUSTR_TO_STDSTR( OUString::number( nValue ) ); }); type = libcmis::PropertyType::Integer; } @@ -206,7 +206,7 @@ namespace { uno::Sequence< double > seqValue; value >>= seqValue; - std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values), + std::transform(std::cbegin(seqValue), std::cend(seqValue), std::back_inserter(values), [](const double fValue) -> std::string { return OUSTR_TO_STDSTR( OUString::number( fValue ) ); }); type = libcmis::PropertyType::Decimal; } @@ -214,7 +214,7 @@ namespace { uno::Sequence< util::DateTime > seqValue; value >>= seqValue; - std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values), + std::transform(std::cbegin(seqValue), std::cend(seqValue), std::back_inserter(values), [](const util::DateTime& rValue) -> std::string { OUStringBuffer aBuffer; ::sax::Converter::convertDateTime( aBuffer, rValue, nullptr ); diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index f1b50e46b009..fabbfda3129a 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -494,7 +494,7 @@ namespace ucb::ucp::ext aEvent.Further = false; aEvent.PropertyHandle = -1; - for ( auto& rRet : aRet ) + for ( auto& rRet : asNonConstRange(aRet) ) { // all our properties are read-only ... rRet <<= IllegalAccessException("property is read-only.", *this ); diff --git a/ucb/source/ucp/file/filnot.cxx b/ucb/source/ucp/file/filnot.cxx index 728d48eea6ec..dadeffdb9cde 100644 --- a/ucb/source/ucp/file/filnot.cxx +++ b/ucb/source/ucp/file/filnot.cxx @@ -204,7 +204,7 @@ void PropertyChangeNotifier::notifyPropertyChanged( { uno::Sequence< beans::PropertyChangeEvent > Changes = seqChanged; - for( auto& rChange : Changes ) + for( auto& rChange : asNonConstRange(Changes) ) rChange.Source = m_xCreatorContent; // notify listeners for all Events diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx index 6f465dab57ba..b17092d2c2f8 100644 --- a/ucb/source/ucp/file/filtask.cxx +++ b/ucb/source/ucp/file/filtask.cxx @@ -1096,7 +1096,7 @@ TaskManager::getv( sal_Int32 CommandId, PropertySet& propset = it->second.properties; - std::transform(properties.begin(), properties.end(), seq.begin(), + std::transform(properties.begin(), properties.end(), seq.getArray(), [&propset](const beans::Property& rProp) -> uno::Any { MyProperty readProp( rProp.Name ); auto it1 = propset.find( readProp ); @@ -2518,7 +2518,7 @@ TaskManager::getv( PropertySet& propset = it->second.properties; - std::transform(properties.begin(), properties.end(), seq.begin(), + std::transform(properties.begin(), properties.end(), seq.getArray(), [&propset](const beans::Property& rProp) -> uno::Any { MyProperty readProp( rProp.Name ); auto it1 = propset.find( readProp ); diff --git a/ucbhelper/source/provider/contentinfo.cxx b/ucbhelper/source/provider/contentinfo.cxx index c8f5da5aaa79..28be385ea215 100644 --- a/ucbhelper/source/provider/contentinfo.cxx +++ b/ucbhelper/source/provider/contentinfo.cxx @@ -107,7 +107,7 @@ uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties() m_xProps->realloc( nPos + nAddProps ); std::copy(rAddProps.begin(), rAddProps.end(), - std::next(m_xProps->begin(), nPos)); + std::next(m_xProps->getArray(), nPos)); } } } diff --git a/ucbhelper/source/provider/resultsetmetadata.cxx b/ucbhelper/source/provider/resultsetmetadata.cxx index ee3196d85426..ccd8a27587ce 100644 --- a/ucbhelper/source/provider/resultsetmetadata.cxx +++ b/ucbhelper/source/provider/resultsetmetadata.cxx @@ -286,7 +286,7 @@ sal_Int32 SAL_CALL ResultSetMetaData::getColumnType( sal_Int32 column ) const Sequence< Property > aProps = xInfo->getProperties(); - for ( Property& rProp : m_aProps ) + for ( Property& rProp : asNonConstRange(m_aProps) ) { auto pProp = std::find_if(aProps.begin(), aProps.end(), [&rProp](const Property& rProp1) { return rProp.Name == rProp1.Name; }); diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx index ed1d45fb984d..631c3ddbfb1d 100644 --- a/unotools/source/config/cmdoptions.cxx +++ b/unotools/source/config/cmdoptions.cxx @@ -281,7 +281,7 @@ Sequence< OUString > SvtCommandOptions_Impl::impl_GetPropertyNames() Sequence< OUString > lDisabledItems = GetNodeNames( SETNODE_DISABLED, utl::ConfigNameFormat::LocalPath ); // Expand all keys - for (OUString& rItem : toNonConstRange(lDisabledItems)) + for (OUString& rItem : asNonConstRange(lDisabledItems)) rItem = SETNODE_DISABLED PATHDELIMITER + rItem + PATHDELIMITER PROPERTYNAME_CMD; // Return result. diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index cf0384ad3651..37a5cd4d8cb0 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_n(lStates.begin(), lStates.getLength(), false); + std::fill_n(lStates.getArray(), 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(std::cbegin(_rNames), std::cend(_rNames), _rNames.begin(), + std::transform(std::cbegin(_rNames), std::cend(_rNames), _rNames.getArray(), [&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(std::cbegin(_rNames), std::cend(_rNames), _rNames.begin(), + std::transform(std::cbegin(_rNames), std::cend(_rNames), _rNames.getArray(), [](const OUString& rName) -> OUString { return wrapConfigurationElementName(rName); }); } } diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index f8bfb4c06418..b5669c7b485b 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(std::cbegin(aReturn), std::cend(aReturn), aReturn.begin(), + std::transform(std::cbegin(aReturn), std::cend(aReturn), aReturn.getArray(), [this](const OUString& rName) -> OUString { return normalizeName(rName, NO_CONFIGURATION); }); } catch(Exception&) diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx index 3b9232690fc2..b6d29f42fea4 100644 --- a/unotools/source/config/lingucfg.cxx +++ b/unotools/source/config/lingucfg.cxx @@ -976,7 +976,7 @@ bool SvtLinguConfig::GetDictionaryEntry( if (bSuccess) { // get file URL's for the locations - for (OUString& rLocation : aLocations) + for (OUString& rLocation : asNonConstRange(aLocations)) { if (!lcl_GetFileUrlFromOrigin( rLocation, rLocation )) bSuccess = false; diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx index 26bdb65e4638..35018b8b88c7 100644 --- a/unotools/source/config/moduleoptions.cxx +++ b/unotools/source/config/moduleoptions.cxx @@ -364,7 +364,7 @@ void SvtModuleOptions_Impl::ImplCommit() sBasePath = PATHSEPARATOR + rInfo.getFactory() + PATHSEPARATOR; const css::uno::Sequence< css::beans::PropertyValue > lChangedProperties = rInfo.getChangedProperties ( sBasePath ); - std::copy(lChangedProperties.begin(), lChangedProperties.end(), std::next(lCommitProperties.begin(), nRealCount)); + std::copy(lChangedProperties.begin(), lChangedProperties.end(), std::next(lCommitProperties.getArray(), nRealCount)); nRealCount += lChangedProperties.getLength(); } // Resize commit list to real size. @@ -738,7 +738,7 @@ void SvtModuleOptions_Impl::MakeReadonlyStatesAvailable() return; css::uno::Sequence< OUString > lFactories = GetNodeNames(OUString()); - for (OUString& rFactory : toNonConstRange(lFactories)) + for (OUString& rFactory : asNonConstRange(lFactories)) rFactory += PATHSEPARATOR PROPERTYNAME_DEFAULTFILTER; css::uno::Sequence< sal_Bool > lReadonlyStates = GetReadOnlyStates(lFactories); diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx index b20a45b4dbdc..4fff44a2051a 100644 --- a/unotools/source/config/viewoptions.cxx +++ b/unotools/source/config/viewoptions.cxx @@ -319,7 +319,7 @@ css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData() const sal_Int32 c = lNames.getLength(); css::uno::Sequence< css::beans::NamedValue > lUserData(c); - std::transform(lNames.begin(), lNames.end(), lUserData.begin(), + std::transform(lNames.begin(), lNames.end(), lUserData.getArray(), [&xUserData](const OUString& rName) -> css::beans::NamedValue { return { rName, xUserData->getByName(rName) }; }); diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index 782ae724c6f4..b2417c3ee3ae 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -1563,15 +1563,16 @@ void LocaleDataWrapper::loadDateAcceptancePatterns( } // Never overwrite the locale's full date pattern! The first. - if (aDateAcceptancePatterns[0] == rPatterns[0]) + if (std::as_const(aDateAcceptancePatterns)[0] == rPatterns[0]) aDateAcceptancePatterns = comphelper::containerToSequence(rPatterns); // sane else { // Copy existing full date pattern and append the sequence passed. /* TODO: could check for duplicates and shrink target sequence */ Sequence< OUString > aTmp( rPatterns.size() + 1 ); - aTmp[0] = aDateAcceptancePatterns[0]; - std::copy(rPatterns.begin(), rPatterns.end(), std::next(aTmp.begin())); + auto it = aTmp.getArray(); + *it = std::as_const(aDateAcceptancePatterns)[0]; + std::copy(rPatterns.begin(), rPatterns.end(), std::next(it)); aDateAcceptancePatterns = aTmp; } } diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx index 8f3ff6b45601..d8ea543bf4ca 100644 --- a/vbahelper/source/msforms/vbalistcontrolhelper.cxx +++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx @@ -125,7 +125,7 @@ ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargInde sList.realloc( sList.getLength() + 1 ); // point at first element to be overwritten - std::copy(sVec.begin(), sVec.end(), std::next(sList.begin(), nIndex)); + std::copy(sVec.begin(), sVec.end(), std::next(sList.getArray(), nIndex)); } m_xProps->setPropertyValue( "StringItemList", uno::makeAny( sList ) ); diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 2eaa7e9f5a38..9ed61ba32685 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -152,13 +152,12 @@ dispatchRequests (const uno::Reference< frame::XModel>& xModel, const OUString & uno::Reference<frame::XDispatch> xDispatcher = xDispatchProvider->queryDispatch(url,"",0); - uno::Sequence<beans::PropertyValue> dispatchProps(1); - sal_Int32 nProps = sProps.getLength(); + uno::Sequence<beans::PropertyValue> dispatchProps(nProps + 1); + if ( nProps ) { - dispatchProps.realloc( nProps + 1 ); - std::copy(sProps.begin(), sProps.end(), dispatchProps.begin()); + std::copy(sProps.begin(), sProps.end(), dispatchProps.getArray()); } if ( xDispatcher.is() ) @@ -734,7 +733,7 @@ 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 [begin, end] = toNonConstRange(aProp); + auto [begin, end] = asNonConstRange(aProp); auto pProp = std::find_if(begin, end, [&aName](const beans::PropertyValue& rProp) { return rProp.Name == aName; }); if (pProp != end) diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx index 9b50282ee8b0..10923d8704f2 100644 --- a/vcl/qa/cppunit/canvasbitmaptest.cxx +++ b/vcl/qa/cppunit/canvasbitmaptest.cxx @@ -499,7 +499,7 @@ private: { const uno::Sequence< rendering::ARGBColor > aTemp( convertIntegerToARGB(deviceColor) ); uno::Sequence< rendering::RGBColor > aRes( aTemp.getLength() ); - std::transform(aTemp.begin(), aTemp.end(), aRes.begin(), + std::transform(aTemp.begin(), aTemp.end(), aRes.getArray(), [](const rendering::ARGBColor& rColor) { return rendering::RGBColor(rColor.Red, rColor.Green, @@ -520,7 +520,7 @@ private: if( getPalette().is() ) { - std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(), + std::transform(deviceColor.begin(), deviceColor.end(), aRes.getArray(), [](sal_Int8 nIn) { auto fColor = vcl::unotools::toDoubleColor(nIn); return rendering::ARGBColor(1.0, fColor, fColor, fColor); @@ -554,7 +554,7 @@ private: if( getPalette().is() ) { - std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(), + std::transform(deviceColor.begin(), deviceColor.end(), aRes.getArray(), [](sal_Int8 nIn) { auto fColor = vcl::unotools::toDoubleColor(nIn); return rendering::ARGBColor(1.0, fColor, fColor, fColor); diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 9f5b6ced8808..ed639b524028 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -702,7 +702,7 @@ QAccessible::State QtAccessibleWidget::state() const if (!xStateSet.is()) return state; - Sequence<sal_Int16> aStates = xStateSet->getStates(); + const Sequence<sal_Int16> aStates = xStateSet->getStates(); for (const sal_Int16 nState : aStates) { diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 8bacefd777d8..24c1ccd66000 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1054,7 +1054,7 @@ ErrCode GraphicFilter::readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkTy { VectorGraphicDataArray aNewData(nMemoryLength); aMemStream.Seek(STREAM_SEEK_TO_BEGIN); - aMemStream.ReadBytes(aNewData.begin(), nMemoryLength); + aMemStream.ReadBytes(aNewData.getArray(), nMemoryLength); // Make a uncompressed copy for GfxLink rGraphicContentSize = nMemoryLength; @@ -1073,7 +1073,7 @@ ErrCode GraphicFilter::readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkTy else { VectorGraphicDataArray aNewData(nStreamLength); - rStream.ReadBytes(aNewData.begin(), nStreamLength); + rStream.ReadBytes(aNewData.getArray(), nStreamLength); if (!rStream.GetError()) { @@ -1125,7 +1125,7 @@ ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLi const sal_uInt32 nStreamLength(rStream.remainingSize()); VectorGraphicDataArray aNewData(nStreamLength); - rStream.ReadBytes(aNewData.begin(), nStreamLength); + rStream.ReadBytes(aNewData.getArray(), nStreamLength); if (!rStream.GetError()) { diff --git a/vcl/source/gdi/configsettings.cxx b/vcl/source/gdi/configsettings.cxx index 67e3b89ebfcc..5586f67a610a 100644 --- a/vcl/source/gdi/configsettings.cxx +++ b/vcl/source/gdi/configsettings.cxx @@ -95,7 +95,7 @@ void SettingsConfigItem::getValues() #endif const Sequence< OUString > aKeys( GetNodeNames( aKeyName ) ); Sequence< OUString > aSettingsKeys( aKeys.getLength() ); - std::transform(aKeys.begin(), aKeys.end(), aSettingsKeys.begin(), + std::transform(aKeys.begin(), aKeys.end(), aSettingsKeys.getArray(), [&aKeyName](const OUString& rKey) -> OUString { return aKeyName + "/" + rKey; }); const Sequence< Any > aValues( GetProperties( aSettingsKeys ) ); for( int i = 0; i < aValues.getLength(); i++ ) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 620a00f6e145..dc48e55efa94 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1456,7 +1456,7 @@ css::uno::Sequence< css::beans::PropertyValue > PrinterController::getJobPropert aMergeSet.insert( rPropVal.Name ); css::uno::Sequence< css::beans::PropertyValue > aResult( nResultLen ); - std::copy(i_rMergeList.begin(), i_rMergeList.end(), aResult.begin()); + std::copy(i_rMergeList.begin(), i_rMergeList.end(), aResult.getArray()); int nCur = i_rMergeList.getLength(); for(const css::beans::PropertyValue & rPropVal : mpImplData->maUIProperties) { diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index bf8f3b508ff6..3bf729d65418 100644 --- a/vcl/source/gdi/vectorgraphicdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -206,7 +206,7 @@ void VectorGraphicData::ensureSequenceAndRange() case VectorGraphicDataType::Svg: { css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize()); - std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin()); + std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.getArray()); const uno::Reference<io::XInputStream> xInputStream(new comphelper::SequenceInputStream(aDataSequence)); @@ -223,7 +223,7 @@ void VectorGraphicData::ensureSequenceAndRange() const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext); css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize()); - std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin()); + std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.getArray()); const uno::Reference<io::XInputStream> xInputStream(new comphelper::SequenceInputStream(aDataSequence)); uno::Sequence< ::beans::PropertyValue > aPropertySequence; @@ -336,11 +336,12 @@ VectorGraphicData::VectorGraphicData( if (nStmLen) { VectorGraphicDataArray aVectorGraphicDataArray(nStmLen); - rIStm.ReadBytes(aVectorGraphicDataArray.begin(), nStmLen); + auto pData = aVectorGraphicDataArray.getArray(); + rIStm.ReadBytes(pData, nStmLen); if (!rIStm.GetError()) { - maDataContainer = BinaryDataContainer(reinterpret_cast<const sal_uInt8*>(aVectorGraphicDataArray.begin()), aVectorGraphicDataArray.getLength()); + maDataContainer = BinaryDataContainer(reinterpret_cast<const sal_uInt8*>(pData), nStmLen); } } } diff --git a/vcl/source/graphic/UnoGraphic.cxx b/vcl/source/graphic/UnoGraphic.cxx index fde322d94b7e..e415de1523d3 100644 --- a/vcl/source/graphic/UnoGraphic.cxx +++ b/vcl/source/graphic/UnoGraphic.cxx @@ -102,7 +102,7 @@ uno::Sequence< OUString > SAL_CALL Graphic::getSupportedServiceNames() aRet.realloc( nOldCount + aNew.getLength() ); - std::copy(aNew.begin(), aNew.end(), std::next(aRet.begin(), nOldCount)); + std::copy(aNew.begin(), aNew.end(), std::next(aRet.getArray(), nOldCount)); return aRet; } diff --git a/vcl/source/uitest/uitest.cxx b/vcl/source/uitest/uitest.cxx index 1c5a989d67d8..f52e636f5081 100644 --- a/vcl/source/uitest/uitest.cxx +++ b/vcl/source/uitest/uitest.cxx @@ -39,7 +39,7 @@ bool UITest::executeCommandWithParameters(const OUString& rCommand, sal_uInt32 nIndex( lNewArgs.getLength() ); lNewArgs.realloc( lNewArgs.getLength()+rArgs.getLength() ); - std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.begin(), nIndex)); + std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.getArray(), nIndex)); } return comphelper::dispatchCommand(rCommand,lNewArgs); } diff --git a/vcl/unx/generic/dtrans/X11_transferable.cxx b/vcl/unx/generic/dtrans/X11_transferable.cxx index 1310f70bc234..a6ad1b4a15da 100644 --- a/vcl/unx/generic/dtrans/X11_transferable.cxx +++ b/vcl/unx/generic/dtrans/X11_transferable.cxx @@ -90,7 +90,7 @@ sal_Bool SAL_CALL X11Transferable::isDataFlavorSupported( const DataFlavor& aFla return false; } - Sequence< DataFlavor > aFlavors( getTransferDataFlavors() ); + const Sequence< DataFlavor > aFlavors( getTransferDataFlavors() ); return std::any_of(aFlavors.begin(), aFlavors.end(), [&aFlavor](const DataFlavor& rFlavor) { return aFlavor.MimeType.equalsIgnoreAsciiCase( rFlavor.MimeType ) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index c8e5ee0fb912..e333312bc8df 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -156,13 +156,13 @@ static void lcl_handleDropdownField( const uno::Reference< beans::XPropertySet > const FFDataHandler::DropDownEntries_t& rEntries = pFFDataHandler->getDropDownEntries(); uno::Sequence< OUString > sItems( rEntries.size() ); - ::std::copy( rEntries.begin(), rEntries.end(), sItems.begin()); + ::std::copy( rEntries.begin(), rEntries.end(), sItems.getArray()); if ( sItems.hasElements() ) rxFieldProps->setPropertyValue( "Items", uno::makeAny( sItems ) ); sal_Int32 nResult = pFFDataHandler->getDropDownResult().toInt32(); if (nResult > 0 && o3tl::make_unsigned(nResult) < sItems.size()) - rxFieldProps->setPropertyValue( "SelectedItem", uno::makeAny( sItems[ nResult ] ) ); + rxFieldProps->setPropertyValue( "SelectedItem", uno::makeAny( std::as_const(sItems)[ nResult ] ) ); if ( !pFFDataHandler->getHelpText().isEmpty() ) rxFieldProps->setPropertyValue( "Help", uno::makeAny( pFFDataHandler->getHelpText() ) ); } @@ -2381,7 +2381,7 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, const Proper uno::Sequence< beans::PropertyValue > aValues = pPropertyMap->GetPropertyValues(/*bCharGrabBag=*/!m_bIsInComments); if (m_bStartTOC || m_bStartIndex || m_bStartBibliography) - for( auto& rValue : aValues ) + for( auto& rValue : asNonConstRange(aValues) ) { if (rValue.Name == "CharHidden") rValue.Value <<= false; @@ -5235,7 +5235,7 @@ static uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( bool pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator; } //copy the 'old' entries except the last (page no) - std::copy(aLevel.begin(), std::prev(aLevel.end()), std::next(aNewLevel.begin())); + std::copy(aLevel.begin(), std::prev(aLevel.end()), std::next(pNewLevel)); //copy page no entry (last or last but one depending on bHyperlinks sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3); pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1]; diff --git a/xmlhelp/source/cxxhelp/provider/content.cxx b/xmlhelp/source/cxxhelp/provider/content.cxx index c1dd7486f4dc..f00b17b6277b 100644 --- a/xmlhelp/source/cxxhelp/provider/content.cxx +++ b/xmlhelp/source/cxxhelp/provider/content.cxx @@ -232,7 +232,7 @@ uno::Any SAL_CALL Content::execute( uno::Sequence< uno::Any > ret(propertyValues.getLength()); const uno::Sequence< beans::Property > props(getProperties(Environment)); // No properties can be set - std::transform(std::cbegin(propertyValues), std::cend(propertyValues), ret.begin(), + std::transform(std::cbegin(propertyValues), std::cend(propertyValues), ret.getArray(), [&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/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 372cd9cdaf9a..db8c7d6fc06e 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -701,7 +701,7 @@ uno::Sequence< OUString > lcl_DataSequenceToStringSequence( [](const OUString& rString) { return !rString.isEmpty(); }); if( bHasText ) { - auto [begin, end] = toNonConstRange(aValuesSequence); + auto [begin, end] = asNonConstRange(aValuesSequence); std::iota(begin, end, 1); } } @@ -3516,7 +3516,7 @@ void SchXMLExportHelper_Impl::exportDataPoints( } else { - for( sal_Int32 nCurrIndex : aDataPointSeq ) + for( sal_Int32 nCurrIndex : std::as_const(aDataPointSeq) ) { aPropertyStates.clear(); aDataLabelPropertyStates.clear(); diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index 6739bab69197..d706bb46c038 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -234,7 +234,7 @@ Reference< chart2::data::XLabeledDataSequence2 > lcl_createAndAddSequenceToSerie sal_Int32 nOldCount = aOldSeq.getLength(); Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 ); aNewSeq[0].set(xLabeledSeq, uno::UNO_QUERY_THROW); - std::copy(aOldSeq.begin(), aOldSeq.end(), std::next(aNewSeq.begin())); + std::copy(aOldSeq.begin(), aOldSeq.end(), std::next(aNewSeq.getArray())); xSeriesSink->setData( aNewSeq ); return xLabeledSeq; diff --git a/xmloff/source/core/PropertySetMerger.cxx b/xmloff/source/core/PropertySetMerger.cxx index bef82ea39923..7663aef638d3 100644 --- a/xmloff/source/core/PropertySetMerger.cxx +++ b/xmloff/source/core/PropertySetMerger.cxx @@ -157,7 +157,7 @@ Sequence< PropertyState > SAL_CALL PropertySetMergerImpl::getPropertyStates( con const sal_Int32 nCount = aPropertyName.getLength(); Sequence< PropertyState > aPropStates( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aPropStates.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aPropStates.getArray(), [this](const OUString& rPropName) -> PropertyState { return getPropertyState(rPropName); }); return aPropStates; diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 8cf4992340e1..f94fa160afd7 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -1062,7 +1062,7 @@ void FixZOrder(uno::Reference<drawing::XShapes> const& xShapes, return; // nothing to do } uno::Sequence<sal_Int32> aNewOrder(nCount); - auto iterInsert(aNewOrder.begin()); + auto iterInsert(aNewOrder.getArray()); for (auto const& rLayer : layers) { assert(rLayer.nMin <= rLayer.nMax); // empty layers have been removed @@ -1283,7 +1283,7 @@ void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape drawing::GluePoint2 aGluePoint; - uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() ); + const uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() ); for( const sal_Int32 nIdentifier : aIdSequence ) { diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index e4f4f6aed753..0bbc1d51b883 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(std::cbegin(aXMLValueList), std::cend(aXMLValueList), aPropertyValueList.begin(), + std::transform(std::cbegin(aXMLValueList), std::cend(aXMLValueList), aPropertyValueList.getArray(), [](const Any& rXMLValue) -> sal_Int16 { // only value sequences of numeric types implemented so far. double nVal( 0 ); diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index 91bf65072359..24f35dbed58a 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -93,7 +93,7 @@ namespace xmloff css::uno::Sequence<T> anySeq; bool bSuccess = value >>= anySeq; assert(bSuccess); (void)bSuccess; - for (T const & i : anySeq) + for (T const & i : std::as_const(anySeq)) { OUString sValue(implConvertAny(makeAny(i))); AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue ); diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 8d4a96058f40..01ac94d097f2 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -380,7 +380,7 @@ namespace if(!vListEntries.empty()) { Sequence<OUString> vListEntriesSeq(vListEntries.size()); - copy(vListEntries.begin(), vListEntries.end(), vListEntriesSeq.begin()); + copy(vListEntries.begin(), vListEntries.end(), vListEntriesSeq.getArray()); vOutParams[OUString(ODF_FORMDROPDOWN_LISTENTRY)] <<= vListEntriesSeq; } for(const auto& rCurrent : vOutParams) diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx index 2a6111ca6256..2a853c430646 100644 --- a/xmloff/source/transform/OOo2Oasis.cxx +++ b/xmloff/source/transform/OOo2Oasis.cxx @@ -1932,7 +1932,7 @@ void OOo2OasisTransformer::Initialize( { Sequence<Any> aArgs( 1 + rArguments.getLength() ); aArgs[0] <<= xFilter; - std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin())); + std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.getArray())); XMLTransformerBase::initialize( aArgs ); OSL_ENSURE( GetDocHandler() == xFilter, diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx index 5f1e6a1286e7..db3ac9b3d663 100644 --- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx +++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx @@ -124,7 +124,7 @@ bool PDFSigningTest::sign(const OUString& rInURL, const OUString& rOutURL, uno::Sequence<uno::Reference<security::XCertificate>> aCertificates = xSecurityEnvironment->getPersonalCertificates(); DateTime now(DateTime::SYSTEM); - for (auto& cert : aCertificates) + for (auto& cert : asNonConstRange(aCertificates)) { css::util::DateTime aNotValidAfter = cert->getNotValidAfter(); css::util::DateTime aNotValidBefore = cert->getNotValidBefore(); |