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
28 class VSDXMLParserBase
29 {
30 public:
31 explicit VSDXMLParserBase();
32 virtual ~VSDXMLParserBase();
33 virtual bool parseMain() = 0;
34 virtual bool extractStencils() = 0;
35
36 protected:
37 // Protected data
38 VSDCollector *m_collector;
39 VSDStencils m_stencils;
40 VSDStencil *m_currentStencil;
41 VSDShape m_shape;
42 bool m_isStencilStarted;
43 unsigned m_currentStencilID;
44
45 bool m_extractStencils;
46 bool m_isInStyles;
47 unsigned m_currentLevel;
48 unsigned m_currentShapeLevel;
49 std::map<unsigned, Colour> m_colours;
50 VSDFieldList m_fieldList;
51 VSDShapeList m_shapeList;
52 librevenge::RVNGBinaryData m_currentBinaryData;
53 std::stack<VSDShape> m_shapeStack;
54 std::stack<unsigned> m_shapeLevelStack;
55 bool m_isShapeStarted;
56 bool m_isPageStarted;
57 VSDGeometryList *m_currentGeometryList;
58 unsigned m_currentGeometryListIndex;
59
60 std::map<unsigned, VSDName> m_fonts;
61
62 // Helper functions
63
64 int readByteData(unsigned char &value, xmlTextReaderPtr reader);
65 int readByteData(boost::optional<unsigned char> &value, xmlTextReaderPtr reader);
66 int readUnsignedData(boost::optional<unsigned> &value, xmlTextReaderPtr reader);
67 int readLongData(boost::optional<long> &value, xmlTextReaderPtr reader);
68 int readLongData(long &value, xmlTextReaderPtr reader);
69 int readDoubleData(boost::optional<double> &value, xmlTextReaderPtr reader);
70 int readDoubleData(double &value, xmlTextReaderPtr reader);
71 int readBoolData(boost::optional<bool> &value, xmlTextReaderPtr reader);
72 int readBoolData(bool &value, xmlTextReaderPtr reader);
73 int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader);
74 int readExtendedColourData(Colour &value, xmlTextReaderPtr reader);
75 int readExtendedColourData(boost::optional<Colour> &value, xmlTextReaderPtr reader);
76 int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
77 int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
78
79 virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
80 unsigned getIX(xmlTextReaderPtr reader);
81 virtual void _handleLevelChange(unsigned level);
82 void _flushShape();
83
84 virtual int getElementToken(xmlTextReaderPtr reader) = 0;
85 virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
86
87 // Functions reading the DiagramML document content
88
89 void readEllipticalArcTo(xmlTextReaderPtr reader);
90 void readEllipse(xmlTextReaderPtr reader);
91 void readGeometry(xmlTextReaderPtr reader);
92 void readMoveTo(xmlTextReaderPtr reader);
93 void readLineTo(xmlTextReaderPtr reader);
94 void readArcTo(xmlTextReaderPtr reader);
95 void readNURBSTo(xmlTextReaderPtr reader);
96 void readPolylineTo(xmlTextReaderPtr reader);
97 void readInfiniteLine(xmlTextReaderPtr reader);
98 void readRelCubBezTo(xmlTextReaderPtr reader);
99 void readRelEllipticalArcTo(xmlTextReaderPtr reader);
100 void readRelLineTo(xmlTextReaderPtr reader);
101 void readRelMoveTo(xmlTextReaderPtr reader);
102 void readRelQuadBezTo(xmlTextReaderPtr reader);
103 void readForeignData(xmlTextReaderPtr reader);
104 virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
105 void readShape(xmlTextReaderPtr reader);
106 void readColours(xmlTextReaderPtr reader);
107 void readPage(xmlTextReaderPtr reader);
108 void readText(xmlTextReaderPtr reader);
109 void readCharIX(xmlTextReaderPtr reader);
110 void readParaIX(xmlTextReaderPtr reader);
111
112 void readStyleSheet(xmlTextReaderPtr reader);
113 void readPageSheet(xmlTextReaderPtr reader);
114
115 void readSplineStart(xmlTextReaderPtr reader);
116 void readSplineKnot(xmlTextReaderPtr reader);
117
118 void readStencil(xmlTextReaderPtr reader);
119
120 void handlePagesStart(xmlTextReaderPtr reader);
121 void handlePagesEnd(xmlTextReaderPtr reader);
122 void handlePageStart(xmlTextReaderPtr reader);
123 void handlePageEnd(xmlTextReaderPtr reader);
124 void handleMastersStart(xmlTextReaderPtr reader);
125 void handleMastersEnd(xmlTextReaderPtr reader);
126 void handleMasterStart(xmlTextReaderPtr reader);
127 void handleMasterEnd(xmlTextReaderPtr reader);
128 void skipPages(xmlTextReaderPtr reader);
129 void skipMasters(xmlTextReaderPtr reader);
130
131 private:
132 VSDXMLParserBase(const VSDXMLParserBase &);
133 VSDXMLParserBase &operator=(const VSDXMLParserBase &);
134
135 void initColours();
136 };
137
138 } // namespace libvisio
139
140 #endif // __VSDXMLPARSERBASE_H__
141 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDXMLParserBase::readMoveTo
void readMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:167
libvisio::VSDShape
Definition: VSDStencils.h:26
libvisio::VSDXMLParserBase::operator=
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::handleMastersEnd
void handleMastersEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1811
libvisio::VSDXMLParserBase::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDXMLParserBase.h:55
libvisio::VSDXMLParserBase::readRelLineTo
void readRelLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:778
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:24
libvisio::VSDXMLParserBase::readRelQuadBezTo
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:880
libvisio::VSDXMLParserBase::readSplineStart
void readSplineStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1489
libvisio::VSDXMLParserBase::handleMasterStart
void handleMasterStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1820
libvisio::VSDXMLParserBase::handlePageEnd
void handlePageEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1784
libvisio::Colour
Definition: VSDTypes.h:72
libvisio::VSDXMLParserBase::m_shape
VSDShape m_shape
Definition: VSDXMLParserBase.h:41
libvisio::VSDXMLParserBase::readPolylineData
int readPolylineData(boost::optional< PolylineData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1924
libvisio::VSDXMLParserBase::m_shapeList
VSDShapeList m_shapeList
Definition: VSDXMLParserBase.h:51
libvisio::VSDXMLParserBase::m_stencils
VSDStencils m_stencils
Definition: VSDXMLParserBase.h:39
libvisio::VSDXMLParserBase::handleMastersStart
void handleMastersStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1797
libvisio::VSDXMLParserBase::readStringData
virtual xmlChar * readStringData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::readBoolData
int readBoolData(boost::optional< bool > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2033
libvisio::VSDXMLParserBase::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDXMLParserBase.h:57
VSDParagraphList.h
libvisio::VSDXMLParserBase::m_colours
std::map< unsigned, Colour > m_colours
Definition: VSDXMLParserBase.h:49
VSDXMLHelper.h
libvisio::VSDXMLParserBase::readStyleSheet
void readStyleSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1459
VSDCharacterList.h
libvisio::VSDXMLParserBase::m_collector
VSDCollector * m_collector
Definition: VSDXMLParserBase.h:38
libvisio::VSDXMLParserBase::m_currentLevel
unsigned m_currentLevel
Definition: VSDXMLParserBase.h:47
libvisio::VSDXMLParserBase::readNURBSTo
void readNURBSTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:458
libvisio::VSDXMLParserBase::readStencil
void readStencil(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1611
libvisio::VSDXMLParserBase::getBinaryData
virtual void getBinaryData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_shapeStack
std::stack< VSDShape > m_shapeStack
Definition: VSDXMLParserBase.h:53
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:1977
libvisio::VSDFieldList
Definition: VSDFieldList.h:81
libvisio::VSDXMLParserBase::m_currentStencil
VSDStencil * m_currentStencil
Definition: VSDXMLParserBase.h:40
libvisio::VSDXMLParserBase::_flushShape
void _flushShape()
Definition: VSDXMLParserBase.cpp:1667
libvisio::VSDXMLParserBase::readRelCubBezTo
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:711
libvisio::VSDXMLParserBase::readColours
void readColours(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1048
libvisio::VSDXMLParserBase::readByteData
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2056
libvisio::VSDXMLParserBase::m_currentGeometryListIndex
unsigned m_currentGeometryListIndex
Definition: VSDXMLParserBase.h:58
libvisio::VSDXMLParserBase::readArcTo
void readArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:269
libvisio::VSDXMLParserBase::handlePageStart
void handlePageStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1777
libvisio::VSDXMLParserBase::getElementDepth
virtual int getElementDepth(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_currentBinaryData
librevenge::RVNGBinaryData m_currentBinaryData
Definition: VSDXMLParserBase.h:52
VSDStencils.h
libvisio::VSDXMLParserBase::parseMain
virtual bool parseMain()=0
libvisio::VSDXMLParserBase::m_isInStyles
bool m_isInStyles
Definition: VSDXMLParserBase.h:46
libvisio::VSDXMLParserBase::m_isPageStarted
bool m_isPageStarted
Definition: VSDXMLParserBase.h:56
libvisio::VSDXMLParserBase::readRelEllipticalArcTo
void readRelEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:644
libvisio::VSDXMLParserBase::readLineTo
void readLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:218
libvisio::VSDXMLParserBase::readPageSheet
void readPageSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1483
libvisio::VSDXMLParserBase::~VSDXMLParserBase
virtual ~VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:36
libvisio::VSDXMLParserBase::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDXMLParserBase.h:48
libvisio::VSDXMLParserBase::m_shapeLevelStack
std::stack< unsigned > m_shapeLevelStack
Definition: VSDXMLParserBase.h:54
libvisio::VSDXMLParserBase::extractStencils
virtual bool extractStencils()=0
libvisio::VSDXMLParserBase::readCharIX
void readCharIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1192
VSDShapeList.h
libvisio::VSDXMLParserBase::getIX
unsigned getIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2118
libvisio::VSDXMLParserBase::readLongData
int readLongData(boost::optional< long > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2005
libvisio::VSDXMLParserBase::readExtendedColourData
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2073
libvisio::VSDXMLParserBase::readPolylineTo
void readPolylineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:530
libvisio::VSDStencil
Definition: VSDStencils.h:60
libvisio::VSDXMLParserBase::m_currentStencilID
unsigned m_currentStencilID
Definition: VSDXMLParserBase.h:43
libvisio::VSDXMLParserBase::skipPages
void skipPages(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1867
libvisio
Definition: libvisio_utils.h:68
libvisio::VSDXMLParserBase
Definition: VSDXMLParserBase.h:28
libvisio::VSDXMLParserBase::readInfiniteLine
void readInfiniteLine(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:585
libvisio::VSDXMLParserBase::readNURBSData
int readNURBSData(boost::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1881
libvisio::VSDXMLParserBase::handlePagesEnd
void handlePagesEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1770
libvisio::VSDXMLParserBase::readForeignData
void readForeignData(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1627
libvisio::VSDXMLParserBase::handleMasterEnd
void handleMasterEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1829
libvisio::VSDXMLParserBase::readShape
void readShape(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:939
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:50
libvisio::VSDXMLParserBase::_handleLevelChange
virtual void _handleLevelChange(unsigned level)
Definition: VSDXMLParserBase.cpp:1756
libvisio::VSDShapeList
Definition: VSDShapeList.h:19
libvisio::VSDXMLParserBase::m_extractStencils
bool m_extractStencils
Definition: VSDXMLParserBase.h:45
libvisio::VSDXMLParserBase::readRelMoveTo
void readRelMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:829
libvisio::VSDXMLParserBase::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDXMLParserBase.h:42
libvisio::VSDXMLParserBase::readEllipse
void readEllipse(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:391
libvisio::VSDXMLParserBase::readGeometry
void readGeometry(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:44
libvisio::VSDXMLParserBase::readSplineKnot
void readSplineKnot(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1556
libvisio::VSDXMLParserBase::initColours
void initColours()
Definition: VSDXMLParserBase.cpp:1019
libvisio::VSDXMLParserBase::readUnsignedData
int readUnsignedData(boost::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2047
libvisio::VSDXMLParserBase::skipMasters
void skipMasters(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1853
libvisio::VSDXMLParserBase::readParaIX
void readParaIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1373
libvisio::VSDXMLParserBase::readText
void readText(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1108
libvisio::VSDXMLParserBase::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDXMLParserBase.h:60
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:47
libvisio::VSDXMLParserBase::handlePagesStart
void handlePagesStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1762
libvisio::VSDXMLParserBase::readPage
void readPage(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1082