summaryrefslogtreecommitdiff
path: root/sw/source/core/edit/edlingu.cxx
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-11-14 00:57:07 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-14 09:58:55 +0100
commit25622f29b4003307d2ba780ff1232d8b7cdafa35 (patch)
treead15c747685e803deeb5fffd209ae0b5992ac87a /sw/source/core/edit/edlingu.cxx
parent638d619866784510dcbf0cadb6eb251208489a73 (diff)
Simplify containers iterations in sw/source/core/[d-l]*
Use range-based loop or replace with STL functions Change-Id: I143e9a769e1c1bb0228933a0a92150f00e3e1f20 Reviewed-on: https://gerrit.libreoffice.org/63347 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/edit/edlingu.cxx')
-rw-r--r--sw/source/core/edit/edlingu.cxx32
1 files changed, 9 insertions, 23 deletions
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index bcb24e45abe3..69e855b90dd0 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -1047,14 +1047,8 @@ void SwEditShell::PutSpellingToSentenceStart()
static sal_uInt32 lcl_CountRedlines(const svx::SpellPortions& rLastPortions)
{
- sal_uInt32 nRet = 0;
- SpellPortions::const_iterator aIter = rLastPortions.begin();
- for( ; aIter != rLastPortions.end(); ++aIter)
- {
- if( aIter->bIsHidden )
- ++nRet;
- }
- return nRet;
+ return static_cast<sal_uInt32>(std::count_if(rLastPortions.begin(), rLastPortions.end(),
+ [](const svx::SpellPortion& rPortion) { return rPortion.bIsHidden; }));
}
void SwEditShell::MoveContinuationPosToEndOfCheckedSentence()
@@ -1157,8 +1151,6 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
IgnoreGrammarErrorAt( *pCursor );
OSL_FAIL("TODO: add ignore mark to text node");
}
- if(aCurrentNewPortion == rNewPortions.begin())
- break;
}
while(aCurrentNewPortion != rNewPortions.begin());
}
@@ -1175,8 +1167,7 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
// delete the sentence completely
mxDoc->getIDocumentContentOperations().DeleteAndJoin(*pCursor);
- svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.begin();
- while(aCurrentNewPortion != rNewPortions.end())
+ for(const auto& rCurrentNewPortion : rNewPortions)
{
// set the language attribute
SvtScriptType nScriptType = GetScriptType();
@@ -1190,14 +1181,13 @@ void SwEditShell::ApplyChangedSentence(const svx::SpellPortions& rNewPortions, b
SfxItemSet aSet(GetAttrPool(), {{nLangWhichId, nLangWhichId}});
GetCurAttr( aSet );
const SvxLanguageItem& rLang = static_cast<const SvxLanguageItem& >(aSet.Get(nLangWhichId));
- if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage)
- SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) );
+ if(rLang.GetLanguage() != rCurrentNewPortion.eLanguage)
+ SetAttrItem( SvxLanguageItem(rCurrentNewPortion.eLanguage, nLangWhichId) );
// insert the new string
- mxDoc->getIDocumentContentOperations().InsertString(*pCursor, aCurrentNewPortion->sText);
+ mxDoc->getIDocumentContentOperations().InsertString(*pCursor, rCurrentNewPortion.sText);
// set the cursor to the end of the inserted string
*pCursor->Start() = *pCursor->End();
- ++aCurrentNewPortion;
}
}
@@ -1286,14 +1276,10 @@ static SpellContentPosition lcl_FindNextDeletedRedline(
aRet.nLeft = aRet.nRight = SAL_MAX_INT32;
if(!rDeletedRedlines.empty())
{
- SpellContentPositions::const_iterator aIter = rDeletedRedlines.begin();
- for( ; aIter != rDeletedRedlines.end(); ++aIter)
- {
- if(aIter->nLeft < nSearchFrom)
- continue;
+ auto aIter = std::find_if_not(rDeletedRedlines.begin(), rDeletedRedlines.end(),
+ [nSearchFrom](const SpellContentPosition& rPos) { return rPos.nLeft < nSearchFrom; });
+ if (aIter != rDeletedRedlines.end())
aRet = *aIter;
- break;
- }
}
return aRet;
}