1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX
11 #define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX
13 #include <conditio.hxx>
14 #include <formula/funcutl.hxx>
15 #include <vcl/weld.hxx>
16 #include <svl/lstner.hxx>
17 #include <svx/fntctrl.hxx>
19 class ScIconSetFrmtDataEntry
;
20 class ScCondFormatDlg
;
21 class ScCondFormatList
;
23 class ScColorScaleFormat
;
24 class ScDataBarFormat
;
25 class ScIconSetFormat
;
26 struct ScDataBarFormatData
;
28 namespace condformat
{
32 enum ScCondFrmtEntryType
50 ScCondFormatList
* mpParent
;
51 std::unique_ptr
<weld::Builder
> mxBuilder
;
55 std::unique_ptr
<weld::Widget
> mxBorder
;
56 std::unique_ptr
<weld::Container
> mxGrid
;
57 std::unique_ptr
<weld::Label
> mxFtCondNr
;
58 std::unique_ptr
<weld::Label
> mxFtCondition
;
61 OUString
const maStrCondition
;
62 Link
<ScCondFrmtEntry
&,void> maClickHdl
;
64 DECL_LINK( EntrySelectHdl
, const MouseEvent
&, bool );
67 std::unique_ptr
<weld::ComboBox
> mxLbType
;
72 virtual void Select();
73 virtual void Deselect();
75 virtual OUString
GetExpressionString() = 0;
78 ScCondFrmtEntry(ScCondFormatList
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
);
79 virtual ~ScCondFrmtEntry();
81 void Show() { mxGrid
->show(); }
83 void set_grid_top_attach(int nAttach
) { mxBorder
->set_grid_top_attach(nAttach
); }
84 int get_grid_top_attach() const { return mxBorder
->get_grid_top_attach(); }
86 Size
get_preferred_size() const { return mxBorder
->get_preferred_size(); }
88 void SetPos(const ScAddress
& rPos
) { maPos
= rPos
; };
89 bool IsSelected() const { return mbActive
;}
90 void SetIndex(sal_Int32 nIndex
);
92 virtual ScFormatEntry
* GetEntry() const = 0;
93 virtual void SetActive() = 0;
94 virtual void SetInactive() = 0;
96 virtual condformat::entry::ScCondFrmtEntryType
GetType() = 0;
99 class ScConditionFrmtEntry
: public ScCondFrmtEntry
, public SfxListener
101 //cond format ui elements
102 SvxFontPrevWindow maWdPreview
;
103 std::unique_ptr
<weld::ComboBox
> mxLbCondType
;
104 std::unique_ptr
<formula::RefEdit
> mxEdVal1
;
105 std::unique_ptr
<formula::RefEdit
> mxEdVal2
;
106 std::unique_ptr
<weld::Label
> mxFtVal
;
107 std::unique_ptr
<weld::Label
> mxFtStyle
;
108 std::unique_ptr
<weld::ComboBox
> mxLbStyle
;
109 std::unique_ptr
<weld::Widget
> mxWdPreviewWin
;
110 std::unique_ptr
<weld::CustomWeld
> mxWdPreview
;
111 bool mbIsInStyleCreate
;
113 static const sal_Int32 NUM_COND_ENTRIES
= 24;
114 // Lookup table from positions in maLbCondType to the condition mode enum
115 static const ScConditionMode mpEntryToCond
[NUM_COND_ENTRIES
];
117 ScFormatEntry
* createConditionEntry() const;
119 virtual OUString
GetExpressionString() override
;
120 void Init(ScCondFormatDlg
* pDialogParent
);
121 DECL_LINK( StyleSelectHdl
, weld::ComboBox
&, void );
122 DECL_LINK( ConditionTypeSelectHdl
, weld::ComboBox
&, void );
123 DECL_LINK( OnEdChanged
, formula::RefEdit
&, void );
125 // Searches the lookup table for the entry position, given condition mode
126 static sal_Int32
ConditionModeToEntryPos( ScConditionMode eMode
);
127 // Accesses the lookup table for the condition mode, given entry position
128 static ScConditionMode
EntryPosToConditionMode( sal_Int32 aEntryPos
);
129 // Returns the number of edit fields used for a given condition mode
130 static sal_Int32
GetNumberEditFields( ScConditionMode eMode
);
133 virtual void Select() override
;
134 virtual void Deselect() override
;
137 ScConditionFrmtEntry(ScCondFormatList
* pParent
, ScDocument
* pDoc
, ScCondFormatDlg
* pDialogParent
,
138 const ScAddress
& rPos
, const ScCondFormatEntry
* pFormatEntry
= nullptr);
139 virtual ~ScConditionFrmtEntry() override
;
141 virtual ScFormatEntry
* GetEntry() const override
;
142 virtual void SetActive() override
;
143 virtual void SetInactive() override
;
145 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
147 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::CONDITION
; }
150 class ScFormulaFrmtEntry
: public ScCondFrmtEntry
152 SvxFontPrevWindow maWdPreview
;
153 std::unique_ptr
<weld::Label
> mxFtStyle
;
154 std::unique_ptr
<weld::ComboBox
> mxLbStyle
;
155 std::unique_ptr
<weld::Widget
> mxWdPreviewWin
;
156 std::unique_ptr
<weld::CustomWeld
> mxWdPreview
;
157 std::unique_ptr
<formula::RefEdit
> mxEdFormula
;
159 ScFormatEntry
* createFormulaEntry() const;
160 virtual OUString
GetExpressionString() override
;
161 void Init(ScCondFormatDlg
* pDialogParent
);
163 DECL_LINK(StyleSelectHdl
, weld::ComboBox
&, void);
166 ScFormulaFrmtEntry(ScCondFormatList
* pParent
, ScDocument
* PDoc
, ScCondFormatDlg
* pDialogParent
, const ScAddress
& rPos
, const ScCondFormatEntry
* pFormatEntry
= nullptr);
167 virtual ~ScFormulaFrmtEntry() override
;
169 virtual ScFormatEntry
* GetEntry() const override
;
170 virtual void SetActive() override
;
171 virtual void SetInactive() override
;
172 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::FORMULA
; }
175 class ScColorScale2FrmtEntry
: public ScCondFrmtEntry
178 //color format ui elements
179 std::unique_ptr
<weld::ComboBox
> mxLbColorFormat
;
181 //color scale ui elements
182 std::unique_ptr
<weld::ComboBox
> mxLbEntryTypeMin
;
183 std::unique_ptr
<weld::ComboBox
> mxLbEntryTypeMax
;
185 std::unique_ptr
<weld::Entry
> mxEdMin
;
186 std::unique_ptr
<weld::Entry
> mxEdMax
;
188 std::unique_ptr
<ColorListBox
> mxLbColMin
;
189 std::unique_ptr
<ColorListBox
> mxLbColMax
;
191 std::unique_ptr
<weld::Label
> mxFtMin
;
192 std::unique_ptr
<weld::Label
> mxFtMax
;
194 ScFormatEntry
* createColorscaleEntry() const;
196 virtual OUString
GetExpressionString() override
;
199 DECL_LINK( EntryTypeHdl
, weld::ComboBox
&, void );
201 ScColorScale2FrmtEntry(ScCondFormatList
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScColorScaleFormat
* pFormat
= nullptr);
202 virtual ~ScColorScale2FrmtEntry() override
;
203 virtual ScFormatEntry
* GetEntry() const override
;
204 virtual void SetActive() override
;
205 virtual void SetInactive() override
;
206 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::COLORSCALE2
; }
209 class ScColorScale3FrmtEntry
: public ScCondFrmtEntry
212 //color format ui elements
213 std::unique_ptr
<weld::ComboBox
> mxLbColorFormat
;
215 //color scale ui elements
216 std::unique_ptr
<weld::ComboBox
> mxLbEntryTypeMin
;
217 std::unique_ptr
<weld::ComboBox
> mxLbEntryTypeMiddle
;
218 std::unique_ptr
<weld::ComboBox
> mxLbEntryTypeMax
;
220 std::unique_ptr
<weld::Entry
> mxEdMin
;
221 std::unique_ptr
<weld::Entry
> mxEdMiddle
;
222 std::unique_ptr
<weld::Entry
> mxEdMax
;
224 std::unique_ptr
<ColorListBox
> mxLbColMin
;
225 std::unique_ptr
<ColorListBox
> mxLbColMiddle
;
226 std::unique_ptr
<ColorListBox
> mxLbColMax
;
228 std::unique_ptr
<weld::Label
> mxFtMin
;
229 std::unique_ptr
<weld::Label
> mxFtMax
;
231 ScFormatEntry
* createColorscaleEntry() const;
233 virtual OUString
GetExpressionString() override
;
236 DECL_LINK( EntryTypeHdl
, weld::ComboBox
&, void );
238 ScColorScale3FrmtEntry(ScCondFormatList
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScColorScaleFormat
* pFormat
= nullptr);
239 virtual ~ScColorScale3FrmtEntry() override
;
240 virtual ScFormatEntry
* GetEntry() const override
;
241 virtual void SetActive() override
;
242 virtual void SetInactive() override
;
243 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::COLORSCALE3
; }
246 class ScDataBarFrmtEntry
: public ScCondFrmtEntry
248 //color format ui elements
249 std::unique_ptr
<weld::ComboBox
> mxLbColorFormat
;
251 //data bar ui elements
252 std::unique_ptr
<weld::ComboBox
> mxLbDataBarMinType
;
253 std::unique_ptr
<weld::ComboBox
> mxLbDataBarMaxType
;
254 std::unique_ptr
<weld::Entry
> mxEdDataBarMin
;
255 std::unique_ptr
<weld::Entry
> mxEdDataBarMax
;
256 std::unique_ptr
<weld::Button
> mxBtOptions
;
258 std::unique_ptr
<weld::Label
> mxFtMin
;
259 std::unique_ptr
<weld::Label
> mxFtMax
;
261 std::unique_ptr
<ScDataBarFormatData
> mpDataBarData
;
263 ScFormatEntry
* createDatabarEntry() const;
265 virtual OUString
GetExpressionString() override
;
268 DECL_LINK( OptionBtnHdl
, weld::Button
&, void );
269 DECL_LINK( DataBarTypeSelectHdl
, weld::ComboBox
&, void );
271 ScDataBarFrmtEntry(ScCondFormatList
* pParemt
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScDataBarFormat
* pFormat
= nullptr);
272 virtual ~ScDataBarFrmtEntry() override
;
273 virtual ScFormatEntry
* GetEntry() const override
;
274 virtual void SetActive() override
;
275 virtual void SetInactive() override
;
277 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::DATABAR
; }
280 class ScDateFrmtEntry
: public ScCondFrmtEntry
, public SfxListener
283 ScDateFrmtEntry(ScCondFormatList
* pParent
, ScDocument
* pDoc
, const ScCondDateFormatEntry
* pFormat
= nullptr);
284 virtual ~ScDateFrmtEntry() override
;
285 virtual ScFormatEntry
* GetEntry() const override
;
286 virtual void SetActive() override
;
287 virtual void SetInactive() override
;
288 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::DATE
; }
290 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
293 virtual OUString
GetExpressionString() override
;
298 DECL_LINK( StyleSelectHdl
, weld::ComboBox
&, void );
300 SvxFontPrevWindow maWdPreview
;
301 std::unique_ptr
<weld::ComboBox
> mxLbDateEntry
;
302 std::unique_ptr
<weld::Label
> mxFtStyle
;
303 std::unique_ptr
<weld::ComboBox
> mxLbStyle
;
304 std::unique_ptr
<weld::Widget
> mxWdPreviewWin
;
305 std::unique_ptr
<weld::CustomWeld
> mxWdPreview
;
307 bool mbIsInStyleCreate
;
310 class ScIconSetFrmtEntry
: public ScCondFrmtEntry
312 //color format ui elements
313 std::unique_ptr
<weld::ComboBox
> mxLbColorFormat
;
315 // icon set ui elements
316 std::unique_ptr
<weld::ComboBox
> mxLbIconSetType
;
318 std::unique_ptr
<weld::Container
> mxIconParent
;
320 typedef std::vector
<std::unique_ptr
<ScIconSetFrmtDataEntry
>> ScIconSetFrmtDataEntriesType
;
321 ScIconSetFrmtDataEntriesType maEntries
;
323 virtual OUString
GetExpressionString() override
;
327 DECL_LINK(IconSetTypeHdl
, weld::ComboBox
&, void);
330 ScIconSetFrmtEntry(ScCondFormatList
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScIconSetFormat
* pFormat
= nullptr);
331 virtual ~ScIconSetFrmtEntry() override
;
332 virtual ScFormatEntry
* GetEntry() const override
;
333 virtual void SetActive() override
;
334 virtual void SetInactive() override
;
335 virtual condformat::entry::ScCondFrmtEntryType
GetType() override
{ return condformat::entry::ICONSET
; }
340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */