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 <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
24namespace libvisio
25{
26
27class VSDCollector;
28class XMLErrorWatcher;
29
30 class VSDXMLParserBase
31{
32public:
33 explicit VSDXMLParserBase();
34 virtual ~VSDXMLParserBase();
35 virtual bool parseMain() = 0;
36 virtual bool extractStencils() = 0;
37
38protected:
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 bool readColourOrColourIndex(Colour &value, long &idx, xmlTextReaderPtr reader);
83 int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
84 int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
85 int readStringData(VSDName &text, xmlTextReaderPtr reader);
86 void readTriggerId(unsigned &id, xmlTextReaderPtr reader);
87
88 virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
89 unsigned getIX(xmlTextReaderPtr reader);
90 virtual void _handleLevelChange(unsigned level);
91 void _flushShape();
92
93 virtual int getElementToken(xmlTextReaderPtr reader) = 0;
94 virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
95
96 // Functions reading the DiagramML document content
97
98 void readEllipticalArcTo(xmlTextReaderPtr reader);
99 void readEllipse(xmlTextReaderPtr reader);
100 void readGeometry(xmlTextReaderPtr reader);
101 void readMoveTo(xmlTextReaderPtr reader);
102 void readLineTo(xmlTextReaderPtr reader);
103 void readArcTo(xmlTextReaderPtr reader);
104 void readNURBSTo(xmlTextReaderPtr reader);
105 void readPolylineTo(xmlTextReaderPtr reader);
106 void readInfiniteLine(xmlTextReaderPtr reader);
107 void readRelCubBezTo(xmlTextReaderPtr reader);
108 void readRelEllipticalArcTo(xmlTextReaderPtr reader);
109 void readRelLineTo(xmlTextReaderPtr reader);
110 void readRelMoveTo(xmlTextReaderPtr reader);
111 void readRelQuadBezTo(xmlTextReaderPtr reader);
112 void readForeignData(xmlTextReaderPtr reader);
113 virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
114 void readShape(xmlTextReaderPtr reader);
115 void readColours(xmlTextReaderPtr reader);
116 void readPage(xmlTextReaderPtr reader);
117 void readText(xmlTextReaderPtr reader);
118 void readCharIX(xmlTextReaderPtr reader);
119 void readParaIX(xmlTextReaderPtr reader);
120 void readLayerIX(xmlTextReaderPtr reader);
121 void readLayerMember(xmlTextReaderPtr reader);
122
123 void readStyleSheet(xmlTextReaderPtr reader);
124 void readPageSheet(xmlTextReaderPtr reader);
125
126 void readSplineStart(xmlTextReaderPtr reader);
127 void readSplineKnot(xmlTextReaderPtr reader);
128
129 void readStencil(xmlTextReaderPtr reader);
130
131 void handlePagesStart(xmlTextReaderPtr reader);
132 void handlePagesEnd(xmlTextReaderPtr reader);
133 void handlePageStart(xmlTextReaderPtr reader);
134 void handlePageEnd(xmlTextReaderPtr reader);
135 void handleMastersStart(xmlTextReaderPtr reader);
136 void handleMastersEnd(xmlTextReaderPtr reader);
137 void handleMasterStart(xmlTextReaderPtr reader);
138 void handleMasterEnd(xmlTextReaderPtr reader);
139 void skipPages(xmlTextReaderPtr reader);
140 void skipMasters(xmlTextReaderPtr reader);
141
142private:
143 VSDXMLParserBase(const VSDXMLParserBase &);
144 VSDXMLParserBase &operator=(const VSDXMLParserBase &);
145
146 void initColours();
147};
148
149} // namespace libvisio
150
151#endif // __VSDXMLPARSERBASE_H__
152/* 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::readColourOrColourIndex
bool readColourOrColourIndex(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition VSDXMLParserBase.cpp:2227
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:2264
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:2255
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