summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-02-15 00:08:43 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-15 12:21:28 +0100
commit9d7620613d3ea2feb45a7ff57c4d2544bb1c6fe6 (patch)
tree20e56cfbe9a0bc07974fb14861556da74f3ecddc /oox
parentSourceManager::getExpansionRange already returns CharSourceRange since Clang 7 (diff)
downloadcore-9d7620613d3ea2feb45a7ff57c4d2544bb1c6fe6.tar.gz
core-9d7620613d3ea2feb45a7ff57c4d2544bb1c6fe6.zip
Simplify containers iterations in oox, opencl, package
Use range-based loop or replace with STL functions Change-Id: I91405920d91383bc6cf13b9497d262b1f6f0a84d Reviewed-on: https://gerrit.libreoffice.org/67848 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/contexthandler2.cxx8
-rw-r--r--oox/source/core/xmlfilterbase.cxx24
-rw-r--r--oox/source/drawingml/chart/typegroupconverter.cxx8
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx21
-rw-r--r--oox/source/drawingml/shape.cxx18
-rw-r--r--oox/source/ole/vbacontrol.cxx22
6 files changed, 51 insertions, 50 deletions
diff --git a/oox/source/core/contexthandler2.cxx b/oox/source/core/contexthandler2.cxx
index a88d58b7d41a..ab9cea4a49fc 100644
--- a/oox/source/core/contexthandler2.cxx
+++ b/oox/source/core/contexthandler2.cxx
@@ -66,10 +66,10 @@ sal_Int32 ContextHandler2Helper::getCurrentElementWithMce() const
sal_Int32 ContextHandler2Helper::getCurrentElement() const
{
- for ( ContextStack::reverse_iterator It = mxContextStack->rbegin();
- It != mxContextStack->rend(); ++It )
- if( getNamespace( It->mnElement ) != NMSP_mce )
- return It->mnElement;
+ auto It = std::find_if(mxContextStack->rbegin(), mxContextStack->rend(),
+ [](const ElementInfo& rItem) { return getNamespace(rItem.mnElement) != NMSP_mce; });
+ if (It != mxContextStack->rend())
+ return It->mnElement;
return XML_ROOT_CONTEXT;
}
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 09d5dd63060d..8050c91b0d8e 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -782,30 +782,31 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
FSNS( XML_xmlns, XML_vt ), OUStringToOString(rSelf.getNamespaceURL(OOX_NS(officeDocPropsVT)), RTL_TEXTENCODING_UTF8).getStr(),
FSEND );
- for (auto aIt = aprop.begin(); aIt != aprop.end(); ++aIt)
+ size_t nIndex = 0;
+ for (const auto& rProp : aprop)
{
- if ( !aIt->Name.isEmpty() )
+ if ( !rProp.Name.isEmpty() )
{
- OString aName = OUStringToOString( aIt->Name, RTL_TEXTENCODING_ASCII_US );
+ OString aName = OUStringToOString( rProp.Name, RTL_TEXTENCODING_ASCII_US );
// pid starts from 2 not from 1 as MS supports pid from 2
pAppProps->startElement( XML_property ,
XML_fmtid, "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
- XML_pid, OString::number((aIt - aprop.begin()) + 2),
+ XML_pid, OString::number(nIndex + 2),
XML_name, aName,
FSEND);
- switch ( aIt->Value.getValueTypeClass() )
+ switch ( rProp.Value.getValueTypeClass() )
{
case TypeClass_STRING:
{
OUString aValue;
- aIt->Value >>= aValue;
+ rProp.Value >>= aValue;
writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aValue );
}
break;
case TypeClass_BOOLEAN:
{
- bool val = *o3tl::forceAccess<bool>(aIt->Value);
+ bool val = *o3tl::forceAccess<bool>(rProp.Value);
writeElement( pAppProps, FSNS( XML_vt, XML_bool ), val ? 1 : 0);
}
break;
@@ -815,23 +816,23 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
util::Date aDate;
util::Duration aDuration;
util::DateTime aDateTime;
- if ( ( aIt->Value ) >>= num )
+ if ( rProp.Value >>= num )
{
writeElement( pAppProps, FSNS( XML_vt, XML_i4 ), num );
}
- else if ( ( aIt->Value ) >>= aDate )
+ else if ( rProp.Value >>= aDate )
{
aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Year, aDate.Month, aDate.Day, true );
writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime);
}
- else if ( ( aIt->Value ) >>= aDuration )
+ else if ( rProp.Value >>= aDuration )
{
OUStringBuffer buf;
::sax::Converter::convertDuration( buf, aDuration );
OUString aDurationStr = buf.makeStringAndClear();
writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aDurationStr );
}
- else if ( ( aIt->Value ) >>= aDateTime )
+ else if ( rProp.Value >>= aDateTime )
writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime );
else
//no other options
@@ -841,6 +842,7 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
}
pAppProps->endElement( XML_property );
}
+ ++nIndex;
}
pAppProps->endElement( XML_Properties );
}
diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx
index 98623f750aca..1f6c73e11d0b 100644
--- a/oox/source/drawingml/chart/typegroupconverter.cxx
+++ b/oox/source/drawingml/chart/typegroupconverter.cxx
@@ -371,7 +371,7 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
OSL_ENSURE( aSeries.size() >= 3, "TypeGroupConverter::convertFromModel - too few stock chart series" );
int nRoleIdx = (aSeries.size() == 3) ? 1 : 0;
- for( SeriesConvVector::iterator aIt = aSeries.begin(), aEnd = aSeries.end(); (nRoleIdx < 4) && (aIt != aEnd); ++nRoleIdx, ++aIt )
+ for( auto& rxSeriesConv : aSeries )
{
// create a data sequence with a specific role
OUString aRole;
@@ -382,9 +382,13 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
case 2: aRole = "values-min"; break;
case 3: aRole = "values-last"; break;
}
- Reference< XLabeledDataSequence > xDataSeq = (*aIt)->createValueSequence( aRole );
+ Reference< XLabeledDataSequence > xDataSeq = rxSeriesConv->createValueSequence( aRole );
if( xDataSeq.is() )
aLabeledSeqVec.push_back( xDataSeq );
+
+ ++nRoleIdx;
+ if (nRoleIdx >= 4)
+ break;
}
// attach labeled data sequences to series and insert series into chart type
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 1e7e9607172e..b3063762cd7a 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -150,10 +150,8 @@ void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
{
const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
const std::vector<oox::drawingml::ShapePtr>& rChildren = pParentShape->getChildren();
- auto it = std::find_if(
- rChildren.begin(), rChildren.end(),
- [pShape](const oox::drawingml::ShapePtr& pChild) { return pChild == pShape; });
- if (it == rChildren.end())
+ if (std::none_of(rChildren.begin(), rChildren.end(),
+ [pShape](const oox::drawingml::ShapePtr& pChild) { return pChild == pShape; }))
// This is not our parent.
continue;
@@ -1152,23 +1150,20 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
pPresNode->msModelId);
if( aNodeName != mrDgm.getData()->getPresOfNameMap().end() )
{
- DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin();
- const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end();
- while( aVecIter != aVecEnd )
+ for( const auto& rItem : aNodeName->second )
{
DiagramData::PointNameMap& rMap = mrDgm.getData()->getPointNameMap();
// pPresNode is the presentation node of the aDataNode2 data node.
- DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(aVecIter->first);
+ DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(rItem.first);
if (aDataNode2 == rMap.end())
{
//busted, skip it
- ++aVecIter;
continue;
}
rShape->setDataNodeType(aDataNode2->second->mnType);
- if( aVecIter->second == 0 )
+ if( rItem.second == 0 )
{
// grab shape attr from topmost element(s)
rShape->getShapeProperties() = aDataNode2->second->mpShape->getShapeProperties();
@@ -1210,8 +1205,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
for (const auto& pSourceParagraph : rSourceParagraphs)
{
TextParagraph& rPara = pTextBody->addParagraph();
- if (aVecIter->second != -1)
- rPara.getProperties().setLevel(aVecIter->second);
+ if (rItem.second != -1)
+ rPara.getProperties().setLevel(rItem.second);
for (const auto& pRun : pSourceParagraph->getRuns())
rPara.addRun(pRun);
@@ -1219,8 +1214,6 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
rPara.getProperties().apply(rBody->getParagraphs().front()->getProperties());
}
}
-
- ++aVecIter;
}
}
else
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b935bec0de96..b01aa8ac51ce 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1190,35 +1190,35 @@ Reference< XShape > const & Shape::createAndInsert(
if( aShapeProps.hasProperty( PROP_FillGradient ) )
{
std::vector<beans::PropertyValue> aGradientStops;
- auto aIt = aFillProperties.maGradientProps.maGradientStops.begin();
- for( size_t i = 0; i < aFillProperties.maGradientProps.maGradientStops.size(); ++i )
+ size_t i = 0;
+ for( const auto& [rPos, rColor] : aFillProperties.maGradientProps.maGradientStops )
{ // for each stop in the gradient definition:
// save position
std::vector<beans::PropertyValue> aGradientStop;
- aGradientStop.push_back(comphelper::makePropertyValue("Pos", aIt->first));
+ aGradientStop.push_back(comphelper::makePropertyValue("Pos", rPos));
- OUString sStopColorScheme = aIt->second.getSchemeName();
+ OUString sStopColorScheme = rColor.getSchemeName();
if( sStopColorScheme.isEmpty() )
{
// save RGB color
- aGradientStop.push_back(comphelper::makePropertyValue("RgbClr", aIt->second.getColor(rGraphicHelper, nFillPhClr)));
+ aGradientStop.push_back(comphelper::makePropertyValue("RgbClr", rColor.getColor(rGraphicHelper, nFillPhClr)));
// in the case of a RGB color, transformations are already applied to
// the color with the exception of alpha transformations. We only need
// to keep the transparency value to calculate the alpha value later.
- if( aIt->second.hasTransparency() )
- aGradientStop.push_back(comphelper::makePropertyValue("Transparency", aIt->second.getTransparency()));
+ if( rColor.hasTransparency() )
+ aGradientStop.push_back(comphelper::makePropertyValue("Transparency", rColor.getTransparency()));
}
else
{
// save color with scheme name
aGradientStop.push_back(comphelper::makePropertyValue("SchemeClr", sStopColorScheme));
// save all color transformations
- aGradientStop.push_back(comphelper::makePropertyValue("Transformations", aIt->second.getTransformations()));
+ aGradientStop.push_back(comphelper::makePropertyValue("Transformations", rColor.getTransformations()));
}
aGradientStops.push_back(comphelper::makePropertyValue(OUString::number(i), comphelper::containerToSequence(aGradientStop)));
- ++aIt;
+ ++i;
}
// If getFillProperties.moFillType is unused that means gradient is defined by a theme
// which is already saved into StyleFillRef property, so no need to save the explicit values too
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 6a6de0cbfe52..0f3de9741094 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -450,21 +450,23 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
}
}
// apply caption/titles to pages
- auto itCtrlId = pMultiPage->mnIDs.begin();
- auto itCtrlId_end = pMultiPage->mnIDs.end();
- AxArrayString::iterator itCaption = sCaptions.begin();
maControls.clear();
// need to sort the controls according to the order of the ids
- for ( sal_Int32 index = 1 ; ( sCaptions.size() == idToPage.size() ) && itCtrlId != itCtrlId_end; ++itCtrlId, ++itCaption, ++index )
+ if ( sCaptions.size() == idToPage.size() )
{
- IdToPageMap::iterator iter = idToPage.find( *itCtrlId );
- if ( iter != idToPage.end() )
+ AxArrayString::iterator itCaption = sCaptions.begin();
+ for ( const auto& rCtrlId : pMultiPage->mnIDs )
{
- AxPageModel* pPage = static_cast<AxPageModel*> ( iter->second->mxCtrlModel.get() );
-
- pPage->importProperty( XML_Caption, *itCaption );
- maControls.push_back( iter->second );
+ IdToPageMap::iterator iter = idToPage.find( rCtrlId );
+ if ( iter != idToPage.end() )
+ {
+ AxPageModel* pPage = static_cast<AxPageModel*> ( iter->second->mxCtrlModel.get() );
+
+ pPage->importProperty( XML_Caption, *itCaption );
+ maControls.push_back( iter->second );
+ }
+ ++itCaption;
}
}
}