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 
54 struct Pointer
55 {
56  unsigned Type;
57  unsigned Offset;
58  unsigned Length;
59  unsigned short Format;
60  unsigned ListSize;
61 };
62 
64 {
65 public:
66  explicit VSDXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
67  virtual ~VSDXParser();
68  bool parseMain();
69 
70 protected:
71  // reader functions
72  void readEllipticalArcTo(WPXInputStream *input);
73  void readForeignData(WPXInputStream *input);
74  void readEllipse(WPXInputStream *input);
75  void readLine(WPXInputStream *input);
76  virtual void readFillAndShadow(WPXInputStream *input) = 0;
77  void readGeomList(WPXInputStream *input);
78  void readGeometry(WPXInputStream *input);
79  void readMoveTo(WPXInputStream *input);
80  void readLineTo(WPXInputStream *input);
81  void readArcTo(WPXInputStream *input);
82  void readNURBSTo(WPXInputStream *input);
83  void readPolylineTo(WPXInputStream *input);
84  void readInfiniteLine(WPXInputStream *input);
85  void readShapeData(WPXInputStream *input);
86  void readXFormData(WPXInputStream *input);
87  void readTxtXForm(WPXInputStream *input);
88  void readShapeId(WPXInputStream *input);
89  void readShapeList(WPXInputStream *input);
90  void readForeignDataType(WPXInputStream *input);
91  void readPageProps(WPXInputStream *input);
92  void readShape(WPXInputStream *input);
93  void readColours(WPXInputStream *input);
94  void readFont(WPXInputStream *input, unsigned id);
95  void readFontIX(WPXInputStream *input);
96  void readCharList(WPXInputStream *input);
97  void readParaList(WPXInputStream *input);
98  void readPage(WPXInputStream *input);
99  virtual void readText(WPXInputStream *input) = 0;
100  virtual void readCharIX(WPXInputStream *input) = 0;
101  virtual void readParaIX(WPXInputStream *input) = 0;
102  void readTextBlock(WPXInputStream *input);
103 
104  void readNameList(WPXInputStream *input);
105  virtual void readName(WPXInputStream *input) = 0;
106 
107  void readFieldList(WPXInputStream *input);
108  virtual void readTextField(WPXInputStream *input) = 0;
109 
110  void readStyleSheet(WPXInputStream *input);
111 
112  void readSplineStart(WPXInputStream *input);
113  void readSplineKnot(WPXInputStream *input);
114 
115  void readStencilShape(WPXInputStream *input);
116 
117  void readOLEList(WPXInputStream *input);
118  void readOLEData(WPXInputStream *input);
119 
120  // parser of one pass
121  bool parseDocument(WPXInputStream *input);
122 
123  // Stream handlers
124  void handleStreams(WPXInputStream *input, unsigned shift, unsigned level);
125  void handleStream(const Pointer &ptr, unsigned idx, unsigned level);
126  void handleChunks(WPXInputStream *input, unsigned level);
127 
128  void handleStencils(WPXInputStream *input, unsigned shift);
129  void handleStencilPage(WPXInputStream *input, unsigned shift);
130  void handleStencilForeign(WPXInputStream *input, unsigned shift);
131  void handleStencilOle(WPXInputStream *input, unsigned shift);
132  void handleStencilShape(WPXInputStream *input);
133 
134  virtual bool getChunkHeader(WPXInputStream *input) = 0;
135  void _handleLevelChange(unsigned level);
136 
137  WPXInputStream *m_input;
138  libwpg::WPGPaintInterface *m_painter;
142  std::vector<VSDXGeometryList *> m_geomListVector;
146  std::vector<VSDXCharacterList *> m_charListVector;
147  std::vector<VSDXParagraphList *> m_paraListVector;
149  unsigned m_currentLevel;
150 
158 
159 private:
160  VSDXParser();
161  VSDXParser(const VSDXParser &);
162  VSDXParser &operator=(const VSDXParser &);
163 
164 };
165 
166 } // namespace libvisio
167 
168 #endif // __VSDXPARSER_H__
169 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1.1