VSDXMLParserBase.h Source File documentation

VSDXMLParserBase.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libvisio project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef __VSDXMLPARSERBASE_H__
11 #define __VSDXMLPARSERBASE_H__
12
13 #include <map>
14 #include <stack>
15 #include <string>
16 #include <boost/optional.hpp>
17 #include "VSDXMLHelper.h"
18 #include "VSDCharacterList.h"
19 #include "VSDParagraphList.h"
20 #include "VSDShapeList.h"
21 #include "VSDStencils.h"
22
23 namespace libvisio
24 {
25
26 class VSDCollector;
27 class XMLErrorWatcher;
28
29 class VSDXMLParserBase
30 {
31 public:
32 explicit VSDXMLParserBase();
33 virtual ~VSDXMLParserBase();
34 virtual bool parseMain() = 0;
35 virtual bool extractStencils() = 0;
36
37 protected:
38 // Protected data
39 VSDCollector *m_collector;
40 VSDStencils m_stencils;
41 VSDStencil *m_currentStencil;
42 VSDShape m_shape;
43 bool m_isStencilStarted;
44 unsigned m_currentStencilID;
45
46 bool m_extractStencils;
47 bool m_isInStyles;
48 unsigned m_currentLevel;
49 unsigned m_currentShapeLevel;
50 std::map<unsigned, Colour> m_colours;
51 VSDFieldList m_fieldList;
52 VSDShapeList m_shapeList;
53 librevenge::RVNGBinaryData m_currentBinaryData;
54 std::stack<VSDShape> m_shapeStack;
55 std::stack<unsigned> m_shapeLevelStack;
56 bool m_isShapeStarted;
57 bool m_isPageStarted;
58 VSDGeometryList *m_currentGeometryList;
59 unsigned m_currentGeometryListIndex;
60
61 std::map<unsigned, VSDName> m_fonts;
62
63 std::map<unsigned, VSDTabStop> *m_currentTabSet;
64
65 XMLErrorWatcher *m_watcher;
66
67 // Helper functions
68
69 int readByteData(unsigned char &value, xmlTextReaderPtr reader);
70 int readByteData(boost::optional<unsigned char> &value, xmlTextReaderPtr reader);
71 int readUnsignedData(boost::optional<unsigned> &value, xmlTextReaderPtr reader);
72 int readLongData(boost::optional<long> &value, xmlTextReaderPtr reader);
73 int readLongData(long &value, xmlTextReaderPtr reader);
74 int readDoubleData(boost::optional<double> &value, xmlTextReaderPtr reader);
75 int readDoubleData(double &value, xmlTextReaderPtr reader);
76 int readBoolData(boost::optional<bool> &value, xmlTextReaderPtr reader);
77 int readBoolData(bool &value, xmlTextReaderPtr reader);
78 int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader);
79 int readExtendedColourData(Colour &value, xmlTextReaderPtr reader);
80 int readExtendedColourData(boost::optional<Colour> &value, xmlTextReaderPtr reader);
81 int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
82 int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
83 int readStringData(VSDName &text, xmlTextReaderPtr reader);
84
85 virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
86 unsigned getIX(xmlTextReaderPtr reader);
87 virtual void _handleLevelChange(unsigned level);
88 void _flushShape();
89
90 virtual int getElementToken(xmlTextReaderPtr reader) = 0;
91 virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
92
93 // Functions reading the DiagramML document content
94
95 void readEllipticalArcTo(xmlTextReaderPtr reader);
96 void readEllipse(xmlTextReaderPtr reader);
97 void readGeometry(xmlTextReaderPtr reader);
98 void readMoveTo(xmlTextReaderPtr reader);
99 void readLineTo(xmlTextReaderPtr reader);
100 void readArcTo(xmlTextReaderPtr reader);
101 void readNURBSTo(xmlTextReaderPtr reader);
102 void readPolylineTo(xmlTextReaderPtr reader);
103 void readInfiniteLine(xmlTextReaderPtr reader);
104 void readRelCubBezTo(xmlTextReaderPtr reader);
105 void readRelEllipticalArcTo(xmlTextReaderPtr reader);
106 void readRelLineTo(xmlTextReaderPtr reader);
107 void readRelMoveTo(xmlTextReaderPtr reader);
108 void readRelQuadBezTo(xmlTextReaderPtr reader);
109 void readForeignData(xmlTextReaderPtr reader);
110 virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
111 void readShape(xmlTextReaderPtr reader);
112 void readColours(xmlTextReaderPtr reader);
113 void readPage(xmlTextReaderPtr reader);
114 void readText(xmlTextReaderPtr reader);
115 void readCharIX(xmlTextReaderPtr reader);
116 void readParaIX(xmlTextReaderPtr reader);
117 void readLayerIX(xmlTextReaderPtr reader);
118 void readLayerMember(xmlTextReaderPtr reader);
119
120 void readStyleSheet(xmlTextReaderPtr reader);
121 void readPageSheet(xmlTextReaderPtr reader);
122
123 void readSplineStart(xmlTextReaderPtr reader);
124 void readSplineKnot(xmlTextReaderPtr reader);
125
126 void readStencil(xmlTextReaderPtr reader);
127
128 void handlePagesStart(xmlTextReaderPtr reader);
129 void handlePagesEnd(xmlTextReaderPtr reader);
130 void handlePageStart(xmlTextReaderPtr reader);
131 void handlePageEnd(xmlTextReaderPtr reader);
132 void handleMastersStart(xmlTextReaderPtr reader);
133 void handleMastersEnd(xmlTextReaderPtr reader);
134 void handleMasterStart(xmlTextReaderPtr reader);
135 void handleMasterEnd(xmlTextReaderPtr reader);
136 void skipPages(xmlTextReaderPtr reader);
137 void skipMasters(xmlTextReaderPtr reader);
138
139 private:
140 VSDXMLParserBase(const VSDXMLParserBase &);
141 VSDXMLParserBase &operator=(const VSDXMLParserBase &);
142
143 void initColours();
144 };
145
146 } // namespace libvisio
147
148 #endif // __VSDXMLPARSERBASE_H__
149 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDXMLParserBase::m_watcher
XMLErrorWatcher * m_watcher
Definition: VSDXMLParserBase.h:65
libvisio::VSDXMLParserBase::readMoveTo
void readMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:171
libvisio::VSDShape
Definition: VSDStencils.h:26
libvisio::VSDXMLParserBase::operator=
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::handleMastersEnd
void handleMastersEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1894
libvisio::VSDXMLParserBase::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDXMLParserBase.h:56
libvisio::VSDXMLParserBase::readRelLineTo
void readRelLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:772
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:27
libvisio::VSDXMLParserBase::readLayerMember
void readLayerMember(xmlTextReaderPtr reader)
libvisio::VSDXMLParserBase::readRelQuadBezTo
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:872
libvisio::VSDXMLParserBase::readSplineStart
void readSplineStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1571
libvisio::VSDXMLParserBase::handleMasterStart
void handleMasterStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1903
libvisio::XMLErrorWatcher
Definition: libvisio_xml.h:24
libvisio::VSDXMLParserBase::handlePageEnd
void handlePageEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1867
libvisio::Colour
Definition: VSDTypes.h:73
libvisio::VSDXMLParserBase::m_currentTabSet
std::map< unsigned, VSDTabStop > * m_currentTabSet
Definition: VSDXMLParserBase.h:63
libvisio::VSDXMLParserBase::m_shape
VSDShape m_shape
Definition: VSDXMLParserBase.h:42
libvisio::VSDXMLParserBase::readPolylineData
int readPolylineData(boost::optional< PolylineData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2005
libvisio::VSDXMLParserBase::m_shapeList
VSDShapeList m_shapeList
Definition: VSDXMLParserBase.h:52
libvisio::VSDXMLParserBase::m_stencils
VSDStencils m_stencils
Definition: VSDXMLParserBase.h:40
libvisio::VSDXMLParserBase::readStringData
int readStringData(VSDName &text, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2055
libvisio::VSDXMLParserBase::handleMastersStart
void handleMastersStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1880
libvisio::VSDXMLParserBase::readBoolData
int readBoolData(boost::optional< bool > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2123
libvisio::VSDXMLParserBase::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDXMLParserBase.h:58
VSDParagraphList.h
libvisio::VSDXMLParserBase::m_colours
std::map< unsigned, Colour > m_colours
Definition: VSDXMLParserBase.h:50
VSDXMLHelper.h
libvisio::VSDXMLParserBase::readStyleSheet
void readStyleSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1549
VSDCharacterList.h
libvisio::VSDXMLParserBase::m_collector
VSDCollector * m_collector
Definition: VSDXMLParserBase.h:39
libvisio::VSDXMLParserBase::m_currentLevel
unsigned m_currentLevel
Definition: VSDXMLParserBase.h:48
libvisio::VSDXMLParserBase::readNURBSTo
void readNURBSTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:457
libvisio::VSDXMLParserBase::readLayerIX
void readLayerIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1352
libvisio::VSDXMLParserBase::readStencil
void readStencil(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1691
libvisio::VSDXMLParserBase::getBinaryData
virtual void getBinaryData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_shapeStack
std::stack< VSDShape > m_shapeStack
Definition: VSDXMLParserBase.h:54
libvisio::VSDStencils
Definition: VSDStencils.h:78
libvisio::VSDCollector
Definition: VSDCollector.h:20
libvisio::VSDXMLParserBase::readDoubleData
int readDoubleData(boost::optional< double > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2071
libvisio::VSDFieldList
Definition: VSDFieldList.h:81
libvisio::VSDXMLParserBase::m_currentStencil
VSDStencil * m_currentStencil
Definition: VSDXMLParserBase.h:41
libvisio::VSDXMLParserBase::_flushShape
void _flushShape()
Definition: VSDXMLParserBase.cpp:1744
libvisio::VSDXMLParserBase::readRelCubBezTo
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:706
libvisio::VSDXMLParserBase::readColours
void readColours(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1028
libvisio::VSDXMLParserBase::readByteData
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2145
libvisio::VSDXMLParserBase::m_currentGeometryListIndex
unsigned m_currentGeometryListIndex
Definition: VSDXMLParserBase.h:59
libvisio::VSDXMLParserBase::readArcTo
void readArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:271
libvisio::VSDXMLParserBase::handlePageStart
void handlePageStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1860
libvisio::VSDXMLParserBase::getElementDepth
virtual int getElementDepth(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_currentBinaryData
librevenge::RVNGBinaryData m_currentBinaryData
Definition: VSDXMLParserBase.h:53
VSDStencils.h
libvisio::VSDXMLParserBase::parseMain
virtual bool parseMain()=0
libvisio::VSDXMLParserBase::m_isInStyles
bool m_isInStyles
Definition: VSDXMLParserBase.h:47
libvisio::VSDXMLParserBase::m_isPageStarted
bool m_isPageStarted
Definition: VSDXMLParserBase.h:57
libvisio::VSDXMLParserBase::readRelEllipticalArcTo
void readRelEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:640
libvisio::VSDXMLParserBase::readLineTo
void readLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:221
libvisio::VSDXMLParserBase::readPageSheet
void readPageSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1565
libvisio::VSDXMLParserBase::~VSDXMLParserBase
virtual ~VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:40
libvisio::VSDXMLParserBase::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDXMLParserBase.h:49
libvisio::VSDXMLParserBase::m_shapeLevelStack
std::stack< unsigned > m_shapeLevelStack
Definition: VSDXMLParserBase.h:55
libvisio::VSDXMLParserBase::extractStencils
virtual bool extractStencils()=0
libvisio::VSDXMLParserBase::readCharIX
void readCharIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1173
VSDShapeList.h
libvisio::VSDXMLParserBase::getIX
unsigned getIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2206
libvisio::VSDXMLParserBase::readLongData
int readLongData(boost::optional< long > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2097
libvisio::VSDXMLParserBase::readExtendedColourData
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2162
libvisio::VSDXMLParserBase::readPolylineTo
void readPolylineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:528
libvisio::VSDStencil
Definition: VSDStencils.h:62
libvisio::VSDXMLParserBase::m_currentStencilID
unsigned m_currentStencilID
Definition: VSDXMLParserBase.h:44
libvisio::VSDXMLParserBase::skipPages
void skipPages(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1950
libvisio
Definition: libvisio_utils.h:73
libvisio::VSDXMLParserBase
Definition: VSDXMLParserBase.h:29
libvisio::VSDXMLParserBase::readInfiniteLine
void readInfiniteLine(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:582
libvisio::VSDXMLParserBase::readNURBSData
int readNURBSData(boost::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1964
libvisio::VSDXMLParserBase::handlePagesEnd
void handlePagesEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1853
libvisio::VSDXMLParserBase::readForeignData
void readForeignData(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1706
libvisio::VSDXMLParserBase::handleMasterEnd
void handleMasterEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1912
libvisio::VSDXMLParserBase::readShape
void readShape(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:930
libvisio::VSDXMLParserBase::readEllipticalArcTo
void readEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:325
libvisio::VSDXMLParserBase::getElementToken
virtual int getElementToken(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_fieldList
VSDFieldList m_fieldList
Definition: VSDXMLParserBase.h:51
libvisio::VSDXMLParserBase::_handleLevelChange
virtual void _handleLevelChange(unsigned level)
Definition: VSDXMLParserBase.cpp:1839
libvisio::VSDShapeList
Definition: VSDShapeList.h:19
libvisio::VSDXMLParserBase::m_extractStencils
bool m_extractStencils
Definition: VSDXMLParserBase.h:46
libvisio::VSDXMLParserBase::readRelMoveTo
void readRelMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:822
libvisio::VSDXMLParserBase::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDXMLParserBase.h:43
libvisio::VSDXMLParserBase::readEllipse
void readEllipse(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:391
libvisio::VSDXMLParserBase::readGeometry
void readGeometry(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:48
libvisio::VSDName
Definition: VSDTypes.h:179
libvisio::VSDXMLParserBase::readSplineKnot
void readSplineKnot(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1637
libvisio::VSDXMLParserBase::initColours
void initColours()
Definition: VSDXMLParserBase.cpp:999
libvisio::VSDXMLParserBase::readUnsignedData
int readUnsignedData(boost::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2136
libvisio::VSDXMLParserBase::skipMasters
void skipMasters(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1936
libvisio::VSDXMLParserBase::readParaIX
void readParaIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1403
libvisio::VSDXMLParserBase::readText
void readText(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1080
libvisio::VSDXMLParserBase::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDXMLParserBase.h:61
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:47
libvisio::VSDXMLParserBase::handlePagesStart
void handlePagesStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1845
libvisio::VSDXMLParserBase::readPage
void readPage(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1060