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 
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
64 
67  unsigned m_currentLevel;
69  std::map<unsigned, Colour> m_colours;
72  WPXBinaryData m_currentBinaryData;
73  std::stack<VSDShape> m_shapeStack;
74  std::stack<unsigned> m_shapeLevelStack;
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:
155 
156  void initColours();
157 };
158 
159 } // namespace libvisio
160 
161 #endif // __VSDXMLPARSERBASE_H__
162 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
void readMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:188
Definition: VSDStencils.h:47
VSDXMLParserBase & operator=(const VSDXMLParserBase &)
void handleMastersEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1832
bool m_isShapeStarted
Definition: VSDXMLParserBase.h:75
void readRelLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:799
VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:45
void readRelQuadBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:901
void readSplineStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1510
void handleMasterStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1841
void handlePageEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1805
Definition: VSDTypes.h:78
VSDShape m_shape
Definition: VSDXMLParserBase.h:61
int readPolylineData(boost::optional< PolylineData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1945
VSDShapeList m_shapeList
Definition: VSDXMLParserBase.h:71
VSDStencils m_stencils
Definition: VSDXMLParserBase.h:59
void handleMastersStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1818
virtual xmlChar * readStringData(xmlTextReaderPtr reader)=0
int readBoolData(boost::optional< bool > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2054
VSDGeometryList * m_currentGeometryList
Definition: VSDXMLParserBase.h:77
std::map< unsigned, Colour > m_colours
Definition: VSDXMLParserBase.h:69
void readStyleSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1480
VSDCollector * m_collector
Definition: VSDXMLParserBase.h:58
unsigned m_currentLevel
Definition: VSDXMLParserBase.h:67
void readNURBSTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:479
void readStencil(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1632
virtual void getBinaryData(xmlTextReaderPtr reader)=0
std::stack< VSDShape > m_shapeStack
Definition: VSDXMLParserBase.h:73
Definition: VSDStencils.h:95
Definition: VSDCollector.h:41
int readDoubleData(boost::optional< double > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1998
Definition: VSDFieldList.h:102
VSDStencil * m_currentStencil
Definition: VSDXMLParserBase.h:60
void _flushShape()
Definition: VSDXMLParserBase.cpp:1688
void readRelCubBezTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:732
void readColours(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1069
int readByteData(unsigned char &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2077
unsigned m_currentGeometryListIndex
Definition: VSDXMLParserBase.h:78
void readArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:290
void handlePageStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1798
virtual int getElementDepth(xmlTextReaderPtr reader)=0
virtual bool parseMain()=0
bool m_isInStyles
Definition: VSDXMLParserBase.h:66
bool m_isPageStarted
Definition: VSDXMLParserBase.h:76
void readRelEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:665
void readLineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:239
void readPageSheet(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1504
virtual ~VSDXMLParserBase()
Definition: VSDXMLParserBase.cpp:57
unsigned m_currentShapeLevel
Definition: VSDXMLParserBase.h:68
std::stack< unsigned > m_shapeLevelStack
Definition: VSDXMLParserBase.h:74
virtual bool extractStencils()=0
void readCharIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1213
unsigned getIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2164
int readLongData(boost::optional< long > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2026
int readExtendedColourData(Colour &value, long &idx, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2119
void readPolylineTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:551
Definition: VSDStencils.h:79
unsigned m_currentStencilID
Definition: VSDXMLParserBase.h:63
void skipPages(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1888
Definition: VSDXMLParserBase.h:48
void readInfiniteLine(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:606
int readNURBSData(boost::optional< NURBSData > &data, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1902
void handlePagesEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1791
void readForeignData(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1648
void handleMasterEnd(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1850
void readShape(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:960
void readEllipticalArcTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:345
virtual int getElementToken(xmlTextReaderPtr reader)=0
VSDFieldList m_fieldList
Definition: VSDXMLParserBase.h:70
WPXBinaryData m_currentBinaryData
Definition: VSDXMLParserBase.h:72
virtual void _handleLevelChange(unsigned level)
Definition: VSDXMLParserBase.cpp:1777
Definition: VSDShapeList.h:40
bool m_extractStencils
Definition: VSDXMLParserBase.h:65
void readRelMoveTo(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:850
bool m_isStencilStarted
Definition: VSDXMLParserBase.h:62
void readEllipse(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:412
void readGeometry(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:65
void readSplineKnot(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1577
void initColours()
Definition: VSDXMLParserBase.cpp:1040
int readUnsignedData(boost::optional< unsigned > &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2068
void skipMasters(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1874
void readParaIX(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1394
void readText(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1129
int readColourData(Colour &value, xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:2094
std::map< unsigned, VSDName > m_fonts
Definition: VSDXMLParserBase.h:80
Definition: VSDGeometryList.h:68
void handlePagesStart(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1783
void readPage(xmlTextReaderPtr reader)
Definition: VSDXMLParserBase.cpp:1103

Generated for libvisio by doxygen 1.8.5