- 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 /* libvisio
3 * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * Major Contributor(s):
16 * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17 *
18 *
19 * All Rights Reserved.
20 *
21 * For minor contributions see the git repository.
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27 * instead of those above.
28 */
29
30 #ifndef __VSDXMLPARSERBASE_H__
31 #define __VSDXMLPARSERBASE_H__
32
33 #include <map>
34 #include <stack>
35 #include <string>
36 #include <boost/optional.hpp>
37 #include "VSDXMLHelper.h"
38 #include "VSDCharacterList.h"
39 #include "VSDParagraphList.h"
40 #include "VSDShapeList.h"
41 #include "VSDStencils.h"
42
43 namespace libvisio
44 {
45
46 class VSDCollector;
47
48 class VSDXMLParserBase
49 {
50 public:
51 explicit VSDXMLParserBase();
52 virtual ~VSDXMLParserBase();
53 virtual bool parseMain() = 0;
54 virtual bool extractStencils() = 0;
55
56 protected:
57 // Protected data
58 VSDCollector *m_collector;
59 VSDStencils m_stencils;
60 VSDStencil *m_currentStencil;
61 VSDShape m_shape;
62 bool m_isStencilStarted;
63 unsigned m_currentStencilID;
64
65 bool m_extractStencils;
66 bool m_isInStyles;
67 unsigned m_currentLevel;
68 unsigned m_currentShapeLevel;
69 std::map<unsigned, Colour> m_colours;
70 VSDFieldList m_fieldList;
71 VSDShapeList m_shapeList;
72 WPXBinaryData m_currentBinaryData;
73 std::stack<VSDShape> m_shapeStack;
74 std::stack<unsigned> m_shapeLevelStack;
75 bool m_isShapeStarted;
76 bool m_isPageStarted;
77 VSDGeometryList *m_currentGeometryList;
78 unsigned m_currentGeometryListIndex;
79
80 std::map<unsigned, VSDName> m_fonts;
81
82 // Helper functions
83
84 int readByteData(unsigned char &value, xmlTextReaderPtr reader);
85 int readByteData(boost::optional<unsigned char> &value, xmlTextReaderPtr reader);
86 int readUnsignedData(boost::optional<unsigned> &value, xmlTextReaderPtr reader);
87 int readLongData(boost::optional<long> &value, xmlTextReaderPtr reader);
88 int readLongData(long &value, xmlTextReaderPtr reader);
89 int readDoubleData(boost::optional<double> &value, xmlTextReaderPtr reader);
90 int readDoubleData(double &value, xmlTextReaderPtr reader);
91 int readBoolData(boost::optional<bool> &value, xmlTextReaderPtr reader);
92 int readBoolData(bool &value, xmlTextReaderPtr reader);
93 int readColourData(Colour &value, xmlTextReaderPtr reader);
94 int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader);
95 int readExtendedColourData(Colour &value, xmlTextReaderPtr reader);
96 int readExtendedColourData(boost::optional<Colour> &value, xmlTextReaderPtr reader);
97 int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
98 int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
99
100 virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
101 unsigned getIX(xmlTextReaderPtr reader);
102 virtual void _handleLevelChange(unsigned level);
103 void _flushShape();
104
105 virtual int getElementToken(xmlTextReaderPtr reader) = 0;
106 virtual int getElementDepth(xmlTextReaderPtr reader) = 0;
107
108 // Functions reading the DiagramML document content
109
110 void readEllipticalArcTo(xmlTextReaderPtr reader);
111 void readEllipse(xmlTextReaderPtr reader);
112 void readGeometry(xmlTextReaderPtr reader);
113 void readMoveTo(xmlTextReaderPtr reader);
114 void readLineTo(xmlTextReaderPtr reader);
115 void readArcTo(xmlTextReaderPtr reader);
116 void readNURBSTo(xmlTextReaderPtr reader);
117 void readPolylineTo(xmlTextReaderPtr reader);
118 void readInfiniteLine(xmlTextReaderPtr reader);
119 void readRelCubBezTo(xmlTextReaderPtr reader);
120 void readRelEllipticalArcTo(xmlTextReaderPtr reader);
121 void readRelLineTo(xmlTextReaderPtr reader);
122 void readRelMoveTo(xmlTextReaderPtr reader);
123 void readRelQuadBezTo(xmlTextReaderPtr reader);
124 void readForeignData(xmlTextReaderPtr reader);
125 virtual void getBinaryData(xmlTextReaderPtr reader) = 0;
126 void readShape(xmlTextReaderPtr reader);
127 void readColours(xmlTextReaderPtr reader);
128 void readPage(xmlTextReaderPtr reader);
129 void readText(xmlTextReaderPtr reader);
130 void readCharIX(xmlTextReaderPtr reader);
131 void readParaIX(xmlTextReaderPtr reader);
132
133 void readStyleSheet(xmlTextReaderPtr reader);
134 void readPageSheet(xmlTextReaderPtr reader);
135
136 void readSplineStart(xmlTextReaderPtr reader);
137 void readSplineKnot(xmlTextReaderPtr reader);
138
139 void readStencil(xmlTextReaderPtr reader);
140
141 void handlePagesStart(xmlTextReaderPtr reader);
142 void handlePagesEnd(xmlTextReaderPtr reader);
143 void handlePageStart(xmlTextReaderPtr reader);
144 void handlePageEnd(xmlTextReaderPtr reader);
145 void handleMastersStart(xmlTextReaderPtr reader);
146 void handleMastersEnd(xmlTextReaderPtr reader);
147 void handleMasterStart(xmlTextReaderPtr reader);
148 void handleMasterEnd(xmlTextReaderPtr reader);
149 void skipPages(xmlTextReaderPtr reader);
150 void skipMasters(xmlTextReaderPtr reader);
151
152 private:
153 VSDXMLParserBase(const VSDXMLParserBase &);
154 VSDXMLParserBase &operator=(const VSDXMLParserBase &);
155
156 void initColours();
157 };
158
159 } // namespace libvisio
160
161 #endif // __VSDXMLPARSERBASE_H__
162 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDXMLParserBase::readMoveTo
void readMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:188
libvisio::VSDShape
Definition: VSDStencils.h:47
libvisio::VSDXMLParserBase::operator=
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
libvisio::VSDXMLParserBase::handleMastersEnd
void handleMastersEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1832
libvisio::VSDXMLParserBase::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDXMLParserBase.h:75
libvisio::VSDXMLParserBase::readRelLineTo
void readRelLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:799
libvisio::VSDXMLParserBase::VSDXMLParserBase
VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:45
libvisio::VSDXMLParserBase::readRelQuadBezTo
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:901
libvisio::VSDXMLParserBase::readSplineStart
void readSplineStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1510
libvisio::VSDXMLParserBase::handleMasterStart
void handleMasterStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1841
libvisio::VSDXMLParserBase::handlePageEnd
void handlePageEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1805
libvisio::Colour
Definition: VSDTypes.h:78
libvisio::VSDXMLParserBase::m_shape
VSDShape m_shape
Definition: VSDXMLParserBase.h:61
libvisio::VSDXMLParserBase::readPolylineData
int readPolylineData(boost::optional< PolylineData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1945
libvisio::VSDXMLParserBase::m_shapeList
VSDShapeList m_shapeList
Definition: VSDXMLParserBase.h:71
libvisio::VSDXMLParserBase::m_stencils
VSDStencils m_stencils
Definition: VSDXMLParserBase.h:59
libvisio::VSDXMLParserBase::handleMastersStart
void handleMastersStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1818
libvisio::VSDXMLParserBase::readStringData
virtual xmlChar * readStringData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::readBoolData
int readBoolData(boost::optional< bool > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2054
libvisio::VSDXMLParserBase::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDXMLParserBase.h:77
VSDParagraphList.h
libvisio::VSDXMLParserBase::m_colours
std::map< unsigned, Colour > m_colours
Definition: VSDXMLParserBase.h:69
VSDXMLHelper.h
libvisio::VSDXMLParserBase::readStyleSheet
void readStyleSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1480
VSDCharacterList.h
libvisio::VSDXMLParserBase::m_collector
VSDCollector * m_collector
Definition: VSDXMLParserBase.h:58
libvisio::VSDXMLParserBase::m_currentLevel
unsigned m_currentLevel
Definition: VSDXMLParserBase.h:67
libvisio::VSDXMLParserBase::readNURBSTo
void readNURBSTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:479
libvisio::VSDXMLParserBase::readStencil
void readStencil(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1632
libvisio::VSDXMLParserBase::getBinaryData
virtual void getBinaryData(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_shapeStack
std::stack< VSDShape > m_shapeStack
Definition: VSDXMLParserBase.h:73
libvisio::VSDStencils
Definition: VSDStencils.h:95
libvisio::VSDCollector
Definition: VSDCollector.h:41
libvisio::VSDXMLParserBase::readDoubleData
int readDoubleData(boost::optional< double > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1998
libvisio::VSDFieldList
Definition: VSDFieldList.h:102
libvisio::VSDXMLParserBase::m_currentStencil
VSDStencil * m_currentStencil
Definition: VSDXMLParserBase.h:60
libvisio::VSDXMLParserBase::_flushShape
void _flushShape()
Definition: VSDXMLParserBase.cpp:1688
libvisio::VSDXMLParserBase::readRelCubBezTo
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:732
libvisio::VSDXMLParserBase::readColours
void readColours(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1069
libvisio::VSDXMLParserBase::readByteData
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2077
libvisio::VSDXMLParserBase::m_currentGeometryListIndex
unsigned m_currentGeometryListIndex
Definition: VSDXMLParserBase.h:78
libvisio::VSDXMLParserBase::readArcTo
void readArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:290
libvisio::VSDXMLParserBase::handlePageStart
void handlePageStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1798
libvisio::VSDXMLParserBase::getElementDepth
virtual int getElementDepth(xmlTextReaderPtr reader)=0
VSDStencils.h
libvisio::VSDXMLParserBase::parseMain
virtual bool parseMain()=0
libvisio::VSDXMLParserBase::m_isInStyles
bool m_isInStyles
Definition: VSDXMLParserBase.h:66
libvisio::VSDXMLParserBase::m_isPageStarted
bool m_isPageStarted
Definition: VSDXMLParserBase.h:76
libvisio::VSDXMLParserBase::readRelEllipticalArcTo
void readRelEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:665
libvisio::VSDXMLParserBase::readLineTo
void readLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:239
libvisio::VSDXMLParserBase::readPageSheet
void readPageSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1504
libvisio::VSDXMLParserBase::~VSDXMLParserBase
virtual ~VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:57
libvisio::VSDXMLParserBase::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDXMLParserBase.h:68
libvisio::VSDXMLParserBase::m_shapeLevelStack
std::stack< unsigned > m_shapeLevelStack
Definition: VSDXMLParserBase.h:74
libvisio::VSDXMLParserBase::extractStencils
virtual bool extractStencils()=0
libvisio::VSDXMLParserBase::readCharIX
void readCharIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1213
VSDShapeList.h
libvisio::VSDXMLParserBase::getIX
unsigned getIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2164
libvisio::VSDXMLParserBase::readLongData
int readLongData(boost::optional< long > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2026
libvisio::VSDXMLParserBase::readExtendedColourData
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2119
libvisio::VSDXMLParserBase::readPolylineTo
void readPolylineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:551
libvisio::VSDStencil
Definition: VSDStencils.h:79
libvisio::VSDXMLParserBase::m_currentStencilID
unsigned m_currentStencilID
Definition: VSDXMLParserBase.h:63
libvisio::VSDXMLParserBase::skipPages
void skipPages(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1888
libvisio::VSDXMLParserBase
Definition: VSDXMLParserBase.h:48
libvisio::VSDXMLParserBase::readInfiniteLine
void readInfiniteLine(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:606
libvisio::VSDXMLParserBase::readNURBSData
int readNURBSData(boost::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1902
libvisio::VSDXMLParserBase::handlePagesEnd
void handlePagesEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1791
libvisio::VSDXMLParserBase::readForeignData
void readForeignData(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1648
libvisio::VSDXMLParserBase::handleMasterEnd
void handleMasterEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1850
libvisio::VSDXMLParserBase::readShape
void readShape(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:960
libvisio::VSDXMLParserBase::readEllipticalArcTo
void readEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:345
libvisio::VSDXMLParserBase::getElementToken
virtual int getElementToken(xmlTextReaderPtr reader)=0
libvisio::VSDXMLParserBase::m_fieldList
VSDFieldList m_fieldList
Definition: VSDXMLParserBase.h:70
libvisio::VSDXMLParserBase::m_currentBinaryData
WPXBinaryData m_currentBinaryData
Definition: VSDXMLParserBase.h:72
libvisio::VSDXMLParserBase::_handleLevelChange
virtual void _handleLevelChange(unsigned level)
Definition: VSDXMLParserBase.cpp:1777
libvisio::VSDShapeList
Definition: VSDShapeList.h:40
libvisio::VSDXMLParserBase::m_extractStencils
bool m_extractStencils
Definition: VSDXMLParserBase.h:65
libvisio::VSDXMLParserBase::readRelMoveTo
void readRelMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:850
libvisio::VSDXMLParserBase::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDXMLParserBase.h:62
libvisio::VSDXMLParserBase::readEllipse
void readEllipse(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:412
libvisio::VSDXMLParserBase::readGeometry
void readGeometry(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:65
libvisio::VSDXMLParserBase::readSplineKnot
void readSplineKnot(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1577
libvisio::VSDXMLParserBase::initColours
void initColours()
Definition: VSDXMLParserBase.cpp:1040
libvisio::VSDXMLParserBase::readUnsignedData
int readUnsignedData(boost::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2068
libvisio::VSDXMLParserBase::skipMasters
void skipMasters(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1874
libvisio::VSDXMLParserBase::readParaIX
void readParaIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1394
libvisio::VSDXMLParserBase::readText
void readText(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1129
libvisio::VSDXMLParserBase::readColourData
int readColourData(Colour &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2094
libvisio::VSDXMLParserBase::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDXMLParserBase.h:80
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:68
libvisio::VSDXMLParserBase::handlePagesStart
void handlePagesStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1783
libvisio::VSDXMLParserBase::readPage
void readPage(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1103