summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-19 16:39:06 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-20 19:54:20 +0200
commit2efbeea3f2625f62e08e78789de25ca5783d5e5d (patch)
treea182037bb92ae2b29bd29f78d236175fee6c3678 /xmloff
parent5e8911efab74eb2519eb8ba8301b282b232c2d00 (diff)
pvs-studio: loop-variable-too-small
Change-Id: Ie4aafecd17cf53ab3cbab2003b59da374d06e06b Reviewed-on: https://gerrit.libreoffice.org/62058 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/xmlexppr.cxx6
-rw-r--r--xmloff/source/style/xmlnumfe.cxx8
-rw-r--r--xmloff/source/style/xmlnumfi.cxx32
-rw-r--r--xmloff/source/style/xmlnumi.cxx5
-rw-r--r--xmloff/source/text/txtparai.cxx10
5 files changed, 22 insertions, 39 deletions
diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index 4f8292ed26dd..5cb4f9b02e1d 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -999,13 +999,9 @@ void SvXMLExportPropertyMapper::exportElementItems(
SvXmlExportFlags nFlags,
const std::vector<sal_uInt16>& rIndexArray ) const
{
- const sal_uInt16 nCount = rIndexArray.size();
-
bool bItemsExported = false;
- for( sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++ )
+ for (const sal_uInt16 nElement : rIndexArray)
{
- const sal_uInt16 nElement = rIndexArray[nIndex];
-
OSL_ENSURE( 0 != (mpImpl->mxPropMapper->GetEntryFlags(
rProperties[nElement].mnIndex ) & MID_FLAG_ELEMENT_ITEM_EXPORT),
"wrong mid flag!" );
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index b83ae01fb358..81df9f5262a9 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -601,8 +601,8 @@ void SvXMLNumFmtExport::WriteNumberElement_Impl(
// number:embedded-text as child elements
- sal_uInt16 nEntryCount = rEmbeddedEntries.size();
- for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
+ auto nEntryCount = rEmbeddedEntries.size();
+ for (decltype(nEntryCount) nEntry=0; nEntry < nEntryCount; ++nEntry)
{
const SvXMLEmbeddedTextEntry *const pObj = &rEmbeddedEntries[nEntry];
@@ -953,8 +953,8 @@ static OUString lcl_GetDefaultCalendar( SvNumberFormatter const * pFormatter, La
static bool lcl_IsInEmbedded( const SvXMLEmbeddedTextEntryArr& rEmbeddedEntries, sal_uInt16 nPos )
{
- sal_uInt16 nCount = rEmbeddedEntries.size();
- for (sal_uInt16 i=0; i<nCount; i++)
+ auto nCount = rEmbeddedEntries.size();
+ for (decltype(nCount) i=0; i<nCount; i++)
if ( rEmbeddedEntries[i].nSourcePos == nPos )
return true;
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 7afd4391e4a7..a3039cd51518 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -356,12 +356,10 @@ SvXMLNumImpData::SvXMLNumImpData(
sal_uInt32 SvXMLNumImpData::GetKeyForName( const OUString& rName )
{
- sal_uInt16 nCount = m_NameEntries.size();
- for (sal_uInt16 i=0; i<nCount; i++)
+ for (const auto& rObj : m_NameEntries)
{
- const SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
- if ( pObj->aName == rName )
- return pObj->nKey; // found
+ if (rObj.aName == rName)
+ return rObj.nKey; // found
}
return NUMBERFORMAT_ENTRY_NOT_FOUND;
}
@@ -373,11 +371,9 @@ void SvXMLNumImpData::AddKey( sal_uInt32 nKey, const OUString& rName, bool bRemo
// if there is already an entry for this key without the bRemoveAfterUse flag,
// clear the flag for this entry, too
- sal_uInt16 nCount = m_NameEntries.size();
- for (sal_uInt16 i=0; i<nCount; i++)
+ for (const auto& rObj : m_NameEntries)
{
- SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
- if ( pObj->nKey == nKey && !pObj->bRemoveAfterUse )
+ if (rObj.nKey == nKey && !rObj.bRemoveAfterUse)
{
bRemoveAfterUse = false; // clear flag for new entry
break;
@@ -395,13 +391,11 @@ void SvXMLNumImpData::AddKey( sal_uInt32 nKey, const OUString& rName, bool bRemo
void SvXMLNumImpData::SetUsed( sal_uInt32 nKey )
{
- sal_uInt16 nCount = m_NameEntries.size();
- for (sal_uInt16 i=0; i<nCount; i++)
+ for (auto& rObj : m_NameEntries)
{
- SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
- if ( pObj->nKey == nKey )
+ if (rObj.nKey == nKey)
{
- pObj->bRemoveAfterUse = false; // used -> don't remove
+ rObj.bRemoveAfterUse = false; // used -> don't remove
// continue searching - there may be several entries for the same key
// (with different names), the format must not be deleted if any one of
@@ -419,15 +413,13 @@ void SvXMLNumImpData::RemoveVolatileFormats()
if ( !pFormatter )
return;
- sal_uInt16 nCount = m_NameEntries.size();
- for (sal_uInt16 i=0; i<nCount; i++)
+ for (const auto& rObj : m_NameEntries)
{
- const SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
- if ( pObj->bRemoveAfterUse )
+ if (rObj.bRemoveAfterUse )
{
- const SvNumberformat* pFormat = pFormatter->GetEntry(pObj->nKey);
+ const SvNumberformat* pFormat = pFormatter->GetEntry(rObj.nKey);
if (pFormat && (pFormat->GetType() & SvNumFormatType::DEFINED))
- pFormatter->DeleteEntry( pObj->nKey );
+ pFormatter->DeleteEntry(rObj.nKey);
}
}
}
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 3b60ce724f19..6b36f2edccd2 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -1062,12 +1062,9 @@ void SvxXMLListStyleContext::FillUnoNumRule(
{
if( pLevelStyles && rNumRule.is() )
{
- sal_uInt16 nCount = pLevelStyles->size();
sal_Int32 l_nLevels = rNumRule->getCount();
- for( sal_uInt16 i=0; i < nCount; i++ )
+ for (const auto& pLevelStyle : *pLevelStyles)
{
- SvxXMLListLevelStyleContext_Impl *pLevelStyle =
- (*pLevelStyles)[i].get();
sal_Int32 nLevel = pLevelStyle->GetLevel();
if( nLevel >= 0 && nLevel < l_nLevels )
{
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 9134fe01cffb..48d28cd1df7c 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -274,10 +274,9 @@ XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
if (XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName))
{
// search for reference start
- sal_uInt16 nCount = rHints.GetHints().size();
- for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
+ for (const auto& rHintPtr : rHints.GetHints())
{
- XMLHint_Impl *const pHint = rHints.GetHints()[nPos].get();
+ XMLHint_Impl *const pHint = rHintPtr.get();
if ( pHint->IsReference() &&
sName == static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName() )
{
@@ -1099,10 +1098,9 @@ void XMLIndexMarkImportContext_Impl::StartElement(
if (!sID.isEmpty())
{
// if we have an ID, find the hint and set the end position
- sal_uInt16 nCount = m_rHints.GetHints().size();
- for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
+ for (const auto& rHintPtr : m_rHints.GetHints())
{
- XMLHint_Impl *const pHint = m_rHints.GetHints()[nPos].get();
+ XMLHint_Impl *const pHint = rHintPtr.get();
if ( pHint->IsIndexMark() &&
sID == static_cast<XMLIndexMarkHint_Impl *>(pHint)->GetID() )
{