[Libreoffice-commits] libvisio.git: 7 commits - src/lib
David Tardon
dtardon at redhat.com
Sun Mar 25 14:50:44 UTC 2018
src/lib/VDXParser.cpp | 39 ++++++++++++++++++++-------------------
src/lib/VSD5Parser.cpp | 7 ++++---
src/lib/VSD6Parser.cpp | 5 +++--
src/lib/VSDCharacterList.cpp | 3 ++-
src/lib/VSDContentCollector.cpp | 3 ++-
src/lib/VSDFieldList.cpp | 3 ++-
src/lib/VSDGeometryList.cpp | 3 ++-
src/lib/VSDInternalStream.cpp | 2 +-
src/lib/VSDMetaData.cpp | 1 +
src/lib/VSDPages.cpp | 1 +
src/lib/VSDParagraphList.cpp | 33 ++++++++++-----------------------
src/lib/VSDParagraphList.h | 3 ++-
src/lib/VSDParser.cpp | 23 +++++++++++------------
src/lib/VSDShapeList.cpp | 2 +-
src/lib/VSDStencils.cpp | 25 +++++++------------------
src/lib/VSDStencils.h | 7 ++++---
src/lib/VSDStyles.cpp | 3 ++-
src/lib/VSDStylesCollector.cpp | 3 ++-
src/lib/VSDXMLHelper.cpp | 5 +----
src/lib/VSDXMLParserBase.cpp | 9 +++++----
src/lib/VSDXMLTokenMap.cpp | 1 +
src/lib/VSDXMetaData.cpp | 1 +
src/lib/VSDXParser.cpp | 39 ++++++++++++++++++++-------------------
src/lib/VisioDocument.cpp | 3 ++-
src/lib/libvisio_utils.cpp | 6 ++----
src/lib/libvisio_xml.cpp | 3 +++
26 files changed, 112 insertions(+), 121 deletions(-)
New commits:
commit c1bb49486e73e9e19944be6a995e3bbd96210f8f
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:49:53 2018 +0200
move define where it should be
Change-Id: Ie8080354158b01bd29c14105dce3919eb19a01e6
diff --git a/src/lib/VSDXMLHelper.cpp b/src/lib/VSDXMLHelper.cpp
index c0e1cf5..6f483b8 100644
--- a/src/lib/VSDXMLHelper.cpp
+++ b/src/lib/VSDXMLHelper.cpp
@@ -7,10 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
-#define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE 1
-#endif
-
#include "VSDXMLHelper.h"
#include <memory>
diff --git a/src/lib/libvisio_xml.cpp b/src/lib/libvisio_xml.cpp
index fb18627..df0c5f9 100644
--- a/src/lib/libvisio_xml.cpp
+++ b/src/lib/libvisio_xml.cpp
@@ -9,6 +9,9 @@
#include "libvisio_xml.h"
+#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
+#define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE 1
+#endif
#include <boost/lexical_cast.hpp>
#include "VSDTypes.h"
commit 5fa2b1a754a026f7c36f339b396574c1c43700c8
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:48:12 2018 +0200
make sure headers are self-contained
Change-Id: I77beb4ce00ec070f2599362f6462d967613abd2b
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index 0e5cc1b..c305ab8 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -7,12 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VDXParser.h"
+
#include <memory>
#include <string.h>
#include <libxml/xmlIO.h>
#include <libxml/xmlstring.h>
#include <librevenge-stream/librevenge-stream.h>
-#include "VDXParser.h"
#include "libvisio_utils.h"
#include "libvisio_xml.h"
#include "VSDContentCollector.h"
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index fe841cc..cfc0d94 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -7,13 +7,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSD5Parser.h"
+
#include <librevenge-stream/librevenge-stream.h>
#include <locale.h>
#include <sstream>
#include <string>
#include <stack>
#include "libvisio_utils.h"
-#include "VSD5Parser.h"
#include "VSDInternalStream.h"
#include "VSDDocumentStructure.h"
#include "VSDContentCollector.h"
diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp
index ea3be55..a41016b 100644
--- a/src/lib/VSD6Parser.cpp
+++ b/src/lib/VSD6Parser.cpp
@@ -7,12 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSD6Parser.h"
+
#include <librevenge-stream/librevenge-stream.h>
#include <locale.h>
#include <sstream>
#include <string>
#include "libvisio_utils.h"
-#include "VSD6Parser.h"
#include "VSDInternalStream.h"
#include "VSDDocumentStructure.h"
#include "VSDContentCollector.h"
diff --git a/src/lib/VSDCharacterList.cpp b/src/lib/VSDCharacterList.cpp
index 6f9fe8e..17935fc 100644
--- a/src/lib/VSDCharacterList.cpp
+++ b/src/lib/VSDCharacterList.cpp
@@ -7,9 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "VSDCollector.h"
#include "VSDCharacterList.h"
+#include "VSDCollector.h"
+
namespace libvisio
{
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index cde0ad0..8b297da 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDContentCollector.h"
+
#include <algorithm>
#include <cassert>
#include <string.h> // for memcpy
@@ -17,7 +19,6 @@
#include <unicode/ucnv.h>
#include <unicode/utf8.h>
-#include "VSDContentCollector.h"
#include "VSDParser.h"
#include "VSDInternalStream.h"
diff --git a/src/lib/VSDFieldList.cpp b/src/lib/VSDFieldList.cpp
index 363d20e..c4c16ef 100644
--- a/src/lib/VSDFieldList.cpp
+++ b/src/lib/VSDFieldList.cpp
@@ -7,9 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDFieldList.h"
+
#include <time.h>
#include "VSDCollector.h"
-#include "VSDFieldList.h"
#include "libvisio_utils.h"
void libvisio::VSDTextField::handle(VSDCollector *collector) const
diff --git a/src/lib/VSDGeometryList.cpp b/src/lib/VSDGeometryList.cpp
index 92746d8..a195136 100644
--- a/src/lib/VSDGeometryList.cpp
+++ b/src/lib/VSDGeometryList.cpp
@@ -7,8 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "VSDCollector.h"
#include "VSDGeometryList.h"
+
+#include "VSDCollector.h"
#include "libvisio_utils.h"
namespace libvisio
diff --git a/src/lib/VSDInternalStream.cpp b/src/lib/VSDInternalStream.cpp
index 9d66015..bc3548a 100644
--- a/src/lib/VSDInternalStream.cpp
+++ b/src/lib/VSDInternalStream.cpp
@@ -7,9 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <string.h>
#include "VSDInternalStream.h"
+#include <string.h>
VSDInternalStream::VSDInternalStream(librevenge::RVNGInputStream *input, unsigned long size, bool compressed) :
librevenge::RVNGInputStream(),
diff --git a/src/lib/VSDMetaData.cpp b/src/lib/VSDMetaData.cpp
index c200b5f..09e8f97 100644
--- a/src/lib/VSDMetaData.cpp
+++ b/src/lib/VSDMetaData.cpp
@@ -8,6 +8,7 @@
*/
#include "VSDMetaData.h"
+
#include <cassert>
#include <cmath>
#include <cstdio>
diff --git a/src/lib/VSDPages.cpp b/src/lib/VSDPages.cpp
index 335dd69..1236435 100644
--- a/src/lib/VSDPages.cpp
+++ b/src/lib/VSDPages.cpp
@@ -8,6 +8,7 @@
*/
#include "VSDPages.h"
+
#include "libvisio_utils.h"
libvisio::VSDPage::VSDPage()
diff --git a/src/lib/VSDParagraphList.cpp b/src/lib/VSDParagraphList.cpp
index f77b500..33f75fa 100644
--- a/src/lib/VSDParagraphList.cpp
+++ b/src/lib/VSDParagraphList.cpp
@@ -7,9 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "VSDCollector.h"
#include "VSDParagraphList.h"
+#include "VSDCollector.h"
+
namespace libvisio
{
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 673cc93..c967165 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDParser.h"
+
#include <librevenge-stream/librevenge-stream.h>
#include <locale.h>
#include <cassert>
@@ -15,7 +17,6 @@
#include <cmath>
#include <set>
#include "libvisio_utils.h"
-#include "VSDParser.h"
#include "VSDInternalStream.h"
#include "VSDDocumentStructure.h"
#include "VSDContentCollector.h"
diff --git a/src/lib/VSDShapeList.cpp b/src/lib/VSDShapeList.cpp
index de15718..bfa29d1 100644
--- a/src/lib/VSDShapeList.cpp
+++ b/src/lib/VSDShapeList.cpp
@@ -7,9 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "VSDCollector.h"
#include "VSDShapeList.h"
+#include "VSDCollector.h"
libvisio::VSDShapeList::VSDShapeList() :
m_elements(),
diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp
index 192114c..7037f2f 100644
--- a/src/lib/VSDStencils.cpp
+++ b/src/lib/VSDStencils.cpp
@@ -8,6 +8,7 @@
*/
#include "VSDStencils.h"
+
#include "libvisio_utils.h"
libvisio::VSDShape::VSDShape()
diff --git a/src/lib/VSDStyles.cpp b/src/lib/VSDStyles.cpp
index cc87a68..9a3d400 100644
--- a/src/lib/VSDStyles.cpp
+++ b/src/lib/VSDStyles.cpp
@@ -7,9 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDStyles.h"
+
#include <set>
#include <stack>
-#include "VSDStyles.h"
#include "VSDTypes.h"
namespace libvisio
diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp
index 527bc33..cc8021f 100644
--- a/src/lib/VSDStylesCollector.cpp
+++ b/src/lib/VSDStylesCollector.cpp
@@ -7,9 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDStylesCollector.h"
+
#include <vector>
#include <map>
-#include "VSDStylesCollector.h"
libvisio::VSDStylesCollector::VSDStylesCollector(
std::vector<std::map<unsigned, XForm> > &groupXFormsSequence,
diff --git a/src/lib/VSDXMLHelper.cpp b/src/lib/VSDXMLHelper.cpp
index 80f62a5..c0e1cf5 100644
--- a/src/lib/VSDXMLHelper.cpp
+++ b/src/lib/VSDXMLHelper.cpp
@@ -11,13 +11,14 @@
#define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE 1
#endif
+#include "VSDXMLHelper.h"
+
#include <memory>
#include <sstream>
#include <istream>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <librevenge-stream/librevenge-stream.h>
-#include "VSDXMLHelper.h"
#include "libvisio_utils.h"
#include "libvisio_xml.h"
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index c78b872..edbaac4 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDXMLParserBase.h"
+
#include <string.h>
#include <libxml/xmlIO.h>
#include <libxml/xmlstring.h>
@@ -15,7 +17,6 @@
#include <boost/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
-#include "VSDXMLParserBase.h"
#include "libvisio_utils.h"
#include "libvisio_xml.h"
#include "VSDContentCollector.h"
diff --git a/src/lib/VSDXMLTokenMap.cpp b/src/lib/VSDXMLTokenMap.cpp
index b9a5829..97b01f2 100644
--- a/src/lib/VSDXMLTokenMap.cpp
+++ b/src/lib/VSDXMLTokenMap.cpp
@@ -8,6 +8,7 @@
*/
#include "VSDXMLTokenMap.h"
+
#include <string.h>
namespace
diff --git a/src/lib/VSDXMetaData.cpp b/src/lib/VSDXMetaData.cpp
index c0e5708..9b3d3cf 100644
--- a/src/lib/VSDXMetaData.cpp
+++ b/src/lib/VSDXMetaData.cpp
@@ -8,6 +8,7 @@
*/
#include "VSDXMetaData.h"
+
#include "VSDXMLTokenMap.h"
#include "libvisio_utils.h"
#include "libvisio_xml.h"
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 153e464..1bb46cf 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -7,12 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "VSDXParser.h"
+
#include <memory>
#include <string.h>
#include <libxml/xmlIO.h>
#include <libxml/xmlstring.h>
#include <librevenge-stream/librevenge-stream.h>
-#include "VSDXParser.h"
#include "libvisio_utils.h"
#include "libvisio_xml.h"
#include "VSDContentCollector.h"
diff --git a/src/lib/VisioDocument.cpp b/src/lib/VisioDocument.cpp
index bc2b477..accb5d1 100644
--- a/src/lib/VisioDocument.cpp
+++ b/src/lib/VisioDocument.cpp
@@ -7,12 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <libvisio/libvisio.h>
+
#include <algorithm>
#include <memory>
#include <string>
#include <librevenge/librevenge.h>
-#include <libvisio/libvisio.h>
#include "libvisio_utils.h"
#include "libvisio_xml.h"
#include "VDXParser.h"
diff --git a/src/lib/libvisio_utils.cpp b/src/lib/libvisio_utils.cpp
index 8ab2aab..457b06d 100644
--- a/src/lib/libvisio_utils.cpp
+++ b/src/lib/libvisio_utils.cpp
@@ -7,10 +7,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "libvisio_utils.h"
+
#include <cstdarg>
#include <cstdio>
#include "VSDInternalStream.h"
-#include "libvisio_utils.h"
uint8_t libvisio::readU8(librevenge::RVNGInputStream *input)
{
commit b52f763a0026d8c3eb2aa4b2ec3fa8a5abedbe9d
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:44:55 2018 +0200
drop unused headers
Change-Id: I697c5ee7e9ed2c694452e00ca2ed77c92c7650a3
diff --git a/src/lib/libvisio_utils.cpp b/src/lib/libvisio_utils.cpp
index 63ab796..8ab2aab 100644
--- a/src/lib/libvisio_utils.cpp
+++ b/src/lib/libvisio_utils.cpp
@@ -7,9 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <vector>
-#include <string>
-#include <algorithm> // std::count
#include <cstdarg>
#include <cstdio>
#include "VSDInternalStream.h"
commit 26ea6f33a413861a4764bbfae6f244ec38f7bad8
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:42:46 2018 +0200
use unique_ptr for text xform
Change-Id: I2dacd0bfe4024055e9233730ff6485c8631f6a48
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index a81e5bc..0e5cc1b 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -613,7 +613,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinX, reader);
}
break;
@@ -621,7 +621,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinY, reader);
}
break;
@@ -629,7 +629,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->width, reader);
}
break;
@@ -637,7 +637,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->height, reader);
}
break;
@@ -645,7 +645,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinLocX, reader);
}
break;
@@ -653,7 +653,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinLocY, reader);
}
break;
@@ -661,7 +661,7 @@ void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->angle, reader);
}
break;
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index fabb9a3..673cc93 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -1167,9 +1167,7 @@ void libvisio::VSDParser::readXForm1D(librevenge::RVNGInputStream *input)
void libvisio::VSDParser::readTxtXForm(librevenge::RVNGInputStream *input)
{
- if (m_shape.m_txtxform)
- delete m_shape.m_txtxform;
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
input->seek(1, librevenge::RVNG_SEEK_CUR);
m_shape.m_txtxform->pinX = readDouble(input);
input->seek(1, librevenge::RVNG_SEEK_CUR);
@@ -1317,7 +1315,7 @@ void libvisio::VSDParser::readShape(librevenge::RVNGInputStream *input)
m_shape.m_foreign = make_unique<ForeignData>(*(tmpShape->m_foreign));
m_shape.m_xform = tmpShape->m_xform;
if (tmpShape->m_txtxform)
- m_shape.m_txtxform = new XForm(*(tmpShape->m_txtxform));
+ m_shape.m_txtxform = make_unique<XForm>(*(tmpShape->m_txtxform));
m_shape.m_tabSets = tmpShape->m_tabSets;
m_shape.m_text = tmpShape->m_text;
m_shape.m_textFormat = tmpShape->m_textFormat;
diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp
index ba7f9be..192114c 100644
--- a/src/lib/VSDStencils.cpp
+++ b/src/lib/VSDStencils.cpp
@@ -15,7 +15,7 @@ libvisio::VSDShape::VSDShape()
m_masterShape(MINUS_ONE), m_shapeId(MINUS_ONE), m_lineStyleId(MINUS_ONE), m_fillStyleId(MINUS_ONE),
m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(),
m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
- m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(nullptr),
+ m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(),
m_xform1d(), m_misc(), m_layerMem()
{
}
@@ -69,9 +69,7 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
m_nurbsData = shape.m_nurbsData;
m_polylineData = shape.m_polylineData;
m_xform = shape.m_xform;
- if (m_txtxform)
- delete m_txtxform;
- m_txtxform = shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : nullptr;
+ m_txtxform.reset(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : nullptr);
m_xform1d.reset(shape.m_xform1d ? new XForm1D(*shape.m_xform1d) : nullptr);
m_misc = shape.m_misc;
m_layerMem = shape.m_layerMem;
@@ -82,8 +80,6 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
void libvisio::VSDShape::clear()
{
m_foreign = nullptr;
- if (m_txtxform)
- delete m_txtxform;
m_txtxform = nullptr;
m_xform1d = nullptr;
diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h
index 7be7063..01d2f4f 100644
--- a/src/lib/VSDStencils.h
+++ b/src/lib/VSDStencils.h
@@ -53,7 +53,7 @@ public:
std::map<unsigned, NURBSData> m_nurbsData;
std::map<unsigned, PolylineData> m_polylineData;
XForm m_xform;
- XForm *m_txtxform;
+ std::unique_ptr<XForm> m_txtxform;
std::unique_ptr<XForm1D> m_xform1d;
VSDMisc m_misc;
VSDName m_layerMem;
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 48d2741..c78b872 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -969,7 +969,7 @@ void libvisio::VSDXMLParserBase::readShape(xmlTextReaderPtr reader)
m_shape.m_foreign = make_unique<ForeignData>(*(tmpShape->m_foreign));
m_shape.m_xform = tmpShape->m_xform;
if (tmpShape->m_txtxform)
- m_shape.m_txtxform = new XForm(*(tmpShape->m_txtxform));
+ m_shape.m_txtxform = make_unique<XForm>(*(tmpShape->m_txtxform));
m_shape.m_geometries = tmpShape->m_geometries;
m_shape.m_charList = tmpShape->m_charList;
m_shape.m_paraList = tmpShape->m_paraList;
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index e2c8087..153e464 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -994,7 +994,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinX, reader);
}
break;
@@ -1002,7 +1002,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinY, reader);
}
break;
@@ -1010,7 +1010,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->width, reader);
}
break;
@@ -1018,7 +1018,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->height, reader);
}
break;
@@ -1026,7 +1026,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinLocX, reader);
}
break;
@@ -1034,7 +1034,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->pinLocY, reader);
}
break;
@@ -1042,7 +1042,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_txtxform)
- m_shape.m_txtxform = new XForm();
+ m_shape.m_txtxform = make_unique<XForm>();
ret = readDoubleData(m_shape.m_txtxform->angle, reader);
}
break;
commit 8a3b290280fe07a990d7a84b21a0cdc5f28d1c2f
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:39:03 2018 +0200
use unique_ptr to hold foreign data
Change-Id: I605e3fc76a7f909566450ccff33649745f16f200
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index 72f78b9..a81e5bc 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -940,7 +940,7 @@ void libvisio::VDXParser::getBinaryData(xmlTextReaderPtr reader)
if (data)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
m_shape.m_foreign->data.clear();
m_shape.m_foreign->data.appendBase64Data(librevenge::RVNGString((const char *)data));
}
@@ -967,7 +967,7 @@ void libvisio::VDXParser::readForeignInfo(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->offsetX, reader);
}
break;
@@ -975,7 +975,7 @@ void libvisio::VDXParser::readForeignInfo(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->offsetY, reader);
}
break;
@@ -983,7 +983,7 @@ void libvisio::VDXParser::readForeignInfo(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->width, reader);
}
break;
@@ -991,7 +991,7 @@ void libvisio::VDXParser::readForeignInfo(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->height, reader);
}
break;
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index 50b3324..fe841cc 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -406,7 +406,7 @@ void libvisio::VSD5Parser::readShape(librevenge::RVNGInputStream *input)
if (tmpShape)
{
if (tmpShape->m_foreign)
- m_shape.m_foreign = new ForeignData(*(tmpShape->m_foreign));
+ m_shape.m_foreign = make_unique<ForeignData>(*(tmpShape->m_foreign));
m_shape.m_text = tmpShape->m_text;
m_shape.m_textFormat = tmpShape->m_textFormat;
}
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 61e5f38..fabb9a3 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -343,7 +343,7 @@ void libvisio::VSDParser::handleStream(const Pointer &ptr, unsigned idx, unsigne
break;
case VSD_OLE_LIST:
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
m_shape.m_foreign->dataId = idx;
break;
default:
@@ -770,7 +770,7 @@ void libvisio::VSDParser::readForeignData(librevenge::RVNGInputStream *input)
librevenge::RVNGBinaryData binaryData(buffer, tmpBytesRead);
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
m_shape.m_foreign->dataId = m_header.id;
m_shape.m_foreign->data = binaryData;
}
@@ -788,7 +788,7 @@ void libvisio::VSDParser::readOLEData(librevenge::RVNGInputStream *input)
librevenge::RVNGBinaryData oleData(buffer, tmpBytesRead);
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
// Append data instead of setting it - allows multi-stream OLE objects
m_shape.m_foreign->data.append(oleData);
@@ -1236,7 +1236,7 @@ void libvisio::VSDParser::readForeignDataType(librevenge::RVNGInputStream *input
unsigned foreignFormat = readU32(input);
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
m_shape.m_foreign->typeId = m_header.id;
m_shape.m_foreign->type = foreignType;
m_shape.m_foreign->format = foreignFormat;
@@ -1314,7 +1314,7 @@ void libvisio::VSDParser::readShape(librevenge::RVNGInputStream *input)
if (tmpShape)
{
if (tmpShape->m_foreign)
- m_shape.m_foreign = new ForeignData(*(tmpShape->m_foreign));
+ m_shape.m_foreign = make_unique<ForeignData>(*(tmpShape->m_foreign));
m_shape.m_xform = tmpShape->m_xform;
if (tmpShape->m_txtxform)
m_shape.m_txtxform = new XForm(*(tmpShape->m_txtxform));
diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp
index 2243c53..ba7f9be 100644
--- a/src/lib/VSDStencils.cpp
+++ b/src/lib/VSDStencils.cpp
@@ -11,7 +11,7 @@
#include "libvisio_utils.h"
libvisio::VSDShape::VSDShape()
- : m_geometries(), m_shapeList(), m_fields(), m_foreign(nullptr), m_parent(0), m_masterPage(MINUS_ONE),
+ : m_geometries(), m_shapeList(), m_fields(), m_foreign(), m_parent(0), m_masterPage(MINUS_ONE),
m_masterShape(MINUS_ONE), m_shapeId(MINUS_ONE), m_lineStyleId(MINUS_ONE), m_fillStyleId(MINUS_ONE),
m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(),
m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
@@ -47,9 +47,7 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
m_geometries = shape.m_geometries;
m_shapeList = shape.m_shapeList;
m_fields = shape.m_fields;
- if (m_foreign)
- delete m_foreign;
- m_foreign = shape.m_foreign ? new ForeignData(*(shape.m_foreign)) : nullptr;
+ m_foreign.reset(shape.m_foreign ? new ForeignData(*(shape.m_foreign)) : nullptr);
m_parent = shape.m_parent;
m_masterPage = shape.m_masterPage;
m_masterShape = shape.m_masterShape;
@@ -83,8 +81,6 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
void libvisio::VSDShape::clear()
{
- if (m_foreign)
- delete m_foreign;
m_foreign = nullptr;
if (m_txtxform)
delete m_txtxform;
diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h
index 5beedf9..7be7063 100644
--- a/src/lib/VSDStencils.h
+++ b/src/lib/VSDStencils.h
@@ -36,7 +36,7 @@ public:
std::map<unsigned, VSDGeometryList> m_geometries;
VSDShapeList m_shapeList;
VSDFieldList m_fields;
- ForeignData *m_foreign;
+ std::unique_ptr<ForeignData> m_foreign;
unsigned m_parent, m_masterPage, m_masterShape, m_shapeId;
unsigned m_lineStyleId, m_fillStyleId, m_textStyleId;
VSDOptionalLineStyle m_lineStyle;
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index e1d9d0d..48d2741 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -966,7 +966,7 @@ void libvisio::VSDXMLParserBase::readShape(xmlTextReaderPtr reader)
if (tmpShape)
{
if (tmpShape->m_foreign)
- m_shape.m_foreign = new ForeignData(*(tmpShape->m_foreign));
+ m_shape.m_foreign = make_unique<ForeignData>(*(tmpShape->m_foreign));
m_shape.m_xform = tmpShape->m_xform;
if (tmpShape->m_txtxform)
m_shape.m_txtxform = new XForm(*(tmpShape->m_txtxform));
@@ -1707,7 +1707,7 @@ void libvisio::VSDXMLParserBase::readForeignData(xmlTextReaderPtr reader)
{
VSD_DEBUG_MSG(("VSDXMLParser::readForeignData\n"));
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
const shared_ptr<xmlChar> foreignTypeString(xmlTextReaderGetAttribute(reader, BAD_CAST("ForeignType")), xmlFree);
if (foreignTypeString)
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index e6385d8..e2c8087 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -1098,7 +1098,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->offsetX, reader);
}
break;
@@ -1106,7 +1106,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->offsetY, reader);
}
break;
@@ -1114,7 +1114,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->width, reader);
}
break;
@@ -1122,7 +1122,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
ret = readDoubleData(m_shape.m_foreign->height, reader);
}
break;
@@ -1469,7 +1469,7 @@ void libvisio::VSDXParser::getBinaryData(xmlTextReaderPtr reader)
}
}
if (!m_shape.m_foreign)
- m_shape.m_foreign = new ForeignData();
+ m_shape.m_foreign = make_unique<ForeignData>();
m_shape.m_foreign->data = m_currentBinaryData;
}
commit 160825ec6e25b3de6086479f856d14a6dcaaa60a
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:30:08 2018 +0200
use unique_ptr
Change-Id: I2677dfde71b049c287df2ea68d656b0ad63dc8df
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index bb7b9d3..72f78b9 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -488,7 +488,7 @@ void libvisio::VDXParser::readMisc(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
readTriggerId(m_shape.m_xform1d->beginId, reader);
}
break;
@@ -496,7 +496,7 @@ void libvisio::VDXParser::readMisc(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
readTriggerId(m_shape.m_xform1d->endId, reader);
}
break;
@@ -692,7 +692,7 @@ void libvisio::VDXParser::readXForm1D(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->beginX, reader);
}
break;
@@ -700,7 +700,7 @@ void libvisio::VDXParser::readXForm1D(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->beginY, reader);
}
break;
@@ -708,7 +708,7 @@ void libvisio::VDXParser::readXForm1D(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->endX, reader);
}
break;
@@ -716,7 +716,7 @@ void libvisio::VDXParser::readXForm1D(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->endY, reader);
}
break;
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index 4caa901..50b3324 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -497,7 +497,7 @@ void libvisio::VSD5Parser::readMisc(librevenge::RVNGInputStream *input)
void libvisio::VSD5Parser::readXForm1D(librevenge::RVNGInputStream *input)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
input->seek(1, librevenge::RVNG_SEEK_CUR);
m_shape.m_xform1d->beginX = readDouble(input);
input->seek(1, librevenge::RVNG_SEEK_CUR);
diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp
index 745de2f..ea3be55 100644
--- a/src/lib/VSD6Parser.cpp
+++ b/src/lib/VSD6Parser.cpp
@@ -430,7 +430,7 @@ void libvisio::VSD6Parser::readMisc(librevenge::RVNGInputStream *input)
if (0x40000073 == readU32(input))
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
if (m_shape.m_xform1d->beginId == MINUS_ONE)
m_shape.m_xform1d->beginId = shapeId;
else if (m_shape.m_xform1d->endId == MINUS_ONE)
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 6bf380a..61e5f38 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -1154,7 +1154,7 @@ void libvisio::VSDParser::readXFormData(librevenge::RVNGInputStream *input)
void libvisio::VSDParser::readXForm1D(librevenge::RVNGInputStream *input)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
input->seek(1, librevenge::RVNG_SEEK_CUR);
m_shape.m_xform1d->beginX = readDouble(input);
input->seek(1, librevenge::RVNG_SEEK_CUR);
@@ -2268,7 +2268,7 @@ void libvisio::VSDParser::readMisc(librevenge::RVNGInputStream *input)
if (0x40000073 == readU32(input))
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
if (m_shape.m_xform1d->beginId == MINUS_ONE)
m_shape.m_xform1d->beginId = shapeId;
else if (m_shape.m_xform1d->endId == MINUS_ONE)
diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp
index 91865bd..2243c53 100644
--- a/src/lib/VSDStencils.cpp
+++ b/src/lib/VSDStencils.cpp
@@ -16,7 +16,7 @@ libvisio::VSDShape::VSDShape()
m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(),
m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(nullptr),
- m_xform1d(nullptr), m_misc(), m_layerMem()
+ m_xform1d(), m_misc(), m_layerMem()
{
}
@@ -74,9 +74,7 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
if (m_txtxform)
delete m_txtxform;
m_txtxform = shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : nullptr;
- if (m_xform1d)
- delete m_xform1d;
- m_xform1d = shape.m_xform1d ? new XForm1D(*(shape.m_xform1d)) : nullptr;
+ m_xform1d.reset(shape.m_xform1d ? new XForm1D(*shape.m_xform1d) : nullptr);
m_misc = shape.m_misc;
m_layerMem = shape.m_layerMem;
}
@@ -91,8 +89,6 @@ void libvisio::VSDShape::clear()
if (m_txtxform)
delete m_txtxform;
m_txtxform = nullptr;
- if (m_xform1d)
- delete m_xform1d;
m_xform1d = nullptr;
m_geometries.clear();
diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h
index 1b0a464..5beedf9 100644
--- a/src/lib/VSDStencils.h
+++ b/src/lib/VSDStencils.h
@@ -11,6 +11,7 @@
#define __VSDSTENCILS_H__
#include <map>
+#include <memory>
#include <vector>
#include "VSDStyles.h"
#include "VSDGeometryList.h"
@@ -53,7 +54,7 @@ public:
std::map<unsigned, PolylineData> m_polylineData;
XForm m_xform;
XForm *m_txtxform;
- XForm1D *m_xform1d;
+ std::unique_ptr<XForm1D> m_xform1d;
VSDMisc m_misc;
VSDName m_layerMem;
};
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 10a6081..e6385d8 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -1050,7 +1050,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->beginX, reader);
}
break;
@@ -1058,7 +1058,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->beginY, reader);
}
break;
@@ -1066,7 +1066,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
readTriggerId(m_shape.m_xform1d->beginId, reader);
}
break;
@@ -1074,7 +1074,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
readTriggerId(m_shape.m_xform1d->endId, reader);
}
break;
@@ -1082,7 +1082,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->endX, reader);
}
break;
@@ -1090,7 +1090,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
{
if (!m_shape.m_xform1d)
- m_shape.m_xform1d = new XForm1D();
+ m_shape.m_xform1d = make_unique<XForm1D>();
ret = readDoubleData(m_shape.m_xform1d->endY, reader);
}
break;
commit e3f0216ba318fddbfab2b92159c363dced48082e
Author: David Tardon <dtardon at redhat.com>
Date: Sun Mar 25 16:18:13 2018 +0200
avoid manual memory mgmt
Change-Id: If7229a08104410cd2df3b84202c75e68cbcfc114
diff --git a/src/lib/VSDParagraphList.cpp b/src/lib/VSDParagraphList.cpp
index c1863a1..f77b500 100644
--- a/src/lib/VSDParagraphList.cpp
+++ b/src/lib/VSDParagraphList.cpp
@@ -84,7 +84,7 @@ libvisio::VSDParagraphList::VSDParagraphList(const libvisio::VSDParagraphList &p
m_elementsOrder(paraList.m_elementsOrder)
{
for (auto iter = paraList.m_elements.begin(); iter != paraList.m_elements.end(); ++iter)
- m_elements[iter->first] = iter->second->clone();
+ m_elements[iter->first] = clone(iter->second);
}
libvisio::VSDParagraphList &libvisio::VSDParagraphList::operator=(const libvisio::VSDParagraphList ¶List)
@@ -93,7 +93,7 @@ libvisio::VSDParagraphList &libvisio::VSDParagraphList::operator=(const libvisio
{
clear();
for (auto iter = paraList.m_elements.begin(); iter != paraList.m_elements.end(); ++iter)
- m_elements[iter->first] = iter->second->clone();
+ m_elements[iter->first] = clone(iter->second);
m_elementsOrder = paraList.m_elementsOrder;
}
return *this;
@@ -101,7 +101,6 @@ libvisio::VSDParagraphList &libvisio::VSDParagraphList::operator=(const libvisio
libvisio::VSDParagraphList::~VSDParagraphList()
{
- clear();
}
void libvisio::VSDParagraphList::addParaIX(unsigned id, unsigned level, unsigned charCount, const boost::optional<double> &indFirst,
@@ -112,21 +111,11 @@ void libvisio::VSDParagraphList::addParaIX(unsigned id, unsigned level, unsigned
const boost::optional<VSDName> &bulletFont, const boost::optional<double> &bulletFontSize,
const boost::optional<double> &textPosAfterBullet, const boost::optional<unsigned> &flags)
{
- auto *tmpElement = dynamic_cast<VSDParaIX *>(m_elements[id]);
+ auto *tmpElement = dynamic_cast<VSDParaIX *>(m_elements[id].get());
if (!tmpElement)
- {
- auto iter = m_elements.find(id);
- if (m_elements.end() != iter)
- {
- if (iter->second)
- delete iter->second;
- m_elements.erase(iter);
- }
-
- m_elements[id] = new VSDParaIX(id, level, charCount, indFirst, indLeft, indRight, spLine, spBefore,
- spAfter, align, bullet, bulletStr, bulletFont, bulletFontSize,
- textPosAfterBullet, flags);
- }
+ m_elements[id] = make_unique<VSDParaIX>(id, level, charCount, indFirst, indLeft, indRight, spLine, spBefore,
+ spAfter, align, bullet, bulletStr, bulletFont, bulletFontSize,
+ textPosAfterBullet, flags);
else
tmpElement->m_style.override(VSDOptionalParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore,
spAfter, align, bullet, bulletStr, bulletFont, bulletFontSize,
@@ -181,19 +170,18 @@ void libvisio::VSDParagraphList::handle(VSDCollector *collector) const
{
if (empty())
return;
- std::map<unsigned, VSDParagraphListElement *>::const_iterator iter;
if (!m_elementsOrder.empty())
{
for (unsigned i = 0; i < m_elementsOrder.size(); i++)
{
- iter = m_elements.find(m_elementsOrder[i]);
+ auto iter = m_elements.find(m_elementsOrder[i]);
if (iter != m_elements.end() && (0 == i || iter->second->getCharCount()))
iter->second->handle(collector);
}
}
else
{
- for (iter = m_elements.begin(); iter != m_elements.end(); ++iter)
+ for (auto iter = m_elements.begin(); iter != m_elements.end(); ++iter)
if (m_elements.begin() == iter || iter->second->getCharCount())
iter->second->handle(collector);
}
@@ -201,8 +189,6 @@ void libvisio::VSDParagraphList::handle(VSDCollector *collector) const
void libvisio::VSDParagraphList::clear()
{
- for (auto &element : m_elements)
- delete element.second;
m_elements.clear();
m_elementsOrder.clear();
}
diff --git a/src/lib/VSDParagraphList.h b/src/lib/VSDParagraphList.h
index 090ce91..9a7cbe0 100644
--- a/src/lib/VSDParagraphList.h
+++ b/src/lib/VSDParagraphList.h
@@ -10,6 +10,7 @@
#ifndef __VSDPARAGRAPHLIST_H__
#define __VSDPARAGRAPHLIST_H__
+#include <memory>
#include <vector>
#include <map>
#include "VSDStyles.h"
@@ -47,7 +48,7 @@ public:
return (m_elements.empty());
}
private:
- std::map<unsigned, VSDParagraphListElement *> m_elements;
+ std::map<unsigned, std::unique_ptr<VSDParagraphListElement>> m_elements;
std::vector<unsigned> m_elementsOrder;
};
More information about the Libreoffice-commits
mailing list