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 <map>
38 #include <libwpd/libwpd.h>
39 #include <libwpd-stream/libwpd-stream.h>
40 #include <libwpg/libwpg.h>
41 #include "VSDTypes.h"
42 #include "VSDGeometryList.h"
43 #include "VSDFieldList.h"
44 #include "VSDCharacterList.h"
45 #include "VSDParagraphList.h"
46 #include "VSDShapeList.h"
47 #include "VSDStencils.h"
48 
49 namespace libvisio
50 {
51 
52 class VSDCollector;
53 
54 struct Pointer
55 {
57  : Type(0), Offset(0), Length(0), Format(0), ListSize(0) {}
58  Pointer(const Pointer &ptr)
59  : Type(ptr.Type), Offset(ptr.Offset), Length(ptr.Length), Format(ptr.Format), ListSize(ptr.ListSize) {}
60  unsigned Type;
61  unsigned Offset;
62  unsigned Length;
63  unsigned short Format;
64  unsigned ListSize;
65 };
66 
67 class VSDParser
68 {
69 public:
70  explicit VSDParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
71  virtual ~VSDParser();
72  bool parseMain();
73  bool extractStencils();
74 
75 protected:
76  // reader functions
77  void readEllipticalArcTo(WPXInputStream *input);
78  void readForeignData(WPXInputStream *input);
79  void readEllipse(WPXInputStream *input);
80  virtual void readLine(WPXInputStream *input);
81  virtual void readFillAndShadow(WPXInputStream *input);
82  virtual void readGeomList(WPXInputStream *input);
83  void readGeometry(WPXInputStream *input);
84  void readMoveTo(WPXInputStream *input);
85  void readLineTo(WPXInputStream *input);
86  void readArcTo(WPXInputStream *input);
87  void readNURBSTo(WPXInputStream *input);
88  void readPolylineTo(WPXInputStream *input);
89  void readInfiniteLine(WPXInputStream *input);
90  void readShapeData(WPXInputStream *input);
91  void readXFormData(WPXInputStream *input);
92  void readTxtXForm(WPXInputStream *input);
93  void readShapeId(WPXInputStream *input);
94  virtual void readShapeList(WPXInputStream *input);
95  void readForeignDataType(WPXInputStream *input);
96  void readPageProps(WPXInputStream *input);
97  virtual void readShape(WPXInputStream *input);
98  void readColours(WPXInputStream *input);
99  void readFont(WPXInputStream *input);
100  void readFontIX(WPXInputStream *input);
101  virtual void readCharList(WPXInputStream *input);
102  virtual void readParaList(WPXInputStream *input);
103  virtual void readPropList(WPXInputStream *input);
104  virtual void readPage(WPXInputStream *input);
105  virtual void readText(WPXInputStream *input);
106  virtual void readCharIX(WPXInputStream *input);
107  virtual void readParaIX(WPXInputStream *input);
108  virtual void readTextBlock(WPXInputStream *input);
109 
110  void readNameList(WPXInputStream *input);
111  virtual void readName(WPXInputStream *input);
112 
113  virtual void readFieldList(WPXInputStream *input);
114  virtual void readTextField(WPXInputStream *input);
115 
116  virtual void readStyleSheet(WPXInputStream *input);
117  void readPageSheet(WPXInputStream *input);
118 
119  void readSplineStart(WPXInputStream *input);
120  void readSplineKnot(WPXInputStream *input);
121 
122  void readStencilShape(WPXInputStream *input);
123 
124  void readOLEList(WPXInputStream *input);
125  void readOLEData(WPXInputStream *input);
126 
127  // parser of one pass
128  bool parseDocument(WPXInputStream *input, unsigned shift);
129 
130  // Stream handlers
131  void handleStreams(WPXInputStream *input, unsigned ptrType, unsigned shift, unsigned level);
132  void handleStream(const Pointer &ptr, unsigned idx, unsigned level);
133  void handleChunks(WPXInputStream *input, unsigned level);
134  void handleChunk(WPXInputStream *input);
135  void handleBlob(WPXInputStream *input, unsigned shift, unsigned level);
136 
137  virtual void readPointer(WPXInputStream *input, Pointer &ptr);
138  virtual void readPointerInfo(WPXInputStream *input, unsigned ptrType, unsigned shift, unsigned &listSize, int &pointerCount);
139  virtual bool getChunkHeader(WPXInputStream *input);
140  void _handleLevelChange(unsigned level);
141  Colour _colourFromIndex(unsigned idx);
142  void _flushShape();
143 
144  virtual unsigned getUInt(WPXInputStream *input);
145  virtual int getInt(WPXInputStream *input);
146 
147  WPXInputStream *m_input;
148  libwpg::WPGPaintInterface *m_painter;
152  unsigned m_currentLevel;
153 
161 
163  std::vector<Colour> m_colours;
164 
167 
170 
173 
174  std::map<unsigned, VSDName> m_fonts;
175 
176 private:
177  VSDParser();
178  VSDParser(const VSDParser &);
179  VSDParser &operator=(const VSDParser &);
180 
181 };
182 
183 } // namespace libvisio
184 
185 #endif // __VSDPARSER_H__
186 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.2