WPG2Parser.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* libwpg
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Major Contributor(s):
10 * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
11 * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
12 * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
13 *
14 * For minor contributions see the git repository.
15 *
16 * Alternatively, the contents of this file may be used under the terms
17 * of the GNU Lesser General Public License Version 2.1 or later
18 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19 * applicable instead of those above.
20 *
21 * For further information visit http://libwpg.sourceforge.net
22 */
23
24/* "This product is not manufactured, approved, or supported by
25 * Corel Corporation or Corel Corporation Limited."
26 */
27
28#ifndef __WPG2PARSER_H__
29#define __WPG2PARSER_H__
30
31#include "WPGXParser.h"
32#include "WPGDashArray.h"
33#include "WPGBitmap.h"
34#include <librevenge/librevenge.h>
35
36#include <map>
37#include <stack>
38#include <vector>
39
41{
42public:
43 double element[3][3];
44
46 {
47 // identity transformation
48 element[0][0] = element[1][1] = 1;
49 element[2][2] = 1;
50 element[0][1] = element[0][2] = 0;
51 element[1][0] = element[1][2] = 0;
52 element[2][0] = element[2][1] = 0;
53 }
54
55 void transform(long &x, long &y) const
56 {
57 long rx = (long)(element[0][0]*x + element[1][0]*y + element[2][0]);
58 long ry = (long)(element[0][1]*x + element[1][1]*y + element[2][1]);
59 x = rx;
60 y = ry;
61 }
62
63 ::librevenge::RVNGPropertyList transformPoint(const ::librevenge::RVNGPropertyList &p) const
64 {
65 ::librevenge::RVNGPropertyList propList;
66 propList.insert("svg:x", (element[0][0]*p["svg:x"]->getDouble() + element[1][0]*p["svg:y"]->getDouble() + element[2][0]));
67 propList.insert("svg:y", (element[0][1]*p["svg:x"]->getDouble() + element[1][1]*p["svg:y"]->getDouble() + element[2][1]));
68 return propList;
69 }
70
71 ::librevenge::RVNGPropertyList transformRect(const ::librevenge::RVNGPropertyList &r) const
72 {
73 ::librevenge::RVNGPropertyList propList;
74 double oldx1 = r["svg:x"]->getDouble();
75 double oldy1 = r["svg:y"]->getDouble();
76 double oldx2 = r["svg:x"]->getDouble() + r["svg:width"]->getDouble();
77 double oldy2 = r["svg:y"]->getDouble() + r["svg:height"]->getDouble();
78
79 double newx1 = element[0][0]*oldx1 + element[1][0]*oldy1 + element[2][0];
80 double newy1 = element[0][1]*oldx1 + element[1][1]*oldy1 + element[2][1];
81 double newx2 = element[0][0]*oldx2 + element[1][0]*oldy2 + element[2][0];
82 double newy2 = element[0][1]*oldx2 + element[1][1]*oldy2 + element[2][1];
83
84 propList.insert("svg:x", (double)newx1);
85 propList.insert("svg:y", (double)newy1);
86 propList.insert("svg:width", (newx2-newx1));
87 propList.insert("svg:height", (newy2-newy1));
88 return propList;
89 }
90
92 {
93 double result[3][3];
94
95 for (int i = 0; i < 3; i++)
96 for (int j = 0; j < 3; j++)
97 {
98 result[i][j] = 0;
99 for (int k = 0; k < 3; k++)
100 result[i][j] += m.element[i][k]*element[k][j];
101 }
102
103 for (int x = 0; x < 3; x++)
104 for (int y = 0; y < 3; y++)
105 element[x][y] = result[x][y];
106
107 return *this;
108 }
109};
110
121
123{
124public:
125 unsigned subIndex;
127 ::librevenge::RVNGPropertyListVector compoundPath;
133
137
138 bool isCompoundPolygon() const
139 {
140 return parentType == 0x1a;
141 }
142};
143
145{
146public:
147 double x1, y1, x2, y2;
148 long hres, vres;
149 WPGBitmapContext(): x1(0), y1(0), x2(0), y2(0), hres(100), vres(100) {}
150};
151
153{
154public:
155 double x1, y1, x2, y2;
157 std::vector<librevenge::RVNGString> mimeTypes;
159};
160
162{
163public:
164 double x1, y1, x2, y2;
165 unsigned short flags;
166 unsigned char vertAlign;
167 unsigned char horAlign;
169 WPGTextDataContext(): x1(0), y1(0), x2(0), y2(0), flags(), vertAlign(), horAlign(), baseLineAngle(0.0) {}
170};
171
172class WPG2Parser : public WPGXParser
173{
174public:
175 WPG2Parser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, bool isEmbedded = false);
176 bool parse();
177
178private:
179 void handleStartWPG();
180 void handleEndWPG();
181 void handleFormSettings();
182 void handleLayer();
184
186// void handlePatternDefinition();
187 void handleColorPalette();
189 void handlePenForeColor();
191 void handlePenBackColor();
193 void handlePenStyle();
194 void handlePenSize();
195 void handleDPPenSize();
196 void handleLineCap();
197 void handleLineJoin();
198 void handleBrushGradient();
204 void handleBrushPattern();
205
206 void handlePolyline();
207 void handlePolyspline();
208 void handlePolycurve();
209 void handleRectangle();
210 void handleArc();
211
212 void handleBitmap();
213 void handleBitmapData();
214
215 void handleTextData();
216 void handleTextLine();
217 void handleTextBlock();
218 void handleTextPath();
219
220 void handleObjectCapsule();
221 void handleObjectImage();
222
223 void resetPalette();
225 void setPenStyle();
226
227 unsigned int getRemainingRecordLength() const;
228 bool checkRLESize(unsigned bytes) const;
229
230 // parsing context
234 bool m_exit;
236 unsigned int m_xres;
237 unsigned int m_yres;
238 long m_xofs;
239 long m_yofs;
243 ::librevenge::RVNGPropertyList m_style;
249 ::librevenge::RVNGPropertyListVector m_gradient;
250 std::map<unsigned int,libwpg::WPGDashArray> m_dashArrayStyles;
252#ifdef DEBUG
253 unsigned int m_layerId;
254#endif
257 ::librevenge::RVNGPropertyList m_gradientRef;
258 std::stack<WPGGroupContext> m_groupStack;
269
272#if DUMP_BINARY_DATA
273 unsigned m_binaryId;
274#endif
275};
276
277#endif // __WPG2PARSER_H__
278/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
Definition WPG2Parser.cpp:175
Definition WPG2Parser.h:173
void handleDPBrushForeColor()
Definition WPG2Parser.cpp:1167
WPGTextDataContext m_textData
Definition WPG2Parser.h:267
bool m_compoundFramed
Definition WPG2Parser.h:262
WPGBitmapContext m_bitmap
Definition WPG2Parser.h:264
void handleLineCap()
Definition WPG2Parser.cpp:974
long m_width
Definition WPG2Parser.h:240
void handleRectangle()
Definition WPG2Parser.cpp:1609
void handleObjectCapsule()
Definition WPG2Parser.cpp:2168
bool parse()
Definition WPG2Parser.cpp:293
void parseCharacterization(ObjectCharacterization *)
Definition WPG2Parser.cpp:1330
long m_xofs
Definition WPG2Parser.h:238
void handleBrushGradient()
Definition WPG2Parser.cpp:1002
void handleBrushBackColor()
Definition WPG2Parser.cpp:1263
WPG2TransformMatrix m_matrix
Definition WPG2Parser.h:255
void handlePolyline()
Definition WPG2Parser.cpp:1416
void handleDPColorPalette()
Definition WPG2Parser.cpp:793
bool m_vFlipped
Definition WPG2Parser.h:266
std::stack< WPGGroupContext > m_groupStack
Definition WPG2Parser.h:258
::librevenge::RVNGPropertyListVector m_gradient
Definition WPG2Parser.h:249
void flushCompoundPolygon()
Definition WPG2Parser.cpp:706
void handleDPPenForeColor()
Definition WPG2Parser.cpp:833
unsigned int m_xres
Definition WPG2Parser.h:236
void handleTextLine()
Definition WPG2Parser.cpp:2302
void handlePolyspline()
Definition WPG2Parser.cpp:1510
bool m_graphicsStarted
Definition WPG2Parser.h:235
void handleBitmap()
Definition WPG2Parser.cpp:1748
void handlePenSize()
Definition WPG2Parser.cpp:937
void handleBrushForeColor()
Definition WPG2Parser.cpp:1072
void handleTextData()
Definition WPG2Parser.cpp:2384
void handleEndWPG()
Definition WPG2Parser.cpp:640
int m_recordLength
Definition WPG2Parser.h:231
void handleArc()
Definition WPG2Parser.cpp:1662
void handleStartWPG()
Definition WPG2Parser.cpp:533
void handlePenStyleDefinition()
Definition WPG2Parser.cpp:739
void handlePenStyle()
Definition WPG2Parser.cpp:912
bool m_layerOpened
Definition WPG2Parser.h:251
bool m_drawTextData
Definition WPG2Parser.h:268
bool m_compoundWindingRule
Definition WPG2Parser.h:260
void handleCompoundPolygon()
Definition WPG2Parser.cpp:692
void handleDPBrushGradient()
Definition WPG2Parser.cpp:1037
bool m_success
Definition WPG2Parser.h:233
void handlePenForeColor()
Definition WPG2Parser.cpp:812
void handleTextPath()
Definition WPG2Parser.cpp:2376
unsigned int m_yres
Definition WPG2Parser.h:237
libwpg::WPGDashArray m_dashArray
Definition WPG2Parser.h:248
void handleLayer()
Definition WPG2Parser.cpp:675
libwpg::WPGColor m_brushBackColor
Definition WPG2Parser.h:247
long m_yofs
Definition WPG2Parser.h:239
unsigned int getRemainingRecordLength() const
Definition WPG2Parser.cpp:2428
bool m_compoundFilled
Definition WPG2Parser.h:261
libwpg::WPGColor m_brushForeColor
Definition WPG2Parser.h:246
void handleBrushPattern()
Definition WPG2Parser.cpp:1310
void handleLineJoin()
Definition WPG2Parser.cpp:988
void handleBitmapData()
Definition WPG2Parser.cpp:1798
void handleDPPenSize()
Definition WPG2Parser.cpp:955
long m_recordEnd
Definition WPG2Parser.h:232
bool m_compoundClosed
Definition WPG2Parser.h:263
void resetPalette()
Definition WPG2Parser.cpp:2415
double m_gradientAngle
Definition WPG2Parser.h:256
::librevenge::RVNGPropertyList m_style
Definition WPG2Parser.h:243
void setPenStyle()
Definition WPG2Parser.cpp:898
void handleTextBlock()
Definition WPG2Parser.cpp:2339
void handleColorPalette()
Definition WPG2Parser.cpp:774
WPGBinaryDataContext m_binaryData
Definition WPG2Parser.h:265
bool m_doublePrecision
Definition WPG2Parser.h:242
void handlePolycurve()
Definition WPG2Parser.cpp:1523
libwpg::WPGColor m_penForeColor
Definition WPG2Parser.h:244
long m_height
Definition WPG2Parser.h:241
void handleFormSettings()
Definition WPG2Parser.cpp:653
::librevenge::RVNGPropertyList m_gradientRef
Definition WPG2Parser.h:257
WPG2TransformMatrix m_compoundMatrix
Definition WPG2Parser.h:259
void handleDPPenBackColor()
Definition WPG2Parser.cpp:877
void handleDPBrushBackColor()
Definition WPG2Parser.cpp:1285
bool m_hFlipped
Definition WPG2Parser.h:266
std::map< unsigned int, libwpg::WPGDashArray > m_dashArrayStyles
Definition WPG2Parser.h:250
libwpg::WPGColor m_penBackColor
Definition WPG2Parser.h:245
void handleObjectImage()
Definition WPG2Parser.cpp:2258
bool m_exit
Definition WPG2Parser.h:234
bool checkRLESize(unsigned bytes) const
Definition WPG2Parser.cpp:2435
void handlePenBackColor()
Definition WPG2Parser.cpp:857
Definition WPG2Parser.h:41
WPG2TransformMatrix & transformBy(const WPG2TransformMatrix &m)
Definition WPG2Parser.h:91
::librevenge::RVNGPropertyList transformPoint(const ::librevenge::RVNGPropertyList &p) const
Definition WPG2Parser.h:63
void transform(long &x, long &y) const
Definition WPG2Parser.h:55
double element[3][3]
Definition WPG2Parser.h:43
WPG2TransformMatrix()
Definition WPG2Parser.h:45
::librevenge::RVNGPropertyList transformRect(const ::librevenge::RVNGPropertyList &r) const
Definition WPG2Parser.h:71
Definition WPG2Parser.h:153
int numObjects
Definition WPG2Parser.h:156
double y1
Definition WPG2Parser.h:155
double x2
Definition WPG2Parser.h:155
double x1
Definition WPG2Parser.h:155
std::vector< librevenge::RVNGString > mimeTypes
Definition WPG2Parser.h:157
WPGBinaryDataContext()
Definition WPG2Parser.h:158
double y2
Definition WPG2Parser.h:155
int objectIndex
Definition WPG2Parser.h:156
Definition WPG2Parser.h:145
double y2
Definition WPG2Parser.h:147
double y1
Definition WPG2Parser.h:147
long vres
Definition WPG2Parser.h:148
double x1
Definition WPG2Parser.h:147
double x2
Definition WPG2Parser.h:147
WPGBitmapContext()
Definition WPG2Parser.h:149
long hres
Definition WPG2Parser.h:148
Definition WPG2Parser.h:112
bool isFilled
Definition WPG2Parser.h:115
WPGCompoundPolygon()
Definition WPG2Parser.h:119
bool isClosed
Definition WPG2Parser.h:117
WPG2TransformMatrix matrix
Definition WPG2Parser.h:114
bool isFramed
Definition WPG2Parser.h:116
Definition WPG2Parser.h:123
WPG2TransformMatrix compoundMatrix
Definition WPG2Parser.h:128
bool compoundFilled
Definition WPG2Parser.h:130
::librevenge::RVNGPropertyListVector compoundPath
Definition WPG2Parser.h:127
bool isCompoundPolygon() const
Definition WPG2Parser.h:138
unsigned subIndex
Definition WPG2Parser.h:125
bool compoundWindingRule
Definition WPG2Parser.h:129
bool compoundFramed
Definition WPG2Parser.h:131
WPGGroupContext()
Definition WPG2Parser.h:134
bool compoundClosed
Definition WPG2Parser.h:132
int parentType
Definition WPG2Parser.h:126
Definition WPG2Parser.h:162
double baseLineAngle
Definition WPG2Parser.h:168
double y2
Definition WPG2Parser.h:164
double x1
Definition WPG2Parser.h:164
double y1
Definition WPG2Parser.h:164
unsigned char horAlign
Definition WPG2Parser.h:167
double x2
Definition WPG2Parser.h:164
unsigned char vertAlign
Definition WPG2Parser.h:166
WPGTextDataContext()
Definition WPG2Parser.h:169
unsigned short flags
Definition WPG2Parser.h:165
Definition WPGXParser.h:39
Definition WPGColor.h:35
Definition WPGDashArray.h:35

Generated for libwpg by doxygen 1.9.8