[Libreoffice-commits] libvisio.git: src/lib
Miklos Vajna
vmiklos at collabora.co.uk
Tue Sep 19 07:56:43 UTC 2017
src/lib/VSD5Parser.cpp | 6 +-
src/lib/VSDCharacterList.cpp | 13 ++---
src/lib/VSDContentCollector.cpp | 103 +++++++++++++++++++---------------------
src/lib/VSDFieldList.cpp | 12 ++--
src/lib/VSDGeometryList.cpp | 20 +++----
src/lib/VSDLayerList.cpp | 12 ++--
src/lib/VSDMetaData.cpp | 4 -
src/lib/VSDPages.cpp | 12 ++--
src/lib/VSDParagraphList.cpp | 13 ++---
src/lib/VSDParser.cpp | 8 +--
src/lib/VSDShapeList.cpp | 4 -
src/lib/VSDStylesCollector.cpp | 4 -
src/lib/VSDXMLHelper.cpp | 12 ++--
src/lib/VSDXMLParserBase.cpp | 8 +--
14 files changed, 113 insertions(+), 118 deletions(-)
New commits:
commit f958f47bf16eb932c6e6aa3caebdde67470cd705
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Sep 19 09:56:21 2017 +0200
Convert explicit for loops to range-based ones where possible
This is most useful in libvisio::VSDMetaData::readPropertySetStream() to
avoid repeating ourselves.
Change-Id: Ieeca010476c776589b56b145f5b973eec86001fe
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index c3f80fd..12e5ed0 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -128,11 +128,11 @@ void libvisio::VSD5Parser::handleChunkRecords(librevenge::RVNGInputStream *input
}
}
i = 0;
- for (std::map<unsigned, ChunkHeader>::iterator iter = records.begin(); iter != records.end(); ++iter)
+ for (auto &record : records)
{
- m_header = iter->second;
+ m_header = record.second;
m_header.id = i++;
- input->seek(startPosition + iter->first, librevenge::RVNG_SEEK_SET);
+ input->seek(startPosition + record.first, librevenge::RVNG_SEEK_SET);
handleChunk(input);
}
}
diff --git a/src/lib/VSDCharacterList.cpp b/src/lib/VSDCharacterList.cpp
index 6574d7a..3961bd5 100644
--- a/src/lib/VSDCharacterList.cpp
+++ b/src/lib/VSDCharacterList.cpp
@@ -148,9 +148,8 @@ void libvisio::VSDCharacterList::setCharCount(unsigned id, unsigned charCount)
void libvisio::VSDCharacterList::resetCharCount()
{
- for (std::map<unsigned, VSDCharacterListElement *>::iterator iter = m_elements.begin();
- iter != m_elements.end(); ++iter)
- iter->second->setCharCount(0);
+ for (auto &element : m_elements)
+ element.second->setCharCount(0);
}
unsigned libvisio::VSDCharacterList::getLevel() const
@@ -163,8 +162,8 @@ unsigned libvisio::VSDCharacterList::getLevel() const
void libvisio::VSDCharacterList::setElementsOrder(const std::vector<unsigned> &elementsOrder)
{
m_elementsOrder.clear();
- for (unsigned i = 0; i<elementsOrder.size(); i++)
- m_elementsOrder.push_back(elementsOrder[i]);
+ for (unsigned int i : elementsOrder)
+ m_elementsOrder.push_back(i);
}
void libvisio::VSDCharacterList::handle(VSDCollector *collector) const
@@ -191,8 +190,8 @@ void libvisio::VSDCharacterList::handle(VSDCollector *collector) const
void libvisio::VSDCharacterList::clear()
{
- for (std::map<unsigned, VSDCharacterListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
- delete iter->second;
+ for (auto &element : m_elements)
+ delete element.second;
m_elements.clear();
m_elementsOrder.clear();
}
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 8163ce8..512cac9 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -333,14 +333,14 @@ void libvisio::VSDContentCollector::_flushCurrentPath(unsigned shapeId)
{
bool firstPoint = true;
bool wasMove = false;
- for (unsigned i = 0; i < m_currentFillGeometry.size(); i++)
+ for (auto &i : m_currentFillGeometry)
{
if (firstPoint)
{
firstPoint = false;
wasMove = true;
}
- else if (m_currentFillGeometry[i]["librevenge:path-action"]->getStr() == "M")
+ else if (i["librevenge:path-action"]->getStr() == "M")
{
if (!tmpPath.empty())
{
@@ -362,7 +362,7 @@ void libvisio::VSDContentCollector::_flushCurrentPath(unsigned shapeId)
}
else
wasMove = false;
- tmpPath.push_back(m_currentFillGeometry[i]);
+ tmpPath.push_back(i);
}
if (!tmpPath.empty())
{
@@ -407,16 +407,16 @@ void libvisio::VSDContentCollector::_flushCurrentPath(unsigned shapeId)
double y = 0.0;
double prevX = 0.0;
double prevY = 0.0;
- for (unsigned i = 0; i < m_currentLineGeometry.size(); i++)
+ for (auto &i : m_currentLineGeometry)
{
if (firstPoint)
{
firstPoint = false;
wasMove = true;
- x = m_currentLineGeometry[i]["svg:x"]->getDouble();
- y = m_currentLineGeometry[i]["svg:y"]->getDouble();
+ x = i["svg:x"]->getDouble();
+ y = i["svg:y"]->getDouble();
}
- else if (m_currentLineGeometry[i]["librevenge:path-action"]->getStr() == "M")
+ else if (i["librevenge:path-action"]->getStr() == "M")
{
if (!tmpPath.empty())
{
@@ -437,17 +437,17 @@ void libvisio::VSDContentCollector::_flushCurrentPath(unsigned shapeId)
tmpPath.pop_back();
}
}
- x = m_currentLineGeometry[i]["svg:x"]->getDouble();
- y = m_currentLineGeometry[i]["svg:y"]->getDouble();
+ x = i["svg:x"]->getDouble();
+ y = i["svg:y"]->getDouble();
wasMove = true;
}
else
wasMove = false;
- tmpPath.push_back(m_currentLineGeometry[i]);
- if (m_currentLineGeometry[i]["svg:x"])
- prevX = m_currentLineGeometry[i]["svg:x"]->getDouble();
- if (m_currentLineGeometry[i]["svg:y"])
- prevY = m_currentLineGeometry[i]["svg:y"]->getDouble();
+ tmpPath.push_back(i);
+ if (i["svg:x"])
+ prevX = i["svg:x"]->getDouble();
+ if (i["svg:y"])
+ prevY = i["svg:y"]->getDouble();
}
if (!tmpPath.empty())
{
@@ -581,22 +581,22 @@ void libvisio::VSDContentCollector::_convertToPath(const std::vector<librevenge:
{
double prevX = DBL_MAX;
double prevY = DBL_MAX;
- for (unsigned i = 0; i < segmentVector.size(); ++i)
+ for (const auto &i : segmentVector)
{
- if (!segmentVector[i]["librevenge:path-action"])
+ if (!i["librevenge:path-action"])
continue;
double x = DBL_MAX;
double y = DBL_MAX;
- if (segmentVector[i]["svg:x"] && segmentVector[i]["svg:y"])
+ if (i["svg:x"] && i["svg:y"])
{
- x = segmentVector[i]["svg:x"]->getDouble();
- y = segmentVector[i]["svg:y"]->getDouble();
+ x = i["svg:x"]->getDouble();
+ y = i["svg:y"]->getDouble();
}
// skip segment that have length 0.0
if (!VSD_ALMOST_ZERO(x-prevX) || !VSD_ALMOST_ZERO(y-prevY))
{
- path.append(segmentVector[i]);
+ path.append(i);
prevX = x;
prevY = y;
}
@@ -1200,12 +1200,11 @@ void libvisio::VSDContentCollector::_fillParagraphProperties(librevenge::RVNGPro
void libvisio::VSDContentCollector::_fillTabSet(librevenge::RVNGPropertyList &propList, const VSDTabSet &tabSet)
{
librevenge::RVNGPropertyListVector tmpTabSet;
- for (std::map<unsigned, VSDTabStop>::const_iterator iterTS = tabSet.m_tabStops.begin();
- iterTS != tabSet.m_tabStops.end(); ++iterTS)
+ for (const auto &tabStop : tabSet.m_tabStops)
{
librevenge::RVNGPropertyList tmpTabStop;
- tmpTabStop.insert("style:position", iterTS->second.m_position);
- switch (iterTS->second.m_alignment)
+ tmpTabStop.insert("style:position", tabStop.second.m_position);
+ switch (tabStop.second.m_alignment)
{
case 0:
tmpTabStop.insert("style:type", "left");
@@ -1281,9 +1280,9 @@ void libvisio::VSDContentCollector::_flushCurrentPage()
m_groupMemberships != m_groupMembershipsSequence.end())
{
std::stack<std::pair<unsigned, VSDOutputElementList> > groupTextStack;
- for (std::list<unsigned>::iterator iterList = m_pageShapeOrder->begin(); iterList != m_pageShapeOrder->end(); ++iterList)
+ for (unsigned int &iterList : *m_pageShapeOrder)
{
- std::map<unsigned, unsigned>::iterator iterGroup = m_groupMemberships->find(*iterList);
+ std::map<unsigned, unsigned>::iterator iterGroup = m_groupMemberships->find(iterList);
if (iterGroup == m_groupMemberships->end())
{
while (!groupTextStack.empty())
@@ -1302,14 +1301,14 @@ void libvisio::VSDContentCollector::_flushCurrentPage()
}
std::map<unsigned, VSDOutputElementList>::iterator iter;
- iter = m_pageOutputDrawing.find(*iterList);
+ iter = m_pageOutputDrawing.find(iterList);
if (iter != m_pageOutputDrawing.end())
m_currentPage.append(iter->second);
- iter = m_pageOutputText.find(*iterList);
+ iter = m_pageOutputText.find(iterList);
if (iter != m_pageOutputText.end())
- groupTextStack.push(std::make_pair(*iterList, iter->second));
+ groupTextStack.push(std::make_pair(iterList, iter->second));
else
- groupTextStack.push(std::make_pair(*iterList, VSDOutputElementList()));
+ groupTextStack.push(std::make_pair(iterList, VSDOutputElementList()));
}
while (!groupTextStack.empty())
{
@@ -1514,12 +1513,12 @@ void libvisio::VSDContentCollector::collectInfiniteLine(unsigned /* id */, unsig
{
xmove = points.begin()->first;
ymove = points.begin()->second;
- for (std::map<double, double>::iterator iter = points.begin(); iter != points.end(); ++iter)
+ for (auto &point : points)
{
- if (iter->first != xmove || iter->second != ymove)
+ if (point.first != xmove || point.second != ymove)
{
- xline = iter->first;
- yline = iter->second;
+ xline = point.first;
+ yline = point.second;
}
}
}
@@ -2102,10 +2101,10 @@ bool libvisio::VSDContentCollector::_isUniform(const std::vector<double> &weight
if (weights.empty())
return true;
double previousValue = weights[0];
- for (std::vector<double>::size_type i = 0; i < weights.size(); ++i)
+ for (double weight : weights)
{
- if (VSD_ALMOST_ZERO(weights[i] - previousValue))
- previousValue = weights[i];
+ if (VSD_ALMOST_ZERO(weight - previousValue))
+ previousValue = weight;
else
return false;
}
@@ -2125,12 +2124,12 @@ void libvisio::VSDContentCollector::collectNURBSTo(unsigned /* id */, unsigned l
std::vector<std::pair<double, double> > controlPoints(ctrlPnts);
// Convert control points to static co-ordinates
- for (std::vector<std::pair<double, double> >::iterator iter = controlPoints.begin(); iter != controlPoints.end(); ++iter)
+ for (auto &controlPoint : controlPoints)
{
if (xType == 0) // Percentage
- iter->first *= m_xform.width;
+ controlPoint.first *= m_xform.width;
if (yType == 0) // Percentage
- iter->second *= m_xform.height;
+ controlPoint.second *= m_xform.height;
}
controlPoints.push_back(std::pair<double,double>(x2, y2));
@@ -2150,10 +2149,10 @@ void libvisio::VSDContentCollector::collectNURBSTo(unsigned /* id */, unsigned l
double lastKnot = knotVector.back()-knotVector[0];
if (VSD_ALMOST_ZERO(lastKnot))
lastKnot = VSD_EPSILON;
- for (std::vector<double>::iterator knot = knotVector.begin(); knot != knotVector.end(); ++knot)
+ for (double &knot : knotVector)
{
- *knot -= firstKnot;
- *knot /= lastKnot;
+ knot -= firstKnot;
+ knot /= lastKnot;
}
if (degree <= 3 && _isUniform(weights))
@@ -2573,11 +2572,11 @@ void libvisio::VSDContentCollector::collectShape(unsigned id, unsigned level, un
_handleForeignData(m_stencilShape->m_foreign->data);
}
- for (std::map< unsigned, VSDName>::const_iterator iterData = m_stencilShape->m_names.begin(); iterData != m_stencilShape->m_names.end(); ++iterData)
+ for (const auto &name : m_stencilShape->m_names)
{
librevenge::RVNGString nameString;
- _convertDataToString(nameString, iterData->second.m_data, iterData->second.m_format);
- m_stencilNames[iterData->first] = nameString;
+ _convertDataToString(nameString, name.second.m_data, name.second.m_format);
+ m_stencilNames[name.first] = nameString;
}
if (m_stencilShape->m_txtxform)
@@ -3469,12 +3468,11 @@ void libvisio::VSDContentCollector::_handleLevelChange(unsigned level)
if (m_currentFillGeometry.empty() && m_currentLineGeometry.empty() && !m_noShow)
{
- for (std::map<unsigned, VSDGeometryList>::const_iterator cstiter = m_stencilShape->m_geometries.begin();
- cstiter != m_stencilShape->m_geometries.end(); ++cstiter)
+ for (const auto &geometry : m_stencilShape->m_geometries)
{
m_x = 0.0;
m_y = 0.0;
- cstiter->second.handle(this);
+ geometry.second.handle(this);
}
}
m_isStencilStarted = false;
@@ -3616,15 +3614,14 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex
UChar32 ucs4Character = 0;
if (format == VSD_TEXT_SYMBOL) // SYMBOL
{
- for (std::vector<unsigned char>::const_iterator iter = characters.begin();
- iter != characters.end(); ++iter)
+ for (unsigned char character : characters)
{
if (0x1e == ucs4Character)
ucs4Character = 0xfffc;
- else if (*iter < 0x20)
+ else if (character < 0x20)
ucs4Character = 0x20;
else
- ucs4Character = symbolmap[*iter - 0x20];
+ ucs4Character = symbolmap[character - 0x20];
appendUCS4(text, ucs4Character);
}
}
diff --git a/src/lib/VSDFieldList.cpp b/src/lib/VSDFieldList.cpp
index bf11537..13b540f 100644
--- a/src/lib/VSDFieldList.cpp
+++ b/src/lib/VSDFieldList.cpp
@@ -204,8 +204,8 @@ libvisio::VSDFieldList::~VSDFieldList()
void libvisio::VSDFieldList::setElementsOrder(const std::vector<unsigned> &elementsOrder)
{
m_elementsOrder.clear();
- for (unsigned i = 0; i<elementsOrder.size(); i++)
- m_elementsOrder.push_back(elementsOrder[i]);
+ for (unsigned int i : elementsOrder)
+ m_elementsOrder.push_back(i);
}
void libvisio::VSDFieldList::addFieldList(unsigned id, unsigned level)
@@ -235,9 +235,9 @@ void libvisio::VSDFieldList::handle(VSDCollector *collector) const
std::map<unsigned, VSDFieldListElement *>::const_iterator iter;
if (!m_elementsOrder.empty())
{
- for (unsigned i = 0; i < m_elementsOrder.size(); i++)
+ for (unsigned int i : m_elementsOrder)
{
- iter = m_elements.find(m_elementsOrder[i]);
+ iter = m_elements.find(i);
if (iter != m_elements.end())
iter->second->handle(collector);
}
@@ -251,8 +251,8 @@ void libvisio::VSDFieldList::handle(VSDCollector *collector) const
void libvisio::VSDFieldList::clear()
{
- for (std::map<unsigned, VSDFieldListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
- delete iter->second;
+ for (auto &element : m_elements)
+ delete element.second;
m_elements.clear();
m_elementsOrder.clear();
}
diff --git a/src/lib/VSDGeometryList.cpp b/src/lib/VSDGeometryList.cpp
index 764273e..f62ed24 100644
--- a/src/lib/VSDGeometryList.cpp
+++ b/src/lib/VSDGeometryList.cpp
@@ -918,8 +918,8 @@ void libvisio::VSDGeometryList::addRelQuadBezTo(unsigned id, unsigned level, con
void libvisio::VSDGeometryList::setElementsOrder(const std::vector<unsigned> &elementsOrder)
{
m_elementsOrder.clear();
- for (unsigned i = 0; i<elementsOrder.size(); i++)
- m_elementsOrder.push_back(elementsOrder[i]);
+ for (unsigned int i : elementsOrder)
+ m_elementsOrder.push_back(i);
}
void libvisio::VSDGeometryList::handle(VSDCollector *collector) const
@@ -929,9 +929,9 @@ void libvisio::VSDGeometryList::handle(VSDCollector *collector) const
std::map<unsigned, VSDGeometryListElement *>::const_iterator iter;
if (!m_elementsOrder.empty())
{
- for (unsigned i = 0; i < m_elementsOrder.size(); i++)
+ for (unsigned int i : m_elementsOrder)
{
- iter = m_elements.find(m_elementsOrder[i]);
+ iter = m_elements.find(i);
if (iter != m_elements.end())
iter->second->handle(collector);
}
@@ -944,9 +944,9 @@ void libvisio::VSDGeometryList::handle(VSDCollector *collector) const
tmpVector.push_back(iter->first);
std::sort(tmpVector.begin(), tmpVector.end());
- for (unsigned i = 0; i < tmpVector.size(); i++)
+ for (unsigned int i : tmpVector)
{
- iter = m_elements.find(tmpVector[i]);
+ iter = m_elements.find(i);
if (iter != m_elements.end())
iter->second->handle(collector);
}
@@ -956,8 +956,8 @@ void libvisio::VSDGeometryList::handle(VSDCollector *collector) const
void libvisio::VSDGeometryList::clear()
{
- for (std::map<unsigned, VSDGeometryListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
- delete iter->second;
+ for (auto &element : m_elements)
+ delete element.second;
m_elements.clear();
m_elementsOrder.clear();
}
@@ -987,8 +987,8 @@ void libvisio::VSDGeometryList::clearElement(unsigned id)
void libvisio::VSDGeometryList::resetLevel(unsigned level)
{
- for (std::map<unsigned, VSDGeometryListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
- iter->second->setLevel(level);
+ for (auto &element : m_elements)
+ element.second->setLevel(level);
}
diff --git a/src/lib/VSDLayerList.cpp b/src/lib/VSDLayerList.cpp
index 2ab7f8a..e8aad03 100644
--- a/src/lib/VSDLayerList.cpp
+++ b/src/lib/VSDLayerList.cpp
@@ -70,9 +70,9 @@ void libvisio::VSDLayerList::addLayer(unsigned id, const libvisio::VSDLayer &lay
const libvisio::Colour *libvisio::VSDLayerList::getColour(const std::vector<unsigned> &ids)
{
std::map<unsigned, libvisio::VSDLayer>::const_iterator iterColour = m_elements.end();
- for (std::vector<unsigned>::const_iterator iter = ids.begin(); iter != ids.end(); ++iter)
+ for (unsigned int id : ids)
{
- std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(*iter);
+ std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(id);
// It is enough that one layer does not override colour and the original colour is used
if (iterMap == m_elements.end() || !iterMap->second.m_colour)
return nullptr;
@@ -93,9 +93,9 @@ bool libvisio::VSDLayerList::getVisible(const std::vector<unsigned> &ids)
if (ids.empty())
return true;
- for (std::vector<unsigned>::const_iterator iter = ids.begin(); iter != ids.end(); ++iter)
+ for (unsigned int id : ids)
{
- std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(*iter);
+ std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(id);
if (iterMap == m_elements.end())
return true;
else if (iterMap->second.m_visible)
@@ -109,9 +109,9 @@ bool libvisio::VSDLayerList::getPrintable(const std::vector<unsigned> &ids)
if (ids.empty())
return true;
- for (std::vector<unsigned>::const_iterator iter = ids.begin(); iter != ids.end(); ++iter)
+ for (unsigned int id : ids)
{
- std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(*iter);
+ std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(id);
if (iterMap == m_elements.end())
return true;
else if (iterMap->second.m_printable)
diff --git a/src/lib/VSDMetaData.cpp b/src/lib/VSDMetaData.cpp
index 358a6ef..a7bcb4d 100644
--- a/src/lib/VSDMetaData.cpp
+++ b/src/lib/VSDMetaData.cpp
@@ -107,9 +107,9 @@ void libvisio::VSDMetaData::readPropertySetStream(librevenge::RVNGInputStream *i
uint16_t data2 = readU16(input);
uint16_t data3 = readU16(input);
uint8_t data4[8];
- for (int i = 0; i < 8; i++)
+ for (unsigned char &i : data4)
{
- data4[i] = readU8(input);
+ i = readU8(input);
}
// Pretty-printed GUID is 36 bytes + the terminating null-character.
char FMTID0[37];
diff --git a/src/lib/VSDPages.cpp b/src/lib/VSDPages.cpp
index 08c4073..a0294ad 100644
--- a/src/lib/VSDPages.cpp
+++ b/src/lib/VSDPages.cpp
@@ -83,15 +83,15 @@ void libvisio::VSDPages::draw(librevenge::RVNGDrawingInterface *painter)
painter->startDocument(librevenge::RVNGPropertyList());
painter->setDocumentMetaData(m_metaData);
- for (unsigned i = 0; i < m_pages.size(); ++i)
+ for (auto &page : m_pages)
{
librevenge::RVNGPropertyList pageProps;
- pageProps.insert("svg:width", m_pages[i].m_pageWidth);
- pageProps.insert("svg:height", m_pages[i].m_pageHeight);
- if (m_pages[i].m_pageName.len())
- pageProps.insert("draw:name", m_pages[i].m_pageName);
+ pageProps.insert("svg:width", page.m_pageWidth);
+ pageProps.insert("svg:height", page.m_pageHeight);
+ if (page.m_pageName.len())
+ pageProps.insert("draw:name", page.m_pageName);
painter->startPage(pageProps);
- _drawWithBackground(painter, m_pages[i]);
+ _drawWithBackground(painter, page);
painter->endPage();
}
// Visio shows background pages in tabs after the normal pages
diff --git a/src/lib/VSDParagraphList.cpp b/src/lib/VSDParagraphList.cpp
index 7ec7f30..cfb70b1 100644
--- a/src/lib/VSDParagraphList.cpp
+++ b/src/lib/VSDParagraphList.cpp
@@ -158,9 +158,8 @@ void libvisio::VSDParagraphList::setCharCount(unsigned id, unsigned charCount)
void libvisio::VSDParagraphList::resetCharCount()
{
- for (std::map<unsigned, VSDParagraphListElement *>::iterator iter = m_elements.begin();
- iter != m_elements.end(); ++iter)
- iter->second->setCharCount(0);
+ for (auto &element : m_elements)
+ element.second->setCharCount(0);
}
unsigned libvisio::VSDParagraphList::getLevel() const
@@ -173,8 +172,8 @@ unsigned libvisio::VSDParagraphList::getLevel() const
void libvisio::VSDParagraphList::setElementsOrder(const std::vector<unsigned> &elementsOrder)
{
m_elementsOrder.clear();
- for (unsigned i = 0; i<elementsOrder.size(); i++)
- m_elementsOrder.push_back(elementsOrder[i]);
+ for (unsigned int i : elementsOrder)
+ m_elementsOrder.push_back(i);
}
void libvisio::VSDParagraphList::handle(VSDCollector *collector) const
@@ -201,8 +200,8 @@ void libvisio::VSDParagraphList::handle(VSDCollector *collector) const
void libvisio::VSDParagraphList::clear()
{
- for (std::map<unsigned, VSDParagraphListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
- delete iter->second;
+ for (auto &element : m_elements)
+ delete element.second;
m_elements.clear();
m_elementsOrder.clear();
}
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index cc7484c..31baf5a 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -97,9 +97,9 @@ bool libvisio::VSDParser::getChunkHeader(librevenge::RVNGInputStream *input)
m_header.trailer += 4;
}
- for (unsigned i = 0; i < 14; i++)
+ for (unsigned int trailerChunk : trailerChunks)
{
- if (m_header.chunkType == trailerChunks[i] && m_header.trailer != 12 && m_header.trailer != 4)
+ if (m_header.chunkType == trailerChunk && m_header.trailer != 12 && m_header.trailer != 4)
{
m_header.trailer += 4;
break;
@@ -284,9 +284,9 @@ void libvisio::VSDParser::handleStreams(librevenge::RVNGInputStream *input, unsi
if (!pointerOrder.empty())
{
- for (unsigned j=0; j < pointerOrder.size(); ++j)
+ for (unsigned int j : pointerOrder)
{
- iter = PtrList.find(pointerOrder[j]);
+ iter = PtrList.find(j);
if (iter != PtrList.end())
{
handleStream(iter->second, iter->first, level+1, visited);
diff --git a/src/lib/VSDShapeList.cpp b/src/lib/VSDShapeList.cpp
index bb45cd0..de15718 100644
--- a/src/lib/VSDShapeList.cpp
+++ b/src/lib/VSDShapeList.cpp
@@ -70,9 +70,9 @@ const std::vector<unsigned> &libvisio::VSDShapeList::getShapesOrder()
std::map<unsigned, unsigned>::const_iterator iter;
if (!m_elementsOrder.empty())
{
- for (unsigned i = 0; i < m_elementsOrder.size(); i++)
+ for (unsigned int i : m_elementsOrder)
{
- iter = m_elements.find(m_elementsOrder[i]);
+ iter = m_elements.find(i);
if (iter != m_elements.end())
m_shapesOrder.push_back(iter->second);
}
diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp
index c7ff44d..7f849f7 100644
--- a/src/lib/VSDStylesCollector.cpp
+++ b/src/lib/VSDStylesCollector.cpp
@@ -209,8 +209,8 @@ void libvisio::VSDStylesCollector::collectShapesOrder(unsigned /* id */, unsigne
{
_handleLevelChange(level);
m_shapeList.clear();
- for (unsigned i = 0; i < shapeIds.size(); ++i)
- m_shapeList.push_back(shapeIds[i]);
+ for (unsigned int shapeId : shapeIds)
+ m_shapeList.push_back(shapeId);
_flushShapeList();
}
diff --git a/src/lib/VSDXMLHelper.cpp b/src/lib/VSDXMLHelper.cpp
index cddef07..6df3255 100644
--- a/src/lib/VSDXMLHelper.cpp
+++ b/src/lib/VSDXMLHelper.cpp
@@ -66,20 +66,20 @@ void libvisio::VSDXRelationship::rebaseTarget(const char *baseDir)
boost::split(segments, target, boost::is_any_of("/\\"));
std::vector<std::string> normalizedSegments;
- for (unsigned i = 0; i < segments.size(); ++i)
+ for (auto &segment : segments)
{
- if (segments[i] == "..")
+ if (segment == "..")
normalizedSegments.pop_back();
- else if (segments[i] != "." && !segments[i].empty())
- normalizedSegments.push_back(segments[i]);
+ else if (segment != "." && !segment.empty())
+ normalizedSegments.push_back(segment);
}
target.clear();
- for (unsigned j = 0; j < normalizedSegments.size(); ++j)
+ for (const auto &normalizedSegment : normalizedSegments)
{
if (!target.empty())
target.append("/");
- target.append(normalizedSegments[j]);
+ target.append(normalizedSegment);
}
// VSD_DEBUG_MSG(("VSDXRelationship::rebaseTarget %s -> %s\n", m_target.c_str(), target.c_str()));
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 35f26e4..678e302 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -1790,16 +1790,16 @@ void libvisio::VSDXMLParserBase::_flushShape()
if (!m_shape.m_geometries.empty())
{
- for (std::map<unsigned, VSDGeometryList>::iterator iter = m_shape.m_geometries.begin(); iter != m_shape.m_geometries.end(); ++iter)
- iter->second.resetLevel(m_currentShapeLevel+2);
+ for (auto &geometry : m_shape.m_geometries)
+ geometry.second.resetLevel(m_currentShapeLevel+2);
std::vector<unsigned> tmpVector;
for (std::map<unsigned, VSDGeometryList>::const_iterator iterGeom = m_shape.m_geometries.begin(); iterGeom != m_shape.m_geometries.end(); ++iterGeom)
tmpVector.push_back(iterGeom->first);
std::sort(tmpVector.begin(), tmpVector.end());
- for (unsigned i = 0; i < tmpVector.size(); i++)
+ for (unsigned int i : tmpVector)
{
- std::map<unsigned, VSDGeometryList>::const_iterator iter = m_shape.m_geometries.find(tmpVector[i]);
+ std::map<unsigned, VSDGeometryList>::const_iterator iter = m_shape.m_geometries.find(i);
if (iter != m_shape.m_geometries.end())
{
iter->second.handle(m_collector);
More information about the Libreoffice-commits
mailing list