basctl/source/basicide/scriptdocument.cxx                          |    5 -
 chart2/qa/extras/chart2import.cxx                                  |    2 
 chart2/qa/extras/charttest.hxx                                     |    4 
 chart2/source/controller/dialogs/DialogModel.cxx                   |    2 
 chart2/source/controller/main/ObjectHierarchy.cxx                  |    2 
 chart2/source/model/template/ColumnLineChartTypeTemplate.cxx       |    2 
 chart2/source/tools/DataSeriesHelper.cxx                           |    2 
 chart2/source/tools/DataSourceHelper.cxx                           |    4 
 chart2/source/tools/DiagramHelper.cxx                              |    4 
 chart2/source/tools/InternalDataProvider.cxx                       |   10 --
 chart2/source/tools/UncachedDataSequence.cxx                       |    4 
 comphelper/qa/unit/base64_test.cxx                                 |   12 +-
 comphelper/source/property/opropertybag.cxx                        |   21 ++--
 comphelper/source/property/propertycontainerhelper.cxx             |   10 +-
 connectivity/source/commontools/ConnectionWrapper.cxx              |    3 
 connectivity/source/commontools/dbtools2.cxx                       |    6 -
 connectivity/source/drivers/jdbc/JStatement.cxx                    |    5 -
 connectivity/source/drivers/odbc/OStatement.cxx                    |    5 -
 connectivity/source/sdbcx/VDescriptor.cxx                          |    5 -
 cppuhelper/source/factory.cxx                                      |    2 
 dbaccess/source/core/dataaccess/ModelImpl.cxx                      |    2 
 dbaccess/source/core/dataaccess/connection.cxx                     |    2 
 dbaccess/source/core/dataaccess/databasedocument.cxx               |    5 -
 dbaccess/source/core/dataaccess/datasource.cxx                     |   10 +-
 dbaccess/source/ui/browser/unodatbr.cxx                            |    5 -
 dbaccess/source/ui/misc/UITools.cxx                                |    8 -
 dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx               |    5 -
 dbaccess/source/ui/querydesign/querycontroller.cxx                 |    5 -
 desktop/source/lib/init.cxx                                        |    4 
 desktop/source/lib/lokclipboard.cxx                                |    4 
 extensions/source/bibliography/formcontrolcontainer.cxx            |   17 ++-
 extensions/source/propctrlr/cellbindinghelper.cxx                  |   15 +--
 extensions/source/propctrlr/eformshelper.cxx                       |    6 -
 extensions/source/propctrlr/eventhandler.cxx                       |    4 
 extensions/source/propctrlr/formcomponenthandler.cxx               |    2 
 extensions/source/propctrlr/genericpropertyhandler.cxx             |    4 
 extensions/source/propctrlr/stringrepresentation.cxx               |    3 
 extensions/source/propctrlr/xsdvalidationhelper.cxx                |    9 +-
 forms/source/component/ListBox.cxx                                 |   14 +--
 forms/source/component/propertybaghelper.cxx                       |    2 
 forms/source/misc/InterfaceContainer.cxx                           |    3 
 framework/qa/cppunit/dispatchtest.cxx                              |    4 
 framework/source/services/autorecovery.cxx                         |    2 
 i18npool/qa/cppunit/test_ordinalsuffix.cxx                         |   38 
++------
 i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx  |    3 
 i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx      |    3 
 i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx   |    3 
 i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx |    3 
 i18npool/source/transliteration/transliterationImpl.cxx            |   34 
++-----
 i18npool/source/transliteration/transliteration_OneToOne.cxx       |    3 
 i18npool/source/transliteration/transliteration_body.cxx           |    5 -
 include/com/sun/star/uno/Sequence.h                                |   10 ++
 include/com/sun/star/uno/Sequence.hxx                              |   24 +++++
 include/vcl/FilterConfigItem.hxx                                   |    4 
 include/xmloff/XMLEventExport.hxx                                  |    2 
 oox/source/crypto/AgileEngine.cxx                                  |    2 
 oox/source/export/chartexport.cxx                                  |    4 
 oox/source/helper/zipstorage.cxx                                   |    3 
 oox/source/ole/olestorage.cxx                                      |    3 
 reportdesign/source/core/api/ReportDefinition.cxx                  |    2 
 sc/source/core/data/dptabsrc.cxx                                   |    2 
 sc/source/core/tool/addincol.cxx                                   |    4 
 sc/source/core/tool/rangeseq.cxx                                   |    2 
 sc/source/filter/xml/xmlcvali.cxx                                  |    4 
 sc/source/ui/Accessibility/AccessibleCell.cxx                      |    5 -
 sc/source/ui/miscdlgs/optsolver.cxx                                |   12 +-
 sc/source/ui/unoobj/dapiuno.cxx                                    |    6 -
 sc/source/ui/vba/vbaworkbook.cxx                                   |    5 -
 scripting/source/basprov/basmethnode.cxx                           |    2 
 scripting/source/provider/BrowseNodeFactoryImpl.cxx                |    2 
 scripting/source/provider/ProviderCache.cxx                        |    2 
 scripting/source/provider/URIHelper.cxx                            |    2 
 scripting/source/vbaevents/eventhelper.cxx                         |    2 
 sd/qa/unit/export-tests-ooxml3.cxx                                 |    4 
 sd/source/core/CustomAnimationEffect.cxx                           |   45 
+++++-----
 sd/source/core/CustomAnimationPreset.cxx                           |    2 
 sd/source/core/TransitionPreset.cxx                                |    2 
 sd/source/core/stlsheet.cxx                                        |    2 
 sd/source/filter/eppt/pptexanimations.cxx                          |    2 
 sd/source/filter/html/HtmlOptionsDialog.cxx                        |   13 +-
 sd/source/ui/framework/configuration/ResourceId.cxx                |    2 
 sd/source/ui/remotecontrol/Server.cxx                              |    2 
 sd/source/ui/view/ViewShellBase.cxx                                |    4 
 sdext/source/minimizer/fileopendialog.cxx                          |    4 
 sdext/source/presenter/PresenterScreen.cxx                         |    4 
 sdext/source/presenter/PresenterTheme.cxx                          |    2 
 sfx2/source/appl/appopen.cxx                                       |    8 -
 sfx2/source/appl/sfxhelp.cxx                                       |    4 
 sfx2/source/control/charmapcontrol.cxx                             |    8 -
 sfx2/source/devtools/ObjectInspectorTreeHandler.cxx                |    2 
 sfx2/source/dialog/filedlghelper.cxx                               |    2 
 sfx2/source/dialog/filtergrouping.cxx                              |    8 -
 sfx2/source/dialog/mailmodel.cxx                                   |    2 
 sfx2/source/doc/docfile.cxx                                        |    6 -
 sfx2/source/doc/docinsert.cxx                                      |    2 
 sfx2/source/doc/guisaveas.cxx                                      |    4 
 sfx2/source/doc/objmisc.cxx                                        |    2 
 sfx2/source/doc/objserv.cxx                                        |    2 
 sfx2/source/doc/objstor.cxx                                        |   12 +-
 sfx2/source/doc/sfxbasemodel.cxx                                   |   16 ++-
 sfx2/source/sidebar/ResourceManager.cxx                            |    2 
 starmath/source/mathml/mathmlexport.cxx                            |    4 
 stoc/source/implementationregistration/implreg.cxx                 |   21 ++--
 stoc/source/inspect/introspection.cxx                              |    4 
 stoc/source/invocation/invocation.cxx                              |    2 
 stoc/source/servicemanager/servicemanager.cxx                      |    6 -
 svl/source/config/asiancfg.cxx                                     |    2 
 svl/source/numbers/zforlist.cxx                                    |   26 ++---
 svl/source/numbers/zformat.cxx                                     |    2 
 svl/source/passwordcontainer/passwordcontainer.cxx                 |    2 
 svl/source/passwordcontainer/syscreds.cxx                          |    2 
 svtools/source/dialogs/addresstemplate.cxx                         |    4 
 svtools/source/filter/SvFilterOptionsDialog.cxx                    |    9 +-
 svtools/source/uno/unocontroltablemodel.cxx                        |    2 
 svx/source/accessibility/AccessibleShape.cxx                       |    4 
 svx/source/fmcomp/fmgridcl.cxx                                     |    8 -
 svx/source/fmcomp/fmgridif.cxx                                     |    2 
 svx/source/form/fmshimp.cxx                                        |    2 
 svx/source/form/fmsrcimp.cxx                                       |    2 
 svx/source/form/fmtextcontrolshell.cxx                             |    2 
 svx/source/form/formcontrolfactory.cxx                             |    2 
 svx/source/form/formcontroller.cxx                                 |   18 +---
 svx/source/items/customshapeitem.cxx                               |    6 -
 svx/source/table/accessiblecell.cxx                                |    2 
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx                         |    6 -
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx                         |    2 
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx                         |    4 
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx                         |    2 
 sw/qa/unit/swmodeltestbase.cxx                                     |    4 
 sw/source/core/access/accselectionhelper.cxx                       |    2 
 sw/source/core/edit/edlingu.cxx                                    |   10 +-
 sw/source/core/unocore/unochart.cxx                                |    9 +-
 sw/source/core/unocore/unocoll.cxx                                 |    2 
 sw/source/core/unocore/unoframe.cxx                                |    4 
 sw/source/core/unocore/unoparagraph.cxx                            |    2 
 sw/source/core/unocore/unoport.cxx                                 |    2 
 sw/source/filter/ww8/docxattributeoutput.cxx                       |   20 ++--
 sw/source/filter/ww8/docxexport.cxx                                |   16 +--
 sw/source/filter/ww8/docxsdrexport.cxx                             |   12 +-
 sw/source/filter/ww8/docxtablestyleexport.cxx                      |    4 
 sw/source/filter/ww8/wrtww8.cxx                                    |    3 
 sw/source/ui/dbui/mmaddressblockpage.cxx                           |    9 +-
 sw/source/ui/envelp/mailmrge.cxx                                   |    4 
 sw/source/ui/vba/vbadocumentproperties.cxx                         |    7 -
 sw/source/ui/vba/vbafilterpropsfromformat.hxx                      |   10 +-
 sw/source/ui/vba/vbastyles.cxx                                     |    2 
 sw/source/ui/vba/vbatabstops.cxx                                   |   10 +-
 sw/source/uibase/dbui/dbmgr.cxx                                    |    2 
 sw/source/uibase/dbui/dbtree.cxx                                   |    3 
 sw/source/uibase/dbui/mmconfigitem.cxx                             |    7 -
 sw/source/uibase/fldui/fldmgr.cxx                                  |    2 
 sw/source/uibase/misc/numberingtypelistbox.cxx                     |    3 
 sw/source/uibase/uno/unotxdoc.cxx                                  |    2 
 test/source/sheet/xdatapilottable2.cxx                             |    2 
 toolkit/source/controls/geometrycontrolmodel.cxx                   |   15 +--
 toolkit/source/controls/stdtabcontroller.cxx                       |    8 -
 toolkit/source/controls/unocontrol.cxx                             |    2 
 toolkit/source/controls/unocontrolcontainer.cxx                    |    6 -
 toolkit/source/controls/unocontrols.cxx                            |   28 
+++---
 toolkit/source/helper/formpdfexport.cxx                            |    4 
 ucb/source/cacher/cachedcontentresultset.cxx                       |    2 
 ucb/source/core/ucbcmds.cxx                                        |   16 +--
 ucb/source/core/ucbprops.cxx                                       |    4 
 ucb/source/ucp/file/filcmd.cxx                                     |   12 +-
 ucb/source/ucp/file/filprp.cxx                                     |    6 -
 ucb/source/ucp/file/filrset.cxx                                    |    6 -
 ucb/source/ucp/file/prov.cxx                                       |    6 -
 ucb/source/ucp/ftp/ftpcontent.cxx                                  |    2 
 ucb/source/ucp/ftp/ftpresultsetbase.cxx                            |    6 -
 ucb/source/ucp/webdav-neon/webdavcontent.cxx                       |    2 
 ucbhelper/source/provider/providerhelper.cxx                       |    2 
 ucbhelper/source/provider/resultsetmetadata.cxx                    |    2 
 unotools/source/config/cmdoptions.cxx                              |    5 -
 unotools/source/config/configitem.cxx                              |    6 -
 unotools/source/config/confignode.cxx                              |    2 
 unotools/source/config/moduleoptions.cxx                           |    8 -
 unotools/source/i18n/localedatawrapper.cxx                         |    4 
 uui/source/iahndl-filter.cxx                                       |    4 
 uui/source/iahndl-ssl.cxx                                          |    2 
 vbahelper/source/msforms/vbalistbox.cxx                            |    2 
 vbahelper/source/msforms/vbalistcontrolhelper.cxx                  |    2 
 vbahelper/source/vbahelper/vbacommandbarhelper.cxx                 |    2 
 vbahelper/source/vbahelper/vbacommandbars.cxx                      |    2 
 vbahelper/source/vbahelper/vbahelper.cxx                           |    5 -
 vcl/source/filter/FilterConfigItem.cxx                             |   12 +-
 vcl/source/filter/graphicfilter.cxx                                |    2 
 vcl/source/gdi/configsettings.cxx                                  |   12 +-
 vcl/source/graphic/UnoGraphic.cxx                                  |    2 
 vcl/source/helper/commandinfoprovider.cxx                          |    4 
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx           |    4 
 writerfilter/source/dmapper/DomainMapperTableHandler.hxx           |    2 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx                  |   12 +-
 writerfilter/source/dmapper/GraphicImport.cxx                      |    2 
 writerfilter/source/dmapper/NumberingManager.cxx                   |   10 --
 writerfilter/source/dmapper/PropertyMap.cxx                        |   10 +-
 writerfilter/source/dmapper/StyleSheetTable.cxx                    |    2 
 writerperfect/qa/unit/WpftLoader.cxx                               |    7 -
 xmlhelp/source/cxxhelp/provider/content.cxx                        |    4 
 xmlhelp/source/cxxhelp/provider/databases.cxx                      |    2 
 xmlhelp/source/cxxhelp/provider/resultsetbase.cxx                  |    6 -
 xmlhelp/source/treeview/tvread.cxx                                 |    2 
 xmloff/source/chart/SchXMLChartContext.cxx                         |    2 
 xmloff/source/chart/SchXMLExport.cxx                               |   23 ++---
 xmloff/source/chart/SchXMLImport.cxx                               |    2 
 xmloff/source/chart/SchXMLSeries2Context.cxx                       |    2 
 xmloff/source/chart/SchXMLSeriesHelper.cxx                         |    4 
 xmloff/source/draw/SignatureLineContext.cxx                        |    2 
 xmloff/source/forms/elementimport.cxx                              |    2 
 xmloff/source/forms/formcellbinding.cxx                            |    7 -
 xmloff/source/script/XMLEventExport.cxx                            |    2 
 xmloff/source/style/tabsthdl.cxx                                   |    2 
 xmloff/source/style/xmlnumfe.cxx                                   |    2 
 xmloff/source/table/XMLTableExport.cxx                             |    2 
 xmloff/source/text/XMLSectionExport.cxx                            |    4 
 xmloff/source/text/XMLTextNumRuleInfo.cxx                          |    4 
 xmloff/source/text/txtimp.cxx                                      |    4 
 xmloff/source/text/txtprhdl.cxx                                    |    4 
 xmlsecurity/qa/unit/signing/signing.cxx                            |    2 
 xmlsecurity/source/helper/documentsignaturehelper.cxx              |    4 
 xmlsecurity/source/helper/xmlsignaturehelper.cxx                   |    4 
 220 files changed, 653 insertions(+), 603 deletions(-)

New commits:
commit 8a017d25a62e878fdd32f189f0663b05d2ffb9cf
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Oct 13 09:02:48 2021 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Oct 14 06:00:49 2021 +0200

    Avoid COW overhead using css::uno::Sequence
    
    The scenarios are:
    
    1. Calling sequence's begin() and end() in pairs to pass to algorithms
       (both calls use getArray(), which does the COW checks)
    2. In addition to #1, calling end() again when checking result of find
       algorithms, and/or begin() to calculate result's distance
    3. Using non-const sequences in range-based for loops, which internally
       do #1
    4. Assigning sequence to another sequence variable, and then modifying
       one of them
    
    In many cases, the sequences could be made const, or treated as const
    for the purposes of the algorithms (using std::as_const, std::cbegin,
    and std::cend). Where algorithm modifies the sequence, it was changed
    to only call getArray() once. For that, css::uno::toNonConstRange was
    introduced, which returns a struct (sublclass of std::pair) with two
    iterators [begin, end], that are calculated using one call to begin()
    and one call to getLength().
    
    To handle #4, css::uno::Sequence::swap was introduced, that swaps the
    internal pointer to uno_Sequence. So when a local Sequence variable
    should be assigned to another variable, and the latter will be modified
    further, it's now possible to use swap instead, so the two sequences
    are kept independent.
    
    The modified places were found by temporarily removing non-const end().
    
    Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/basctl/source/basicide/scriptdocument.cxx 
b/basctl/source/basicide/scriptdocument.cxx
index 61c2747d5eb3..d0c37e89ef07 100644
--- a/basctl/source/basicide/scriptdocument.cxx
+++ b/basctl/source/basicide/scriptdocument.cxx
@@ -1213,7 +1213,8 @@ namespace basctl
         auto const sort = comphelper::string::NaturalStringSorter(
             comphelper::getProcessComponentContext(),
             Application::GetSettings().GetUILanguageTag().getLocale());
-        std::sort(aModuleNames.begin(), aModuleNames.end(),
+        auto [begin, end] = toNonConstRange(aModuleNames);
+        std::sort(begin, end,
                   [&sort](const OUString& rLHS, const OUString& rRHS) {
                       return sort.compare(rLHS, rRHS) < 0;
                   });
@@ -1227,7 +1228,7 @@ namespace basctl
 
         OUString aBaseName = _eType == E_SCRIPTS ? OUString("Module") : 
OUString("Dialog");
 
-        Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) );
+        const Sequence< OUString > aUsedNames( getObjectNames( _eType, 
_rLibName ) );
         std::set< OUString > aUsedNamesCheck( aUsedNames.begin(), 
aUsedNames.end() );
 
         bool bValid = false;
diff --git a/chart2/qa/extras/chart2import.cxx 
b/chart2/qa/extras/chart2import.cxx
index 682f24febca0..e908cfc57a71 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -2001,7 +2001,7 @@ void Chart2ImportTest::testTdf116163()
     CPPUNIT_ASSERT(xTextualDataSequence.is());
 
     std::vector<OUString> aCategories;
