filters

wmfimportparser.h

00001 /* This file is part of the KDE project
00002  * Copyright (c) 2003 thierry lorthiois (lorthioist@wanadoo.fr)
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License version 2 as published by the Free Software Foundation.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017 */
00018 #ifndef _WMFIMPORTPARSER_H_
00019 #define _WMFIMPORTPARSER_H_
00020 
00021 #include <qpainter.h>
00022 #include <qdom.h>
00023 #include <core/vdocument.h>
00024 #include <core/vcomposite.h>
00025 #include <kowmfread.h>
00026 
00027 
00034 class WMFImportParser : public KoWmfRead
00035 {
00036 public:
00037     WMFImportParser();
00038     ~WMFImportParser() { }
00039 
00043     bool play( VDocument& doc );
00044 
00045 
00046 private:
00047     // -------------------------------------------------------------------------
00048     // A virtual QPainter 
00049     bool  begin();
00050     bool  end();
00051     void  save();
00052     void  restore();
00053 
00054     // Drawing tools
00055     void  setFont( const QFont &font );
00056     // the pen : the width of the pen is in logical coordinate
00057     void  setPen( const QPen &pen );
00058     const QPen &pen() const;
00059     void  setBrush( const QBrush &brush );
00060 
00061     // Drawing attributes/modes
00062     void  setBackgroundColor( const QColor &c );
00063     void  setBackgroundMode( Qt::BGMode mode );
00064     void  setRasterOp( Qt::RasterOp op );
00065 
00072     void  setWindowOrg( int left, int top );
00073     void  setWindowExt( int width, int height );
00074     
00075     // Clipping
00076     // the 'CoordinateMode' is ommitted : always CoordPainter in wmf
00077     // setClipRegion() is often used with save() and restore() => implement all or none
00078     void  setClipRegion( const QRegion &rec );
00079     QRegion clipRegion();
00080 
00081     // Graphics drawing functions
00082     void  moveTo( int x, int y );
00083     void  lineTo( int x, int y );
00084     void  drawRect( int x, int y, int w, int h );
00085     void  drawRoundRect( int x, int y, int w, int h, int = 25, int = 25 );
00086     void  drawEllipse( int x, int y, int w, int h );
00087     void  drawArc( int x, int y, int w, int h, int a, int alen );
00088     void  drawPie( int x, int y, int w, int h, int a, int alen );
00089     void  drawChord( int x, int y, int w, int h, int a, int alen );
00090     void  drawPolyline( const QPointArray &pa );
00091     void  drawPolygon( const QPointArray &pa, bool winding=FALSE );
00096     void  drawPolyPolygon( QPtrList<QPointArray>& listPa, bool winding=FALSE );
00097     void  drawImage( int x, int y, const QImage &, int sx = 0, int sy = 0, int sw = -1, int sh = -1 );
00098 
00099     // Text drawing 
00100     // rotation = the degrees of rotation in counterclockwise
00101     // not yet implemented in KWinMetaFile
00102     void  drawText( int x, int y, int w, int h, int flags, const QString &s, double rotation );
00103 
00104     // matrix transformation : only used in some bitmap manipulation
00105     void  setWorldMatrix( const QWMatrix &, bool combine=FALSE );
00106 
00107     //-----------------------------------------------------------------------------
00108     // Utilities 
00109     // Add pen, brush and points to a path
00110     void appendPen( VObject& obj );
00111     void appendBrush( VObject& obj );
00112     void appendPoints(VPath& path, const QPointArray& pa);
00113     // coordinate transformation
00114     // translate wmf to (0,0) -> scale to document size -> translate to karbon (0,0)
00115     // Wmf origin is (left,top) corner
00116     // Karbon origin is (left,bottom) corner
00117     double coordX( int left ) 
00118             { return ((double)(left - mCurrentOrg.x()) * mScaleX); }
00119     double coordY( int top ) 
00120             { return (mDoc->height() - ((double)(top - mCurrentOrg.y()) * mScaleY)); }
00121     double scaleW( int width ) 
00122             { return (width * mScaleX); }
00123     double scaleH( int height ) 
00124             { return (height * mScaleY); }
00125 
00126 private:
00127     VDocument *mDoc;
00128     QRegion   mClippingRegion;
00129     QPen      mPen;
00130     QBrush    mBrush;
00131     Qt::BGMode mBackgroundMode;
00132     QColor    mBackgroundColor;
00133     // current origin of WMF logical coordinate
00134     QPoint    mCurrentOrg;
00135     double    mScaleX;
00136     double    mScaleY;
00137     // current position in WMF coordinate (INT16)
00138     QPoint    mCurrentPoint;
00139 };
00140 
00141 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys