Mercurial > clickerconvert
comparison src/xlsx/xlsxdrawinganchor_p.h @ 1:93d3106bb9a4
Add qt xlsx library
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 22 Mar 2016 10:38:08 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:49cd5cc0b072 | 1:93d3106bb9a4 |
---|---|
1 /**************************************************************************** | |
2 ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me> | |
3 ** All right reserved. | |
4 ** | |
5 ** Permission is hereby granted, free of charge, to any person obtaining | |
6 ** a copy of this software and associated documentation files (the | |
7 ** "Software"), to deal in the Software without restriction, including | |
8 ** without limitation the rights to use, copy, modify, merge, publish, | |
9 ** distribute, sublicense, and/or sell copies of the Software, and to | |
10 ** permit persons to whom the Software is furnished to do so, subject to | |
11 ** the following conditions: | |
12 ** | |
13 ** The above copyright notice and this permission notice shall be | |
14 ** included in all copies or substantial portions of the Software. | |
15 ** | |
16 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
19 ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
20 ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
21 ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
22 ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 ** | |
24 ****************************************************************************/ | |
25 | |
26 #ifndef QXLSX_XLSXDRAWINGANCHOR_P_H | |
27 #define QXLSX_XLSXDRAWINGANCHOR_P_H | |
28 | |
29 #include "xlsxglobal.h" | |
30 | |
31 #include <QPoint> | |
32 #include <QSize> | |
33 #include <QString> | |
34 #include <QSharedPointer> | |
35 | |
36 class QXmlStreamReader; | |
37 class QXmlStreamWriter; | |
38 | |
39 namespace QXlsx { | |
40 | |
41 class Drawing; | |
42 class MediaFile; | |
43 class Chart; | |
44 | |
45 //Helper class | |
46 struct XlsxMarker | |
47 { | |
48 XlsxMarker(){} | |
49 XlsxMarker(int row, int column, int rowOffset, int colOffset) | |
50 :cell(QPoint(row, column)), offset(rowOffset, colOffset) | |
51 { | |
52 | |
53 } | |
54 | |
55 int row() const {return cell.x();} | |
56 int col() const {return cell.y();} | |
57 int rowOff() const {return offset.width();} | |
58 int colOff() const {return offset.height();} | |
59 | |
60 QPoint cell; | |
61 QSize offset; | |
62 }; | |
63 | |
64 class DrawingAnchor | |
65 { | |
66 public: | |
67 enum ObjectType { | |
68 GraphicFrame, | |
69 Shape, | |
70 GroupShape, | |
71 ConnectionShape, | |
72 Picture, | |
73 Unknown | |
74 }; | |
75 | |
76 DrawingAnchor(Drawing *drawing, ObjectType objectType); | |
77 virtual ~DrawingAnchor(); | |
78 void setObjectPicture(const QImage &img); | |
79 void setObjectGraphicFrame(QSharedPointer<Chart> chart); | |
80 | |
81 virtual bool loadFromXml(QXmlStreamReader &reader) = 0; | |
82 virtual void saveToXml(QXmlStreamWriter &writer) const = 0; | |
83 | |
84 protected: | |
85 QPoint loadXmlPos(QXmlStreamReader &reader); | |
86 QSize loadXmlExt(QXmlStreamReader &reader); | |
87 XlsxMarker loadXmlMarker(QXmlStreamReader &reader, const QString &node); | |
88 void loadXmlObject(QXmlStreamReader &reader); | |
89 void loadXmlObjectShape(QXmlStreamReader &reader); | |
90 void loadXmlObjectGroupShape(QXmlStreamReader &reader); | |
91 void loadXmlObjectGraphicFrame(QXmlStreamReader &reader); | |
92 void loadXmlObjectConnectionShape(QXmlStreamReader &reader); | |
93 void loadXmlObjectPicture(QXmlStreamReader &reader); | |
94 | |
95 void saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const; | |
96 void saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const; | |
97 void saveXmlMarker(QXmlStreamWriter &writer, const XlsxMarker &marker, const QString &node) const; | |
98 void saveXmlObject(QXmlStreamWriter &writer) const; | |
99 void saveXmlObjectShape(QXmlStreamWriter &writer) const; | |
100 void saveXmlObjectGroupShape(QXmlStreamWriter &writer) const; | |
101 void saveXmlObjectGraphicFrame(QXmlStreamWriter &writer) const; | |
102 void saveXmlObjectConnectionShape(QXmlStreamWriter &writer) const; | |
103 void saveXmlObjectPicture(QXmlStreamWriter &writer) const; | |
104 | |
105 Drawing *m_drawing; | |
106 ObjectType m_objectType; | |
107 QSharedPointer<MediaFile> m_pictureFile; | |
108 QSharedPointer<Chart> m_chartFile; | |
109 | |
110 int m_id; | |
111 }; | |
112 | |
113 class DrawingAbsoluteAnchor : public DrawingAnchor | |
114 { | |
115 public: | |
116 DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType=Unknown); | |
117 | |
118 QPoint pos; | |
119 QSize ext; | |
120 | |
121 bool loadFromXml(QXmlStreamReader &reader); | |
122 void saveToXml(QXmlStreamWriter &writer) const; | |
123 }; | |
124 | |
125 class DrawingOneCellAnchor : public DrawingAnchor | |
126 { | |
127 public: | |
128 DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType=Unknown); | |
129 | |
130 XlsxMarker from; | |
131 QSize ext; | |
132 | |
133 bool loadFromXml(QXmlStreamReader &reader); | |
134 void saveToXml(QXmlStreamWriter &writer) const; | |
135 }; | |
136 | |
137 class DrawingTwoCellAnchor : public DrawingAnchor | |
138 { | |
139 public: | |
140 DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType=Unknown); | |
141 | |
142 XlsxMarker from; | |
143 XlsxMarker to; | |
144 | |
145 bool loadFromXml(QXmlStreamReader &reader); | |
146 void saveToXml(QXmlStreamWriter &writer) const; | |
147 }; | |
148 | |
149 } // namespace QXlsx | |
150 | |
151 #endif // QXLSX_XLSXDRAWINGANCHOR_P_H |