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