configure.ac |1 -
src/lib/MSPUBCollector.cpp| 24 +++-
src/lib/MSPUBCollector.h | 11 +--
src/lib/MSPUBParser2k.cpp | 10 --
src/lib/ShapeGroupElement.cpp |8 ++--
src/lib/ShapeGroupElement.h |5 +++--
6 files changed, 25 insertions(+), 34 deletions(-)
New commits:
commit bbe7f806b95ef427153ba18bff80e674b1704ae5
Author: David Tardon
Date: Sun Apr 23 19:14:45 2017 +0200
replace dumb pointers by smart ones
Change-Id: I9e70f71e67aff4d8ee5ffa1f2024d20686fea222
diff --git a/configure.ac b/configure.ac
index a83aedd..c058bca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,6 @@ AC_SUBST(ZLIB_LIBS)
AC_CHECK_HEADERS(
boost/numeric/conversion/cast.hpp \
boost/optional.hpp \
- boost/ptr_container/ptr_vector.hpp \
,
[],
[AC_MSG_ERROR(Required boost headers not found. Install boost)],
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index 1dd2ce2..d900893 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -442,7 +442,7 @@ void MSPUBCollector::setShapeClipPath(unsigned seqNum,
const std::vector
void MSPUBCollector::beginGroup()
{
- ShapeGroupElement *tmp = new ShapeGroupElement(m_currentShapeGroup);
+ auto tmp = std::make_shared(m_currentShapeGroup.get());
if (!m_currentShapeGroup)
{
m_topLevelShapes.push_back(tmp);
@@ -456,7 +456,9 @@ bool MSPUBCollector::endGroup()
{
return false;
}
- m_currentShapeGroup = m_currentShapeGroup->getParent();
+ auto parent = m_currentShapeGroup->getParent();
+ if (parent)
+m_currentShapeGroup = parent->shared_from_this();
return true;
}
@@ -492,13 +494,13 @@ bool MSPUBCollector::setCurrentGroupSeqNum(unsigned
seqNum)
return false;
}
m_currentShapeGroup->setSeqNum(seqNum);
- m_groupsBySeqNum.insert(std::pair(seqNum,
m_currentShapeGroup));
+ m_groupsBySeqNum.insert(std::make_pair(seqNum, m_currentShapeGroup));
return true;
}
void MSPUBCollector::setShapeOrder(unsigned seqNum)
{
- ShapeGroupElement *tmp = new ShapeGroupElement(m_currentShapeGroup, seqNum);
+ auto tmp = std::make_shared(m_currentShapeGroup.get(),
seqNum);
if (!m_currentShapeGroup)
{
m_topLevelShapes.push_back(tmp);
@@ -1618,14 +1620,14 @@ void MSPUBCollector::assignShapesToPages()
{
for (unsigned i = 0; i < m_topLevelShapes.size(); ++i)
{
-unsigned *ptr_pageSeqNum = getIfExists(m_pageSeqNumsByShapeSeqNum,
m_topLevelShapes[i].getSeqNum());
-m_topLevelShapes[i].setup(std::bind(&MSPUBCollector::setupShapeStructures,
this, _1));
+unsigned *ptr_pageSeqNum = getIfExists(m_pageSeqNumsByShapeSeqNum,
m_topLevelShapes[i]->getSeqNum());
+
m_topLevelShapes[i]->setup(std::bind(&MSPUBCollector::setupShapeStructures,
this, _1));
if (ptr_pageSeqNum)
{
PageInfo *ptr_page = getIfExists(m_pagesBySeqNum, *ptr_pageSeqNum);
if (ptr_page)
{
-ptr_page->m_shapeGroupsOrdered.push_back(&m_topLevelShapes[i]);
+ptr_page->m_shapeGroupsOrdered.push_back(m_topLevelShapes[i]);
}
}
}
@@ -1654,7 +1656,7 @@ void MSPUBCollector::writePage(unsigned pageSeqNum) const
{
pageProps.insert("svg:height", m_height);
}
- const std::vector &shapeGroupsOrdered =
pageInfo.m_shapeGroupsOrdered;
+ const auto &shapeGroupsOrdered = pageInfo.m_shapeGroupsOrdered;
if (!shapeGroupsOrdered.empty())
{
m_painter->startPage(pageProps);
@@ -1677,12 +1679,8 @@ void MSPUBCollector::writePage(unsigned pageSeqNum) const
void MSPUBCollector::writePageShapes(unsigned pageSeqNum) const
{
const PageInfo &pageInfo = m_pagesBySeqNum.find(pageSeqNum)->second;
- const std::vector &shapeGroupsOrdered =
pageInfo.m_shapeGroupsOrdered;
- for (unsigned i = 0; i < shapeGroupsOrdered.size(); ++i)
- {
-ShapeGroupElement *shapeGroup = shapeGroupsOrdered[i];
+ for (const auto &shapeGroup : pageInfo.m_shapeGroupsOrdered)
shapeGroup->visit(std::bind(&MSPUBCollector::paintShape, this, _1, _2, _3,
_4, _5));
- }
}
void MSPUBCollector::writePageBackground(unsigned pageSeqNum) const
diff --git a/src/lib/MSPUBCollector.h b/src/lib/MSPUBCollector.h
index b260e6f..d40b021 100644
--- a/src/lib/MSPUBCollector.h
+++ b/src/lib/MSPUBCollector.h
@@ -14,12 +14,11 @@
#include
#include
#include
+#include
#include
#include
#include
-#include
-
#include
#include
@@ -132,7 +131,7 @@ private:
struct PageInfo
{
-std::vector m_shapeGroupsOrdered;
+std::vector> m_shapeGroupsOrdered;
PageInfo() : m_shapeGroupsOrdered() { }
};
@@ -158,9 +157,9 @@ private:
std::map m_pageSeqNumsByShapeSeqNum;
std::map m_bgShapeSeqNumsByPageSeqNum;
std::set m_skipIfNotBgSeqNums;
- ShapeGroupElement *m_currentShapeGroup;
- boost::ptr_vector m_topLevelShapes;
- std::map m_groupsBySeqNum;
+ std::shared_ptr m_currentShapeGroup;
+ std::vector> m_topLevelShapes;
+ std::map>