annotate src/xlsx/xlsxconditionalformatting.cpp @ 32:ad54c98cb8d8

Minor layout fixes
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 11 Apr 2016 14:33:01 +0200
parents 4ecb91aaf33f
children
rev   line source
1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 /****************************************************************************
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 ** All right reserved.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 **
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 ** Permission is hereby granted, free of charge, to any person obtaining
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 ** a copy of this software and associated documentation files (the
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7 ** "Software"), to deal in the Software without restriction, including
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8 ** without limitation the rights to use, copy, modify, merge, publish,
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 ** distribute, sublicense, and/or sell copies of the Software, and to
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 ** permit persons to whom the Software is furnished to do so, subject to
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11 ** the following conditions:
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 **
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 ** The above copyright notice and this permission notice shall be
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14 ** included in all copies or substantial portions of the Software.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 **
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19 ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 **
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 ****************************************************************************/
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26 #include "xlsxconditionalformatting.h"
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 #include "xlsxconditionalformatting_p.h"
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 #include "xlsxworksheet.h"
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 #include "xlsxcellrange.h"
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 #include "xlsxstyles_p.h"
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 #include <QXmlStreamReader>
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 #include <QXmlStreamWriter>
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 #include <QDebug>
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 QT_BEGIN_NAMESPACE_XLSX
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 ConditionalFormattingPrivate::ConditionalFormattingPrivate()
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43 ConditionalFormattingPrivate::ConditionalFormattingPrivate(const ConditionalFormattingPrivate &other)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44 :QSharedData(other)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
46
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
47 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
48
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
49 ConditionalFormattingPrivate::~ConditionalFormattingPrivate()
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
50 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
51
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
54 void ConditionalFormattingPrivate::writeCfVo(QXmlStreamWriter &writer, const XlsxCfVoData &cfvo) const
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
55 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
56 writer.writeEmptyElement(QStringLiteral("cfvo"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
57 QString type;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
58 switch(cfvo.type) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
59 case ConditionalFormatting::VOT_Formula: type=QStringLiteral("formula"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
60 case ConditionalFormatting::VOT_Max: type=QStringLiteral("max"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
61 case ConditionalFormatting::VOT_Min: type=QStringLiteral("min"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
62 case ConditionalFormatting::VOT_Num: type=QStringLiteral("num"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
63 case ConditionalFormatting::VOT_Percent: type=QStringLiteral("percent"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
64 case ConditionalFormatting::VOT_Percentile: type=QStringLiteral("percentile"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
65 default: break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
66 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
67 writer.writeAttribute(QStringLiteral("type"), type);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
68 writer.writeAttribute(QStringLiteral("val"), cfvo.value);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
69 if (!cfvo.gte)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
70 writer.writeAttribute(QStringLiteral("gte"), QStringLiteral("0"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
71 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
72
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
73 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
74 * \class ConditionalFormatting
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
75 * \brief Conditional formatting for single cell or ranges
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
76 * \inmodule QtXlsx
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
77 *
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
78 * The conditional formatting can be applied to a single cell or ranges of cells.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
79 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
80
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
81
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
82 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
83 \enum ConditionalFormatting::HighlightRuleType
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
84
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
85 \value Highlight_LessThan
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
86 \value Highlight_LessThanOrEqual
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
87 \value Highlight_Equal
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
88 \value Highlight_NotEqual
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
89 \value Highlight_GreaterThanOrEqual
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
90 \value Highlight_GreaterThan
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
91 \value Highlight_Between
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
92 \value Highlight_NotBetween
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
93
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
94 \value Highlight_ContainsText
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
95 \value Highlight_NotContainsText
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
96 \value Highlight_BeginsWith
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
97 \value Highlight_EndsWith
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
98
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
99 \value Highlight_TimePeriod
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
100
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
101 \value Highlight_Duplicate
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
102 \value Highlight_Unique
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
103
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
104 \value Highlight_Blanks
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
105 \value Highlight_NoBlanks
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
106 \value Highlight_Errors
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
107 \value Highlight_NoErrors
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
108
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 \value Highlight_Top
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110 \value Highlight_TopPercent
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
111 \value Highlight_Bottom
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
112 \value Highlight_BottomPercent
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114 \value Highlight_AboveAverage
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
115 \value Highlight_AboveOrEqualAverage
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116 \value Highlight_BelowAverage
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
117 \value Highlight_BelowOrEqualAverage
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
118 \value Highlight_AboveStdDev1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
119 \value Highlight_AboveStdDev2
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
120 \value Highlight_AboveStdDev3
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
121 \value Highlight_BelowStdDev1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
122 \value Highlight_BelowStdDev2
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
123 \value Highlight_BelowStdDev3
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
124
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
125 \value Highlight_Expression
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
126 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
127
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
128 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
129 \enum ConditionalFormatting::ValueObjectType
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
130
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
131 \value VOT_Formula
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
132 \value VOT_Max
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
133 \value VOT_Min
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
134 \value VOT_Num
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
135 \value VOT_Percent
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
136 \value VOT_Percentile
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
137 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
138
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
139 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
140 Construct a conditional formatting object
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
141 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
142 ConditionalFormatting::ConditionalFormatting()
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
143 :d(new ConditionalFormattingPrivate())
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
144 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
145
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
146 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
147
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
148 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
149 Constructs a copy of \a other.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
150 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
151 ConditionalFormatting::ConditionalFormatting(const ConditionalFormatting &other)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
152 :d(other.d)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
153 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
154
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
155 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
156
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
157 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
158 Assigns \a other to this conditional formatting and returns a reference to
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
159 this conditional formatting.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
160 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
161 ConditionalFormatting &ConditionalFormatting::operator=(const ConditionalFormatting &other)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
162 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
163 this->d = other.d;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
164 return *this;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
165 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
166
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
167
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
168 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
169 * Destroy the object.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
170 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
171 ConditionalFormatting::~ConditionalFormatting()
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
172 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
173 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
174
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
175 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
176 * Add a hightlight rule with the given \a type, \a formula1, \a formula2,
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
177 * \a format and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
178 * Return false if failed.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
179 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
180 bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const QString &formula2, const Format &format, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
181 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
182 if (format.isEmpty())
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
183 return false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
184
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
185 bool skipFormula = false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
186
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
187 QSharedPointer<XlsxCfRuleData> cfRule(new XlsxCfRuleData);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
188 if (type >= Highlight_LessThan && type <= Highlight_NotBetween) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
189 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("cellIs");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
190 QString op;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
191 switch (type) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
192 case Highlight_Between: op = QStringLiteral("between"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
193 case Highlight_Equal: op = QStringLiteral("equal"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
194 case Highlight_GreaterThan: op = QStringLiteral("greaterThan"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
195 case Highlight_GreaterThanOrEqual: op = QStringLiteral("greaterThanOrEqual"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
196 case Highlight_LessThan: op = QStringLiteral("lessThan"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
197 case Highlight_LessThanOrEqual: op = QStringLiteral("lessThanOrEqual"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
198 case Highlight_NotBetween: op = QStringLiteral("notBetween"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
199 case Highlight_NotEqual: op = QStringLiteral("notEqual"); break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
200 default: break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
201 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
202 cfRule->attrs[XlsxCfRuleData::A_operator] = op;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
203 } else if (type >= Highlight_ContainsText && type <= Highlight_EndsWith) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
204 if (type == Highlight_ContainsText) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
205 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsText");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
206 cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("containsText");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
207 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("NOT(ISERROR(SEARCH(\"%1\",%2)))").arg(formula1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
208 } else if (type == Highlight_NotContainsText) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
209 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsText");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
210 cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("notContains");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
211 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("ISERROR(SEARCH(\"%2\",%1))").arg(formula1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
212 } else if (type == Highlight_BeginsWith) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
213 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("beginsWith");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
214 cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("beginsWith");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
215 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEFT(%2,LEN(\"%1\"))=\"%1\"").arg(formula1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
216 } else {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
217 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("endsWith");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
218 cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("endsWith");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
219 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("RIGHT(%2,LEN(\"%1\"))=\"%1\"").arg(formula1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
220 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
221 cfRule->attrs[XlsxCfRuleData::A_text] = formula1;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
222 skipFormula = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
223 } else if (type == Highlight_TimePeriod) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
224 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("timePeriod");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
225 //:Todo
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
226 return false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
227 } else if (type == Highlight_Duplicate) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
228 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("duplicateValues");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
229 } else if (type == Highlight_Unique) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
230 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("uniqueValues");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
231 } else if (type == Highlight_Errors) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
232 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsErrors");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
233 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("ISERROR(%1)");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
234 skipFormula = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
235 } else if (type == Highlight_NoErrors) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
236 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsErrors");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
237 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("NOT(ISERROR(%1))");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
238 skipFormula = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
239 } else if (type == Highlight_Blanks) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
240 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsBlanks");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
241 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEN(TRIM(%1))=0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
242 skipFormula = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
243 } else if (type == Highlight_NoBlanks) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
244 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsBlanks");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
245 cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEN(TRIM(%1))>0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
246 skipFormula = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
247 } else if (type >= Highlight_Top && type <= Highlight_BottomPercent) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
248 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("top10");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
249 if (type == Highlight_Bottom || type == Highlight_BottomPercent)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
250 cfRule->attrs[XlsxCfRuleData::A_bottom] = QStringLiteral("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
251 if (type == Highlight_TopPercent || type == Highlight_BottomPercent)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
252 cfRule->attrs[XlsxCfRuleData::A_percent] = QStringLiteral("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
253 cfRule->attrs[XlsxCfRuleData::A_rank] = !formula1.isEmpty() ? formula1 : QStringLiteral("10");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
254 skipFormula = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
255 } else if (type >= Highlight_AboveAverage && type <= Highlight_BelowStdDev3) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
256 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("aboveAverage");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
257 if (type >= Highlight_BelowAverage && type <= Highlight_BelowStdDev3)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
258 cfRule->attrs[XlsxCfRuleData::A_aboveAverage] = QStringLiteral("0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
259 if (type == Highlight_AboveOrEqualAverage || type == Highlight_BelowOrEqualAverage)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
260 cfRule->attrs[XlsxCfRuleData::A_equalAverage] = QStringLiteral("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
261 if (type == Highlight_AboveStdDev1 || type == Highlight_BelowStdDev1)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
262 cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
263 else if (type == Highlight_AboveStdDev2 || type == Highlight_BelowStdDev2)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
264 cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("2");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
265 else if (type == Highlight_AboveStdDev3 || type == Highlight_BelowStdDev3)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
266 cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("3");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
267 } else if (type == Highlight_Expression){
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
268 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("expression");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
269 } else {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
270 return false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
271 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
272
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
273 cfRule->dxfFormat = format;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
274 if (stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
275 cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
276 if (!skipFormula) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
277 if (!formula1.isEmpty())
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
278 cfRule->attrs[XlsxCfRuleData::A_formula1] = formula1.startsWith(QLatin1String("=")) ? formula1.mid(1) : formula1;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
279 if (!formula2.isEmpty())
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
280 cfRule->attrs[XlsxCfRuleData::A_formula2] = formula2.startsWith(QLatin1String("=")) ? formula2.mid(1) : formula2;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
281 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
282 d->cfRules.append(cfRule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
283 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
284 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
285
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
286 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
287 * \overload
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
288 *
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
289 * Add a hightlight rule with the given \a type \a format and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
290 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
291 bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const Format &format, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
292 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
293 if ((type >= Highlight_AboveAverage && type <= Highlight_BelowStdDev3)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
294 || (type >= Highlight_Duplicate && type <= Highlight_NoErrors)) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
295 return addHighlightCellsRule(type, QString(), QString(), format, stopIfTrue);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
296 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
297
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
298 return false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
299 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
300
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
301 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
302 * \overload
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
303 *
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
304 * Add a hightlight rule with the given \a type, \a formula, \a format and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
305 * Return false if failed.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
306 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
307 bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const QString &formula, const Format &format, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
308 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
309 if (type == Highlight_Between || type == Highlight_NotBetween)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
310 return false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
311
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
312 return addHighlightCellsRule(type, formula, QString(), format, stopIfTrue);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
313 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
314
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
315 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
316 * Add a dataBar rule with the given \a color, \a type1, \a val1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
317 * , \a type2, \a val2, \a showData and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
318 * Return false if failed.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
319 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
320 bool ConditionalFormatting::addDataBarRule(const QColor &color, ValueObjectType type1, const QString &val1, ValueObjectType type2, const QString &val2, bool showData, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
321 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
322 QSharedPointer<XlsxCfRuleData> cfRule(new XlsxCfRuleData);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
323
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
324 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("dataBar");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
325 cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(color);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
326 if (stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
327 cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
328 if (!showData)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
329 cfRule->attrs[XlsxCfRuleData::A_hideData] = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
330
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
331 XlsxCfVoData cfvo1(type1, val1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
332 XlsxCfVoData cfvo2(type2, val2);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
333 cfRule->attrs[XlsxCfRuleData::A_cfvo1] = QVariant::fromValue(cfvo1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
334 cfRule->attrs[XlsxCfRuleData::A_cfvo2] = QVariant::fromValue(cfvo2);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
335
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
336 d->cfRules.append(cfRule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
337 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
338 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
339
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
340 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
341 * \overload
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
342 * Add a dataBar rule with the given \a color, \a showData and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
343 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
344 bool ConditionalFormatting::addDataBarRule(const QColor &color, bool showData, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
345 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
346 return addDataBarRule(color, VOT_Min, QStringLiteral("0"), VOT_Max, QStringLiteral("0"), showData, stopIfTrue);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
347 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
348
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
349 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
350 * Add a colorScale rule with the given \a minColor, \a maxColor and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
351 * Return false if failed.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
352 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
353 bool ConditionalFormatting::add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
354 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
355 ValueObjectType type1 = VOT_Min;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
356 ValueObjectType type2 = VOT_Max;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
357 QString val1 = QStringLiteral("0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
358 QString val2 = QStringLiteral("0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
359
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
360 QSharedPointer<XlsxCfRuleData> cfRule(new XlsxCfRuleData);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
361
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
362 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("colorScale");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
363 cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(minColor);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
364 cfRule->attrs[XlsxCfRuleData::A_color2] = XlsxColor(maxColor);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
365 if (stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
366 cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
367
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
368 XlsxCfVoData cfvo1(type1, val1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
369 XlsxCfVoData cfvo2(type2, val2);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
370 cfRule->attrs[XlsxCfRuleData::A_cfvo1] = QVariant::fromValue(cfvo1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
371 cfRule->attrs[XlsxCfRuleData::A_cfvo2] = QVariant::fromValue(cfvo2);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
372
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
373 d->cfRules.append(cfRule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
374 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
375 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
376
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
377 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
378 * Add a colorScale rule with the given \a minColor, \a midColor, \a maxColor and \a stopIfTrue.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
379 * Return false if failed.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
380 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
381 bool ConditionalFormatting::add3ColorScaleRule(const QColor &minColor, const QColor &midColor, const QColor &maxColor, bool stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
382 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
383 ValueObjectType type1 = VOT_Min;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
384 ValueObjectType type2 = VOT_Percent;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
385 ValueObjectType type3 = VOT_Max;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
386 QString val1 = QStringLiteral("0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
387 QString val2 = QStringLiteral("50");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
388 QString val3 = QStringLiteral("0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
389
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
390 QSharedPointer<XlsxCfRuleData> cfRule(new XlsxCfRuleData);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
391
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
392 cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("colorScale");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
393 cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(minColor);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
394 cfRule->attrs[XlsxCfRuleData::A_color2] = XlsxColor(midColor);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
395 cfRule->attrs[XlsxCfRuleData::A_color3] = XlsxColor(maxColor);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
396
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
397 if (stopIfTrue)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
398 cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
399
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
400 XlsxCfVoData cfvo1(type1, val1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
401 XlsxCfVoData cfvo2(type2, val2);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
402 XlsxCfVoData cfvo3(type3, val3);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
403 cfRule->attrs[XlsxCfRuleData::A_cfvo1] = QVariant::fromValue(cfvo1);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
404 cfRule->attrs[XlsxCfRuleData::A_cfvo2] = QVariant::fromValue(cfvo2);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
405 cfRule->attrs[XlsxCfRuleData::A_cfvo3] = QVariant::fromValue(cfvo3);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
406
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
407 d->cfRules.append(cfRule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
408 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
409 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
410
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
411 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
412 Returns the ranges on which the validation will be applied.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
413 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
414 QList<CellRange> ConditionalFormatting::ranges() const
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
415 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
416 return d->ranges;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
417 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
418
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
419 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
420 Add the \a cell on which the conditional formatting will apply to.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
421 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
422 void ConditionalFormatting::addCell(const CellReference &cell)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
423 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
424 d->ranges.append(CellRange(cell, cell));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
425 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
426
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
427 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
428 \overload
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
429 Add the cell(\a row, \a col) on which the conditional formatting will apply to.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
430 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
431 void ConditionalFormatting::addCell(int row, int col)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
432 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
433 d->ranges.append(CellRange(row, col, row, col));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
434 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
435
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
436 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
437 \overload
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
438 Add the range(\a firstRow, \a firstCol, \a lastRow, \a lastCol) on
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
439 which the conditional formatting will apply to.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
440 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
441 void ConditionalFormatting::addRange(int firstRow, int firstCol, int lastRow, int lastCol)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
442 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
443 d->ranges.append(CellRange(firstRow, firstCol, lastRow, lastCol));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
444 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
445
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
446 /*!
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
447 Add the \a range on which the conditional formatting will apply to.
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
448 */
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
449 void ConditionalFormatting::addRange(const CellRange &range)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
450 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
451 d->ranges.append(range);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
452 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
453
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
454 bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader, XlsxCfRuleData *rule, Styles *styles)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
455 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
456 Q_ASSERT(reader.name() == QLatin1String("cfRule"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
457 QXmlStreamAttributes attrs = reader.attributes();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
458 if (attrs.hasAttribute(QLatin1String("type")))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
459 rule->attrs[XlsxCfRuleData::A_type] = attrs.value(QLatin1String("type")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
460 if (attrs.hasAttribute(QLatin1String("dxfId"))) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
461 int id = attrs.value(QLatin1String("dxfId")).toString().toInt();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
462 if (styles)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
463 rule->dxfFormat = styles->dxfFormat(id);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
464 else
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
465 rule->dxfFormat.setDxfIndex(id);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
466 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
467 rule->priority = attrs.value(QLatin1String("priority")).toString().toInt();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
468 if (attrs.value(QLatin1String("stopIfTrue")) == QLatin1String("1")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
469 //default is false
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
470 rule->attrs[XlsxCfRuleData::A_stopIfTrue] = QLatin1String("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
471 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
472 if (attrs.value(QLatin1String("aboveAverage")) == QLatin1String("0")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
473 //default is true
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
474 rule->attrs[XlsxCfRuleData::A_aboveAverage] = QLatin1String("0");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
475 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
476 if (attrs.value(QLatin1String("percent")) == QLatin1String("1")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
477 //default is false
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
478 rule->attrs[XlsxCfRuleData::A_percent] = QLatin1String("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
479 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
480 if (attrs.value(QLatin1String("bottom")) == QLatin1String("1")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
481 //default is false
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
482 rule->attrs[XlsxCfRuleData::A_bottom] = QLatin1String("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
483 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
484 if (attrs.hasAttribute(QLatin1String("operator")))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
485 rule->attrs[XlsxCfRuleData::A_operator] = attrs.value(QLatin1String("operator")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
486
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
487 if (attrs.hasAttribute(QLatin1String("text")))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
488 rule->attrs[XlsxCfRuleData::A_text] = attrs.value(QLatin1String("text")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
489
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
490 if (attrs.hasAttribute(QLatin1String("timePeriod")))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
491 rule->attrs[XlsxCfRuleData::A_timePeriod] = attrs.value(QLatin1String("timePeriod")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
492
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
493 if (attrs.hasAttribute(QLatin1String("rank")))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
494 rule->attrs[XlsxCfRuleData::A_rank] = attrs.value(QLatin1String("rank")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
495
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
496 if (attrs.hasAttribute(QLatin1String("stdDev")))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
497 rule->attrs[XlsxCfRuleData::A_stdDev] = attrs.value(QLatin1String("stdDev")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
498
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
499 if (attrs.value(QLatin1String("equalAverage")) == QLatin1String("1")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
500 //default is false
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
501 rule->attrs[XlsxCfRuleData::A_equalAverage] = QLatin1String("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
502 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
503
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
504 while (!reader.atEnd()) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
505 reader.readNextStartElement();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
506 if (reader.tokenType() == QXmlStreamReader::StartElement) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
507 if (reader.name() == QLatin1String("formula")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
508 QString f = reader.readElementText();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
509 if (!rule->attrs.contains(XlsxCfRuleData::A_formula1))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
510 rule->attrs[XlsxCfRuleData::A_formula1] = f;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
511 else if (!rule->attrs.contains(XlsxCfRuleData::A_formula2))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
512 rule->attrs[XlsxCfRuleData::A_formula2] = f;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
513 else if (!rule->attrs.contains(XlsxCfRuleData::A_formula3))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
514 rule->attrs[XlsxCfRuleData::A_formula3] = f;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
515 } else if (reader.name() == QLatin1String("dataBar")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
516 readCfDataBar(reader, rule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
517 } else if (reader.name() == QLatin1String("colorScale")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
518 readCfColorScale(reader, rule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
519 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
520 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
521 if (reader.tokenType() == QXmlStreamReader::EndElement
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
522 && reader.name() == QStringLiteral("conditionalFormatting")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
523 break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
524 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
525 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
526 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
527 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
528
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
529 bool ConditionalFormattingPrivate::readCfDataBar(QXmlStreamReader &reader, XlsxCfRuleData *rule)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
530 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
531 Q_ASSERT(reader.name() == QLatin1String("dataBar"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
532 QXmlStreamAttributes attrs = reader.attributes();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
533 if (attrs.value(QLatin1String("showValue")) == QLatin1String("0"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
534 rule->attrs[XlsxCfRuleData::A_hideData] = QStringLiteral("1");
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
535
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
536 while (!reader.atEnd()) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
537 reader.readNextStartElement();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
538 if (reader.tokenType() == QXmlStreamReader::StartElement) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
539 if (reader.name() == QLatin1String("cfvo")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
540 XlsxCfVoData data;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
541 readCfVo(reader, data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
542 if (!rule->attrs.contains(XlsxCfRuleData::A_cfvo1))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
543 rule->attrs[XlsxCfRuleData::A_cfvo1] = QVariant::fromValue(data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
544 else
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
545 rule->attrs[XlsxCfRuleData::A_cfvo2] = QVariant::fromValue(data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
546 } else if (reader.name() == QLatin1String("color")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
547 XlsxColor color;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
548 color.loadFromXml(reader);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
549 rule->attrs[XlsxCfRuleData::A_color1] = color;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
550 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
551 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
552 if (reader.tokenType() == QXmlStreamReader::EndElement
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
553 && reader.name() == QStringLiteral("dataBar")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
554 break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
555 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
556 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
557
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
558 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
559 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
560
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
561 bool ConditionalFormattingPrivate::readCfColorScale(QXmlStreamReader &reader, XlsxCfRuleData *rule)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
562 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
563 Q_ASSERT(reader.name() == QLatin1String("colorScale"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
564
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
565 while (!reader.atEnd()) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
566 reader.readNextStartElement();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
567 if (reader.tokenType() == QXmlStreamReader::StartElement) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
568 if (reader.name() == QLatin1String("cfvo")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
569 XlsxCfVoData data;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
570 readCfVo(reader, data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
571 if (!rule->attrs.contains(XlsxCfRuleData::A_cfvo1))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
572 rule->attrs[XlsxCfRuleData::A_cfvo1] = QVariant::fromValue(data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
573 else if (!rule->attrs.contains(XlsxCfRuleData::A_cfvo2))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
574 rule->attrs[XlsxCfRuleData::A_cfvo2] = QVariant::fromValue(data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
575 else
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
576 rule->attrs[XlsxCfRuleData::A_cfvo2] = QVariant::fromValue(data);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
577 } else if (reader.name() == QLatin1String("color")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
578 XlsxColor color;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
579 color.loadFromXml(reader);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
580 if (!rule->attrs.contains(XlsxCfRuleData::A_color1))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
581 rule->attrs[XlsxCfRuleData::A_color1] = color;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
582 else if (!rule->attrs.contains(XlsxCfRuleData::A_color2))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
583 rule->attrs[XlsxCfRuleData::A_color2] = color;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
584 else
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
585 rule->attrs[XlsxCfRuleData::A_color3] = color;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
586 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
587 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
588 if (reader.tokenType() == QXmlStreamReader::EndElement
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
589 && reader.name() == QStringLiteral("colorScale")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
590 break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
591 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
592 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
593
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
594 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
595 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
596
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
597 bool ConditionalFormattingPrivate::readCfVo(QXmlStreamReader &reader, XlsxCfVoData &cfvo)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
598 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
599 Q_ASSERT(reader.name() == QStringLiteral("cfvo"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
600
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
601 QXmlStreamAttributes attrs = reader.attributes();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
602
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
603 QString type = attrs.value(QLatin1String("type")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
604 ConditionalFormatting::ValueObjectType t;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
605 if (type == QLatin1String("formula"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
606 t = ConditionalFormatting::VOT_Formula;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
607 else if (type == QLatin1String("max"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
608 t = ConditionalFormatting::VOT_Max;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
609 else if (type == QLatin1String("min"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
610 t = ConditionalFormatting::VOT_Min;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
611 else if (type == QLatin1String("num"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
612 t = ConditionalFormatting::VOT_Num;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
613 else if (type == QLatin1String("percent"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
614 t = ConditionalFormatting::VOT_Percent;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
615 else //if (type == QLatin1String("percentile"))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
616 t = ConditionalFormatting::VOT_Percentile;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
617
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
618 cfvo.type = t;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
619 cfvo.value = attrs.value(QLatin1String("val")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
620 if (attrs.value(QLatin1String("gte")) == QLatin1String("0")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
621 //default is true
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
622 cfvo.gte = false;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
623 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
624 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
625 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
626
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
627 bool ConditionalFormatting::loadFromXml(QXmlStreamReader &reader, Styles *styles)
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
628 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
629 Q_ASSERT(reader.name() == QStringLiteral("conditionalFormatting"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
630
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
631 d->ranges.clear();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
632 d->cfRules.clear();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
633 QXmlStreamAttributes attrs = reader.attributes();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
634 QString sqref = attrs.value(QLatin1String("sqref")).toString();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
635 foreach (QString range, sqref.split(QLatin1Char(' ')))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
636 this->addRange(range);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
637
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
638 while (!reader.atEnd()) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
639 reader.readNextStartElement();
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
640 if (reader.tokenType() == QXmlStreamReader::StartElement) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
641 if (reader.name() == QLatin1String("cfRule")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
642 QSharedPointer<XlsxCfRuleData> cfRule(new XlsxCfRuleData);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
643 d->readCfRule(reader, cfRule.data(), styles);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
644 d->cfRules.append(cfRule);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
645 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
646 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
647 if (reader.tokenType() == QXmlStreamReader::EndElement
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
648 && reader.name() == QStringLiteral("conditionalFormatting")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
649 break;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
650 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
651 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
652
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
653
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
654 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
655 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
656
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
657 bool ConditionalFormatting::saveToXml(QXmlStreamWriter &writer) const
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
658 {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
659 writer.writeStartElement(QStringLiteral("conditionalFormatting"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
660 QStringList sqref;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
661 foreach (CellRange range, ranges())
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
662 sqref.append(range.toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
663 writer.writeAttribute(QStringLiteral("sqref"), sqref.join(QLatin1Char(' ')));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
664
19
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
665 const QString extNS = QStringLiteral("http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
666 const QString xmNS = QStringLiteral("http://schemas.microsoft.com/office/excel/2006/main");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
667
1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
668 for (int i=0; i<d->cfRules.size(); ++i) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
669 const QSharedPointer<XlsxCfRuleData> &rule = d->cfRules[i];
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
670 writer.writeStartElement(QStringLiteral("cfRule"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
671 writer.writeAttribute(QStringLiteral("type"), rule->attrs[XlsxCfRuleData::A_type].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
672 if (rule->dxfFormat.dxfIndexValid())
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
673 writer.writeAttribute(QStringLiteral("dxfId"), QString::number(rule->dxfFormat.dxfIndex()));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
674 writer.writeAttribute(QStringLiteral("priority"), QString::number(rule->priority));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
675 if (rule->attrs.contains(XlsxCfRuleData::A_stopIfTrue))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
676 writer.writeAttribute(QStringLiteral("stopIfTrue"), rule->attrs[XlsxCfRuleData::A_stopIfTrue].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
677 if (rule->attrs.contains(XlsxCfRuleData::A_aboveAverage))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
678 writer.writeAttribute(QStringLiteral("aboveAverage"), rule->attrs[XlsxCfRuleData::A_aboveAverage].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
679 if (rule->attrs.contains(XlsxCfRuleData::A_percent))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
680 writer.writeAttribute(QStringLiteral("percent"), rule->attrs[XlsxCfRuleData::A_percent].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
681 if (rule->attrs.contains(XlsxCfRuleData::A_bottom))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
682 writer.writeAttribute(QStringLiteral("bottom"), rule->attrs[XlsxCfRuleData::A_bottom].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
683 if (rule->attrs.contains(XlsxCfRuleData::A_operator))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
684 writer.writeAttribute(QStringLiteral("operator"), rule->attrs[XlsxCfRuleData::A_operator].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
685 if (rule->attrs.contains(XlsxCfRuleData::A_text))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
686 writer.writeAttribute(QStringLiteral("text"), rule->attrs[XlsxCfRuleData::A_text].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
687 if (rule->attrs.contains(XlsxCfRuleData::A_timePeriod))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
688 writer.writeAttribute(QStringLiteral("timePeriod"), rule->attrs[XlsxCfRuleData::A_timePeriod].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
689 if (rule->attrs.contains(XlsxCfRuleData::A_rank))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
690 writer.writeAttribute(QStringLiteral("rank"), rule->attrs[XlsxCfRuleData::A_rank].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
691 if (rule->attrs.contains(XlsxCfRuleData::A_stdDev))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
692 writer.writeAttribute(QStringLiteral("stdDev"), rule->attrs[XlsxCfRuleData::A_stdDev].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
693 if (rule->attrs.contains(XlsxCfRuleData::A_equalAverage))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
694 writer.writeAttribute(QStringLiteral("equalAverage"), rule->attrs[XlsxCfRuleData::A_equalAverage].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
695
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
696 if (rule->attrs[XlsxCfRuleData::A_type] == QLatin1String("dataBar")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
697 writer.writeStartElement(QStringLiteral("dataBar"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
698 if (rule->attrs.contains(XlsxCfRuleData::A_hideData))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
699 writer.writeAttribute(QStringLiteral("showValue"), QStringLiteral("0"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
700 d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
701 d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo2].value<XlsxCfVoData>());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
702 rule->attrs[XlsxCfRuleData::A_color1].value<XlsxColor>().saveToXml(writer);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
703 writer.writeEndElement();//dataBar
19
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
704 writer.writeStartElement(QStringLiteral("extLst"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
705 writer.writeStartElement(QStringLiteral("ext"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
706 writer.writeNamespace(extNS, QStringLiteral("x14"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
707 writer.writeAttribute(QStringLiteral("uri"),
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
708 QStringLiteral("{B025F937-C7B1-47D3-B67F-A62EFF666E3E}"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
709 writer.writeStartElement(extNS, QStringLiteral("id"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
710 writer.writeCharacters(QStringLiteral("{00000000-000E-0000-0000-000001000000}"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
711 writer.writeEndElement(); //id
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
712 writer.writeEndElement(); //ext
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
713 writer.writeEndElement(); //extLst
1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
714 } else if (rule->attrs[XlsxCfRuleData::A_type] == QLatin1String("colorScale")) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
715 writer.writeStartElement(QStringLiteral("colorScale"));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
716 d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
717 d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo2].value<XlsxCfVoData>());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
718 if (rule->attrs.contains(XlsxCfRuleData::A_cfvo3))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
719 d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo3].value<XlsxCfVoData>());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
720
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
721 rule->attrs[XlsxCfRuleData::A_color1].value<XlsxColor>().saveToXml(writer);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
722 rule->attrs[XlsxCfRuleData::A_color2].value<XlsxColor>().saveToXml(writer);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
723 if (rule->attrs.contains(XlsxCfRuleData::A_color3))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
724 rule->attrs[XlsxCfRuleData::A_color3].value<XlsxColor>().saveToXml(writer);
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
725
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
726 writer.writeEndElement();//colorScale
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
727 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
728
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
729
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
730 if (rule->attrs.contains(XlsxCfRuleData::A_formula1_temp)) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
731 QString startCell = ranges()[0].toString().split(QLatin1Char(':'))[0];
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
732 writer.writeTextElement(QStringLiteral("formula"), rule->attrs[XlsxCfRuleData::A_formula1_temp].toString().arg(startCell));
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
733 } else if (rule->attrs.contains(XlsxCfRuleData::A_formula1)) {
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
734 writer.writeTextElement(QStringLiteral("formula"), rule->attrs[XlsxCfRuleData::A_formula1].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
735 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
736 if (rule->attrs.contains(XlsxCfRuleData::A_formula2))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
737 writer.writeTextElement(QStringLiteral("formula"), rule->attrs[XlsxCfRuleData::A_formula2].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
738 if (rule->attrs.contains(XlsxCfRuleData::A_formula3))
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
739 writer.writeTextElement(QStringLiteral("formula"), rule->attrs[XlsxCfRuleData::A_formula3].toString());
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
740
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
741 writer.writeEndElement(); //cfRule
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
742 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
743
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
744 writer.writeEndElement(); //conditionalFormatting
19
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
745 writer.writeStartElement(QStringLiteral("extLst"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
746 writer.writeStartElement(QStringLiteral("ext"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
747 writer.writeNamespace(extNS, QStringLiteral("x14"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
748 writer.writeAttribute(QStringLiteral("uri"),
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
749 QStringLiteral("{78C0D931-6437-407d-A8EE-F0AAD7539E65}"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
750 writer.writeStartElement(extNS, QStringLiteral("conditionalFormattings"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
751 writer.writeStartElement(extNS, QStringLiteral("conditionalFormatting"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
752 writer.writeNamespace(xmNS, QStringLiteral("xm"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
753 writer.writeStartElement(extNS, QStringLiteral("cfRule"));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
754 writer.writeAttribute("type", "dataBar");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
755 writer.writeAttribute("id", "{00000000-000E-0000-0000-000001000000}");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
756 writer.writeStartElement(extNS, "dataBar");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
757 writer.writeAttribute("gradient", "0");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
758 writer.writeAttribute("negativeBarColorSameAsPositive", "1");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
759 writer.writeAttribute("axisPosition", "none");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
760 writer.writeStartElement(extNS, "cfvo");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
761 writer.writeAttribute("type", "num");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
762 writer.writeStartElement(xmNS, "f");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
763 writer.writeCharacters("0");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
764 writer.writeEndElement(); // f
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
765 writer.writeEndElement(); // cfvo
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
766
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
767 writer.writeStartElement(extNS, "cfvo");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
768 writer.writeAttribute("type", "num");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
769 writer.writeStartElement(xmNS, "f");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
770 writer.writeCharacters("100");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
771 writer.writeEndElement(); // f
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
772 writer.writeEndElement(); // cfvo
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
773 writer.writeEndElement(); // dataBar
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
774 writer.writeEndElement(); // cfrule
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
775
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
776 writer.writeStartElement(xmNS, "sqref");
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
777 writer.writeCharacters(sqref.join(QLatin1Char(' ')));
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
778 writer.writeEndElement(); // sqref
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
779
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
780 writer.writeEndElement(); // conditionalFormatting
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
781 writer.writeEndElement(); // conditionalFormattings
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
782
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
783 writer.writeEndElement(); //ext
4ecb91aaf33f Hack dataBar's without gradient
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1
diff changeset
784 writer.writeEndElement(); //extLst
1
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
785 return true;
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
786 }
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
787
93d3106bb9a4 Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
788 QT_END_NAMESPACE_XLSX
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)