From 96fab0513215cc416e96e1b2089466afd0d2791c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 May 2016 10:07:50 +0200 Subject: clang-tidy modernize-loop-convert in writerfilter to xmlsecurity Change-Id: I334411c6b57c028ffb41b5deb72002f9d54038c3 Reviewed-on: https://gerrit.libreoffice.org/24923 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/chart/SchXMLExport.cxx | 6 ++---- xmloff/source/draw/sdxmlexp.cxx | 14 ++++++-------- xmloff/source/style/impastpl.cxx | 11 +++++------ xmloff/source/style/xmlnumfi.cxx | 4 +--- xmloff/source/style/xmlstyle.cxx | 6 ++---- xmloff/source/text/txtparae.cxx | 16 ++++++++-------- xmloff/source/text/txtparai.cxx | 4 ++-- xmloff/source/transform/OOo2Oasis.cxx | 8 ++++---- xmloff/source/transform/Oasis2OOo.cxx | 8 ++++---- xmloff/source/transform/StyleOOoTContext.cxx | 6 +++--- 10 files changed, 37 insertions(+), 46 deletions(-) (limited to 'xmloff') 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& rPropStates, const rtl::Reference& 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 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; nPosReleaseRef(); } 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>::get(); const Type aIntType = ::cppu::UnoType::get(); Sequence 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 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 & rPropContext : m_aPropContexts) { - if( m_aPropContexts[i].is() ) - m_aPropContexts[i]->Export(); + if( rPropContext.is() ) + rPropContext->Export(); } } -- cgit