00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00047
00048 KWmf(
00049 unsigned dpi);
00050 virtual ~KWmf();
00051
00052
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
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
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
00104
00105 static const int s_area;
00106
00107
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
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
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
00175
00176
00177 void opArc(U32 words, QDataStream &operands);
00178
00179 void opBrushCreateIndirect(U32 words, QDataStream &operands);
00180 void opEllipse(U32 words, QDataStream &operands);
00181
00182 void opLineTo(U32 words, QDataStream &operands);
00183
00184 void opMoveTo(U32 words, QDataStream &operands);
00185
00186 void opNoop(U32 words, QDataStream &operands);
00187
00188 void opObjectDelete(U32 words, QDataStream &operands);
00189
00190 void opObjectSelect(U32 words, QDataStream &operands);
00191
00192 void opPenCreateIndirect(U32 words, QDataStream &operands);
00193 void opPie(U32 words, QDataStream &operands);
00194
00195 void opPolygon(U32 words, QDataStream &operands);
00196
00197 void opPolygonSetFillMode(U32 words, QDataStream &operands);
00198
00199 void opPolyline(U32 words, QDataStream &operands);
00200 void opRectangle(U32 words, QDataStream &operands);
00201
00202 void opRestoreDc(U32 words, QDataStream &operands);
00203
00204 void opSaveDc(U32 words, QDataStream &operands);
00205
00206 void opWindowSetOrg(U32 words, QDataStream &operands);
00207
00208 void opWindowSetExt(U32 words, QDataStream &operands);
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 };
00220
00221 #endif