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{
151public:
152 explicit CondFormatRule( const CondFormat& rCondFormat, ScConditionalFormat* pFormat );
153
155 void importCfRule( const AttributeList& rAttribs );
157 void appendFormula( const OUString& rFormula );
158
161
163 void setFormatEntry(sal_Int32 nPriority, ScFormatEntry* pEntry);
164
166 void finalizeImport();
167
169 sal_Int32 getPriority() const { return maModel.mnPriority; }
170
174
175private:
180 std::unique_ptr<ColorScaleRule> mpColor;
181 std::unique_ptr<DataBarRule> mpDataBar;
182 std::unique_ptr<IconSetRule> mpIconSet;
183};
184
185typedef std::shared_ptr< CondFormatRule > CondFormatRuleRef;
186
189{
191 bool mbPivot;
192
193 explicit CondFormatModel();
194};
195
196class CondFormatBuffer;
197
199class CondFormat final : public WorksheetHelper
200{
201friend class CondFormatBuffer;
202public:
203 explicit CondFormat( const WorksheetHelper& rHelper );
204
206 void importConditionalFormatting( const AttributeList& rAttribs );
209
213 void importCfRule( SequenceInputStream& rStrm );
214
216 void finalizeImport();
217
219 const ScRangeList& getRanges() const { return maModel.maRanges; }
220
222private:
224 void insertRule( CondFormatRuleRef const & xRule );
225
226private:
228
233};
234
236{
238 // AxisColor
240 // NegativeFillColor
242 OUString maAxisPosition; // DataBar
243 OUString maColorScaleType; // Cfvo
244 bool mbGradient; // DataBar
245 bool mbIsLower; // Cfvo
246};
247
249{
251 {
257 };
261public:
262
263 ExtCfDataBarRule(ScDataBarFormatData* pTarget, const WorksheetHelper& rParent);
264 void finalizeImport();
265 void importDataBar( const AttributeList& rAttribs );
266 void importNegativeFillColor( const AttributeList& rAttribs );
267 void importAxisColor( const AttributeList& rAttribs );
268 void importCfvo( const AttributeList& rAttribs );
270};
271
273{
274public:
275 ExtCfCondFormat(ScRangeList aRange, std::vector< std::unique_ptr<ScFormatEntry> >& rEntries,
276 const std::vector<sal_Int32>* pPriorities = nullptr);
278
279 const ScRangeList& getRange() const;
280 const std::vector< std::unique_ptr<ScFormatEntry> >& getEntries() const;
281 const std::vector<sal_Int32>& getPriorities() const { return maPriorities; }
282
283private:
284 std::vector< std::unique_ptr<ScFormatEntry> > maEntries;
285 std::vector<sal_Int32> maPriorities;
287};
288
289typedef std::shared_ptr< CondFormat > CondFormatRef;
290typedef std::shared_ptr< ExtCfDataBarRule > ExtCfDataBarRuleRef;
291
293{
294public:
295 explicit CondFormatBuffer( const WorksheetHelper& rHelper );
296
302 std::vector< std::unique_ptr<ExtCfCondFormat> >& importExtCondFormat();
303
305 static sal_Int32 convertToApiOperator( sal_Int32 nToken );
307 void finalizeImport();
308private:
310
311private:
316 std::vector< std::unique_ptr<ExtCfCondFormat> > maExtCondFormats;
318};
319
320} // namespace oox::xls
321
322/* 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.
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)
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.
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)
ScDataBarFormatData * mpTarget
void importDataBar(const AttributeList &rAttribs)
void importNegativeFillColor(const AttributeList &rAttribs)
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.