diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-11 09:53:50 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-12 07:12:44 +0000 |
commit | b415494bf0468b74318b61f114e2ff4ae68c00ee (patch) | |
tree | 432f9397ecf4c410e4e9767f433c60e4dc0b0087 /sw/source/uibase | |
parent | 875984617cfd6c773eb93f339929eb3fabd3e97b (diff) |
clang-tidy modernize-loop-convert in sw
Change-Id: I1f4a0ad6658bd3154c48940296aa8edc1ea1612c
Reviewed-on: https://gerrit.libreoffice.org/24876
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sw/source/uibase')
24 files changed, 122 insertions, 138 deletions
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index a4a0a557621c..dcbfba26e97e 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -2956,43 +2956,43 @@ void SwStyleSheetIterator::AppendStyleList(const ::std::vector<OUString>& rList, { SwDoc& rDoc = static_cast<SwDocStyleSheetPool*>(pBasePool)->GetDoc(); bool bUsed = false; - for ( size_t i=0; i < rList.size(); ++i ) + for (const auto & i : rList) { bool bHidden = false; - sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rList[i], (SwGetPoolIdFromName)nSection); + sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(i, (SwGetPoolIdFromName)nSection); switch ( nSection ) { case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL: { bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( nId ); - SwFormat* pFormat = rDoc.FindTextFormatCollByName( rList[i] ); + SwFormat* pFormat = rDoc.FindTextFormatCollByName( i ); bHidden = pFormat && pFormat->IsHidden( ); } break; case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT: { bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId ); - SwFormat* pFormat = rDoc.FindCharFormatByName( rList[i] ); + SwFormat* pFormat = rDoc.FindCharFormatByName( i ); bHidden = pFormat && pFormat->IsHidden( ); } break; case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT: { bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId ); - SwFormat* pFormat = rDoc.FindFrameFormatByName( rList[i] ); + SwFormat* pFormat = rDoc.FindFrameFormatByName( i ); bHidden = pFormat && pFormat->IsHidden( ); } break; case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC: { bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolPageDescUsed( nId ); - SwPageDesc* pPgDesc = rDoc.FindPageDesc(rList[i]); + SwPageDesc* pPgDesc = rDoc.FindPageDesc(i); bHidden = pPgDesc && pPgDesc->IsHidden( ); } break; case nsSwGetPoolIdFromName::GET_POOLID_NUMRULE: { - SwNumRule* pRule = rDoc.FindNumRulePtr( rList[i] ); + SwNumRule* pRule = rDoc.FindNumRulePtr( i ); bUsed = pRule && SwDoc::IsUsed( *pRule ); bHidden = pRule && pRule->IsHidden( ); } @@ -3003,7 +3003,7 @@ void SwStyleSheetIterator::AppendStyleList(const ::std::vector<OUString>& rList, bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) ); if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) ) - aLst.Append( cType, rList[i] ); + aLst.Append( cType, i ); } } diff --git a/sw/source/uibase/app/mainwn.cxx b/sw/source/uibase/app/mainwn.cxx index b61d681cda91..a1968cf4b4bc 100644 --- a/sw/source/uibase/app/mainwn.cxx +++ b/sw/source/uibase/app/mainwn.cxx @@ -38,9 +38,8 @@ static std::vector<SwProgress*> *pProgressContainer = nullptr; static SwProgress *lcl_SwFindProgress( SwDocShell *pDocShell ) { - for ( size_t i = 0; i < pProgressContainer->size(); ++i ) + for (SwProgress* pTmp : *pProgressContainer) { - SwProgress *pTmp = (*pProgressContainer)[i]; if ( pTmp->pDocShell == pDocShell ) return pTmp; } diff --git a/sw/source/uibase/config/uinums.cxx b/sw/source/uibase/config/uinums.cxx index 01805bca5bd1..277b8244dd9d 100644 --- a/sw/source/uibase/config/uinums.cxx +++ b/sw/source/uibase/config/uinums.cxx @@ -73,14 +73,14 @@ void SwChapterNumRules::Save() SwChapterNumRules::~SwChapterNumRules() { - for( sal_uInt16 i = 0; i < nMaxRules; ++i ) - delete pNumRules[i]; + for(SwNumRulesWithName* pNumRule : pNumRules) + delete pNumRule; } void SwChapterNumRules::Init() { - for(sal_uInt16 i = 0; i < nMaxRules; ++i ) - pNumRules[i] = nullptr; + for(SwNumRulesWithName* & rpNumRule : pNumRules) + rpNumRule = nullptr; OUString sNm(CHAPTER_FILENAME); SvtPathOptions aOpt; @@ -136,8 +136,8 @@ SwNumRulesWithName::SwNumRulesWithName( const SwNumRulesWithName& rCopy ) SwNumRulesWithName::~SwNumRulesWithName() { - for( int n = 0; n < MAXLEVEL; ++n ) - delete aFormats[ n ]; + for(SwNumFormatGlobal* p : aFormats) + delete p; } const SwNumRulesWithName& SwNumRulesWithName::operator=(const SwNumRulesWithName &rCopy) diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index 630149f39d9b..08bf9c1b29d3 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -441,10 +441,9 @@ bool SwGlossaryHdl::Expand( const OUString& rShortName, std::unique_ptr<AbstractSwSelGlossaryDlg> pDlg(pFact->CreateSwSelGlossaryDlg(aShortName)); assert(pDlg && "Dialog creation failed!"); - for(size_t i = 0; i < aFoundArr.size(); ++i) + for(TextBlockInfo_Impl & i : aFoundArr) { - TextBlockInfo_Impl* pData = &aFoundArr[i]; - pDlg->InsertGlos(pData->sTitle, pData->sLongName); + pDlg->InsertGlos(i.sTitle, i.sLongName); } pDlg->SelectEntryPos(0); const sal_Int32 nRet = RET_OK == pDlg->Execute()? diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 36acfa22a632..1ef3524c1872 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -606,40 +606,40 @@ void SwPostItMgr::LayoutPostIts() // - place SwPostIts on their initial position // - calculate necessary height for all PostIts together bool bUpdate = false; - for (unsigned long n=0;n<mPages.size();n++) + for (SwPostItPageItem* pPage : mPages) { // only layout if there are notes on this page - if (mPages[n]->mList->size()>0) + if (pPage->mList->size()>0) { std::list<SwSidebarWin*> aVisiblePostItList; unsigned long lNeededHeight = 0; long mlPageBorder = 0; long mlPageEnd = 0; - for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i != mPages[n]->mList->end(); ++i) + for(SwSidebarItem_iterator i = pPage->mList->begin(); i != pPage->mList->end(); ++i) { SwSidebarItem* pItem = (*i); SwSidebarWin* pPostIt = pItem->pPostIt; - if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) + if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) { // x value for notes positioning - mlPageBorder = mpEditWin->LogicToPixel( Point( mPages[n]->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true); + mlPageBorder = mpEditWin->LogicToPixel( Point( pPage->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true); //bending point mlPageEnd = mpWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) ? pItem->maLayoutInfo.mPagePrtArea.Left() - : mPages[n]->mPageRect.Left() + 350; + : pPage->mPageRect.Left() + 350; } - else if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT ) + else if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT ) { // x value for notes positioning - mlPageBorder = mpEditWin->LogicToPixel( Point(mPages[n]->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true); + mlPageBorder = mpEditWin->LogicToPixel( Point(pPage->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true); //bending point mlPageEnd = mpWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) ? pItem->maLayoutInfo.mPagePrtArea.Right() : - mPages[n]->mPageRect.Right() - 350; + pPage->mPageRect.Right() - 350; } if (pItem->bShow) @@ -666,7 +666,7 @@ void SwPostItMgr::LayoutPostIts() pPostIt->SetChangeTracking( pItem->mLayoutStatus, GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor)); - pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition); + pPostIt->SetSidebarPosition(pPage->eSidebarPosition); pPostIt->SetFollow(pPostIt->CalcFollow()); aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() ? pPostIt->GetMinimumSizeWithoutMeta() @@ -699,25 +699,25 @@ void SwPostItMgr::LayoutPostIts() if ((!aVisiblePostItList.empty()) && ShowNotes()) { - bool bOldScrollbar = mPages[n]->bScrollbar; + bool bOldScrollbar = pPage->bScrollbar; if (ShowNotes()) - mPages[n]->bScrollbar = LayoutByPage(aVisiblePostItList, mPages[n]->mPageRect.SVRect(), lNeededHeight); + pPage->bScrollbar = LayoutByPage(aVisiblePostItList, pPage->mPageRect.SVRect(), lNeededHeight); else - mPages[n]->bScrollbar = false; - if (!mPages[n]->bScrollbar) + pPage->bScrollbar = false; + if (!pPage->bScrollbar) { - mPages[n]->lOffset = 0; + pPage->lOffset = 0; } else { //when we changed our zoom level, the offset value can be to big, so lets check for the largest possible zoom value - long aAvailableHeight = mpEditWin->LogicToPixel(Size(0,mPages[n]->mPageRect.Height())).Height() - 2 * GetSidebarScrollerHeight(); + long aAvailableHeight = mpEditWin->LogicToPixel(Size(0,pPage->mPageRect.Height())).Height() - 2 * GetSidebarScrollerHeight(); long lOffset = -1 * GetScrollSize() * (aVisiblePostItList.size() - aAvailableHeight / GetScrollSize()); - if (mPages[n]->lOffset < lOffset) - mPages[n]->lOffset = lOffset; + if (pPage->lOffset < lOffset) + pPage->lOffset = lOffset; } - bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate; - const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0; + bUpdate = (bOldScrollbar != pPage->bScrollbar) || bUpdate; + const long aSidebarheight = pPage->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0; /* TODO - enlarge all notes till GetNextBorder(), as we resized to average value before @@ -725,36 +725,36 @@ void SwPostItMgr::LayoutPostIts() //lets hide the ones which overlap the page for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) { - if (mPages[n]->lOffset != 0) - (*i)->TranslateTopPosition(mPages[n]->lOffset); + if (pPage->lOffset != 0) + (*i)->TranslateTopPosition(pPage->lOffset); - bool bBottom = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y()+(*i)->VirtualSize().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight); - bool bTop = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight); + bool bBottom = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y()+(*i)->VirtualSize().Height())).Y() <= (pPage->mPageRect.Bottom()-aSidebarheight); + bool bTop = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= (pPage->mPageRect.Top()+aSidebarheight); if ( bBottom && bTop ) { (*i)->ShowNote(); } else { - if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (mPages[n]->mPageRect.Top()+aSidebarheight)) + if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (pPage->mPageRect.Top()+aSidebarheight)) { - if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) - (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Left(), - mPages[n]->mPageRect.Top())); - else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT ) - (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Right(), - mPages[n]->mPageRect.Top())); + if ( pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) + (*i)->ShowAnchorOnly(Point( pPage->mPageRect.Left(), + pPage->mPageRect.Top())); + else if ( pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT ) + (*i)->ShowAnchorOnly(Point( pPage->mPageRect.Right(), + pPage->mPageRect.Top())); } else { - if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) - (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Left(), - mPages[n]->mPageRect.Bottom())); - else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT ) - (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Right(), - mPages[n]->mPageRect.Bottom())); + if ( pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) + (*i)->ShowAnchorOnly(Point(pPage->mPageRect.Left(), + pPage->mPageRect.Bottom())); + else if ( pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::RIGHT ) + (*i)->ShowAnchorOnly(Point(pPage->mPageRect.Right(), + pPage->mPageRect.Bottom())); } - OSL_ENSURE(mPages[n]->bScrollbar,"SwPostItMgr::LayoutByPage(): note overlaps, but bScrollbar is not true"); + OSL_ENSURE(pPage->bScrollbar,"SwPostItMgr::LayoutByPage(): note overlaps, but bScrollbar is not true"); } } } @@ -763,17 +763,17 @@ void SwPostItMgr::LayoutPostIts() for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) (*i)->SetPosAndSize(); - bool bOldScrollbar = mPages[n]->bScrollbar; - mPages[n]->bScrollbar = false; - bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate; + bool bOldScrollbar = pPage->bScrollbar; + pPage->bScrollbar = false; + bUpdate = (bOldScrollbar != pPage->bScrollbar) || bUpdate; } aVisiblePostItList.clear(); } else { - if (mPages[n]->bScrollbar) + if (pPage->bScrollbar) bUpdate = true; - mPages[n]->bScrollbar = false; + pPage->bScrollbar = false; } } @@ -1584,24 +1584,24 @@ SwSidebarWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection, long SwPostItMgr::GetNextBorder() { - for (unsigned long n=0;n<mPages.size();n++) + for (SwPostItPageItem* pPage : mPages) { - for(SwSidebarItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); ++b) + for(SwSidebarItem_iterator b = pPage->mList->begin(); b!= pPage->mList->end(); ++b) { if ((*b)->pPostIt == mpActivePostIt) { SwSidebarItem_iterator aNext = b; ++aNext; - bool bFollow = (aNext != mPages[n]->mList->end()) && (*aNext)->pPostIt->IsFollow(); - if ( mPages[n]->bScrollbar || bFollow ) + bool bFollow = (aNext != pPage->mList->end()) && (*aNext)->pPostIt->IsFollow(); + if ( pPage->bScrollbar || bFollow ) { return -1; } else { //if this is the last item, return the bottom border otherwise the next item - if (aNext == mPages[n]->mList->end()) - return mpEditWin->LogicToPixel(Point(0,mPages[n]->mPageRect.Bottom())).Y() - GetSpaceBetween(); + if (aNext == pPage->mList->end()) + return mpEditWin->LogicToPixel(Point(0,pPage->mPageRect.Bottom())).Y() - GetSpaceBetween(); else return (*aNext)->pPostIt->GetPosPixel().Y() - GetSpaceBetween(); } @@ -1830,14 +1830,14 @@ void SwPostItMgr::CorrectPositions() { long aAnchorPosX = 0; long aAnchorPosY = 0; - for (unsigned long n=0;n<mPages.size();n++) + for (SwPostItPageItem* pPage : mPages) { - for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i != mPages[n]->mList->end(); ++i) + for(SwSidebarItem_iterator i = pPage->mList->begin(); i != pPage->mList->end(); ++i) { // check, if anchor overlay object exists. if ( (*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->Anchor() ) { - aAnchorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT + aAnchorPosX = pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X() : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); aAnchorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 621277e0a475..91ada90b7358 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -917,10 +917,9 @@ void SwSidebarWin::SetPosAndSize() pTmpCursorForAnnotationTextRange->FillRects(); SwRects* pRects(pTmpCursorForAnnotationTextRange.get()); - for( size_t a(0); a < pRects->size(); ++a ) + for(SwRect & rNextRect : *pRects) { - const SwRect aNextRect((*pRects)[a]); - const Rectangle aPntRect(aNextRect.SVRect()); + const Rectangle aPntRect(rNextRect.SVRect()); aAnnotationTextRanges.push_back(basegfx::B2DRange( aPntRect.Left(), aPntRect.Top(), diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 5a4c0b7ddf3a..39cc8eaba67f 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -6137,10 +6137,8 @@ void QuickHelpData::FillStrArr( SwWrtShell& rSh, const OUString& rWord ) if ( rACList.GetWordsMatching( rWord, strings ) ) { - for (size_t i= 0; i<strings.size(); i++) + for (const OUString & aCompletedString : strings) { - OUString aCompletedString = strings[i]; - // when we have a matching current date, avoid to suggest // other words with the same matching starting characters, // for example 2016-01-3 instead of 2016-01-30 diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx index 7ceaf547d2aa..f5784b87e3ba 100644 --- a/sw/source/uibase/docvw/srcedtw.cxx +++ b/sw/source/uibase/docvw/srcedtw.cxx @@ -725,9 +725,8 @@ void SwSrcEditWindow::ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineO } } - for ( size_t i = 0; i < aPortionList.size(); i++ ) + for (TextPortion & r : aPortionList) { - TextPortion& r = aPortionList[i]; if ( r.nStart > r.nEnd ) // only until Bug from MD is resolved continue; if(r.eType != svtools::HTMLSGML && diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index b8c04d8b5a2a..9f02086a8aa4 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1604,9 +1604,9 @@ void SwFieldType::GetFieldName_() // insert infos for fields SwFieldType::s_pFieldNames = new std::vector<OUString>; SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms)); - for( sal_uInt16 nIdx = 0; nIdx < SAL_N_ELEMENTS(coFieldNms); ++nIdx ) + for(sal_uInt16 i : coFieldNms) { - const OUString aTmp(SW_RES( coFieldNms[ nIdx ] )); + const OUString aTmp(SW_RES( i )); SwFieldType::s_pFieldNames->push_back(MnemonicGenerator::EraseAllMnemonicChars( aTmp )); } } diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index 16cf70852094..0eff29ad9929 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -614,18 +614,16 @@ void SwSpellPopup::checkRedline() }; SwDoc *pDoc = m_pSh->GetDoc(); SfxItemSet aSet(pDoc->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_PREV_CHANGE); - for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i) + for (sal_uInt16 nWhich : pRedlineIds) { - const sal_uInt16 nWhich = pRedlineIds[i]; aSet.Put(SfxVoidItem(nWhich), nWhich); } m_pSh->GetView().GetState(aSet); // Enable/disable items based on if the which id of the void items are // cleared or not. - for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i) + for (sal_uInt16 nWhich : pRedlineIds) { - const sal_uInt16 nWhich = pRedlineIds[i]; EnableItem(nWhich, aSet.Get(nWhich).Which()); } } diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx index d2e85e9e6c39..009211c77d91 100644 --- a/sw/source/uibase/ribbar/workctrl.cxx +++ b/sw/source/uibase/ribbar/workctrl.cxx @@ -56,8 +56,6 @@ #error SwScrollNaviPopup-CTOR static array wrong size. Are new IDs added? #endif -#define ZOOM_ENTRIES 9 - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -304,9 +302,8 @@ void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt ) void SwScrollNaviPopup::ApplyImageList() { ImageList& rImgLst = aIList; - for(sal_uInt16 i = 0; i < NID_COUNT; i++) + for(sal_uInt16 nNaviId : aNavigationInsertIds) { - sal_uInt16 nNaviId = aNavigationInsertIds[i]; m_pToolBox->SetItemImage(nNaviId, rImgLst.GetImage(nNaviId)); } } @@ -413,9 +410,9 @@ SwZoomBox_Impl::SwZoomBox_Impl( RID_SVXSTR_ZOOM_150 , RID_SVXSTR_ZOOM_200 , RID_SVXSTR_ZOOM_WHOLE_PAGE, RID_SVXSTR_ZOOM_PAGE_WIDTH , RID_SVXSTR_ZOOM_OPTIMAL_VIEW }; - for(sal_uInt16 i = 0; i < ZOOM_ENTRIES ; i++) + for(sal_uInt16 aZoomValue : aZoomValues) { - OUString sEntry = SVX_RESSTR( aZoomValues[i] ); + OUString sEntry = SVX_RESSTR( aZoomValue ); InsertEntry(sEntry); } diff --git a/sw/source/uibase/shells/langhelper.cxx b/sw/source/uibase/shells/langhelper.cxx index 8ac54052c7c1..bc9aa3268445 100644 --- a/sw/source/uibase/shells/langhelper.cxx +++ b/sw/source/uibase/shells/langhelper.cxx @@ -339,25 +339,25 @@ namespace SwLangHelper OSL_ENSURE( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); if (pEditEngine) { - for (size_t i = 0; i < SAL_N_ELEMENTS(aLangWhichId_EE); ++i) - rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_EE[i] )); + for (sal_uInt16 i : aLangWhichId_EE) + rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, i )); pEditEngine->QuickSetAttribs(rCoreSet, rSelection); } else { rWrtSh.GetCurAttr( rCoreSet ); - for (size_t i = 0; i < SAL_N_ELEMENTS(aLangWhichId_Writer); ++i) - rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] )); + for (sal_uInt16 i : aLangWhichId_Writer) + rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, i )); rWrtSh.SetAttrSet( rCoreSet ); } } else // change language for all text { std::set<sal_uInt16> aAttribs; - for (size_t i = 0; i < SAL_N_ELEMENTS(aLangWhichId_Writer); ++i) + for (sal_uInt16 i : aLangWhichId_Writer) { - rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] ) ); - aAttribs.insert( aLangWhichId_Writer[i] ); + rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, i ) ); + aAttribs.insert( i ); } // set all language attributes to default @@ -471,9 +471,9 @@ namespace SwLangHelper RES_CHRATR_CTL_LANGUAGE }; nCurrentLang = LANGUAGE_NONE; - for (size_t i = 0; i < SAL_N_ELEMENTS(aScriptTypes); ++i) + for (sal_uInt16 aScriptType : aScriptTypes) { - LanguageType nTmpLang = GetLanguage( rSh, aScriptTypes[i] ); + LanguageType nTmpLang = GetLanguage( rSh, aScriptType ); if (nTmpLang != LANGUAGE_NONE) { nCurrentLang = LANGUAGE_DONTKNOW; @@ -519,9 +519,9 @@ namespace SwLangHelper EE_CHAR_LANGUAGE_CTL }; nCurrentLang = LANGUAGE_NONE; - for (size_t i = 0; i < SAL_N_ELEMENTS(aScriptTypes); ++i) + for (sal_uInt16 aScriptType : aScriptTypes) { - LanguageType nTmpLang = GetLanguage( aSet, aScriptTypes[i] ); + LanguageType nTmpLang = GetLanguage( aSet, aScriptType ); if (nTmpLang != LANGUAGE_NONE) { nCurrentLang = LANGUAGE_DONTKNOW; diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index 8be3911e478d..32a0f60973cb 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -122,11 +122,11 @@ public: StyleRedefinition* get(const OUString& aString) { - for (size_t i = 0; i < maStyles.size(); i++) + for (StyleRedefinition & rStyle : maStyles) { - if (maStyles[i].maElementName == aString) + if (rStyle.maElementName == aString) { - return &maStyles[i]; + return &rStyle; } } return nullptr; @@ -341,10 +341,10 @@ std::vector<FontSet> initFontSets() FontSet getFontSet(const OUString& rFontVariant, std::vector<FontSet>& aFontSets) { - for (size_t i = 0; i < aFontSets.size(); ++i) + for (FontSet & rFontSet : aFontSets) { - if (aFontSets[i].maName == rFontVariant) - return aFontSets[i]; + if (rFontSet.maName == rFontVariant) + return rFontSet; } return aFontSets[0]; } @@ -453,9 +453,9 @@ ThemePanel::ThemePanel(vcl::Window* pParent, mpValueSetColors->SetDoubleClickHdl(LINK(this, ThemePanel, DoubleClickValueSetHdl)); std::vector<FontSet> aFontSets = initFontSets(); - for (size_t i = 0; i < aFontSets.size(); ++i) + for (FontSet & rFontSet : aFontSets) { - mpListBoxFonts->InsertEntry(aFontSets[i].maName); + mpListBoxFonts->InsertEntry(rFontSet.maName); } maColorSets.init(); diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index 103dabff8563..de1b914a0a25 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -121,10 +121,10 @@ static sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, bool bZoomIn) } else { - for(int i = 0; i < nZoomArrSize; ++i) + for(sal_uInt16 i : aZoomArr) { - if(nCurrentZoom < aZoomArr[i]) - return aZoomArr[i]; + if(nCurrentZoom < i) + return i; } } return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM; diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 5d6991b389de..ad55f89b1265 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -326,9 +326,9 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq ) const ::std::vector<OUString>& rFramePoolArr( SwStyleNameMapper::GetFrameFormatUINameArray()); - for( size_t i = 0; i < rFramePoolArr.size(); ++i ) + for(const auto & i : rFramePoolArr) { - aFormats.push_back(rFramePoolArr[i]); + aFormats.push_back(i); } std::sort(aFormats.begin(), aFormats.end()); diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 974999f9bc2e..a15c1ade2871 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -115,9 +115,8 @@ static void lcl_emitSearchResultCallbacks(SvxSearchItem* pSearchItem, SwWrtShell std::vector<OString> aSelectionRectangles; pShellCursor->SwSelPaintRects::Show(&aSelectionRectangles); std::vector<OString> aRect; - for (size_t i = 0; i < aSelectionRectangles.size(); ++i) + for (const OString & rSelectionRectangle : aSelectionRectangles) { - const OString& rSelectionRectangle = aSelectionRectangles[i]; if (rSelectionRectangle.isEmpty()) continue; aRect.push_back(rSelectionRectangle); diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index 7b94a1dad07f..b4d865c0786a 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -71,10 +71,9 @@ static void lcl_FillSvxColumn(const SwFormatCol& rCol, if( bOrtho ) { nInnerWidth = nTotalWidth; - for ( size_t i = 0; i < rCols.size(); ++i ) + for (const auto & i : rCols) { - const SwColumn* pCol = &rCols[i]; - nInnerWidth -= pCol->GetLeft() + pCol->GetRight(); + nInnerWidth -= i.GetLeft() + i.GetRight(); } if( nInnerWidth < 0 ) nInnerWidth = 0; @@ -193,9 +192,9 @@ void ResizeFrameCols(SwFormatCol& rCol, // If the desired width is getting too large, then all values // must be scaled appropriately. long nScale = (0xffffl << 8)/ nNewWishWidth; - for(size_t i = 0; i < rArr.size(); ++i) + for(SwColumn & i : rArr) { - SwColumn* pCol = &rArr[i]; + SwColumn* pCol = &i; long nVal = pCol->GetWishWidth(); lcl_Scale(nVal, nScale); pCol->SetWishWidth((sal_uInt16) nVal); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index a4e7b2af702e..19038c74bbe0 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3586,10 +3586,10 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages( IStyleAccess::AUTO_STYLE_CHAR, IStyleAccess::AUTO_STYLE_PARA }; - for (int i = 0; i < 2; ++i) + for (IStyleAccess::SwAutoStyleFamily i : aFam) { std::vector< SfxItemSet_Pointer_t > rStyles; - pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]); + pDoc->GetIStyleAccess().getAllStyles(rStyles, i); while (!rStyles.empty()) { SfxItemSet_Pointer_t pStyle = rStyles.back(); diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index 8a16929974a1..79275c247364 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -305,9 +305,8 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) pDrawView->SdrEndTextEdit(); pDrawView->UnmarkAll(); - for (size_t i = 0; i < sdrObjects.size(); ++i) + for (SdrObject* pSdrObject : sdrObjects) { - SdrObject *const pSdrObject(sdrObjects[i]); // GetSelectableFromAny did not check pSdrObject is in right doc! if (pPV && pSdrObject->GetPage() == pPV->GetPage()) { diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx index 16984874bce7..b5c95e684c8a 100644 --- a/sw/source/uibase/utlui/glbltree.cxx +++ b/sw/source/uibase/utlui/glbltree.cxx @@ -1372,9 +1372,8 @@ IMPL_LINK_TYPED( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileD Sequence< OUString >aFileNames( pMedList->size() ); OUString* pFileNames = aFileNames.getArray(); sal_Int32 nPos = 0; - for ( size_t i = 0, n = pMedList->size(); i < n; ++i ) + for (SfxMedium* pMed : *pMedList) { - SfxMedium* pMed = pMedList->at( i ); OUString sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); sFileName += OUString(sfx2::cTokenSeparator); sFileName += pMed->GetFilter()->GetFilterName(); diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx index 21fa08f59d04..03f479a31774 100644 --- a/sw/source/uibase/utlui/gloslst.cxx +++ b/sw/source/uibase/utlui/gloslst.cxx @@ -358,9 +358,8 @@ void SwGlossaryList::Invoke() AutoTextGroup* SwGlossaryList::FindGroup(const OUString& rGroupName) { - for(size_t i = 0; i < aGroupArr.size(); ++i) + for(AutoTextGroup* pRet : aGroupArr) { - AutoTextGroup* pRet = aGroupArr[i]; if(pRet->sName == rGroupName) return pRet; } diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx index cd2880950653..5829a7a9bedc 100644 --- a/sw/source/uibase/utlui/initui.cxx +++ b/sw/source/uibase/utlui/initui.cxx @@ -78,9 +78,9 @@ inline void SetCachedString(CachedStringID id, const OUString& sStr) void ClearStringCache() { - for (int i=0; i<CachedStrings; ++i) + for (OUString* p : StringCache) { - delete StringCache[i]; + delete p; } } diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx b/sw/source/uibase/utlui/viewlayoutctrl.cxx index 3721c9727ec6..0531e0432f8e 100644 --- a/sw/source/uibase/utlui/viewlayoutctrl.cxx +++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx @@ -59,11 +59,11 @@ SwViewLayoutControl::SwViewLayoutControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, mpImpl->maImageAutomatic, mpImpl->maImageAutomatic_Active, mpImpl->maImageBookMode, mpImpl->maImageBookMode_Active}; - for (int i = 0; i < 6; i++) + for (Image & i : arr) { - BitmapEx aBitmap = arr[i].GetBitmapEx(); + BitmapEx aBitmap = i.GetBitmapEx(); aBitmap.Scale(nScaleFactor, nScaleFactor, BmpScaleFlag::Fast); - arr[i] = Image(aBitmap); + i = Image(aBitmap); } mpImpl->maImageSingleColumn = arr[0]; diff --git a/sw/source/uibase/wrtsh/wrtundo.cxx b/sw/source/uibase/wrtsh/wrtundo.cxx index d8e7ed8498a0..ea1c37e32783 100644 --- a/sw/source/uibase/wrtsh/wrtundo.cxx +++ b/sw/source/uibase/wrtsh/wrtundo.cxx @@ -129,10 +129,10 @@ void SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const } OUString buf; - for (size_t i = 0; i < comments.size(); ++i) + for (const OUString & comment : comments) { - OSL_ENSURE(!comments[i].isEmpty(), "no Undo/Redo Text set"); - buf += comments[i] + "\n"; + OSL_ENSURE(!comment.isEmpty(), "no Undo/Redo Text set"); + buf += comment + "\n"; } rStrs.SetString(buf); } |