-    Sequence<OUString> aTextData(xTextualDataSequence->getTextualData());
+    const Sequence<OUString> aTextData(xTextualDataSequence->getTextualData());
     ::std::copy(aTextData.begin(), aTextData.end(),
         ::std::back_inserter(aCategories));
 
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 9094ab308afb..2aec79cfccb0 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -102,8 +102,8 @@ public:
 
 OUString findChartFile(const OUString& rDir, uno::Reference< 
container::XNameAccess > const & xNames )
 {
-    uno::Sequence<OUString> aNames = xNames->getElementNames();
-    OUString* pElement = std::find_if(aNames.begin(), aNames.end(), 
CheckForChartName(rDir));
+    const uno::Sequence<OUString> aNames = xNames->getElementNames();
+    const OUString* pElement = std::find_if(aNames.begin(), aNames.end(), 
CheckForChartName(rDir));
 
     CPPUNIT_ASSERT(pElement != aNames.end());
     return *pElement;
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index b88d1f205d5d..774e395e8951 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -473,7 +473,7 @@ std::vector< Reference< XDataSeriesContainer > >
             for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
             {
                 Reference< XChartTypeContainer > xCTCnt( coords, 
uno::UNO_QUERY_THROW );
-                Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
+                const Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
                 std::transform(
                     aChartTypeSeq.begin(), aChartTypeSeq.end(),
                     std::back_inserter( aResult ),
diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx 
b/chart2/source/controller/main/ObjectHierarchy.cxx
index 1383160e2c65..7934f58fc4d0 100644
--- a/chart2/source/controller/main/ObjectHierarchy.cxx
+++ b/chart2/source/controller/main/ObjectHierarchy.cxx
@@ -246,7 +246,7 @@ void ObjectHierarchy::createAxesTree(
 
     Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( 
xDiagram, /* bOnlyVisible = */ true ) );
     if( !m_bOrderingForElementSelector )
-        std::transform( aAxes.begin(), aAxes.end(),
+        std::transform( std::cbegin(aAxes), std::cend(aAxes),
                       std::back_inserter( rContainer ),
                       lcl_ObjectToOID( xChartDoc ));
 
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx 
b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
index 560332b81e98..889ca43f40e7 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -169,7 +169,7 @@ void ColumnLineChartTypeTemplate::createChartTypes(
     {
         Reference< lang::XMultiServiceFactory > xFact(
             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
-        Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( 
aSeriesSeq ));
+        const Sequence< Reference< XDataSeries > > aFlatSeriesSeq( 
FlattenSequence( aSeriesSeq ));
         sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength();
         sal_Int32 nNumberOfLines = 0;
         sal_Int32 nNumberOfColumns = 0;
diff --git a/chart2/source/tools/DataSeriesHelper.cxx 
b/chart2/source/tools/DataSeriesHelper.cxx
index 9f17273c1607..af3c16190633 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -246,7 +246,7 @@ getAllDataSequences( const 
uno::Sequence<uno::Reference<chart2::XDataSeries> >&
         Reference< chart2::data::XDataSource > xSource( dataSeries, 
uno::UNO_QUERY );
         if( xSource.is())
         {
-            Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( 
xSource->getDataSequences());
+            const Sequence< Reference< chart2::data::XLabeledDataSequence > > 
aSeq( xSource->getDataSequences());
             aSeqVec.insert( aSeqVec.end(), aSeq.begin(), aSeq.end() );
         }
     }
diff --git a/chart2/source/tools/DataSourceHelper.cxx 
b/chart2/source/tools/DataSourceHelper.cxx
index 7722da5e6e60..679b625948e0 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -301,7 +301,7 @@ uno::Reference< chart2::data::XDataSource > 
DataSourceHelper::getUsedData(
         uno::Reference< data::XDataSource > xDataSource(series, 
uno::UNO_QUERY);
         if( !xDataSource.is() )
             continue;
-        uno::Sequence< uno::Reference< data::XLabeledDataSequence > > 
aDataSequences( xDataSource->getDataSequences() );
+        const uno::Sequence< uno::Reference< data::XLabeledDataSequence > > 
aDataSequences( xDataSource->getDataSequences() );
         aResult.insert( aResult.end(), aDataSequences.begin(), 
aDataSequences.end() );
     }
 
@@ -325,7 +325,7 @@ uno::Reference< chart2::data::XDataSource > 
DataSourceHelper::getUsedData(
         uno::Reference< data::XDataSource > xDataSource(series, 
uno::UNO_QUERY);
         if( !xDataSource.is() )
             continue;
-        uno::Sequence< uno::Reference< data::XLabeledDataSequence > > 
aDataSequences( xDataSource->getDataSequences() );
+        const uno::Sequence< uno::Reference< data::XLabeledDataSequence > > 
aDataSequences( xDataSource->getDataSequences() );
         aResult.insert( aResult.end(), aDataSequences.begin(), 
aDataSequences.end() );
     }
 
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index ae6766aecaef..3a1d06bdcf24 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -672,7 +672,7 @@ std::vector< Reference< XDataSeries > >
             for( Reference< XChartType> const & chartType : aChartTypeSeq )
             {
                 Reference< XDataSeriesContainer > xDSCnt( chartType, 
uno::UNO_QUERY_THROW );
-                Sequence< Reference< XDataSeries > > aSeriesSeq( 
xDSCnt->getDataSeries() );
+                const Sequence< Reference< XDataSeries > > aSeriesSeq( 
xDSCnt->getDataSeries() );
                 aResult.insert( aResult.end(), aSeriesSeq.begin(), 
aSeriesSeq.end() );
             }
         }
@@ -1201,7 +1201,7 @@ Sequence< Reference< XChartType > >
             for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
             {
                 Reference< XChartTypeContainer > xCTCnt( coords, 
uno::UNO_QUERY_THROW );
-                Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
+                const Sequence< Reference< XChartType > > aChartTypeSeq( 
xCTCnt->getChartTypes());
                 aResult.insert( aResult.end(), aChartTypeSeq.begin(), 
aChartTypeSeq.end() );
             }
         }
diff --git a/chart2/source/tools/InternalDataProvider.cxx 
b/chart2/source/tools/InternalDataProvider.cxx
index ccbf8697c638..0323043dbff2 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -920,7 +920,7 @@ Sequence< uno::Any > SAL_CALL 
InternalDataProvider::getDataByRangeRepresentation
         else
         {
             // Maybe this 'else' part and the functions is not necessary 
anymore.
-            Sequence< OUString > aLabels = m_bDataInColumns ? 
getRowDescriptions() : getColumnDescriptions();
+            const Sequence< OUString > aLabels = m_bDataInColumns ? 
getRowDescriptions() : getColumnDescriptions();
             aResult.realloc( aLabels.getLength() );
             transform( aLabels.begin(), aLabels.end(),
                        aResult.getArray(), CommonFunctors::makeAny< OUString 
>() );
@@ -931,11 +931,9 @@ Sequence< uno::Any > SAL_CALL 
InternalDataProvider::getDataByRangeRepresentation
         sal_Int32 nIndex = aRange.toInt32();
         if( nIndex >= 0 )
         {
-            Sequence< double > aData;
-            if( m_bDataInColumns )
-                aData = m_aInternalData.getColumnValues(nIndex);
-            else
-                aData = m_aInternalData.getRowValues(nIndex);
+            const Sequence< double > aData = m_bDataInColumns
+                                                 ? 
m_aInternalData.getColumnValues(nIndex)
+                                                 : 
m_aInternalData.getRowValues(nIndex);
             if( aData.hasElements() )
             {
                 aResult.realloc( aData.getLength());
diff --git a/chart2/source/tools/UncachedDataSequence.cxx 
b/chart2/source/tools/UncachedDataSequence.cxx
index d10fa7da3f37..1c7394d22400 100644
--- a/chart2/source/tools/UncachedDataSequence.cxx
+++ b/chart2/source/tools/UncachedDataSequence.cxx
@@ -170,7 +170,7 @@ Sequence< double > SAL_CALL 
UncachedDataSequence::getNumericalData()
     MutexGuard aGuard( GetMutex() );
     if( m_xDataProvider.is())
     {
-        Sequence< uno::Any > aValues( 
m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
+        const Sequence< uno::Any > aValues( 
m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
         aResult.realloc( aValues.getLength());
         std::transform( aValues.begin(), aValues.end(),
                           aResult.getArray(), CommonFunctors::AnyToDouble());
@@ -185,7 +185,7 @@ Sequence< OUString > SAL_CALL 
UncachedDataSequence::getTextualData()
     MutexGuard aGuard( GetMutex() );
     if( m_xDataProvider.is())
     {
-        Sequence< uno::Any > aValues( 
m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
+        const Sequence< uno::Any > aValues( 
m_xDataProvider->getDataByRangeRepresentation( m_aSourceRepresentation ));
         aResult.realloc( aValues.getLength());
         std::transform( aValues.begin(), aValues.end(),
                           aResult.getArray(), CommonFunctors::AnyToString());
diff --git a/comphelper/qa/unit/base64_test.cxx 
b/comphelper/qa/unit/base64_test.cxx
index dd89951e6430..31e865a370a6 100644
--- a/comphelper/qa/unit/base64_test.cxx
+++ b/comphelper/qa/unit/base64_test.cxx
@@ -72,18 +72,18 @@ void Base64Test::testBase64Decode()
 
     uno::Sequence<sal_Int8> expectedSequence = { 0, 0, 0, 0, 0, 1, 2, 3 };
     comphelper::Base64::decode(decodedSequence, "AAAAAAABAgM=");
-    CPPUNIT_ASSERT(
-        std::equal(expectedSequence.begin(), expectedSequence.end(), 
decodedSequence.begin()));
+    CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), 
std::cend(expectedSequence),
+                              std::cbegin(decodedSequence)));
 
     expectedSequence = { 5, 2, 3, 0, 0, 1, 2, 3 };
     comphelper::Base64::decode(decodedSequence, "BQIDAAABAgM=");
-    CPPUNIT_ASSERT(
-        std::equal(expectedSequence.begin(), expectedSequence.end(), 
decodedSequence.begin()));
+    CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), 
std::cend(expectedSequence),
+                              std::cbegin(decodedSequence)));
 
     expectedSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 };
     comphelper::Base64::decode(decodedSequence, "yB9NbwABAgM=");
-    CPPUNIT_ASSERT(
-        std::equal(expectedSequence.begin(), expectedSequence.end(), 
decodedSequence.begin()));
+    CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), 
std::cend(expectedSequence),
+                              std::cbegin(decodedSequence)));
 }
 
 void Base64Test::testBase64EncodeForOStringBuffer()
diff --git a/comphelper/source/property/opropertybag.cxx 
b/comphelper/source/property/opropertybag.cxx
index 62dd474c962f..f84d509847eb 100644
--- a/comphelper/source/property/opropertybag.cxx
+++ b/comphelper/source/property/opropertybag.cxx
@@ -83,14 +83,14 @@ namespace comphelper
            && (_rArguments[1] >>= AllowEmptyPropertyName)
            && (_rArguments[2] >>= AutomaticAddition))
         {
-            m_aAllowedTypes.insert(aTypes.begin(), aTypes.end());
+            m_aAllowedTypes.insert(std::cbegin(aTypes), std::cend(aTypes));
             m_bAutoAddProperties = AutomaticAddition;
 
         } else {
             ::comphelper::NamedValueCollection aArguments( _rArguments );
 
             if ( aArguments.get_ensureType( "AllowedTypes", aTypes ) )
-                m_aAllowedTypes.insert( aTypes.begin(), aTypes.end());
+                m_aAllowedTypes.insert(std::cbegin(aTypes), std::cend(aTypes));
 
             aArguments.get_ensureType( "AutomaticAddition", 
m_bAutoAddProperties );
             aArguments.get_ensureType( "AllowEmptyPropertyName",
@@ -377,8 +377,8 @@ namespace comphelper
         // their names
         Sequence< OUString > aNames( aProperties.getLength() );
         std::transform(
-            aProperties.begin(),
-            aProperties.end(),
+            std::cbegin(aProperties),
+            std::cend(aProperties),
             aNames.getArray(),
             TransformPropertyToName< Property >()
         );
@@ -425,17 +425,18 @@ namespace comphelper
     {
         // sort (the XMultiPropertySet interface requires this)
         Sequence< PropertyValue > aProperties( _rProps );
+        auto [begin, end] = toNonConstRange(aProperties);
         std::sort(
-            aProperties.begin(),
-            aProperties.end(),
+            begin,
+            end,
             ComparePropertyValueByName()
         );
 
         // a sequence of names
         Sequence< OUString > aNames( aProperties.getLength() );
         std::transform(
-            aProperties.begin(),
-            aProperties.end(),
+            std::cbegin(aProperties),
+            std::cend(aProperties),
             aNames.getArray(),
             TransformPropertyToName< PropertyValue >()
         );
@@ -479,8 +480,8 @@ namespace comphelper
             // a sequence of values
             Sequence< Any > aValues( aProperties.getLength() );
             std::transform(
-                aProperties.begin(),
-                aProperties.end(),
+                std::cbegin(aProperties),
+                std::cend(aProperties),
                 aValues.getArray(),
                 ExtractPropertyValue()
             );
diff --git a/comphelper/source/property/propertycontainerhelper.cxx 
b/comphelper/source/property/propertycontainerhelper.cxx
index 1ba31ec8258f..73dcbd2e862b 100644
--- a/comphelper/source/property/propertycontainerhelper.cxx
+++ b/comphelper/source/property/propertycontainerhelper.cxx
@@ -469,15 +469,15 @@ void 
OPropertyContainerHelper::describeProperties(Sequence< Property >& _rProps)
     }
 
     // as our property vector is sorted by handles, not by name, we have to 
sort aOwnProps
-    std::sort(aOwnProps.begin(), aOwnProps.end(), PropertyCompareByName());
+    auto [begin, end] = toNonConstRange(aOwnProps);
+    std::sort(begin, end, PropertyCompareByName());
 
     // unfortunately the STL merge function does not allow the output range to 
overlap one of the input ranges,
     // so we need an extra sequence
-    Sequence< Property > aOutput;
-    aOutput.realloc(_rProps.getLength() + aOwnProps.getLength());
+    Sequence< Property > aOutput(_rProps.getLength() + aOwnProps.getLength());
     // do the merge
-    std::merge(   _rProps.begin(), _rProps.end(),       // input 1
-                  aOwnProps.begin(), aOwnProps.end(),   // input 2
+    std::merge(   std::cbegin(_rProps), std::cend(_rProps),       // input 1
+                  std::cbegin(aOwnProps), std::cend(aOwnProps),   // input 2
                   aOutput.getArray(),                   // output
                   PropertyCompareByName()               // compare operator
               );
diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx 
b/connectivity/source/commontools/ConnectionWrapper.cxx
index 264002e5dc57..252882067865 100644
--- a/connectivity/source/commontools/ConnectionWrapper.cxx
+++ b/connectivity/source/commontools/ConnectionWrapper.cxx
@@ -199,7 +199,8 @@ void OConnectionWrapper::createUniqueId( const OUString& 
_rURL
     if ( !_rPassword.isEmpty() )
         sha1.update(reinterpret_cast<unsigned char 
const*>(_rPassword.getStr()), _rPassword.getLength() * sizeof(sal_Unicode));
     // now we need to sort the properties
-    std::sort(_rInfo.begin(),_rInfo.end(),TPropertyValueLessFunctor());
+    auto [begin, end] = toNonConstRange(_rInfo);
+    std::sort(begin,end,TPropertyValueLessFunctor());
 
     for (PropertyValue const & prop : std::as_const(_rInfo))
     {
diff --git a/connectivity/source/commontools/dbtools2.cxx 
b/connectivity/source/commontools/dbtools2.cxx
index c0cefeaa1b13..0adfe23bdac9 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -637,11 +637,11 @@ bool isDataSourcePropertyEnabled(const 
Reference<XInterface>& _xProp, const OUSt
         {
             Sequence< PropertyValue > aInfo;
             xProp->getPropertyValue("Info") >>= aInfo;
-            const PropertyValue* pValue =std::find_if(aInfo.begin(),
-                                                aInfo.end(),
+            const PropertyValue* pValue =std::find_if(std::cbegin(aInfo),
+                                                std::cend(aInfo),
                                                 [&_sProperty](const 
PropertyValue& lhs)
                                                 { return lhs.Name == 
_sProperty; });
-            if ( pValue != aInfo.end() )
+            if ( pValue != std::cend(aInfo) )
                 pValue->Value >>= bEnabled;
         }
     }
diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx 
b/connectivity/source/drivers/jdbc/JStatement.cxx
index 40fef64ed5ac..da06ef77f2c3 100644
--- a/connectivity/source/drivers/jdbc/JStatement.cxx
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -124,9 +124,10 @@ Sequence< Type > SAL_CALL 
java_sql_Statement_Base::getTypes(  )
     Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
     if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
     {
-        auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(),
+        auto [begin, end] = toNonConstRange(aOldTypes);
+        auto newEnd = std::remove(begin, end,
                                   cppu::UnoType<XGeneratedResultSet>::get());
-        aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd));
+        aOldTypes.realloc(std::distance(begin, newEnd));
     }
 
     return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
diff --git a/connectivity/source/drivers/odbc/OStatement.cxx 
b/connectivity/source/drivers/odbc/OStatement.cxx
index c5d63ef771a8..13ffeda8e4ba 100644
--- a/connectivity/source/drivers/odbc/OStatement.cxx
+++ b/connectivity/source/drivers/odbc/OStatement.cxx
@@ -131,9 +131,10 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes(  )
     Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
     if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
     {
-        auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(),
+        auto [begin, end] = toNonConstRange(aOldTypes);
+        auto newEnd = std::remove(begin, end,
                                   cppu::UnoType<XGeneratedResultSet>::get());
-        aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd));
+        aOldTypes.realloc(std::distance(begin, newEnd));
     }
 
     return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
diff --git a/connectivity/source/sdbcx/VDescriptor.cxx 
b/connectivity/source/sdbcx/VDescriptor.cxx
index 9023a2076a74..2392e2d5f1d2 100644
--- a/connectivity/source/sdbcx/VDescriptor.cxx
+++ b/connectivity/source/sdbcx/VDescriptor.cxx
@@ -74,10 +74,11 @@ namespace connectivity::sdbcx
             Sequence< Property > aProperties;
             describeProperties( aProperties );
 
+            auto [begin, end] = toNonConstRange(aProperties);
             if ( isNew() )
-                std::for_each( aProperties.begin(), aProperties.end(), 
ResetROAttribute() );
+                std::for_each( begin, end, ResetROAttribute() );
             else
-                std::for_each( aProperties.begin(), aProperties.end(), 
SetROAttribute() );
+                std::for_each( begin, end, SetROAttribute() );
 
             return new ::cppu::OPropertyArrayHelper( aProperties );
         }
diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx
index 0cad2093070d..09535a15690f 100644
--- a/cppuhelper/source/factory.cxx
+++ b/cppuhelper/source/factory.cxx
@@ -773,7 +773,7 @@ Sequence< OUString > 
ORegistryFactoryHelper::getSupportedServiceNames()
 
                 // Full qualified names like 
"IMPLEMENTATIONS/TEST/UNO/SERVICES/com.sun.star..."
                 Sequence<OUString> seqKeys = xKey->getKeyNames();
-                for( OUString & key : seqKeys )
+                for( OUString & key : toNonConstRange(seqKeys) )
                     key = key.copy(nPrefixLen);
 
                 aServiceNames = seqKeys;
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx 
b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 8f993096fe95..c7a7238f3f97 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -1376,7 +1376,7 @@ bool 
ODatabaseModelImpl::hasTrustedScriptingSignature(bool bAllowUIToAddAuthor)
         uno::Reference<security::XDocumentDigitalSignatures> xSigner(
             security::DocumentDigitalSignatures::createWithVersion(
                 comphelper::getProcessComponentContext(), aODFVersion));
-        uno::Sequence<security::DocumentSignatureInformation> aInfo
+        const uno::Sequence<security::DocumentSignatureInformation> aInfo
             = xSigner->verifyScriptingContentSignatures(xStorage,
                                                         
uno::Reference<io::XInputStream>());
 
diff --git a/dbaccess/source/core/dataaccess/connection.cxx 
b/dbaccess/source/core/dataaccess/connection.cxx
index d5889255523e..15054023170e 100644
--- a/dbaccess/source/core/dataaccess/connection.cxx
+++ b/dbaccess/source/core/dataaccess/connection.cxx
@@ -750,7 +750,7 @@ void OConnection::impl_checkTableQueryNames_nothrow()
     try
     {
         Reference< XNameAccess > xTables( getTables() );
-        Sequence< OUString > aTableNames( xTables->getElementNames() );
+        const Sequence< OUString > aTableNames( xTables->getElementNames() );
         std::set< OUString > aSortedTableNames( aTableNames.begin(), 
aTableNames.end() );
 
         Reference< XNameAccess > xQueries( getQueries() );
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx 
b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 7fc1cb6eb254..e9867def1b99 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -223,11 +223,12 @@ Sequence< Type > SAL_CALL ODatabaseDocument::getTypes(  )
     // allowed to contain macros, too.
     if ( !m_bAllowDocumentScripting )
     {
-        auto newEnd = std::remove_if( aTypes.begin(), aTypes.end(),
+        auto [begin, end] = toNonConstRange(aTypes);
+        auto newEnd = std::remove_if( begin, end,
                                       [](const Type& t)
                                       { return t == 
cppu::UnoType<XEmbeddedScripts>::get() ||
                                                t == 
cppu::UnoType<XScriptInvocationContext>::get();} );
-        aTypes.realloc( std::distance(aTypes.begin(), newEnd) );
+        aTypes.realloc( std::distance(begin, newEnd) );
     }
 
     return aTypes;
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx 
b/dbaccess/source/core/dataaccess/datasource.cxx
index 4f499eccc263..48039c3e6943 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -1046,13 +1046,15 @@ void ODatabaseSource::getFastPropertyValue( Any& 
rValue, sal_Int32 nHandle ) con
                 // transform them so that only property values which fulfill 
certain
                 // criteria survive
                 Sequence< PropertyValue > aNonDefaultOrUserDefined( 
aValues.getLength() );
+                auto [begin, end] = toNonConstRange(aValues);
+                auto pCopyStart = aNonDefaultOrUserDefined.getArray();
                 const PropertyValue* pCopyEnd = std::remove_copy_if(
-                    aValues.begin(),
-                    aValues.end(),
-                    aNonDefaultOrUserDefined.getArray(),
+                    begin,
+                    end,
+                    pCopyStart,
                     IsDefaultAndNotRemoveable( aPropertyAttributes )
                 );
-                aNonDefaultOrUserDefined.realloc( pCopyEnd - 
aNonDefaultOrUserDefined.getArray() );
+                aNonDefaultOrUserDefined.realloc( pCopyEnd - pCopyStart );
                 rValue <<= aNonDefaultOrUserDefined;
             }
             catch( const Exception& )
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx 
b/dbaccess/source/ui/browser/unodatbr.cxx
index 43f084fec020..b6bf10274b8b 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -214,10 +214,11 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( 
 )
     OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did 
not initialize this, yet!" );
     if ( !m_aDocScriptSupport || !*m_aDocScriptSupport )
     {
-        auto newEnd = std::remove_if( aTypes.begin(), aTypes.end(),
+        auto [begin, end] = toNonConstRange(aTypes);
+        auto newEnd = std::remove_if( begin, end,
                                       [](const Type& type)
                                       { return type == 
cppu::UnoType<XScriptInvocationContext>::get(); } );
-        aTypes.realloc( std::distance(aTypes.begin(), newEnd) );
+        aTypes.realloc( std::distance(begin, newEnd) );
     }
     return aTypes;
 }
diff --git a/dbaccess/source/ui/misc/UITools.cxx 
b/dbaccess/source/ui/misc/UITools.cxx
index 4086e7b442f2..7c9a09cc8484 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -982,17 +982,17 @@ void fillAutoIncrementValue(const 
Reference<XPropertySet>& _xDatasource,
     _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo;
 
     // search the right propertyvalue
-    const PropertyValue* pValue =std::find_if(aInfo.begin(), aInfo.end(),
+    const PropertyValue* pValue =std::find_if(std::cbegin(aInfo), 
std::cend(aInfo),
                                         [](const PropertyValue& lhs)
                                         {return lhs.Name == 
PROPERTY_AUTOINCREMENTCREATION;} );
 
-    if ( pValue != aInfo.end() )
+    if ( pValue != std::cend(aInfo) )
         pValue->Value >>= _rsAutoIncrementValue;
-    pValue =std::find_if(aInfo.begin(), aInfo.end(),
+    pValue =std::find_if(std::cbegin(aInfo), std::cend(aInfo),
                          [](const PropertyValue& lhs)
                          {return lhs.Name == "IsAutoRetrievingEnabled";} );
 
-    if ( pValue != aInfo.end() )
+    if ( pValue != std::cend(aInfo) )
         pValue->Value >>= _rAutoIncrementValueEnabled;
 }
 
diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx 
b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
index 6a6784e92dcc..82ce80f71333 100644
--- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
+++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
@@ -222,10 +222,11 @@ namespace dbaui
         Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() );
         if ( !m_pImpl->documentHasScriptSupport() )
         {
-            auto newEnd = std::remove_if( aTypes.begin(), aTypes.end(),
+            auto [begin, end] = toNonConstRange(aTypes);
+            auto newEnd = std::remove_if( begin, end,
                                           [](const Type& type)
                                           { return type == 
cppu::UnoType<XScriptInvocationContext>::get(); } );
-            aTypes.realloc( std::distance(aTypes.begin(), newEnd) );
+            aTypes.realloc( std::distance(begin, newEnd) );
         }
         return aTypes;
     }
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx 
b/dbaccess/source/ui/querydesign/querycontroller.cxx
index 8070df7a5f90..4f7bd55bde1e 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -288,9 +288,10 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& 
o_rValue, sal_Int32 i
         PropertyAttribute::READONLY
     );
 
+    auto [begin, end] = toNonConstRange(aProps);
     std::sort(
-        aProps.begin(),
-        aProps.end(),
+        begin,
+        end,
         ::comphelper::PropertyCompareByName()
     );
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 60e025e3e371..156176ba023d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5883,9 +5883,9 @@ static char* lo_getFilterTypes(LibreOfficeKit* pThis)
         uno::Sequence<beans::PropertyValue> aValues;
         if (xTypeDetection->getByName(rType) >>= aValues)
         {
-            auto it = std::find_if(aValues.begin(), aValues.end(), [](const 
beans::PropertyValue& rValue) { return rValue.Name == "MediaType"; });
+            auto it = std::find_if(std::cbegin(aValues), std::cend(aValues), 
[](const beans::PropertyValue& rValue) { return rValue.Name == "MediaType"; });
             OUString aValue;
-            if (it != aValues.end() && (it->Value >>= aValue) && 
!aValue.isEmpty())
+            if (it != std::cend(aValues) && (it->Value >>= aValue) && 
!aValue.isEmpty())
             {
                 auto typeNode = aJson.startNode(rType.toUtf8().getStr());
                 aJson.put("MediaType", aValue.toUtf8());
diff --git a/desktop/source/lib/lokclipboard.cxx 
b/desktop/source/lib/lokclipboard.cxx
index 193c74472ba4..41f46e854164 100644
--- a/desktop/source/lib/lokclipboard.cxx
+++ b/desktop/source/lib/lokclipboard.cxx
@@ -219,11 +219,11 @@ uno::Sequence<datatransfer::DataFlavor> SAL_CALL 
LOKTransferable::getTransferDat
 
 sal_Bool SAL_CALL LOKTransferable::isDataFlavorSupported(const 
datatransfer::DataFlavor& rFlavor)
 {
-    return std::find_if(m_aFlavors.begin(), m_aFlavors.end(),
+    return std::find_if(std::cbegin(m_aFlavors), std::cend(m_aFlavors),
                         [&rFlavor](const datatransfer::DataFlavor& i) {
                             return i.MimeType == rFlavor.MimeType && 
i.DataType == rFlavor.DataType;
                         })
-           != m_aFlavors.end();
+           != std::cend(m_aFlavors);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/formcontrolcontainer.cxx 
b/extensions/source/bibliography/formcontrolcontainer.cxx
index 5e9f7d37aa35..c6ec73700656 100644
--- a/extensions/source/bibliography/formcontrolcontainer.cxx
+++ b/extensions/source/bibliography/formcontrolcontainer.cxx
@@ -92,15 +92,16 @@ namespace bib
         try
         {
             Reference< XControlContainer > xControlCont = 
getControlContainer();
-            Sequence< Reference< XControl > > aControls;
             if ( xControlCont.is() )
-                aControls = xControlCont->getControls();
-
-            std::for_each(
-                aControls.begin(),
-                aControls.end(),
-                ControlModeSwitch( _bDesign )
-            );
+            {
+                const Sequence<Reference<XControl>> aControls = 
xControlCont->getControls();
+
+                std::for_each(
+                    aControls.begin(),
+                    aControls.end(),
+                    ControlModeSwitch( _bDesign )
+                );
+            }
         }
         catch( const Exception&)
         {
diff --git a/extensions/source/propctrlr/cellbindinghelper.cxx 
b/extensions/source/propctrlr/cellbindinghelper.cxx
index e27345e7fee7..90dd8b77277b 100644
--- a/extensions/source/propctrlr/cellbindinghelper.cxx
+++ b/extensions/source/propctrlr/cellbindinghelper.cxx
@@ -375,15 +375,16 @@ namespace pcr
             Reference< XMultiServiceFactory > xDocumentFactory( m_xDocument, 
UNO_QUERY );
             OSL_ENSURE( xDocumentFactory.is(), 
"CellBindingHelper::isSpreadsheetDocumentWhichSupplies: spreadsheet document, 
but no factory?" );
 
-            Sequence< OUString > aAvailableServices;
             if ( xDocumentFactory.is() )
-                aAvailableServices = 
xDocumentFactory->getAvailableServiceNames( );
+            {
+                const Sequence<OUString> aAvailableServices = 
xDocumentFactory->getAvailableServiceNames( );
 
-            bYesItIs = std::any_of(
-                aAvailableServices.begin(),
-                aAvailableServices.end(),
-                StringCompare( _rService )
-            );
+                bYesItIs = std::any_of(
+                    aAvailableServices.begin(),
+                    aAvailableServices.end(),
+                    StringCompare( _rService )
+                );
+            }
         }
 
         return bYesItIs;
diff --git a/extensions/source/propctrlr/eformshelper.cxx 
b/extensions/source/propctrlr/eformshelper.cxx
index 36f5f2a2b44d..ff0a91e0e518 100644
--- a/extensions/source/propctrlr/eformshelper.cxx
+++ b/extensions/source/propctrlr/eformshelper.cxx
@@ -305,7 +305,7 @@ namespace pcr
             OSL_ENSURE( xForms.is(), "EFormsHelper::getFormModelNames: invalid 
forms container!" );
             if ( xForms.is() )
             {
-                Sequence< OUString > aModelNames = xForms->getElementNames();
+                const Sequence< OUString > aModelNames = 
xForms->getElementNames();
                 _rModelNames.resize( aModelNames.getLength() );
                 std::copy( aModelNames.begin(), aModelNames.end(), 
_rModelNames.begin() );
             }
@@ -329,7 +329,7 @@ namespace pcr
                 OSL_ENSURE( xBindings.is(), "EFormsHelper::getBindingNames: 
invalid bindings container obtained from the model!" );
                 if ( xBindings.is() )
                 {
-                    Sequence< OUString > aNames = xBindings->getElementNames();
+                    const Sequence< OUString > aNames = 
xBindings->getElementNames();
                     _rBindingNames.resize( aNames.getLength() );
                     std::copy( aNames.begin(), aNames.end(), 
_rBindingNames.begin() );
                 }
@@ -590,7 +590,7 @@ namespace pcr
                 xInfo = _rxProps->getPropertySetInfo();
             if ( xInfo.is() )
             {
-                Sequence< Property > aProperties = xInfo->getProperties();
+                const Sequence< Property > aProperties = 
xInfo->getProperties();
                 std::for_each( aProperties.begin(), aProperties.end(),
                     PropertyBagInserter( _rBag )
                 );
diff --git a/extensions/source/propctrlr/eventhandler.cxx 
b/extensions/source/propctrlr/eventhandler.cxx
index 940d7d48f379..b920a4262650 100644
--- a/extensions/source/propctrlr/eventhandler.cxx
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -276,7 +276,7 @@ namespace pcr
             Reference< XIntrospectionAccess > xIntrospectionAccess(
                 _rxIntrospection->inspect( makeAny( _rxComponent ) ), 
UNO_SET_THROW );
 
-            Sequence< Type > aListeners( 
xIntrospectionAccess->getSupportedListeners() );
+            const Sequence< Type > aListeners( 
xIntrospectionAccess->getSupportedListeners() );
 
             std::copy( aListeners.begin(), aListeners.end(),
                          std::insert_iterator< TypeBag >( _out_rTypes, 
_out_rTypes.begin() ) );
@@ -770,7 +770,7 @@ namespace pcr
         }
 
         // the initial selection in the dialog
-        Sequence< OUString > aNames( pEventHolder->getElementNames() );
+        const Sequence< OUString > aNames( pEventHolder->getElementNames() );
         const OUString* pChosenEvent = std::find( aNames.begin(), 
aNames.end(), rForEvent.sListenerMethodName );
         sal_uInt16 nInitialSelection = static_cast<sal_uInt16>( pChosenEvent - 
aNames.begin() );
 
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx 
b/extensions/source/propctrlr/formcomponenthandler.cxx
index 1bea9150f14f..92c03d54e17c 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -1329,7 +1329,7 @@ namespace pcr
                 std::vector< OUString > aListEntries;
 
                 Reference< XDatabaseContext > xDatabaseContext = 
sdb::DatabaseContext::create( m_xContext );
-                Sequence< OUString > aDatasources = 
xDatabaseContext->getElementNames();
+                const Sequence< OUString > aDatasources = 
xDatabaseContext->getElementNames();
                 aListEntries.resize( aDatasources.getLength() );
                 std::copy( aDatasources.begin(), aDatasources.end(), 
aListEntries.begin() );
                 aDescriptor.Control = 
PropertyHandlerHelper::createComboBoxControl(
diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx 
b/extensions/source/propctrlr/genericpropertyhandler.cxx
index 984f951dfd58..485c6937c2f6 100644
--- a/extensions/source/propctrlr/genericpropertyhandler.cxx
+++ b/extensions/source/propctrlr/genericpropertyhandler.cxx
@@ -116,7 +116,7 @@ namespace pcr
             TOOLS_WARN_EXCEPTION( "extensions.propctrlr", 
"EnumRepresentation::getDescriptions" );
         }
 
-        return std::vector< OUString >( aNames.begin(), aNames.end() );
+        return std::vector< OUString >( std::cbegin(aNames), std::cend(aNames) 
);
     }
 
     void EnumRepresentation::impl_getValues( Sequence< sal_Int32 >& 
_out_rValues ) const
@@ -162,7 +162,7 @@ namespace pcr
         Sequence< sal_Int32 > aValues;
         impl_getValues( aValues );
 
-        sal_Int32 index = std::find( aValues.begin(), aValues.end(), nAsInt ) 
- aValues.begin();
+        sal_Int32 index = std::find( std::cbegin(aValues), std::cend(aValues), 
nAsInt ) - std::cbegin(aValues);
 
         std::vector< OUString > aDescriptions( getDescriptions() );
         if ( ( index >= 0 ) && ( index < 
static_cast<sal_Int32>(aDescriptions.size()) ) )
diff --git a/extensions/source/propctrlr/stringrepresentation.cxx 
b/extensions/source/propctrlr/stringrepresentation.cxx
index 3e28295d7348..073cbbedd130 100644
--- a/extensions/source/propctrlr/stringrepresentation.cxx
+++ b/extensions/source/propctrlr/stringrepresentation.cxx
@@ -255,7 +255,8 @@ void SAL_CALL StringRepresentation::initialize(const 
uno::Sequence< uno::Any > &
     uno::Sequence<
         uno::Reference< reflection::XConstantTypeDescription > >
         cs(m_xTypeDescription->getConstants());
-    std::sort(cs.begin(), cs.end(), CompareConstants());
+    auto [begin, end] = toNonConstRange(cs);
+    std::sort(begin, end, CompareConstants());
     m_aConstants = cs;
 }
 
diff --git a/extensions/source/propctrlr/xsdvalidationhelper.cxx 
b/extensions/source/propctrlr/xsdvalidationhelper.cxx
index 12197e87d0b3..390993de6aca 100644
--- a/extensions/source/propctrlr/xsdvalidationhelper.cxx
+++ b/extensions/source/propctrlr/xsdvalidationhelper.cxx
@@ -83,12 +83,13 @@ namespace pcr
         try
         {
             Reference< XDataTypeRepository > xRepository = 
getDataTypeRepository();
-            Sequence< OUString > aElements;
             if ( xRepository.is() )
-                aElements = xRepository->getElementNames();
+            {
+                const Sequence<OUString> aElements = 
xRepository->getElementNames();
 
-            _rNames.resize( aElements.getLength() );
-            std::copy( aElements.begin(), aElements.end(), _rNames.begin() );
+                _rNames.resize( aElements.getLength() );
+                std::copy( aElements.begin(), aElements.end(), _rNames.begin() 
);
+            }
         }
         catch( const Exception& )
         {
diff --git a/forms/source/component/ListBox.cxx 
b/forms/source/component/ListBox.cxx
index 91a22ea4ef3d..2f95f6331f01 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -313,8 +313,8 @@ namespace frm
             // copy to member
             ValueList().swap(m_aListSourceValues);
             ::std::copy(
-                aListSource.begin(),
-                aListSource.end(),
+                std::cbegin(aListSource),
+                std::cend(aListSource),
                 ::std::insert_iterator< ValueList >( m_aListSourceValues, 
m_aListSourceValues.end() )
             );
 
@@ -952,7 +952,7 @@ namespace frm
                     Reference<XNameAccess> xFieldNames = 
getTableFields(xConnection, sListSource);
                     if (xFieldNames.is())
                     {
-                        css::uno::Sequence<OUString> seqNames = 
xFieldNames->getElementNames();
+                        const css::uno::Sequence<OUString> seqNames = 
xFieldNames->getElementNames();
                         ::std::copy(
                             seqNames.begin(),
                             seqNames.end(),
@@ -1378,8 +1378,8 @@ namespace frm
             OSL_VERIFY( _rExternalValue >>= aSelectIndexesPure );
             aSelectIndexes.realloc( aSelectIndexesPure.getLength() );
             ::std::copy(
-                aSelectIndexesPure.begin(),
-                aSelectIndexesPure.end(),
+                std::cbegin(aSelectIndexesPure),
+                std::cend(aSelectIndexesPure),
                 aSelectIndexes.getArray()
             );
         }
@@ -1590,8 +1590,8 @@ namespace frm
             // expects int's
             Sequence< sal_Int32 > aTransformed( aSelectSequence.getLength() );
             ::std::copy(
-                aSelectSequence.begin(),
-                aSelectSequence.end(),
+                std::cbegin(aSelectSequence),
+                std::cend(aSelectSequence),
                 aTransformed.getArray()
             );
             aReturn <<= aTransformed;
diff --git a/forms/source/component/propertybaghelper.cxx 
b/forms/source/component/propertybaghelper.cxx
index 134cfe6e2b10..f5c77c707a99 100644
--- a/forms/source/component/propertybaghelper.cxx
+++ b/forms/source/component/propertybaghelper.cxx
@@ -256,7 +256,7 @@ namespace frm
         Reference< XMultiPropertySet > xMe( 
m_rContext.getPropertiesInterface(), css::uno::UNO_SET_THROW );
         Reference< XPropertySetInfo > xPSI( xMe->getPropertySetInfo(), 
css::uno::UNO_SET_THROW );
 
-        Sequence< Property > aProperties( xPSI->getProperties() );
+        const Sequence< Property > aProperties( xPSI->getProperties() );
         Sequence< OUString > aPropertyNames( aProperties.getLength() );
         ::std::transform( aProperties.begin(), aProperties.end(),
             aPropertyNames.getArray(), SelectNameOfProperty() );
diff --git a/forms/source/misc/InterfaceContainer.cxx 
b/forms/source/misc/InterfaceContainer.cxx
index 41dbd7f3c086..837baa838dab 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -394,7 +394,8 @@ void OInterfaceContainer::transformEvents()
             if ( aChildEvents.hasElements() )
             {
                 // do the transformation
-                ::std::for_each( aChildEvents.begin(), aChildEvents.end(), 
TransformEventTo52Format() );
+                auto [begin, end] = toNonConstRange(aChildEvents);
+                ::std::for_each( begin, end, TransformEventTo52Format() );
 
                 // revoke the script events
                 m_xEventAttacher->revokeScriptEvents( i );
diff --git a/framework/qa/cppunit/dispatchtest.cxx 
b/framework/qa/cppunit/dispatchtest.cxx
index 2f21a71b005e..9d2446b56ef3 100644
--- a/framework/qa/cppunit/dispatchtest.cxx
+++ b/framework/qa/cppunit/dispatchtest.cxx
@@ -124,8 +124,8 @@ uno::Reference<frame::XDispatch> 
MyInterceptor::queryDispatch(const util::URL& r
                                                               const OUString& 
/*rTargetFrameName*/,
                                                               sal_Int32 
/*SearchFlags*/)
 {
-    if (std::find(m_aDisabledCommands.begin(), m_aDisabledCommands.end(), 
rURL.Complete)
-        != m_aDisabledCommands.end())
+    if (std::find(std::cbegin(m_aDisabledCommands), 
std::cend(m_aDisabledCommands), rURL.Complete)
+        != std::cend(m_aDisabledCommands))
         ++m_nExpected;
     else
         ++m_nUnexpected;
diff --git a/framework/source/services/autorecovery.cxx 
b/framework/source/services/autorecovery.cxx
index 7b66409014b9..193504354306 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -3379,7 +3379,7 @@ void AutoRecovery::implts_openOneDoc(const OUString&      
         sURL       ,
         }
 
         // re-create all the views
-        ::std::vector< OUString > aViewsToRestore( rInfo.ViewNames.begin(), 
rInfo.ViewNames.end() );
+        ::std::vector< OUString > aViewsToRestore( 
std::cbegin(rInfo.ViewNames), std::cend(rInfo.ViewNames) );
         // if we don't have views for whatever reason, then create a 
default-view, at least
         if ( aViewsToRestore.empty() )
             aViewsToRestore.emplace_back( );
diff --git a/i18npool/qa/cppunit/test_ordinalsuffix.cxx 
b/i18npool/qa/cppunit/test_ordinalsuffix.cxx
index fb06a41fa4b2..be21f38ca531 100644
--- a/i18npool/qa/cppunit/test_ordinalsuffix.cxx
+++ b/i18npool/qa/cppunit/test_ordinalsuffix.cxx
@@ -46,50 +46,36 @@ void TestOrdinalSuffix::tearDown()
 void TestOrdinalSuffix::testFrench()
 {
     lang::Locale aLocale("fr", "LU", "");
-    uno::Sequence< OUString > aSuffixes;
-    OUString *pStart, *pEnd, *pFind;
 
     //1er
-    aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
-    pStart = aSuffixes.begin();
-    pEnd = aSuffixes.end();
-    pFind = std::find(pStart, pEnd, OUString("er"));
-    CPPUNIT_ASSERT(pFind != pEnd);
+    uno::Sequence<OUString> aSuffixes = m_xOrdinal->getOrdinalSuffix(1, 
aLocale);
+    const OUString* pFind = std::find(std::cbegin(aSuffixes), 
std::cend(aSuffixes), OUString("er"));
+    CPPUNIT_ASSERT(pFind != std::cend(aSuffixes));
 
     //2e, 3e, etc.
     aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
-    pStart = aSuffixes.begin();
-    pEnd = aSuffixes.end();
-    pFind = std::find(pStart, pEnd, OUString("e"));
-    CPPUNIT_ASSERT(pFind != pEnd);
+    pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), 
OUString("e"));
+    CPPUNIT_ASSERT(pFind != std::cend(aSuffixes));
 }
 
 void TestOrdinalSuffix::testEnglish()
 {
     lang::Locale aLocale("en", "US", "");
-    uno::Sequence< OUString > aSuffixes;
-    OUString *pStart, *pEnd, *pFind;
 
     //1st
-    aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
-    pStart = aSuffixes.begin();
-    pEnd = aSuffixes.end();
-    pFind = std::find(pStart, pEnd, OUString("st"));
-    CPPUNIT_ASSERT(pFind != pEnd);
+    uno::Sequence<OUString> aSuffixes = m_xOrdinal->getOrdinalSuffix(1, 
aLocale);
+    const OUString* pFind = std::find(std::cbegin(aSuffixes), 
std::cend(aSuffixes), OUString("st"));
+    CPPUNIT_ASSERT(pFind != std::cend(aSuffixes));
 
     //2nd
     aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
-    pStart = aSuffixes.begin();
-    pEnd = aSuffixes.end();
-    pFind = std::find(pStart, pEnd, OUString("nd"));
-    CPPUNIT_ASSERT(pFind != pEnd);
+    pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), 
OUString("nd"));
+    CPPUNIT_ASSERT(pFind != std::cend(aSuffixes));
 
     //3rd
     aSuffixes = m_xOrdinal->getOrdinalSuffix(3, aLocale);
-    pStart = aSuffixes.begin();
-    pEnd = aSuffixes.end();
-    pFind = std::find(pStart, pEnd, OUString("rd"));
-    CPPUNIT_ASSERT(pFind != pEnd);
+    pFind = std::find(std::cbegin(aSuffixes), std::cend(aSuffixes), 
OUString("rd"));
+    CPPUNIT_ASSERT(pFind != std::cend(aSuffixes));
 }
 
 
diff --git a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx 
b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
index 4d09e9f88ef0..5a071a3887fa 100644
--- a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
@@ -77,7 +77,8 @@ ignoreIandEfollowedByYa_ja_JP::foldingImpl( const OUString& 
inStr, sal_Int32 sta
     if (pOffset) {
         // Allocate nCount length to offset argument.
         pOffset->realloc( nCount );
-        std::iota(pOffset->begin(), pOffset->end(), startPos);
+        auto [begin, end] = toNonConstRange(*pOffset);
+        std::iota(begin, end, startPos);
     }
 
 
diff --git a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx 
b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
index 22a600d51f41..bdee0d87d6fa 100644
--- a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
@@ -95,7 +95,8 @@ ignoreIterationMark_ja_JP::foldingImpl( const OUString& 
inStr, sal_Int32 startPo
     if (pOffset) {
         // Allocate nCount length to offset argument.
         pOffset->realloc( nCount );
-        std::iota(pOffset->begin(), pOffset->end(), startPos);
+        auto [begin, end] = toNonConstRange(*pOffset);
+        std::iota(begin, end, startPos);
     }
 
 
diff --git a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx 
b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
index f54ff822e4e1..1c64d65104d9 100644
--- a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
@@ -38,7 +38,8 @@ ignoreKiKuFollowedBySa_ja_JP::foldingImpl( const OUString& 
inStr, sal_Int32 star
     if (pOffset) {
         // Allocate nCount length to offset argument.
         pOffset->realloc( nCount );
-        std::iota(pOffset->begin(), pOffset->end(), startPos);
+        auto [begin, end] = toNonConstRange(*pOffset);
+        std::iota(begin, end, startPos);
     }
 
 
diff --git a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx 
b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
index 4d7f8241a35a..fc87d206dc3e 100644
--- a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
@@ -300,7 +300,8 @@ ignoreProlongedSoundMark_ja_JP::foldingImpl( const 
OUString& inStr, sal_Int32 st
     if (pOffset) {
         // Allocate nCount length to offset argument.
         pOffset->realloc( nCount );
-        std::iota(pOffset->begin(), pOffset->end(), startPos);
+        auto [begin, end] = toNonConstRange(*pOffset);
+        std::iota(begin, end, startPos);
     }
 
 
diff --git a/i18npool/source/transliteration/transliterationImpl.cxx 
b/i18npool/source/transliteration/transliterationImpl.cxx
index 8649eccfc807..6a04ce8cd823 100644
--- a/i18npool/source/transliteration/transliterationImpl.cxx
+++ b/i18npool/source/transliteration/transliterationImpl.cxx
@@ -306,7 +306,7 @@ TransliterationImpl::transliterate( const OUString& inStr, 
sal_Int32 startPos, s
             tmpStr = bodyCascade[0]->transliterate(tmpStr, 0, nCount, offset);
             if ( startPos )
             {
-                for (sal_Int32 & j : offset)
+                for (sal_Int32 & j : toNonConstRange(offset))
                     j += startPos;
             }
             return tmpStr;
@@ -316,31 +316,22 @@ TransliterationImpl::transliterate( const OUString& 
inStr, sal_Int32 startPos, s
     {
         OUString tmpStr = inStr.copy(startPos, nCount);
 
-        std::iota(offset.begin(), offset.end(), startPos);
+        auto [begin, end] = toNonConstRange(offset);
+        std::iota(begin, end, startPos);
 
-        sal_Int16 from = 0, to = 1;
-        Sequence<sal_Int32> off[2];
-
-        off[to] = offset;
-        off[from].realloc(nCount);
+        Sequence<sal_Int32> from(nCount);
+        Sequence<sal_Int32> to = offset;
         for (sal_Int32 i = 0; i < numCascade; i++) {
-            tmpStr = bodyCascade[i]->transliterate(tmpStr, 0, nCount, 
off[from]);
+            tmpStr = bodyCascade[i]->transliterate(tmpStr, 0, nCount, from);
 
             nCount = tmpStr.getLength();
 
-            assert(off[from].getLength() == nCount);
-            std::swap(from, to);
-            // tdf#89665: don't use operator[] to write - too slow!
-            // interestingly gcc 4.9 -Os won't even inline the const operator[]
-            sal_Int32 const*const pFrom(off[from].getConstArray());
-            sal_Int32 *const pTo(off[to].getArray());
-            for (sal_Int32 j = 0; j < nCount; j++)
-            {
-                assert(pTo[j] < off[from].getLength());
-                pTo[j] = pFrom[pTo[j]];
-            }
+            assert(from.getLength() == nCount);
+            from.swap(to);
+            for (sal_Int32& ix : toNonConstRange(to))
+                ix = std::as_const(from)[ix];
         }
-        offset = off[to];
+        offset = to;
         return tmpStr;
     }
 }
@@ -375,7 +366,8 @@ TransliterationImpl::folding( const OUString& inStr, 
sal_Int32 startPos, sal_Int
     {
         OUString tmpStr = inStr.copy(startPos, nCount);
 
-        std::iota(offset.begin(), offset.end(), startPos);
+        auto [begin, end] = toNonConstRange(offset);
+        std::iota(begin, end, startPos);
 
         sal_Int16 from = 0, to = 1;
         Sequence<sal_Int32> off[2];
diff --git a/i18npool/source/transliteration/transliteration_OneToOne.cxx 
b/i18npool/source/transliteration/transliteration_OneToOne.cxx
index a030d558d3b8..34f4902f79bb 100644
--- a/i18npool/source/transliteration/transliteration_OneToOne.cxx
+++ b/i18npool/source/transliteration/transliteration_OneToOne.cxx
@@ -68,7 +68,8 @@ transliteration_OneToOne::transliterateImpl( const OUString& 
inStr, sal_Int32 st
     // Allocate nCount length to offset argument.
     if (pOffset) {
         pOffset->realloc( nCount );
-        std::iota(pOffset->begin(), pOffset->end(), startPos);
+        auto [begin, end] = toNonConstRange(*pOffset);
+        std::iota(begin, end, startPos);
     }
 
     // Translation
diff --git a/i18npool/source/transliteration/transliteration_body.cxx 
b/i18npool/source/transliteration/transliteration_body.cxx
index 1f4541082435..b0c710c6c696 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -260,8 +260,9 @@ static OUString transliterate_titlecase_Impl(
                xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, 
rLocale );
         pOffset->realloc( aRes.getLength() );
 
-        sal_Int32* pOffsetInt = std::fill_n(pOffset->begin(), nResolvedLen, 0);
-        std::iota(pOffsetInt, pOffset->end(), 1);
+        auto [begin, end] = toNonConstRange(*pOffset);
+        sal_Int32* pOffsetInt = std::fill_n(begin, nResolvedLen, 0);
+        std::iota(pOffsetInt, end, 1);
     }
     return aRes;
 }
diff --git a/include/com/sun/star/uno/Sequence.h 
b/include/com/sun/star/uno/Sequence.h
index 6b19af68d8a1..39caf8ff768f 100644
--- a/include/com/sun/star/uno/Sequence.h
+++ b/include/com/sun/star/uno/Sequence.h
@@ -265,6 +265,16 @@ public:
     */
     uno_Sequence * SAL_CALL get() const
         { return _pSequence; }
+
+#if defined LIBO_INTERNAL_ONLY
+    /** Swaps sequences efficiently exchanging their underlying 
representations.
+
+        @param other another sequence of same type
+
+        @since LibreOffice 7.3
+    */
+    inline void swap(Sequence& other);
+#endif
 };
 
 // Find uses of illegal Sequence<bool> (instead of Sequence<sal_Bool>) during
diff --git a/include/com/sun/star/uno/Sequence.hxx 
b/include/com/sun/star/uno/Sequence.hxx
index 26a51350815b..08a74d73789f 100644
--- a/include/com/sun/star/uno/Sequence.hxx
+++ b/include/com/sun/star/uno/Sequence.hxx
@@ -30,6 +30,7 @@
 #if defined LIBO_INTERNAL_ONLY
 # include <type_traits>
 # include <ostream>
+# include <utility>
 #endif
 
 #include "osl/interlck.h"
@@ -203,6 +204,13 @@ inline void Sequence< E >::realloc( sal_Int32 nSize )
         throw ::std::bad_alloc();
 }
 
+#if defined LIBO_INTERNAL_ONLY
+template <class E> inline void Sequence<E>::swap(Sequence& other)
+{
+    std::swap(_pSequence, other._pSequence);
+}
+#endif
+
 inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
     const ::rtl::ByteSequence & rByteSequence )
 {
@@ -271,6 +279,22 @@ inline std::basic_ostream<charT, traits> 
&operator<<(std::basic_ostream<charT, t
     return os;
 }
 
+template <class E> inline auto toNonConstRange(css::uno::Sequence<E>& s)
+{
+    // Two iterators [begin, end] representing the non-const range of the 
Sequence.
+    // It only calls Sequence::getArray once, to avoid the second COW overhead 
when
+    // Sequence::begin() and Sequence::end() are called in pairs.
+    // Inheriting from pair allows to use std::tie to unpack the two iterators.
+    struct SequenceRange : public std::pair<E*, E*>
+    {
+        SequenceRange(E* ptr, sal_Int32 len) : std::pair<E*, E*>(ptr, ptr + 
len) {}
+        // These allow to pass it as range-expression to range-based for loops
+        E* begin() { return std::pair<E*, E*>::first; }
+        E* end() { return std::pair<E*, E*>::second; }
+    };
+    return SequenceRange(s.begin(), s.getLength());
+};
+
 /// @endcond
 
 #endif
diff --git a/include/vcl/FilterConfigItem.hxx b/include/vcl/FilterConfigItem.hxx
index f1593b4db2c3..45692fedb01f 100644
--- a/include/vcl/FilterConfigItem.hxx
+++ b/include/vcl/FilterConfigItem.hxx
@@ -52,8 +52,8 @@ class VCL_DLLPUBLIC FilterConfigItem
     void     ImpInitTree( std::u16string_view rTree );
 
 
-    static css::beans::PropertyValue* GetPropertyValue(
-                css::uno::Sequence< css::beans::PropertyValue >& rPropSeq,
+    static const css::beans::PropertyValue* GetPropertyValue(
+                const css::uno::Sequence< css::beans::PropertyValue >& 
rPropSeq,
                     const OUString& rName );
     static  bool WritePropertyValue(
                 css::uno::Sequence< css::beans::PropertyValue >& rPropSeq,
diff --git a/include/xmloff/XMLEventExport.hxx 
b/include/xmloff/XMLEventExport.hxx
index d37cb6717399..48198032377f 100644
--- a/include/xmloff/XMLEventExport.hxx
+++ b/include/xmloff/XMLEventExport.hxx
@@ -111,7 +111,7 @@ private:
 
     /// export one event (start container-element if necessary)
     SAL_DLLPRIVATE void ExportEvent(
-        css::uno::Sequence<css::beans::PropertyValue>& rEventValues,
+        const css::uno::Sequence<css::beans::PropertyValue>& rEventValues,
         const XMLEventName& rXmlEventName,
         bool bUseWhitespace,
         bool& rExported);
diff --git a/oox/source/crypto/AgileEngine.cxx 
b/oox/source/crypto/AgileEngine.cxx
index 63712d01b3ef..0fd655ced63c 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -504,7 +504,7 @@ bool 
AgileEngine::readEncryptionInfo(uno::Reference<io::XInputStream> & rxInputS
     uno::Sequence<sal_Int8> aReadReservedBytes(sizeof(sal_uInt32));
     rxInputStream->readBytes(aReadReservedBytes, 
aReadReservedBytes.getLength());
 
-    if (!std::equal(aReadReservedBytes.begin(), aReadReservedBytes.end(), 
aExpectedReservedBytes.begin()))
+    if (!std::equal(std::cbegin(aReadReservedBytes), 
std::cend(aReadReservedBytes), aExpectedReservedBytes.begin()))
         return false;
 
     mInfo.spinCount = 0;
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 452b5f5ef851..32736e67fad0 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -406,7 +406,7 @@ static void lcl_fillCategoriesIntoStringVector(
     if( xTextualDataSequence.is())
     {
         rOutCategories.clear();
-        Sequence< OUString > aTextData( 
xTextualDataSequence->getTextualData());
+        const Sequence< OUString > aTextData( 
xTextualDataSequence->getTextualData());
         rOutCategories.insert( rOutCategories.end(), aTextData.begin(), 
aTextData.end() );
     }
     else
@@ -425,7 +425,7 @@ static ::std::vector< double > 
lcl_getAllValuesFromSequence( const Reference< ch
     Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, 
uno::UNO_QUERY );
     if( xNumSeq.is())
     {
-        Sequence< double > aValues( xNumSeq->getNumericalData());
+        const Sequence< double > aValues( xNumSeq->getNumericalData());
         aResult.insert( aResult.end(), aValues.begin(), aValues.end() );
     }
     else if( xSeq.is())
diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx
index 987ab3b809d1..d11d145bb764 100644
--- a/oox/source/helper/zipstorage.cxx
+++ b/oox/source/helper/zipstorage.cxx
@@ -110,10 +110,9 @@ Reference< XStorage > ZipStorage::implGetXStorage() const
 
 void ZipStorage::implGetElementNames( ::std::vector< OUString >& 
orElementNames ) const
 {
-    Sequence< OUString > aNames;
     if( mxStorage.is() ) try
     {
-        aNames = mxStorage->getElementNames();
+        const Sequence<OUString> aNames = mxStorage->getElementNames();
         if( aNames.hasElements() )
             orElementNames.insert( orElementNames.end(), aNames.begin(), 
aNames.end() );
     }
diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx
index 82aa1cd79fe8..32673fa699af 100644
--- a/oox/source/ole/olestorage.cxx
+++ b/oox/source/ole/olestorage.cxx
@@ -279,10 +279,9 @@ Reference< XStorage > OleStorage::implGetXStorage() const
 
 void OleStorage::implGetElementNames( ::std::vector< OUString >& 
orElementNames ) const
 {
-    Sequence< OUString > aNames;
     if( mxStorage.is() ) try
     {
-        aNames = mxStorage->getElementNames();
+        const Sequence<OUString> aNames = mxStorage->getElementNames();
         if( aNames.hasElements() )
             orElementNames.insert( orElementNames.end(), aNames.begin(), 
aNames.end() );
     }
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx 
b/reportdesign/source/core/api/ReportDefinition.cxx
index 6c0892ceecc3..f296561bf62e 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1919,7 +1919,7 @@ void SAL_CALL OReportDefinition::setMimeType( const 
OUString& _mimetype )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
-    uno::Sequence< OUString > aList = getAvailableMimeTypes();
+    const uno::Sequence< OUString > aList = getAvailableMimeTypes();
     if ( ::std::find(aList.begin(), aList.end(), _mimetype) == aList.end() )
         throwIllegallArgumentException("getAvailableMimeTypes()"
                         ,*this
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 0b7410dd4d52..f02a510bcdeb 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -2096,7 +2096,7 @@ void SAL_CALL ScDPLevel::setPropertyValue( const 
OUString& aPropertyName, const
         uno::Sequence<sheet::GeneralFunction> aSeq;
         aValue >>= aSeq;
         aSubTotals.realloc(aSeq.getLength());
-        std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(),
+        std::transform(std::cbegin(aSeq), std::cend(aSeq), aSubTotals.begin(),
             [](const sheet::GeneralFunction& rFunc) -> sal_Int16 {
                 return static_cast<sal_Int16>(rFunc); });
     }
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 0545622cd43e..1598e1b69d0d 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1365,9 +1365,9 @@ void ScUnoAddInCall::ExecuteCall()
         uno::Sequence<uno::Any> aRealArgs( nDestLen );
         uno::Any* pDest = aRealArgs.getArray();
 
-        pDest = std::copy_n(aArgs.begin(), nCallPos, pDest);
+        pDest = std::copy_n(std::cbegin(aArgs), nCallPos, pDest);
         *pDest = aCallerAny;
-        std::copy(std::next(aArgs.begin(), nCallPos), aArgs.end(), 
std::next(pDest));
+        std::copy(std::next(std::cbegin(aArgs), nCallPos), std::cend(aArgs), 
std::next(pDest));
 
         ExecuteCallWithArgs( aRealArgs );
     }
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index c4e8cc77d942..141802e076b8 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -365,7 +365,7 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const 
css::uno::Any & rAny )
         sal_Int32 nMaxColCount = 0;
         if (nRowCount)
         {
-            auto pRow = std::max_element(aSequence.begin(), aSequence.end(),
+            auto pRow = std::max_element(std::cbegin(aSequence), 
std::cend(aSequence),
                 [](const uno::Sequence<uno::Any>& a, const 
uno::Sequence<uno::Any>& b) {
                     return a.getLength() < b.getLength(); });
             nMaxColCount = pRow->getLength();
diff --git a/sc/source/filter/xml/xmlcvali.cxx 
b/sc/source/filter/xml/xmlcvali.cxx
index bc3856bd4afc..6a5669b7866a 100644
--- a/sc/source/filter/xml/xmlcvali.cxx
+++ b/sc/source/filter/xml/xmlcvali.cxx
@@ -362,10 +362,10 @@ void SAL_CALL 
ScXMLContentValidationContext::endFastElement( sal_Int32 /*nElemen
         uno::Sequence<beans::PropertyValue> aValues;
         pEvents->GetEventSequence( "OnError", aValues );
 
-        auto pValue = std::find_if(aValues.begin(), aValues.end(),
+        auto pValue = std::find_if(std::cbegin(aValues), std::cend(aValues),
             [](const beans::PropertyValue& rValue) {
                 return rValue.Name == "MacroName" || rValue.Name == "Script"; 
});
-        if (pValue != aValues.end())
+        if (pValue != std::cend(aValues))
             pValue->Value >>= sErrorTitle;
     }
 
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx 
b/sc/source/ui/Accessibility/AccessibleCell.cxx
index ed7e718cc5f0..a7a8d442533d 100644
--- a/sc/source/ui/Accessibility/AccessibleCell.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -522,9 +522,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL 
ScAccessibleCell::getCharacterAtt
     sal_uInt16 nParaIndent = mpDoc->GetAttr( maCellAddress, ATTR_INDENT 
)->GetValue();
     if (nParaIndent > 0)
     {
-        auto pAttrib = std::find_if(aAttribs.begin(), aAttribs.end(),
+        auto [begin, end] = toNonConstRange(aAttribs);
+        auto pAttrib = std::find_if(begin, end,
             [](const beans::PropertyValue& rAttrib) { return "ParaLeftMargin" 
== rAttrib.Name; });
-        if (pAttrib != aAttribs.end())
+        if (pAttrib != end)
             pAttrib->Value <<= nParaIndent;
     }
     return aAttribs;
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx 
b/sc/source/ui/miscdlgs/optsolver.cxx
index 5425a65c6c6d..c81819b3027a 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -862,10 +862,11 @@ bool ScOptSolverDlg::CallSolver()       // return true -> 
close dialog after cal
         sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
                          ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
         aVariables.realloc( nVarPos + nAdd );
+        auto it = aVariables.begin() + nVarPos;
 
         for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); 
++nRow)
             for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); 
++nCol)
-                aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
+                *it++ = table::CellAddress( nTab, nCol, nRow );
     }
 
     uno::Sequence<sheet::SolverConstraint> aConstraints;
@@ -969,9 +970,8 @@ bool ScOptSolverDlg::CallSolver()       // return true -> 
close dialog after cal
     // copy old document values
 
     sal_Int32 nVarCount = aVariables.getLength();
-    uno::Sequence<double> aOldValues;
-    aOldValues.realloc( nVarCount );
-    std::transform(aVariables.begin(), aVariables.end(), aOldValues.begin(),
+    uno::Sequence<double> aOldValues( nVarCount );
+    std::transform(std::cbegin(aVariables), std::cend(aVariables), 
aOldValues.begin(),
         [this](const table::CellAddress& rVariable) -> double {
             ScAddress aCellPos;
             ScUnoConversion::FillScAddress( aCellPos, rVariable );
@@ -1026,7 +1026,7 @@ bool ScOptSolverDlg::CallSolver()       // return true -> 
close dialog after cal
             for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
             {
                 ScAddress aCellPos;
-                ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] 
);
+                ScUnoConversion::FillScAddress( aCellPos, 
std::as_const(aVariables)[nVarPos] );
                 rFunc.SetValueCell(aCellPos, aSolution[nVarPos], false);
             }
             mpDocShell->UnlockPaint();
@@ -1064,7 +1064,7 @@ bool ScOptSolverDlg::CallSolver()       // return true -> 
close dialog after cal
         {
             ScAddress aCellPos;
             ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
-            rFunc.SetValueCell(aCellPos, aOldValues[nVarPos], false);
+            rFunc.SetValueCell(aCellPos, std::as_const(aOldValues)[nVarPos], 
false);
         }
         mpDocShell->UnlockPaint();
     }
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 0b945a182419..dd85f6ff8ba5 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1713,7 +1713,7 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( 
const OUString& aPropertyNa
         if( aValue >>= aSeq)
         {
             std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength());
-            std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(),
+            std::transform(std::cbegin(aSeq), std::cend(aSeq), 
aSubTotals.begin(),
                 [](const sheet::GeneralFunction& rValue) -> ScGeneralFunction {
                     const int nValAsInt = static_cast<int>(rValue);
                     return static_cast<ScGeneralFunction>(nValAsInt);
@@ -1727,7 +1727,7 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( 
const OUString& aPropertyNa
         if( aValue >>= aSeq )
         {
             std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength());
-            std::transform(aSeq.begin(), aSeq.end(), aSubTotals.begin(),
+            std::transform(std::cbegin(aSeq), std::cend(aSeq), 
aSubTotals.begin(),
                 [](sal_Int16 nValue) -> ScGeneralFunction { return 
static_cast<ScGeneralFunction>(nValue); });
             setSubtotals( aSubTotals );
         }
@@ -2691,7 +2691,7 @@ bool lclExtractGroupMembers( ScFieldGroupMembers& 
rMembers, const Any& rElement
     if( rElement >>= aSeq )
     {
         if( aSeq.hasElements() )
-            rMembers.insert( rMembers.end(), aSeq.begin(), aSeq.end() );
+            rMembers.insert( rMembers.end(), std::cbegin(aSeq), 
std::cend(aSeq) );
         return true;
     }
 
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index cabe2fe375e8..fb23ab02fcc4 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -84,9 +84,10 @@ ScVbaWorkbook::Colors( const ::uno::Any& Index )
 
 bool ScVbaWorkbook::setFilterPropsFromFormat( sal_Int32 nFormat, 
uno::Sequence< beans::PropertyValue >& rProps )
 {
-    auto pProp = std::find_if(rProps.begin(), rProps.end(),
+    auto [begin, end] = toNonConstRange(rProps);
+    auto pProp = std::find_if(begin, end,
         [](const beans::PropertyValue& rProp) { return rProp.Name == 
"FilterName"; });
-    bool bRes = pProp != rProps.end();
+    bool bRes = pProp != end;
     if (bRes)
     {
         switch( nFormat )
diff --git a/scripting/source/basprov/basmethnode.cxx 
b/scripting/source/basprov/basmethnode.cxx
index d053fa11b809..688b4ef2140f 100644
--- a/scripting/source/basprov/basmethnode.cxx
+++ b/scripting/source/basprov/basmethnode.cxx
@@ -203,7 +203,7 @@ namespace basprov
                 sDocURL = xModel->getURL();
                 if ( sDocURL.isEmpty() )
                 {
-                    Sequence < PropertyValue > aProps = xModel->getArgs();
+                    const Sequence < PropertyValue > aProps = 
xModel->getArgs();
                     // TODO: according to MBA the property 'Title' may change 
in future
                     const PropertyValue* pProp = std::find_if(aProps.begin(), 
aProps.end(),
                         [](const PropertyValue& rProp) { return rProp.Name == 
"Title"; });
diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx 
b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
index d3c1c1f0b394..1366f0d24f6b 100644
--- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx
+++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
@@ -102,7 +102,7 @@ public:
 
         Sequence< Reference < browse::XBrowseNode > > result( numChildren );
         sal_Int32 index = 0;
-        for ( Sequence< Reference < browse::XBrowseNode > >& children : seqs )
+        for ( const Sequence< Reference < browse::XBrowseNode > >& children : 
seqs )
         {
             std::copy(children.begin(), children.end(), 
std::next(result.begin(), index));
             index += children.getLength();
diff --git a/scripting/source/provider/ProviderCache.cxx 
b/scripting/source/provider/ProviderCache.cxx
index f5bdfe1ac11b..be134725635e 100644
--- a/scripting/source/provider/ProviderCache.cxx
+++ b/scripting/source/provider/ProviderCache.cxx
@@ -144,7 +144,7 @@ ProviderCache::populateCache()
             Reference< lang::XSingleComponentFactory > factory( 
xEnum->nextElement(), UNO_QUERY_THROW );
             Reference< lang::XServiceInfo > xServiceInfo( factory, 
UNO_QUERY_THROW );
 
-            Sequence< OUString > serviceNames = 
xServiceInfo->getSupportedServiceNames();
+            const Sequence< OUString > serviceNames = 
xServiceInfo->getSupportedServiceNames();
 
             if ( serviceNames.hasElements() )
             {
diff --git a/scripting/source/provider/URIHelper.cxx 
b/scripting/source/provider/URIHelper.cxx
index 9247f4b9fa98..3fa98db81355 100644
--- a/scripting/source/provider/URIHelper.cxx
+++ b/scripting/source/provider/URIHelper.cxx
@@ -142,7 +142,7 @@ ScriptingFrameworkURIHelper::initBaseURI()
         return false;
     }
 
-    uno::Sequence< OUString > children =
+    const uno::Sequence< OUString > children =
         m_xSimpleFileAccess->getFolderContents( uri, true );
 
     auto pChild = std::find_if(children.begin(), children.end(), [&test](const 
OUString& child) {
diff --git a/scripting/source/vbaevents/eventhelper.cxx 
b/scripting/source/vbaevents/eventhelper.cxx
index b6cf579bd5de..9bc86023c2e8 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -393,7 +393,7 @@ ScriptEventHelper::getEventListeners() const
     for ( const Type& listType : aControlListeners )
     {
         OUString sFullTypeName = listType.getTypeName();
-        Sequence< OUString > sMeths =
+        const Sequence< OUString > sMeths =
             comphelper::getEventMethodsForType( listType );
         std::transform(sMeths.begin(), sMeths.end(), 
std::back_inserter(eventMethods),
             [&sFullTypeName](const OUString& rMeth) -> OUString { return 
sFullTypeName + DELIM + rMeth; });
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 359b5215860b..4fc288f116c0 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -935,10 +935,10 @@ static bool getScaleXValue(const 
uno::Reference<beans::XPropertySet>& xSet)
         uno::Sequence<beans::PropertyValue> aTextPathProperties;
         aIterator->Value >>= aTextPathProperties;
         auto aIterator2 = std::find_if(
-            aTextPathProperties.begin(), aTextPathProperties.end(),
+            std::cbegin(aTextPathProperties), std::cend(aTextPathProperties),
             [](const beans::PropertyValue& rValue) { return rValue.Name == 
"ScaleX"; });
 
-        if (aIterator2 != aTextPathProperties.end())
+        if (aIterator2 != std::cend(aTextPathProperties))
         {
             aIterator2->Value >>= bScaleX;
         }
diff --git a/sd/source/core/CustomAnimationEffect.cxx 
b/sd/source/core/CustomAnimationEffect.cxx
index d82a89e65da3..83a3e674e710 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -387,7 +387,7 @@ sal_Int32 CustomAnimationEffect::get_node_type( const 
Reference< XAnimationNode
 
     if( xNode.is() )
     {
-        Sequence< NamedValue > aUserData( xNode->getUserData() );
+        const Sequence< NamedValue > aUserData( xNode->getUserData() );
         if( aUserData.hasElements() )
         {
             const NamedValue* pProp = std::find_if(aUserData.begin(), 
aUserData.end(),
@@ -418,17 +418,18 @@ void CustomAnimationEffect::setPresetClassAndId( 
sal_Int16 nPresetClass, const O
     bool bFoundPresetId = false;
     if( nLength )
     {
-        NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(),
+        auto [begin, end] = toNonConstRange(aUserData);
+        NamedValue* pProp = std::find_if(begin, end,
             [](const NamedValue& rProp) { return rProp.Name == "preset-class"; 
});
-        if (pProp != aUserData.end())
+        if (pProp != end)
         {
             pProp->Value <<= mnPresetClass;
             bFoundPresetClass = true;
         }
 
-        pProp = std::find_if(aUserData.begin(), aUserData.end(),
+        pProp = std::find_if(begin, end,
             [](const NamedValue& rProp) { return rProp.Name == "preset-id"; });
-        if (pProp != aUserData.end())
+        if (pProp != end)
         {
             pProp->Value <<= mnPresetClass;
             bFoundPresetId = true;
@@ -439,16 +440,18 @@ void CustomAnimationEffect::setPresetClassAndId( 
sal_Int16 nPresetClass, const O
     if( !bFoundPresetClass )
     {
         aUserData.realloc( nLength + 1);
-        aUserData[nLength].Name = "preset-class";
-        aUserData[nLength].Value <<= mnPresetClass;
+        auto& el = aUserData[nLength];
+        el.Name = "preset-class";
+        el.Value <<= mnPresetClass;
         ++nLength;
     }
 
     if( !bFoundPresetId && maPresetId.getLength() > 0 )
     {
         aUserData.realloc( nLength + 1);
-        aUserData[nLength].Name = "preset-id";
-        aUserData[nLength].Value <<= maPresetId;
+        auto& el = aUserData[nLength];
+        el.Name = "preset-id";
+        el.Value <<= maPresetId;
     }
 
     mxNode->setUserData( aUserData );
@@ -470,9 +473,10 @@ void CustomAnimationEffect::setNodeType( sal_Int16 
nNodeType )
     bool bFound = false;
     if( nLength )
     {
-        NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(),
+        auto [begin, end] = toNonConstRange(aUserData);
+        NamedValue* pProp = std::find_if(begin, end,
             [](const NamedValue& rProp) { return rProp.Name == "node-type"; });
-        if (pProp != aUserData.end())
+        if (pProp != end)
         {
             pProp->Value <<= mnNodeType;
             bFound = true;
@@ -483,8 +487,9 @@ void CustomAnimationEffect::setNodeType( sal_Int16 
nNodeType )
     if( !bFound )
     {
         aUserData.realloc( nLength + 1);
-        aUserData[nLength].Name = "node-type";
-        aUserData[nLength].Value <<= mnNodeType;
+        auto& el = aUserData[nLength];
+        el.Name = "node-type";
+        el.Value <<= mnNodeType;
     }
 
     mxNode->setUserData( aUserData );
@@ -503,9 +508,10 @@ void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId 
)
     bool bFound = false;
     if( nLength )
     {
-        NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(),
+        auto [begin, end] = toNonConstRange(aUserData);
+        NamedValue* pProp = std::find_if(begin, end,
             [](const NamedValue& rProp) { return rProp.Name == "group-id"; });
-        if (pProp != aUserData.end())
+        if (pProp != end)
         {
             pProp->Value <<= mnGroupId;
             bFound = true;
@@ -516,8 +522,9 @@ void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId )
     if( !bFound )
     {
         aUserData.realloc( nLength + 1);
-        aUserData[nLength].Name = "group-id";
-        aUserData[nLength].Value <<= mnGroupId;
+        auto& el = aUserData[nLength];
+        el.Name = "group-id";
+        el.Value <<= mnGroupId;
     }
 
     mxNode->setUserData( aUserData );
@@ -1677,7 +1684,7 @@ CustomAnimationEffectPtr EffectSequenceHelper::append( 
const CustomAnimationPres
             std::vector< NamedValue > aNewUserData;
             Sequence< NamedValue > aUserData( xNode->getUserData() );
 
-            std::copy_if(aUserData.begin(), aUserData.end(), 
std::back_inserter(aNewUserData),
+            std::copy_if(std::cbegin(aUserData), std::cend(aUserData), 
std::back_inserter(aNewUserData),
                 [](const NamedValue& rProp) { return rProp.Name != "text-only" 
&& rProp.Name != "preset-property"; });
 
             if( !aNewUserData.empty() )
@@ -2972,7 +2979,7 @@ void EffectSequenceHelper::processAfterEffect( const 
Reference< XAnimationNode >
     {
         Reference< XAnimationNode > xMaster;
 
-        Sequence< NamedValue > aUserData( xNode->getUserData() );
+        const Sequence< NamedValue > aUserData( xNode->getUserData() );
         const NamedValue* pProp = std::find_if(aUserData.begin(), 
aUserData.end(),
             [](const NamedValue& rProp) { return rProp.Name == 
"master-element"; });
 
diff --git a/sd/source/core/CustomAnimationPreset.cxx 
b/sd/source/core/CustomAnimationPreset.cxx
index 5147cb3cf0e0..0bb74770b732 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -123,7 +123,7 @@ CustomAnimationPreset::CustomAnimationPreset( const 
CustomAnimationEffectPtr& pE
     mfDuration = pEffect->getDuration();
     maDefaultSubTyp = pEffect->getPresetSubType();
 
-    Sequence< NamedValue > aUserData( pEffect->getNode()->getUserData() );
+    const Sequence< NamedValue > aUserData( pEffect->getNode()->getUserData() 
);
 
     mbIsTextOnly = std::any_of(aUserData.begin(), aUserData.end(),
         [](const NamedValue& rProp) { return rProp.Name == "text-only"; });
diff --git a/sd/source/core/TransitionPreset.cxx 
b/sd/source/core/TransitionPreset.cxx
index 19914e3498e4..992c5a1e0b7e 100644
--- a/sd/source/core/TransitionPreset.cxx
+++ b/sd/source/core/TransitionPreset.cxx
@@ -61,7 +61,7 @@ namespace sd {
 TransitionPreset::TransitionPreset( const css::uno::Reference< 
css::animations::XAnimationNode >& xNode )
 {
     // first locate preset id
-    Sequence< NamedValue > aUserData( xNode->getUserData() );
+    const Sequence< NamedValue > aUserData( xNode->getUserData() );
     const NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(),
         [](const NamedValue& rProp) { return rProp.Name == "preset-id"; });
     if (pProp != aUserData.end())
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 67c0758ec4d6..72298f94d951 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -305,7 +305,7 @@ bool SdStyleSheet::IsUsed() const
         cppu::OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( 
cppu::UnoType<XModifyListener>::get() );
         if( pContainer )
         {
-            Sequence< Reference< XInterface > > aModifyListeners( 
pContainer->getElements() );
+            const Sequence< Reference< XInterface > > aModifyListeners( 
pContainer->getElements() );
             bResult = std::any_of(aModifyListeners.begin(), 
aModifyListeners.end(),
                 [](const Reference<XInterface>& rListener) {
                     Reference< XStyle > xStyle( rListener, UNO_QUERY );
diff --git a/sd/source/filter/eppt/pptexanimations.cxx 
b/sd/source/filter/eppt/pptexanimations.cxx
index 1b8f314dff38..1b455036b766 100644
--- a/sd/source/filter/eppt/pptexanimations.cxx
+++ b/sd/source/filter/eppt/pptexanimations.cxx
@@ -374,7 +374,7 @@ void AnimationExporter::processAfterEffectNodes( const 
Reference< XAnimationNode
                                 {
                                     Reference< XAnimationNode > xMaster;
 
-                                    Sequence< NamedValue > aUserData( 
xChildNode3->getUserData() );
+                                    const Sequence< NamedValue > aUserData( 
xChildNode3->getUserData() );
                                     const NamedValue* p = 
std::find_if(aUserData.begin(), aUserData.end(),
                                         [](const NamedValue& rProp) { return 
rProp.Name == "master-element"; });
 
diff --git a/sd/source/filter/html/HtmlOptionsDialog.cxx 
b/sd/source/filter/html/HtmlOptionsDialog.cxx
index c7d2f7a8eb09..daa5e7362a39 100644
--- a/sd/source/filter/html/HtmlOptionsDialog.cxx
+++ b/sd/source/filter/html/HtmlOptionsDialog.cxx
@@ -123,16 +123,17 @@ Sequence< OUString > SAL_CALL 
SdHtmlOptionsDialog::getSupportedServiceNames()
 // XPropertyAccess
 Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues()
 {
-    auto pProp = std::find_if(maMediaDescriptor.begin(), 
maMediaDescriptor.end(),
+    auto pProp = std::find_if(std::cbegin(maMediaDescriptor), 
std::cend(maMediaDescriptor),
         [](const PropertyValue& rProp) { return rProp.Name == "FilterData"; });
-    auto i = static_cast<sal_Int32>(std::distance(maMediaDescriptor.begin(), 
pProp));
+    auto i = 
static_cast<sal_Int32>(std::distance(std::cbegin(maMediaDescriptor), pProp));
     sal_Int32 nCount = maMediaDescriptor.getLength();
     if ( i == nCount )
         maMediaDescriptor.realloc( ++nCount );
 
     // the "FilterData" Property is an Any that will contain our 
PropertySequence of Values
-    maMediaDescriptor[ i ].Name = "FilterData";
-    maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
+    auto& el = maMediaDescriptor[ i ];
+    el.Name = "FilterData";
+    el.Value <<= maFilterDataSequence;
     return maMediaDescriptor;
 }
 
@@ -140,9 +141,9 @@ void SdHtmlOptionsDialog::setPropertyValues( const 
Sequence< PropertyValue > & a
 {
     maMediaDescriptor = aProps;
 
-    auto pProp = std::find_if(maMediaDescriptor.begin(), 
maMediaDescriptor.end(),
+    auto pProp = std::find_if(std::cbegin(maMediaDescriptor), 
std::cend(maMediaDescriptor),
         [](const PropertyValue& rProp) { return rProp.Name == "FilterData"; });
-    if (pProp != maMediaDescriptor.end())
+    if (pProp != std::cend(maMediaDescriptor))
         pProp->Value >>= maFilterDataSequence;
 }
 
diff --git a/sd/source/ui/framework/configuration/ResourceId.cxx 
b/sd/source/ui/framework/configuration/ResourceId.cxx
index 48a6d360f5f2..9afc594cd7e9 100644
--- a/sd/source/ui/framework/configuration/ResourceId.cxx
+++ b/sd/source/ui/framework/configuration/ResourceId.cxx
@@ -362,7 +362,7 @@ void SAL_CALL ResourceId::initialize (const Sequence<Any>& 
aArguments)
                 if (xAnchor.is())
                 {
                     maResourceURLs.push_back(xAnchor->getResourceURL());
-                    Sequence<OUString> aAnchorURLs (xAnchor->getAnchorURLs());
+                    const Sequence<OUString> aAnchorURLs 
(xAnchor->getAnchorURLs());
                     maResourceURLs.insert( maResourceURLs.end(), 
aAnchorURLs.begin(), aAnchorURLs.end() );
                 }
             }
diff --git a/sd/source/ui/remotecontrol/Server.cxx 
b/sd/source/ui/remotecontrol/Server.cxx
index 1a53e682eca6..d1942df124c8 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -247,7 +247,7 @@ std::vector< std::shared_ptr< ClientInfo > > 
RemoteServer::getClients()
     // TODO: we should probably add some sort of extra labelling to mark
     // authorised AND connected client.
     Reference< XNameAccess > const xConfig = 
officecfg::Office::Impress::Misc::AuthorisedRemotes::get();
-    Sequence< OUString > aNames = xConfig->getElementNames();
+    const Sequence< OUString > aNames = xConfig->getElementNames();
     std::transform(aNames.begin(), aNames.end(), std::back_inserter(aClients),
         [](const OUString& rName) -> std::shared_ptr<ClientInfo> {
             return std::make_shared<ClientInfo>(rName, true); });
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index 897aed6f1524..7cc5a58b8da5 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -873,9 +873,9 @@ OUString ViewShellBase::GetInitialViewShellType() const
 
         // Search the properties for the one that tells us what page kind to
         // use.
-        auto pProperty = std::find_if(aProperties.begin(), aProperties.end(),
+        auto pProperty = std::find_if(std::cbegin(aProperties), 
std::cend(aProperties),
             [](const beans::PropertyValue& rProperty) { return rProperty.Name 
== sUNO_View_PageKind; });
-        if (pProperty != aProperties.end())
+        if (pProperty != std::cend(aProperties))
         {
             sal_Int16 nPageKind = 0;
             pProperty->Value >>= nPageKind;
diff --git a/sdext/source/minimizer/fileopendialog.cxx 
b/sdext/source/minimizer/fileopendialog.cxx
index aab29c03907b..ef0dbf4b4a43 100644
--- a/sdext/source/minimizer/fileopendialog.cxx
+++ b/sdext/source/minimizer/fileopendialog.cxx
@@ -114,9 +114,9 @@ FileOpenDialog::FileOpenDialog( const Reference< 
XComponentContext >& rxContext
             if ( xTypes->getByName( rFilterEntry.maType ) >>= aTypeProperties )
             {
                 Sequence< OUString > aExtensions;
-                auto pProp = std::find_if(aTypeProperties.begin(), 
aTypeProperties.end(),
+                auto pProp = std::find_if(std::cbegin(aTypeProperties), 
std::cend(aTypeProperties),
                     [](const PropertyValue& rProp) { return rProp.Name == 
"Extensions"; });
-                if (pProp != aTypeProperties.end())
+                if (pProp != std::cend(aTypeProperties))
                     pProp->Value >>= aExtensions;
                 if ( aExtensions.hasElements() )
                 {
diff --git a/sdext/source/presenter/PresenterScreen.cxx 
b/sdext/source/presenter/PresenterScreen.cxx
index ab30f08ebe90..a53f28e868ef 100644
--- a/sdext/source/presenter/PresenterScreen.cxx
+++ b/sdext/source/presenter/PresenterScreen.cxx
@@ -141,9 +141,9 @@ Any SAL_CALL PresenterScreenJob::execute(
         pArg->Value >>= lEnv;
 
     Reference<frame::XModel2> xModel;
-    auto pProp = std::find_if(lEnv.begin(), lEnv.end(),
+    auto pProp = std::find_if(std::cbegin(lEnv), std::cend(lEnv),
         [](const beans::NamedValue& rProp) { return rProp.Name == "Model"; });
-    if (pProp != lEnv.end())
+    if (pProp != std::cend(lEnv))
         pProp->Value >>= xModel;
 
     Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
diff --git a/sdext/source/presenter/PresenterTheme.cxx 
b/sdext/source/presenter/PresenterTheme.cxx
index c29e8e0de8a2..c84747d0f360 100644
--- a/sdext/source/presenter/PresenterTheme.cxx
+++ b/sdext/source/presenter/PresenterTheme.cxx
@@ -323,7 +323,7 @@ bool PresenterTheme::ConvertToColor (
     Sequence<sal_Int8> aByteSequence;
     if (rColorSequence >>= aByteSequence)
     {
-        rColor = std::accumulate(aByteSequence.begin(), aByteSequence.end(), 
sal_uInt32(0),
+        rColor = std::accumulate(std::cbegin(aByteSequence), 
std::cend(aByteSequence), sal_uInt32(0),
             [](const sal_uInt32 nRes, const sal_uInt8 nByte) { return (nRes << 
8) | nByte; });
         return true;
     }
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 5936accbfedb..4bae1c14a570 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -882,7 +882,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
                             Sequence < OUString > aTmp;
                             aRet >>= aTmp;
 
-                            
aProtocols.insert(aProtocols.end(),aTmp.begin(),aTmp.end());
+                            
aProtocols.insert(aProtocols.end(),std::cbegin(aTmp),std::cend(aTmp));
                         }
                     }
 
@@ -1037,11 +1037,11 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq 
)
     // Any Referer (that was relevant in the above call to
     // SvtSecurityOptions::isSecureMacroUri) is no longer relevant, assuming
     // this "open" request is initiated directly by the user:
-    auto pArg = std::find_if(aArgs.begin(), aArgs.end(),
+    auto pArg = std::find_if(std::cbegin(aArgs), std::cend(aArgs),
         [](const PropertyValue& rArg) { return rArg.Name == "Referer"; });
-    if (pArg != aArgs.end())
+    if (pArg != std::cend(aArgs))
     {
-        auto nIndex = static_cast<sal_Int32>(std::distance(aArgs.begin(), 
pArg));
+        auto nIndex = static_cast<sal_Int32>(std::distance(std::cbegin(aArgs), 
pArg));
         comphelper::removeElementAt(aArgs, nIndex);
     }
 
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 5f0b3f7f60ff..039b85bb1e27 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -473,9 +473,9 @@ OUString 
SfxHelp::GetHelpModuleName_Impl(std::u16string_view rHelpID)
                     
ModuleManager::create(::comphelper::getProcessComponentContext()) );
                 Sequence< PropertyValue > lProps;
                 xModuleManager->getByName( aModuleIdentifier ) >>= lProps;
-                auto pProp = std::find_if(lProps.begin(), lProps.end(),
+                auto pProp = std::find_if(std::cbegin(lProps), 
std::cend(lProps),
                     [](const PropertyValue& rProp) { return rProp.Name == 
"ooSetupFactoryShortName"; });
-                if (pProp != lProps.end())
+                if (pProp != std::cend(lProps))
                     pProp->Value >>= aFactoryShortName;
             }
             catch (const Exception&)
diff --git a/sfx2/source/control/charmapcontrol.cxx 
b/sfx2/source/control/charmapcontrol.cxx
index b86cc52111ee..032306b8a85f 100644
--- a/sfx2/source/control/charmapcontrol.cxx
+++ b/sfx2/source/control/charmapcontrol.cxx
@@ -119,11 +119,11 @@ SfxCharmapCtrl::~SfxCharmapCtrl()
 void SfxCharmapCtrl::getFavCharacterList()
 {
     //retrieve recent character list
-    css::uno::Sequence< OUString > rFavCharList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
+    const css::uno::Sequence< OUString > rFavCharList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
     m_aFavCharList.insert( m_aFavCharList.end(), rFavCharList.begin(), 
rFavCharList.end() );
 
     //retrieve recent character font list
-    css::uno::Sequence< OUString > rFavCharFontList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() 
);
+    const css::uno::Sequence< OUString > rFavCharFontList( 
officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() 
);
     m_aFavCharFontList.insert( m_aFavCharFontList.end(), 
rFavCharFontList.begin(), rFavCharFontList.end() );
 
     // tdf#135997: make sure that the two lists are same length
@@ -158,11 +158,11 @@ void SfxCharmapCtrl::updateFavCharControl()
 void SfxCharmapCtrl::getRecentCharacterList()
 {
     //retrieve recent character list
-    css::uno::Sequence< OUString > rRecentCharList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
+    const css::uno::Sequence< OUString > rRecentCharList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
     m_aRecentCharList.insert( m_aRecentCharList.end(), 
rRecentCharList.begin(), rRecentCharList.end() );
 
     //retrieve recent character font list
-    css::uno::Sequence< OUString > rRecentCharFontList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
+    const css::uno::Sequence< OUString > rRecentCharFontList( 
officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
     m_aRecentCharFontList.insert( m_aRecentCharFontList.end(), 
rRecentCharFontList.begin(), rRecentCharFontList.end() );
 
     // tdf#135997: make sure that the two lists are same length
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx 
b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
index 53f622554d62..253932bb2632 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -68,7 +68,7 @@ OUString enumValueToEnumName(uno::Any const& aValue,
     
xTypeDescription.set(xManager->getByHierarchicalName(aValue.getValueType().getTypeName()),

... etc. - the rest is truncated

Reply via email to