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 {
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;
162  unsigned m_currentLevel;
163 
171 
173  std::vector<Colour> m_colours;
174 
177 
180 
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;
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: */

Generated for libvisio by doxygen 1.8.4