[Libreoffice-commits] core.git: editeng/source
Julien Nabet
serval2412 at yahoo.fr
Sat Mar 10 23:15:18 UTC 2018
editeng/source/editeng/editdoc.cxx | 5 -
editeng/source/editeng/editeng.cxx | 12 +---
editeng/source/editeng/editobj.cxx | 74 ++++++++++---------------
editeng/source/editeng/edtspell.cxx | 38 ++++++------
editeng/source/editeng/eertfpar.cxx | 4 -
editeng/source/editeng/impedit2.cxx | 20 +++---
editeng/source/editeng/impedit3.cxx | 3 -
editeng/source/editeng/impedit4.cxx | 4 -
editeng/source/misc/SvXMLAutoCorrectExport.cxx | 9 +--
editeng/source/misc/splwrap.cxx | 8 +-
editeng/source/misc/svxacorr.cxx | 24 ++++----
editeng/source/misc/txtrange.cxx | 6 +-
editeng/source/outliner/paralist.cxx | 11 +--
editeng/source/uno/UnoForbiddenCharsTable.cxx | 5 -
editeng/source/uno/unoedhlp.cxx | 12 ++--
editeng/source/uno/unofored.cxx | 24 ++++----
editeng/source/uno/unotext.cxx | 7 --
editeng/source/uno/unotext2.cxx | 12 ++--
18 files changed, 126 insertions(+), 152 deletions(-)
New commits:
commit e9171066136868fe89947dda5095e9479d5e50e7
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Sat Mar 10 18:00:58 2018 +0100
Use for-range loops in editeng
Change-Id: I6abf56aba1211e1288bd8ee673e0614d1b5dc1d6
Reviewed-on: https://gerrit.libreoffice.org/51050
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 32b965d7cc6d..ce315aaed1bb 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2829,10 +2829,9 @@ EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos )
const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_Int32 nFromPos ) const
{
assert(nWhich);
- AttribsType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
- for (; it != itEnd; ++it)
+ for (auto const& attrib : aAttribs)
{
- const EditCharAttrib& rAttr = *it->get();
+ const EditCharAttrib& rAttr = *attrib.get();
if (rAttr.GetStart() >= nFromPos && rAttr.Which() == nWhich)
return &rAttr;
}
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index bacf77c21767..594e77f5c156 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2277,11 +2277,9 @@ sal_uInt16 EditEngine::GetFieldCount( sal_Int32 nPara ) const
ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
if ( pNode )
{
- const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
- CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
- for (; it != itEnd; ++it)
+ for (auto const& attrib : pNode->GetCharAttribs().GetAttribs())
{
- if ((*it)->Which() == EE_FEATURE_FIELD)
+ if (attrib->Which() == EE_FEATURE_FIELD)
++nFields;
}
}
@@ -2295,11 +2293,9 @@ EFieldInfo EditEngine::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const
if ( pNode )
{
sal_uInt16 nCurrentField = 0;
- const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
- CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
- for (; it != itEnd; ++it)
+ for (auto const& attrib : pNode->GetCharAttribs().GetAttribs())
{
- const EditCharAttrib& rAttr = *it->get();
+ const EditCharAttrib& rAttr = *attrib.get();
if (rAttr.Which() == EE_FEATURE_FIELD)
{
if ( nCurrentField == nField )
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index d990d6d2d578..31fc124a52f1 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -143,9 +143,8 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
ContentInfo::~ContentInfo()
{
- XEditAttributesType::iterator it = maCharAttribs.begin(), itEnd = maCharAttribs.end();
- for (; it != itEnd; ++it)
- aParaAttribs.GetPool()->Remove(*(*it)->GetItem());
+ for (auto const& charAttrib : maCharAttribs)
+ aParaAttribs.GetPool()->Remove(*charAttrib->GetItem());
maCharAttribs.clear();
}
@@ -214,13 +213,11 @@ void ContentInfo::Dump() const
cout << "text: '" << OUString(const_cast<rtl_uString*>(maText.getData())) << "'" << endl;
cout << "style: '" << aStyle << "'" << endl;
- XEditAttributesType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
- for (; it != itEnd; ++it)
+ for (auto const& attrib : aAttribs)
{
- const XEditAttribute& rAttr = *it;
cout << "attribute: " << endl;
- cout << " span: [begin=" << rAttr.GetStart() << ", end=" << rAttr.GetEnd() << "]" << endl;
- cout << " feature: " << (rAttr.IsFeature() ? "yes":"no") << endl;
+ cout << " span: [begin=" << attrib.GetStart() << ", end=" << attrib.GetEnd() << "]" << endl;
+ cout << " feature: " << (attrib.IsFeature() ? "yes":"no") << endl;
}
}
#endif
@@ -468,9 +465,8 @@ void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
ContentInfosType aReplaced;
aReplaced.reserve(aContents.size());
- ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
- for (; it != itEnd; ++it)
- aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*it->get(), *pNewPool)));
+ for (auto const& content : aContents)
+ aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content.get(), *pNewPool)));
aReplaced.swap(aContents);
// set local variables
@@ -482,9 +478,8 @@ void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
#if DEBUG_EDIT_ENGINE
void EditTextObjectImpl::Dump() const
{
- ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
- for (; it != itEnd; ++it)
- it->Dump();
+ for (auto const& content : aContents)
+ content.Dump();
}
#endif
@@ -580,9 +575,8 @@ EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, const EditTextOb
pPool->SetDefaultMetric( r.pPool->GetMetric( DEF_METRIC ) );
aContents.reserve(r.aContents.size());
- ContentInfosType::const_iterator it = r.aContents.begin(), itEnd = r.aContents.end();
- for (; it != itEnd; ++it)
- aContents.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*it->get(), *pPool)));
+ for (auto const& content : r.aContents)
+ aContents.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content.get(), *pPool)));
}
EditTextObjectImpl::~EditTextObjectImpl()
@@ -611,10 +605,9 @@ void EditTextObjectImpl::SetUserType( OutlinerMode n )
void EditTextObjectImpl::NormalizeString( svl::SharedStringPool& rPool )
{
- ContentInfosType::iterator it = aContents.begin(), itEnd = aContents.end();
- for (; it != itEnd; ++it)
+ for (auto const& content : aContents)
{
- ContentInfo& rInfo = *it->get();
+ ContentInfo& rInfo = *content.get();
rInfo.NormalizeString(rPool);
}
}
@@ -623,10 +616,9 @@ std::vector<svl::SharedString> EditTextObjectImpl::GetSharedStrings() const
{
std::vector<svl::SharedString> aSSs;
aSSs.reserve(aContents.size());
- ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
- for (; it != itEnd; ++it)
+ for (auto const& content : aContents)
{
- const ContentInfo& rInfo = *it->get();
+ const ContentInfo& rInfo = *content.get();
aSSs.push_back(rInfo.GetSharedString());
}
return aSSs;
@@ -706,10 +698,9 @@ void EditTextObjectImpl::ClearPortionInfo()
bool EditTextObjectImpl::HasOnlineSpellErrors() const
{
- ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
- for (; it != itEnd; ++it)
+ for (auto const& content : aContents)
{
- if ( (*it)->GetWrongList() && !(*it)->GetWrongList()->empty() )
+ if ( content->GetWrongList() && !content->GetWrongList()->empty() )
return true;
}
return false;
@@ -767,11 +758,10 @@ const SvxFieldData* EditTextObjectImpl::GetFieldData(sal_Int32 nPara, size_t nPo
// URL position is out-of-bound.
return nullptr;
- ContentInfo::XEditAttributesType::const_iterator it = rC.maCharAttribs.begin(), itEnd = rC.maCharAttribs.end();
size_t nCurPos = 0;
- for (; it != itEnd; ++it)
+ for (auto const& charAttrib : rC.maCharAttribs)
{
- const XEditAttribute& rAttr = *it->get();
+ const XEditAttribute& rAttr = *charAttrib.get();
if (rAttr.GetItem()->Which() != EE_FEATURE_FIELD)
// Skip attributes that are not fields.
continue;
@@ -900,13 +890,11 @@ void EditTextObjectImpl::GetAllSections( std::vector<editeng::Section>& rAttrs )
}
// Sort and remove duplicates for each paragraph.
- std::vector<std::vector<size_t>>::iterator it = aParaBorders.begin(), itEnd = aParaBorders.end();
- for (; it != itEnd; ++it)
+ for (auto & paraBorders : aParaBorders)
{
- std::vector<size_t>& rBorders = *it;
- std::sort(rBorders.begin(), rBorders.end());
- auto itUniqueEnd = std::unique(rBorders.begin(), rBorders.end());
- rBorders.erase(itUniqueEnd, rBorders.end());
+ std::sort(paraBorders.begin(), paraBorders.end());
+ auto itUniqueEnd = std::unique(paraBorders.begin(), paraBorders.end());
+ paraBorders.erase(itUniqueEnd, paraBorders.end());
}
std::vector<editeng::Section> aAttrs;
@@ -914,26 +902,26 @@ void EditTextObjectImpl::GetAllSections( std::vector<editeng::Section>& rAttrs )
// Create storage for each section. Note that this creates storage even
// for unformatted sections. The entries are sorted first by paragraph,
// then by section positions. They don't overlap with each other.
- it = aParaBorders.begin();
- for (; it != itEnd; ++it)
+ size_t nPara1 = 0;
+ for (auto const& paraBorders : aParaBorders)
{
- size_t nPara = distance(aParaBorders.begin(), it);
- const std::vector<size_t>& rBorders = *it;
- if (rBorders.size() == 1 && rBorders[0] == 0)
+ if (paraBorders.size() == 1 && paraBorders[0] == 0)
{
// Empty paragraph. Push an empty section.
- aAttrs.emplace_back(nPara, 0, 0);
+ aAttrs.emplace_back(nPara1, 0, 0);
+ ++nPara1;
continue;
}
- auto itBorder = rBorders.begin(), itBorderEnd = rBorders.end();
+ auto itBorder = paraBorders.begin(), itBorderEnd = paraBorders.end();
size_t nPrev = *itBorder;
size_t nCur;
for (++itBorder; itBorder != itBorderEnd; ++itBorder, nPrev = nCur)
{
nCur = *itBorder;
- aAttrs.emplace_back(nPara, nPrev, nCur);
+ aAttrs.emplace_back(nPara1, nPrev, nCur);
}
+ ++nPara1;
}
if (aAttrs.empty())
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index 1ca0587715f6..72dbf1666564 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -282,7 +282,7 @@ void WrongList::TextDeleted( size_t nPos, size_t nLength )
}
}
- for (WrongList::iterator i = begin(); i != end(); )
+ for (WrongList::iterator i = maRanges.begin(); i != maRanges.end(); )
{
bool bDelWrong = false;
if (i->mnEnd >= nPos)
@@ -334,12 +334,12 @@ bool WrongList::NextWrong( size_t& rnStart, size_t& rnEnd ) const
rnStart get the start position, is possibly adjusted wrt. Wrong start
rnEnd does not have to be initialized.
*/
- for (WrongList::const_iterator i = begin(); i != end(); ++i)
+ for (auto const& range : maRanges)
{
- if (i->mnEnd > rnStart)
+ if (range.mnEnd > rnStart)
{
- rnStart = i->mnStart;
- rnEnd = i->mnEnd;
+ rnStart = range.mnStart;
+ rnEnd = range.mnEnd;
return true;
}
}
@@ -348,11 +348,11 @@ bool WrongList::NextWrong( size_t& rnStart, size_t& rnEnd ) const
bool WrongList::HasWrong( size_t nStart, size_t nEnd ) const
{
- for (WrongList::const_iterator i = begin(); i != end(); ++i)
+ for (auto const& range : maRanges)
{
- if (i->mnStart == nStart && i->mnEnd == nEnd)
+ if (range.mnStart == nStart && range.mnEnd == nEnd)
return true;
- else if (i->mnStart >= nStart)
+ else if (range.mnStart >= nStart)
break;
}
return false;
@@ -360,11 +360,11 @@ bool WrongList::HasWrong( size_t nStart, size_t nEnd ) const
bool WrongList::HasAnyWrong( size_t nStart, size_t nEnd ) const
{
- for (WrongList::const_iterator i = begin(); i != end(); ++i)
+ for (auto const& range : maRanges)
{
- if (i->mnEnd >= nStart && i->mnStart < nEnd)
+ if (range.mnEnd >= nStart && range.mnStart < nEnd)
return true;
- else if (i->mnStart >= nEnd)
+ else if (range.mnStart >= nEnd)
break;
}
return false;
@@ -373,7 +373,7 @@ bool WrongList::HasAnyWrong( size_t nStart, size_t nEnd ) const
void WrongList::ClearWrongs( size_t nStart, size_t nEnd,
const ContentNode* pNode )
{
- for (WrongList::iterator i = begin(); i != end(); )
+ for (WrongList::iterator i = maRanges.begin(); i != maRanges.end(); )
{
if (i->mnEnd > nStart && i->mnStart < nEnd)
{
@@ -406,8 +406,8 @@ void WrongList::ClearWrongs( size_t nStart, size_t nEnd,
void WrongList::InsertWrong( size_t nStart, size_t nEnd )
{
- WrongList::iterator nPos = end();
- for (WrongList::iterator i = begin(); i != end(); ++i)
+ WrongList::iterator nPos = maRanges.end();
+ for (WrongList::iterator i = maRanges.begin(); i != maRanges.end(); ++i)
{
if (i->mnStart >= nStart)
{
@@ -453,13 +453,13 @@ bool WrongList::operator==(const WrongList& rCompare) const
|| maRanges.size() != rCompare.maRanges.size())
return false;
- WrongList::const_iterator rCA = maRanges.begin();
WrongList::const_iterator rCB = rCompare.maRanges.begin();
- for (; rCA != maRanges.end(); ++rCA, ++rCB)
+ for (auto const& rangeA : maRanges)
{
- if(rCA->mnStart != rCB->mnStart || rCA->mnEnd != rCB->mnEnd)
+ if(rangeA.mnStart != rCB->mnStart || rangeA.mnEnd != rCB->mnEnd)
return false;
+ ++rCB;
}
return true;
@@ -509,9 +509,9 @@ bool WrongList::DbgIsBuggy() const
{
// Check if the ranges overlap.
bool bError = false;
- for (WrongList::const_iterator i = begin(); !bError && (i != end()); ++i)
+ for (WrongList::const_iterator i = maRanges.begin(); !bError && (i != maRanges.end()); ++i)
{
- for (WrongList::const_iterator j = i + 1; !bError && (j != end()); ++j)
+ for (WrongList::const_iterator j = i + 1; !bError && (j != maRanges.end()); ++j)
{
// 1) Start before, End after the second Start
if (i->mnStart <= j->mnStart && i->mnEnd >= j->mnStart)
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index 7c056db7c24d..3fb2afb68159 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -497,9 +497,9 @@ void EditRTFParser::CreateStyleSheets()
// the SvxRTFParser has now created the template...
if (mpEditEngine->GetStyleSheetPool() && mpEditEngine->IsImportRTFStyleSheetsSet())
{
- for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it)
+ for (auto const& elem : GetStyleTbl())
{
- SvxRTFStyleType* pRTFStyle = it->second.get();
+ SvxRTFStyleType* pRTFStyle = elem.second.get();
CreateStyleSheet( pRTFStyle );
}
}
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 227ceba90dba..362b828decbf 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2260,13 +2260,13 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR
pLeft->GetWrongList()->SetInvalidRange(nInv, nEnd+1);
// Take over misspelled words
WrongList* pRWrongs = pRight->GetWrongList();
- for (WrongList::iterator i = pRWrongs->begin(); i < pRWrongs->end(); ++i)
+ for (auto & elem : *pRWrongs)
{
- if (i->mnStart != 0) // Not a subsequent
+ if (elem.mnStart != 0) // Not a subsequent
{
- i->mnStart = i->mnStart + nEnd;
- i->mnEnd = i->mnEnd + nEnd;
- pLeft->GetWrongList()->push_back(*i);
+ elem.mnStart = elem.mnStart + nEnd;
+ elem.mnEnd = elem.mnEnd + nEnd;
+ pLeft->GetWrongList()->push_back(elem);
}
}
}
@@ -2845,19 +2845,19 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttrib
WrongList* pLWrongs = rPaM.GetNode()->GetWrongList();
WrongList* pRWrongs = aPaM.GetNode()->GetWrongList();
// take over misspelled words:
- for(WrongList::iterator i = pLWrongs->begin(); i < pLWrongs->end(); ++i)
+ for (auto & elem : *pLWrongs)
{
// Correct only if really a word gets overlapped in the process of
// Spell checking
- if (i->mnStart > static_cast<size_t>(nEnd))
+ if (elem.mnStart > static_cast<size_t>(nEnd))
{
- pRWrongs->push_back(*i);
+ pRWrongs->push_back(elem);
editeng::MisspellRange& rRWrong = pRWrongs->back();
rRWrong.mnStart = rRWrong.mnStart - nEnd;
rRWrong.mnEnd = rRWrong.mnEnd - nEnd;
}
- else if (i->mnStart < static_cast<size_t>(nEnd) && i->mnEnd > static_cast<size_t>(nEnd))
- i->mnEnd = nEnd;
+ else if (elem.mnStart < static_cast<size_t>(nEnd) && elem.mnEnd > static_cast<size_t>(nEnd))
+ elem.mnEnd = nEnd;
}
sal_Int32 nInv = nEnd ? nEnd-1 : nEnd;
if ( nEnd )
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 79880497619f..8b67a8eb7c74 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2191,9 +2191,8 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
// Correct the positions in the Array and the portion widths:
// Last character won't be considered ...
- for ( std::vector<sal_Int32>::const_iterator it(aPositions.begin()); it != aPositions.end(); ++it )
+ for (auto const& nChar : aPositions)
{
- sal_Int32 nChar = *it;
if ( nChar < nLastChar )
{
sal_Int32 nPortionStart, nPortion;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 38d627b2142c..75cb969b1887 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1381,10 +1381,8 @@ void ImpEditEngine::GetAllMisspellRanges( std::vector<editeng::MisspellRanges>&
void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges )
{
EditDoc& rDoc = GetEditDoc();
- std::vector<editeng::MisspellRanges>::const_iterator it = rRanges.begin(), itEnd = rRanges.end();
- for (; it != itEnd; ++it)
+ for (auto const& rParaRanges : rRanges)
{
- const editeng::MisspellRanges& rParaRanges = *it;
ContentNode* pNode = rDoc.GetObject(rParaRanges.mnParagraph);
if (!pNode)
continue;
diff --git a/editeng/source/misc/SvXMLAutoCorrectExport.cxx b/editeng/source/misc/SvXMLAutoCorrectExport.cxx
index 81047abc3475..5c41f5f63b46 100644
--- a/editeng/source/misc/SvXMLAutoCorrectExport.cxx
+++ b/editeng/source/misc/SvXMLAutoCorrectExport.cxx
@@ -51,17 +51,14 @@ ErrCode SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum /*eClass*/)
{
SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, true, true);
SvxAutocorrWordList::Content aContent = pAutocorr_List->getSortedContent();
- for( SvxAutocorrWordList::Content::iterator it = aContent.begin();
- it != aContent.end(); ++it )
+ for (auto const& content : aContent)
{
- const SvxAutocorrWord* p = *it;
-
AddAttribute( XML_NAMESPACE_BLOCKLIST,
XML_ABBREVIATED_NAME,
- p->GetShort());
+ content->GetShort());
AddAttribute( XML_NAMESPACE_BLOCKLIST,
XML_NAME,
- p->IsTextOnly() ? p->GetLong() : p->GetShort());
+ content->IsTextOnly() ? content->GetLong() : content->GetShort());
SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, true, true);
}
diff --git a/editeng/source/misc/splwrap.cxx b/editeng/source/misc/splwrap.cxx
index bf883bf72500..d31752d15cc7 100644
--- a/editeng/source/misc/splwrap.cxx
+++ b/editeng/source/misc/splwrap.cxx
@@ -92,11 +92,10 @@ void SvxSpellWrapper::ShowLanguageErrors()
// display message boxes for languages not available for
// spellchecking or hyphenation
LangCheckState_map_t &rLCS = GetLangCheckState();
- LangCheckState_map_t::iterator aIt( rLCS.begin() );
- while (aIt != rLCS.end())
+ for (auto const& elem : rLCS)
{
- LanguageType nLang = aIt->first;
- sal_uInt16 nVal = aIt->second;
+ LanguageType nLang = elem.first;
+ sal_uInt16 nVal = elem.second;
sal_uInt16 nTmpSpell = nVal & 0x00FF;
sal_uInt16 nTmpHyph = (nVal >> 8) & 0x00FF;
@@ -116,7 +115,6 @@ void SvxSpellWrapper::ShowLanguageErrors()
}
rLCS[ nLang ] = (nTmpHyph << 8) | nTmpSpell;
- ++aIt;
}
}
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 302c941b06b7..9ba2b3152618 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2621,12 +2621,12 @@ struct SvxAutocorrWordList::Impl
void DeleteAndDestroyAll()
{
- for (AutocorrWordHashType::const_iterator it = maHash.begin(); it != maHash.end(); ++it)
- delete it->second;
+ for (auto const& elem : maHash)
+ delete elem.second;
maHash.clear();
- for (AutocorrWordSetType::const_iterator it2 = maSet.begin(); it2 != maSet.end(); ++it2)
- delete *it2;
+ for (auto const& elem : maSet)
+ delete elem;
maSet.clear();
}
};
@@ -2701,12 +2701,12 @@ SvxAutocorrWordList::Content SvxAutocorrWordList::getSortedContent() const
if ( mpImpl->maSet.empty() )
{
// This beast has some O(N log(N)) in a terribly slow ICU collate fn.
- for (AutocorrWordHashType::const_iterator it = mpImpl->maHash.begin(); it != mpImpl->maHash.end(); ++it)
- mpImpl->maSet.insert( it->second );
+ for (auto const& elem : mpImpl->maHash)
+ mpImpl->maSet.insert( elem.second );
mpImpl->maHash.clear();
}
- for (AutocorrWordSetType::const_iterator it = mpImpl->maSet.begin(); it != mpImpl->maSet.end(); ++it)
- aContent.push_back( *it );
+ for (auto const& elem : mpImpl->maSet)
+ aContent.push_back(elem);
return aContent;
}
@@ -2837,15 +2837,15 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
const SvxAutocorrWord* SvxAutocorrWordList::SearchWordsInList(const OUString& rTxt, sal_Int32& rStt,
sal_Int32 nEndPos) const
{
- for (AutocorrWordHashType::const_iterator it = mpImpl->maHash.begin(); it != mpImpl->maHash.end(); ++it)
+ for (auto const& elem : mpImpl->maHash)
{
- if( const SvxAutocorrWord *aTmp = WordMatches( it->second, rTxt, rStt, nEndPos ) )
+ if( const SvxAutocorrWord *aTmp = WordMatches( elem.second, rTxt, rStt, nEndPos ) )
return aTmp;
}
- for (AutocorrWordSetType::const_iterator it2 = mpImpl->maSet.begin(); it2 != mpImpl->maSet.end(); ++it2)
+ for (auto const& elem : mpImpl->maSet)
{
- if( const SvxAutocorrWord *aTmp = WordMatches( *it2, rTxt, rStt, nEndPos ) )
+ if( const SvxAutocorrWord *aTmp = WordMatches( elem, rTxt, rStt, nEndPos ) )
return aTmp;
}
return nullptr;
diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx
index 312d642f3d95..299e568fe404 100644
--- a/editeng/source/misc/txtrange.cxx
+++ b/editeng/source/misc/txtrange.cxx
@@ -633,10 +633,10 @@ LongDqPtr TextRanger::GetTextRanges( const Range& rRange )
{
DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye Bye" );
//Can we find the result we need in the cache?
- for (std::deque<RangeCache>::iterator it = mRangeCache.begin(); it != mRangeCache.end(); ++it)
+ for (auto & elem : mRangeCache)
{
- if (it->range == rRange)
- return &(it->results);
+ if (elem.range == rRange)
+ return &(elem.results);
}
//Calculate a new result
RangeCache rngCache(rRange);
diff --git a/editeng/source/outliner/paralist.cxx b/editeng/source/outliner/paralist.cxx
index a4e907f41ba9..af4c8f53da09 100644
--- a/editeng/source/outliner/paralist.cxx
+++ b/editeng/source/outliner/paralist.cxx
@@ -93,9 +93,8 @@ void Paragraph::dumpAsXml(struct _xmlTextWriter* pWriter) const
void ParagraphList::Clear()
{
- std::vector<Paragraph*>::iterator iter;
- for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
- delete *iter;
+ for (auto const& entry : maEntries)
+ delete entry;
maEntries.clear();
}
@@ -236,11 +235,11 @@ void ParagraphList::Collapse( Paragraph const * pParent )
sal_Int32 ParagraphList::GetAbsPos( Paragraph const * pParent ) const
{
sal_Int32 pos = 0;
- std::vector<Paragraph*>::const_iterator iter;
- for (iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++pos)
+ for (auto const& entry : maEntries)
{
- if (*iter == pParent)
+ if (entry == pParent)
return pos;
+ ++pos;
}
return EE_PARA_NOT_FOUND;
diff --git a/editeng/source/uno/UnoForbiddenCharsTable.cxx b/editeng/source/uno/UnoForbiddenCharsTable.cxx
index 35e0bed8b494..bdc938c690eb 100644
--- a/editeng/source/uno/UnoForbiddenCharsTable.cxx
+++ b/editeng/source/uno/UnoForbiddenCharsTable.cxx
@@ -111,10 +111,9 @@ Sequence< lang::Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
{
lang::Locale* pLocales = aLocales.getArray();
- for( SvxForbiddenCharactersTable::Map::iterator it = mxForbiddenChars->GetMap().begin();
- it != mxForbiddenChars->GetMap().end(); ++it )
+ for (auto const& elem : mxForbiddenChars->GetMap())
{
- const LanguageType nLanguage = it->first;
+ const LanguageType nLanguage = elem.first;
*pLocales++ = LanguageTag( nLanguage ).getLocale();
}
}
diff --git a/editeng/source/uno/unoedhlp.cxx b/editeng/source/uno/unoedhlp.cxx
index 3c86fddc35dc..e5ca87a63056 100644
--- a/editeng/source/uno/unoedhlp.cxx
+++ b/editeng/source/uno/unoedhlp.cxx
@@ -128,16 +128,16 @@ bool SvxEditSourceHelper::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nE
// find closest index in front of nIndex
sal_Int32 nCurrIndex;
sal_Int32 nClosestStartIndex_s = 0, nClosestStartIndex_e = 0;
- for(std::vector<EECharAttrib>::iterator i = aCharAttribs.begin(); i < aCharAttribs.end(); ++i)
+ for (auto const& charAttrib : aCharAttribs)
{
- nCurrIndex = i->nStart;
+ nCurrIndex = charAttrib.nStart;
if( nCurrIndex > nClosestStartIndex_s &&
nCurrIndex <= nIndex)
{
nClosestStartIndex_s = nCurrIndex;
}
- nCurrIndex = i->nEnd;
+ nCurrIndex = charAttrib.nEnd;
if ( nCurrIndex > nClosestStartIndex_e &&
nCurrIndex < nIndex )
{
@@ -149,16 +149,16 @@ bool SvxEditSourceHelper::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nE
// find closest index behind of nIndex
sal_Int32 nClosestEndIndex_s, nClosestEndIndex_e;
nClosestEndIndex_s = nClosestEndIndex_e = rEE.GetTextLen(nPara);
- for(std::vector<EECharAttrib>::iterator i = aCharAttribs.begin(); i < aCharAttribs.end(); ++i)
+ for (auto const& charAttrib : aCharAttribs)
{
- nCurrIndex = i->nEnd;
+ nCurrIndex = charAttrib.nEnd;
if( nCurrIndex > nIndex &&
nCurrIndex < nClosestEndIndex_e )
{
nClosestEndIndex_e = nCurrIndex;
}
- nCurrIndex = i->nStart;
+ nCurrIndex = charAttrib.nStart;
if ( nCurrIndex > nIndex &&
nCurrIndex < nClosestEndIndex_s)
{
diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx
index 450fadcce02b..406c0d7a13d6 100644
--- a/editeng/source/uno/unofored.cxx
+++ b/editeng/source/uno/unofored.cxx
@@ -193,39 +193,39 @@ SfxItemState GetSvxEditEngineItemState( EditEngine const & rEditEngine, const ES
const SfxPoolItem* pParaItem = nullptr;
- for(std::vector<EECharAttrib>::const_iterator i = aAttribs.begin(); i < aAttribs.end(); ++i)
+ for (auto const& attrib : aAttribs)
{
- DBG_ASSERT(i->pAttr, "GetCharAttribs gives corrupt data");
+ DBG_ASSERT(attrib.pAttr, "GetCharAttribs gives corrupt data");
- const bool bEmptyPortion = i->nStart == i->nEnd;
- if((!bEmptyPortion && i->nStart >= nEndPos) ||
- (bEmptyPortion && i->nStart > nEndPos))
+ const bool bEmptyPortion = attrib.nStart == attrib.nEnd;
+ if((!bEmptyPortion && attrib.nStart >= nEndPos) ||
+ (bEmptyPortion && attrib.nStart > nEndPos))
break; // break if we are already behind our selection
- if((!bEmptyPortion && i->nEnd <= nPos) ||
- (bEmptyPortion && i->nEnd < nPos))
+ if((!bEmptyPortion && attrib.nEnd <= nPos) ||
+ (bEmptyPortion && attrib.nEnd < nPos))
continue; // or if the attribute ends before our selection
- if(i->pAttr->Which() != nWhich)
+ if(attrib.pAttr->Which() != nWhich)
continue; // skip if is not the searched item
// if we already found an item
if( pParaItem )
{
// ... and its different to this one than the state is don't care
- if(*pParaItem != *(i->pAttr))
+ if(*pParaItem != *(attrib.pAttr))
return SfxItemState::DONTCARE;
}
else
- pParaItem = i->pAttr;
+ pParaItem = attrib.pAttr;
if( bEmpty )
bEmpty = false;
- if(!bGaps && i->nStart > nLastEnd)
+ if(!bGaps && attrib.nStart > nLastEnd)
bGaps = true;
- nLastEnd = i->nEnd;
+ nLastEnd = attrib.nEnd;
}
if( !bEmpty && !bGaps && nLastEnd < ( nEndPos - 1 ) )
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 93dbfd6c0aef..5ccacadf0637 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1277,12 +1277,9 @@ void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault()
if( pForwarder )
{
- PropertyEntryVector_t aEntries = mpPropSet->getPropertyMap().getPropertyEntries();
- PropertyEntryVector_t::const_iterator aIt = aEntries.begin();
- while( aIt != aEntries.end() )
+ for (auto & entry : mpPropSet->getPropertyMap().getPropertyEntries())
{
- _setPropertyToDefault( pForwarder, &(*aIt), -1 );
- ++aIt;
+ _setPropertyToDefault( pForwarder, &entry, -1 );
}
}
}
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx
index 5adb8f73d3ae..41c5c4e73f2c 100644
--- a/editeng/source/uno/unotext2.cxx
+++ b/editeng/source/uno/unotext2.cxx
@@ -60,9 +60,11 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase
if( currentPara == maSelection.nEndPara )
nEndPos = std::min(nEndPos, maSelection.nEndPos);
ESelection aCurrentParaSel = ESelection( currentPara, nStartPos, currentPara, nEndPos );
- for( auto aIter = rRanges.begin(); (aIter != rRanges.end()) && (pContent == nullptr); ++aIter )
+ for (auto const& elemRange : rRanges)
{
- SvxUnoTextContent* pIterContent = dynamic_cast< SvxUnoTextContent* >( ( *aIter ) );
+ if (!pContent)
+ break;
+ SvxUnoTextContent* pIterContent = dynamic_cast< SvxUnoTextContent* >( elemRange );
if( pIterContent && (pIterContent->mnParagraph == currentPara) )
{
ESelection aIterSel = pIterContent->GetSelection();
@@ -405,9 +407,11 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration(const SvxUnoTextBase& rTe
const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
SvxUnoTextRange* pRange = nullptr;
- for( auto aIter = rRanges.begin(); (aIter != rRanges.end()) && (pRange == nullptr); ++aIter )
+ for (auto const& elemRange : rRanges)
{
- SvxUnoTextRange* pIterRange = dynamic_cast< SvxUnoTextRange* >( ( *aIter ) );
+ if (!pRange)
+ break;
+ SvxUnoTextRange* pIterRange = dynamic_cast< SvxUnoTextRange* >( elemRange );
if( pIterRange && pIterRange->mbPortion && (aSel == pIterRange->maSelection) )
pRange = pIterRange;
}
More information about the Libreoffice-commits
mailing list