Mercurial > clickerconvert
comparison src/xlsx/xlsxworksheet_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 #ifndef XLSXWORKSHEET_P_H | |
26 #define XLSXWORKSHEET_P_H | |
27 | |
28 // | |
29 // W A R N I N G | |
30 // ------------- | |
31 // | |
32 // This file is not part of the Qt Xlsx API. It exists for the convenience | |
33 // of the Qt Xlsx. This header file may change from | |
34 // version to version without notice, or even be removed. | |
35 // | |
36 // We mean it. | |
37 // | |
38 | |
39 #include "xlsxworksheet.h" | |
40 #include "xlsxabstractsheet_p.h" | |
41 #include "xlsxcell.h" | |
42 #include "xlsxdatavalidation.h" | |
43 #include "xlsxconditionalformatting.h" | |
44 #include "xlsxcellformula.h" | |
45 | |
46 #include <QImage> | |
47 #include <QSharedPointer> | |
48 #include <QRegularExpression> | |
49 | |
50 class QXmlStreamWriter; | |
51 class QXmlStreamReader; | |
52 | |
53 namespace QXlsx { | |
54 | |
55 const int XLSX_ROW_MAX = 1048576; | |
56 const int XLSX_COLUMN_MAX = 16384; | |
57 const int XLSX_STRING_MAX = 32767; | |
58 | |
59 class SharedStrings; | |
60 | |
61 struct XlsxHyperlinkData | |
62 { | |
63 enum LinkType | |
64 { | |
65 External, | |
66 Internal | |
67 }; | |
68 | |
69 XlsxHyperlinkData(LinkType linkType=External, const QString &target=QString(), const QString &location=QString() | |
70 , const QString &display=QString(), const QString &tip=QString()) | |
71 :linkType(linkType), target(target), location(location), display(display), tooltip(tip) | |
72 { | |
73 | |
74 } | |
75 | |
76 LinkType linkType; | |
77 QString target; //For External link | |
78 QString location; | |
79 QString display; | |
80 QString tooltip; | |
81 }; | |
82 | |
83 // ECMA-376 Part1 18.3.1.81 | |
84 struct XlsxSheetFormatProps | |
85 { | |
86 XlsxSheetFormatProps(int baseColWidth = 8, | |
87 bool customHeight = false, | |
88 double defaultColWidth = 0.0, | |
89 double defaultRowHeight = 15, | |
90 quint8 outlineLevelCol = 0, | |
91 quint8 outlineLevelRow = 0, | |
92 bool thickBottom = false, | |
93 bool thickTop = false, | |
94 bool zeroHeight = false) : | |
95 baseColWidth(baseColWidth), | |
96 customHeight(customHeight), | |
97 defaultColWidth(defaultColWidth), | |
98 defaultRowHeight(defaultRowHeight), | |
99 outlineLevelCol(outlineLevelCol), | |
100 outlineLevelRow(outlineLevelRow), | |
101 thickBottom(thickBottom), | |
102 thickTop(thickTop), | |
103 zeroHeight(zeroHeight) { | |
104 } | |
105 | |
106 int baseColWidth; | |
107 bool customHeight; | |
108 double defaultColWidth; | |
109 double defaultRowHeight; | |
110 quint8 outlineLevelCol; | |
111 quint8 outlineLevelRow; | |
112 bool thickBottom; | |
113 bool thickTop; | |
114 bool zeroHeight; | |
115 }; | |
116 | |
117 struct XlsxRowInfo | |
118 { | |
119 XlsxRowInfo(double height=0, const Format &format=Format(), bool hidden=false) : | |
120 customHeight(false), height(height), format(format), hidden(hidden), outlineLevel(0) | |
121 , collapsed(false) | |
122 { | |
123 | |
124 } | |
125 | |
126 bool customHeight; | |
127 double height; | |
128 Format format; | |
129 bool hidden; | |
130 int outlineLevel; | |
131 bool collapsed; | |
132 }; | |
133 | |
134 struct XlsxColumnInfo | |
135 { | |
136 XlsxColumnInfo(int firstColumn=0, int lastColumn=1, double width=0, const Format &format=Format(), bool hidden=false) : | |
137 firstColumn(firstColumn), lastColumn(lastColumn), customWidth(false), width(width), format(format), hidden(hidden) | |
138 , outlineLevel(0), collapsed(false) | |
139 { | |
140 | |
141 } | |
142 int firstColumn; | |
143 int lastColumn; | |
144 bool customWidth; | |
145 double width; | |
146 Format format; | |
147 bool hidden; | |
148 int outlineLevel; | |
149 bool collapsed; | |
150 }; | |
151 | |
152 class XLSX_AUTOTEST_EXPORT WorksheetPrivate : public AbstractSheetPrivate | |
153 { | |
154 Q_DECLARE_PUBLIC(Worksheet) | |
155 public: | |
156 WorksheetPrivate(Worksheet *p, Worksheet::CreateFlag flag); | |
157 ~WorksheetPrivate(); | |
158 int checkDimensions(int row, int col, bool ignore_row=false, bool ignore_col=false); | |
159 Format cellFormat(int row, int col) const; | |
160 QString generateDimensionString() const; | |
161 void calculateSpans() const; | |
162 void splitColsInfo(int colFirst, int colLast); | |
163 void validateDimension(); | |
164 | |
165 void saveXmlSheetData(QXmlStreamWriter &writer) const; | |
166 void saveXmlCellData(QXmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell) const; | |
167 void saveXmlMergeCells(QXmlStreamWriter &writer) const; | |
168 void saveXmlHyperlinks(QXmlStreamWriter &writer) const; | |
169 void saveXmlDrawings(QXmlStreamWriter &writer) const; | |
170 void saveXmlDataValidations(QXmlStreamWriter &writer) const; | |
171 int rowPixelsSize(int row) const; | |
172 int colPixelsSize(int col) const; | |
173 | |
174 void loadXmlSheetData(QXmlStreamReader &reader); | |
175 void loadXmlColumnsInfo(QXmlStreamReader &reader); | |
176 void loadXmlMergeCells(QXmlStreamReader &reader); | |
177 void loadXmlDataValidations(QXmlStreamReader &reader); | |
178 void loadXmlSheetFormatProps(QXmlStreamReader &reader); | |
179 void loadXmlSheetViews(QXmlStreamReader &reader); | |
180 void loadXmlHyperlinks(QXmlStreamReader &reader); | |
181 | |
182 QList<QSharedPointer<XlsxRowInfo> > getRowInfoList(int rowFirst, int rowLast); | |
183 QList <QSharedPointer<XlsxColumnInfo> > getColumnInfoList(int colFirst, int colLast); | |
184 QList<int> getColumnIndexes(int colFirst, int colLast); | |
185 bool isColumnRangeValid(int colFirst, int colLast); | |
186 | |
187 SharedStrings *sharedStrings() const; | |
188 | |
189 QMap<int, QMap<int, QSharedPointer<Cell> > > cellTable; | |
190 QMap<int, QMap<int, QString> > comments; | |
191 QMap<int, QMap<int, QSharedPointer<XlsxHyperlinkData> > > urlTable; | |
192 QList<CellRange> merges; | |
193 QMap<int, QSharedPointer<XlsxRowInfo> > rowsInfo; | |
194 QMap<int, QSharedPointer<XlsxColumnInfo> > colsInfo; | |
195 QMap<int, QSharedPointer<XlsxColumnInfo> > colsInfoHelper; | |
196 | |
197 QList<DataValidation> dataValidationsList; | |
198 QList<ConditionalFormatting> conditionalFormattingList; | |
199 QMap<int, CellFormula> sharedFormulaMap; | |
200 | |
201 CellRange dimension; | |
202 int previous_row; | |
203 | |
204 mutable QMap<int, QString> row_spans; | |
205 QMap<int, double> row_sizes; | |
206 QMap<int, double> col_sizes; | |
207 | |
208 int outline_row_level; | |
209 int outline_col_level; | |
210 | |
211 int default_row_height; | |
212 bool default_row_zeroed; | |
213 | |
214 XlsxSheetFormatProps sheetFormatProps; | |
215 | |
216 bool windowProtection; | |
217 bool showFormulas; | |
218 bool showGridLines; | |
219 bool showRowColHeaders; | |
220 bool showZeros; | |
221 bool rightToLeft; | |
222 bool tabSelected; | |
223 bool showRuler; | |
224 bool showOutlineSymbols; | |
225 bool showWhiteSpace; | |
226 | |
227 QRegularExpression urlPattern; | |
228 private: | |
229 static double calculateColWidth(int characters); | |
230 }; | |
231 | |
232 } | |
233 #endif // XLSXWORKSHEET_P_H |