sw/source/core/doc/DocumentContentOperationsManager.cxx | 34 +--- sw/source/core/doc/DocumentListItemsManager.cxx | 5 sw/source/core/doc/SwStyleNameMapper.cxx | 6 sw/source/core/doc/acmplwrd.cxx | 40 +---- sw/source/core/doc/doc.cxx | 7 sw/source/core/doc/docnew.cxx | 5 sw/source/core/doc/docnum.cxx | 21 -- sw/source/core/doc/docredln.cxx | 5 sw/source/core/doc/docsort.cxx | 16 +- sw/source/core/doc/doctxm.cxx | 4 sw/source/core/doc/gctable.cxx | 5 sw/source/core/doc/list.cxx | 43 +---- sw/source/core/doc/number.cxx | 13 - sw/source/core/doc/swserv.cxx | 6 sw/source/core/doc/tblafmt.cxx | 36 ++--- sw/source/core/doc/tblcpy.cxx | 35 +--- sw/source/core/doc/tblrwcl.cxx | 28 +-- sw/source/core/doc/textboxhelper.cxx | 16 +- sw/source/core/docnode/ndcopy.cxx | 13 - sw/source/core/docnode/ndtbl.cxx | 115 +++++++--------- sw/source/core/docnode/node.cxx | 11 - sw/source/core/draw/dview.cxx | 8 - sw/source/core/edit/edlingu.cxx | 32 +--- sw/source/core/fields/reffld.cxx | 13 - sw/source/core/frmedt/fefly1.cxx | 8 - sw/source/core/frmedt/fetab.cxx | 6 sw/source/core/frmedt/tblsel.cxx | 5 sw/source/core/layout/atrfrm.cxx | 4 sw/source/core/layout/layact.cxx | 4 sw/source/core/layout/laycache.cxx | 6 sw/source/core/layout/newfrm.cxx | 7 sw/source/core/layout/paintfrm.cxx | 30 ---- 32 files changed, 223 insertions(+), 364 deletions(-)
New commits: commit 25622f29b4003307d2ba780ff1232d8b7cdafa35 Author: Arkadiy Illarionov <qar...@gmail.com> AuthorDate: Wed Nov 14 00:57:07 2018 +0300 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Nov 14 09:58:55 2018 +0100 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.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 37115a78c946..639435b742b7 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -258,11 +258,8 @@ namespace // We have to count the "non-copied" nodes.. sal_uLong nDelCount; SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount)); - for(mark_vector_t::const_iterator ppMark = vMarksToCopy.begin(); - ppMark != vMarksToCopy.end(); - ++ppMark) + for(const sw::mark::IMark* const pMark : vMarksToCopy) { - const ::sw::mark::IMark* const pMark = *ppMark; SwPaM aTmpPam(*pCpyStt); lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetMarkPos().nNode.GetIndex(), nDelCount); lcl_SetCpyPos( pMark->GetMarkPos(), rStt, *pCpyStt, *aTmpPam.GetPoint(), nDelCount); @@ -302,10 +299,9 @@ namespace pNewFieldmark->SetFieldHelptext(pOldFieldmark->GetFieldHelptext()); ::sw::mark::IFieldmark::parameter_map_t* pNewParams = pNewFieldmark->GetParameters(); const ::sw::mark::IFieldmark::parameter_map_t* pOldParams = pOldFieldmark->GetParameters(); - ::sw::mark::IFieldmark::parameter_map_t::const_iterator pIt = pOldParams->begin(); - for (; pIt != pOldParams->end(); ++pIt ) + for (const auto& rEntry : *pOldParams ) { - pNewParams->insert( *pIt ); + pNewParams->insert( rEntry ); } } @@ -2164,11 +2160,8 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos, // Insert the Bookmarks back into the Document. *rPaM.GetMark() = *aSavePam.Start(); - for( - std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin(); - pBkmk != aSaveBkmks.end(); - ++pBkmk) - pBkmk->SetInDoc( + for(auto& rBkmk : aSaveBkmks) + rBkmk.SetInDoc( &m_rDoc, rPaM.GetMark()->nNode, &rPaM.GetMark()->nContent); @@ -2284,11 +2277,8 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod RestFlyInRange( aSaveFlyArr, aIdx, nullptr ); // Add the Bookmarks back to the Document - for( - std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin(); - pBkmk != aSaveBkmks.end(); - ++pBkmk) - pBkmk->SetInDoc(&m_rDoc, aIdx); + for(auto& rBkmk : aSaveBkmks) + rBkmk.SetInDoc(&m_rDoc, aIdx); if( !aSavRedlInsPosArr.empty() ) { @@ -3494,16 +3484,16 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl( if ( aSet.size() == aVecSwFrameFormat.size() ) { size_t n = 0; - for (std::set< ZSortFly >::const_iterator nIt=aSet.begin() ; nIt != aSet.end(); ++nIt, ++n ) + for (const auto& rFlyN : aSet) { - const SwFrameFormat *pFormatN = (*nIt).GetFormat(); + const SwFrameFormat *pFormatN = rFlyN.GetFormat(); const SwFormatChain &rChain = pFormatN->GetChain(); int nCnt = int(nullptr != rChain.GetPrev()); nCnt += rChain.GetNext() ? 1: 0; size_t k = 0; - for (std::set< ZSortFly >::const_iterator kIt=aSet.begin() ; kIt != aSet.end(); ++kIt, ++k ) + for (const auto& rFlyK : aSet) { - const SwFrameFormat *pFormatK = (*kIt).GetFormat(); + const SwFrameFormat *pFormatK = rFlyK.GetFormat(); if ( rChain.GetPrev() == pFormatK ) { ::lcl_ChainFormats( static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[k]), @@ -3516,7 +3506,9 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl( static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[k]) ); --nCnt; } + ++k; } + ++n; } // Re-create content property of draw formats, knowing how old shapes diff --git a/sw/source/core/doc/DocumentListItemsManager.cxx b/sw/source/core/doc/DocumentListItemsManager.cxx index edb859a6e57a..3aa083d4d3b4 100644 --- a/sw/source/core/doc/DocumentListItemsManager.cxx +++ b/sw/source/core/doc/DocumentListItemsManager.cxx @@ -79,11 +79,8 @@ void DocumentListItemsManager::getNumItems( tSortedNodeNumList& orNodeNumList ) orNodeNumList.clear(); orNodeNumList.reserve( mpListItemsList->size() ); - tImplSortedNodeNumList::iterator aIter; - tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end(); - for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter ) + for ( const SwNodeNum* pNodeNum : *mpListItemsList ) { - const SwNodeNum* pNodeNum = (*aIter); if ( pNodeNum->IsCounted() && pNodeNum->GetTextNode() && pNodeNum->GetTextNode()->HasNumber() ) { diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx b/sw/source/core/doc/SwStyleNameMapper.cxx index 59a6c68be3fe..5ca2e5df8046 100644 --- a/sw/source/core/doc/SwStyleNameMapper.cxx +++ b/sw/source/core/doc/SwStyleNameMapper.cxx @@ -506,15 +506,15 @@ const NameToIdHash & SwStyleNameMapper::getHashTable ( SwGetPoolIdFromName eFlag sal_uInt16 nSize = std::accumulate( vIndexes.begin(), vIndexes.end(), 0, lcl_AccumulateIndexCount ); NameToIdHash *pHash = new NameToIdHash( nSize ); - for ( std::vector<NameArrayIndexTuple_t>::iterator entry = vIndexes.begin(); entry != vIndexes.end(); ++entry ) + for ( const auto& rEntry : vIndexes ) { // Get a pointer to the function which will populate pStrings - const std::vector<OUString>& (*pStringsFetchFunc)() = std::get<2>( *entry ); + const std::vector<OUString>& (*pStringsFetchFunc)() = std::get<2>( rEntry ); if ( pStringsFetchFunc ) { const std::vector<OUString>& rStrings = pStringsFetchFunc(); sal_uInt16 nIndex, nId; - for ( nIndex = 0, nId = std::get<0>( *entry ) ; nId < std::get<1>( *entry ) ; nId++, nIndex++ ) + for ( nIndex = 0, nId = std::get<0>( rEntry ) ; nId < std::get<1>( rEntry ) ; nId++, nIndex++ ) (*pHash)[rStrings[nIndex]] = nId; } } diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx index 75f683bec8bf..b804dc578d37 100644 --- a/sw/source/core/doc/acmplwrd.cxx +++ b/sw/source/core/doc/acmplwrd.cxx @@ -152,26 +152,18 @@ void SwAutoCompleteClient::Modify( const SfxPoolItem* pOld, const SfxPoolItem *) void SwAutoCompleteWord_Impl::AddDocument(SwDoc& rDoc) { - SwAutoCompleteClientVector::iterator aIt; - for(aIt = aClientVector.begin(); aIt != aClientVector.end(); ++aIt) - { - if(&aIt->GetDoc() == &rDoc) - return; - } + if (std::any_of(aClientVector.begin(), aClientVector.end(), + [&rDoc](SwAutoCompleteClient& rClient) { return &rClient.GetDoc() == &rDoc; })) + return; aClientVector.emplace_back(rAutoCompleteWord, rDoc); } void SwAutoCompleteWord_Impl::RemoveDocument(const SwDoc& rDoc) { - SwAutoCompleteClientVector::iterator aIt; - for(aIt = aClientVector.begin(); aIt != aClientVector.end(); ++aIt) - { - if(&aIt->GetDoc() == &rDoc) - { - aClientVector.erase(aIt); - return; - } - } + auto aIt = std::find_if(aClientVector.begin(), aClientVector.end(), + [&rDoc](SwAutoCompleteClient& rClient) { return &rClient.GetDoc() == &rDoc; }); + if (aIt != aClientVector.end()) + aClientVector.erase(aIt); } SwAutoCompleteString::SwAutoCompleteString( @@ -194,23 +186,19 @@ SwAutoCompleteString::~SwAutoCompleteString() void SwAutoCompleteString::AddDocument(const SwDoc& rDoc) { - for(SwDocPtrVector::iterator aIt = aSourceDocs.begin(); aIt != aSourceDocs.end(); ++aIt) - { - if( *aIt == &rDoc ) - return; - } + auto aIt = std::find(aSourceDocs.begin(), aSourceDocs.end(), &rDoc); + if (aIt != aSourceDocs.end()) + return; aSourceDocs.push_back(&rDoc); } bool SwAutoCompleteString::RemoveDocument(const SwDoc& rDoc) { - for(SwDocPtrVector::iterator aIt = aSourceDocs.begin(); aIt != aSourceDocs.end(); ++aIt) + auto aIt = std::find(aSourceDocs.begin(), aSourceDocs.end(), &rDoc); + if (aIt != aSourceDocs.end()) { - if( *aIt == &rDoc ) - { - aSourceDocs.erase(aIt); - return aSourceDocs.empty(); - } + aSourceDocs.erase(aIt); + return aSourceDocs.empty(); } return false; } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 66286f9bc971..cfb91b7f401c 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1605,11 +1605,9 @@ bool SwDoc::ConvertFieldsToText() for( SwFormatField* pCurFieldFormat = aIter.First(); pCurFieldFormat; pCurFieldFormat = aIter.Next() ) aFieldFormats.push_back(pCurFieldFormat); - std::vector<const SwFormatField*>::iterator aBegin = aFieldFormats.begin(); - std::vector<const SwFormatField*>::iterator aEnd = aFieldFormats.end(); - while(aBegin != aEnd) + for(const auto& rpFieldFormat : aFieldFormats) { - const SwTextField *pTextField = (*aBegin)->GetTextField(); + const SwTextField *pTextField = rpFieldFormat->GetTextField(); // skip fields that are currently not in the document // e.g. fields in undo or redo array @@ -1677,7 +1675,6 @@ bool SwDoc::ConvertFieldsToText() bRet = true; } } - ++aBegin; } } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index d3e9b548905e..ed0f0529de6f 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -425,9 +425,8 @@ SwDoc::~SwDoc() // Release the BaseLinks { ::sfx2::SvLinkSources aTemp(getIDocumentLinksAdministration().GetLinkManager().GetServers()); - for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); - it != aTemp.end(); ++it ) - (*it)->Closed(); + for( const auto& rpLinkSrc : aTemp ) + rpLinkSrc->Closed(); if( !getIDocumentLinksAdministration().GetLinkManager().GetLinks().empty() ) getIDocumentLinksAdministration().GetLinkManager().Remove( 0, getIDocumentLinksAdministration().GetLinkManager().GetLinks().size() ); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 28d5cd766aea..8db15b33bbf8 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -121,10 +121,8 @@ void SwDoc::SetOutlineNumRule( const SwNumRule& rRule ) // changed outline style SwNumRule::tTextNodeList aTextNodeList; mpOutlineRule->GetTextNodeList( aTextNodeList ); - for ( SwNumRule::tTextNodeList::iterator aIter = aTextNodeList.begin(); - aIter != aTextNodeList.end(); ++aIter ) + for ( SwTextNode* pTextNd : aTextNodeList ) { - SwTextNode* pTextNd = *aIter; pTextNd->NumRuleChgd(); // assure that list level corresponds to outline level @@ -793,10 +791,8 @@ static void lcl_ChgNumRule( SwDoc& rDoc, const SwNumRule& rRule ) SwNumRule::tTextNodeList aTextNodeList; pOld->GetTextNodeList( aTextNodeList ); sal_uInt8 nLvl( 0 ); - for ( SwNumRule::tTextNodeList::iterator aIter = aTextNodeList.begin(); - aIter != aTextNodeList.end(); ++aIter ) + for ( SwTextNode* pTextNd : aTextNodeList ) { - SwTextNode* pTextNd = *aIter; nLvl = static_cast<sal_uInt8>(pTextNd->GetActualListLevel()); if( nLvl < MAXLEVEL ) @@ -1084,10 +1080,8 @@ bool SwDoc::RenameNumRule(const OUString & rOldName, const OUString & rNewName, SwNumRuleItem aItem(rNewName); - for ( SwNumRule::tTextNodeList::iterator aIter = aTextNodeList.begin(); - aIter != aTextNodeList.end(); ++aIter ) + for ( SwTextNode* pTextNd : aTextNodeList ) { - SwTextNode * pTextNd = *aIter; pTextNd->SetAttr(aItem); } @@ -1107,10 +1101,8 @@ void SwDoc::StopNumRuleAnimations( OutputDevice* pOut ) { SwNumRule::tTextNodeList aTextNodeList; GetNumRuleTable()[ --n ]->GetTextNodeList( aTextNodeList ); - for ( SwNumRule::tTextNodeList::iterator aTextNodeIter = aTextNodeList.begin(); - aTextNodeIter != aTextNodeList.end(); ++aTextNodeIter ) + for ( SwTextNode* pTNd : aTextNodeList ) { - SwTextNode* pTNd = *aTextNodeIter; SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*pTNd); for(SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next() ) if (pFrame->HasAnimation() && @@ -1157,11 +1149,8 @@ bool SwDoc::ReplaceNumRule( const SwPosition& rPos, const SwTextNode* pGivenTextNode = rPos.nNode.GetNode().GetTextNode(); SwNumRuleItem aRule( rNewRule ); - for ( SwNumRule::tTextNodeList::iterator aIter = aTextNodeList.begin(); - aIter != aTextNodeList.end(); ++aIter ) + for ( SwTextNode* pTextNd : aTextNodeList ) { - SwTextNode* pTextNd = *aIter; - if ( pGivenTextNode && pGivenTextNode->GetListId() == pTextNd->GetListId() ) { diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index b719204f3431..e26e02b53848 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -866,10 +866,9 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore)); // Actually we need to reset the Attribute here! - std::vector<sal_uInt16>::const_iterator it; - for( it = m_aWhichIds.begin(); it != m_aWhichIds.end(); ++it ) + for( const auto& rWhichId : m_aWhichIds ) { - pDoc->getIDocumentContentOperations().InsertPoolItem( rPam, *GetDfltAttr( *it ), + pDoc->getIDocumentContentOperations().InsertPoolItem( rPam, *GetDfltAttr( rWhichId ), SetAttrMode::DONTEXPAND ); } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 70633e0eada5..e78977830d06 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -397,11 +397,10 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) GetIDocumentUndoRedo().DoUndo(false); size_t n = 0; - for (SwSortTextElements::const_iterator it = aSortSet.begin(); - it != aSortSet.end(); ++it, ++n) + for (const auto& rElem : aSortSet) { aStart = nBeg + n; - aRg.aStart = it->aPos.GetIndex(); + aRg.aStart = rElem.aPos.GetIndex(); aRg.aEnd = aRg.aStart.GetIndex() + 1; // Move Nodes @@ -411,8 +410,9 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) // Insert Move in Undo if(pUndoSort) { - pUndoSort->Insert(it->nOrg, nBeg + n); + pUndoSort->Insert(rElem.nOrg, nBeg + n); } + ++n; } // Delete all elements from the SortArray aSortSet.clear(); @@ -569,17 +569,17 @@ bool SwDoc::SortTable(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) // Move after Sorting SwMovedBoxes aMovedList; sal_uInt16 i = 0; - for (SwSortBoxElements::const_iterator it = aSortList.begin(); - it != aSortList.end(); ++i, ++it) + for (const auto& rElem : aSortList) { if(rOpt.eDirection == SRT_ROWS) { - MoveRow(this, aFlatBox, it->nRow, i+nStart, aMovedList, pUndoSort); + MoveRow(this, aFlatBox, rElem.nRow, i+nStart, aMovedList, pUndoSort); } else { - MoveCol(this, aFlatBox, it->nRow, i+nStart, aMovedList, pUndoSort); + MoveCol(this, aFlatBox, rElem.nRow, i+nStart, aMovedList, pUndoSort); } + ++i; } // Restore table frames: diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index fb4a438bdda4..cb8179062d71 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1022,9 +1022,9 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, aN2L.RestoreUpperFrames( pDoc->GetNodes(), nIdx, nIdx + 1 ); std::set<SwRootFrame*> aAllLayouts = pDoc->GetAllLayouts(); - for ( std::set<SwRootFrame*>::iterator pLayoutIter = aAllLayouts.begin(); pLayoutIter != aAllLayouts.end(); ++pLayoutIter) + for ( const auto& rpLayout : aAllLayouts ) { - SwFrame::CheckPageDescs( static_cast<SwPageFrame*>((*pLayoutIter)->Lower()) ); + SwFrame::CheckPageDescs( static_cast<SwPageFrame*>(rpLayout->Lower()) ); } SetProtect( SwTOXBase::IsProtected() ); diff --git a/sw/source/core/doc/gctable.cxx b/sw/source/core/doc/gctable.cxx index fcc2cef19805..660324549c21 100644 --- a/sw/source/core/doc/gctable.cxx +++ b/sw/source/core/doc/gctable.cxx @@ -301,9 +301,8 @@ void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara ) } while( true ); } - for( SwTableBoxes::const_iterator it = pLine->GetTabBoxes().begin(); - it != pLine->GetTabBoxes().end(); ++it) - lcl_GC_Box_Border(*it, pGCPara ); + for( const auto& rpBox : pLine->GetTabBoxes() ) + lcl_GC_Box_Border(rpBox, pGCPara ); ++pGCPara->nLinePos; } diff --git a/sw/source/core/doc/list.cxx b/sw/source/core/doc/list.cxx index 46be497f77ad..fe616182c701 100644 --- a/sw/source/core/doc/list.cxx +++ b/sw/source/core/doc/list.cxx @@ -98,14 +98,11 @@ SwListImpl::SwListImpl( const OUString& sListId, SwListImpl::~SwListImpl() COVERITY_NOEXCEPT_FALSE { - tListTrees::iterator aNumberTreeIter; - for ( aNumberTreeIter = maListTrees.begin(); - aNumberTreeIter != maListTrees.end(); - ++aNumberTreeIter ) + for ( auto& rNumberTree : maListTrees ) { - SwNodeNum::HandleNumberTreeRootNodeDelete( *((*aNumberTreeIter).first) ); - delete (*aNumberTreeIter).first; - delete (*aNumberTreeIter).second; + SwNodeNum::HandleNumberTreeRootNodeDelete( *(rNumberTree.first) ); + delete rNumberTree.first; + delete rNumberTree.second; } } @@ -116,19 +113,16 @@ void SwListImpl::InsertListItem( SwNodeNum& rNodeNum, const SwPosition aPosOfNodeNum( rNodeNum.GetPosition() ); const SwNodes* pNodesOfNodeNum = &(aPosOfNodeNum.nNode.GetNode().GetNodes()); - tListTrees::const_iterator aNumberTreeIter; - for ( aNumberTreeIter = maListTrees.begin(); - aNumberTreeIter != maListTrees.end(); - ++aNumberTreeIter ) + for ( const auto& rNumberTree : maListTrees ) { - const SwPosition* pStart = (*aNumberTreeIter).second->Start(); - const SwPosition* pEnd = (*aNumberTreeIter).second->End(); + const SwPosition* pStart = rNumberTree.second->Start(); + const SwPosition* pEnd = rNumberTree.second->End(); const SwNodes* pRangeNodes = &(pStart->nNode.GetNode().GetNodes()); if ( pRangeNodes == pNodesOfNodeNum && *pStart <= aPosOfNodeNum && aPosOfNodeNum <= *pEnd) { - (*aNumberTreeIter).first->AddChild( &rNodeNum, nLevel ); + rNumberTree.first->AddChild( &rNodeNum, nLevel ); break; } @@ -142,23 +136,17 @@ void SwListImpl::RemoveListItem( SwNodeNum& rNodeNum ) void SwListImpl::InvalidateListTree() { - tListTrees::iterator aNumberTreeIter; - for ( aNumberTreeIter = maListTrees.begin(); - aNumberTreeIter != maListTrees.end(); - ++aNumberTreeIter ) + for ( auto& rNumberTree : maListTrees ) { - (*aNumberTreeIter).first->InvalidateTree(); + rNumberTree.first->InvalidateTree(); } } void SwListImpl::ValidateListTree() { - tListTrees::iterator aNumberTreeIter; - for ( aNumberTreeIter = maListTrees.begin(); - aNumberTreeIter != maListTrees.end(); - ++aNumberTreeIter ) + for ( auto& rNumberTree : maListTrees ) { - (*aNumberTreeIter).first->NotifyInvalidChildren(); + rNumberTree.first->NotifyInvalidChildren(); } } @@ -200,12 +188,9 @@ bool SwListImpl::IsListLevelMarked( const int nListLevel ) const void SwListImpl::NotifyItemsOnListLevel( const int nLevel ) { - tListTrees::iterator aNumberTreeIter; - for ( aNumberTreeIter = maListTrees.begin(); - aNumberTreeIter != maListTrees.end(); - ++aNumberTreeIter ) + for ( auto& rNumberTree : maListTrees ) { - (*aNumberTreeIter).first->NotifyNodesOnListLevel( nLevel ); + rNumberTree.first->NotifyNodesOnListLevel( nLevel ); } } diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index acdeba686d99..50c2ebb3793c 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -326,10 +326,9 @@ void SwNumFormat::UpdateNumNodes( SwDoc* pDoc ) { SwNumRule::tTextNodeList aTextNodeList; pRule->GetTextNodeList( aTextNodeList ); - for ( SwNumRule::tTextNodeList::iterator aIter = aTextNodeList.begin(); - aIter != aTextNodeList.end(); ++aIter ) + for ( auto& rpTextNode : aTextNodeList ) { - lcl_SetRuleChgd( *(*aIter), i ); + lcl_SetRuleChgd( *rpTextNode, i ); } bFnd = true; break; @@ -859,10 +858,8 @@ void SwNumRule::SetInvalidRule(bool bFlag) if (bFlag) { std::set< SwList* > aLists; - tTextNodeList::iterator aIter; - for ( aIter = maTextNodeList.begin(); aIter != maTextNodeList.end(); ++aIter ) + for ( const SwTextNode* pTextNode : maTextNodeList ) { - const SwTextNode* pTextNode = *aIter; // #i111681# - applying patch from cmc SwList* pList = pTextNode->GetDoc()->getIDocumentListsAccess().getListByName( pTextNode->GetListId() ); OSL_ENSURE( pList, "<SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue."); @@ -973,10 +970,8 @@ void SwNumRule::SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent void SwNumRule::Validate() { std::set< SwList* > aLists; - tTextNodeList::iterator aIter; - for ( aIter = maTextNodeList.begin(); aIter != maTextNodeList.end(); ++aIter ) + for ( const SwTextNode* pTextNode : maTextNodeList ) { - const SwTextNode* pTextNode = *aIter; aLists.insert( pTextNode->GetDoc()->getIDocumentListsAccess().getListByName( pTextNode->GetListId() ) ); } for ( auto aList : aLists ) diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx index 288db677587c..aaf7b2723026 100644 --- a/sw/source/core/doc/swserv.cxx +++ b/sw/source/core/doc/swserv.cxx @@ -302,9 +302,9 @@ SwDataChanged::~SwDataChanged() const ::sfx2::SvLinkSources& rServers = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetServers(); ::sfx2::SvLinkSources aTemp(rServers); - for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it ) + for( const auto& rpLinkSrc : aTemp ) { - ::sfx2::SvLinkSourceRef refObj( *it ); + ::sfx2::SvLinkSourceRef refObj( rpLinkSrc ); // Any one else interested in the Object? if( refObj->HasDataLinks() && dynamic_cast<const SwServerObject*>( refObj.get() ) != nullptr) { @@ -319,7 +319,7 @@ SwDataChanged::~SwDataChanged() if( !refObj->HasDataLinks() ) { // Then remove from the list - pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( *it ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( rpLinkSrc ); } } } diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index b018a468a793..e5fc328e07bb 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -1186,14 +1186,12 @@ void SwTableAutoFormatTable::EraseAutoFormat(size_t const i) void SwTableAutoFormatTable::EraseAutoFormat(const OUString& rName) { - for (auto iter = m_pImpl->m_AutoFormats.begin(); - iter != m_pImpl->m_AutoFormats.end(); ++iter) + auto iter = std::find_if(m_pImpl->m_AutoFormats.begin(), m_pImpl->m_AutoFormats.end(), + [&rName](const std::unique_ptr<SwTableAutoFormat>& rpFormat) { return rpFormat->GetName() == rName; }); + if (iter != m_pImpl->m_AutoFormats.end()) { - if ((*iter)->GetName() == rName) - { - m_pImpl->m_AutoFormats.erase(iter); - return; - } + m_pImpl->m_AutoFormats.erase(iter); + return; } SAL_INFO("sw.core", "SwTableAutoFormatTable::EraseAutoFormat, SwTableAutoFormat with given name not found"); } @@ -1209,15 +1207,12 @@ std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(siz std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(const OUString& rName) { std::unique_ptr<SwTableAutoFormat> pRet; - for (auto iter = m_pImpl->m_AutoFormats.begin(); - iter != m_pImpl->m_AutoFormats.end(); ++iter) + auto iter = std::find_if(m_pImpl->m_AutoFormats.begin(), m_pImpl->m_AutoFormats.end(), + [&rName](const std::unique_ptr<SwTableAutoFormat>& rpFormat) { return rpFormat->GetName() == rName; }); + if (iter != m_pImpl->m_AutoFormats.end()) { - if ((*iter)->GetName() == rName) - { - pRet = std::move(*iter); - m_pImpl->m_AutoFormats.erase(iter); - break; - } + pRet = std::move(*iter); + m_pImpl->m_AutoFormats.erase(iter); } return pRet; } @@ -1427,13 +1422,12 @@ void SwCellStyleTable::AddBoxFormat(const SwBoxAutoFormat& rBoxFormat, const OUS void SwCellStyleTable::RemoveBoxFormat(const OUString& sName) { - for (auto iter = m_aCellStyles.begin(); iter != m_aCellStyles.end(); ++iter) + auto iter = std::find_if(m_aCellStyles.begin(), m_aCellStyles.end(), + [&sName](const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rStyle) { return rStyle.first == sName; }); + if (iter != m_aCellStyles.end()) { - if (iter->first == sName) - { - m_aCellStyles.erase(iter); - return; - } + m_aCellStyles.erase(iter); + return; } SAL_INFO("sw.core", "SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists"); } diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index c43c8fa668ef..672324930747 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -46,6 +46,7 @@ #include <fmtfsize.hxx> #include <deque> #include <memory> +#include <numeric> #include <o3tl/make_unique.hxx> static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, @@ -116,15 +117,12 @@ namespace if( nSize < rBox.GetTabLines().size() ) { SubLine aSubLine; - SubLine::iterator pBox = pStartLn->begin(); - SubLine::iterator pEnd = pStartLn->end(); - while( pBox != pEnd ) + for( const auto& rSubBox : *pStartLn ) { SubBox aSub; - aSub.mpBox = pBox->mpBox; + aSub.mpBox = rSubBox.mpBox; aSub.mbCovered = true; aSubLine.push_back( aSub ); - ++pBox; } do { @@ -230,16 +228,9 @@ namespace } if( bNoSelection && mnStartCol < USHRT_MAX ) { - BoxStructure::iterator pC = maLines[0].begin(); - BoxStructure::iterator pEnd = maLines[0].end(); - sal_uInt16 nIdx = mnStartCol; - mnStartCol = 0; - while( nIdx && pC != pEnd ) - { - mnStartCol += pC->mnColSpan; - --nIdx; - ++pC; - } + sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size())); + mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0), + [](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; }); } else mnStartCol = USHRT_MAX; @@ -274,13 +265,10 @@ namespace maLines[rLine].reserve( pStartLn->size() ); BoxStructure::iterator pSel = maLines[rLine].end(); ColumnStructure::iterator pCol = maCols.begin(); - SubLine::iterator pBox = pStartLn->begin(); - SubLine::iterator pEnd = pStartLn->end(); - while( pBox != pEnd ) + for( const auto& rBox : *pStartLn ) { - addBox( rLine, pSelBoxes, pBox->mpBox, nBorder, nCol, - pCol, pSel, bSelected, pBox->mbCovered ); - ++pBox; + addBox( rLine, pSelBoxes, rBox.mpBox, nBorder, nCol, + pCol, pSel, bSelected, rBox.mbCovered ); } ++rLine; ++pStartLn; @@ -1050,9 +1038,8 @@ SwSelBoxes& SwTable::SelLineFromBox( const SwTableBox* pBox, // Delete all old ones rBoxes.clear(); - for( SwTableBoxes::iterator it = pLine->GetTabBoxes().begin(); - it != pLine->GetTabBoxes().end(); ++it) - FndContentBox(*it, &rBoxes ); + for( const auto& rpBox : pLine->GetTabBoxes() ) + FndContentBox(rpBox, &rBoxes ); return rBoxes; } diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index ee0050226efe..5b17b345666f 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -1647,9 +1647,8 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes, // Clean up this Line's structure once again, generally all of them GCLines(); - for( SwTableBoxes::iterator it = GetTabLines()[0]->GetTabBoxes().begin(); - it != GetTabLines()[0]->GetTabBoxes().end(); ++it) - lcl_BoxSetHeadCondColl(*it); + for( const auto& rpBox : GetTabLines()[0]->GetTabBoxes() ) + lcl_BoxSetHeadCondColl(rpBox); aFndBox.MakeFrames( *this ); @@ -2135,18 +2134,16 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, SwCollectTableLineBoxes aLnPara( false, SplitTable_HeadlineOption::BorderCopy ); pLn = GetTabLines()[ nLnPos - 1 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_Box_CollectBox( *it, &aLnPara ); + for( const auto& rpBox : pLn->GetTabBoxes() ) + sw_Box_CollectBox( rpBox, &aLnPara ); if( aLnPara.Resize( lcl_GetBoxOffset( aFndBox ), lcl_GetLineWidth( *pFndLn )) ) { aLnPara.SetValues( true ); pLn = pNewTable->GetTabLines()[ 0 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_BoxSetSplitBoxFormats(*it, &aLnPara ); + for( const auto& rpBox : pLn->GetTabBoxes() ) + sw_BoxSetSplitBoxFormats(rpBox, &aLnPara ); } } @@ -2160,18 +2157,16 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, SwCollectTableLineBoxes aLnPara( true, SplitTable_HeadlineOption::BorderCopy ); pLn = GetTabLines()[ nLnPos + 1 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_Box_CollectBox( *it, &aLnPara ); + for( const auto& rpBox : pLn->GetTabBoxes() ) + sw_Box_CollectBox( rpBox, &aLnPara ); if( aLnPara.Resize( lcl_GetBoxOffset( aFndBox ), lcl_GetLineWidth( *pFndLn )) ) { aLnPara.SetValues( false ); pLn = pNewTable->GetTabLines().back(); - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_BoxSetSplitBoxFormats(*it, &aLnPara ); + for( const auto& rpBox : pLn->GetTabBoxes() ) + sw_BoxSetSplitBoxFormats(rpBox, &aLnPara ); } } } @@ -3305,9 +3300,8 @@ void CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize ) SwTwips nCurrentSize = 0; // See if the tables have a correct width - for (SwTableBoxes::const_iterator i(rBoxes.begin()); i != rBoxes.end(); ++i) + for (const SwTableBox* pBox : rBoxes) { - const SwTableBox* pBox = *i; const SwTwips nBoxW = pBox->GetFrameFormat()->GetFrameSize().GetWidth(); nCurrentSize += nBoxW; diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 45fce1328985..686485ff33e5 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -604,21 +604,23 @@ void SwTextBoxHelper::restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrame SavedLink& rSavedLinks, SavedContent& rResetContent) { std::size_t i = 0; - for (auto aSetIt = rOld.begin(); aSetIt != rOld.end(); ++aSetIt, ++i) + for (const auto& rIt : rOld) { - auto aTextBoxIt = rSavedLinks.find(aSetIt->GetFormat()); + auto aTextBoxIt = rSavedLinks.find(rIt.GetFormat()); if (aTextBoxIt != rSavedLinks.end()) { std::size_t j = 0; - for (auto aSetJt = rOld.begin(); aSetJt != rOld.end(); ++aSetJt, ++j) + for (const auto& rJt : rOld) { - if (aSetJt->GetFormat() == aTextBoxIt->second) + if (rJt.GetFormat() == aTextBoxIt->second) rNew[i]->SetFormatAttr(rNew[j]->GetContent()); + ++j; } } - if (rResetContent.find(aSetIt->GetFormat()) != rResetContent.end()) - const_cast<SwFrameFormat*>(aSetIt->GetFormat()) - ->SetFormatAttr(rResetContent[aSetIt->GetFormat()]); + if (rResetContent.find(rIt.GetFormat()) != rResetContent.end()) + const_cast<SwFrameFormat*>(rIt.GetFormat()) + ->SetFormatAttr(rResetContent[rIt.GetFormat()]); + ++i; } } diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index f323f0a8ea58..88d2cef844c7 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -140,8 +140,8 @@ static void lcl_CopyTableLine( const SwTableLine* pLine, CopyTable* pCT ); static void lcl_CopyTableBox( SwTableBox* pBox, CopyTable* pCT ) { SwTableBoxFormat * pBoxFormat = static_cast<SwTableBoxFormat*>(pBox->GetFrameFormat()); - for (MapTableFrameFormats::const_iterator it = pCT->m_rMapArr.begin(); it != pCT->m_rMapArr.end(); ++it) - if ( !lcl_SrchNew( *it, reinterpret_cast<SwFrameFormat**>(&pBoxFormat) ) ) + for (const auto& rMap : pCT->m_rMapArr) + if ( !lcl_SrchNew( rMap, reinterpret_cast<SwFrameFormat**>(&pBoxFormat) ) ) break; if (pBoxFormat == pBox->GetFrameFormat()) // Create a new one? @@ -205,8 +205,8 @@ static void lcl_CopyTableBox( SwTableBox* pBox, CopyTable* pCT ) static void lcl_CopyTableLine( const SwTableLine* pLine, CopyTable* pCT ) { SwTableLineFormat * pLineFormat = static_cast<SwTableLineFormat*>(pLine->GetFrameFormat()); - for (MapTableFrameFormats::const_iterator it = pCT->m_rMapArr.begin(); it != pCT->m_rMapArr.end(); ++it) - if ( !lcl_SrchNew( *it, reinterpret_cast<SwFrameFormat**>(&pLineFormat) ) ) + for (const auto& rMap : pCT->m_rMapArr) + if ( !lcl_SrchNew( rMap, reinterpret_cast<SwFrameFormat**>(&pLineFormat) ) ) break; if( pLineFormat == pLine->GetFrameFormat() ) // Create a new one? @@ -228,9 +228,8 @@ static void lcl_CopyTableLine( const SwTableLine* pLine, CopyTable* pCT ) } pCT->m_pInsLine = pNewLine; - for( SwTableBoxes::iterator it = const_cast<SwTableLine*>(pLine)->GetTabBoxes().begin(); - it != const_cast<SwTableLine*>(pLine)->GetTabBoxes().end(); ++it) - lcl_CopyTableBox(*it, pCT ); + for( auto& rpBox : const_cast<SwTableLine*>(pLine)->GetTabBoxes() ) + lcl_CopyTableBox(rpBox, pCT); } SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index f206d2eb04a9..bc4535be0d23 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1201,16 +1201,16 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > SwNodeIndex const prev(rTableNodes.begin()->begin()->aStart, -1); SwNodeIndex const* pPrev(&prev); // pPrev could point to non-textnode now - for (auto row = rTableNodes.begin(); row != rTableNodes.end(); ++row) + for (const auto& rRow : rTableNodes) { - for (auto cell = row->begin(); cell != row->end(); ++cell) + for (const auto& rCell : rRow) { - assert(SwNodeIndex(*pPrev, +1) == cell->aStart); - SwPaM pam(cell->aStart, 0, *pPrev, + assert(SwNodeIndex(*pPrev, +1) == rCell.aStart); + SwPaM pam(rCell.aStart, 0, *pPrev, (pPrev->GetNode().IsContentNode()) ? pPrev->GetNode().GetContentNode()->Len() : 0); rIDRA.SplitRedline(pam); - pPrev = &cell->aEnd; + pPrev = &rCell.aEnd; } } // another one to break between last cell and node after table @@ -1386,7 +1386,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes, SwDoc* pDoc = GetDoc(); SwTable& rTable = pTableNd->GetTable(); SwTableBox* pBox; - sal_uInt16 nBoxes, nLines, nMaxBoxes = 0; + sal_uInt16 nLines, nMaxBoxes = 0; SwNodeIndex aNodeIndex = rTableNodes.begin()->begin()->aStart; // delete frames of all contained content nodes @@ -1400,46 +1400,45 @@ SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes, } } - std::vector<std::vector < SwNodeRange > >::const_iterator aRowIter = rTableNodes.begin(); - for( nLines = 0, nBoxes = 0; - aRowIter != rTableNodes.end(); - ++aRowIter, nLines++, nBoxes = 0 ) + nLines = 0; + for( const auto& rRow : rTableNodes ) { + sal_uInt16 nBoxes = 0; SwTableLine* pLine = new SwTableLine( pLineFormat, 1, nullptr ); rTable.GetTabLines().insert(rTable.GetTabLines().begin() + nLines, pLine); - std::vector< SwNodeRange >::const_iterator aCellIter = aRowIter->begin(); - - for( ; aCellIter != aRowIter->end(); ++aCellIter ) + for( const auto& rCell : rRow ) { - const SwNodeIndex aTmpIdx( aCellIter->aStart, 0 ); + const SwNodeIndex aTmpIdx( rCell.aStart, 0 ); - SwNodeIndex aCellEndIdx(aCellIter->aEnd); - ++aCellEndIdx; - SwStartNode* pSttNd = new SwStartNode( aTmpIdx, SwNodeType::Start, - SwTableBoxStartNode ); + SwNodeIndex aCellEndIdx(rCell.aEnd); + ++aCellEndIdx; + SwStartNode* pSttNd = new SwStartNode( aTmpIdx, SwNodeType::Start, + SwTableBoxStartNode ); - // Quotation of http://nabble.documentfoundation.org/Some-strange-lines-by-taking-a-look-at-the-bt-of-fdo-51916-tp3994561p3994639.html - // SwNode's constructor adds itself to the same SwNodes array as the other node (pSttNd). - // So this statement is only executed for the side-effect. - new SwEndNode( aCellEndIdx, *pSttNd ); + // Quotation of http://nabble.documentfoundation.org/Some-strange-lines-by-taking-a-look-at-the-bt-of-fdo-51916-tp3994561p3994639.html + // SwNode's constructor adds itself to the same SwNodes array as the other node (pSttNd). + // So this statement is only executed for the side-effect. + new SwEndNode( aCellEndIdx, *pSttNd ); - //set the start node on all node of the current cell - SwNodeIndex aCellNodeIdx = aCellIter->aStart; - for(;aCellNodeIdx <= aCellIter->aEnd; ++aCellNodeIdx ) - { - aCellNodeIdx.GetNode().m_pStartOfSection = pSttNd; - //skip start/end node pairs - if( aCellNodeIdx.GetNode().IsStartNode() ) - aCellNodeIdx.Assign(*aCellNodeIdx.GetNode().EndOfSectionNode()); - } + //set the start node on all node of the current cell + SwNodeIndex aCellNodeIdx = rCell.aStart; + for(;aCellNodeIdx <= rCell.aEnd; ++aCellNodeIdx ) + { + aCellNodeIdx.GetNode().m_pStartOfSection = pSttNd; + //skip start/end node pairs + if( aCellNodeIdx.GetNode().IsStartNode() ) + aCellNodeIdx.Assign(*aCellNodeIdx.GetNode().EndOfSectionNode()); + } - // assign Section to the Box - pBox = new SwTableBox( pBoxFormat, *pSttNd, pLine ); - pLine->GetTabBoxes().insert( pLine->GetTabBoxes().begin() + nBoxes++, pBox ); + // assign Section to the Box + pBox = new SwTableBox( pBoxFormat, *pSttNd, pLine ); + pLine->GetTabBoxes().insert( pLine->GetTabBoxes().begin() + nBoxes++, pBox ); } if( nMaxBoxes < nBoxes ) nMaxBoxes = nBoxes; + + nLines++; } lcl_SetTableBoxWidths2(rTable, nMaxBoxes, *pBoxFormat, *pDoc); @@ -1514,9 +1513,8 @@ static void lcl_DelLine( SwTableLine* pLine, DelTabPara* pPara ) { assert(pPara && "The parameters are missing!"); DelTabPara aPara( *pPara ); - for( SwTableBoxes::iterator it = pLine->GetTabBoxes().begin(); - it != pLine->GetTabBoxes().end(); ++it) - lcl_DelBox(*it, &aPara ); + for( auto& rpBox : pLine->GetTabBoxes() ) + lcl_DelBox(rpBox, &aPara ); if( pLine->GetUpper() ) // Is there a parent Box? // Return the last TextNode pPara->pLastNd = aPara.pLastNd; @@ -2645,15 +2643,15 @@ void SwDoc::GetTabRows( SwTabCols &rFill, const SwCellFrame* pBoxFrame ) // transfer calculated values from BoundaryMap and HiddenMap into rFill: size_t nIdx = 0; - for ( aIter = aBoundaries.begin(); aIter != aBoundaries.end(); ++aIter ) + for ( const auto& rEntry : aBoundaries ) { const long nTabTop = aRectFnSet.GetPrtTop(*pTab); - const long nKey = aRectFnSet.YDiff( (*aIter).first, nTabTop ); - const std::pair< long, long > aTmpPair = (*aIter).second; + const long nKey = aRectFnSet.YDiff( rEntry.first, nTabTop ); + const std::pair< long, long > aTmpPair = rEntry.second; const long nFirst = aRectFnSet.YDiff( aTmpPair.first, nTabTop ); const long nSecond = aTmpPair.second; - aHiddenIter = aHidden.find( (*aIter).first ); + aHiddenIter = aHidden.find( rEntry.first ); const bool bHidden = aHiddenIter != aHidden.end() && (*aHiddenIter).second; rFill.Insert( nKey, nFirst, nSecond, bHidden, nIdx++ ); } @@ -2970,13 +2968,11 @@ bool sw_Line_CollectBox( const SwTableLine*& rpLine, void* pPara ) { SwCollectTableLineBoxes* pSplPara = static_cast<SwCollectTableLineBoxes*>(pPara); if( pSplPara->IsGetValues() ) - for( SwTableBoxes::iterator it = const_cast<SwTableLine*>(rpLine)->GetTabBoxes().begin(); - it != const_cast<SwTableLine*>(rpLine)->GetTabBoxes().end(); ++it) - sw_Box_CollectBox(*it, pSplPara ); + for( const auto& rpBox : const_cast<SwTableLine*>(rpLine)->GetTabBoxes() ) + sw_Box_CollectBox(rpBox, pSplPara ); else - for( SwTableBoxes::iterator it = const_cast<SwTableLine*>(rpLine)->GetTabBoxes().begin(); - it != const_cast<SwTableLine*>(rpLine)->GetTabBoxes().end(); ++it) - sw_BoxSetSplitBoxFormats(*it, pSplPara ); + for( auto& rpBox : const_cast<SwTableLine*>(rpLine)->GetTabBoxes() ) + sw_BoxSetSplitBoxFormats(rpBox, pSplPara ); return true; } @@ -3148,15 +3144,13 @@ bool SwDoc::SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eHdlnM SwCollectTableLineBoxes aPara( false, eHdlnMode ); SwTableLine* pLn = rTable.GetTabLines()[ rTable.GetTabLines().size() - 1 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_Box_CollectBox(*it, &aPara ); + for( const auto& rpBox : pLn->GetTabBoxes() ) + sw_Box_CollectBox(rpBox, &aPara ); aPara.SetValues( true ); pLn = pNew->GetTable().GetTabLines()[ 0 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_BoxSetSplitBoxFormats(*it, &aPara ); + for( auto& rpBox : pLn->GetTabBoxes() ) + sw_BoxSetSplitBoxFormats(rpBox, &aPara ); // Switch off repeating Header pNew->GetTable().SetRowsToRepeat( 0 ); @@ -3173,15 +3167,13 @@ bool SwDoc::SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eHdlnM SwCollectTableLineBoxes aPara( true, eHdlnMode, pHst ); SwTableLine* pLn = rTable.GetTabLines()[ 0 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_Box_CollectBox(*it, &aPara ); + for( const auto& rpBox : pLn->GetTabBoxes() ) + sw_Box_CollectBox(rpBox, &aPara ); aPara.SetValues( true ); pLn = pNew->GetTable().GetTabLines()[ 0 ]; - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - sw_BoxSetSplitBoxFormats(*it, &aPara ); + for( auto& rpBox : pLn->GetTabBoxes() ) + sw_BoxSetSplitBoxFormats(rpBox, &aPara ); } break; @@ -3295,9 +3287,8 @@ static void lcl_SplitTable_CpyLine( SwTableLine* pLn, SplitTable_Para* pPara ) else pLn->ChgFrameFormat( pDestFormat ); - for( SwTableBoxes::iterator it = pLn->GetTabBoxes().begin(); - it != pLn->GetTabBoxes().end(); ++it) - lcl_SplitTable_CpyBox(*it, pPara ); + for( auto& rpBox : pLn->GetTabBoxes() ) + lcl_SplitTable_CpyBox(rpBox, pPara ); } static void lcl_SplitTable_CpyBox( SwTableBox* pBox, SplitTable_Para* pPara ) diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 9c36a1fadff7..27fa3622e931 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1636,9 +1636,8 @@ bool SwContentNode::ResetAttr( const std::vector<sal_uInt16>& rWhichArr ) SwAttrSet aOld( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ), aNew( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ); - std::vector<sal_uInt16>::const_iterator it; - for ( it = rWhichArr.begin(); it != rWhichArr.end(); ++it ) - if( AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, *it, &aOld, &aNew )) + for ( const auto& rWhich : rWhichArr ) + if( AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, rWhich, &aOld, &aNew )) ++nDel; if( nDel ) @@ -1708,11 +1707,9 @@ sal_uInt16 SwContentNode::ClearItemsFromAttrSet( const std::vector<sal_uInt16>& OSL_ENSURE( GetpSwAttrSet(), "no item set" ); SwAttrSet aNewAttrSet( *GetpSwAttrSet() ); - for ( std::vector<sal_uInt16>::const_iterator aIter = rWhichIds.begin(); - aIter != rWhichIds.end(); - ++aIter ) + for ( const auto& rWhichId : rWhichIds ) { - nRet = nRet + aNewAttrSet.ClearItem( *aIter ); + nRet = nRet + aNewAttrSet.ClearItem( rWhichId ); } if ( nRet ) AttrSetHandleHelper::GetNewAutoStyle( mpAttrSet, *this, aNewAttrSet ); diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 5c9c46df21d3..a95bde0b4144 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -387,10 +387,8 @@ void SwDrawView::MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj, } // move 'repeated' ones of 'child' objects - for ( std::vector<SdrObject*>::const_iterator aObjIter = _rMovedChildObjs.begin(); - aObjIter != _rMovedChildObjs.end(); ++aObjIter ) + for ( SdrObject* pChildObj : _rMovedChildObjs ) { - SdrObject* pChildObj = (*aObjIter); { const SwContact* pContact = ::GetUserCall( pChildObj ); assert(pContact && "SwDrawView::MoveRepeatedObjs(..) - missing contact object -> crash."); @@ -977,8 +975,8 @@ void SwDrawView::DeleteMarked() ::FrameNotify( Imp().GetShell(), FLY_DRAG_END ); // Only delete these now: earlier deletion would clear the mark list as well. - for (std::vector<SwFrameFormat*>::iterator i = aTextBoxesToDelete.begin(); i != aTextBoxesToDelete.end(); ++i) - pDoc->getIDocumentLayoutAccess().DelLayoutFormat(*i); + for (auto& rpTextBox : aTextBoxesToDelete) + pDoc->getIDocumentLayoutAccess().DelLayoutFormat(rpTextBox); } pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr); if( pTmpRoot ) 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; } diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 8211f3b18ebd..d3edf112736c 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1175,8 +1175,8 @@ void RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, bool bField ) GetFieldIdsFromDoc( rDoc, aDstIds ); // Map all the new src fields to the next available unused id - for ( std::set<sal_uInt16>::iterator pIt = aDstIds.begin(); pIt != aDstIds.end(); ++pIt ) - AddId( GetFirstUnusedId(aIds), *pIt ); + for (const auto& rId : aDstIds) + AddId( GetFirstUnusedId(aIds), rId ); // Change the Sequence number of all SetExp fields in the source document SwFieldType* pType = rDoc.getIDocumentFieldsAccess().GetFieldType( SwFieldIds::SetExp, aName, false ); @@ -1198,8 +1198,8 @@ void RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, bool bField ) GetNoteIdsFromDoc( rDestDoc, aIds ); GetNoteIdsFromDoc( rDoc, aDstIds ); - for (std::set<sal_uInt16>::iterator pIt = aDstIds.begin(); pIt != aDstIds.end(); ++pIt) - AddId( GetFirstUnusedId(aIds), *pIt ); + for (const auto& rId : aDstIds) + AddId( GetFirstUnusedId(aIds), rId ); // Change the footnotes/endnotes in the source doc to the new ID for ( const auto pFootnoteIdx : rDoc.GetFootnoteIdxs() ) @@ -1217,11 +1217,10 @@ void RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, bool bField ) sal_uInt16 RefIdsMap::GetFirstUnusedId( std::set<sal_uInt16> &rIds ) { sal_uInt16 num(0); - std::set<sal_uInt16>::iterator it; - for( it = rIds.begin(); it != rIds.end(); ++it ) + for( const auto& rId : rIds ) { - if( num != *it ) + if( num != rId ) { return num; } diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index e1ba7f7d2adf..8a1c36b28f48 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -1887,18 +1887,16 @@ void SwFEShell::GetConnectableFrameFormats(SwFrameFormat & rFormat, /* number of page rFormat resides on */ sal_uInt16 nPageNum = SwFormatGetPageNum(static_cast<SwFlyFrameFormat *>(&rFormat)); - std::vector< const SwFrameFormat * >::const_iterator aIt; - - for (aIt = aTmpSpzArray.begin(); aIt != aTmpSpzArray.end(); ++aIt) + for (const auto& rpFormat : aTmpSpzArray) { - const OUString aString = (*aIt)->GetName(); + const OUString aString = rpFormat->GetName(); /* rFormat is not a valid successor or predecessor of itself */ if (aString != rReference && aString != rFormat.GetName()) { sal_uInt16 nNum1 = - SwFormatGetPageNum(static_cast<const SwFlyFrameFormat *>(*aIt)); + SwFormatGetPageNum(static_cast<const SwFlyFrameFormat *>(rpFormat)); if (nNum1 == nPageNum -1) aPrevPageVec.push_back(aString); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 5aa912204eac..0b50d6d938f4 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -2279,12 +2279,8 @@ static bool lcl_IsFormulaSelBoxes( const SwTable& rTable, const SwTableBoxFormul for (size_t nSelBoxes = aBoxes.size(); nSelBoxes; ) { SwTableBox* pBox = aBoxes[ --nSelBoxes ]; - SwCellFrames::iterator iC; - for( iC = rCells.begin(); iC != rCells.end(); ++iC ) - if( (*iC)->GetTabBox() == pBox ) - break; // found - if( iC == rCells.end() ) + if( std::none_of(rCells.begin(), rCells.end(), [&pBox](SwCellFrame* pFrame) { return pFrame->GetTabBox() == pBox; }) ) return false; } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 6f17da290939..d08545eaaf7f 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -2083,9 +2083,8 @@ static void FndLineCopyCol( SwTableLine* pLine, FndPara* pFndPara ) { std::unique_ptr<FndLine_> pFndLine(new FndLine_(pLine, pFndPara->pFndBox)); FndPara aPara(*pFndPara, pFndLine.get()); - for( SwTableBoxes::iterator it = pFndLine->GetLine()->GetTabBoxes().begin(); - it != pFndLine->GetLine()->GetTabBoxes().end(); ++it) - FndBoxCopyCol(*it, &aPara ); + for( auto& rpBox : pFndLine->GetLine()->GetTabBoxes() ) + FndBoxCopyCol(rpBox, &aPara ); if( !pFndLine->GetBoxes().empty() ) { pFndPara->pFndBox->GetLines().push_back( std::move(pFndLine) ); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 67dc38f2223d..de02414bdaf5 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3528,9 +3528,9 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc) std::vector<SwFrameFormat*> const*const pFlys(pNode->GetAnchoredFlys()); if (pFlys) { - for (auto it = pFlys->begin(); it != pFlys->end(); ++it) + for (const auto& rpFly : *pFlys) { - SwFormatAnchor const& rAnchor((**it).GetAnchor(false)); + SwFormatAnchor const& rAnchor((*rpFly).GetAnchor(false)); assert(&rAnchor.GetContentAnchor()->nNode.GetNode() == pNode); } } diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index d4cd2b349b87..62028b741499 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -175,8 +175,8 @@ bool SwLayAction::PaintWithoutFlys( const SwRect &rRect, const SwContentFrame *p } bool bRetPaint = false; - for ( SwRects::const_iterator it = aTmp.begin(); it != aTmp.end(); ++it ) - bRetPaint |= m_pImp->GetShell()->AddPaintRect( *it ); + for ( const auto& rRegionRect : aTmp ) + bRetPaint |= m_pImp->GetShell()->AddPaintRect( rRegionRect ); return bRetPaint; } diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index b507e0933293..2e6ffcc7e315 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -1013,14 +1013,11 @@ void SwLayHelper::CheckFlyCache_( SwPageFrame* pPage ) if ( aFlyCacheSet.size() == aFlySet.size() ) { - std::set< const SwFlyCache*, FlyCacheCompare >::iterator aFlyCacheSetIt = - aFlyCacheSet.begin(); std::set< const SdrObject*, SdrObjectCompare >::iterator aFlySetIt = aFlySet.begin(); - while ( aFlyCacheSetIt != aFlyCacheSet.end() ) + for ( const SwFlyCache* pFlyCache : aFlyCacheSet ) { - const SwFlyCache* pFlyCache = *aFlyCacheSetIt; SwFlyFrame* pFly = const_cast<SwVirtFlyDrawObj*>(static_cast<const SwVirtFlyDrawObj*>(*aFlySetIt))->GetFlyFrame(); if ( pFly->getFrameArea().Left() == FAR_AWAY ) @@ -1037,7 +1034,6 @@ void SwLayHelper::CheckFlyCache_( SwPageFrame* pPage ) } } - ++aFlyCacheSetIt; ++aFlySetIt; } } diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx index 7a5ff2ac591c..adc2909c38a5 100644 --- a/sw/source/core/layout/newfrm.cxx +++ b/sw/source/core/layout/newfrm.cxx @@ -319,9 +319,8 @@ void SwRootFrame::DeRegisterShell( SwViewShell *pSh ) mpWaitingCurrShell = nullptr; // Remove references - for ( SwCurrShells::iterator it = mpCurrShells->begin(); it != mpCurrShells->end(); ++it ) + for ( CurrShell *pC : *mpCurrShells ) { - CurrShell *pC = *it; if (pC->pPrev == pSh) pC->pPrev = nullptr; } @@ -484,8 +483,8 @@ void SwRootFrame::DestroyImpl() mpDestroy.reset(); // Remove references - for ( SwCurrShells::iterator it = mpCurrShells->begin(); it != mpCurrShells->end(); ++it ) - (*it)->pRoot = nullptr; + for ( auto& rpCurrShell : *mpCurrShells ) + rpCurrShell->pRoot = nullptr; mpCurrShells.reset(); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index bfb80dbd8de8..67979b8d4984 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1052,10 +1052,8 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut, pOut->SetDrawMode( DrawModeFlags::Default ); } - for (SwSubsRects::iterator it = aLineRects.begin(); it != aLineRects.end(); - ++it) + for (SwLineRect& rLRect : aLineRects) { - SwLineRect &rLRect = (*it); // Add condition <!rLRect.IsLocked()> to prevent paint of locked subsidiary lines. if ( !rLRect.IsPainted() && !rLRect.IsLocked() ) @@ -2399,11 +2397,9 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons break; const SwLineEntrySet& rEntrySet = (*aIter).second; - for (SwLineEntrySet::const_iterator aSetIter = rEntrySet.begin(); - aSetIter != rEntrySet.end(); ++aSetIter) + for (const SwLineEntry& rEntry : rEntrySet) { - const SwLineEntry& rEntry = *aSetIter; - const svx::frame::Style& rEntryStyle( (*aSetIter).maAttribute ); + const svx::frame::Style& rEntryStyle( rEntry.maAttribute ); Point aStart, aEnd; if ( bHori ) @@ -2607,11 +2603,9 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint, SwLineEntryMap::const_iterator aMapIter = maVertLines.find( rStartPoint.X() ); OSL_ENSURE( aMapIter != maVertLines.end(), "FindStylesForLine: Error" ); const SwLineEntrySet& rVertSet = (*aMapIter).second; - SwLineEntrySet::const_iterator aIter = rVertSet.begin(); - while ( aIter != rVertSet.end() ) + for ( const SwLineEntry& rEntry : rVertSet ) { - const SwLineEntry& rEntry = *aIter; if ( bHori ) { if ( rStartPoint.Y() == rEntry.mnStartPos ) @@ -2626,17 +2620,14 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint, else if ( rEndPoint.Y() == rEntry.mnStartPos ) pStyles[ 5 ] = rEntry.maAttribute; } - ++aIter; } aMapIter = maHoriLines.find( rStartPoint.Y() ); OSL_ENSURE( aMapIter != maHoriLines.end(), "FindStylesForLine: Error" ); const SwLineEntrySet& rHoriSet = (*aMapIter).second; - aIter = rHoriSet.begin(); - while ( aIter != rHoriSet.end() ) + for ( const SwLineEntry& rEntry : rHoriSet ) { - const SwLineEntry& rEntry = *aIter; if ( bHori ) { if ( rStartPoint.X() == rEntry.mnEndPos ) @@ -2651,7 +2642,6 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint, else if ( rStartPoint.X() == rEntry.mnStartPos ) pStyles[ 3 ] = rEntry.maAttribute; } - ++aIter; } if ( bHori ) @@ -2659,16 +2649,13 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint, aMapIter = maVertLines.find( rEndPoint.X() ); OSL_ENSURE( aMapIter != maVertLines.end(), "FindStylesForLine: Error" ); const SwLineEntrySet& rVertSet2 = (*aMapIter).second; - aIter = rVertSet2.begin(); - while ( aIter != rVertSet2.end() ) + for ( const SwLineEntry& rEntry : rVertSet2 ) { - const SwLineEntry& rEntry = *aIter; if ( rEndPoint.Y() == rEntry.mnStartPos ) pStyles[ 6 ] = rEntry.maAttribute; else if ( rEndPoint.Y() == rEntry.mnEndPos ) pStyles[ 4 ] = rEntry.maAttribute; - ++aIter; } } else @@ -2676,16 +2663,13 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint, aMapIter = maHoriLines.find( rEndPoint.Y() ); OSL_ENSURE( aMapIter != maHoriLines.end(), "FindStylesForLine: Error" ); const SwLineEntrySet& rHoriSet2 = (*aMapIter).second; - aIter = rHoriSet2.begin(); - while ( aIter != rHoriSet2.end() ) + for ( const SwLineEntry& rEntry : rHoriSet2 ) { - const SwLineEntry& rEntry = *aIter; if ( rEndPoint.X() == rEntry.mnEndPos ) pStyles[ 4 ] = rEntry.maAttribute; else if ( rEndPoint.X() == rEntry.mnStartPos ) pStyles[ 6 ] = rEntry.maAttribute; - ++aIter; } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits