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 <memory>
15#include <stack>
16#include <string>
17#include <boost/optional.hpp>
18#include "VSDXMLHelper.h"
19#include "VSDCharacterList.h"
20#include "VSDParagraphList.h"
21#include "VSDShapeList.h"
22#include "VSDStencils.h"
23
24 namespace libvisio
25{
26
27 class VSDCollector;
28 class XMLErrorWatcher;
29
30 class VSDXMLParserBase
31{
32 public:
33 explicit VSDXMLParserBase();
34 virtual ~VSDXMLParserBase();
35 virtual bool parseMain() = 0;
36 virtual bool extractStencils() = 0;
37
38 protected:
39 // Protected data
40 VSDCollector *m_collector;
41 VSDStencils m_stencils;
42 std::unique_ptr<VSDStencil> m_currentStencil;
43 VSDShape m_shape;
44 bool m_isStencilStarted;
45 unsigned m_currentStencilID;
46
47 bool m_extractStencils;
48 bool m_isInStyles;
49 unsigned m_currentLevel;
50 unsigned m_currentShapeLevel;
51 std::map<unsigned, Colour> m_colours;
52 VSDFieldList m_fieldList;
53 VSDShapeList m_shapeList;
54 librevenge::RVNGBinaryData m_currentBinaryData;
55 std::stack<VSDShape> m_shapeStack;
56 std::stack<unsigned> m_shapeLevelStack;
57 bool m_isShapeStarted;
58 bool m_isPageStarted;
59 VSDGeometryList *m_currentGeometryList;
60 unsigned m_currentGeometryListIndex;
61
62 std::map<unsigned, VSDName> m_fonts;
63
64 std::map<unsigned, VSDTabStop> *m_currentTabSet;
65
66 XMLErrorWatcher *m_watcher;
67
68 // Helper functions
69
70 int readByteData(unsigned char &value, xmlTextReaderPtr reader);
71 int readByteData(boost::optional<unsigned char> &value, xmlTextReaderPtr reader);
72 int readUnsignedData(boost::optional<unsigned> &value, xmlTextReaderPtr reader);
73 int readLongData(boost::optional<long> &value, xmlTextReaderPtr reader);
74 int readLongData(long &value, xmlTextReaderPtr reader);
75 int readDoubleData(boost::optional<double> &value, xmlTextReaderPtr reader);
76 int readDoubleData(double &value, xmlTextReaderPtr reader);
77 int readBoolData(boost::optional<bool> &value, xmlTextReaderPtr reader);
78 int readBoolData(bool &value, xmlTextReaderPtr reader);
79 int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader);
80 int readExtendedColourData(Colour &value, xmlTextReaderPtr reader);
81 int readExtendedColourData(boost::optional<Colour> &value, xmlTextReaderPtr reader);
82 int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
83 int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
84 int readStringData(VSDName &text, xmlTextReaderPtr reader);
85 void readTriggerId(unsigned &id, xmlTextReaderPtr reader);
86
87 virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
88 unsigned getIX(xmlTextReaderPtr reader);
89 virtual void _handleLevelChange(unsigned level);
90 void _flushShape();
91
92 virtual int getElementToken(xmlTextReaderPtr reader) = 0;
93 virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
94
95 // Functions reading the DiagramML document content
96
97 void readEllipticalArcTo(xmlTextReaderPtr reader);
98 void readEllipse(xmlTextReaderPtr reader);
99 void readGeometry(xmlTextReaderPtr reader);
100 void readMoveTo(xmlTextReaderPtr reader);
101 void readLineTo(xmlTextReaderPtr reader);
102 void readArcTo(xmlTextReaderPtr reader);
103 void readNURBSTo(xmlTextReaderPtr reader);
104 void readPolylineTo(xmlTextReaderPtr reader);
105 void readInfiniteLine(xmlTextReaderPtr reader);
106 void readRelCubBezTo(xmlTextReaderPtr reader);
107 void readRelEllipticalArcTo(xmlTextReaderPtr reader);
108 void readRelLineTo(xmlTextReaderPtr reader);
109 void readRelMoveTo(xmlTextReaderPtr reader);
110 void readRelQuadBezTo(xmlTextReaderPtr reader);
111 void readForeignData(xmlTextReaderPtr reader);
112 virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
113 void readShape(xmlTextReaderPtr reader);
114 void readColours(xmlTextReaderPtr reader);
115 void readPage(xmlTextReaderPtr reader);
116 void readText(xmlTextReaderPtr reader);
117 void readCharIX(xmlTextReaderPtr reader);
118 void readParaIX(xmlTextReaderPtr reader);
119 void readLayerIX(xmlTextReaderPtr reader);
120 void readLayerMember(xmlTextReaderPtr reader);
121
122 void readStyleSheet(xmlTextReaderPtr reader);
123 void readPageSheet(xmlTextReaderPtr reader);
124
125 void readSplineStart(xmlTextReaderPtr reader);
126 void readSplineKnot(xmlTextReaderPtr reader);
127
128 void readStencil(xmlTextReaderPtr reader);
129
130 void handlePagesStart(xmlTextReaderPtr reader);
131 void handlePagesEnd(xmlTextReaderPtr reader);
132 void handlePageStart(xmlTextReaderPtr reader);
133 void handlePageEnd(xmlTextReaderPtr reader);
134 void handleMastersStart(xmlTextReaderPtr reader);
135 void handleMastersEnd(xmlTextReaderPtr reader);
136 void handleMasterStart(xmlTextReaderPtr reader);
137 void handleMasterEnd(xmlTextReaderPtr reader);
138 void skipPages(xmlTextReaderPtr reader);
139 void skipMasters(xmlTextReaderPtr reader);
140
141 private:
142 VSDXMLParserBase(const VSDXMLParserBase &);
143 VSDXMLParserBase &operator=(const VSDXMLParserBase &);
144
145 void initColours();
146};
147
148} // namespace libvisio
149
150#endif // __VSDXMLPARSERBASE_H__
151/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
VSDCharacterList.h
VSDParagraphList.h
VSDShapeList.h
VSDStencils.h
VSDXMLHelper.h
libvisio::VSDCollector
Definition: VSDCollector.h:21
libvisio::VSDFieldList
Definition: VSDFieldList.h:88
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:48
libvisio::VSDName
Definition: VSDTypes.h:171
libvisio::VSDShapeList
Definition: VSDShapeList.h:20
libvisio::VSDShape
Definition: VSDStencils.h:28
libvisio::VSDStencils
Definition: VSDStencils.h:79
libvisio::VSDXMLParserBase
Definition: VSDXMLParserBase.h:31
libvisio::VSDXMLParserBase::getElementDepth
virtual int getElementDepth(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::getBinaryData
virtual void getBinaryData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::handleMasterStart
void handleMasterStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1906
libvisio::VSDXMLParserBase::readNURBSData
int readNURBSData(boost::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1964
libvisio::VSDXMLParserBase::readGeometry
void readGeometry(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:48
libvisio::VSDXMLParserBase::readRelLineTo
void readRelLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:772
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::readParaIX
void readParaIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1406
libvisio::VSDXMLParserBase::handleMastersStart
void handleMastersStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1883
libvisio::VSDXMLParserBase::readStringData
int readStringData(VSDName &text, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2074
libvisio::VSDXMLParserBase::m_shapeLevelStack
std::stack< unsigned > m_shapeLevelStack
Definition: VSDXMLParserBase.h:56
libvisio::VSDXMLParserBase::readPageSheet
void readPageSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1568
libvisio::VSDXMLParserBase::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDXMLParserBase.h:44
libvisio::VSDXMLParserBase::initColours
void initColours()
Definition: VSDXMLParserBase.cpp:999
libvisio::VSDXMLParserBase::readText
void readText(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1080
libvisio::VSDXMLParserBase::m_currentGeometryListIndex
unsigned m_currentGeometryListIndex
Definition: VSDXMLParserBase.h:60
libvisio::VSDXMLParserBase::readLayerMember
void readLayerMember(xmlTextReaderPtr reader)
libvisio::VSDXMLParserBase::readNURBSTo
void readNURBSTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:457
libvisio::VSDXMLParserBase::m_currentStencil
std::unique_ptr< VSDStencil > m_currentStencil
Definition: VSDXMLParserBase.h:42
libvisio::VSDXMLParserBase::m_shapeList
VSDShapeList m_shapeList
Definition: VSDXMLParserBase.h:53
libvisio::VSDXMLParserBase::handleMasterEnd
void handleMasterEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1915
libvisio::VSDXMLParserBase::readStencil
void readStencil(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1694
libvisio::VSDXMLParserBase::readStyleSheet
void readStyleSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1552
libvisio::VSDXMLParserBase::readArcTo
void readArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:271
libvisio::VSDXMLParserBase::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDXMLParserBase.h:62
libvisio::VSDXMLParserBase::parseMain
virtual bool parseMain()=0
libvisio::VSDXMLParserBase::readEllipse
void readEllipse(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:391
libvisio::VSDXMLParserBase::readTriggerId
void readTriggerId(unsigned &id, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2239
libvisio::VSDXMLParserBase::m_stencils
VSDStencils m_stencils
Definition: VSDXMLParserBase.h:41
libvisio::VSDXMLParserBase::operator=
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::readColours
void readColours(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1028
libvisio::VSDXMLParserBase::handleMastersEnd
void handleMastersEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1897
libvisio::VSDXMLParserBase::readRelCubBezTo
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:706
libvisio::VSDXMLParserBase::readPolylineTo
void readPolylineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:528
libvisio::VSDXMLParserBase::readByteData
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2164
libvisio::VSDXMLParserBase::readUnsignedData
int readUnsignedData(boost::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2155
libvisio::VSDXMLParserBase::~VSDXMLParserBase
virtual ~VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:42
libvisio::VSDXMLParserBase::m_currentLevel
unsigned m_currentLevel
Definition: VSDXMLParserBase.h:49
libvisio::VSDXMLParserBase::m_currentBinaryData
librevenge::RVNGBinaryData m_currentBinaryData
Definition: VSDXMLParserBase.h:54
libvisio::VSDXMLParserBase::m_extractStencils
bool m_extractStencils
Definition: VSDXMLParserBase.h:47
libvisio::VSDXMLParserBase::readSplineKnot
void readSplineKnot(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1640
libvisio::VSDXMLParserBase::getElementToken
virtual int getElementToken(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::extractStencils
virtual bool extractStencils()=0
libvisio::VSDXMLParserBase::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDXMLParserBase.h:50
libvisio::VSDXMLParserBase::_handleLevelChange
virtual void _handleLevelChange(unsigned level)
Definition: VSDXMLParserBase.cpp:1842
libvisio::VSDXMLParserBase::readDoubleData
int readDoubleData(boost::optional< double > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2090
libvisio::VSDXMLParserBase::handlePagesStart
void handlePagesStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1848
libvisio::VSDXMLParserBase::m_collector
VSDCollector * m_collector
Definition: VSDXMLParserBase.h:40
libvisio::VSDXMLParserBase::readRelMoveTo
void readRelMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:822
libvisio::VSDXMLParserBase::m_currentTabSet
std::map< unsigned, VSDTabStop > * m_currentTabSet
Definition: VSDXMLParserBase.h:64
libvisio::VSDXMLParserBase::handlePageStart
void handlePageStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1863
libvisio::VSDXMLParserBase::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDXMLParserBase.h:57
libvisio::VSDXMLParserBase::readBoolData
int readBoolData(boost::optional< bool > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2142
libvisio::VSDXMLParserBase::readForeignData
void readForeignData(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1707
libvisio::VSDXMLParserBase::m_isInStyles
bool m_isInStyles
Definition: VSDXMLParserBase.h:48
libvisio::VSDXMLParserBase::m_currentStencilID
unsigned m_currentStencilID
Definition: VSDXMLParserBase.h:45
libvisio::VSDXMLParserBase::readStringData
virtual xmlChar * readStringData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::skipMasters
void skipMasters(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1936
libvisio::VSDXMLParserBase::readLineTo
void readLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:221
libvisio::VSDXMLParserBase::m_shape
VSDShape m_shape
Definition: VSDXMLParserBase.h:43
libvisio::VSDXMLParserBase::readCharIX
void readCharIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1173
libvisio::VSDXMLParserBase::readRelEllipticalArcTo
void readRelEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:640
libvisio::VSDXMLParserBase::readPolylineData
int readPolylineData(boost::optional< PolylineData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2017
libvisio::VSDXMLParserBase::handlePagesEnd
void handlePagesEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1856
libvisio::VSDXMLParserBase::readShape
void readShape(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:930
libvisio::VSDXMLParserBase::readMoveTo
void readMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:171
libvisio::VSDXMLParserBase::getIX
unsigned getIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2230
libvisio::VSDXMLParserBase::m_isPageStarted
bool m_isPageStarted
Definition: VSDXMLParserBase.h:58
libvisio::VSDXMLParserBase::handlePageEnd
void handlePageEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1870
libvisio::VSDXMLParserBase::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDXMLParserBase.h:59
libvisio::VSDXMLParserBase::readRelQuadBezTo
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:872
libvisio::VSDXMLParserBase::_flushShape
void _flushShape()
Definition: VSDXMLParserBase.cpp:1745
libvisio::VSDXMLParserBase::skipPages
void skipPages(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1950
libvisio::VSDXMLParserBase::readExtendedColourData
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2181
libvisio::VSDXMLParserBase::readSplineStart
void readSplineStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1574
libvisio::VSDXMLParserBase::readEllipticalArcTo
void readEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:325
libvisio::VSDXMLParserBase::readLayerIX
void readLayerIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1355
libvisio::VSDXMLParserBase::m_fieldList
VSDFieldList m_fieldList
Definition: VSDXMLParserBase.h:52
libvisio::VSDXMLParserBase::readInfiniteLine
void readInfiniteLine(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:582
libvisio::VSDXMLParserBase::m_watcher
XMLErrorWatcher * m_watcher
Definition: VSDXMLParserBase.h:66
libvisio::VSDXMLParserBase::m_colours
std::map< unsigned, Colour > m_colours
Definition: VSDXMLParserBase.h:51
libvisio::VSDXMLParserBase::readLongData
int readLongData(boost::optional< long > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2116
libvisio::VSDXMLParserBase::readPage
void readPage(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1060
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:29
libvisio::VSDXMLParserBase::m_shapeStack
std::stack< VSDShape > m_shapeStack
Definition: VSDXMLParserBase.h:55
libvisio::XMLErrorWatcher
Definition: libvisio_xml.h:25
libvisio
Definition: libvisio_utils.h:49
libvisio::Colour
Definition: VSDTypes.h:71