F:/KPlato/koffice/libs/kwmf/kwmf.h

Aller à la documentation de ce fichier.
00001 /*
00002     Copyright (C) 2000, S.R.Haque <shaheedhaque@hotmail.com>.
00003     This file is part of the KDE project
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     aS32 with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 
00020 DESCRIPTION
00021 
00022     This is a generic parser for Windows MetaFiles (WMFs). The output is
00023     a series of callbacks (a.k.a. virtual functions) which the caller can
00024     override as required.
00025 
00026     This is based on code originally written by Stefan Taferner
00027     (taferner@kde.org).
00028 */
00029 
00030 #ifndef KWMF_H
00031 #define KWMF_H
00032 
00033 #include <koffice_export.h>
00034 
00035 #include <QList>
00036 
00037 #include <q3valuestack.h>
00038 
00039 class QDataStream;
00040 class QPolygon;
00041 
00042 class KOWMF_EXPORT KWmf
00043 {
00044 public:
00045 
00046     // Construction.
00047 
00048     KWmf(
00049         unsigned dpi);
00050     virtual ~KWmf();
00051 
00052     // Called to parse the given file.
00053 
00054     bool parse(
00055         const QString &file);
00056     bool parse(
00057         QDataStream &stream,
00058         unsigned size);
00059 
00060     class KOWMF_EXPORT DrawContext
00061     {
00062     public:
00063         DrawContext();
00064         bool m_winding;
00065         unsigned m_brushColor;
00066         unsigned m_brushStyle;
00067         unsigned m_penColor;
00068         unsigned m_penStyle;
00069         unsigned m_penWidth;
00070     };
00071 
00072     // Should be protected...
00073 
00074     void brushSet(
00075         unsigned color,
00076         unsigned style);
00077     void penSet(
00078         unsigned color,
00079         unsigned style,
00080         unsigned width);
00081 
00082 protected:
00083     // Override to get results of parsing.
00084 
00085     virtual void gotEllipse(
00086         const DrawContext &dc,
00087         QString type,
00088         QPoint topLeft,
00089         QSize halfAxes,
00090         unsigned startAngle,
00091         unsigned stopAngle) = 0;
00092     virtual void gotPolygon(
00093         const DrawContext &dc,
00094         const QPolygon &points) = 0;
00095     virtual void gotPolyline(
00096         const DrawContext &dc,
00097         const QPolygon &points) = 0;
00098     virtual void gotRectangle(
00099         const DrawContext &dc,
00100         const QPolygon &points) = 0;
00101 
00102 private:
00103     // Debug support.
00104 
00105     static const int s_area;
00106 
00107     // Use unambiguous names for Microsoft types.
00108 
00109     typedef short S16;
00110     typedef int S32;
00111     typedef unsigned int U32;
00112 
00113     int m_dpi;
00114     int m_windowOrgX;
00115     int m_windowOrgY;
00116     int m_windowFlipX;
00117     int m_windowFlipY;
00118     DrawContext m_dc;
00119     Q3ValueStack<DrawContext> m_savedDcs;
00120     QPoint m_lineFrom;
00121 
00122     // Windows handle management.
00123 
00124     class WinObjHandle
00125     {
00126     public:
00127         virtual ~WinObjHandle () {}
00128         virtual void apply(KWmf &p) = 0;
00129     };
00130 
00131     class WinObjBrushHandle: public WinObjHandle
00132     {
00133     public:
00134         virtual void apply(KWmf &p);
00135         unsigned m_color;
00136         unsigned m_style;
00137     };
00138 
00139     class WinObjPenHandle: public WinObjHandle
00140     {
00141     public:
00142         virtual void apply(KWmf &p);
00143         unsigned m_color;
00144         unsigned m_style;
00145         unsigned m_width;
00146     };
00147 
00148     WinObjPenHandle *handleCreatePen(void);
00149     WinObjBrushHandle *handleCreateBrush(void);
00150     QList<WinObjHandle *>m_objectHandles;
00151 
00152     unsigned getColor(S32 color);
00153     QPoint normalisePoint(
00154         QDataStream &operands);
00155     QSize normaliseSize(
00156         QDataStream &operands);
00157     void genericArc(
00158         const QString &type,
00159         QDataStream &operands);
00160 
00161     // Opcode handling and painter methods.
00162 
00163     void walk(
00164         U32 words,
00165         QDataStream &stream);
00166     void skip(
00167         U32 words,
00168         QDataStream &operands);
00169     void invokeHandler(
00170         S16 opcode,
00171         U32 words,
00172         QDataStream &operands);
00173 /*
00174     // draw multiple polygons
00175     void opPolypolygon(U32 words, QDataStream &operands);
00176 */
00177     void opArc(U32 words, QDataStream &operands);
00178     // create a logical brush
00179     void opBrushCreateIndirect(U32 words, QDataStream &operands);
00180     void opEllipse(U32 words, QDataStream &operands);
00181     // draw line to coord
00182     void opLineTo(U32 words, QDataStream &operands);
00183     // move pen to coord
00184     void opMoveTo(U32 words, QDataStream &operands);
00185     // do nothing
00186     void opNoop(U32 words, QDataStream &operands);
00187     // Free object handle
00188     void opObjectDelete(U32 words, QDataStream &operands);
00189     // Activate object handle
00190     void opObjectSelect(U32 words, QDataStream &operands);
00191     // create a logical pen
00192     void opPenCreateIndirect(U32 words, QDataStream &operands);
00193     void opPie(U32 words, QDataStream &operands);
00194     // draw polygon
00195     void opPolygon(U32 words, QDataStream &operands);
00196     // set polygon fill mode
00197     void opPolygonSetFillMode(U32 words, QDataStream &operands);
00198     // draw series of lines
00199     void opPolyline(U32 words, QDataStream &operands);
00200     void opRectangle(U32 words, QDataStream &operands);
00201     // restore drawing context
00202     void opRestoreDc(U32 words, QDataStream &operands);
00203     // save drawing context
00204     void opSaveDc(U32 words, QDataStream &operands);
00205     // set window origin
00206     void opWindowSetOrg(U32 words, QDataStream &operands);
00207     // set window extents
00208     void opWindowSetExt(U32 words, QDataStream &operands);
00209 /*
00210     // set background pen color
00211     void opsetBkColor(U32 words, QDataStream &operands);
00212     // set background pen mode
00213     void opsetBkMode(U32 words, QDataStream &operands);
00214     // Set raster operation mode
00215     void opsetRop(U32 words, QDataStream &operands);
00216     // Escape (enhanced command set)
00217     void opescape(U32 words, QDataStream &operands);
00218 */
00219 };
00220 
00221 #endif

Généré le Wed Nov 22 23:41:13 2006 pour KPlato par  doxygen 1.5.1-p1