LibreOffice Module sc (master) 1
condformatbuffer.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include "worksheethelper.hxx"
23#include <tools/color.hxx>
24#include <colorscale.hxx>
25#include <conditio.hxx>
26#include <rangelst.hxx>
27
28#include <memory>
29#include <vector>
30
32class ScDataBarFormat;
34class ScIconSetFormat;
36
37namespace oox { class AttributeList; }
38
39namespace oox::xls {
40
41class CondFormat;
42
45{
46 typedef ::std::vector< ApiTokenSequence > ApiTokenSequenceVector;
47
49 OUString maText;
50 sal_Int32 mnPriority;
51 sal_Int32 mnType;
52 sal_Int32 mnOperator;
53 sal_Int32 mnTimePeriod;
54 sal_Int32 mnRank;
55 sal_Int32 mnStdDev;
56 sal_Int32 mnDxfId;
58 bool mbBottom;
59 bool mbPercent;
62
63 explicit CondFormatRuleModel();
64
66 void setBiffOperator( sal_Int32 nOperator );
67
69 void setBiff12TextType( sal_Int32 nOperator );
70};
71
73{
75 double mnVal;
76
77 bool mbMin;
78 bool mbMax;
81 bool mbNum;
82 OUString maFormula;
83
85 maColor(),
86 mnVal(0),
87 mbMin(false),
88 mbMax(false),
89 mbPercent(false),
90 mbPercentile(false),
91 mbNum(false) {}
92};
93
94class ColorScaleRule final : public WorksheetHelper
95{
96public:
97 ColorScaleRule( const CondFormat& rFormat );
98
99 void importCfvo( const AttributeList& rAttribs );
100 void importColor( const AttributeList& rAttribs );
101
102 void AddEntries( ScColorScaleFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
103
104private:
105 std::vector< ColorScaleRuleModelEntry > maColorScaleRuleEntries;
106
107 sal_uInt32 mnCfvo;
108 sal_uInt32 mnCol;
109};
110
111class DataBarRule final : public WorksheetHelper
112{
113public:
114 DataBarRule( const CondFormat& rFormat );
115 void importCfvo( const AttributeList& rAttribs );
116 void importColor( const AttributeList& rAttribs );
117 void importAttribs( const AttributeList& rAttribs );
118
119 void SetData( ScDataBarFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
120
122
123private:
124 std::unique_ptr<ScDataBarFormatData> mxFormat;
125
126 std::unique_ptr<ColorScaleRuleModelEntry> mpUpperLimit;
127 std::unique_ptr<ColorScaleRuleModelEntry> mpLowerLimit;
128};
129
130class IconSetRule final : public WorksheetHelper
131{
132public:
133 IconSetRule( const WorksheetHelper& rParent );
134 void importCfvo( const AttributeList& rAttribs );
135 void importAttribs( const AttributeList& rAttribs );
136 void importFormula(const OUString& rFormula);
137 void importIcon(const AttributeList& rAttribs);
138
139 void SetData( ScIconSetFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
140
141private:
142 std::vector< ColorScaleRuleModelEntry > maEntries;
143 std::unique_ptr<ScIconSetFormatData> mxFormatData;
146};
147
149class CondFormatRule final : public WorksheetHelper
150{
151friend class CondFormatBuffer;
152public:
153 explicit CondFormatRule( const CondFormat& rCondFormat, ScConditionalFormat* pFormat );
154
156 void importCfRule( const AttributeList& rAttribs );
158 void appendFormula( const OUString& rFormula );
159
161 void importCfRule( SequenceInputStream& rStrm );
162
164 void setFormatEntry(sal_Int32 nPriority, ScFormatEntry* pEntry);
165
167 void finalizeImport();
168
170 sal_Int32 getPriority() const { return maModel.mnPriority; }
171
175
176private:
181 std::unique_ptr<ColorScaleRule> mpColor;
182 std::unique_ptr<DataBarRule> mpDataBar;
183 std::unique_ptr<IconSetRule> mpIconSet;
184};
185
186typedef std::shared_ptr< CondFormatRule > CondFormatRuleRef;
187
190{
192 bool mbPivot;
193
194 explicit CondFormatModel();
195};
196
197class CondFormatBuffer;
198
200class CondFormat final : public WorksheetHelper
201{
202friend class CondFormatBuffer;
203public:
204 explicit CondFormat( const WorksheetHelper& rHelper );
205 ~CondFormat();
206
208 void importConditionalFormatting( const AttributeList& rAttribs );
211
215 void importCfRule( SequenceInputStream& rStrm );
216
218 void finalizeImport();
219
221 const ScRangeList& getRanges() const { return maModel.maRanges; }
222
224 void insertRule( CondFormatRuleRef const & xRule );
225private:
227
228private:
230
235};
236
238{
240 // AxisColor
243 // NegativeFillColor
245 OUString maAxisPosition; // DataBar
246 OUString maColorScaleType; // Cfvo
247 OUString msScaleTypeValue; // Cfvo
248 bool mbGradient; // DataBar
249 bool mbIsLower; // Cfvo
250};
251
253{
255 {
262 };
266public:
267
268 ExtCfDataBarRule(ScDataBarFormatData* pTarget, const WorksheetHelper& rParent);
269 void finalizeImport();
270 void importDataBar( const AttributeList& rAttribs );
271 void importPositiveFillColor( const AttributeList& rAttribs );
272 void importNegativeFillColor( const AttributeList& rAttribs );
273 void importAxisColor( const AttributeList& rAttribs );
274 void importCfvo( const AttributeList& rAttribs );
277};
278
280{
281public:
282 ExtCfCondFormat(ScRangeList aRange, std::vector< std::unique_ptr<ScFormatEntry> >& rEntries,
283 const std::vector<sal_Int32>* pPriorities = nullptr);
285
286 const ScRangeList& getRange() const;
287 const std::vector< std::unique_ptr<ScFormatEntry> >& getEntries() const;
288 const std::vector<sal_Int32>& getPriorities() const { return maPriorities; }
289
290private:
291 std::vector< std::unique_ptr<ScFormatEntry> > maEntries;
292 std::vector<sal_Int32> maPriorities;
294};
295
296typedef std::shared_ptr< CondFormat > CondFormatRef;
297typedef std::shared_ptr< ExtCfDataBarRule > ExtCfDataBarRuleRef;
298
300{
301public:
302 explicit CondFormatBuffer( const WorksheetHelper& rHelper );
303
309 std::vector< std::unique_ptr<ExtCfCondFormat> >& importExtCondFormat();
310 std::vector<std::unique_ptr<ScFormatEntry> >& importExtFormatEntries();
311
313 static sal_Int32 convertToApiOperator( sal_Int32 nToken );
315 void finalizeImport();
316 bool insertRule(CondFormatRef const & xCondFmt, CondFormatRuleRef const & xRule);
317
318private:
320 void updateImport(const ScDataBarFormatData* pTarget);
321
322private:
327 std::vector< std::unique_ptr<ExtCfCondFormat> > maExtCondFormats;
328 std::vector<std::unique_ptr<ScFormatEntry> > maExtFormatEntries;
330};
331
332} // namespace oox::xls
333
334/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< ColorScaleRuleModelEntry > maColorScaleRuleEntries
void importColor(const AttributeList &rAttribs)
ColorScaleRule(const CondFormat &rFormat)
void importCfvo(const AttributeList &rAttribs)
void AddEntries(ScColorScaleFormat *pFormat, ScDocument *pDoc, const ScAddress &rAddr)
RefVector< ExtCfDataBarRule > ExtCfDataBarRuleVec
std::vector< std::unique_ptr< ExtCfCondFormat > > & importExtCondFormat()
ExtCfDataBarRuleVec maCfRules
All conditional formatting in a sheet.
ExtCfDataBarRuleRef createExtCfDataBarRule(ScDataBarFormatData *pTarget)
CondFormatRef importConditionalFormatting(const AttributeList &rAttribs)
Imports settings from the conditionalFormatting element.
std::vector< std::unique_ptr< ScFormatEntry > > & importExtFormatEntries()
static ScConditionMode convertToInternalOperator(sal_Int32 nToken)
std::vector< std::unique_ptr< ExtCfCondFormat > > maExtCondFormats
All external conditional formatting rules in a sheet.
CondFormatBuffer(const WorksheetHelper &rHelper)
bool insertRule(CondFormatRef const &xCondFmt, CondFormatRuleRef const &xRule)
void updateImport(const ScDataBarFormatData *pTarget)
static sal_Int32 convertToApiOperator(sal_Int32 nToken)
Converts an OOXML condition operator token to the API constant.
CondFormatRef importCondFormatting(SequenceInputStream &rStrm)
Imports settings from the CONDFORMATTING record.
std::vector< std::unique_ptr< ScFormatEntry > > maExtFormatEntries
RefVector< CondFormat > CondFormatVec
Represents a single rule in a conditional formatting.
void importCfRule(const AttributeList &rAttribs)
Imports rule settings from the cfRule element.
CondFormatRuleModel maModel
void appendFormula(const OUString &rFormula)
Appends a new condition formula string.
std::unique_ptr< ColorScaleRule > mpColor
ScConditionalFormat * mpFormat
void finalizeImport()
Creates a conditional formatting rule in the Calc document.
const CondFormat & mrCondFormat
void setFormatEntry(sal_Int32 nPriority, ScFormatEntry *pEntry)
Directly set a ScFormatEntry with a priority ready for finalizeImport().
ColorScaleRule * getColorScale()
std::unique_ptr< IconSetRule > mpIconSet
CondFormatRule(const CondFormat &rCondFormat, ScConditionalFormat *pFormat)
sal_Int32 getPriority() const
Returns the priority of this rule.
std::unique_ptr< DataBarRule > mpDataBar
Represents a conditional formatting object with a list of affected cell ranges.
RefMap< sal_Int32, CondFormatRule > CondFormatRuleMap
CondFormat(const WorksheetHelper &rHelper)
void insertRule(CondFormatRuleRef const &xRule)
const ScRangeList & getRanges() const
Returns the cell ranges this conditional formatting belongs to.
ScConditionalFormat * mpFormat
Maps formatting rules by priority.
void importConditionalFormatting(const AttributeList &rAttribs)
Imports settings from the conditionalFormatting element.
CondFormatRuleMap maRules
Model of this conditional formatting.
CondFormatRuleRef createRule()
void importCondFormatting(SequenceInputStream &rStrm)
Imports settings from the CONDFORMATTING record.
CondFormatRuleRef importCfRule(const AttributeList &rAttribs)
Imports a conditional formatting rule from the cfRule element.
void finalizeImport()
Creates the conditional formatting in the Calc document.
std::unique_ptr< ColorScaleRuleModelEntry > mpLowerLimit
ScDataBarFormatData * getDataBarFormatData()
void importCfvo(const AttributeList &rAttribs)
DataBarRule(const CondFormat &rFormat)
std::unique_ptr< ScDataBarFormatData > mxFormat
std::unique_ptr< ColorScaleRuleModelEntry > mpUpperLimit
void importColor(const AttributeList &rAttribs)
void SetData(ScDataBarFormat *pFormat, ScDocument *pDoc, const ScAddress &rAddr)
void importAttribs(const AttributeList &rAttribs)
const std::vector< sal_Int32 > & getPriorities() const
const ScRangeList & getRange() const
std::vector< sal_Int32 > maPriorities
std::vector< std::unique_ptr< ScFormatEntry > > maEntries
const std::vector< std::unique_ptr< ScFormatEntry > > & getEntries() const
ExtCfCondFormat(ScRangeList aRange, std::vector< std::unique_ptr< ScFormatEntry > > &rEntries, const std::vector< sal_Int32 > *pPriorities=nullptr)
void importPositiveFillColor(const AttributeList &rAttribs)
ScDataBarFormatData * mpTarget
void importDataBar(const AttributeList &rAttribs)
void importNegativeFillColor(const AttributeList &rAttribs)
const ScDataBarFormatData * GetDataBarData()
void importCfvo(const AttributeList &rAttribs)
ExtCfDataBarRule(ScDataBarFormatData *pTarget, const WorksheetHelper &rParent)
void importAxisColor(const AttributeList &rAttribs)
std::unique_ptr< ScIconSetFormatData > mxFormatData
void importIcon(const AttributeList &rAttribs)
std::vector< ColorScaleRuleModelEntry > maEntries
void SetData(ScIconSetFormat *pFormat, ScDocument *pDoc, const ScAddress &rAddr)
IconSetRule(const WorksheetHelper &rParent)
void importFormula(const OUString &rFormula)
void importAttribs(const AttributeList &rAttribs)
void importCfvo(const AttributeList &rAttribs)
ColorTransparency
ScConditionMode
Definition: conditio.hxx:60
void SvStream & rStrm
std::shared_ptr< CondFormatRule > CondFormatRuleRef
@ CondFormat
Shared formula definition.
std::shared_ptr< CondFormat > CondFormatRef
std::shared_ptr< ExtCfDataBarRule > ExtCfDataBarRuleRef
const sal_uInt32 UNSIGNED_RGB_TRANSPARENT
DefTokenId nToken
Definition: qproform.cxx:397
Model for a conditional formatting object.
bool mbPivot
Cell ranges for this conditional format.
CondFormatModel()
Conditional formatting belongs to pivot table.
Model for a single rule in a conditional formatting.
bool mbEqualAverage
In average rules: True = above average, false = below.
bool mbAboveAverage
In top-10 rules: True = percent, false = rank.
sal_Int32 mnTimePeriod
In cell-is rules: Comparison operator.
sal_Int32 mnPriority
Text for 'contains' rules.
CondFormatRuleModel()
In average rules: True = include average, false = exclude.
bool mbPercent
In top-10 rules: True = bottom, false = top.
sal_Int32 mnType
Priority of this rule.
bool mbStopIfTrue
Differential formatting identifier.
ApiTokenSequenceVector maFormulas
sal_Int32 mnRank
In time-period rules: Type of time period.
::std::vector< ApiTokenSequence > ApiTokenSequenceVector
OUString maText
Formulas for rule conditions.
bool mbBottom
True = stop evaluating rules, if this rule is true.
sal_Int32 mnStdDev
In top-10 rules: True = bottom, false = top.
void setBiff12TextType(sal_Int32 nOperator)
Sets the passed BIFF12 text comparison type and operator.
sal_Int32 mnOperator
Type of the rule.
void setBiffOperator(sal_Int32 nOperator)
Sets the passed BIFF operator for condition type cellIs.
sal_Int32 mnDxfId
In average rules: Number of std deviations.