VSDXMLParserBase.h Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 XMLErrorWatcher *m_watcher;
64
65 // Helper functions
66
67 int readByteData(unsigned char &value, xmlTextReaderPtr reader);
68 int readByteData(boost::optional<unsigned char> &value, xmlTextReaderPtr reader);
69 int readUnsignedData(boost::optional<unsigned> &value, xmlTextReaderPtr reader);
70 int readLongData(boost::optional<long> &value, xmlTextReaderPtr reader);
71 int readLongData(long &value, xmlTextReaderPtr reader);
72 int readDoubleData(boost::optional<double> &value, xmlTextReaderPtr reader);
73 int readDoubleData(double &value, xmlTextReaderPtr reader);
74 int readBoolData(boost::optional<bool> &value, xmlTextReaderPtr reader);
75 int readBoolData(bool &value, xmlTextReaderPtr reader);
76 int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader);
77 int readExtendedColourData(Colour &value, xmlTextReaderPtr reader);
78 int readExtendedColourData(boost::optional<Colour> &value, xmlTextReaderPtr reader);
79 int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
80 int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
81
82 virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
83 unsigned getIX(xmlTextReaderPtr reader);
84 virtual void _handleLevelChange(unsigned level);
85 void _flushShape();
86
87 virtual int getElementToken(xmlTextReaderPtr reader) = 0;
88 virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
89
90 // Functions reading the DiagramML document content
91
92 void readEllipticalArcTo(xmlTextReaderPtr reader);
93 void readEllipse(xmlTextReaderPtr reader);
94 void readGeometry(xmlTextReaderPtr reader);
95 void readMoveTo(xmlTextReaderPtr reader);
96 void readLineTo(xmlTextReaderPtr reader);
97 void readArcTo(xmlTextReaderPtr reader);
98 void readNURBSTo(xmlTextReaderPtr reader);
99 void readPolylineTo(xmlTextReaderPtr reader);
100 void readInfiniteLine(xmlTextReaderPtr reader);
101 void readRelCubBezTo(xmlTextReaderPtr reader);
102 void readRelEllipticalArcTo(xmlTextReaderPtr reader);
103 void readRelLineTo(xmlTextReaderPtr reader);
104 void readRelMoveTo(xmlTextReaderPtr reader);
105 void readRelQuadBezTo(xmlTextReaderPtr reader);
106 void readForeignData(xmlTextReaderPtr reader);
107 virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
108 void readShape(xmlTextReaderPtr reader);
109 void readColours(xmlTextReaderPtr reader);
110 void readPage(xmlTextReaderPtr reader);
111 void readText(xmlTextReaderPtr reader);
112 void readCharIX(xmlTextReaderPtr reader);
113 void readParaIX(xmlTextReaderPtr reader);
114
115 void readStyleSheet(xmlTextReaderPtr reader);
116 void readPageSheet(xmlTextReaderPtr reader);
117
118 void readSplineStart(xmlTextReaderPtr reader);
119 void readSplineKnot(xmlTextReaderPtr reader);
120
121 void readStencil(xmlTextReaderPtr reader);
122
123 void handlePagesStart(xmlTextReaderPtr reader);
124 void handlePagesEnd(xmlTextReaderPtr reader);
125 void handlePageStart(xmlTextReaderPtr reader);
126 void handlePageEnd(xmlTextReaderPtr reader);
127 void handleMastersStart(xmlTextReaderPtr reader);
128 void handleMastersEnd(xmlTextReaderPtr reader);
129 void handleMasterStart(xmlTextReaderPtr reader);
130 void handleMasterEnd(xmlTextReaderPtr reader);
131 void skipPages(xmlTextReaderPtr reader);
132 void skipMasters(xmlTextReaderPtr reader);
133
134 private:
135 VSDXMLParserBase(const VSDXMLParserBase &);
136 VSDXMLParserBase &operator=(const VSDXMLParserBase &);
137
138 void initColours();
139 };
140
141 } // namespace libvisio
142
143 #endif // __VSDXMLPARSERBASE_H__
144 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDXMLParserBase::m_watcher
XMLErrorWatcher * m_watcher
Definition: VSDXMLParserBase.h:63
libvisio::VSDXMLParserBase::readMoveTo
void readMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:170
libvisio::VSDShape
Definition: VSDStencils.h:26
libvisio::VSDXMLParserBase::operator=
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::handleMastersEnd
void handleMastersEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1763
libvisio::VSDXMLParserBase::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDXMLParserBase.h:56
libvisio::VSDXMLParserBase::readRelLineTo
void readRelLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:771
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:27
libvisio::VSDXMLParserBase::readRelQuadBezTo
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:871
libvisio::VSDXMLParserBase::readSplineStart
void readSplineStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1446
libvisio::VSDXMLParserBase::handleMasterStart
void handleMasterStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1772
libvisio::XMLErrorWatcher
Definition: libvisio_xml.h:24
libvisio::VSDXMLParserBase::handlePageEnd
void handlePageEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1736
libvisio::Colour
Definition: VSDTypes.h:72
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:1874
libvisio::VSDXMLParserBase::m_shapeList
VSDShapeList m_shapeList
Definition: VSDXMLParserBase.h:52
libvisio::VSDXMLParserBase::m_stencils
VSDStencils m_stencils
Definition: VSDXMLParserBase.h:40
libvisio::VSDXMLParserBase::handleMastersStart
void handleMastersStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1749
libvisio::VSDXMLParserBase::readStringData
virtual xmlChar * readStringData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::readBoolData
int readBoolData(boost::optional< bool > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1976
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:1424
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:456
libvisio::VSDXMLParserBase::readStencil
void readStencil(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1566
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:76
libvisio::VSDCollector
Definition: VSDCollector.h:20
libvisio::VSDXMLParserBase::readDoubleData
int readDoubleData(boost::optional< double > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1924
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:1619
libvisio::VSDXMLParserBase::readRelCubBezTo
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:705
libvisio::VSDXMLParserBase::readColours
void readColours(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1025
libvisio::VSDXMLParserBase::readByteData
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1998
libvisio::VSDXMLParserBase::m_currentGeometryListIndex
unsigned m_currentGeometryListIndex
Definition: VSDXMLParserBase.h:59
libvisio::VSDXMLParserBase::readArcTo
void readArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:270
libvisio::VSDXMLParserBase::handlePageStart
void handlePageStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1729
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:639
libvisio::VSDXMLParserBase::readLineTo
void readLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:220
libvisio::VSDXMLParserBase::readPageSheet
void readPageSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1440
libvisio::VSDXMLParserBase::~VSDXMLParserBase
virtual ~VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:39
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:1159
VSDShapeList.h
libvisio::VSDXMLParserBase::getIX
unsigned getIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2059
libvisio::VSDXMLParserBase::readLongData
int readLongData(boost::optional< long > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1950
libvisio::VSDXMLParserBase::readExtendedColourData
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2015
libvisio::VSDXMLParserBase::readPolylineTo
void readPolylineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:527
libvisio::VSDStencil
Definition: VSDStencils.h:60
libvisio::VSDXMLParserBase::m_currentStencilID
unsigned m_currentStencilID
Definition: VSDXMLParserBase.h:44
libvisio::VSDXMLParserBase::skipPages
void skipPages(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1819
libvisio
Definition: libvisio_utils.h:70
libvisio::VSDXMLParserBase
Definition: VSDXMLParserBase.h:29
libvisio::VSDXMLParserBase::readInfiniteLine
void readInfiniteLine(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:581
libvisio::VSDXMLParserBase::readNURBSData
int readNURBSData(boost::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1833
libvisio::VSDXMLParserBase::handlePagesEnd
void handlePagesEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1722
libvisio::VSDXMLParserBase::readForeignData
void readForeignData(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1581
libvisio::VSDXMLParserBase::handleMasterEnd
void handleMasterEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1781
libvisio::VSDXMLParserBase::readShape
void readShape(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:929
libvisio::VSDXMLParserBase::readEllipticalArcTo
void readEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:324
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:1708
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:821
libvisio::VSDXMLParserBase::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDXMLParserBase.h:43
libvisio::VSDXMLParserBase::readEllipse
void readEllipse(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:390
libvisio::VSDXMLParserBase::readGeometry
void readGeometry(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:47
libvisio::VSDXMLParserBase::readSplineKnot
void readSplineKnot(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1512
libvisio::VSDXMLParserBase::initColours
void initColours()
Definition: VSDXMLParserBase.cpp:996
libvisio::VSDXMLParserBase::readUnsignedData
int readUnsignedData(boost::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1989
libvisio::VSDXMLParserBase::skipMasters
void skipMasters(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1805
libvisio::VSDXMLParserBase::readParaIX
void readParaIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1338
libvisio::VSDXMLParserBase::readText
void readText(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1075
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:1714
libvisio::VSDXMLParserBase::readPage
void readPage(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1057