- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

VSDParser.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) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
17 * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
18 *
19 *
20 * All Rights Reserved.
21 *
22 * For minor contributions see the git repository.
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
26 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
27 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
28 * instead of those above.
29 */
30
31 #ifndef __VSDPARSER_H__
32 #define __VSDPARSER_H__
33
34 #include <stdio.h>
35 #include <iostream>
36 #include <vector>
37 #include <stack>
38 #include <map>
39 #include <libwpd/libwpd.h>
40 #include <libwpd-stream/libwpd-stream.h>
41 #include <libwpg/libwpg.h>
42 #include "VSDTypes.h"
43 #include "VSDGeometryList.h"
44 #include "VSDFieldList.h"
45 #include "VSDCharacterList.h"
46 #include "VSDParagraphList.h"
47 #include "VSDShapeList.h"
48 #include "VSDStencils.h"
49
50 namespace libvisio
51 {
52
53 class VSDCollector;
54
55 struct Pointer
56 {
57 Pointer()
58 : Type(0), Offset(0), Length(0), Format(0), ListSize(0) {}
59 Pointer(const Pointer &ptr)
60 : Type(ptr.Type), Offset(ptr.Offset), Length(ptr.Length), Format(ptr.Format), ListSize(ptr.ListSize) {}
61 unsigned Type;
62 unsigned Offset;
63 unsigned Length;
64 unsigned short Format;
65 unsigned ListSize;
66 };
67
68 class VSDParser
69 {
70 public:
71 explicit VSDParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
72 virtual ~VSDParser();
73 bool parseMain();
74 bool extractStencils();
75
76 protected:
77 // reader functions
78 void readEllipticalArcTo(WPXInputStream *input);
79 void readForeignData(WPXInputStream *input);
80 void readEllipse(WPXInputStream *input);
81 virtual void readLine(WPXInputStream *input);
82 virtual void readFillAndShadow(WPXInputStream *input);
83 virtual void readGeomList(WPXInputStream *input);
84 void readGeometry(WPXInputStream *input);
85 void readMoveTo(WPXInputStream *input);
86 void readLineTo(WPXInputStream *input);
87 void readArcTo(WPXInputStream *input);
88 void readNURBSTo(WPXInputStream *input);
89 void readPolylineTo(WPXInputStream *input);
90 void readInfiniteLine(WPXInputStream *input);
91 void readShapeData(WPXInputStream *input);
92 void readXFormData(WPXInputStream *input);
93 void readTxtXForm(WPXInputStream *input);
94 void readShapeId(WPXInputStream *input);
95 virtual void readShapeList(WPXInputStream *input);
96 void readForeignDataType(WPXInputStream *input);
97 void readPageProps(WPXInputStream *input);
98 virtual void readShape(WPXInputStream *input);
99 void readColours(WPXInputStream *input);
100 void readFont(WPXInputStream *input);
101 void readFontIX(WPXInputStream *input);
102 virtual void readCharList(WPXInputStream *input);
103 virtual void readParaList(WPXInputStream *input);
104 virtual void readPropList(WPXInputStream *input);
105 virtual void readPage(WPXInputStream *input);
106 virtual void readText(WPXInputStream *input);
107 virtual void readCharIX(WPXInputStream *input);
108 virtual void readParaIX(WPXInputStream *input);
109 virtual void readTextBlock(WPXInputStream *input);
110
111 void readNameList(WPXInputStream *input);
112 virtual void readName(WPXInputStream *input);
113
114 virtual void readNameList2(WPXInputStream *input);
115 virtual void readName2(WPXInputStream *input);
116
117 virtual void readFieldList(WPXInputStream *input);
118 virtual void readTextField(WPXInputStream *input);
119
120 virtual void readStyleSheet(WPXInputStream *input);
121 void readPageSheet(WPXInputStream *input);
122
123 void readSplineStart(WPXInputStream *input);
124 void readSplineKnot(WPXInputStream *input);
125
126 void readStencilShape(WPXInputStream *input);
127
128 void readOLEList(WPXInputStream *input);
129 void readOLEData(WPXInputStream *input);
130
131 virtual void readNameIDX(WPXInputStream *input);
132 virtual void readNameIDX123(WPXInputStream *input);
133
134 void readMisc(WPXInputStream *input);
135
136 // parser of one pass
137 bool parseDocument(WPXInputStream *input, unsigned shift);
138
139 // Stream handlers
140 void handleStreams(WPXInputStream *input, unsigned ptrType, unsigned shift, unsigned level);
141 void handleStream(const Pointer &ptr, unsigned idx, unsigned level);
142 void handleChunks(WPXInputStream *input, unsigned level);
143 void handleChunk(WPXInputStream *input);
144 void handleBlob(WPXInputStream *input, unsigned shift, unsigned level);
145
146 virtual void readPointer(WPXInputStream *input, Pointer &ptr);
147 virtual void readPointerInfo(WPXInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount);
148 virtual bool getChunkHeader(WPXInputStream *input);
149 void _handleLevelChange(unsigned level);
150 Colour _colourFromIndex(unsigned idx);
151 void _flushShape();
152 void _nameFromId(VSDName &name, unsigned id, unsigned level);
153
154 virtual unsigned getUInt(WPXInputStream *input);
155 virtual int getInt(WPXInputStream *input);
156
157 WPXInputStream *m_input;
158 libwpg::WPGPaintInterface *m_painter;
159 ChunkHeader m_header;
160 VSDCollector *m_collector;
161 VSDShapeList m_shapeList;
162 unsigned m_currentLevel;
163
164 VSDStencils m_stencils;
165 VSDStencil *m_currentStencil;
166 VSDShape m_shape;
167 bool m_isStencilStarted;
168 bool m_isInStyles;
169 unsigned m_currentShapeLevel;
170 unsigned m_currentShapeID;
171
172 bool m_extractStencils;
173 std::vector<Colour> m_colours;
174
175 bool m_isBackgroundPage;
176 bool m_isShapeStarted;
177
178 double m_shadowOffsetX;
179 double m_shadowOffsetY;
180
181 VSDGeometryList *m_currentGeometryList;
182 unsigned m_currentGeomListCount;
183
184 std::map<unsigned, VSDName> m_fonts;
185 std::map<unsigned, VSDName> m_names;
186 std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
187 VSDName m_currentPageName;
188
189 private:
190 VSDParser();
191 VSDParser(const VSDParser &);
192 VSDParser &operator=(const VSDParser &);
193
194 };
195
196 } // namespace libvisio
197
198 #endif // __VSDPARSER_H__
199 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDParser::readFillAndShadow
virtual void readFillAndShadow(WPXInputStream *input)
Definition: VSDParser.cpp:1791
libvisio::VSDParser::~VSDParser
virtual ~VSDParser()
Definition: VSDParser.cpp:53
libvisio::VSDShape
Definition: VSDStencils.h:47
libvisio::VSDParser::m_currentLevel
unsigned m_currentLevel
Definition: VSDParser.h:162
libvisio::VSDParser::readSplineKnot
void readSplineKnot(WPXInputStream *input)
Definition: VSDParser.cpp:1500
libvisio::VSDParser::readTxtXForm
void readTxtXForm(WPXInputStream *input)
Definition: VSDParser.cpp:989
libvisio::VSDParser::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDParser.h:176
libvisio::VSDParser::VSDParser
VSDParser()
libvisio::VSDParser::handleStream
void handleStream(const Pointer &ptr, unsigned idx, unsigned level)
Definition: VSDParser.cpp:274
libvisio::VSDParser::m_input
WPXInputStream * m_input
Definition: VSDParser.h:157
libvisio::VSDParser::readGeomList
virtual void readGeomList(WPXInputStream *input)
Definition: VSDParser.cpp:843
libvisio::VSDParser::readCharList
virtual void readCharList(WPXInputStream *input)
Definition: VSDParser.cpp:871
libvisio::VSDParser::m_isBackgroundPage
bool m_isBackgroundPage
Definition: VSDParser.h:175
libvisio::VSDParser::m_shapeList
VSDShapeList m_shapeList
Definition: VSDParser.h:161
libvisio::Pointer::Offset
unsigned Offset
Definition: VSDParser.h:62
libvisio::Colour
Definition: VSDTypes.h:78
libvisio::Pointer
Definition: VSDParser.h:55
libvisio::VSDParser::readParaList
virtual void readParaList(WPXInputStream *input)
Definition: VSDParser.cpp:892
libvisio::VSDParser::m_header
ChunkHeader m_header
Definition: VSDParser.h:159
libvisio::VSDParser::readTextField
virtual void readTextField(WPXInputStream *input)
Definition: VSDParser.cpp:1884
libvisio::VSDParser::m_shadowOffsetX
double m_shadowOffsetX
Definition: VSDParser.h:178
libvisio::VSDParser::m_colours
std::vector< Colour > m_colours
Definition: VSDParser.h:173
libvisio::VSDParser::_colourFromIndex
Colour _colourFromIndex(unsigned idx)
Definition: VSDParser.cpp:1962
libvisio::VSDParser::handleStreams
void handleStreams(WPXInputStream *input, unsigned ptrType, unsigned shift, unsigned level)
Definition: VSDParser.cpp:206
libvisio::VSDParser::readName
virtual void readName(WPXInputStream *input)
Definition: VSDParser.cpp:1858
libvisio::VSDParser::m_currentPageName
VSDName m_currentPageName
Definition: VSDParser.h:187
libvisio::VSDParser::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDParser.h:169
libvisio::VSDParser::readCharIX
virtual void readCharIX(WPXInputStream *input)
Definition: VSDParser.cpp:1687
libvisio::VSDParser::readPointer
virtual void readPointer(WPXInputStream *input, Pointer &ptr)
Definition: VSDParser.cpp:186
VSDParagraphList.h
libvisio::VSDParser::handleChunk
void handleChunk(WPXInputStream *input)
Definition: VSDParser.cpp:427
libvisio::VSDParser::readShapeData
void readShapeData(WPXInputStream *input)
Definition: VSDParser.cpp:1420
libvisio::VSDParser::readEllipse
void readEllipse(WPXInputStream *input)
Definition: VSDParser.cpp:772
VSDCharacterList.h
libvisio::VSDParser::getInt
virtual int getInt(WPXInputStream *input)
Definition: VSDParser.cpp:1974
libvisio::VSDParser::readParaIX
virtual void readParaIX(WPXInputStream *input)
Definition: VSDParser.cpp:1754
libvisio::VSDParser::readOLEList
void readOLEList(WPXInputStream *input)
Definition: VSDParser.cpp:716
libvisio::VSDParser::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDParser.h:184
VSDGeometryList.h
libvisio::VSDParser::readLineTo
void readLineTo(WPXInputStream *input)
Definition: VSDParser.cpp:945
libvisio::VSDStencils
Definition: VSDStencils.h:95
libvisio::VSDParser::_flushShape
void _flushShape()
Definition: VSDParser.cpp:583
libvisio::VSDParser::readEllipticalArcTo
void readEllipticalArcTo(WPXInputStream *input)
Definition: VSDParser.cpp:682
libvisio::VSDParser
Definition: VSDParser.h:68
libvisio::VSDParser::readGeometry
void readGeometry(WPXInputStream *input)
Definition: VSDParser.cpp:923
libvisio::VSDCollector
Definition: VSDCollector.h:41
libvisio::Pointer::Length
unsigned Length
Definition: VSDParser.h:63
libvisio::VSDParser::m_currentStencil
VSDStencil * m_currentStencil
Definition: VSDParser.h:165
libvisio::VSDParser::readOLEData
void readOLEData(WPXInputStream *input)
Definition: VSDParser.cpp:720
libvisio::VSDParser::readArcTo
void readArcTo(WPXInputStream *input)
Definition: VSDParser.cpp:956
libvisio::VSDParser::readText
virtual void readText(WPXInputStream *input)
Definition: VSDParser.cpp:1665
libvisio::VSDParser::readPageSheet
void readPageSheet(WPXInputStream *input)
Definition: VSDParser.cpp:1659
libvisio::VSDParser::readShapeList
virtual void readShapeList(WPXInputStream *input)
Definition: VSDParser.cpp:1018
libvisio::VSDParser::readFont
void readFont(WPXInputStream *input)
Definition: VSDParser.cpp:1558
libvisio::VSDParser::readLine
virtual void readLine(WPXInputStream *input)
Definition: VSDParser.cpp:791
libvisio::VSDParser::readXFormData
void readXFormData(WPXInputStream *input)
Definition: VSDParser.cpp:969
VSDStencils.h
VSDTypes.h
libvisio::VSDParser::m_currentShapeID
unsigned m_currentShapeID
Definition: VSDParser.h:170
libvisio::VSDParser::readPolylineTo
void readPolylineTo(WPXInputStream *input)
Definition: VSDParser.cpp:1307
libvisio::VSDParser::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDParser.h:181
libvisio::VSDParser::readMisc
void readMisc(WPXInputStream *input)
Definition: VSDParser.cpp:1953
libvisio::VSDParser::readNameList
void readNameList(WPXInputStream *input)
Definition: VSDParser.cpp:1512
VSDFieldList.h
libvisio::Pointer::ListSize
unsigned ListSize
Definition: VSDParser.h:65
libvisio::VSDParser::readForeignData
void readForeignData(WPXInputStream *input)
Definition: VSDParser.cpp:702
libvisio::VSDParser::m_shadowOffsetY
double m_shadowOffsetY
Definition: VSDParser.h:179
libvisio::VSDParser::readTextBlock
virtual void readTextBlock(WPXInputStream *input)
Definition: VSDParser.cpp:813
libvisio::VSDParser::_handleLevelChange
void _handleLevelChange(unsigned level)
Definition: VSDParser.cpp:654
libvisio::VSDParser::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDParser.h:167
libvisio::VSDParser::m_namesMapMap
std::map< unsigned, std::map< unsigned, VSDName > > m_namesMapMap
Definition: VSDParser.h:186
VSDShapeList.h
libvisio::VSDParser::readForeignDataType
void readForeignDataType(WPXInputStream *input)
Definition: VSDParser.cpp:1040
libvisio::VSDParser::readSplineStart
void readSplineStart(WPXInputStream *input)
Definition: VSDParser.cpp:1485
libvisio::VSDParser::_nameFromId
void _nameFromId(VSDName &name, unsigned id, unsigned level)
Definition: VSDParser.cpp:57
libvisio::VSDStencil
Definition: VSDStencils.h:79
libvisio::VSDParser::readInfiniteLine
void readInfiniteLine(WPXInputStream *input)
Definition: VSDParser.cpp:1406
libvisio::VSDParser::readName2
virtual void readName2(WPXInputStream *input)
Definition: VSDParser.cpp:1869
libvisio::VSDParser::readMoveTo
void readMoveTo(WPXInputStream *input)
Definition: VSDParser.cpp:934
libvisio::ChunkHeader
Definition: VSDTypes.h:66
libvisio::VSDParser::m_currentGeomListCount
unsigned m_currentGeomListCount
Definition: VSDParser.h:182
libvisio::VSDParser::m_stencils
VSDStencils m_stencils
Definition: VSDParser.h:164
libvisio::VSDParser::handleBlob
void handleBlob(WPXInputStream *input, unsigned shift, unsigned level)
Definition: VSDParser.cpp:393
libvisio::Pointer::Type
unsigned Type
Definition: VSDParser.h:61
libvisio::VSDParser::extractStencils
bool extractStencils()
Definition: VSDParser.cpp:180
libvisio::VSDParser::readNameIDX
virtual void readNameIDX(WPXInputStream *input)
Definition: VSDParser.cpp:735
libvisio::VSDParser::handleChunks
void handleChunks(WPXInputStream *input, unsigned level)
Definition: VSDParser.cpp:409
libvisio::VSDShapeList
Definition: VSDShapeList.h:40
libvisio::VSDParser::m_shape
VSDShape m_shape
Definition: VSDParser.h:166
libvisio::VSDParser::m_painter
libwpg::WPGPaintInterface * m_painter
Definition: VSDParser.h:158
libvisio::Pointer::Pointer
Pointer(const Pointer &ptr)
Definition: VSDParser.h:59
libvisio::VSDParser::operator=
VSDParser & operator=(const VSDParser &)
libvisio::VSDParser::readFieldList
virtual void readFieldList(WPXInputStream *input)
Definition: VSDParser.cpp:1522
libvisio::Pointer::Format
unsigned short Format
Definition: VSDParser.h:64
libvisio::VSDParser::readStyleSheet
virtual void readStyleSheet(WPXInputStream *input)
Definition: VSDParser.cpp:1647
libvisio::VSDParser::m_extractStencils
bool m_extractStencils
Definition: VSDParser.h:172
libvisio::VSDParser::readNameList2
virtual void readNameList2(WPXInputStream *input)
Definition: VSDParser.cpp:1517
libvisio::VSDParser::readPage
virtual void readPage(WPXInputStream *input)
Definition: VSDParser.cpp:916
libvisio::VSDParser::readShape
virtual void readShape(WPXInputStream *input)
Definition: VSDParser.cpp:1092
libvisio::VSDParser::readNURBSTo
void readNURBSTo(WPXInputStream *input)
Definition: VSDParser.cpp:1148
libvisio::VSDParser::readPointerInfo
virtual void readPointerInfo(WPXInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount)
Definition: VSDParser.cpp:195
libvisio::VSDParser::readPropList
virtual void readPropList(WPXInputStream *input)
Definition: VSDParser.cpp:912
libvisio::VSDName
Definition: VSDTypes.h:184
libvisio::VSDParser::parseMain
bool parseMain()
Definition: VSDParser.cpp:125
libvisio::VSDParser::readNameIDX123
virtual void readNameIDX123(WPXInputStream *input)
Definition: VSDParser.cpp:756
libvisio::VSDParser::readShapeId
void readShapeId(WPXInputStream *input)
Definition: VSDParser.cpp:1010
libvisio::VSDParser::m_collector
VSDCollector * m_collector
Definition: VSDParser.h:160
libvisio::Pointer::Pointer
Pointer()
Definition: VSDParser.h:57
libvisio::VSDParser::readColours
void readColours(WPXInputStream *input)
Definition: VSDParser.cpp:1539
libvisio::VSDParser::readFontIX
void readFontIX(WPXInputStream *input)
Definition: VSDParser.cpp:1575
libvisio::VSDParser::readStencilShape
void readStencilShape(WPXInputStream *input)
libvisio::VSDParser::getUInt
virtual unsigned getUInt(WPXInputStream *input)
Definition: VSDParser.cpp:1969
libvisio::VSDParser::readPageProps
void readPageProps(WPXInputStream *input)
Definition: VSDParser.cpp:1068
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:68
libvisio::VSDParser::m_isInStyles
bool m_isInStyles
Definition: VSDParser.h:168
libvisio::VSDParser::parseDocument
bool parseDocument(WPXInputStream *input, unsigned shift)
Definition: VSDParser.cpp:167
libvisio::VSDParser::m_names
std::map< unsigned, VSDName > m_names
Definition: VSDParser.h:185
libvisio::VSDParser::getChunkHeader
virtual bool getChunkHeader(WPXInputStream *input)
Definition: VSDParser.cpp:69