filters

wmfimportparser.h
1/* This file is part of the KDE project
2 * Copyright (c) 2003 thierry lorthiois (lorthioist@wanadoo.fr)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License version 2 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public License
14 * along with this library; see the file COPYING.LIB. If not, write to
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17*/
18#ifndef _WMFIMPORTPARSER_H_
19#define _WMFIMPORTPARSER_H_
20
21#include <tqpainter.h>
22#include <tqdom.h>
23#include <core/vdocument.h>
24#include <core/vcomposite.h>
25#include <kowmfread.h>
26
27
33
34class WMFImportParser : public KoWmfRead
35{
36public:
37 WMFImportParser();
38 ~WMFImportParser() { }
39
43 bool play( VDocument& doc );
44
45
46private:
47 // -------------------------------------------------------------------------
48 // A virtual TQPainter
49 bool begin();
50 bool end();
51 void save();
52 void restore();
53
54 // Drawing tools
55 void setFont( const TQFont &font );
56 // the pen : the width of the pen is in logical coordinate
57 void setPen( const TQPen &pen );
58 const TQPen &pen() const;
59 void setBrush( const TQBrush &brush );
60
61 // Drawing attributes/modes
62 void setBackgroundColor( const TQColor &c );
63 void setBackgroundMode( TQt::BGMode mode );
64 void setRasterOp( TQt::RasterOp op );
65
72 void setWindowOrg( int left, int top );
73 void setWindowExt( int width, int height );
74
75 // Clipping
76 // the 'CoordinateMode' is ommitted : always CoordPainter in wmf
77 // setClipRegion() is often used with save() and restore() => implement all or none
78 void setClipRegion( const TQRegion &rec );
79 TQRegion clipRegion();
80
81 // Graphics drawing functions
82 void moveTo( int x, int y );
83 void lineTo( int x, int y );
84 void drawRect( int x, int y, int w, int h );
85 void drawRoundRect( int x, int y, int w, int h, int = 25, int = 25 );
86 void drawEllipse( int x, int y, int w, int h );
87 void drawArc( int x, int y, int w, int h, int a, int alen );
88 void drawPie( int x, int y, int w, int h, int a, int alen );
89 void drawChord( int x, int y, int w, int h, int a, int alen );
90 void drawPolyline( const TQPointArray &pa );
91 void drawPolygon( const TQPointArray &pa, bool winding=false );
96 void drawPolyPolygon( TQPtrList<TQPointArray>& listPa, bool winding=false );
97 void drawImage( int x, int y, const TQImage &, int sx = 0, int sy = 0, int sw = -1, int sh = -1 );
98
99 // Text drawing
100 // rotation = the degrees of rotation in counterclockwise
101 // not yet implemented in KWinMetaFile
102 void drawText( int x, int y, int w, int h, int flags, const TQString &s, double rotation );
103
104 // matrix transformation : only used in some bitmap manipulation
105 void setWorldMatrix( const TQWMatrix &, bool combine=false );
106
107 //-----------------------------------------------------------------------------
108 // Utilities
109 // Add pen, brush and points to a path
110 void appendPen( VObject& obj );
111 void appendBrush( VObject& obj );
112 void appendPoints(VPath& path, const TQPointArray& pa);
113 // coordinate transformation
114 // translate wmf to (0,0) -> scale to document size -> translate to karbon (0,0)
115 // Wmf origin is (left,top) corner
116 // Karbon origin is (left,bottom) corner
117 double coordX( int left )
118 { return ((double)(left - mCurrentOrg.x()) * mScaleX); }
119 double coordY( int top )
120 { return (mDoc->height() - ((double)(top - mCurrentOrg.y()) * mScaleY)); }
121 double scaleW( int width )
122 { return (width * mScaleX); }
123 double scaleH( int height )
124 { return (height * mScaleY); }
125
126private:
127 VDocument *mDoc;
128 TQRegion mClippingRegion;
129 TQPen mPen;
130 TQBrush mBrush;
131 TQt::BGMode mBackgroundMode;
132 TQColor mBackgroundColor;
133 // current origin of WMF logical coordinate
134 TQPoint mCurrentOrg;
135 double mScaleX;
136 double mScaleY;
137 // current position in WMF coordinate (INT16)
138 TQPoint mCurrentPoint;
139};
140
141#endif
bool play(VDocument &doc)
play WMF file on a VDocument.