VSDParser.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 __VSDPARSER_H__
11 #define __VSDPARSER_H__
12
13 #include <stdio.h>
14 #include <iostream>
15 #include <vector>
16 #include <stack>
17 #include <map>
18 #include <librevenge/librevenge.h>
19 #include "VSDTypes.h"
20 #include "VSDGeometryList.h"
21 #include "VSDFieldList.h"
22 #include "VSDCharacterList.h"
23 #include "VSDParagraphList.h"
24 #include "VSDShapeList.h"
25 #include "VSDLayerList.h"
26 #include "VSDStencils.h"
27
28 namespace libvisio
29 {
30
31 class VSDCollector;
32
33 struct Pointer
34 {
35 Pointer()
36 : Type(0), Offset(0), Length(0), Format(0), ListSize(0) {}
37 Pointer(const Pointer &ptr)
38 : Type(ptr.Type), Offset(ptr.Offset), Length(ptr.Length), Format(ptr.Format), ListSize(ptr.ListSize) {}
39 unsigned Type;
40 unsigned Offset;
41 unsigned Length;
42 unsigned short Format;
43 unsigned ListSize;
44 };
45
46 class VSDParser
47 {
48 public:
49 explicit VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container = 0);
50 virtual ~VSDParser();
51 bool parseMain();
52 bool extractStencils();
53
54 protected:
55 // reader functions
56 void readEllipticalArcTo(librevenge::RVNGInputStream *input);
57 void readForeignData(librevenge::RVNGInputStream *input);
58 void readEllipse(librevenge::RVNGInputStream *input);
59 virtual void readLine(librevenge::RVNGInputStream *input);
60 virtual void readFillAndShadow(librevenge::RVNGInputStream *input);
61 virtual void readGeomList(librevenge::RVNGInputStream *input);
62 void readGeometry(librevenge::RVNGInputStream *input);
63 void readMoveTo(librevenge::RVNGInputStream *input);
64 void readLineTo(librevenge::RVNGInputStream *input);
65 void readArcTo(librevenge::RVNGInputStream *input);
66 void readNURBSTo(librevenge::RVNGInputStream *input);
67 void readPolylineTo(librevenge::RVNGInputStream *input);
68 void readInfiniteLine(librevenge::RVNGInputStream *input);
69 void readShapeData(librevenge::RVNGInputStream *input);
70 void readXFormData(librevenge::RVNGInputStream *input);
71 void readXForm1D(librevenge::RVNGInputStream *input);
72 void readTxtXForm(librevenge::RVNGInputStream *input);
73 void readShapeId(librevenge::RVNGInputStream *input);
74 virtual void readShapeList(librevenge::RVNGInputStream *input);
75 void readForeignDataType(librevenge::RVNGInputStream *input);
76 void readPageProps(librevenge::RVNGInputStream *input);
77 virtual void readShape(librevenge::RVNGInputStream *input);
78 void readColours(librevenge::RVNGInputStream *input);
79 void readFont(librevenge::RVNGInputStream *input);
80 void readFontIX(librevenge::RVNGInputStream *input);
81 virtual void readCharList(librevenge::RVNGInputStream *input);
82 virtual void readParaList(librevenge::RVNGInputStream *input);
83 virtual void readPropList(librevenge::RVNGInputStream *input);
84 virtual void readPage(librevenge::RVNGInputStream *input);
85 virtual void readText(librevenge::RVNGInputStream *input);
86 virtual void readCharIX(librevenge::RVNGInputStream *input);
87 virtual void readParaIX(librevenge::RVNGInputStream *input);
88 virtual void readTextBlock(librevenge::RVNGInputStream *input);
89 virtual void readTabsDataList(librevenge::RVNGInputStream *input);
90 virtual void readTabsData(librevenge::RVNGInputStream *input);
91
92 void readNameList(librevenge::RVNGInputStream *input);
93 virtual void readName(librevenge::RVNGInputStream *input);
94
95 virtual void readNameList2(librevenge::RVNGInputStream *input);
96 virtual void readName2(librevenge::RVNGInputStream *input);
97
98 virtual void readFieldList(librevenge::RVNGInputStream *input);
99 virtual void readTextField(librevenge::RVNGInputStream *input);
100
101 virtual void readStyleSheet(librevenge::RVNGInputStream *input);
102 void readPageSheet(librevenge::RVNGInputStream *input);
103
104 void readSplineStart(librevenge::RVNGInputStream *input);
105 void readSplineKnot(librevenge::RVNGInputStream *input);
106
107 void readStencilShape(librevenge::RVNGInputStream *input);
108
109 void readOLEList(librevenge::RVNGInputStream *input);
110 void readOLEData(librevenge::RVNGInputStream *input);
111
112 virtual void readNameIDX(librevenge::RVNGInputStream *input);
113 virtual void readNameIDX123(librevenge::RVNGInputStream *input);
114
115 void readMisc(librevenge::RVNGInputStream *input);
116
117 virtual void readLayerList(librevenge::RVNGInputStream *input);
118 virtual void readLayer(librevenge::RVNGInputStream *input);
119 virtual void readLayerMem(librevenge::RVNGInputStream *input);
120
121 // parser of one pass
122 bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift);
123
124 void parseMetaData();
125
126 // Stream handlers
127 void handleStreams(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned level);
128 void handleStream(const Pointer &ptr, unsigned idx, unsigned level);
129 void handleChunks(librevenge::RVNGInputStream *input, unsigned level);
130 void handleChunk(librevenge::RVNGInputStream *input);
131 void handleBlob(librevenge::RVNGInputStream *input, unsigned shift, unsigned level);
132
133 virtual void readPointer(librevenge::RVNGInputStream *input, Pointer &ptr);
134 virtual void readPointerInfo(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount);
135 virtual bool getChunkHeader(librevenge::RVNGInputStream *input);
136 void _handleLevelChange(unsigned level);
137 Colour _colourFromIndex(unsigned idx);
138 void _flushShape();
139 void _nameFromId(VSDName &name, unsigned id, unsigned level);
140
141 virtual unsigned getUInt(librevenge::RVNGInputStream *input);
142 virtual int getInt(librevenge::RVNGInputStream *input);
143
144 librevenge::RVNGInputStream *m_input;
145 librevenge::RVNGDrawingInterface *m_painter;
146 librevenge::RVNGInputStream *m_container;
147 ChunkHeader m_header;
148 VSDCollector *m_collector;
149 VSDShapeList m_shapeList;
150 unsigned m_currentLevel;
151
152 VSDStencils m_stencils;
153 VSDStencil *m_currentStencil;
154 VSDShape m_shape;
155 bool m_isStencilStarted;
156 bool m_isInStyles;
157 unsigned m_currentShapeLevel;
158 unsigned m_currentShapeID;
159
160 unsigned m_currentLayerListLevel;
161
162 bool m_extractStencils;
163 std::vector<Colour> m_colours;
164
165 bool m_isBackgroundPage;
166 bool m_isShapeStarted;
167
168 double m_shadowOffsetX;
169 double m_shadowOffsetY;
170
171 VSDGeometryList *m_currentGeometryList;
172 unsigned m_currentGeomListCount;
173
174 std::map<unsigned, VSDName> m_fonts;
175 std::map<unsigned, VSDName> m_names;
176 std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
177 VSDName m_currentPageName;
178
179 std::map<unsigned, VSDTabStop> *m_currentTabSet;
180
181 private:
182 VSDParser();
183 VSDParser(const VSDParser &);
184 VSDParser &operator=(const VSDParser &);
185
186 };
187
188 } // namespace libvisio
189
190 #endif // __VSDPARSER_H__
191 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDParser::m_input
librevenge::RVNGInputStream * m_input
Definition: VSDParser.h:144
libvisio::VSDShape
Definition: VSDStencils.h:26
libvisio::VSDParser::m_currentLevel
unsigned m_currentLevel
Definition: VSDParser.h:150
libvisio::VSDParser::m_container
librevenge::RVNGInputStream * m_container
Definition: VSDParser.h:146
libvisio::VSDParser::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDParser.h:166
libvisio::VSDParser::m_isBackgroundPage
bool m_isBackgroundPage
Definition: VSDParser.h:165
libvisio::VSDParser::m_shapeList
VSDShapeList m_shapeList
Definition: VSDParser.h:149
libvisio::Pointer::Offset
unsigned Offset
Definition: VSDParser.h:40
libvisio::VSDParser::m_currentLayerListLevel
unsigned m_currentLayerListLevel
Definition: VSDParser.h:160
libvisio::Colour
Definition: VSDTypes.h:73
libvisio::Pointer
Definition: VSDParser.h:33
libvisio::VSDParser::m_header
ChunkHeader m_header
Definition: VSDParser.h:147
libvisio::VSDParser::m_shadowOffsetX
double m_shadowOffsetX
Definition: VSDParser.h:168
libvisio::VSDParser::m_colours
std::vector< Colour > m_colours
Definition: VSDParser.h:163
libvisio::VSDParser::m_painter
librevenge::RVNGDrawingInterface * m_painter
Definition: VSDParser.h:145
libvisio::VSDParser::m_currentPageName
VSDName m_currentPageName
Definition: VSDParser.h:177
libvisio::VSDParser::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDParser.h:157
VSDParagraphList.h
VSDCharacterList.h
libvisio::VSDParser::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDParser.h:174
VSDGeometryList.h
libvisio::VSDStencils
Definition: VSDStencils.h:78
libvisio::VSDParser
Definition: VSDParser.h:46
libvisio::VSDCollector
Definition: VSDCollector.h:20
libvisio::VSDParser::m_currentTabSet
std::map< unsigned, VSDTabStop > * m_currentTabSet
Definition: VSDParser.h:179
libvisio::Pointer::Length
unsigned Length
Definition: VSDParser.h:41
libvisio::VSDParser::m_currentStencil
VSDStencil * m_currentStencil
Definition: VSDParser.h:153
VSDStencils.h
VSDTypes.h
libvisio::VSDParser::m_currentShapeID
unsigned m_currentShapeID
Definition: VSDParser.h:158
libvisio::VSDParser::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDParser.h:171
VSDFieldList.h
libvisio::Pointer::ListSize
unsigned ListSize
Definition: VSDParser.h:43
libvisio::VSDParser::m_shadowOffsetY
double m_shadowOffsetY
Definition: VSDParser.h:169
libvisio::VSDParser::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDParser.h:155
libvisio::VSDParser::m_namesMapMap
std::map< unsigned, std::map< unsigned, VSDName > > m_namesMapMap
Definition: VSDParser.h:176
VSDShapeList.h
libvisio::VSDStencil
Definition: VSDStencils.h:62
VSDLayerList.h
libvisio
Definition: libvisio_utils.h:73
libvisio::ChunkHeader
Definition: VSDTypes.h:61
libvisio::VSDParser::m_currentGeomListCount
unsigned m_currentGeomListCount
Definition: VSDParser.h:172
libvisio::VSDParser::m_stencils
VSDStencils m_stencils
Definition: VSDParser.h:152
libvisio::Pointer::Type
unsigned Type
Definition: VSDParser.h:39
libvisio::VSDShapeList
Definition: VSDShapeList.h:19
libvisio::VSDParser::m_shape
VSDShape m_shape
Definition: VSDParser.h:154
libvisio::Pointer::Pointer
Pointer(const Pointer &ptr)
Definition: VSDParser.h:37
libvisio::Pointer::Format
unsigned short Format
Definition: VSDParser.h:42
libvisio::VSDParser::m_extractStencils
bool m_extractStencils
Definition: VSDParser.h:162
libvisio::VSDName
Definition: VSDTypes.h:179
libvisio::VSDParser::m_collector
VSDCollector * m_collector
Definition: VSDParser.h:148
libvisio::Pointer::Pointer
Pointer()
Definition: VSDParser.h:35
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:47
libvisio::VSDParser::m_isInStyles
bool m_isInStyles
Definition: VSDParser.h:156
libvisio::VSDParser::m_names
std::map< unsigned, VSDName > m_names
Definition: VSDParser.h:175