summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-14 09:25:24 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-15 10:36:36 +0200
commit2484de6728bd11bb7949003d112f1ece2223c7a1 (patch)
tree1296534e396da284b38d2c478dcd2b31c4714179 /sfx2
parent88375fd36899d21d3309cf8333712e02a87d3a91 (diff)
Remove non-const Sequence::begin()/end() in internal code
... to avoid hidden cost of multiple COW checks, because they call getArray() internally. This obsoletes [loplugin:sequenceloop]. Also rename toNonConstRange to asNonConstRange, to reflect that the result is a view of the sequence, not an independent object. TODO: also drop non-const operator[], but introduce operator[] in SequenceRange. Change-Id: Idd5fd7a3400fe65274d2a6343025e2ef8911635d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123518 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appdispatchprovider.cxx2
-rw-r--r--sfx2/source/appl/helpinterceptor.cxx2
-rw-r--r--sfx2/source/appl/macroloader.cxx2
-rw-r--r--sfx2/source/control/templatelocalview.cxx2
-rw-r--r--sfx2/source/control/unoctitm.cxx8
-rw-r--r--sfx2/source/dialog/backingcomp.cxx2
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx4
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx2
-rw-r--r--sfx2/source/dialog/filtergrouping.cxx2
-rw-r--r--sfx2/source/doc/doctemplates.cxx8
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx6
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx2
-rw-r--r--sfx2/source/view/viewprn.cxx2
13 files changed, 22 insertions, 22 deletions
diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx
index af86f8bcc02c..d3f64e1d4f34 100644
--- a/sfx2/source/appl/appdispatchprovider.cxx
+++ b/sfx2/source/appl/appdispatchprovider.cxx
@@ -146,7 +146,7 @@ Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispat
{
sal_Int32 nCount = seqDescriptor.getLength();
uno::Sequence< uno::Reference < frame::XDispatch > > lDispatcher(nCount);
- std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(),
+ std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.getArray(),
[this](const DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> {
return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
return lDispatcher;
diff --git a/sfx2/source/appl/helpinterceptor.cxx b/sfx2/source/appl/helpinterceptor.cxx
index 7fd631b05951..a9ff76101510 100644
--- a/sfx2/source/appl/helpinterceptor.cxx
+++ b/sfx2/source/appl/helpinterceptor.cxx
@@ -125,7 +125,7 @@ Sequence < Reference < XDispatch > > SAL_CALL HelpInterceptor_Impl::queryDispatc
{
Sequence< Reference< XDispatch > > aReturn( aDescripts.getLength() );
- std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(),
+ std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(),
[this](const DispatchDescriptor& rDescr) -> Reference<XDispatch> {
return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
return aReturn;
diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx
index f77d557f09f4..3f8fb33636ad 100644
--- a/sfx2/source/appl/macroloader.cxx
+++ b/sfx2/source/appl/macroloader.cxx
@@ -106,7 +106,7 @@ uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL
{
sal_Int32 nCount = seqDescriptor.getLength();
uno::Sequence< uno::Reference<frame::XDispatch> > lDispatcher(nCount);
- std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(),
+ std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.getArray(),
[this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> {
return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
return lDispatcher;
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 4d0571eeaca1..45802f71996e 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -909,7 +909,7 @@ bool TemplateLocalView::IsInternalTemplate(const OUString& rPath)
uno::Any aAny = xPathSettings->getPropertyValue("Template_internal");
aAny >>= aInternalTemplateDirs;
SfxURLRelocator_Impl aRelocator(xContext);
- for (auto& rInternalTemplateDir : aInternalTemplateDirs)
+ for (OUString& rInternalTemplateDir : asNonConstRange(aInternalTemplateDirs))
{
aRelocator.makeRelocatableURL(rInternalTemplateDir);
aRelocator.makeAbsoluteURL(rInternalTemplateDir);
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 2ab7e28dc2d7..a20056c15fff 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -597,7 +597,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
sal_uInt32 nIndex( lNewArgs.getLength() );
lNewArgs.realloc( nIndex + nAddArgs );
- std::copy(aAddArgs.begin(), aAddArgs.end(), std::next(lNewArgs.begin(), nIndex));
+ std::copy(aAddArgs.begin(), aAddArgs.end(), std::next(lNewArgs.getArray(), nIndex));
}
// Overwrite possible detected synchron argument, if real listener exists (currently no other way)
@@ -609,9 +609,9 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
// we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document
// so we must retrieve this as an argument from the parsed URL
lNewArgs.realloc( lNewArgs.getLength()+1 );
- nMarkArg = lNewArgs.getLength()-1;
- lNewArgs[nMarkArg].Name = "Bookmark";
- lNewArgs[nMarkArg].Value <<= aURL.Mark;
+ auto& el = lNewArgs[lNewArgs.getLength()-1];
+ el.Name = "Bookmark";
+ el.Value <<= aURL.Mark;
}
css::uno::Reference< css::frame::XFrame > xFrameRef(xFrame.get(), css::uno::UNO_QUERY);
diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx
index 8863a752ed45..845435ddc4f4 100644
--- a/sfx2/source/dialog/backingcomp.cxx
+++ b/sfx2/source/dialog/backingcomp.cxx
@@ -683,7 +683,7 @@ css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL Bac
sal_Int32 nCount = seqDescripts.getLength();
css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount );
- std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(),
+ std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(),
[this](const css::frame::DispatchDescriptor& rDesc) -> css::uno::Reference<XDispatch> {
return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); });
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 1a3cdec7e08f..7462f840d1ec 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -2322,7 +2322,7 @@ bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet* rSet )
aOldProps[i].Value >>= oldValue;
// We only edit hours and minutes
// don't compare NanoSeconds and Seconds
- for ( auto& rDateTime : oldValue )
+ for ( auto& rDateTime : asNonConstRange(oldValue) )
{
rDateTime.NanoSeconds = 0;
rDateTime.Seconds = 0;
@@ -2357,7 +2357,7 @@ void SfxCmisPropertiesPage::Reset( const SfxItemSet* rItemSet )
m_xPropertiesCtrl->ClearAllLines();
const SfxDocumentInfoItem& rInfoItem = rItemSet->Get(SID_DOCINFO);
uno::Sequence< document::CmisProperty > aCmisProps = rInfoItem.GetCmisProperties();
- for ( auto& rCmisProp : aCmisProps )
+ for ( auto& rCmisProp : asNonConstRange(aCmisProps) )
{
m_xPropertiesCtrl->AddLine(rCmisProp.Id,
rCmisProp.Name,
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 7765793c8a13..99e0de639070 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -613,7 +613,7 @@ void FileDialogHelper_Impl::updateVersions()
aEntries.realloc( xVersions.getLength() + 1 );
aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION );
- std::transform(xVersions.begin(), xVersions.end(), std::next(aEntries.begin()),
+ std::transform(xVersions.begin(), xVersions.end(), std::next(aEntries.getArray()),
[](const util::RevisionTag& rVersion) -> OUString { return rVersion.Identifier; });
}
catch( const uno::Exception& )
diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx
index aa2a8a930e8f..dcdc1a1a32c3 100644
--- a/sfx2/source/dialog/filtergrouping.cxx
+++ b/sfx2/source/dialog/filtergrouping.cxx
@@ -818,7 +818,7 @@ namespace sfx2
Sequence< StringPair > aFilters( comphelper::containerToSequence(_rGroup) );
if ( _bAddExtension )
{
- for ( StringPair & filter : aFilters )
+ for ( StringPair & filter : asNonConstRange(aFilters) )
filter.First = addExtension( filter.First, filter.Second, true, *m_pFileDlgImpl );
}
m_xFilterGroupManager->appendFilterGroup( OUString(), aFilters );
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index f381b8b7bcf1..7a036226bbec 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -547,7 +547,7 @@ void SfxDocTplService_Impl::getDirList()
u"vnd.sun.star.expand:" );
sal_Int32 nIdx{ 0 };
- for (auto& rTemplateDir : maTemplateDirs)
+ for (auto& rTemplateDir : asNonConstRange(maTemplateDirs))
{
aURL.SetSmartProtocol( INetProtocol::File );
aURL.SetURL( aDirs.getToken( 0, C_DELIM, nIdx ) );
@@ -573,7 +573,7 @@ void SfxDocTplService_Impl::getDirList()
Any aAny = xPathSettings->getPropertyValue( "Template_internal" );
aAny >>= maInternalTemplateDirs;
- for (auto& rInternalTemplateDir : maInternalTemplateDirs)
+ for (auto& rInternalTemplateDir : asNonConstRange(maInternalTemplateDirs))
{
//expand vnd.sun.star.expand: and remove "..." from them
//to normalize into the expected url patterns
@@ -967,7 +967,7 @@ bool SfxDocTplService_Impl::setProperty( Content& rContent,
Sequence< OUString > aValues;
if ( rPropValue >>= aValues )
{
- for ( auto& rValue : aValues )
+ for ( auto& rValue : asNonConstRange(aValues) )
{
maRelocator.makeRelocatableURL( rValue );
}
@@ -1026,7 +1026,7 @@ bool SfxDocTplService_Impl::getProperty(Content& rContent, const OUString& rProp
Sequence< OUString > aValues;
if ( rPropValue >>= aValues )
{
- for ( auto& rValue : aValues )
+ for ( auto& rValue : asNonConstRange(aValues) )
{
maRelocator.makeAbsoluteURL( rValue );
}
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 254ccec4e3c7..e0fdd4caab63 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -398,7 +398,7 @@ SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell const * pObjectShell )
SfxOwnFramesLocker::~SfxOwnFramesLocker()
{
- for ( auto& rFrame : m_aLockedFrames )
+ for ( auto& rFrame : asNonConstRange(m_aLockedFrames) )
{
try
{
@@ -1615,7 +1615,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue >
nSlotId = SID_CHECKIN;
sal_Int32 nLength = aSeqArgs.getLength( );
aArgs = Sequence< beans::PropertyValue >( nLength - 1 );
- std::copy_if(aSeqArgs.begin(), aSeqArgs.end(), aArgs.begin(),
+ std::copy_if(aSeqArgs.begin(), aSeqArgs.end(), aArgs.getArray(),
[](const beans::PropertyValue& rProp) { return rProp.Name != "CheckIn"; });
}
@@ -2792,7 +2792,7 @@ SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium )
static void addTitle_Impl( Sequence < beans::PropertyValue >& rSeq, const OUString& rTitle )
{
- auto [begin, end] = toNonConstRange(rSeq);
+ auto [begin, end] = asNonConstRange(rSeq);
auto pProp = std::find_if(begin, end,
[](const beans::PropertyValue& rProp) { return rProp.Name == "Title"; });
if (pProp != end)
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index 49653b4546cf..354f4b3ad96e 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -835,7 +835,7 @@ uno::Sequence< Reference< frame::XDispatch > > SAL_CALL SfxBaseController::query
sal_Int32 nCount = seqDescripts.getLength();
uno::Sequence< Reference< frame::XDispatch > > lDispatcher( nCount );
- std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(),
+ std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(),
[this](const frame::DispatchDescriptor& rDesc) -> Reference< frame::XDispatch > {
return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); });
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 1be88db77133..603d31d41b33 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -702,7 +702,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// the TransformItems function overwrite aProps
TransformItems( nId, *rReq.GetArgs(), aProps, GetInterface()->GetSlot(nId) );
- for ( auto& rProp : aProps )
+ for ( auto& rProp : asNonConstRange(aProps) )
{
if ( rProp.Name == "Copies" )
{