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