diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-12 10:07:50 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-13 08:09:03 +0000 |
commit | 96fab0513215cc416e96e1b2089466afd0d2791c (patch) | |
tree | 7c03bd56b0c3744f0560c05ebb2f422155e64543 | |
parent | b3d5da663ff09c72455a8d3bf9be7c00220271bb (diff) |
clang-tidy modernize-loop-convert in writerfilter to xmlsecurity
Change-Id: I334411c6b57c028ffb41b5deb72002f9d54038c3
Reviewed-on: https://gerrit.libreoffice.org/24923
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
32 files changed, 131 insertions, 153 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 89369371d261..176998295193 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -284,11 +284,11 @@ bool lcl_extractTableBorderProperty(const PropertyMapPtr& pTableProperties, cons void lcl_extractHoriOrient(std::vector<beans::PropertyValue>& rFrameProperties, sal_Int32& nHoriOrient) { // Shifts the frame left by the given value. - for (size_t i = 0; i < rFrameProperties.size(); ++i) + for (beans::PropertyValue & rFrameProperty : rFrameProperties) { - if (rFrameProperties[i].Name == "HoriOrient") + if (rFrameProperty.Name == "HoriOrient") { - sal_Int32 nValue = rFrameProperties[i].Value.get<sal_Int32>(); + sal_Int32 nValue = rFrameProperty.Value.get<sal_Int32>(); if (nValue != text::HoriOrientation::NONE) nHoriOrient = nValue; return; @@ -301,9 +301,8 @@ void lcl_extractHoriOrient(std::vector<beans::PropertyValue>& rFrameProperties, void lcl_DecrementHoriOrientPosition(std::vector<beans::PropertyValue>& rFrameProperties, sal_Int32 nAmount) { // Shifts the frame left by the given value. - for (size_t i = 0; i < rFrameProperties.size(); ++i) + for (beans::PropertyValue & rPropertyValue : rFrameProperties) { - beans::PropertyValue& rPropertyValue = rFrameProperties[i]; if (rPropertyValue.Name == "HoriOrientPosition") { sal_Int32 nValue = rPropertyValue.Value.get<sal_Int32>(); @@ -720,10 +719,10 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl { PROP_TOP_BORDER, PROP_LEFT_BORDER, PROP_BOTTOM_BORDER, PROP_RIGHT_BORDER }; - for (size_t i = 0; i < SAL_N_ELEMENTS(pBorders); ++i) + for (const PropertyIds& rBorder : pBorders) { - boost::optional<PropertyMap::Property> oStyleCellBorder = pStyleProps->getProperty(pBorders[i]); - boost::optional<PropertyMap::Property> oDirectCellBorder = (*aCellIterator)->getProperty(pBorders[i]); + boost::optional<PropertyMap::Property> oStyleCellBorder = pStyleProps->getProperty(rBorder); + boost::optional<PropertyMap::Property> oDirectCellBorder = (*aCellIterator)->getProperty(rBorder); if (oStyleCellBorder && oDirectCellBorder) { // We have a cell border from the table style and as direct formatting as well. @@ -733,12 +732,12 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl { // The style one would be visible, but then cleared away as direct formatting. // Delete both, so that table formatting can become visible. - pStyleProps->Erase(pBorders[i]); - (*aCellIterator)->Erase(pBorders[i]); + pStyleProps->Erase(rBorder); + (*aCellIterator)->Erase(rBorder); } else { - boost::optional<PropertyMap::Property> oTableBorder = rInfo.pTableBorders->getProperty(pBorders[i]); + boost::optional<PropertyMap::Property> oTableBorder = rInfo.pTableBorders->getProperty(rBorder); if (oTableBorder) { table::BorderLine2 aTableBorder = oTableBorder->second.get<table::BorderLine2>(); @@ -747,8 +746,8 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl if (aTableBorder.LineStyle != table::BorderLineStyle::NONE && bNoCellBorder) { // But at a table-level, there is a border, then again delete both cell properties. - pStyleProps->Erase(pBorders[i]); - (*aCellIterator)->Erase(pBorders[i]); + pStyleProps->Erase(rBorder); + (*aCellIterator)->Erase(rBorder); } } } @@ -862,8 +861,8 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl /// Do all cells in this row have a CellHideMark property? bool lcl_hideMarks(PropertyMapVector1& rCellProperties) { - for (size_t nCell = 0; nCell < rCellProperties.size(); ++nCell) - if (!rCellProperties[nCell]->isSet(PROP_CELL_HIDE_MARK)) + for (PropertyMapPtr & p : rCellProperties) + if (!p->isSet(PROP_CELL_HIDE_MARK)) return false; return true; } diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 900688ba56ea..b558afd381d6 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -623,8 +623,8 @@ void DomainMapperTableManager::endOfRowAction() // a grid of "20:40:20" and it doesn't have to do something with the tableWidth // -> so we have get the sum of each grid entry for the fullWidthRelative: int nFullWidthRelative = 0; - for (size_t i = 0 ; i < (*pTableGrid.get()).size(); i++ ) - nFullWidthRelative += (*pTableGrid.get())[ i ]; + for (sal_Int32 i : (*pTableGrid.get())) + nFullWidthRelative += i; if( pTableGrid->size() == ( m_nGridBefore + nGrids + m_nGridAfter ) && m_nCell.back( ) > 0 ) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 59526fda0d41..f5db807046da 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1357,8 +1357,8 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const OLEHandler OUString("VertOrient"), OUString("VertOrientPosition") }; - for (size_t i = 0; i < SAL_N_ELEMENTS(pProperties); ++i) - xOLEProperties->setPropertyValue(pProperties[i], xReplacementProperties->getPropertyValue(pProperties[i])); + for (const OUString & s : pProperties) + xOLEProperties->setPropertyValue(s, xReplacementProperties->getPropertyValue(s)); } else // mimic the treatment of graphics here.. it seems anchoring as character @@ -2167,11 +2167,11 @@ style::NumberingType:: CHARS_CYRILLIC_LOWER_LETTER_N_SR*/ }; - for( sal_uInt32 nNum = 0; nNum < SAL_N_ELEMENTS(aNumberingPairs); ++nNum) + for(const NumberingPairs& rNumberingPair : aNumberingPairs) { - if( /*sCommand*/sNumber.equalsAscii(aNumberingPairs[nNum].cWordName )) + if( /*sCommand*/sNumber.equalsAscii(rNumberingPair.cWordName )) { - nRet = aNumberingPairs[nNum].nType; + nRet = rNumberingPair.nType; break; } } diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index f97fe259aa66..04849c1bbbc4 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1162,8 +1162,8 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b PROP_BOTTOM_BORDER }; - for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder ) - xGraphicObjectProperties->setPropertyValue(getPropertyName( aBorderProps[nBorder]), uno::makeAny(aBorderLine)); + for(PropertyIds & rBorderProp : aBorderProps) + xGraphicObjectProperties->setPropertyValue(getPropertyName(rBorderProp), uno::makeAny(aBorderLine)); // setting graphic object shadow proerties if (m_pImpl->bShadow) diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index f3552ea1ef9b..0cbd6db7a704 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -306,8 +306,8 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( ) PROP_ADJUST, PROP_INDENT_AT, PROP_FIRST_LINE_INDENT, PROP_FIRST_LINE_OFFSET, PROP_LEFT_MARGIN }; - for(int i=0; i<nIds; ++i) { - boost::optional<PropertyMap::Property> aProp = getProperty(aReadIds[i]); + for(PropertyIds & rReadId : aReadIds) { + boost::optional<PropertyMap::Property> aProp = getProperty(rReadId); if (aProp) aNumberingProperties.push_back( beans::PropertyValue( getPropertyName(aProp->first), 0, aProp->second, beans::PropertyState_DIRECT_VALUE ) diff --git a/writerfilter/source/dmapper/PageBordersHandler.cxx b/writerfilter/source/dmapper/PageBordersHandler.cxx index a140a754f648..f9fe9685692b 100644 --- a/writerfilter/source/dmapper/PageBordersHandler.cxx +++ b/writerfilter/source/dmapper/PageBordersHandler.cxx @@ -133,10 +133,9 @@ void PageBordersHandler::lcl_sprm( Sprm& rSprm ) void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext ) { - for ( int i = 0, length = m_aBorders.size( ); i < length; i++ ) + for (const PgBorder& rBorder : m_aBorders) { - PgBorder aBorder = m_aBorders[i]; - pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine, aBorder.m_bShadow ); + pSectContext->SetBorder( rBorder.m_ePos, rBorder.m_nDistance, rBorder.m_rLine, rBorder.m_bShadow ); } } diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index f4655817fd92..31001c182bf4 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1101,10 +1101,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) // Text area width is known at the end of a section: decide if tables should be converted or not. std::vector<FloatingTableInfo>& rPendingFloatingTables = rDM_Impl.m_aPendingFloatingTables; uno::Reference<text::XTextAppendAndConvert> xBodyText( rDM_Impl.GetBodyText(), uno::UNO_QUERY ); - for (size_t i = 0; i < rPendingFloatingTables.size(); ++i) + for (FloatingTableInfo & rInfo : rPendingFloatingTables) { - FloatingTableInfo& rInfo = rPendingFloatingTables[i]; - if (FloatingTableConversion(rInfo)) xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties); } @@ -1437,15 +1435,15 @@ void SectionPropertyMap::ApplyProperties_( vValues.push_back(pIter->Value); } } - for (beans::PropertyValue* iter = vCharVals.begin(); iter!=vCharVals.end(); ++iter) + for (beans::PropertyValue & v : vCharVals) { - vNames.push_back(iter->Name); - vValues.push_back(iter->Value); + vNames.push_back(v.Name); + vValues.push_back(v.Value); } - for (beans::PropertyValue* iter = vParaVals.begin(); iter!=vParaVals.end(); ++iter) + for (beans::PropertyValue & v : vParaVals) { - vNames.push_back(iter->Name); - vValues.push_back(iter->Value); + vNames.push_back(v.Name); + vValues.push_back(v.Value); } } if (xMultiSet.is()) diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index a9449f1b7ed5..293ff4f4199b 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -29,9 +29,9 @@ awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet, OUString& r { OUString aLongest = rDefault; sal_Int32 nHeight = 0; - for (std::size_t i = 0; i < rItems.size(); ++i) - if (rItems[i].getLength() > aLongest.getLength()) - aLongest = rItems[i]; + for (const OUString & rItem : rItems) + if (rItem.getLength() > aLongest.getLength()) + aLongest = rItem; MapMode aMap(MAP_100TH_MM); OutputDevice* pOut = Application::GetDefaultDevice(); @@ -190,8 +190,8 @@ sal_Int32 SdtHelper::getInteropGrabBagSize() bool SdtHelper::containedInInteropGrabBag(const OUString& rValueName) { - for (std::size_t i=0; i < m_aGrabBag.size(); ++i) - if (m_aGrabBag[i].Name == rValueName) + for (beans::PropertyValue & i : m_aGrabBag) + if (i.Name == rValueName) return true; return false; diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 57fcf24818e1..30590cb75936 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -232,11 +232,11 @@ PropertyMapPtr TableStyleSheetEntry::GetLocalPropertiesFromMask( sal_Int32 nMask // Get the properties applying according to the mask PropertyMapPtr pProps( new PropertyMap( ) ); - for (size_t i = 0; i < SAL_N_ELEMENTS(aOrderedStyleTable); ++i) + for (const TblStyleTypeAndMask & i : aOrderedStyleTable) { - TblStylePrs::iterator pIt = m_aStyles.find( aOrderedStyleTable[ i ].type ); - if ( ( nMask & aOrderedStyleTable[ i ].mask ) && ( pIt != m_aStyles.end( ) ) ) - lcl_mergeProps( pProps, pIt->second, aOrderedStyleTable[ i ].type ); + TblStylePrs::iterator pIt = m_aStyles.find( i.type ); + if ( ( nMask & i.mask ) && ( pIt != m_aStyles.end( ) ) ) + lcl_mergeProps( pProps, pIt->second, i.type ); } return pProps; } @@ -1195,11 +1195,11 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByISTD(const OUString& sIndex) { StyleSheetEntryPtr pRet; - for( size_t nPos = 0; nPos < m_pImpl->m_aStyleSheetEntries.size(); ++nPos ) + for(StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries) { - if( m_pImpl->m_aStyleSheetEntries[nPos]->sStyleIdentifierD == sIndex) + if( rpEntry->sStyleIdentifierD == sIndex) { - pRet = m_pImpl->m_aStyleSheetEntries[nPos]; + pRet = rpEntry; break; } } @@ -1210,11 +1210,11 @@ const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByISTD(const OUString& s const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByStyleName(const OUString& sIndex) { StyleSheetEntryPtr pRet; - for( size_t nPos = 0; nPos < m_pImpl->m_aStyleSheetEntries.size(); ++nPos ) + for(StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries) { - if( m_pImpl->m_aStyleSheetEntries[nPos]->sStyleName == sIndex) + if( rpEntry->sStyleName == sIndex) { - pRet = m_pImpl->m_aStyleSheetEntries[nPos]; + pRet = rpEntry; break; } } @@ -1225,11 +1225,11 @@ const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByStyleName(const OUStri const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByConvertedStyleName(const OUString& sIndex) { StyleSheetEntryPtr pRet; - for( size_t nPos = 0; nPos < m_pImpl->m_aStyleSheetEntries.size(); ++nPos ) + for(StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries) { - if( m_pImpl->m_aStyleSheetEntries[nPos]->sConvertedStyleName == sIndex) + if( rpEntry->sConvertedStyleName == sIndex) { - pRet = m_pImpl->m_aStyleSheetEntries[nPos]; + pRet = rpEntry; break; } } @@ -1240,9 +1240,8 @@ const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByConvertedStyleName(con const StyleSheetEntryPtr StyleSheetTable::FindDefaultParaStyle() { StyleSheetEntryPtr pRet; - for (size_t i = 0; i < m_pImpl->m_aStyleSheetEntries.size(); ++i) + for (StyleSheetEntryPtr & pEntry : m_pImpl->m_aStyleSheetEntries) { - StyleSheetEntryPtr pEntry = m_pImpl->m_aStyleSheetEntries[i]; if (pEntry->bIsDefaultStyle && pEntry->nStyleTypeCode == STYLE_TYPE_PARA) { pRet = pEntry; diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index e0c9f07d5f86..4e8d4d497436 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -129,9 +129,9 @@ bool OOXMLFastContextHandler::prepareMceContext(Token_t nElement, const uno::Ref "wps", "wpg", }; - for (size_t i = 0; i < SAL_N_ELEMENTS(aFeatures); ++i) + for (const char *p : aFeatures) { - if (aRequires.equalsAscii(aFeatures[i])) + if (aRequires.equalsAscii(p)) { m_bTookChoice = true; return false; @@ -1407,8 +1407,8 @@ void OOXMLFastContextHandlerTextTableRow::handleGridBefore( const OOXMLValue::Po OOXMLPropertySet::Pointer_t pBorderProps( new OOXMLPropertySet ); static Id borders[] = { NS_ooxml::LN_CT_TcBorders_top, NS_ooxml::LN_CT_TcBorders_bottom, NS_ooxml::LN_CT_TcBorders_start, NS_ooxml::LN_CT_TcBorders_end }; - for( size_t j = 0; j < SAL_N_ELEMENTS( borders ); ++j ) - pBorderProps->add( fakeNoBorder( borders[ j ] )); + for(sal_uInt32 border : borders) + pBorderProps->add( fakeNoBorder( border )); OOXMLValue::Pointer_t pValue( new OOXMLPropertySetValue( pBorderProps )); OOXMLProperty::Pointer_t pProp (new OOXMLProperty(NS_ooxml::LN_CT_TcPrBase_tcBorders, pValue, OOXMLProperty::SPRM)); diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx index 81e52ace7594..73dd505ffdb3 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySet.cxx +++ b/writerfilter/source/ooxml/OOXMLPropertySet.cxx @@ -354,10 +354,8 @@ void OOXMLPropertySet::resolve(Properties & rHandler) // be appended to mProperties. I don't think it can cause elements // to be deleted. But let's check with < here just to be safe that // the indexing below works. - for (size_t nIt = 0; nIt < mProperties.size(); ++nIt) + for (OOXMLProperty::Pointer_t& pProp : mProperties) { - OOXMLProperty::Pointer_t pProp = mProperties[nIt]; - if (pProp.get() != nullptr) pProp->resolve(rHandler); } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 43056acedce4..8793d4fe2536 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1458,9 +1458,9 @@ void RTFDocumentImpl::replayRowBuffer( rCellsSrpms.pop_front(); rCellsAttributes.pop_front(); } - for (std::size_t i = 0; i < rBuffer.size(); ++i) + for (Buf_t & i : rBuffer) { - SAL_WARN_IF(BUFFER_CELLEND == std::get<0>(rBuffer[i]), + SAL_WARN_IF(BUFFER_CELLEND == std::get<0>(i), "writerfilter.rtf", "dropping table cell!"); } assert(0 == rCellsSrpms.size()); diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 598bddd4c7fb..5e919d3039dd 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -140,14 +140,14 @@ void RTFSdrImport::resolveLineColorAndWidth(bool bTextFrame, const uno::Referenc { "TopBorder", "LeftBorder", "BottomBorder", "RightBorder" }; - for (unsigned int i = 0; i < SAL_N_ELEMENTS(aBorders); ++i) + for (const char* pBorder : aBorders) { - table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(OUString::createFromAscii(aBorders[i])).get<table::BorderLine2>(); + table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(OUString::createFromAscii(pBorder)).get<table::BorderLine2>(); if (rLineColor.hasValue()) aBorderLine.Color = rLineColor.get<sal_Int32>(); if (rLineWidth.hasValue()) aBorderLine.LineWidth = rLineWidth.get<sal_Int32>(); - xPropertySet->setPropertyValue(OUString::createFromAscii(aBorders[i]), uno::makeAny(aBorderLine)); + xPropertySet->setPropertyValue(OUString::createFromAscii(pBorder), uno::makeAny(aBorderLine)); } } } @@ -298,8 +298,8 @@ int RTFSdrImport::initShape(uno::Reference<drawing::XShape>& o_xShape, createShape("com.sun.star.text.TextFrame", o_xShape, o_xPropSet); m_bTextFrame = true; std::vector<beans::PropertyValue> aDefaults = getTextFrameDefaults(true); - for (std::size_t j = 0; j < aDefaults.size(); ++j) - o_xPropSet->setPropertyValue(aDefaults[j].Name, aDefaults[j].Value); + for (beans::PropertyValue & i : aDefaults) + o_xPropSet->setPropertyValue(i.Name, i.Value); break; } SAL_FALLTHROUGH; diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx index f9074fe91ed4..28dafedf0583 100644 --- a/xmlhelp/source/treeview/tvread.cxx +++ b/xmlhelp/source/treeview/tvread.cxx @@ -56,8 +56,8 @@ namespace treeview { ~TVDom() { - for( size_t i = 0; i < children.size(); ++i ) - delete children[i]; + for(TVDom* p : children) + delete p; } TVDom* newChild() @@ -468,8 +468,9 @@ void TVChildTarget::Check(TVDom* tvDom) { TVDom* p = tvDom->children[tvDom->children.size()-1]; - for(size_t k=0; k<p->children.size(); ++k) - if (!SearchAndInsert(p->children[k], tvDom->children[i])) tvDom->children[i]->newChild(p->children[k]); + for(TVDom* k : p->children) + if (!SearchAndInsert(k, tvDom->children[i])) + tvDom->children[i]->newChild(k); tvDom->children.pop_back(); h = true; diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 8338b756367d..cde978867028 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -1597,10 +1597,9 @@ void SchXMLExportHelper_Impl::exportTable() SvXMLElementExport aColumns( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, true, true ); sal_Int32 nNextIndex = 0; - for( size_t nN=0; nN< aData.aHiddenColumns.size(); nN++ ) + for(sal_Int32 nHiddenIndex : aData.aHiddenColumns) { //i91578 display of hidden values (copy paste scenario; export hidden flag thus it can be used during migration to locale table upon paste ) - sal_Int32 nHiddenIndex = aData.aHiddenColumns[nN]; if( nHiddenIndex > nNextIndex ) { sal_Int64 nRepeat = static_cast< sal_Int64 >( nHiddenIndex - nNextIndex ); @@ -2245,9 +2244,8 @@ bool lcl_exportAxisType( const Reference< chart2::XAxis >& rChart2Axis, SvXMLExp void disableLinkedNumberFormat( std::vector<XMLPropertyState>& rPropStates, const rtl::Reference<XMLPropertySetMapper>& rMapper ) { - for (size_t i = 0; i < rPropStates.size(); ++i) + for (XMLPropertyState & rState : rPropStates) { - XMLPropertyState& rState = rPropStates[i]; if (rState.mnIndex < 0 || rMapper->GetEntryCount() <= rState.mnIndex) continue; diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index ecaef3bda4f4..d25d18b069cd 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -691,8 +691,8 @@ SdXMLExport::~SdXMLExport() if(mpPageMasterInfoList) { - for ( size_t i = 0, n = mpPageMasterInfoList->size(); i < n; ++i ) - delete mpPageMasterInfoList->at( i ); + for (ImpXMLEXPPageMasterInfo* p : *mpPageMasterInfoList) + delete p; mpPageMasterInfoList->clear(); delete mpPageMasterInfoList; mpPageMasterInfoList = nullptr; @@ -701,8 +701,8 @@ SdXMLExport::~SdXMLExport() // clear auto-layout infos if(mpAutoLayoutInfoList) { - for ( size_t i = 0, n = mpAutoLayoutInfoList->size(); i < n; ++i ) - delete mpAutoLayoutInfoList->at( i ); + for (ImpXMLAutoLayoutInfo* p : *mpAutoLayoutInfoList) + delete p; mpAutoLayoutInfoList->clear(); delete mpAutoLayoutInfoList; mpAutoLayoutInfoList = nullptr; @@ -812,9 +812,8 @@ void SdXMLExport::ImpWriteAutoLayoutInfos() { if( !mpAutoLayoutInfoList->empty() ) { - for(size_t nCnt = 0; nCnt < mpAutoLayoutInfoList->size(); nCnt++) + for(ImpXMLAutoLayoutInfo* pInfo : *mpAutoLayoutInfoList) { - ImpXMLAutoLayoutInfo* pInfo = mpAutoLayoutInfoList->at( nCnt ); if(pInfo) { // prepare presentation-page layout attributes, style-name @@ -1389,9 +1388,8 @@ ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetPageMasterInfoByName(const OUString& { if(!rName.isEmpty() && !mpPageMasterInfoList->empty()) { - for( size_t nCnt = 0; nCnt < mpPageMasterInfoList->size(); nCnt++) + for(ImpXMLEXPPageMasterInfo* pInfo : *mpPageMasterInfoList) { - ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->at(nCnt); if(pInfo) { if(!pInfo->GetMasterPageName().isEmpty() && rName.equals(pInfo->GetMasterPageName())) diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index 2d4959ee1d9d..8d2305aeca4d 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -189,9 +189,8 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam } // Create a name based on the properties used - for( size_t i = 0, n = maProperties.size(); i < n; ++i ) + for(XMLPropertyState & rState : maProperties) { - XMLPropertyState& rState = maProperties[i]; if (rState.mnIndex == -1) continue; OUString sXMLName(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex)); @@ -250,9 +249,9 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam #if OSL_DEBUG_LEVEL > 0 std::set<sal_Int32> DebugProperties; - for (size_t i = 0; i < maProperties.size(); ++i) + for (XMLPropertyState & rPropState : maProperties) { - sal_Int32 const property(maProperties[i].mnIndex); + sal_Int32 const property(rPropState.mnIndex); // serious bug: will cause duplicate attributes to be exported assert(DebugProperties.find(property) == DebugProperties.end()); if (-1 != property) @@ -361,9 +360,9 @@ OUString XMLAutoStylePoolParent::Find( const XMLAutoStyleFamily& rFamilyData, co { OUString sName; vector< XMLPropertyState>::size_type nItems = rProperties.size(); - for (size_t i = 0, n = m_PropertiesList.size(); i < n; ++i) + for (const auto & i : m_PropertiesList) { - const XMLAutoStylePoolProperties *const pIS = m_PropertiesList[i].get(); + const XMLAutoStylePoolProperties *const pIS = i.get(); if( nItems > pIS->GetProperties().size() ) { continue; diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index b3808e96d07f..dbf78643bb13 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -1257,10 +1257,8 @@ sal_uInt16 SvXMLNumFmtDefaults::GetDefaultDateFormat( SvXMLDateElementAttributes SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs, bool bSystem ) { - static const sal_uInt16 nCount = sizeof(aDefaultDateFormats) / sizeof(SvXMLDefaultDateFormat); - for (sal_uInt16 nPos=0; nPos<nCount; nPos++) + for (const auto & rEntry : aDefaultDateFormats) { - const SvXMLDefaultDateFormat& rEntry = aDefaultDateFormats[nPos]; if ( bSystem == rEntry.bSystem && ( eDOW == rEntry.eDOW || ( rEntry.eDOW == XML_DEA_ANY && eDOW != XML_DEA_NONE ) ) && ( eDay == rEntry.eDay || ( rEntry.eDay == XML_DEA_ANY && eDay != XML_DEA_NONE ) ) && diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 56a5c1fdcf50..73aa9053b134 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -292,9 +292,8 @@ SvXMLStylesContext_Impl::~SvXMLStylesContext_Impl() { delete pIndices; - for ( size_t i = 0, n = aStyles.size(); i < n; ++i ) + for (SvXMLStyleContext* pStyle : aStyles) { - SvXMLStyleContext *pStyle = aStyles[ i ]; pStyle->ReleaseRef(); } aStyles.clear(); @@ -312,9 +311,8 @@ void SvXMLStylesContext_Impl::Clear() { FlushIndex(); - for ( size_t i = 0, n = aStyles.size(); i < n; ++i ) + for (SvXMLStyleContext* pStyle : aStyles) { - SvXMLStyleContext *pStyle = aStyles[ i ]; pStyle->ReleaseRef(); } aStyles.clear(); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index ba08a558ada5..9dfe9d298b4d 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -379,17 +379,17 @@ void FieldParamExporter::Export() const Type aSeqType = cppu::UnoType<Sequence<OUString>>::get(); const Type aIntType = ::cppu::UnoType<sal_Int32>::get(); Sequence<OUString> vParameters(m_xFieldParams->getElementNames()); - for(const OUString* pCurrent = vParameters.begin(); pCurrent != vParameters.end(); ++pCurrent) + for(const auto & rParameter : vParameters) { - const Any aValue = m_xFieldParams->getByName(*pCurrent); + const Any aValue = m_xFieldParams->getByName(rParameter); const Type& aValueType = aValue.getValueType(); if(aValueType == aStringType) { OUString sValue; aValue >>= sValue; - ExportParameter(*pCurrent,sValue); + ExportParameter(rParameter,sValue); - if ( *pCurrent == ODF_OLE_PARAM ) + if ( rParameter == ODF_OLE_PARAM ) { // Save the OLE object Reference< embed::XStorage > xTargetStg = m_pExport->GetTargetStorage(); @@ -414,22 +414,22 @@ void FieldParamExporter::Export() { bool bValue = false; aValue >>= bValue; - ExportParameter(*pCurrent, OUString::boolean(bValue) ); + ExportParameter(rParameter, OUString::boolean(bValue) ); } else if(aValueType == aSeqType) { Sequence<OUString> vValue; aValue >>= vValue; - for(OUString* pSeqCurrent = vValue.begin(); pSeqCurrent != vValue.end(); ++pSeqCurrent) + for(const OUString & i : vValue) { - ExportParameter(*pCurrent, *pSeqCurrent); + ExportParameter(rParameter, i); } } else if(aValueType == aIntType) { sal_Int32 nValue = 0; aValue >>= nValue; - ExportParameter(*pCurrent, OUStringBuffer().append(nValue).makeStringAndClear()); + ExportParameter(rParameter, OUStringBuffer().append(nValue).makeStringAndClear()); } } } diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 5570bf36fc9a..c851e00b392a 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -2065,9 +2065,9 @@ XMLParaContext::~XMLParaContext() if (pHints && !pHints->GetHints().empty()) { - for (size_t i = 0; i < pHints->GetHints().size(); ++i) + for (const auto & i : pHints->GetHints()) { - XMLHint_Impl *const pHint = pHints->GetHints()[i].get(); + XMLHint_Impl *const pHint = i.get(); xAttrCursor->gotoRange( pHint->GetStart(), false ); xAttrCursor->gotoRange( pHint->GetEnd(), true ); switch( pHint->GetType() ) diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx index c8ff4c696222..e6937ac0c5b6 100644 --- a/xmloff/source/transform/OOo2Oasis.cxx +++ b/xmloff/source/transform/OOo2Oasis.cxx @@ -1829,14 +1829,14 @@ OOo2OasisTransformer::OOo2OasisTransformer( const sal_Char *pImplName, GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG ); GetReplaceNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG ); - for( sal_uInt16 i=0; i<MAX_OOO_ACTIONS; ++i ) - m_aActions[i] = nullptr; + for(XMLTransformerActions*& rp : m_aActions) + rp = nullptr; } OOo2OasisTransformer::~OOo2OasisTransformer() throw() { - for( sal_uInt16 i=0; i<MAX_OOO_ACTIONS; ++i ) - delete m_aActions[i]; + for(XMLTransformerActions* p : m_aActions) + delete p; XMLEventOOoTransformerContext::FlushEventMap( m_pEventMap ); } diff --git a/xmloff/source/transform/Oasis2OOo.cxx b/xmloff/source/transform/Oasis2OOo.cxx index 03b99f35f704..209bf61cc5db 100644 --- a/xmloff/source/transform/Oasis2OOo.cxx +++ b/xmloff/source/transform/Oasis2OOo.cxx @@ -1937,14 +1937,14 @@ Oasis2OOoTransformer::Oasis2OOoTransformer() throw() : GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG ); GetReplaceNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG ); - for( sal_uInt16 i=0; i<MAX_OASIS_ACTIONS; ++i ) - m_aActions[i] = nullptr; + for(XMLTransformerActions* & rp : m_aActions) + rp = nullptr; } Oasis2OOoTransformer::~Oasis2OOoTransformer() throw() { - for( sal_uInt16 i=0; i<MAX_OASIS_ACTIONS; ++i ) - delete m_aActions[i]; + for(XMLTransformerActions* p : m_aActions) + delete p; XMLEventOASISTransformerContext::FlushEventMap( m_pEventMap ); XMLEventOASISTransformerContext::FlushEventMap( m_pFormEventMap ); } diff --git a/xmloff/source/transform/StyleOOoTContext.cxx b/xmloff/source/transform/StyleOOoTContext.cxx index a7321722ee96..4f28f654541e 100644 --- a/xmloff/source/transform/StyleOOoTContext.cxx +++ b/xmloff/source/transform/StyleOOoTContext.cxx @@ -1026,10 +1026,10 @@ void XMLPropertiesOOoTContext_Impl::Characters( const OUString& ) void XMLPropertiesOOoTContext_Impl::Export() { - for( sal_uInt16 i=0; i < MAX_PROP_TYPES; i++ ) + for(rtl::Reference<XMLTypedPropertiesOOoTContext_Impl> & rPropContext : m_aPropContexts) { - if( m_aPropContexts[i].is() ) - m_aPropContexts[i]->Export(); + if( rPropContext.is() ) + rPropContext->Export(); } } diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx index 1a4da841b449..5f4e506771fb 100644 --- a/xmlreader/source/xmlreader.cxx +++ b/xmlreader/source/xmlreader.cxx @@ -487,14 +487,14 @@ char const * XmlReader::handleReference(char const * position, char const * end) RTL_CONSTASCII_STRINGPARAM("'") }, { RTL_CONSTASCII_STRINGPARAM("quot;"), RTL_CONSTASCII_STRINGPARAM("\"") } }; - for (std::size_t i = 0; i < SAL_N_ELEMENTS(refs); ++i) { + for (const auto & ref : refs) { if (rtl_str_shortenedCompare_WithLength( - position, end - position, refs[i].inBegin, refs[i].inLength, - refs[i].inLength) == + position, end - position, ref.inBegin, ref.inLength, + ref.inLength) == 0) { - position += refs[i].inLength; - pad_.add(refs[i].outBegin, refs[i].outLength); + position += ref.inLength; + pad_.add(ref.outBegin, ref.outLength); return position; } } diff --git a/xmlscript/source/xml_helper/xml_element.cxx b/xmlscript/source/xml_helper/xml_element.cxx index d758b0fa9662..1347ac84d582 100644 --- a/xmlscript/source/xml_helper/xml_element.cxx +++ b/xmlscript/source/xml_helper/xml_element.cxx @@ -44,9 +44,9 @@ Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nInde void XMLElement::dumpSubElements( Reference< xml::sax::XDocumentHandler > const & xOut ) { - for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos ) + for (Reference<XAttributeList> & _subElem : _subElems) { - XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() ); + XMLElement * pElem = static_cast< XMLElement * >( _subElem.get() ); pElem->dump( xOut ); } } diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 7f17cf8a83c6..6610f76d4ad4 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -1229,9 +1229,9 @@ void ElementDescriptor::readBullitinBoard( StyleBag * all_styles ) } if (! all_elements.empty()) { - for ( std::size_t n = 0; n < all_elements.size(); ++n ) + for (ElementDescriptor* p : all_elements) { - addSubElement( all_elements[ n ] ); + addSubElement( p ); } } } diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index d4a250984e54..d8a7446d51b3 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -1270,10 +1270,8 @@ OUString StyleBag::getStyleId( Style const & rStyle ) } // lookup existing style - for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos ) + for (Style* pStyle : _styles) { - Style * pStyle = _styles[ nStylesPos ]; - short demanded_defaults = ~rStyle._set & rStyle._all; // test, if defaults are not set if ((~pStyle->_set & demanded_defaults) == demanded_defaults && @@ -1342,9 +1340,9 @@ OUString StyleBag::getStyleId( Style const & rStyle ) StyleBag::~StyleBag() { - for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) + for (Style* _style : _styles) { - delete _styles[ nPos ]; + delete _style; } } @@ -1356,9 +1354,9 @@ void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOu xOut->ignorableWhitespace( OUString() ); xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() ); // export styles - for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) + for (Style* _style : _styles) { - Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() ); + Reference< xml::sax::XAttributeList > xAttr( _style->createElement() ); static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() ); } xOut->ignorableWhitespace( OUString() ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index 4d157d2c6736..006adccdb427 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -1195,9 +1195,8 @@ void TitledBoxElement::endElement() } // create radios AFTER group box! - for ( size_t nPos = 0; nPos < _radios.size(); ++nPos ) + for (Reference<XElement>& xRadio : _radios) { - Reference< xml::input::XElement > xRadio( _radios[ nPos ] ); Reference< xml::input::XAttributes > xAttributes( xRadio->getAttributes() ); ControlImportContext ctx( _pImport, getControlId( xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlRadioButtonModel", xAttributes ) ); @@ -1291,9 +1290,8 @@ Reference< xml::input::XElement > RadioGroupElement::startChildElement( void RadioGroupElement::endElement() throw (xml::sax::SAXException, RuntimeException, std::exception) { - for ( size_t nPos = 0; nPos < _radios.size(); ++nPos ) + for (Reference<XElement>& xRadio : _radios) { - Reference< xml::input::XElement > xRadio( _radios[ nPos ] ); Reference< xml::input::XAttributes > xAttributes( xRadio->getAttributes() ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx index 3303bb0a1614..3b53820b090c 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -1441,11 +1441,11 @@ void ImportContext::importEvents( Reference< container::XNameContainer > xEvents( xSupplier->getEvents() ); if (xEvents.is()) { - for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos ) + for (const auto & rEvent : rEvents) { script::ScriptEventDescriptor descr; - EventElement * pEventElement = static_cast< EventElement * >( rEvents[ nPos ].get() ); + EventElement * pEventElement = static_cast< EventElement * >( rEvent.get() ); sal_Int32 nUid = pEventElement->getUid(); OUString aLocalName( pEventElement->getLocalName() ); Reference< xml::input::XAttributes > xAttributes( pEventElement->getAttributes() ); diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx index ea88c0e27547..795c990aed3d 100644 --- a/xmlsecurity/source/helper/xsecsign.cxx +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -50,9 +50,9 @@ OUString XSecController::createId() char str[68]="ID_"; int length = 3; - for (int i=0; i<16; ++i) + for (sal_uInt8 i : aSeq) { - length += sprintf(str+length, "%04x", aSeq[i]); + length += sprintf(str+length, "%04x", i); } return OUString::createFromAscii(str); @@ -393,10 +393,8 @@ bool XSecController::WriteOOXMLSignature(const uno::Reference<embed::XStorage>& // Export the signature template. cssu::Reference<xml::sax::XDocumentHandler> xSEKHandler(m_xSAXEventKeeper, uno::UNO_QUERY); - for (size_t i = 0; i < m_vInternalSignatureInformations.size(); ++i) + for (InternalSignatureInformation & rInformation : m_vInternalSignatureInformations) { - InternalSignatureInformation& rInformation = m_vInternalSignatureInformations[i]; - // Prepare the signature creator. rInformation.xReferenceResolvedListener = prepareSignatureToWrite(rInformation, embed::StorageFormats::OFOPXML); diff --git a/xmlsecurity/source/xmlsec/nss/secerror.cxx b/xmlsecurity/source/xmlsec/nss/secerror.cxx index 4448599c10eb..ccc2e99338d5 100644 --- a/xmlsecurity/source/xmlsec/nss/secerror.cxx +++ b/xmlsecurity/source/xmlsec/nss/secerror.cxx @@ -48,11 +48,10 @@ const char * getCertError(PRErrorCode errNum) { static const char sEmpty[] = ""; - const int numDesc = SAL_N_ELEMENTS(allDesc); - for (int i = 0; i < numDesc; i++) + for (const ErrDesc& i : allDesc) { - if (allDesc[i].errNum == errNum) - return allDesc[i].errString; + if (i.errNum == errNum) + return i.errString; } return sEmpty; |