VSDParser.h Source File documentation

- 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 /*
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 "VSDStencils.h"
26
27 namespace libvisio
28 {
29
30 class VSDCollector;
31
32 struct Pointer
33 {
34 Pointer()
35 : Type(0), Offset(0), Length(0), Format(0), ListSize(0) {}
36 Pointer(const Pointer &ptr)
37 : Type(ptr.Type), Offset(ptr.Offset), Length(ptr.Length), Format(ptr.Format), ListSize(ptr.ListSize) {}
38 unsigned Type;
39 unsigned Offset;
40 unsigned Length;
41 unsigned short Format;
42 unsigned ListSize;
43 };
44
45 class VSDParser
46 {
47 public:
48 explicit VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container = 0);
49 virtual ~VSDParser();
50 bool parseMain();
51 bool extractStencils();
52
53 protected:
54 // reader functions
55 void readEllipticalArcTo(librevenge::RVNGInputStream *input);
56 void readForeignData(librevenge::RVNGInputStream *input);
57 void readEllipse(librevenge::RVNGInputStream *input);
58 virtual void readLine(librevenge::RVNGInputStream *input);
59 virtual void readFillAndShadow(librevenge::RVNGInputStream *input);
60 virtual void readGeomList(librevenge::RVNGInputStream *input);
61 void readGeometry(librevenge::RVNGInputStream *input);
62 void readMoveTo(librevenge::RVNGInputStream *input);
63 void readLineTo(librevenge::RVNGInputStream *input);
64 void readArcTo(librevenge::RVNGInputStream *input);
65 void readNURBSTo(librevenge::RVNGInputStream *input);
66 void readPolylineTo(librevenge::RVNGInputStream *input);
67 void readInfiniteLine(librevenge::RVNGInputStream *input);
68 void readShapeData(librevenge::RVNGInputStream *input);
69 void readXFormData(librevenge::RVNGInputStream *input);
70 void readXForm1D(librevenge::RVNGInputStream *input);
71 void readTxtXForm(librevenge::RVNGInputStream *input);
72 void readShapeId(librevenge::RVNGInputStream *input);
73 virtual void readShapeList(librevenge::RVNGInputStream *input);
74 void readForeignDataType(librevenge::RVNGInputStream *input);
75 void readPageProps(librevenge::RVNGInputStream *input);
76 virtual void readShape(librevenge::RVNGInputStream *input);
77 void readColours(librevenge::RVNGInputStream *input);
78 void readFont(librevenge::RVNGInputStream *input);
79 void readFontIX(librevenge::RVNGInputStream *input);
80 virtual void readCharList(librevenge::RVNGInputStream *input);
81 virtual void readParaList(librevenge::RVNGInputStream *input);
82 virtual void readPropList(librevenge::RVNGInputStream *input);
83 virtual void readPage(librevenge::RVNGInputStream *input);
84 virtual void readText(librevenge::RVNGInputStream *input);
85 virtual void readCharIX(librevenge::RVNGInputStream *input);
86 virtual void readParaIX(librevenge::RVNGInputStream *input);
87 virtual void readTextBlock(librevenge::RVNGInputStream *input);
88
89 void readNameList(librevenge::RVNGInputStream *input);
90 virtual void readName(librevenge::RVNGInputStream *input);
91
92 virtual void readNameList2(librevenge::RVNGInputStream *input);
93 virtual void readName2(librevenge::RVNGInputStream *input);
94
95 virtual void readFieldList(librevenge::RVNGInputStream *input);
96 virtual void readTextField(librevenge::RVNGInputStream *input);
97
98 virtual void readStyleSheet(librevenge::RVNGInputStream *input);
99 void readPageSheet(librevenge::RVNGInputStream *input);
100
101 void readSplineStart(librevenge::RVNGInputStream *input);
102 void readSplineKnot(librevenge::RVNGInputStream *input);
103
104 void readStencilShape(librevenge::RVNGInputStream *input);
105
106 void readOLEList(librevenge::RVNGInputStream *input);
107 void readOLEData(librevenge::RVNGInputStream *input);
108
109 virtual void readNameIDX(librevenge::RVNGInputStream *input);
110 virtual void readNameIDX123(librevenge::RVNGInputStream *input);
111
112 void readMisc(librevenge::RVNGInputStream *input);
113
114 // parser of one pass
115 bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift);
116
117 bool parseMetaData();
118
119 // Stream handlers
120 void handleStreams(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned level);
121 void handleStream(const Pointer &ptr, unsigned idx, unsigned level);
122 void handleChunks(librevenge::RVNGInputStream *input, unsigned level);
123 void handleChunk(librevenge::RVNGInputStream *input);
124 void handleBlob(librevenge::RVNGInputStream *input, unsigned shift, unsigned level);
125
126 virtual void readPointer(librevenge::RVNGInputStream *input, Pointer &ptr);
127 virtual void readPointerInfo(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount);
128 virtual bool getChunkHeader(librevenge::RVNGInputStream *input);
129 void _handleLevelChange(unsigned level);
130 Colour _colourFromIndex(unsigned idx);
131 void _flushShape();
132 void _nameFromId(VSDName &name, unsigned id, unsigned level);
133
134 virtual unsigned getUInt(librevenge::RVNGInputStream *input);
135 virtual int getInt(librevenge::RVNGInputStream *input);
136
137 librevenge::RVNGInputStream *m_input;
138 librevenge::RVNGDrawingInterface *m_painter;
139 librevenge::RVNGInputStream *m_container;
140 ChunkHeader m_header;
141 VSDCollector *m_collector;
142 VSDShapeList m_shapeList;
143 unsigned m_currentLevel;
144
145 VSDStencils m_stencils;
146 VSDStencil *m_currentStencil;
147 VSDShape m_shape;
148 bool m_isStencilStarted;
149 bool m_isInStyles;
150 unsigned m_currentShapeLevel;
151 unsigned m_currentShapeID;
152
153 bool m_extractStencils;
154 std::vector<Colour> m_colours;
155
156 bool m_isBackgroundPage;
157 bool m_isShapeStarted;
158
159 double m_shadowOffsetX;
160 double m_shadowOffsetY;
161
162 VSDGeometryList *m_currentGeometryList;
163 unsigned m_currentGeomListCount;
164
165 std::map<unsigned, VSDName> m_fonts;
166 std::map<unsigned, VSDName> m_names;
167 std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
168 VSDName m_currentPageName;
169
170 private:
171 VSDParser();
172 VSDParser(const VSDParser &);
173 VSDParser &operator=(const VSDParser &);
174
175 };
176
177 } // namespace libvisio
178
179 #endif // __VSDPARSER_H__
180 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDParser::readParaIX
virtual void readParaIX(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1779
libvisio::VSDParser::m_input
librevenge::RVNGInputStream * m_input
Definition: VSDParser.h:137
libvisio::VSDParser::readPageSheet
void readPageSheet(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1684
libvisio::VSDParser::~VSDParser
virtual ~VSDParser()
Definition: VSDParser.cpp:33
libvisio::VSDShape
Definition: VSDStencils.h:26
libvisio::VSDParser::readNameIDX
virtual void readNameIDX(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:745
libvisio::VSDParser::m_currentLevel
unsigned m_currentLevel
Definition: VSDParser.h:143
libvisio::VSDParser::m_container
librevenge::RVNGInputStream * m_container
Definition: VSDParser.h:139
libvisio::VSDParser::readLineTo
void readLineTo(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:955
libvisio::VSDParser::readFont
void readFont(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1583
libvisio::VSDParser::readSplineStart
void readSplineStart(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1510
libvisio::VSDParser::readPointer
virtual void readPointer(librevenge::RVNGInputStream *input, Pointer &ptr)
Definition: VSDParser.cpp:190
libvisio::VSDParser::readFillAndShadow
virtual void readFillAndShadow(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1816
libvisio::VSDParser::readNameIDX123
virtual void readNameIDX123(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:766
libvisio::VSDParser::m_isShapeStarted
bool m_isShapeStarted
Definition: VSDParser.h:157
libvisio::VSDParser::VSDParser
VSDParser()
libvisio::VSDParser::handleStream
void handleStream(const Pointer &ptr, unsigned idx, unsigned level)
Definition: VSDParser.cpp:281
libvisio::VSDParser::readOLEList
void readOLEList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:726
libvisio::VSDParser::readGeometry
void readGeometry(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:933
libvisio::VSDParser::m_isBackgroundPage
bool m_isBackgroundPage
Definition: VSDParser.h:156
libvisio::VSDParser::m_shapeList
VSDShapeList m_shapeList
Definition: VSDParser.h:142
libvisio::VSDParser::readText
virtual void readText(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1690
libvisio::VSDParser::readPolylineTo
void readPolylineTo(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1332
libvisio::Pointer::Offset
unsigned Offset
Definition: VSDParser.h:39
libvisio::VSDParser::handleChunk
void handleChunk(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:434
libvisio::Colour
Definition: VSDTypes.h:72
libvisio::Pointer
Definition: VSDParser.h:32
libvisio::VSDParser::readPageProps
void readPageProps(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1093
libvisio::VSDParser::m_header
ChunkHeader m_header
Definition: VSDParser.h:140
libvisio::VSDParser::m_shadowOffsetX
double m_shadowOffsetX
Definition: VSDParser.h:159
libvisio::VSDParser::m_colours
std::vector< Colour > m_colours
Definition: VSDParser.h:154
libvisio::VSDParser::_colourFromIndex
Colour _colourFromIndex(unsigned idx)
Definition: VSDParser.cpp:1987
libvisio::VSDParser::m_painter
librevenge::RVNGDrawingInterface * m_painter
Definition: VSDParser.h:138
libvisio::VSDParser::parseDocument
bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift)
Definition: VSDParser.cpp:171
libvisio::VSDParser::m_currentPageName
VSDName m_currentPageName
Definition: VSDParser.h:168
libvisio::VSDParser::m_currentShapeLevel
unsigned m_currentShapeLevel
Definition: VSDParser.h:150
libvisio::VSDParser::readNameList2
virtual void readNameList2(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1542
VSDParagraphList.h
libvisio::VSDParser::handleChunks
void handleChunks(librevenge::RVNGInputStream *input, unsigned level)
Definition: VSDParser.cpp:416
libvisio::VSDParser::readInfiniteLine
void readInfiniteLine(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1431
libvisio::VSDParser::readColours
void readColours(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1564
VSDCharacterList.h
libvisio::VSDParser::readPage
virtual void readPage(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:926
libvisio::VSDParser::readNURBSTo
void readNURBSTo(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1173
libvisio::VSDParser::m_fonts
std::map< unsigned, VSDName > m_fonts
Definition: VSDParser.h:165
VSDGeometryList.h
libvisio::VSDParser::readShapeList
virtual void readShapeList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1043
libvisio::VSDStencils
Definition: VSDStencils.h:76
libvisio::VSDParser::_flushShape
void _flushShape()
Definition: VSDParser.cpp:593
libvisio::VSDParser
Definition: VSDParser.h:45
libvisio::VSDParser::readStencilShape
void readStencilShape(librevenge::RVNGInputStream *input)
libvisio::VSDCollector
Definition: VSDCollector.h:20
libvisio::Pointer::Length
unsigned Length
Definition: VSDParser.h:40
libvisio::VSDParser::m_currentStencil
VSDStencil * m_currentStencil
Definition: VSDParser.h:146
libvisio::VSDParser::readCharIX
virtual void readCharIX(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1712
libvisio::VSDParser::handleStreams
void handleStreams(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned level)
Definition: VSDParser.cpp:210
libvisio::VSDParser::readSplineKnot
void readSplineKnot(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1525
VSDStencils.h
libvisio::VSDParser::readParaList
virtual void readParaList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:902
VSDTypes.h
libvisio::VSDParser::m_currentShapeID
unsigned m_currentShapeID
Definition: VSDParser.h:151
libvisio::VSDParser::m_currentGeometryList
VSDGeometryList * m_currentGeometryList
Definition: VSDParser.h:162
libvisio::VSDParser::readFontIX
void readFontIX(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1600
libvisio::VSDParser::readShape
virtual void readShape(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1117
libvisio::VSDParser::handleBlob
void handleBlob(librevenge::RVNGInputStream *input, unsigned shift, unsigned level)
Definition: VSDParser.cpp:400
VSDFieldList.h
libvisio::Pointer::ListSize
unsigned ListSize
Definition: VSDParser.h:42
libvisio::VSDParser::parseMetaData
bool parseMetaData()
Definition: VSDParser.cpp:150
libvisio::VSDParser::m_shadowOffsetY
double m_shadowOffsetY
Definition: VSDParser.h:160
libvisio::VSDParser::_handleLevelChange
void _handleLevelChange(unsigned level)
Definition: VSDParser.cpp:664
libvisio::VSDParser::readEllipse
void readEllipse(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:782
libvisio::VSDParser::readArcTo
void readArcTo(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:966
libvisio::VSDParser::m_isStencilStarted
bool m_isStencilStarted
Definition: VSDParser.h:148
libvisio::VSDParser::readTxtXForm
void readTxtXForm(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1014
libvisio::VSDParser::m_namesMapMap
std::map< unsigned, std::map< unsigned, VSDName > > m_namesMapMap
Definition: VSDParser.h:167
libvisio::VSDParser::readOLEData
void readOLEData(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:730
libvisio::VSDParser::readLine
virtual void readLine(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:801
VSDShapeList.h
libvisio::VSDParser::_nameFromId
void _nameFromId(VSDName &name, unsigned id, unsigned level)
Definition: VSDParser.cpp:37
libvisio::VSDParser::readForeignData
void readForeignData(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:712
libvisio::VSDStencil
Definition: VSDStencils.h:60
libvisio::VSDParser::readPointerInfo
virtual void readPointerInfo(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount)
Definition: VSDParser.cpp:199
libvisio::VSDParser::readTextBlock
virtual void readTextBlock(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:823
libvisio::VSDParser::getChunkHeader
virtual bool getChunkHeader(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:49
libvisio::VSDParser::readXForm1D
void readXForm1D(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:999
libvisio
Definition: libvisio_utils.h:68
libvisio::VSDParser::readName2
virtual void readName2(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1894
libvisio::VSDParser::readMisc
void readMisc(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1978
libvisio::VSDParser::readXFormData
void readXFormData(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:979
libvisio::ChunkHeader
Definition: VSDTypes.h:60
libvisio::VSDParser::readNameList
void readNameList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1537
libvisio::VSDParser::m_currentGeomListCount
unsigned m_currentGeomListCount
Definition: VSDParser.h:163
libvisio::VSDParser::readStyleSheet
virtual void readStyleSheet(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1672
libvisio::VSDParser::m_stencils
VSDStencils m_stencils
Definition: VSDParser.h:145
libvisio::Pointer::Type
unsigned Type
Definition: VSDParser.h:38
libvisio::VSDParser::getUInt
virtual unsigned getUInt(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1994
libvisio::VSDParser::extractStencils
bool extractStencils()
Definition: VSDParser.cpp:184
libvisio::VSDParser::readShapeId
void readShapeId(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1035
libvisio::VSDShapeList
Definition: VSDShapeList.h:19
libvisio::VSDParser::m_shape
VSDShape m_shape
Definition: VSDParser.h:147
libvisio::Pointer::Pointer
Pointer(const Pointer &ptr)
Definition: VSDParser.h:36
libvisio::VSDParser::readEllipticalArcTo
void readEllipticalArcTo(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:692
libvisio::VSDParser::operator=
VSDParser & operator=(const VSDParser &)
libvisio::Pointer::Format
unsigned short Format
Definition: VSDParser.h:41
libvisio::VSDParser::readFieldList
virtual void readFieldList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1547
libvisio::VSDParser::readForeignDataType
void readForeignDataType(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1065
libvisio::VSDParser::readName
virtual void readName(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1883
libvisio::VSDParser::m_extractStencils
bool m_extractStencils
Definition: VSDParser.h:153
libvisio::VSDName
Definition: VSDTypes.h:178
libvisio::VSDParser::parseMain
bool parseMain()
Definition: VSDParser.cpp:105
libvisio::VSDParser::m_collector
VSDCollector * m_collector
Definition: VSDParser.h:141
libvisio::VSDParser::readPropList
virtual void readPropList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:922
libvisio::Pointer::Pointer
Pointer()
Definition: VSDParser.h:34
libvisio::VSDParser::getInt
virtual int getInt(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1999
libvisio::VSDParser::readTextField
virtual void readTextField(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1909
libvisio::VSDParser::readCharList
virtual void readCharList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:881
libvisio::VSDParser::readGeomList
virtual void readGeomList(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:853
libvisio::VSDParser::readMoveTo
void readMoveTo(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:944
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:47
libvisio::VSDParser::m_isInStyles
bool m_isInStyles
Definition: VSDParser.h:149
libvisio::VSDParser::readShapeData
void readShapeData(librevenge::RVNGInputStream *input)
Definition: VSDParser.cpp:1445
libvisio::VSDParser::m_names
std::map< unsigned, VSDName > m_names
Definition: VSDParser.h:166