VSDXParser.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 __VSDXPARSER_H__
32 #define __VSDXPARSER_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 "VSDXTypes.h"
42 #include "VSDXGeometryList.h"
43 #include "VSDXFieldList.h"
44 #include "VSDXCharacterList.h"
45 #include "VSDXParagraphList.h"
46 #include "VSDXShapeList.h"
47 #include "VSDXStencils.h"
48 
49 namespace libvisio
50 {
51 
52 class VSDXCollector;
53 
55 {
56 public:
57  explicit VSDXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
58  virtual ~VSDXParser();
59  bool parseMain();
60 
61 protected:
62  // reader functions
63  void readEllipticalArcTo(WPXInputStream *input);
64  void readForeignData(WPXInputStream *input);
65  void readEllipse(WPXInputStream *input);
66  void readLine(WPXInputStream *input);
67  virtual void readFillAndShadow(WPXInputStream *input) = 0;
68  void readGeomList(WPXInputStream *input);
69  void readGeometry(WPXInputStream *input);
70  void readMoveTo(WPXInputStream *input);
71  void readLineTo(WPXInputStream *input);
72  void readArcTo(WPXInputStream *input);
73  void readNURBSTo(WPXInputStream *input);
74  void readPolylineTo(WPXInputStream *input);
75  void readInfiniteLine(WPXInputStream *input);
76  void readShapeData(WPXInputStream *input);
77  void readXFormData(WPXInputStream *input);
78  void readTxtXForm(WPXInputStream *input);
79  void readShapeId(WPXInputStream *input);
80  void readShapeList(WPXInputStream *input);
81  void readForeignDataType(WPXInputStream *input);
82  void readPageProps(WPXInputStream *input);
83  void readShape(WPXInputStream *input);
84  void readColours(WPXInputStream *input);
85  void readFont(WPXInputStream *input, unsigned id);
86  void readFontIX(WPXInputStream *input);
87  void readCharList(WPXInputStream *input);
88  void readParaList(WPXInputStream *input);
89  void readPage(WPXInputStream *input);
90  virtual void readText(WPXInputStream *input) = 0;
91  virtual void readCharIX(WPXInputStream *input) = 0;
92  virtual void readParaIX(WPXInputStream *input) = 0;
93  void readTextBlock(WPXInputStream *input);
94 
95  void readNameList(WPXInputStream *input);
96  virtual void readName(WPXInputStream *input) = 0;
97 
98  void readFieldList(WPXInputStream *input);
99  virtual void readTextField(WPXInputStream *input) = 0;
100 
101  void readStyleSheet(WPXInputStream *input);
102 
103  void readSplineStart(WPXInputStream *input);
104  void readSplineKnot(WPXInputStream *input);
105 
106  void readStencilShape(WPXInputStream *input);
107 
108  void readOLEList(WPXInputStream *input);
109  void readOLEData(WPXInputStream *input);
110 
111  // parser of one pass
112  bool parseDocument(WPXInputStream *input);
113 
114  // Stream handlers
115  void handlePages(WPXInputStream *input, unsigned shift);
116  void handlePage(WPXInputStream *input);
117  void handleStyles(WPXInputStream *input);
118  void handleStencils(WPXInputStream *input, unsigned shift);
119  void handleStencilPage(WPXInputStream *input, unsigned shift);
120  void handleStencilForeign(WPXInputStream *input, unsigned shift);
121  void handleStencilOle(WPXInputStream *input, unsigned shift);
122  void handleStencilShape(WPXInputStream *input);
123 
124  virtual bool getChunkHeader(WPXInputStream *input) = 0;
125  void _handleLevelChange(unsigned level);
126 
127  WPXInputStream *m_input;
128  libwpg::WPGPaintInterface *m_painter;
132  std::vector<VSDXGeometryList *> m_geomListVector;
136  std::vector<VSDXCharacterList *> m_charListVector;
137  std::vector<VSDXParagraphList *> m_paraListVector;
139  unsigned m_currentLevel;
140 
146  unsigned m_currentPageID;
147 
148 private:
149  VSDXParser();
150  VSDXParser(const VSDXParser &);
151  VSDXParser &operator=(const VSDXParser &);
152 
153 };
154 
155 struct Pointer
156 {
157  unsigned Type;
158  unsigned Offset;
159  unsigned Length;
160  unsigned short Format;
161 };
162 
163 } // namespace libvisio
164 
165 #endif // __VSDXPARSER_H__
166 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1.2