comparison src/xlsx/xlsxstyles_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 XLSXSTYLES_H
26 #define XLSXSTYLES_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 "xlsxglobal.h"
40 #include "xlsxformat.h"
41 #include "xlsxabstractooxmlfile.h"
42 #include <QSharedPointer>
43 #include <QHash>
44 #include <QList>
45 #include <QMap>
46 #include <QStringList>
47 #include <QVector>
48
49 class QXmlStreamWriter;
50 class QXmlStreamReader;
51 class QIODevice;
52 class StylesTest;
53
54 namespace QXlsx {
55
56 class Format;
57 class XlsxColor;
58
59 struct XlsxFormatNumberData
60 {
61 XlsxFormatNumberData() : formatIndex(0) {}
62
63 int formatIndex;
64 QString formatString;
65 };
66
67 class XLSX_AUTOTEST_EXPORT Styles : public AbstractOOXmlFile
68 {
69 public:
70 Styles(CreateFlag flag);
71 ~Styles();
72 void addXfFormat(const Format &format, bool force=false);
73 Format xfFormat(int idx) const;
74 void addDxfFormat(const Format &format, bool force=false);
75 Format dxfFormat(int idx) const;
76
77 void saveToXmlFile(QIODevice *device) const;
78 bool loadFromXmlFile(QIODevice *device);
79
80 QColor getColorByIndex(int idx);
81
82 private:
83 friend class Format;
84 friend class ::StylesTest;
85
86 void fixNumFmt(const Format &format);
87
88 void writeNumFmts(QXmlStreamWriter &writer) const;
89 void writeFonts(QXmlStreamWriter &writer) const;
90 void writeFont(QXmlStreamWriter &writer, const Format &font, bool isDxf = false) const;
91 void writeFills(QXmlStreamWriter &writer) const;
92 void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false) const;
93 void writeBorders(QXmlStreamWriter &writer) const;
94 void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false) const;
95 void writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) const;
96 void writeCellXfs(QXmlStreamWriter &writer) const;
97 void writeDxfs(QXmlStreamWriter &writer) const;
98 void writeDxf(QXmlStreamWriter &writer, const Format &format) const;
99 void writeColors(QXmlStreamWriter &writer) const;
100
101 bool readNumFmts(QXmlStreamReader &reader);
102 bool readFonts(QXmlStreamReader &reader);
103 bool readFont(QXmlStreamReader &reader, Format &format);
104 bool readFills(QXmlStreamReader &reader);
105 bool readFill(QXmlStreamReader &reader, Format &format);
106 bool readBorders(QXmlStreamReader &reader);
107 bool readBorder(QXmlStreamReader &reader, Format &format);
108 bool readSubBorder(QXmlStreamReader &reader, const QString &name, Format::BorderStyle &style, XlsxColor &color);
109 bool readCellXfs(QXmlStreamReader &reader);
110 bool readDxfs(QXmlStreamReader &reader);
111 bool readDxf(QXmlStreamReader &reader);
112 bool readColors(QXmlStreamReader &reader);
113 bool readIndexedColors(QXmlStreamReader &reader);
114
115 QHash<QString, int> m_builtinNumFmtsHash;
116 QMap<int, QSharedPointer<XlsxFormatNumberData> > m_customNumFmtIdMap;
117 QHash<QString, QSharedPointer<XlsxFormatNumberData> > m_customNumFmtsHash;
118 int m_nextCustomNumFmtId;
119 QList<Format> m_fontsList;
120 QList<Format> m_fillsList;
121 QList<Format> m_bordersList;
122 QHash<QByteArray, Format> m_fontsHash;
123 QHash<QByteArray, Format> m_fillsHash;
124 QHash<QByteArray, Format> m_bordersHash;
125
126 QVector<QColor> m_indexedColors;
127 bool m_isIndexedColorsDefault;
128
129 QList<Format> m_xf_formatsList;
130 QHash<QByteArray, Format> m_xf_formatsHash;
131
132 QList<Format> m_dxf_formatsList;
133 QHash<QByteArray, Format> m_dxf_formatsHash;
134
135 bool m_emptyFormatAdded;
136 };
137
138 }
139 #endif // XLSXSTYLES_H
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)