summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/core/table/swnewtable.cxx27
-rw-r--r--sw/source/core/table/swtable.cxx16
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx35
-rw-r--r--sw/source/core/text/SwGrammarMarkUp.cxx36
-rw-r--r--sw/source/core/text/itratr.cxx20
-rw-r--r--sw/source/core/text/porlay.cxx10
-rw-r--r--sw/source/core/text/txtfrm.cxx16
-rw-r--r--sw/source/core/text/wrong.cxx81
-rw-r--r--sw/source/core/tox/ToxTextGenerator.cxx6
-rw-r--r--sw/source/core/txtnode/atrftn.cxx5
-rw-r--r--sw/source/core/txtnode/modeltoviewhelper.cxx115
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx38
-rw-r--r--sw/source/core/txtnode/thints.cxx94
-rw-r--r--sw/source/core/undo/SwRewriter.cxx4
-rw-r--r--sw/source/core/undo/unnum.cxx6
-rw-r--r--sw/source/core/undo/unsort.cxx8
-rw-r--r--sw/source/core/undo/untbl.cxx10
-rw-r--r--sw/source/core/unocore/unochart.cxx25
-rw-r--r--sw/source/core/unocore/unoidx.cxx6
-rw-r--r--sw/source/core/unocore/unosrch.cxx15
-rw-r--r--sw/source/core/unocore/unostyle.cxx10
-rw-r--r--sw/source/core/view/viewsh.cxx4
22 files changed, 240 insertions, 347 deletions
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 5dff4890393d..d71edc38df84 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1347,18 +1347,16 @@ static sal_uInt16 lcl_CalculateSplitLineHeights( SwSplitLines &rCurr, SwSplitLin
rCurr.insert( rCurr.end(), nHeight );
pLines[ i - nFirst ] = nHeight;
}
- auto pSplit = aBoxes.begin();
- while( pSplit != aBoxes.end() )
+ for( const auto& rSplit : aBoxes )
{
- SwTwips nBase = pSplit->first <= nFirst ? 0 :
- pLines[ pSplit->first - nFirst - 1 ];
- SwTwips nDiff = pLines[ pSplit->second - nFirst ] - nBase;
+ SwTwips nBase = rSplit.first <= nFirst ? 0 :
+ pLines[ rSplit.first - nFirst - 1 ];
+ SwTwips nDiff = pLines[ rSplit.second - nFirst ] - nBase;
for( sal_uInt16 i = 1; i < nCnt; ++i )
{
SwTwips nSplit = nBase + ( i * nDiff ) / nCnt;
rNew.insert( nSplit );
}
- ++pSplit;
}
return nFirst;
}
@@ -1422,10 +1420,9 @@ bool SwTable::NewSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCn
aFndBox.DelFrames( *this );
SwTwips nLast = 0;
SwSplitLines::iterator pSplit = aSplitLines.begin();
- SwSplitLines::iterator pCurr = aRowLines.begin();
- while( pCurr != aRowLines.end() )
+ for( const auto& rCurr : aRowLines )
{
- while( pSplit != aSplitLines.end() && *pSplit < *pCurr )
+ while( pSplit != aSplitLines.end() && *pSplit < rCurr )
{
InsertSpannedRow( pDoc, nFirst, 1 );
SwTableLine* pRow = GetTabLines()[ nFirst ];
@@ -1438,16 +1435,15 @@ bool SwTable::NewSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCn
++pSplit;
++nFirst;
}
- if( pSplit != aSplitLines.end() && *pCurr == *pSplit )
+ if( pSplit != aSplitLines.end() && rCurr == *pSplit )
++pSplit;
SwTableLine* pRow = GetTabLines()[ nFirst ];
SwFrameFormat* pRowFormat = pRow->ClaimFrameFormat();
SwFormatFrameSize aFSz( pRowFormat->GetFrameSize() );
aFSz.SetHeightSizeType( ATT_MIN_SIZE );
- aFSz.SetHeight( *pCurr - nLast );
+ aFSz.SetHeight( rCurr - nLast );
pRowFormat->SetFormatAttr( aFSz );
- nLast = *pCurr;
- ++pCurr;
+ nLast = rCurr;
++nFirst;
}
}
@@ -1476,9 +1472,8 @@ bool SwTable::NewSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCn
aIndices.insert( i );
}
- std::set<size_t>::iterator pCurrBox = aIndices.begin();
- while( pCurrBox != aIndices.end() )
- lcl_UnMerge( *this, *rBoxes[*pCurrBox++], nCnt, bSameHeight );
+ for( const auto& rCurrBox : aIndices )
+ lcl_UnMerge( *this, *rBoxes[rCurrBox], nCnt, bSameHeight );
CHECK_TABLE( *this )
// update the layout
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index e77c7a657606..4054520e1f0f 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1086,8 +1086,8 @@ static void lcl_CalcNewWidths( std::list<sal_uInt16> &rSpanPos, ChangeList& rCha
if( pCurr != rChanges.end() && pCurr->first <= nPos &&
pCurr->first != pCurr->second )
{
- while( pSpan != rSpanPos.end() && *pSpan < nCurr )
- ++pSpan;
+ pSpan = std::find_if(pSpan, rSpanPos.end(),
+ [nCurr](const sal_uInt16 nSpan) { return nSpan >= nCurr; });
if( pSpan != rSpanPos.end() && *pSpan == nCurr )
{
aNewChanges.push_back( *pCurr );
@@ -1217,12 +1217,10 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew,
if( nCurr )
{
ChangeList aCopy;
- ChangeList::iterator pCop = aOldNew.begin();
sal_uInt16 nPos = 0;
- while( pCop != aOldNew.end() )
+ for( const auto& rCop : aOldNew )
{
- aCopy.push_back( *pCop );
- ++pCop;
+ aCopy.push_back( rCop );
aRowSpanPos.push_back( nPos++ );
}
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[nCurr],
@@ -1241,12 +1239,10 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew,
if( nCurr+1 < static_cast<sal_uInt16>(rLines.size()) )
{
ChangeList aCopy;
- ChangeList::iterator pCop = aOldNew.begin();
sal_uInt16 nPos = 0;
- while( pCop != aOldNew.end() )
+ for( const auto& rCop : aOldNew )
{
- aCopy.push_back( *pCop );
- ++pCop;
+ aCopy.push_back( rCop );
aRowSpanPos.push_back( nPos++ );
}
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[nCurr],
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 0416f62bcabb..b804369aaa07 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -110,10 +110,9 @@ void lcl_DBGCheckStack()
*/
sal_uInt16 nElement;
- std::vector< sal_uInt16 >::iterator aIter;
- for ( aIter = aStructStack.begin(); aIter != aStructStack.end(); ++aIter )
+ for ( const auto& rItem : aStructStack )
{
- nElement = *aIter;
+ nElement = rItem;
}
(void)nElement;
}
@@ -806,16 +805,12 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType )
SwRect aPorRect;
rInf.CalcRect( *pPor, &aPorRect );
const Point aPorCenter = aPorRect.Center();
- LinkIdMap::const_iterator aIter;
- for ( aIter = rLinkIdMap.begin(); aIter != rLinkIdMap.end(); ++aIter )
+ auto aIter = std::find_if(rLinkIdMap.begin(), rLinkIdMap.end(),
+ [&aPorCenter](const IdMapEntry& rEntry) { return rEntry.first.IsInside(aPorCenter); });
+ if (aIter != rLinkIdMap.end())
{
- const SwRect& rLinkRect = (*aIter).first;
- if ( rLinkRect.IsInside( aPorCenter ) )
- {
- sal_Int32 nLinkId = (*aIter).second;
- mpPDFExtOutDevData->SetStructureAttributeNumerical( vcl::PDFWriter::LinkAnnotation, nLinkId );
- break;
- }
+ sal_Int32 nLinkId = (*aIter).second;
+ mpPDFExtOutDevData->SetStructureAttributeNumerical( vcl::PDFWriter::LinkAnnotation, nLinkId );
}
}
}
@@ -2119,11 +2114,9 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
// LINKS FROM EDITENGINE
std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
- std::vector< vcl::PDFExtOutDevBookmarkEntry >::const_iterator aIBeg = rBookmarks.begin();
- const std::vector< vcl::PDFExtOutDevBookmarkEntry >::const_iterator aIEnd = rBookmarks.end();
- while ( aIBeg != aIEnd )
+ for ( const auto& rBookmark : rBookmarks )
{
- OUString aBookmarkName( aIBeg->aBookmark );
+ OUString aBookmarkName( rBookmark.aBookmark );
const bool bIntern = '#' == aBookmarkName[0];
if ( bIntern )
{
@@ -2142,24 +2135,22 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
if ( -1 != nDestPageNum )
{
tools::Rectangle aRect(SwRectToPDFRect(pCurrPage, rDestRect.SVRect()));
- if ( aIBeg->nLinkId != -1 )
+ if ( rBookmark.nLinkId != -1 )
{
// Destination Export
const sal_Int32 nDestId = pPDFExtOutDevData->CreateDest(aRect, nDestPageNum);
// Connect Link and Destination:
- pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, nDestId );
+ pPDFExtOutDevData->SetLinkDest( rBookmark.nLinkId, nDestId );
}
else
{
- pPDFExtOutDevData->DescribeRegisteredDest(aIBeg->nDestId, aRect, nDestPageNum);
+ pPDFExtOutDevData->DescribeRegisteredDest(rBookmark.nDestId, aRect, nDestPageNum);
}
}
}
else
- pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aBookmarkName );
-
- ++aIBeg;
+ pPDFExtOutDevData->SetLinkURL( rBookmark.nLinkId, aBookmarkName );
}
rBookmarks.clear();
}
diff --git a/sw/source/core/text/SwGrammarMarkUp.cxx b/sw/source/core/text/SwGrammarMarkUp.cxx
index a752619d8f81..3a007ce055d2 100644
--- a/sw/source/core/text/SwGrammarMarkUp.cxx
+++ b/sw/source/core/text/SwGrammarMarkUp.cxx
@@ -41,9 +41,8 @@ void SwGrammarMarkUp::MoveGrammar( sal_Int32 nPos, sal_Int32 nDiff )
Move( nPos, nDiff );
if( maSentence.empty() )
return;
- std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
- while( pIter != maSentence.end() && *pIter < nPos )
- ++pIter;
+ auto pIter = std::find_if(maSentence.begin(), maSentence.end(),
+ [nPos](const sal_Int32& rPos) { return rPos >= nPos; });
const sal_Int32 nEnd = nDiff < 0 ? nPos-nDiff : nPos;
while( pIter != maSentence.end() )
{
@@ -60,9 +59,8 @@ SwGrammarMarkUp* SwGrammarMarkUp::SplitGrammarList( sal_Int32 nSplitPos )
SwGrammarMarkUp* pNew = static_cast<SwGrammarMarkUp*>(SplitList( nSplitPos ));
if( maSentence.empty() )
return pNew;
- std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
- while( pIter != maSentence.end() && *pIter < nSplitPos )
- ++pIter;
+ auto pIter = std::find_if(maSentence.begin(), maSentence.end(),
+ [nSplitPos](const sal_Int32& rPos) { return rPos >= nSplitPos; });
if( pIter != maSentence.begin() )
{
if( !pNew ) {
@@ -82,11 +80,9 @@ void SwGrammarMarkUp::JoinGrammarList( SwGrammarMarkUp* pNext, sal_Int32 nInsert
{
if( pNext->maSentence.empty() )
return;
- std::vector< sal_Int32 >::iterator pIter = pNext->maSentence.begin();
- while( pIter != pNext->maSentence.end() )
+ for( auto& rPos : pNext->maSentence )
{
- *pIter = *pIter + nInsertPos;
- ++pIter;
+ rPos += nInsertPos;
}
maSentence.insert( maSentence.end(), pNext->maSentence.begin(), pNext->maSentence.end() );
}
@@ -106,9 +102,8 @@ void SwGrammarMarkUp::ClearGrammarList( sal_Int32 nSentenceEnd )
nStart = *pIter;
++pIter;
}
- std::vector< sal_Int32 >::iterator pLast = pIter;
- while( pLast != maSentence.end() && *pLast <= nSentenceEnd )
- ++pLast;
+ auto pLast = std::find_if(pIter, maSentence.end(),
+ [nSentenceEnd](const sal_Int32& rPos) { return rPos > nSentenceEnd; });
maSentence.erase( pIter, pLast );
RemoveEntry( nStart, nSentenceEnd );
SetInvalid( nSentenceEnd + 1, COMPLETE_STRING );
@@ -117,9 +112,8 @@ void SwGrammarMarkUp::ClearGrammarList( sal_Int32 nSentenceEnd )
void SwGrammarMarkUp::setSentence( sal_Int32 nStart )
{
- std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
- while( pIter != maSentence.end() && *pIter < nStart )
- ++pIter;
+ auto pIter = std::find_if(maSentence.begin(), maSentence.end(),
+ [nStart](const sal_Int32& rPos) { return rPos >= nStart; });
if( pIter == maSentence.end() || *pIter > nStart )
maSentence.insert( pIter, nStart );
}
@@ -128,9 +122,8 @@ sal_Int32 SwGrammarMarkUp::getSentenceStart( sal_Int32 nPos )
{
if( maSentence.empty() )
return 0;
- std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
- while( pIter != maSentence.end() && *pIter < nPos )
- ++pIter;
+ auto pIter = std::find_if(maSentence.begin(), maSentence.end(),
+ [nPos](const sal_Int32& rPos) { return rPos >= nPos; });
if( pIter != maSentence.begin() )
--pIter;
if( pIter != maSentence.end() && *pIter < nPos )
@@ -142,9 +135,8 @@ sal_Int32 SwGrammarMarkUp::getSentenceEnd( sal_Int32 nPos )
{
if( maSentence.empty() )
return COMPLETE_STRING;
- std::vector< sal_Int32 >::iterator pIter = maSentence.begin();
- while( pIter != maSentence.end() && *pIter <= nPos )
- ++pIter;
+ auto pIter = std::find_if(maSentence.begin(), maSentence.end(),
+ [nPos](const sal_Int32& rPos) { return rPos > nPos; });
if( pIter != maSentence.end() )
return *pIter;
return COMPLETE_STRING;
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 0533fae9be27..7e1c7e4e1bfb 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -606,20 +606,12 @@ static bool CanSkipOverRedline(SwRangeRedline const& rRedline,
// char formats must be *nominally* the same
if (pAttr->Which() == RES_TXTATR_CHARFMT)
{
- bool isFound(false);
- for (auto iter = activeCharFmts.begin(); iter != activeCharFmts.end(); ++iter)
- {
- if (**iter == *pAttr)
- {
- activeCharFmts.erase(iter);
- isFound = true;
- break;
- }
- }
- if (!isFound)
- {
- if (!isTheAnswerYes) return false;
- }
+ auto iter = std::find_if(activeCharFmts.begin(), activeCharFmts.end(),
+ [&pAttr](const SwTextAttr* pCharFmt) { return *pCharFmt == *pAttr; });
+ if (iter != activeCharFmts.end())
+ activeCharFmts.erase(iter);
+ else if (!isTheAnswerYes)
+ return false;
}
SfxItemSet const& rSet((pAttr->Which() == RES_TXTATR_CHARFMT)
? static_cast<SfxItemSet const&>(pAttr->GetCharFormat().GetCharFormat()->GetAttrSet())
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 307f28ab0f30..c309f6c3fe1d 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1372,13 +1372,13 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
// position and that we don't have "empty" changes.
sal_uInt8 nLastTyp = i18n::ScriptType::WEAK;
sal_Int32 nLastPos = 0;
- for (std::vector<ScriptChangeInfo>::const_iterator i2 = m_ScriptChanges.begin(); i2 != m_ScriptChanges.end(); ++i2)
+ for (const auto& rScriptChange : m_ScriptChanges)
{
- SAL_WARN_IF( nLastTyp == i2->type ||
- nLastPos >= i2->position,
+ SAL_WARN_IF( nLastTyp == rScriptChange.type ||
+ nLastPos >= rScriptChange.position,
"sw.core", "Heavy InitScriptType() confusion" );
- nLastPos = i2->position;
- nLastTyp = i2->type;
+ nLastPos = rScriptChange.position;
+ nLastTyp = rScriptChange.type;
}
#endif
}
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index b6b51c9c713b..e124fd73bc56 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -966,9 +966,9 @@ MapViewToModel(MergedPara const& rMerged, TextFrameIndex const i_nIndex)
{
sal_Int32 nIndex(i_nIndex);
sw::Extent const* pExtent(nullptr);
- for (auto it = rMerged.extents.begin(); it != rMerged.extents.end(); ++it)
+ for (const auto& rExt : rMerged.extents)
{
- pExtent = &*it;
+ pExtent = &rExt;
if (nIndex < (pExtent->nEnd - pExtent->nStart))
{
return std::make_pair(pExtent->pNode, pExtent->nStart + nIndex);
@@ -1680,23 +1680,23 @@ void UpdateMergedParaForMove(sw::MergedPara & rMerged,
std::vector<std::pair<sal_Int32, sal_Int32>> deleted;
sal_Int32 const nSourceEnd(nSourceStart + nLen);
sal_Int32 nLastEnd(0);
- for (auto it = rMerged.extents.begin(); it != rMerged.extents.end(); ++it)
+ for (const auto& rExt : rMerged.extents)
{
- if (it->pNode == &rNode)
+ if (rExt.pNode == &rNode)
{
sal_Int32 const nStart(std::max(nLastEnd, nSourceStart));
- sal_Int32 const nEnd(std::min(it->nStart, nSourceEnd));
+ sal_Int32 const nEnd(std::min(rExt.nStart, nSourceEnd));
if (nStart < nEnd)
{
deleted.emplace_back(nStart, nEnd);
}
- nLastEnd = it->nEnd;
- if (nSourceEnd <= it->nEnd)
+ nLastEnd = rExt.nEnd;
+ if (nSourceEnd <= rExt.nEnd)
{
break;
}
}
- else if (rNode.GetIndex() < it->pNode->GetIndex())
+ else if (rNode.GetIndex() < rExt.pNode->GetIndex())
{
break;
}
diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx
index d85cf9a99bdf..4e1668104f32 100644
--- a/sw/source/core/text/wrong.cxx
+++ b/sw/source/core/text/wrong.cxx
@@ -198,18 +198,12 @@ sal_uInt16 SwWrongList::GetWrongPos( sal_Int32 nValue ) const
// position of the first smart tag which covers nValue
if ( !maList[0].maType.isEmpty() || maList[0].mpSubList )
{
- for (std::vector<SwWrongArea>::const_iterator aIter(maList.begin()), aEnd(maList.end()); aIter != aEnd; ++aIter)
- {
- const sal_Int32 nSTPos = (*aIter).mnPos;
- const sal_Int32 nSTLen = (*aIter).mnLen;
- if ( nSTPos <= nValue && nValue < nSTPos + nSTLen )
- break;
- if ( nSTPos > nValue )
- break;
-
- ++nMin;
- }
- return nMin;
+ auto aIter = std::find_if(maList.begin(), maList.end(),
+ [nValue](const SwWrongArea& rST) {
+ return (rST.mnPos <= nValue && nValue < rST.mnPos + rST.mnLen)
+ || (rST.mnPos > nValue);
+ });
+ return static_cast<sal_uInt16>(std::distance(maList.begin(), aIter));
}
--nMax;
@@ -591,38 +585,36 @@ void SwWrongList::Remove(sal_uInt16 nIdx, sal_uInt16 nLen )
}
void SwWrongList::RemoveEntry( sal_Int32 nBegin, sal_Int32 nEnd ) {
- sal_uInt16 nDelPos = 0;
- sal_uInt16 nDel = 0;
- std::vector<SwWrongArea>::const_iterator aIter(maList.begin()), aEnd(maList.end());
- while( aIter != aEnd && (*aIter).mnPos < nBegin )
- {
- ++aIter;
- ++nDelPos;
- }
+ std::vector<SwWrongArea>::const_iterator aEnd(maList.end());
+ auto aDelIter = std::find_if(maList.cbegin(), aEnd,
+ [nBegin](const SwWrongArea& rST) { return rST.mnPos >= nBegin; });
+ auto aIter = aDelIter;
if( WRONGLIST_GRAMMAR == GetWrongListType() )
{
- while( aIter != aEnd && nBegin < nEnd && nEnd > (*aIter).mnPos )
+ if( nBegin < nEnd )
{
- ++aIter;
- ++nDel;
+ aIter = std::find_if(aDelIter, aEnd,
+ [nEnd](const SwWrongArea& rST) { return rST.mnPos >= nEnd; });
}
}
else
{
- while( aIter != aEnd && nBegin == (*aIter).mnPos && nEnd == (*aIter).mnPos +(*aIter).mnLen )
- {
- ++aIter;
- ++nDel;
- }
+ aIter = std::find_if(aDelIter, aEnd,
+ [nBegin, nEnd](const SwWrongArea& rST) {
+ return (rST.mnPos != nBegin) || ((rST.mnPos + rST.mnLen) != nEnd);
+ });
}
+ auto nDel = static_cast<sal_uInt16>(std::distance(aDelIter, aIter));
if( nDel )
+ {
+ auto nDelPos = static_cast<sal_uInt16>(std::distance(maList.cbegin(), aDelIter));
Remove( nDelPos, nDel );
+ }
}
bool SwWrongList::LookForEntry( sal_Int32 nBegin, sal_Int32 nEnd ) {
- std::vector<SwWrongArea>::iterator aIter = maList.begin();
- while( aIter != maList.end() && (*aIter).mnPos < nBegin )
- ++aIter;
+ auto aIter = std::find_if(maList.begin(), maList.end(),
+ [nBegin](const SwWrongArea& rST) { return rST.mnPos >= nBegin; });
return aIter != maList.end()
&& nBegin == (*aIter).mnPos
&& nEnd == (*aIter).mnPos + (*aIter).mnLen;
@@ -632,31 +624,14 @@ void SwWrongList::Insert( const OUString& rType,
css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag,
sal_Int32 nNewPos, sal_Int32 nNewLen )
{
- std::vector<SwWrongArea>::iterator aIter = maList.begin();
-
- while ( aIter != maList.end() )
+ auto aIter = std::find_if(maList.begin(), maList.end(),
+ [nNewPos](const SwWrongArea& rST) { return nNewPos <= rST.mnPos; });
+ if ( aIter != maList.end() && nNewPos == (*aIter).mnPos )
{
const sal_Int32 nSTPos = (*aIter).mnPos;
- if ( nNewPos < nSTPos )
- {
- // insert at current position
- break;
- }
- else if ( nNewPos == nSTPos )
- {
- while ( aIter != maList.end() && (*aIter).mnPos == nSTPos )
- {
- if ( nNewLen < (*aIter).mnLen )
- {
- // insert at current position
- break;
- }
- ++aIter;
- }
- break;
- }
- ++aIter;
+ aIter = std::find_if(aIter, maList.end(),
+ [nSTPos, nNewLen](const SwWrongArea& rST) { return rST.mnPos != nSTPos || nNewLen < rST.mnLen; });
}
maList.insert(aIter, SwWrongArea( rType, meType, xPropertyBag, nNewPos, nNewLen) );
diff --git a/sw/source/core/tox/ToxTextGenerator.cxx b/sw/source/core/tox/ToxTextGenerator.cxx
index 4734b1e97bde..43df06ad2e07 100644
--- a/sw/source/core/tox/ToxTextGenerator.cxx
+++ b/sw/source/core/tox/ToxTextGenerator.cxx
@@ -178,11 +178,9 @@ ToxTextGenerator::GenerateText(SwDoc* pDoc, const std::vector<std::unique_ptr<Sw
// create an enumerator
// #i21237#
SwFormTokens aPattern = mToxForm.GetPattern(nLvl);
- SwFormTokens::iterator aIt = aPattern.begin();
// remove text from node
- while(aIt != aPattern.end()) // #i21237#
+ for(const auto& aToken : aPattern) // #i21237#
{
- SwFormToken aToken = *aIt; // #i21237#
sal_Int32 nStartCharStyle = rText.getLength();
switch( aToken.eTokenType )
{
@@ -259,8 +257,6 @@ ToxTextGenerator::GenerateText(SwDoc* pDoc, const std::vector<std::unique_ptr<Sw
rText.getLength(), SetAttrMode::DONTEXPAND );
}
}
-
- ++aIt; // #i21237#
}
pTOXNd->SetAttr( aTStops );
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index cc0e6f0ea12a..9ab598e1ef5f 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -96,11 +96,10 @@ namespace {
rLowestUnusedNums.reserve(numRequired);
sal_uInt16 newNum = 0;
- std::set<sal_uInt16>::iterator it;
//Start by using numbers from gaps in rUsedNums
- for( it = rUsedNums.begin(); it != rUsedNums.end(); ++it )
+ for( const auto& rNum : rUsedNums )
{
- while ( newNum < *it )
+ while ( newNum < rNum )
{
rLowestUnusedNums.push_back( newNum++ );
if ( --numRequired == 0)
diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx
index 8c2b2c078996..e2776a8ebe36 100644
--- a/sw/source/core/txtnode/modeltoviewhelper.cxx
+++ b/sw/source/core/txtnode/modeltoviewhelper.cxx
@@ -182,10 +182,8 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode)
std::vector<sw::mark::IFieldmark*> aDropDowns =
rNode.GetDoc()->getIDocumentMarkAccess()->getDropDownsFor(aPaM);
- for (std::vector<sw::mark::IFieldmark*>::iterator aI = aDropDowns.begin(), aEnd = aDropDowns.end();
- aI != aEnd; ++aI)
+ for (sw::mark::IFieldmark *pMark : aDropDowns)
{
- sw::mark::IFieldmark *pMark = *aI;
const sal_Int32 nDummyCharPos = pMark->GetMarkPos().nContent.GetIndex()-1;
if (aHiddenMulti.IsSelected(nDummyCharPos))
continue;
@@ -207,15 +205,15 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode)
//store the end of each range in the model and where that end of range
//maps to in the view
sal_Int32 nOffset = 0;
- for (std::vector<block>::iterator i = aBlocks.begin(); i != aBlocks.end(); ++i)
+ for (const auto& rBlock : aBlocks)
{
- const sal_Int32 nBlockLen = i->m_nLen;
+ const sal_Int32 nBlockLen = rBlock.m_nLen;
if (!nBlockLen)
continue;
- const sal_Int32 nBlockStart = i->m_nStart;
+ const sal_Int32 nBlockStart = rBlock.m_nStart;
const sal_Int32 nBlockEnd = nBlockStart + nBlockLen;
- if (!i->m_bVisible)
+ if (!rBlock.m_bVisible)
{
sal_Int32 const modelBlockPos(nBlockEnd);
sal_Int32 const viewBlockPos(nBlockStart + nOffset);
@@ -226,16 +224,16 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode)
}
else
{
- for (FieldResultSet::iterator j = i->m_aAttrs.begin(); j != i->m_aAttrs.end(); ++j)
+ for (const auto& rAttr : rBlock.m_aAttrs)
{
- sal_Int32 const modelFieldPos(j->m_nFieldPos);
- sal_Int32 const viewFieldPos(j->m_nFieldPos + nOffset);
+ sal_Int32 const modelFieldPos(rAttr.m_nFieldPos);
+ sal_Int32 const viewFieldPos(rAttr.m_nFieldPos + nOffset);
m_aMap.emplace_back(modelFieldPos, viewFieldPos, true );
- m_aRetText = m_aRetText.replaceAt(viewFieldPos, 1, j->m_sExpand);
- nOffset += j->m_sExpand.getLength() - 1;
+ m_aRetText = m_aRetText.replaceAt(viewFieldPos, 1, rAttr.m_sExpand);
+ nOffset += rAttr.m_sExpand.getLength() - 1;
- switch (j->m_eType)
+ switch (rAttr.m_eType)
{
case FieldResult::FIELD:
m_FieldPositions.push_back(viewFieldPos);
@@ -260,23 +258,20 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode)
sal_Int32 ModelToViewHelper::ConvertToViewPosition( sal_Int32 nModelPos ) const
{
// Search for entry after nPos:
- ConversionMap::const_iterator aIter;
-
- for ( aIter = m_aMap.begin(); aIter != m_aMap.end(); ++aIter )
+ auto aIter = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [nModelPos](const ConversionMapEntry& rEntry) { return rEntry.m_nModelPos >= nModelPos; });
+ if (aIter != m_aMap.end())
{
- if (aIter->m_nModelPos >= nModelPos)
- {
- //if it's an invisible portion, map all contained positions
- //to the anchor viewpos
- if (!aIter->m_bVisible)
- return aIter->m_nViewPos;
-
- //if it's a visible portion, then the view position is the anchor
- //viewpos - the offset of the input modelpos from the anchor
- //modelpos
- const sal_Int32 nOffsetFromEnd = aIter->m_nModelPos - nModelPos;
- return aIter->m_nViewPos - nOffsetFromEnd;
- }
+ //if it's an invisible portion, map all contained positions
+ //to the anchor viewpos
+ if (!aIter->m_bVisible)
+ return aIter->m_nViewPos;
+
+ //if it's a visible portion, then the view position is the anchor
+ //viewpos - the offset of the input modelpos from the anchor
+ //modelpos
+ const sal_Int32 nOffsetFromEnd = aIter->m_nModelPos - nModelPos;
+ return aIter->m_nViewPos - nOffsetFromEnd;
}
return nModelPos;
@@ -290,46 +285,40 @@ ModelToViewHelper::ModelPosition ModelToViewHelper::ConvertToModelPosition( sal_
aRet.mnPos = nViewPos;
// Search for entry after nPos:
- ConversionMap::const_iterator aIter;
- for ( aIter = m_aMap.begin(); aIter != m_aMap.end(); ++aIter )
- {
- if (aIter->m_nViewPos > nViewPos)
- {
- const sal_Int32 nPosModel = aIter->m_nModelPos;
- const sal_Int32 nPosExpand = aIter->m_nViewPos;
+ auto aIter = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [nViewPos](const ConversionMapEntry& rEntry) { return rEntry.m_nViewPos > nViewPos; });
- // If nViewPos is in front of first field, we are finished.
- if ( aIter == m_aMap.begin() )
- break;
+ // If nViewPos is in front of first field, we are finished.
+ if (aIter != m_aMap.end() && aIter != m_aMap.begin())
+ {
+ const sal_Int32 nPosModel = aIter->m_nModelPos;
+ const sal_Int32 nPosExpand = aIter->m_nViewPos;
- --aIter;
+ --aIter;
- // nPrevPosModel is the field position
- const sal_Int32 nPrevPosModel = aIter->m_nModelPos;
- const sal_Int32 nPrevPosExpand = aIter->m_nViewPos;
+ // nPrevPosModel is the field position
+ const sal_Int32 nPrevPosModel = aIter->m_nModelPos;
+ const sal_Int32 nPrevPosExpand = aIter->m_nViewPos;
- const sal_Int32 nLengthModel = nPosModel - nPrevPosModel;
- const sal_Int32 nLengthExpand = nPosExpand - nPrevPosExpand;
+ const sal_Int32 nLengthModel = nPosModel - nPrevPosModel;
+ const sal_Int32 nLengthExpand = nPosExpand - nPrevPosExpand;
- const sal_Int32 nFieldLengthExpand = nLengthExpand - nLengthModel + 1;
- const sal_Int32 nFieldEndExpand = nPrevPosExpand + nFieldLengthExpand;
+ const sal_Int32 nFieldLengthExpand = nLengthExpand - nLengthModel + 1;
+ const sal_Int32 nFieldEndExpand = nPrevPosExpand + nFieldLengthExpand;
- // Check if nPos is outside of field:
- if ( nFieldEndExpand <= nViewPos )
- {
- // nPos is outside of field:
- const sal_Int32 nDistToField = nViewPos - nFieldEndExpand + 1;
- aRet.mnPos = nPrevPosModel + nDistToField;
- }
- else
- {
- // nViewPos is inside a field:
- aRet.mnPos = nPrevPosModel;
- aRet.mnSubPos = nViewPos - nPrevPosExpand;
- aRet.mbIsField = true;
- }
-
- break;
+ // Check if nPos is outside of field:
+ if ( nFieldEndExpand <= nViewPos )
+ {
+ // nPos is outside of field:
+ const sal_Int32 nDistToField = nViewPos - nFieldEndExpand + 1;
+ aRet.mnPos = nPrevPosModel + nDistToField;
+ }
+ else
+ {
+ // nViewPos is inside a field:
+ aRet.mnPos = nPrevPosModel;
+ aRet.mnSubPos = nViewPos - nPrevPosExpand;
+ aRet.mbIsField = true;
}
}
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index b0e8086a2206..c9b419dd69ea 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1305,16 +1305,13 @@ void SwTextNode::Update(
{
pCollector.reset( new SwpHts );
}
- for(SwpHts::iterator it = pCollector->begin(); it != pCollector->end(); ++it)
+ auto it = std::find_if(pCollector->begin(), pCollector->end(),
+ [nWhich](const SwTextAttr *pTmp) { return nWhich == pTmp->Which(); });
+ if (it != pCollector->end())
{
- SwTextAttr *pTmp = *it;
- if( nWhich == pTmp->Which() )
- {
- pCollector->erase( it );
- SwTextAttr::Destroy( pTmp,
- GetDoc()->GetAttrPool() );
- break;
- }
+ SwTextAttr *pTmp = *it;
+ pCollector->erase( it );
+ SwTextAttr::Destroy( pTmp, GetDoc()->GetAttrPool() );
}
SwTextAttr * const pTmp =
MakeTextAttr( *GetDoc(),
@@ -1441,9 +1438,9 @@ void SwTextNode::Update(
#if OSL_DEBUG_LEVEL > 0
std::vector<SwFrameFormat*> checkFormats;
const SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats();
- for (SwFrameFormats::const_iterator pFormat = rFormats.begin(); pFormat != rFormats.end(); ++pFormat)
+ for (auto& rpFormat : rFormats)
{
- const SwFormatAnchor& rAnchor = (*pFormat)->GetAnchor();
+ const SwFormatAnchor& rAnchor = rpFormat->GetAnchor();
const SwPosition* pContentAnchor = rAnchor.GetContentAnchor();
if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR && pContentAnchor)
{
@@ -1455,7 +1452,7 @@ void SwTextNode::Update(
#if 0
rEndIdx.Assign(&aTmpIdxReg, rEndIdx.GetIndex());
#endif
- checkFormats.push_back( *pFormat );
+ checkFormats.push_back( rpFormat );
}
}
}
@@ -4987,17 +4984,16 @@ namespace {
{
bool bRemoveFromList( false );
{
- std::vector<sal_uInt16>::const_iterator it;
- for ( it = rWhichArr.begin(); it != rWhichArr.end(); ++it)
+ for (const auto& rWhich : rWhichArr)
{
// RES_PARATR_NUMRULE and RES_PARATR_LIST_ID
- if ( *it == RES_PARATR_NUMRULE )
+ if ( rWhich == RES_PARATR_NUMRULE )
{
bRemoveFromList = bRemoveFromList ||
mrTextNode.GetNumRule() != nullptr;
mbListStyleOrIdReset = true;
}
- else if ( *it == RES_PARATR_LIST_ID )
+ else if ( rWhich == RES_PARATR_LIST_ID )
{
bRemoveFromList = bRemoveFromList ||
( mrTextNode.GetpSwAttrSet() &&
@@ -5007,7 +5003,7 @@ namespace {
}
// #i70748#
// RES_PARATR_OUTLINELEVEL
- else if ( *it == RES_PARATR_OUTLINELEVEL )
+ else if ( rWhich == RES_PARATR_OUTLINELEVEL )
{
mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
}
@@ -5016,19 +5012,19 @@ namespace {
{
// RES_PARATR_LIST_LEVEL
mbUpdateListLevel = mbUpdateListLevel ||
- ( *it == RES_PARATR_LIST_LEVEL &&
+ ( rWhich == RES_PARATR_LIST_LEVEL &&
mrTextNode.HasAttrListLevel() );
// RES_PARATR_LIST_ISRESTART and RES_PARATR_LIST_RESTARTVALUE
mbUpdateListRestart = mbUpdateListRestart ||
- ( *it == RES_PARATR_LIST_ISRESTART &&
+ ( rWhich == RES_PARATR_LIST_ISRESTART &&
mrTextNode.IsListRestart() ) ||
- ( *it == RES_PARATR_LIST_RESTARTVALUE &&
+ ( rWhich == RES_PARATR_LIST_RESTARTVALUE &&
mrTextNode.HasAttrListRestartValue() );
// RES_PARATR_LIST_ISCOUNTED
mbUpdateListCount = mbUpdateListCount ||
- ( *it == RES_PARATR_LIST_ISCOUNTED &&
+ ( rWhich == RES_PARATR_LIST_ISCOUNTED &&
!mrTextNode.IsCountedInList() );
}
}
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 024824f60733..40f4ab7ccc29 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -444,20 +444,18 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
// so any hint in OverlappingExisting can be split at most by one hint
// in SplitNew, or even not at all (this is not true for existing hints
// that go _around_ new hint, which is the reason d'^etre for pass 4)
- for (NestList_t::iterator itOther = OverlappingExisting.begin();
- itOther != OverlappingExisting.end(); ++itOther)
+ for (auto& rpOther : OverlappingExisting)
{
- const sal_Int32 nOtherStart( (*itOther)->GetStart() );
- const sal_Int32 nOtherEnd ( *(*itOther)->GetEnd() );
+ const sal_Int32 nOtherStart( rpOther->GetStart() );
+ const sal_Int32 nOtherEnd ( *rpOther->GetEnd() );
- for (NestList_t::iterator itNew = SplitNew.begin();
- itNew != SplitNew.end(); ++itNew)
+ for (const auto& rpNew : SplitNew)
{
- const sal_Int32 nSplitNewStart( (*itNew)->GetStart() );
- const sal_Int32 nSplitNewEnd ( *(*itNew)->GetEnd() );
+ const sal_Int32 nSplitNewStart( rpNew->GetStart() );
+ const sal_Int32 nSplitNewEnd ( *rpNew->GetEnd() );
// 4 cases: within, around, overlap l, overlap r, (OTHER: no action)
const bool bRemoveOverlap(
- !bNewSelfNestable && (nNewWhich == (*itOther)->Which()) );
+ !bNewSelfNestable && (nNewWhich == rpOther->Which()) );
switch (ComparePosition(nSplitNewStart, nSplitNewEnd,
nOtherStart, nOtherEnd))
@@ -476,9 +474,9 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
break;
case SwComparePosition::OverlapBefore:
{
- Delete( *itOther ); // this also does NoteInHistory!
- (*itOther)->GetStart() = nSplitNewEnd;
- InsertNesting( **itOther );
+ Delete( rpOther ); // this also does NoteInHistory!
+ rpOther->GetStart() = nSplitNewEnd;
+ InsertNesting( *rpOther );
if (!bRemoveOverlap)
{
if ( MAX_HINTS <= Count() )
@@ -487,7 +485,7 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
return false;
}
SwTextAttrNesting * const pOtherLeft(
- MakeTextAttrNesting( rNode, **itOther,
+ MakeTextAttrNesting( rNode, *rpOther,
nOtherStart, nSplitNewEnd ) );
InsertNesting( *pOtherLeft );
}
@@ -495,9 +493,9 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
break;
case SwComparePosition::OverlapBehind:
{
- Delete( *itOther ); // this also does NoteInHistory!
- *(*itOther)->GetEnd() = nSplitNewStart;
- InsertNesting( **itOther );
+ Delete( rpOther ); // this also does NoteInHistory!
+ *rpOther->GetEnd() = nSplitNewStart;
+ InsertNesting( *rpOther );
if (!bRemoveOverlap)
{
if ( MAX_HINTS <= Count() )
@@ -506,7 +504,7 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
return false;
}
SwTextAttrNesting * const pOtherRight(
- MakeTextAttrNesting( rNode, **itOther,
+ MakeTextAttrNesting( rNode, *rpOther,
nSplitNewStart, nOtherEnd ) );
InsertNesting( *pOtherRight );
}
@@ -525,26 +523,24 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
}
// pass 3: insert new hints
- for (NestList_t::iterator iter = SplitNew.begin();
- iter != SplitNew.end(); ++iter)
+ for (const auto& rpHint : SplitNew)
{
- InsertNesting(**iter);
+ InsertNesting(*rpHint);
}
// pass 4: handle overwritten hints
// RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY should displace attributes
// of the same kind.
- for (NestList_t::iterator itOther = OverwrittenExisting.begin();
- itOther != OverwrittenExisting.end(); ++itOther)
+ for (auto& rpOther : OverwrittenExisting)
{
- const sal_Int32 nOtherStart( (*itOther)->GetStart() );
- const sal_Int32 nOtherEnd ( *(*itOther)->GetEnd() );
+ const sal_Int32 nOtherStart( rpOther->GetStart() );
+ const sal_Int32 nOtherEnd ( *rpOther->GetEnd() );
// overwritten portion is given by start/end of inserted hint
if ((nNewStart <= nOtherStart) && (nOtherEnd <= nNewEnd))
{
- Delete(*itOther);
- rNode.DestroyAttr( *itOther );
+ Delete(rpOther);
+ rNode.DestroyAttr( rpOther );
}
else
{
@@ -553,24 +549,24 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
// now a RUBY is inserted within the META => the existing RUBY is split:
// here it is not possible to simply insert the left/right fragment
// of the existing RUBY because they <em>overlap</em> with the META!
- Delete( *itOther ); // this also does NoteInHistory!
+ Delete( rpOther ); // this also does NoteInHistory!
if (nNewEnd < nOtherEnd)
{
SwTextAttrNesting * const pOtherRight(
MakeTextAttrNesting(
- rNode, **itOther, nNewEnd, nOtherEnd ) );
+ rNode, *rpOther, nNewEnd, nOtherEnd ) );
bool const bSuccess( TryInsertNesting(rNode, *pOtherRight) );
SAL_WARN_IF(!bSuccess, "sw.core", "recursive call 1 failed?");
}
if (nOtherStart < nNewStart)
{
- *(*itOther)->GetEnd() = nNewStart;
- bool const bSuccess( TryInsertNesting(rNode, **itOther) );
+ *rpOther->GetEnd() = nNewStart;
+ bool const bSuccess( TryInsertNesting(rNode, *rpOther) );
SAL_WARN_IF(!bSuccess, "sw.core", "recursive call 2 failed?");
}
else
{
- rNode.DestroyAttr(*itOther);
+ rNode.DestroyAttr(rpOther);
}
}
}
@@ -657,10 +653,10 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
}
// Insert the newly created attributes:
- for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter )
+ for ( const auto& rpHint : aInsDelHints )
{
- Insert( *aIter );
- NoteInHistory( *aIter, true );
+ Insert( rpHint );
+ NoteInHistory( rpHint, true );
}
}
@@ -736,13 +732,12 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
// This should ensure, that pNewHint comes behind the already present
// character style
sal_uInt16 nCharStyleCount = 0;
- aIter = aInsDelHints.begin();
- while ( aIter != aInsDelHints.end() )
+ for ( const auto& rpHint : aInsDelHints )
{
- if ( RES_TXTATR_CHARFMT == (*aIter)->Which() )
+ if ( RES_TXTATR_CHARFMT == rpHint->Which() )
{
// #i74589#
- const SwFormatCharFormat& rOtherCharFormat = (*aIter)->GetCharFormat();
+ const SwFormatCharFormat& rOtherCharFormat = rpHint->GetCharFormat();
const SwFormatCharFormat& rThisCharFormat = rNewHint.GetCharFormat();
const bool bSameCharFormat = rOtherCharFormat.GetCharFormat() == rThisCharFormat.GetCharFormat();
@@ -754,8 +749,8 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
bSameCharFormat ) )
{
// Remove old hint
- Delete( *aIter );
- rNode.DestroyAttr( *aIter );
+ Delete( rpHint );
+ rNode.DestroyAttr( rpHint );
}
else
++nCharStyleCount;
@@ -764,8 +759,8 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
{
// remove all attributes from auto styles, which are explicitly set in
// the new character format:
- OSL_ENSURE( RES_TXTATR_AUTOFMT == (*aIter)->Which(), "AUTOSTYLES - Misc trouble" );
- SwTextAttr* pOther = *aIter;
+ OSL_ENSURE( RES_TXTATR_AUTOFMT == rpHint->Which(), "AUTOSTYLES - Misc trouble" );
+ SwTextAttr* pOther = rpHint;
std::shared_ptr<SfxItemSet> pOldStyle = static_cast<const SwFormatAutoFormat&>(pOther->GetAttr()).GetStyleHandle();
// For each attribute in the automatic style check if it
@@ -800,7 +795,6 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
NoteInHistory( pNewAttr, true );
}
}
- ++aIter;
}
// If there is no current hint and start and end of rNewHint
@@ -824,14 +818,12 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
// Find the current autostyle. Mix attributes if necessary.
SwTextAttr* pCurrentAutoStyle = nullptr;
SwTextAttr* pCurrentCharFormat = nullptr;
- aIter = aInsDelHints.begin();
- while ( aIter != aInsDelHints.end() )
- {
- if ( RES_TXTATR_AUTOFMT == (*aIter)->Which() )
- pCurrentAutoStyle = *aIter;
- else if ( RES_TXTATR_CHARFMT == (*aIter)->Which() )
- pCurrentCharFormat = *aIter;
- ++aIter;
+ for ( const auto& rpHint : aInsDelHints )
+ {
+ if ( RES_TXTATR_AUTOFMT == rpHint->Which() )
+ pCurrentAutoStyle = rpHint;
+ else if ( RES_TXTATR_CHARFMT == rpHint->Which() )
+ pCurrentCharFormat = rpHint;
}
std::shared_ptr<SfxItemSet> pNewStyle = static_cast<const SwFormatAutoFormat&>(rNewHint.GetAttr()).GetStyleHandle();
diff --git a/sw/source/core/undo/SwRewriter.cxx b/sw/source/core/undo/SwRewriter.cxx
index cd63f3e551a8..22105f0a2aa8 100644
--- a/sw/source/core/undo/SwRewriter.cxx
+++ b/sw/source/core/undo/SwRewriter.cxx
@@ -46,9 +46,9 @@ OUString SwRewriter::Apply(const OUString & rStr) const
{
OUString aResult = rStr;
- for (std::vector<SwRewriteRule>::const_iterator aIt = mRules.begin(); aIt != mRules.end(); ++aIt)
+ for (const auto& rRule : mRules)
{
- aResult = aResult.replaceAll(GetPlaceHolder(aIt->first), aIt->second);
+ aResult = aResult.replaceAll(GetPlaceHolder(rRule.first), rRule.second);
}
return aResult;
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index 309c37803c98..480c9008f0bf 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -172,11 +172,11 @@ void SwUndoDelNum::UndoImpl(::sw::UndoRedoContext & rContext)
pHistory->TmpRollback( &rDoc, 0 );
pHistory->SetTmpEnd( pHistory->Count() );
- for( std::vector<NodeLevel>::const_iterator i = aNodes.begin(); i != aNodes.end(); ++i )
+ for( const auto& rNode : aNodes )
{
- SwTextNode* pNd = rDoc.GetNodes()[ i->index ]->GetTextNode();
+ SwTextNode* pNd = rDoc.GetNodes()[ rNode.index ]->GetTextNode();
OSL_ENSURE( pNd, "Where has the TextNode gone?" );
- pNd->SetAttrListLevel( i->level );
+ pNd->SetAttrListLevel( rNode.level );
if( pNd->GetCondFormatColl() )
pNd->ChkCondColl();
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index e3c640c3eca2..ac354d889be4 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -145,8 +145,8 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
SwMoveFlags::DEFAULT);
}
// delete indices
- for(SwUndoSortList::const_iterator it = aIdxList.begin(); it != aIdxList.end(); ++it)
- delete *it;
+ for(auto& rpIdx : aIdxList)
+ delete rpIdx;
aIdxList.clear();
SetPaM(rPam, true);
}
@@ -220,8 +220,8 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
SwMoveFlags::DEFAULT);
}
// delete indices
- for(SwUndoSortList::const_iterator it = aIdxList.begin(); it != aIdxList.end(); ++it)
- delete *it;
+ for(auto& rpIdx : aIdxList)
+ delete rpIdx;
aIdxList.clear();
SetPaM(rPam, true);
SwTextNode const*const pTNd = rPam.GetNode().GetTextNode();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index aa4ff1cfdcf4..d1d349ae9615 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1811,10 +1811,9 @@ void SwUndoTableNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
CHECK_TABLE( pTableNd->GetTable() )
SwSelBoxes aSelBoxes;
- for (std::set<sal_uLong>::iterator it = m_Boxes.begin();
- it != m_Boxes.end(); ++it)
+ for (const auto& rBox : m_Boxes)
{
- SwTableBox* pBox = pTableNd->GetTable().GetTableBox( *it );
+ SwTableBox* pBox = pTableNd->GetTable().GetTableBox( rBox );
aSelBoxes.insert( pBox );
}
@@ -1962,10 +1961,9 @@ CHECKTABLE(pTableNd->GetTable())
SwSelBoxes aSelBoxes;
SwTextFormatColl* pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD );
- std::set<sal_uLong>::iterator it;
- for (it = m_Boxes.begin(); it != m_Boxes.end(); ++it)
+ for (const auto& rBox : m_Boxes)
{
- aIdx = *it;
+ aIdx = rBox;
SwStartNode* pSttNd = rDoc.GetNodes().MakeTextSection( aIdx,
SwTableBoxStartNode, pColl );
pBox = new SwTableBox( static_cast<SwTableBoxFormat*>(pCpyBox->GetFrameFormat()), *pSttNd,
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index b12ddb64987e..87584578da2c 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1396,11 +1396,9 @@ void SAL_CALL SwChartDataProvider::dispose( )
if (bMustDispose)
{
// dispose all data-sequences
- Map_Set_DataSequenceRef_t::iterator aIt( aDataSequences.begin() );
- while (aIt != aDataSequences.end())
+ for (auto& rEntry : aDataSequences)
{
- DisposeAllDataSequences( (*aIt).first );
- ++aIt;
+ DisposeAllDataSequences( rEntry.first );
}
// release all references to data-sequences
aDataSequences.clear();
@@ -1461,17 +1459,15 @@ void SwChartDataProvider::InvalidateTable( const SwTable *pTable )
pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
const Set_DataSequenceRef_t &rSet = aDataSequences[ pTable ];
- Set_DataSequenceRef_t::const_iterator aIt( rSet.begin() );
- while (aIt != rSet.end())
+ for (const auto& rItem : rSet)
{
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
uno::Reference< util::XModifiable > xRef( xTemp, uno::UNO_QUERY );
if (xRef.is())
{
// mark the sequence as 'dirty' and notify listeners
xRef->setModified( true );
}
- ++aIt;
}
}
}
@@ -1545,17 +1541,14 @@ void SwChartDataProvider::DisposeAllDataSequences( const SwTable *pTable )
//! would become invalid.
const Set_DataSequenceRef_t aSet( aDataSequences[ pTable ] );
- Set_DataSequenceRef_t::const_iterator aIt( aSet.begin() );
- Set_DataSequenceRef_t::const_iterator aEndIt( aSet.end() );
- while (aIt != aEndIt)
+ for (const auto& rItem : aSet)
{
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
uno::Reference< lang::XComponent > xRef( xTemp, uno::UNO_QUERY );
if (xRef.is())
{
xRef->dispose();
}
- ++aIt;
}
}
}
@@ -1619,10 +1612,9 @@ void SwChartDataProvider::AddRowCols(
// iterate over all data-sequences for the table
const Set_DataSequenceRef_t &rSet = aDataSequences[ &rTable ];
- Set_DataSequenceRef_t::const_iterator aIt( rSet.begin() );
- while (aIt != rSet.end())
+ for (const auto& rItem : rSet)
{
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
uno::Reference< chart2::data::XTextualDataSequence > xRef( xTemp, uno::UNO_QUERY );
if (xRef.is())
{
@@ -1658,7 +1650,6 @@ void SwChartDataProvider::AddRowCols(
}
}
}
- ++aIt;
}
}
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 9f2eae93fbed..ab2bae1d8aeb 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -2933,17 +2933,15 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex)
// #i21237#
SwFormTokens aPattern = rTOXBase.GetTOXForm().
GetPattern(static_cast<sal_uInt16>(nIndex));
- SwFormTokens::iterator aIt = aPattern.begin();
sal_Int32 nTokenCount = 0;
uno::Sequence< beans::PropertyValues > aRetSeq;
OUString aProgCharStyle;
- while(aIt != aPattern.end()) // #i21237#
+ for(const SwFormToken& aToken : aPattern) // #i21237#
{
nTokenCount++;
aRetSeq.realloc(nTokenCount);
beans::PropertyValues* pTokenProps = aRetSeq.getArray();
- SwFormToken aToken = *aIt; // #i21237#
uno::Sequence< beans::PropertyValue >& rCurTokenSeq =
pTokenProps[nTokenCount-1];
@@ -3157,8 +3155,6 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex)
default:
;
}
-
- ++aIt; // #i21237#
}
uno::Any aRet;
diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx
index 62aaccb29819..87f342d231d2 100644
--- a/sw/source/core/unocore/unosrch.cxx
+++ b/sw/source/core/unocore/unosrch.cxx
@@ -80,15 +80,12 @@ void SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::Property
const sal_uInt32 nLen = aSearchAttribs.getLength();
for(sal_uInt32 i = 0; i < nLen; ++i)
{
- sal_uInt32 nIndex = 0;
- PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
- while(pProps[i].Name != aIt->sName)
- {
- ++aIt;
- nIndex++;
- if( aIt == aPropertyEntries.end() )
- throw beans::UnknownPropertyException();
- }
+ const OUString& sName = pProps[i].Name;
+ auto aIt = std::find_if(aPropertyEntries.begin(), aPropertyEntries.end(),
+ [&sName](const SfxItemPropertyNamedEntry& rProp) { return rProp.sName == sName; });
+ if( aIt == aPropertyEntries.end() )
+ throw beans::UnknownPropertyException();
+ auto nIndex = static_cast<sal_uInt32>(std::distance(aPropertyEntries.begin(), aIt));
pValueArr[nIndex].reset( new beans::PropertyValue(pProps[i]) );
}
}
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 35a3eaefda8c..55500a7eab90 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -4249,17 +4249,15 @@ uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties()
// TODO: Optimize - and fix! the old iteration filled each WhichId
// only once but there are more properties than WhichIds
- PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
- while( aIt != aPropVector.end() )
+ for( const auto& rProp : aPropVector )
{
- if ( aIt->nWID == nWID )
+ if ( rProp.nWID == nWID )
{
beans::PropertyValue aPropertyValue;
- aPropertyValue.Name = aIt->sName;
- pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
+ aPropertyValue.Name = rProp.sName;
+ pItem->QueryValue( aPropertyValue.Value, rProp.nMemberId );
aPropertyVector.push_back( aPropertyValue );
}
- ++aIt;
}
pItem = aIter.NextItem();
}
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 4f38a4d4041e..31f7c64712fb 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1871,9 +1871,9 @@ void SwViewShell::Paint(vcl::RenderContext& rRenderContext, const tools::Rectang
RectangleVector aRectangles;
aRegion.GetRegionRectangles(aRectangles);
- for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
+ for(const auto& rRectangle : aRectangles)
{
- Imp()->AddPaintRect(*aRectIter);
+ Imp()->AddPaintRect(rRectangle);
}
//RegionHandle hHdl( aRegion.BeginEnumRects() );