From 890a59934985ee73d15be10fc083d325858c4f4b Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Tue, 2 Jul 2019 19:15:51 +0300 Subject: Simplify Sequence iterations in sw/source/ui/* Use range-based loops, STL and comphelper functions Change-Id: I0832f526cc549c76b423f5d5d7a5d2928ce117dc Reviewed-on: https://gerrit.libreoffice.org/75005 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov --- sw/source/ui/index/swuiidxmrk.cxx | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'sw/source/ui/index') diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 9b7ac9c6df29..b4b37b2d5935 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -1068,13 +1068,13 @@ static const TextInfo aTextInfoArr[] = {AUTH_FIELD_CUSTOM5, HID_AUTH_FIELD_CUSTOM5 } }; -static OUString lcl_FindColumnEntry(const beans::PropertyValue* pFields, sal_Int32 nLen, const OUString& rColumnTitle) +static OUString lcl_FindColumnEntry(const uno::Sequence& rFields, const OUString& rColumnTitle) { - for(sal_Int32 i = 0; i < nLen; i++) + for(const auto& rField : rFields) { OUString sRet; - if(pFields[i].Name == rColumnTitle && - (pFields[i].Value >>= sRet)) + if(rField.Name == rColumnTitle && + (rField.Value >>= sRet)) { return sRet; } @@ -1157,11 +1157,10 @@ IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, weld::ComboBox&, rBox, void) uno::Sequence aFieldProps; if(aEntry >>= aFieldProps) { - const beans::PropertyValue* pProps = aFieldProps.getConstArray(); - for(sal_Int32 i = 0; i < AUTH_FIELD_END && i < aFieldProps.getLength(); i++) + auto nSize = std::min(static_cast(AUTH_FIELD_END), aFieldProps.getLength()); + for(sal_Int32 i = 0; i < nSize; i++) { - m_sFields[i] = lcl_FindColumnEntry( - pProps, aFieldProps.getLength(), m_sColumnTitles[i]); + m_sFields[i] = lcl_FindColumnEntry(aFieldProps, m_sColumnTitles[i]); } } } @@ -1306,14 +1305,12 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, ChangeSourceHdl, weld::ToggleButton&, void) uno::Sequence aSeq; if( aNames >>= aSeq) { - const beans::PropertyValue* pArr = aSeq.getConstArray(); - for(sal_Int32 i = 0; i < aSeq.getLength(); i++) + for(const beans::PropertyValue& rProp : aSeq) { - OUString sTitle = pArr[i].Name; sal_Int16 nField = 0; - pArr[i].Value >>= nField; + rProp.Value >>= nField; if(nField >= 0 && nField < AUTH_FIELD_END) - m_sColumnTitles[nField] = sTitle; + m_sColumnTitles[nField] = rProp.Name; } } } @@ -1322,9 +1319,8 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, ChangeSourceHdl, weld::ToggleButton&, void) if(xBibAccess.is()) { uno::Sequence aIdentifiers = xBibAccess->getElementNames(); - const OUString* pNames = aIdentifiers.getConstArray(); - for(sal_Int32 i = 0; i < aIdentifiers.getLength(); i++) - m_xEntryLB->append_text(pNames[i]); + for(const OUString& rName : aIdentifiers) + m_xEntryLB->append_text(rName); } } else -- cgit