[Libreoffice-commits] libmspub.git: 2 commits - configure.ac src/lib

2017-04-23 Thread David Tardon
 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>

[Libreoffice-commits] libmspub.git: 2 commits - configure.ac src/lib

2013-05-01 Thread Fridrich Štrba
 configure.ac   |   11 ---
 src/lib/ListInfo.h |1 -
 src/lib/MSPUBBlockID.h |2 ++
 src/lib/MSPUBCollector.cpp |   18 ++
 src/lib/MSPUBCollector.h   |1 -
 src/lib/MSPUBParser.cpp|   28 +++-
 src/lib/MSPUBTypes.h   |3 ++-
 src/lib/libmspub_utils.h   |1 -
 8 files changed, 45 insertions(+), 20 deletions(-)

New commits:
commit ad0f36d02bf8bc1cfabb4d615bb27f216ef81cec
Author: Fridrich Å trba 
Date:   Wed May 1 23:40:46 2013 +0200

Some boost header sanitizing

diff --git a/configure.ac b/configure.ac
index 394e89a..6d8bf60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,10 +66,15 @@ AC_SUBST(ZLIB_LIBS)
 # ===
 # Find required boost headers
 # ===
-AC_CHECK_HEADER(
-   boost/ptr_container/ptr_map.hpp,
+AC_CHECK_HEADERS(
+   boost/bind.hpp \
+   boost/function.hpp \
+   boost/optional.hpp \
+   boost/ptr_container/ptr_vector.hpp \
+   boost/scoped_ptr.hpp \
+   boost/shared_ptr.hpp,
[],
-   [AC_MSG_ERROR(boost/ptr_container/ptr_map.hpp not found. install 
boost)],
+   [AC_MSG_ERROR(Required boost headers not found. Install boost)],
[]
 )
 
diff --git a/src/lib/ListInfo.h b/src/lib/ListInfo.h
index b6691c9..93b56d2 100644
--- a/src/lib/ListInfo.h
+++ b/src/lib/ListInfo.h
@@ -30,7 +30,6 @@
 #define __LISTINFO_H__
 
 #include 
-#include 
 
 #include "NumberingType.h"
 #include "NumberingDelimiter.h"
diff --git a/src/lib/MSPUBCollector.h b/src/lib/MSPUBCollector.h
index 5755043..fd8fd3e 100644
--- a/src/lib/MSPUBCollector.h
+++ b/src/lib/MSPUBCollector.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 993b706..9b150a7 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -32,7 +32,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include "MSPUBParser.h"
 #include "MSPUBCollector.h"
diff --git a/src/lib/libmspub_utils.h b/src/lib/libmspub_utils.h
index c1ff6f8..c0ba308 100644
--- a/src/lib/libmspub_utils.h
+++ b/src/lib/libmspub_utils.h
@@ -33,7 +33,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
commit 546bf85c66d90e14beec96d51018fdc38b0d95c2
Author: Franz Schmid 
Date:   Wed May 1 20:35:07 2013 +0200

Added support for DropCaps letter setting and fixed column and column-gap 
output.

diff --git a/src/lib/MSPUBBlockID.h b/src/lib/MSPUBBlockID.h
index a44c5a8..4cd7c2b 100644
--- a/src/lib/MSPUBBlockID.h
+++ b/src/lib/MSPUBBlockID.h
@@ -69,6 +69,8 @@ enum MSPUBBlockID // Don't be alarmed by multiple elements 
with the same value;
   PARAGRAPH_LEFT_INDENT = 0xD,
   PARAGRAPH_RIGHT_INDENT = 0xE,
   PARAGRAPH_DROP_CAP_LINES = 0x8,
+  PARAGRAPH_DROP_CAP_UP = 0x2C,
+  PARAGRAPH_DROP_CAP_LETTERS = 0x2D,
   THIS_MASTER_NAME = 0xE,
   APPLIED_MASTER_NAME = 0xD,
   BA_ARRAY = 0x02,
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index f16ae79..a23c713 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -809,6 +809,18 @@ boost::function 
libmspub::MSPUBCollector::paintShape(const ShapeInfo
 break;
   }
 }
+if (info.m_numColumns)
+{
+  unsigned ncols = info.m_numColumns.get_value_or(0);
+  if (ncols > 0)
+props.insert("fo:column-count", (int)ncols);
+}
+if (info.m_columnSpacing)
+{
+  unsigned ngap = info.m_columnSpacing;
+  if (ngap > 0)
+props.insert("fo:column-gap", (double)ngap / EMUS_IN_INCH);
+}
 m_painter->startTextObject(props, WPXPropertyListVector());
 for (unsigned i_lines = 0; i_lines < text.size(); ++i_lines)
 {
@@ -1199,6 +1211,12 @@ WPXPropertyList 
libmspub::MSPUBCollector::getParaStyleProps(const ParagraphStyle
   {
 ret.insert("style:drop-cap", (int)dropCapLines);
   }
+  unsigned dropCapLetters = style.m_dropCapLetters.get_value_or(
+  defaultStyle.m_dropCapLetters.get_value_or(0));
+  if (dropCapLetters != 0)
+  {
+ret.insert("style:length", (int)dropCapLetters);
+  }
   return ret;
 }
 
diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 418ea1b..993b706 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -1263,6 +1263,9 @@ libmspub::ParagraphStyle 
libmspub::MSPUBParser::getParagraphStyle(WPXInputStream
 case PARAGRAPH_DROP_CAP_LINES:
   ret.m_dropCapLines = info.data;
   break;
+case PARAGRAPH_DROP_CAP_LETTERS:
+  ret.m_dropCapLetters = info.data;
+  break;
 default:
   break;
 }
@@ -1686,17 +1689,19 @@ void 
libmspub::MSPUBParser::parseEscherShape(WPXInputStream *input, const Escher
 dotStyle));
   }
 
-  unsigned *ptr_numColumns = getIfExists(foptValues.m_scalarValues,
- FIELDID_NUM_COLUMNS);
-  if