diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-10-27 19:50:00 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-30 07:52:11 +0100 |
commit | 16b2b4f27acb83fc651b8484dead53ebd0e269e1 (patch) | |
tree | 04bc6e6b39ba22fdc13942008434d97495c88635 /sw/source/ui | |
parent | 922c4a61ca21848777703a28abfd442dd0b4a858 (diff) |
Simplify containers iterations in sw/source/ui*
Use range-based loop or replace with STL functions.
Change-Id: I0d690e873f720a68f04991674ce84ec590231fd0
Reviewed-on: https://gerrit.libreoffice.org/62432
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/ui')
-rw-r--r-- | sw/source/ui/chrdlg/pardlg.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/config/optcomp.cxx | 24 | ||||
-rw-r--r-- | sw/source/ui/config/optpage.cxx | 13 | ||||
-rw-r--r-- | sw/source/ui/dbui/createaddresslistdialog.cxx | 60 | ||||
-rw-r--r-- | sw/source/ui/dbui/customizeaddresslistdialog.cxx | 37 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmaddressblockpage.cxx | 74 | ||||
-rw-r--r-- | sw/source/ui/dialog/ascfldlg.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/envelp/label1.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/fmtui/tmpdlg.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/frmpage.cxx | 39 | ||||
-rw-r--r-- | sw/source/ui/index/cntex.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 83 | ||||
-rw-r--r-- | sw/source/ui/vba/vbadocumentproperties.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/vba/vbarevisions.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/vba/vbatables.cxx | 7 |
15 files changed, 157 insertions, 219 deletions
diff --git a/sw/source/ui/chrdlg/pardlg.cxx b/sw/source/ui/chrdlg/pardlg.cxx index f3df6a32e9f2..7d74c451942e 100644 --- a/sw/source/ui/chrdlg/pardlg.cxx +++ b/sw/source/ui/chrdlg/pardlg.cxx @@ -222,8 +222,8 @@ void SwParaDlg::PageCreated(const OString& rId, SfxTabPage& rPage) aNames.insert(pBase->GetName()); pBase = pPool->Next(); } - for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it) - rBox.append_text(*it); + for(const auto& rName : aNames) + rBox.append_text(rName); } // inits for Area and Transparency TabPages // The selection attribute lists (XPropertyList derivates, e.g. XColorList for diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx index 5ea1304c1d66..8752338a7ede 100644 --- a/sw/source/ui/config/optcomp.cxx +++ b/sw/source/ui/config/optcomp.cxx @@ -269,20 +269,17 @@ IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl, Button*, void) std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryDefaultCompatDialog")); if (xQueryBox->run() == RET_YES) { - for ( vector< SvtCompatibilityEntry >::iterator pItem = m_pImpl->m_aList.begin(); - pItem != m_pImpl->m_aList.end(); ++pItem ) + auto pItem = std::find_if(m_pImpl->m_aList.begin(), m_pImpl->m_aList.end(), + [](const SvtCompatibilityEntry& rItem) { return rItem.isDefaultEntry(); }); + if (pItem != m_pImpl->m_aList.end()) { - if ( pItem->isDefaultEntry() ) + const sal_Int32 nCount = m_pOptionsLB->GetEntryCount(); + for ( sal_Int32 i = 0; i < nCount; ++i ) { - const sal_Int32 nCount = m_pOptionsLB->GetEntryCount(); - for ( sal_Int32 i = 0; i < nCount; ++i ) - { - bool bChecked = m_pOptionsLB->IsChecked(static_cast< sal_uLong >( i )); + bool bChecked = m_pOptionsLB->IsChecked(static_cast< sal_uLong >( i )); - int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */ - pItem->setValue<bool>( SvtCompatibilityEntry::Index(nCoptIdx), bChecked ); - } - break; + int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */ + pItem->setValue<bool>( SvtCompatibilityEntry::Index(nCoptIdx), bChecked ); } } @@ -331,9 +328,8 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const void SwCompatibilityOptPage::WriteOptions() { m_aConfigItem.Clear(); - for ( vector< SvtCompatibilityEntry >::const_iterator pItem = m_pImpl->m_aList.begin(); - pItem != m_pImpl->m_aList.end(); ++pItem ) - m_aConfigItem.AppendItem(*pItem); + for ( const auto& rItem : m_pImpl->m_aList ) + m_aConfigItem.AppendItem(rItem); } VclPtr<SfxTabPage> SwCompatibilityOptPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet ) diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 71d7f831aeb2..526bc089aad2 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -808,14 +808,13 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet) } // insert to listboxes - for( std::set< OUString >::const_iterator it = aFontNames.begin(); - it != aFontNames.end(); ++it ) + for( const auto& rFontName : aFontNames ) { - m_pStandardBox->InsertEntry( *it ); - m_pTitleBox->InsertEntry( *it ); - m_pListBox->InsertEntry( *it ); - m_pLabelBox->InsertEntry( *it ); - m_pIdxBox->InsertEntry( *it ); + m_pStandardBox->InsertEntry( rFontName ); + m_pTitleBox->InsertEntry( rFontName ); + m_pListBox->InsertEntry( rFontName ); + m_pLabelBox->InsertEntry( rFontName ); + m_pIdxBox->InsertEntry( rFontName ); } } if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_STDFONTS, false, &pItem)) diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx index ad8452df3e5d..0e7961c42fb8 100644 --- a/sw/source/ui/dbui/createaddresslistdialog.cxx +++ b/sw/source/ui/dbui/createaddresslistdialog.cxx @@ -120,11 +120,11 @@ SwAddressControl_Impl::~SwAddressControl_Impl() void SwAddressControl_Impl::dispose() { - for(auto aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter) - aTextIter->disposeAndClear(); + for(auto& rText : m_aFixedTexts) + rText.disposeAndClear(); m_aFixedTexts.clear(); - for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter) - aEditIter->disposeAndClear(); + for(auto& rEdit : m_aEdits) + rEdit.disposeAndClear(); m_aEdits.clear(); m_pScrollBar.disposeAndClear(); m_pWindow.disposeAndClear(); @@ -137,28 +137,24 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData) //when the address data is updated then remove the controls an build again if(!m_aFixedTexts.empty()) { - for(auto aTextIter = m_aFixedTexts.begin(); aTextIter != m_aFixedTexts.end(); ++aTextIter) - aTextIter->disposeAndClear(); + for(auto& rText : m_aFixedTexts) + rText.disposeAndClear(); m_aFixedTexts.clear(); - for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter) - aEditIter->disposeAndClear(); + for(auto& rEdit : m_aEdits) + rEdit.disposeAndClear(); m_aEdits.clear(); m_bNoDataSet = true; } //now create appropriate controls - std::vector< OUString >::iterator aHeaderIter; - long nFTXPos = m_pWindow->LogicToPixel(Point(RSC_SP_CTRL_X, RSC_SP_CTRL_X), MapMode(MapUnit::MapAppFont)).X(); long nFTHeight = m_pWindow->LogicToPixel(Size(RSC_BS_CHARHEIGHT, RSC_BS_CHARHEIGHT), MapMode(MapUnit::MapAppFont)).Height(); long nFTWidth = 0; //determine the width of the FixedTexts - for(aHeaderIter = m_pData->aDBColumnHeaders.begin(); - aHeaderIter != m_pData->aDBColumnHeaders.end(); - ++aHeaderIter) + for(const auto& rHeader : m_pData->aDBColumnHeaders) { - sal_Int32 nTemp = m_pWindow->GetTextWidth(*aHeaderIter); + sal_Int32 nTemp = m_pWindow->GetTextWidth(rHeader); if(nTemp > nFTWidth) nFTWidth = nTemp; } @@ -178,9 +174,7 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData) Edit* pLastEdit = nullptr; sal_Int32 nVisibleLines = 0; sal_Int32 nLines = 0; - for(aHeaderIter = m_pData->aDBColumnHeaders.begin(); - aHeaderIter != m_pData->aDBColumnHeaders.end(); - ++aHeaderIter, nEDYPos += m_nLineHeight, nFTYPos += m_nLineHeight, nLines++) + for(const auto& rHeader : m_pData->aDBColumnHeaders) { VclPtr<FixedText> pNewFT = VclPtr<FixedText>::Create(m_pWindow, WB_RIGHT); VclPtr<Edit> pNewED = VclPtr<Edit>::Create(m_pWindow, WB_BORDER); @@ -194,13 +188,16 @@ void SwAddressControl_Impl::SetData(SwCSVData& rDBData) if(nEDYPos + nEDHeight < m_aWinOutputSize.Height()) ++nVisibleLines; - pNewFT->SetText(*aHeaderIter); + pNewFT->SetText(rHeader); pNewFT->Show(); pNewED->Show(); m_aFixedTexts.push_back(pNewFT); m_aEdits.push_back(pNewED); pLastEdit = pNewED; + nEDYPos += m_nLineHeight; + nFTYPos += m_nLineHeight; + nLines++; } //scrollbar adjustment if(pLastEdit) @@ -251,11 +248,12 @@ void SwAddressControl_Impl::SetCurrentDataSet(sal_uInt32 nSet) if(m_pData->aDBData.size() > m_nCurrentDataSet) { sal_uInt32 nIndex = 0; - for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter, ++nIndex) + for(auto& rEdit : m_aEdits) { OSL_ENSURE(nIndex < m_pData->aDBData[m_nCurrentDataSet].size(), "number of columns doesn't match number of Edits"); - (*aEditIter)->SetText(m_pData->aDBData[m_nCurrentDataSet][nIndex]); + rEdit->SetText(m_pData->aDBData[m_nCurrentDataSet][nIndex]); + ++nIndex; } } } @@ -381,9 +379,9 @@ void SwAddressControl_Impl::Resize() { long nNewEditSize = aSize.Width() - (*m_aEdits.begin())->GetPosPixel().X() - nScrollBarWidth - 6; - for(auto aEditIter = m_aEdits.begin(); aEditIter != m_aEdits.end(); ++aEditIter) + for(auto& rEdit : m_aEdits) { - (*aEditIter)->SetSizePixel(Size(nNewEditSize, (*aEditIter)->GetSizePixel().Height())); + rEdit->SetSizePixel(Size(nNewEditSize, rEdit->GetSizePixel().Height())); } } @@ -552,11 +550,8 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, FindHdl_Impl, Button*, void) { m_xFindDlg.reset(new SwFindEntryDialog(this)); weld::ComboBox& rColumnBox = m_xFindDlg->GetFieldsListBox(); - std::vector< OUString >::iterator aHeaderIter; - for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin(); - aHeaderIter != m_pCSVData->aDBColumnHeaders.end(); - ++aHeaderIter) - rColumnBox.append_text(*aHeaderIter); + for(const auto& rHeader : m_pCSVData->aDBColumnHeaders) + rColumnBox.append_text(rHeader); rColumnBox.set_active(0); m_xFindDlg->show(); } @@ -579,11 +574,8 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, CustomizeHdl_Impl, Button*, void) { weld::ComboBox& rColumnBox = m_xFindDlg->GetFieldsListBox(); rColumnBox.clear(); - std::vector< OUString >::iterator aHeaderIter; - for(aHeaderIter = m_pCSVData->aDBColumnHeaders.begin(); - aHeaderIter != m_pCSVData->aDBColumnHeaders.end(); - ++aHeaderIter) - rColumnBox.append_text(*aHeaderIter); + for(const auto& rHeader : m_pCSVData->aDBColumnHeaders) + rColumnBox.append_text(rHeader); } } @@ -643,9 +635,9 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl, Button*, void) lcl_WriteValues(&(m_pCSVData->aDBColumnHeaders), pStream); std::vector< std::vector< OUString > >::iterator aDataIter; - for( aDataIter = m_pCSVData->aDBData.begin(); aDataIter != m_pCSVData->aDBData.end(); ++aDataIter) + for(const auto& rData : m_pCSVData->aDBData) { - lcl_WriteValues(&(*aDataIter), pStream); + lcl_WriteValues(&rData, pStream); } aMedium.Commit(); EndDialog(RET_OK); diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx b/sw/source/ui/dbui/customizeaddresslistdialog.cxx index af6162bfd0f5..49c1df3fdaa3 100644 --- a/sw/source/ui/dbui/customizeaddresslistdialog.cxx +++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx @@ -46,11 +46,8 @@ SwCustomizeAddressListDialog::SwCustomizeAddressListDialog( m_xUpPB->connect_clicked(aUpDownLk); m_xDownPB->connect_clicked(aUpDownLk); - std::vector< OUString >::iterator aHeaderIter; - - for(aHeaderIter = m_xNewData->aDBColumnHeaders.begin(); - aHeaderIter != m_xNewData->aDBColumnHeaders.end(); ++aHeaderIter) - m_xFieldsLB->append_text(*aHeaderIter); + for (const auto& rHeader : m_xNewData->aDBColumnHeaders) + m_xFieldsLB->append_text(rHeader); m_xFieldsLB->select(0); UpdateButtons(); @@ -97,9 +94,8 @@ IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, weld::Button&, rButto //add the new column m_xNewData->aDBColumnHeaders.insert(m_xNewData->aDBColumnHeaders.begin() + nPos, sNew); //add a new entry into all data arrays - std::vector< std::vector< OUString > >::iterator aDataIter; - for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter) - aDataIter->insert(aDataIter->begin() + nPos, OUString()); + for (auto& rData : m_xNewData->aDBData) + rData.insert(rData.begin() + nPos, OUString()); } @@ -118,9 +114,8 @@ IMPL_LINK_NOARG(SwCustomizeAddressListDialog, DeleteHdl_Impl, weld::Button&, voi //remove the column m_xNewData->aDBColumnHeaders.erase(m_xNewData->aDBColumnHeaders.begin() + nPos); //remove the data - std::vector< std::vector< OUString > >::iterator aDataIter; - for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter) - aDataIter->erase(aDataIter->begin() + nPos); + for (auto& rData : m_xNewData->aDBData) + rData.erase(rData.begin() + nPos); UpdateButtons(); } @@ -141,12 +136,11 @@ IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, weld::Button&, rButton, OUString sHeader = m_xNewData->aDBColumnHeaders[nOldPos]; m_xNewData->aDBColumnHeaders.erase(m_xNewData->aDBColumnHeaders.begin() + nOldPos); m_xNewData->aDBColumnHeaders.insert(m_xNewData->aDBColumnHeaders.begin() + nPos, sHeader); - std::vector< std::vector< OUString > >::iterator aDataIter; - for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter) + for (auto& rData : m_xNewData->aDBData) { - OUString sData = (*aDataIter)[nOldPos]; - aDataIter->erase(aDataIter->begin() + nOldPos); - aDataIter->insert(aDataIter->begin() + nPos, sData); + OUString sData = rData[nOldPos]; + rData.erase(rData.begin() + nOldPos); + rData.insert(rData.begin() + nPos, sData); } UpdateButtons(); @@ -181,15 +175,8 @@ IMPL_LINK(SwAddRenameEntryDialog, ModifyHdl_Impl, weld::Entry&, rEdit, void) if(!bFound) { - std::vector< OUString >::const_iterator aHeaderIter; - for(aHeaderIter = m_rCSVHeader.begin(); - aHeaderIter != m_rCSVHeader.end(); - ++aHeaderIter) - if(*aHeaderIter == sEntry) - { - bFound = true; - break; - } + bFound = std::any_of(m_rCSVHeader.begin(), m_rCSVHeader.end(), + [&sEntry](const OUString& rHeader) { return rHeader == sEntry; }); } m_xOK->set_sensitive(!bFound); } diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index 57b30c60c56b..29b99cf6a8c1 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -696,9 +696,8 @@ IMPL_LINK(SwCustomizeAddressBlockDialog, SelectionChangedHdl_Impl, AddressMultiL } m_pFieldCB->Clear(); if(pVector) { - std::vector<OUString>::iterator aIterator; - for( aIterator = pVector->begin(); aIterator != pVector->end(); ++aIterator) - m_pFieldCB->InsertEntry(*aIterator); + for (const auto& rItem : *pVector) + m_pFieldCB->InsertEntry(rItem); } m_pFieldCB->SetText(sSelect); m_pFieldCB->Enable(); @@ -970,12 +969,12 @@ SwAssignFieldsControl::~SwAssignFieldsControl() void SwAssignFieldsControl::dispose() { - for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter) - aFIIter->disposeAndClear(); - for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter) - aLBIter->disposeAndClear(); - for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter) - aFIIter->disposeAndClear(); + for(auto& rFIItem : m_aFieldNames) + rFIItem.disposeAndClear(); + for(auto& rLBItem : m_aMatches) + rLBItem.disposeAndClear(); + for(auto& rFIItem : m_aPreviews) + rFIItem.disposeAndClear(); m_aFieldNames.clear(); m_aMatches.clear(); @@ -1015,17 +1014,17 @@ void SwAssignFieldsControl::Resize() long nControlHeight = std::max(m_aFieldNames[0]->get_preferred_size().Height(), m_aMatches[0]->get_preferred_size().Height()); - for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter) - (*aFIIter)->SetSizePixel(Size(nColWidth - 6, nControlHeight)); - for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter) + for(auto& rFIItem : m_aFieldNames) + rFIItem->SetSizePixel(Size(nColWidth - 6, nControlHeight)); + for(auto& rLBItem : m_aMatches) { - long nPosY = (*aLBIter)->GetPosPixel().Y(); - (*aLBIter)->SetPosSizePixel(Point(nColWidth, nPosY), Size(nColWidth - 6, nControlHeight)); + long nPosY = rLBItem->GetPosPixel().Y(); + rLBItem->SetPosSizePixel(Point(nColWidth, nPosY), Size(nColWidth - 6, nControlHeight)); } - for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter) + for(auto& rFIItem : m_aPreviews) { - long nPosY = (*aFIIter)->GetPosPixel().Y(); - (*aFIIter)->SetPosSizePixel(Point(2 * nColWidth + 6, nPosY), Size(nColWidth, nControlHeight)); + long nPosY = rFIItem->GetPosPixel().Y(); + rFIItem->SetPosSizePixel(Point(2 * nColWidth + 6, nPosY), Size(nColWidth, nControlHeight)); } } @@ -1086,12 +1085,12 @@ IMPL_LINK(SwAssignFieldsControl, ScrollHdl_Impl, ScrollBar*, pScroll, void) long nMove = m_nFirstYPos - (*m_aMatches.begin())->GetPosPixel().Y() - (nThumb * m_nYOffset); SetUpdateMode(false); - for(auto aFIIter = m_aFieldNames.begin(); aFIIter != m_aFieldNames.end(); ++aFIIter) - lcl_Move(*aFIIter, nMove); - for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter) - lcl_Move(*aLBIter, nMove); - for(auto aFIIter = m_aPreviews.begin(); aFIIter != m_aPreviews.end(); ++aFIIter) - lcl_Move(*aFIIter, nMove); + for(auto& rFIItem : m_aFieldNames) + lcl_Move(rFIItem, nMove); + for(auto& rLBItem : m_aMatches) + lcl_Move(rLBItem, nMove); + for(auto& rFIItem : m_aPreviews) + lcl_Move(rFIItem, nMove); SetUpdateMode(true); } @@ -1117,14 +1116,11 @@ IMPL_LINK(SwAssignFieldsControl, MatchHdl_Impl, ListBox&, rBox, void) } } } - sal_Int32 nIndex = 0; - for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex) + auto aLBIter = std::find(m_aMatches.begin(), m_aMatches.end(), &rBox); + if(aLBIter != m_aMatches.end()) { - if(*aLBIter == &rBox) - { - m_aPreviews[nIndex]->SetText(sPreview); - break; - } + auto nIndex = static_cast<sal_Int32>(std::distance(m_aMatches.begin(), aLBIter)); + m_aPreviews[nIndex]->SetText(sPreview); } m_aModifyHdl.Call(nullptr); } @@ -1134,14 +1130,11 @@ IMPL_LINK(SwAssignFieldsControl, GotFocusHdl_Impl, Control&, rControl, void) ListBox* pBox = static_cast<ListBox*>(&rControl); if(GetFocusFlags::Tab & pBox->GetGetFocusFlags()) { - sal_Int32 nIndex = 0; - for(auto aLBIter = m_aMatches.begin(); aLBIter != m_aMatches.end(); ++aLBIter, ++nIndex) + auto aLBIter = std::find(m_aMatches.begin(), m_aMatches.end(), pBox); + if(aLBIter != m_aMatches.end()) { - if(*aLBIter == pBox) - { - MakeVisible(nIndex); - break; - } + auto nIndex = static_cast<sal_Int32>(std::distance(m_aMatches.begin(), aLBIter)); + MakeVisible(nIndex); } } } @@ -1212,12 +1205,11 @@ uno::Sequence< OUString > SwAssignFieldsDialog::CreateAssignments() m_rConfigItem.GetDefaultAddressHeaders().size()); OUString* pAssignments = aAssignments.getArray(); sal_Int32 nIndex = 0; - for(auto aLBIter = m_pFieldsControl->m_aMatches.begin(); - aLBIter != m_pFieldsControl->m_aMatches.end(); - ++aLBIter, ++nIndex) + for(const auto& rLBItem : m_pFieldsControl->m_aMatches) { - const OUString sSelect = (*aLBIter)->GetSelectedEntry(); + const OUString sSelect = rLBItem->GetSelectedEntry(); pAssignments[nIndex] = (m_sNone != sSelect) ? sSelect : OUString(); + ++nIndex; } return aAssignments; } diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index 2be497a2701b..3b36d6f858d2 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -204,10 +204,9 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh, } // insert into listbox - for( std::set< OUString >::const_iterator it = aFontNames.begin(); - it != aFontNames.end(); ++it ) + for( const auto& rFontName : aFontNames ) { - m_xFontLB->append_text(*it); + m_xFontLB->append_text(rFontName); } if( aOpt.GetFontName().isEmpty() ) diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx index 733d55c6e025..a6f7e0afe580 100644 --- a/sw/source/ui/envelp/label1.cxx +++ b/sw/source/ui/envelp/label1.cxx @@ -513,10 +513,10 @@ void SwLabPage::Reset(const SfxItemSet* rSet) m_xAddrBox->set_active( aItem.m_bAddr ); m_xWritingEdit->set_text( aWriting ); - for(std::vector<OUString>::const_iterator i = GetParentSwLabDlg()->Makes().begin(); i != GetParentSwLabDlg()->Makes().end(); ++i) + for(const auto& rMake : GetParentSwLabDlg()->Makes()) { - if (m_xMakeBox->find_text(*i) == -1) - m_xMakeBox->append_text(*i); + if (m_xMakeBox->find_text(rMake) == -1) + m_xMakeBox->append_text(rMake); } m_xMakeBox->set_active_text(aItem.m_aMake); diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx index 77aa92b22293..c9370c1e5e9e 100644 --- a/sw/source/ui/fmtui/tmpdlg.cxx +++ b/sw/source/ui/fmtui/tmpdlg.cxx @@ -417,8 +417,8 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) aNames.insert(pBase->GetName()); pBase = pPool->Next(); } - for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it) - rBox.append_text(*it); + for(const auto& rName : aNames) + rBox.append_text(rName); } else if (nId == m_nAlignId) { diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index b7d41aca0474..76c5ce2be016 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -441,25 +441,24 @@ static void lcl_InsertVectors(weld::ComboBox& rBox, const std::vector< OUString >& rPrev, const std::vector< OUString >& rThis, const std::vector< OUString >& rNext, const std::vector< OUString >& rRemain) { - std::vector< OUString >::const_iterator aIt; - for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt) - rBox.append_text(*aIt); - for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt) - rBox.append_text(*aIt); - for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt) - rBox.append_text(*aIt); + for(const auto& rItem : rPrev) + rBox.append_text(rItem); + for(const auto& rItem : rThis) + rBox.append_text(rItem); + for(const auto& rItem : rNext) + rBox.append_text(rItem); rBox.append_separator(); //now insert all strings sorted const auto nStartPos = rBox.get_count(); - for(aIt = rPrev.begin(); aIt != rPrev.end(); ++aIt) - ::InsertStringSorted("", *aIt, rBox, nStartPos ); - for(aIt = rThis.begin(); aIt != rThis.end(); ++aIt) - ::InsertStringSorted("", *aIt, rBox, nStartPos ); - for(aIt = rNext.begin(); aIt != rNext.end(); ++aIt) - ::InsertStringSorted("", *aIt, rBox, nStartPos ); - for(aIt = rRemain.begin(); aIt != rRemain.end(); ++aIt) - ::InsertStringSorted("", *aIt, rBox, nStartPos ); + for(const auto& rItem : rPrev) + ::InsertStringSorted("", rItem, rBox, nStartPos ); + for(const auto& rItem : rThis) + ::InsertStringSorted("", rItem, rBox, nStartPos ); + for(const auto& rItem : rNext) + ::InsertStringSorted("", rItem, rBox, nStartPos ); + for(const auto& rItem : rRemain) + ::InsertStringSorted("", rItem, rBox, nStartPos ); } // --> OD 2009-08-31 #mongolianlayout# @@ -812,10 +811,9 @@ void SwFramePage::setOptimalFrameWidth() std::sort(aFrames.begin(), aFrames.end()); aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end()); - for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end(); - aI != aEnd; ++aI) + for (const auto& rFrame : aFrames) { - m_pHorizontalDLB->InsertEntry(SvxSwFramePosString::GetString(*aI)); + m_pHorizontalDLB->InsertEntry(SvxSwFramePosString::GetString(rFrame)); } Size aBiggest(m_pHorizontalDLB->GetOptimalSize()); @@ -853,10 +851,9 @@ void SwFramePage::setOptimalRelWidth() std::sort(aRels.begin(), aRels.end()); aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end()); - for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end(); - aI != aEnd; ++aI) + for (const auto& rRel : aRels) { - m_pHoriRelationLB->InsertEntry(SvxSwFramePosString::GetString(*aI)); + m_pHoriRelationLB->InsertEntry(SvxSwFramePosString::GetString(rRel)); } Size aBiggest(m_pHoriRelationLB->GetOptimalSize()); diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index 5d796bcbda59..17a5d1a9cb1f 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -284,14 +284,12 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( // #i24377# SwFormTokens aPattern = pForm->GetPattern(nCurrLevel); - SwFormTokens::iterator aIt = aPattern.begin(); - while(aIt != aPattern.end()) + for(const auto& aToken : aPattern) { if( aSequPropVals.getLength() <= nTokenIndex) aSequPropVals.realloc(nTokenIndex + 10); - SwFormToken aToken = *aIt; // #i24377# switch(aToken.eTokenType) { case TOKEN_ENTRY_NO : @@ -355,8 +353,6 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( beans::PropertyValues* pValues = aSequPropVals.getArray(); pValues[nTokenIndex] = aPropVals; nTokenIndex++; - - ++aIt; // #i24377# } aSequPropVals.realloc(nTokenIndex); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 6764592ad64b..b234569aa86b 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -2407,11 +2407,9 @@ IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox, void) // #i21237# SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1); - SwFormTokens::iterator aIt = aPattern.begin(); - while(aIt != aPattern.end()) + for(const auto& aToken : aPattern) { - SwFormToken aToken = *aIt; // #i21237# if(TOKEN_AUTHORITY == aToken.eTokenType) { sal_uInt32 nSearch = aToken.nAuthorityField; @@ -2419,8 +2417,6 @@ IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox, void) OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND != nLstBoxPos, "Entry not found?"); m_pAuthFieldsLB->RemoveEntry(nLstBoxPos); } - - ++aIt; // #i21237# } m_pAuthFieldsLB->SelectEntryPos(0); } @@ -2822,14 +2818,11 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL) { // #i21237# SwFormTokens aPattern = m_pForm->GetPattern(m_nLevel + 1); - SwFormTokens::iterator aIt = aPattern.begin(); bool bLastWasText = false; //assure alternating text - code - text Control* pSetActiveControl = nullptr; - while(aIt != aPattern.end()) // #i21237# + for (const auto& aToken : aPattern) // #i21237# { - SwFormToken aToken(*aIt); // #i21237# - if(TOKEN_TEXT == aToken.eTokenType) { SAL_WARN_IF(bLastWasText, "sw", "text following text is invalid"); @@ -2866,8 +2859,6 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL) InsertItem( sForm, aToken ); bLastWasText = false; } - - ++aIt; // #i21237# } if(!bLastWasText) { @@ -3317,56 +3308,48 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) if(pBtn == m_pLeftScrollWin) { //find the first completely visible control (left edge visible) - for (auto it = m_aControlList.begin(); it != m_aControlList.end(); ++it) + auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(), + [](const VclPtr<Control>& rControl) { + Control *pCtrl = rControl.get(); + return pCtrl->GetPosPixel().X() >= 0; + }); + if (it != m_aControlList.end()) { - Control *pCtrl = it->get(); - - long nXPos = pCtrl->GetPosPixel().X(); - - if (nXPos >= 0) + if (it == m_aControlList.begin()) { - if (it == m_aControlList.begin()) - { - //move the current control to the left edge - nMove = -nXPos; - } - else - { - //move the left neighbor to the start position - auto itLeft = it; - --itLeft; - Control *pLeft = itLeft->get(); + //move the current control to the left edge + Control *pCtrl = it->get(); - nMove = -pLeft->GetPosPixel().X(); - } + nMove = -pCtrl->GetPosPixel().X(); + } + else + { + //move the left neighbor to the start position + auto itLeft = it; + --itLeft; + Control *pLeft = itLeft->get(); - break; + nMove = -pLeft->GetPosPixel().X(); } } } else { //find the first completely visible control (right edge visible) - for (auto it = m_aControlList.rbegin(); it != m_aControlList.rend(); ++it) + auto it = std::find_if(m_aControlList.rbegin(), m_aControlList.rend(), + [&nSpace](const VclPtr<Control>& rControl) { + Control *pCtrl = rControl.get(); + long nCtrlWidth = pCtrl->GetSizePixel().Width(); + long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth; + return nXPos <= nSpace; + }); + if (it != m_aControlList.rend() && it != m_aControlList.rbegin()) { - Control *pCtrl = it->get(); - - long nCtrlWidth = pCtrl->GetSizePixel().Width(); - long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth; - - if (nXPos <= nSpace) - { - if (it != m_aControlList.rbegin()) - { - //move the right neighbor to the right edge right aligned - auto itRight = it; - --itRight; - Control *pRight = itRight->get(); - nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width(); - } - - break; - } + //move the right neighbor to the right edge right aligned + auto itRight = it; + --itRight; + Control *pRight = itRight->get(); + nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width(); } //move it left until it's completely visible diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx index 4a74d5abd25b..130471a35d12 100644 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ b/sw/source/ui/vba/vbadocumentproperties.cxx @@ -705,9 +705,11 @@ protected: { uno::Sequence< OUString > aNames( getCount() ); OUString* pName = aNames.getArray(); - DocPropsByName::iterator it_end = mNamedDocProps.end(); - for( DocPropsByName::iterator it = mNamedDocProps.begin(); it != it_end; ++it, ++pName ) - *pName = it->first; + for (const auto& rEntry : mNamedDocProps) + { + *pName = rEntry.first; + ++pName; + } return aNames; } diff --git a/sw/source/ui/vba/vbarevisions.cxx b/sw/source/ui/vba/vbarevisions.cxx index 661413f1ed20..223e523c1c56 100644 --- a/sw/source/ui/vba/vbarevisions.cxx +++ b/sw/source/ui/vba/vbarevisions.cxx @@ -146,12 +146,8 @@ void SAL_CALL SwVbaRevisions::AcceptAll( ) aRevisions.push_back( xRevision ); } - std::vector< uno::Reference< word::XRevision > >::iterator it = aRevisions.begin(); - for( ; it != aRevisions.end(); ++it ) - { - uno::Reference< word::XRevision > xRevision( *it ); + for( const auto& xRevision : aRevisions ) xRevision->Accept(); - } } void SAL_CALL SwVbaRevisions::RejectAll( ) diff --git a/sw/source/ui/vba/vbatables.cxx b/sw/source/ui/vba/vbatables.cxx index 932e416d460e..eb9b4441de89 100644 --- a/sw/source/ui/vba/vbatables.cxx +++ b/sw/source/ui/vba/vbatables.cxx @@ -107,12 +107,11 @@ public: { uno::Sequence< OUString > sNames( mxTables.size() ); OUString* pString = sNames.getArray(); - XTextTableVec::iterator it = mxTables.begin(); - XTextTableVec::iterator it_end = mxTables.end(); - for ( ; it != it_end; ++it, ++pString ) + for ( const auto& rxTable : mxTables ) { - uno::Reference< container::XNamed > xName( *it, uno::UNO_QUERY_THROW ); + uno::Reference< container::XNamed > xName( rxTable, uno::UNO_QUERY_THROW ); *pString = xName->getName(); + ++pString; } return sNames; } |