1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
/* This file is part of the KDE libraries
* Copyright (c) 1998 Stefan Taferner
* 2001/2003 thierry lorthiois (lorthioist@wanadoo.fr)
* With the help of WMF documentation by Caolan Mc Namara
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _KOWMFREADPRIVATE_H_
#define _KOWMFREADPRIVATE_H_
#include <tqpen.h>
#include <tqcolor.h>
#include <tqfont.h>
#include <tqrect.h>
#include <tqregion.h>
#include <tqbuffer.h>
#include <tqstring.h>
#include "kowmfstruct.h"
#include "kowmfstack.h"
class KoWmfRead;
/**
* KoWmfReadPrivate allows to read WMF files
*
*/
class KoWmfReadPrivate
{
public:
KoWmfReadPrivate();
virtual ~KoWmfReadPrivate();
/**
* Load WMF file. Returns true on success.
*/
bool load( const TQByteArray& array );
/**
* Plays a metafile in @p readKwmf and returns true on success.
* To draw on a device you have to inherit the class ReadKwmf
*/
bool play( KoWmfRead* readKwmf );
/* Metafile painter methods */
/// set window origin
void setWindowOrg( TQ_UINT32 size, TQDataStream& stream );
/// set window extents
void setWindowExt( TQ_UINT32 size, TQDataStream& stream );
/// scale window extents
void ScaleWindowExt( TQ_UINT32, TQDataStream& stream );
/// offset in window origin
void OffsetWindowOrg( TQ_UINT32, TQDataStream& stream );
/****************** Drawing *******************/
/// draw line to coord
void lineTo( TQ_UINT32 size, TQDataStream& stream );
/// move pen to coord
void moveTo( TQ_UINT32 size, TQDataStream& stream );
/// draw ellipse
void ellipse( TQ_UINT32 size, TQDataStream& stream );
/// draw polygon
void polygon( TQ_UINT32 size, TQDataStream& stream );
/// draw a list of polygons
void polyPolygon( TQ_UINT32 size, TQDataStream& stream );
/// draw series of lines
void polyline( TQ_UINT32 size, TQDataStream& stream );
/// draw a rectangle
void rectangle( TQ_UINT32 size, TQDataStream& stream );
/// draw round rectangle
void roundRect( TQ_UINT32 size, TQDataStream& stream );
/// draw arc
void arc( TQ_UINT32 size, TQDataStream& stream );
/// draw chord
void chord( TQ_UINT32 size, TQDataStream& stream );
/// draw pie
void pie( TQ_UINT32 size, TQDataStream& stream );
/// set polygon fill mode
void setPolyFillMode( TQ_UINT32 size, TQDataStream& stream );
/// set background pen color
void setBkColor( TQ_UINT32 size, TQDataStream& stream );
/// set background pen mode
void setBkMode( TQ_UINT32 size, TQDataStream& stream );
/// set a pixel
void setPixel( TQ_UINT32 size, TQDataStream& stream );
/// set raster operation mode
void setRop( TQ_UINT32 size, TQDataStream& stream );
/// save device context */
void saveDC( TQ_UINT32 size, TQDataStream& stream );
/// restore device context
void restoreDC( TQ_UINT32 size, TQDataStream& stream );
/// clipping region is the intersection of this region and the original region
void intersectClipRect( TQ_UINT32 size, TQDataStream& stream );
/// delete a clipping rectangle of the original region
void excludeClipRect( TQ_UINT32 size, TQDataStream& stream );
/****************** Text *******************/
/// set text color
void setTextColor( TQ_UINT32 size, TQDataStream& stream );
/// set text alignment
void setTextAlign( TQ_UINT32 size, TQDataStream& stream );
/// draw text
void textOut( TQ_UINT32 size, TQDataStream& stream );
void extTextOut( TQ_UINT32 size, TQDataStream& stream );
/****************** Bitmap *******************/
void SetStretchBltMode( TQ_UINT32, TQDataStream& stream );
/// copies a DIB into a dest location
void dibBitBlt( TQ_UINT32 size, TQDataStream& stream );
/// stretches a DIB into a dest location
void dibStretchBlt( TQ_UINT32 size, TQDataStream& stream );
void stretchDib( TQ_UINT32 size, TQDataStream& stream );
/// create a pattern brush
void dibCreatePatternBrush( TQ_UINT32 size, TQDataStream& stream );
/****************** Object handle *******************/
/// activate object handle
void selectObject( TQ_UINT32 size, TQDataStream& stream );
/// free object handle
void deleteObject( TQ_UINT32 size, TQDataStream& stream );
/// create an empty object in the object list
void createEmptyObject();
/// create a logical brush
void createBrushIndirect( TQ_UINT32 size, TQDataStream& stream );
/// create a logical pen
void createPenIndirect( TQ_UINT32 size, TQDataStream& stream );
/// create a logical font
void createFontIndirect( TQ_UINT32 size, TQDataStream& stream );
/****************** misc *******************/
/// end of meta file
void end( TQ_UINT32, TQDataStream& stream );
/** Calculate header checksum */
static TQ_UINT16 calcCheckSum( WmfPlaceableHeader* );
// function unimplemented
void notyet( TQ_UINT32, TQDataStream& stream );
void region( TQ_UINT32, TQDataStream& stream );
void palette( TQ_UINT32, TQDataStream& stream );
void escape( TQ_UINT32, TQDataStream& stream );
void setRelAbs( TQ_UINT32, TQDataStream& stream );
void setMapMode( TQ_UINT32, TQDataStream& stream );
void extFloodFill( TQ_UINT32, TQDataStream& stream );
void startDoc( TQ_UINT32, TQDataStream& stream );
void startPage( TQ_UINT32, TQDataStream& stream );
void endDoc( TQ_UINT32, TQDataStream& stream );
void endPage( TQ_UINT32, TQDataStream& stream );
void resetDC( TQ_UINT32, TQDataStream& stream );
void bitBlt( TQ_UINT32, TQDataStream& stream );
void setDibToDev( TQ_UINT32, TQDataStream& stream );
void createBrush( TQ_UINT32, TQDataStream& stream );
void createPatternBrush( TQ_UINT32, TQDataStream& stream );
void createBitmap( TQ_UINT32, TQDataStream& stream );
void createBitmapIndirect( TQ_UINT32, TQDataStream& stream );
void createPalette( TQ_UINT32, TQDataStream& stream );
void createRegion( TQ_UINT32, TQDataStream& stream );
private:
//-----------------------------------------------------------------------------
// Utilities and conversion Wmf -> TQt
/** Handle win-object-handles */
bool addHandle( KoWmfHandle* );
void deleteHandle( int );
/** Convert TQINT16 points into TQPointArray */
void pointArray( TQDataStream& stream, TQPointArray& pa );
/** Convertion between windows color and TQColor */
TQColor qtColor( TQ_UINT32 color ) const
{ return TQColor( color & 0xFF, (color>>8) & 0xFF, (color>>16) & 0xFF ); }
/** Convert (x1,y1) and (x2, y2) positions in angle and angleLength */
void xyToAngle( int xStart, int yStart, int xEnd, int yEnd, int& angle, int& aLength );
/** Convert windows rasterOp in QT rasterOp */
TQt::RasterOp winToTQtRaster( TQ_UINT16 param ) const;
TQt::RasterOp winToTQtRaster( TQ_UINT32 param ) const;
/** Converts DIB to BMP */
bool dibToBmp( TQImage& bmp, TQDataStream& stream, TQ_UINT32 size);
public:
// state of the WMF
bool mValid;
bool mStandard;
bool mPlaceable;
bool mEnhanced;
/// bounding rectangle
TQRect mBBox; // placeable file : this is the header
// standard file : this is the value in setWindowOrg and setWindowExt
/// number of points per inch for the default size
int mDpi;
/// number of functions to draw (==0 for all)
int mNbrFunc;
private:
// the output
KoWmfRead *mReadWmf;
// current coordinate != mBBox
TQRect mWindow;
// current state of the drawing
TQColor mTextColor;
TQ_UINT16 mTextAlign;
int mTextRotation;
bool mWinding;
// memory allocation for WMF file
TQBuffer* mBuffer;
int mOffsetFirstRecord;
// stack of object handle
KoWmfHandle** mObjHandleTab;
// number of object on the stack
int mNbrObject;
bool mStackOverflow;
};
/**
* static data
*/
static const struct KoWmfFunc {
void ( KoWmfReadPrivate::*method )( TQ_UINT32, TQDataStream& );
} koWmfFunc[] = {
{ &KoWmfReadPrivate::end }, // 0
{ &KoWmfReadPrivate::setBkColor }, // 1
{ &KoWmfReadPrivate::setBkMode }, // 2
{ &KoWmfReadPrivate::setMapMode }, // 3
{ &KoWmfReadPrivate::setRop }, // 4
{ &KoWmfReadPrivate::setRelAbs }, // 5
{ &KoWmfReadPrivate::setPolyFillMode }, // 6
{ &KoWmfReadPrivate::SetStretchBltMode }, // 7
{ &KoWmfReadPrivate::notyet }, // 8
{ &KoWmfReadPrivate::setTextColor }, // 9
{ &KoWmfReadPrivate::ScaleWindowExt }, // 10
{ &KoWmfReadPrivate::setWindowOrg }, // 11
{ &KoWmfReadPrivate::setWindowExt }, // 12
{ &KoWmfReadPrivate::notyet }, // 13
{ &KoWmfReadPrivate::notyet }, // 14
{ &KoWmfReadPrivate::OffsetWindowOrg }, // 15
{ &KoWmfReadPrivate::notyet }, // 16
{ &KoWmfReadPrivate::notyet }, // 17
{ &KoWmfReadPrivate::notyet }, // 18
{ &KoWmfReadPrivate::lineTo }, // 19
{ &KoWmfReadPrivate::moveTo }, // 20
{ &KoWmfReadPrivate::excludeClipRect }, // 21
{ &KoWmfReadPrivate::intersectClipRect }, // 22
{ &KoWmfReadPrivate::arc }, // 23
{ &KoWmfReadPrivate::ellipse }, // 24
{ &KoWmfReadPrivate::notyet }, // 25
{ &KoWmfReadPrivate::pie }, // 26
{ &KoWmfReadPrivate::rectangle }, // 27
{ &KoWmfReadPrivate::roundRect }, // 28
{ &KoWmfReadPrivate::notyet }, // 29
{ &KoWmfReadPrivate::saveDC }, // 30
{ &KoWmfReadPrivate::setPixel }, // 31
{ &KoWmfReadPrivate::notyet }, // 32
{ &KoWmfReadPrivate::textOut }, // 33
{ &KoWmfReadPrivate::bitBlt }, // 34
{ &KoWmfReadPrivate::notyet }, // 35
{ &KoWmfReadPrivate::polygon }, // 36
{ &KoWmfReadPrivate::polyline }, // 37
{ &KoWmfReadPrivate::escape }, // 38
{ &KoWmfReadPrivate::restoreDC }, // 39
{ &KoWmfReadPrivate::region }, // 40
{ &KoWmfReadPrivate::region }, // 41
{ &KoWmfReadPrivate::region }, // 42
{ &KoWmfReadPrivate::region }, // 43
{ &KoWmfReadPrivate::region }, // 44
{ &KoWmfReadPrivate::selectObject }, // 45
{ &KoWmfReadPrivate::setTextAlign }, // 46
{ 0 }, // 47
{ &KoWmfReadPrivate::chord }, // 48
{ &KoWmfReadPrivate::notyet }, // 49
{ &KoWmfReadPrivate::extTextOut }, // 50
{ &KoWmfReadPrivate::setDibToDev }, // 51
{ &KoWmfReadPrivate::palette }, // 52
{ &KoWmfReadPrivate::palette }, // 53
{ &KoWmfReadPrivate::palette }, // 54
{ &KoWmfReadPrivate::palette }, // 55
{ &KoWmfReadPrivate::polyPolygon }, // 56
{ &KoWmfReadPrivate::palette }, // 57
{ 0 }, // 58
{ 0 }, // 59
{ 0 }, // 60
{ 0 }, // 61
{ 0 }, // 62
{ 0 }, // 63
{ &KoWmfReadPrivate::dibBitBlt }, // 64
{ &KoWmfReadPrivate::dibStretchBlt }, // 65
{ &KoWmfReadPrivate::dibCreatePatternBrush }, // 66
{ &KoWmfReadPrivate::stretchDib }, // 67
{ 0 }, // 68
{ 0 }, // 69
{ 0 }, // 70
{ 0 }, // 71
{ &KoWmfReadPrivate::extFloodFill }, // 72
{ 0 }, // 73
{ 0 }, // 74
{ 0 }, // 75
{ &KoWmfReadPrivate::resetDC }, // 76
{ &KoWmfReadPrivate::startDoc }, // 77
{ 0 }, // 78
{ &KoWmfReadPrivate::startPage }, // 79
{ &KoWmfReadPrivate::endPage }, // 80
{ 0 }, // 81
{ 0 }, // 82
{ 0 }, // 83
{ 0 }, // 84
{ 0 }, // 85
{ 0 }, // 86
{ 0 }, // 87
{ 0 }, // 88
{ 0 }, // 89
{ 0 }, // 90
{ 0 }, // 91
{ 0 }, // 92
{ 0 }, // 93
{ &KoWmfReadPrivate::endDoc }, // 94
{ 0 }, // 95
// 0x5F last function until 0xF0
{ &KoWmfReadPrivate::deleteObject }, // 96
{ 0 }, // 97
{ 0 }, // 98
{ 0 }, // 99
{ 0 }, // 100
{ 0 }, // 101
{ 0 }, // 102
{ &KoWmfReadPrivate::createPalette }, // 103
{ &KoWmfReadPrivate::createBrush }, // 104
{ &KoWmfReadPrivate::createPatternBrush }, // 105
{ &KoWmfReadPrivate::createPenIndirect }, // 106
{ &KoWmfReadPrivate::createFontIndirect }, // 107
{ &KoWmfReadPrivate::createBrushIndirect }, //108
{ &KoWmfReadPrivate::createBitmapIndirect }, //109
{ &KoWmfReadPrivate::createBitmap }, // 110
{ &KoWmfReadPrivate::createRegion } // 111
};
#endif
|