Kaydet (Commit) 2efbeea3 authored tarafından Caolán McNamara's avatar Caolán McNamara

pvs-studio: loop-variable-too-small

Change-Id: Ie4aafecd17cf53ab3cbab2003b59da374d06e06b
Reviewed-on: https://gerrit.libreoffice.org/62058
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 5e8911ef
......@@ -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!" );
......
......@@ -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;
......
......@@ -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);
}
}
}
......
......@@ -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 )
{
......
......@@ -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() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment