Warning, file /office/calligra/filters/karbon/wmf/WmfImportParser.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2003 thierry lorthiois <lorthioist@wanadoo.fr> 0003 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 #ifndef _WMFIMPORTPARSER_H_ 0008 #define _WMFIMPORTPARSER_H_ 0009 0010 #include <WmfAbstractBackend.h> 0011 #include <QPainter> 0012 #include <QMatrix> 0013 0014 class WmfDeviceContext; 0015 class KoXmlWriter; 0016 0017 /** 0018 * WMFImportParser inherits WmfAbstractBackend and translates WMF functions 0019 */ 0020 class WMFImportParser : public Libwmf::WmfAbstractBackend 0021 { 0022 public: 0023 explicit WMFImportParser(KoXmlWriter &svgWriter); 0024 ~WMFImportParser() override; 0025 0026 private: 0027 // ------------------------------------------------------------------------- 0028 // A virtual QPainter 0029 bool begin(const QRect &boundingBox) override; 0030 bool end() override; 0031 void save() override; 0032 void restore() override; 0033 0034 // Drawing attributes/modes 0035 void setCompositionMode(QPainter::CompositionMode) override; 0036 0037 /** 0038 * Change logical Coordinate 0039 * some wmf files call those functions several times in the middle of a drawing 0040 * others wmf files doesn't call setWindow* at all 0041 * negative width and height are possible 0042 */ 0043 void setWindowOrg(int left, int top) override; 0044 void setWindowExt(int width, int height) override; 0045 void setViewportOrg(int left, int top) override; 0046 void setViewportExt(int width, int height) override; 0047 0048 // Clipping 0049 // the 'CoordinateMode' is omitted : always CoordPainter in wmf 0050 // setClipRegion() is often used with save() and restore() => implement all or none 0051 void setClipRegion(Libwmf::WmfDeviceContext &context, const QRegion &rec); 0052 QRegion clipRegion(); 0053 0054 // Graphics drawing functions 0055 void setPixel(Libwmf::WmfDeviceContext &context, int x, int y, const QColor &color) override; 0056 void moveTo(Libwmf::WmfDeviceContext &context, int x, int y); 0057 void lineTo(Libwmf::WmfDeviceContext &context, int x, int y) override; 0058 void drawRect(Libwmf::WmfDeviceContext &context, int x, int y, int w, int h) override; 0059 void drawRoundRect(Libwmf::WmfDeviceContext &context, int x, int y, int w, int h, int = 25, int = 25) override; 0060 void drawEllipse(Libwmf::WmfDeviceContext &context, int x, int y, int w, int h) override; 0061 void drawArc(Libwmf::WmfDeviceContext &context, int x, int y, int w, int h, int a, int alen) override; 0062 void drawPie(Libwmf::WmfDeviceContext &context, int x, int y, int w, int h, int a, int alen) override; 0063 void drawChord(Libwmf::WmfDeviceContext &context, int x, int y, int w, int h, int a, int alen) override; 0064 void drawPolyline(Libwmf::WmfDeviceContext &context, const QPolygon &pa) override; 0065 void drawPolygon(Libwmf::WmfDeviceContext &context, const QPolygon &pa) override; 0066 /** 0067 * drawPolyPolygon draw the XOR of a list of polygons 0068 * listPa : list of polygons 0069 */ 0070 void drawPolyPolygon(Libwmf::WmfDeviceContext &context, QList<QPolygon>& listPa) override; 0071 void drawImage(Libwmf::WmfDeviceContext &context, int x, int y, const QImage &, 0072 int sx = 0, int sy = 0, int sw = -1, int sh = -1) override; 0073 void patBlt(Libwmf::WmfDeviceContext &context, int x, int y, int width, int height, 0074 quint32 rasterOperation) override; 0075 0076 // Text drawing 0077 // rotation = the degrees of rotation in counterclockwise 0078 // not yet implemented in KWinMetaFile 0079 void drawText(Libwmf::WmfDeviceContext &context, int x, int y, const QString &s) override; 0080 0081 // matrix transformation : only used in some bitmap manipulation 0082 void setMatrix(Libwmf::WmfDeviceContext &context, const QMatrix &matrix, bool combine = false) override; 0083 0084 //----------------------------------------------------------------------------- 0085 // Utilities 0086 // Add pen, brush and points to a path 0087 QString saveStroke(Libwmf::WmfDeviceContext &context); 0088 QString saveFill(Libwmf::WmfDeviceContext &context); 0089 0090 // coordinate transformation 0091 QRectF boundBox(int left, int top, int width, int height); 0092 QPointF coord(const QPoint &p); 0093 QSizeF size(const QSize &s); 0094 0095 private: 0096 void updateTransform(); 0097 0098 KoXmlWriter &m_svgWriter; 0099 0100 QSizeF m_pageSize; 0101 0102 struct CoordData { 0103 CoordData() : org(0,0), ext(0,0), extIsValid(false) {} 0104 QPointF org; 0105 QSizeF ext; 0106 bool extIsValid; 0107 }; 0108 0109 CoordData m_window; 0110 CoordData m_viewport; 0111 qreal m_scaleX; 0112 qreal m_scaleY; 0113 QMatrix m_matrix; 0114 }; 0115 0116 #endif // _WMFIMPORTPARSER_H_