/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is QWMF - Qt WMF export class. * * The Initial Developer of the Original Code is * Tobias Burnus . * Portions created by the Initial Developer are Copyright (C) 2004 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /* Credits: * This wouldn't be possible without * libwmf - http://wvware.sourceforge.net/libwmf.html * while this file shares no code with libwmf, it proved to be a valuable tool * to check the syntax * James D. Murray and William van Ryper, Encyclopedia of Graphics File Formats, Oreilly * http://www.oreilly.com/catalog/gffcd/index.html * I used the HTML version which is part of libwmf * Caolán McNamara's "Windows Metafile (wmf) Operand Documentation" * this is also part of libwmf * TrollTech's Qt (http://www.trolltech.com) - otherwise there were no QWMF * Ion Vasilief's QtiPlot - the actual reason that I started this project * http://www.kde-apps.org/content/show.php?content=14826 * Microsoft for creating the format at the first place */ #ifndef QWMF_H #define QWMF_H #include #include #include class Q_EXPORT QWMF : public QPaintDevice { public: QWMF(); QWMF(const QString & fileName); ~QWMF(); int height(); int width(); int inch(); void setHeight(int); void setWidth(int); void setInch(int); void setOutputFileName(const QString &fileName); protected: bool cmd (int, QPainter *, QPDevCmdParam *); int metric(int m) const; struct _WindowsMetaHeader{ Q_UINT16 FileType; /* Type of metafile (0=memory, 1=disk) */ Q_UINT16 HeaderSize; /* Size of header in WORDS (always 9) */ Q_UINT16 Version; /* Version of Microsoft Windows used */ Q_UINT32 FileSize; /* Total size of the metafile in WORDs */ Q_UINT16 NumOfObjects; /* Number of objects in the file */ Q_UINT32 MaxRecordSize; /* The size of largest record in WORDs */ Q_UINT16 NumOfParams; /* Not Used (always 0) */ }; struct _PlaceableMetaHeader { Q_UINT32 Key; /* Magic number (always 9AC6CDD7h) */ Q_UINT32 Handle; /* Metafile HANDLE number (always 0) */ Q_INT16 Left; /* Left coordinate in metafile units */ Q_INT16 Top; /* Top coordinate in metafile units */ Q_INT16 Right; /* Right coordinate in metafile units */ Q_INT16 Bottom; /* Bottom coordinate in metafile units */ Q_UINT16 Inch; /* Number of metafile units per inch */ Q_UINT32 Reserved; /* Reserved (always 0) */ Q_UINT16 Checksum; /* Checksum value for previous 10 WORDs */ }; QFile *myFile; int myWidth; int myHeight; int myInch; int maxWidth; int maxHeight; const QFont *myFont; bool usingWMat; QWMatrix myWMatrix, myFontWMat; Q_UINT32 myRecSize; // maximal size of a single record Q_UINT16 ObjectCounter; // number of objects (brushes, pens, fonts) private: inline Q_UINT32 wmf_4int_dword(unsigned, unsigned, unsigned, unsigned); inline Q_UINT32 wmf_2int_word(unsigned, unsigned); int read_dword(); int read_word(); int write_dword(Q_UINT32); int write_word(Q_UINT32); Q_UINT32 winrgb(QColor); bool writeHeader(); void Init(); Q_UINT32 max(Q_UINT32,Q_UINT32); bool setFont(const QFont *); void transform_xy(QPoint&); void transform_rect(QRect&); }; #endif /* QWMF_H */