Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / condformatdlgentry.hxx
blob4ca6a9f1a38c31abd1ccb8dde83cf756d0452d89
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX
11 #define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX
13 #include "colorscale.hxx"
14 #include "conditio.hxx"
15 #include <formula/funcutl.hxx>
17 #include <svl/lstner.hxx>
19 class ScIconSetFrmtDataEntry;
20 class ScCondFormatDlg;
22 namespace condformat {
24 namespace entry {
26 enum ScCondFrmtEntryType
28 CONDITION,
29 FORMULA,
30 COLORSCALE2,
31 COLORSCALE3,
32 DATABAR,
33 ICONSET,
34 DATE
41 class ScCondFrmtEntry : public Control
43 private:
44 bool mbActive;
46 Link<ScCondFrmtEntry&,void> maClickHdl;
48 //general ui elements
49 VclPtr<FixedText> maFtCondNr;
50 VclPtr<FixedText> maFtCondition;
52 sal_Int32 mnIndex;
53 OUString maStrCondition;
54 protected:
55 VclPtr<ListBox> maLbType;
57 ScDocument* mpDoc;
58 ScAddress maPos;
60 virtual void Select();
61 virtual void Deselect();
63 virtual OUString GetExpressionString() = 0;
65 public:
66 ScCondFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos );
67 virtual ~ScCondFrmtEntry();
68 virtual void dispose() override;
70 virtual bool Notify( NotifyEvent& rNEvt ) override;
72 bool IsSelected() const { return mbActive;}
73 void SetIndex(sal_Int32 nIndex);
74 void SetHeight();
76 virtual ScFormatEntry* GetEntry() const = 0;
77 virtual void SetActive() = 0;
78 virtual void SetInactive() = 0;
80 virtual condformat::entry::ScCondFrmtEntryType GetType() = 0;
83 class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener
85 //cond format ui elements
86 VclPtr<ListBox> maLbCondType;
87 VclPtr<formula::RefEdit> maEdVal1;
88 VclPtr<formula::RefEdit> maEdVal2;
89 VclPtr<FixedText> maFtVal;
90 VclPtr<FixedText> maFtStyle;
91 VclPtr<ListBox> maLbStyle;
92 VclPtr<SvxFontPrevWindow> maWdPreview;
93 bool mbIsInStyleCreate;
95 static const sal_Int32 NUM_COND_ENTRIES = 24;
96 // Lookup table from positions in maLbCondType to the condition mode enum
97 static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES];
99 ScFormatEntry* createConditionEntry() const;
101 virtual OUString GetExpressionString() override;
102 void Init(ScCondFormatDlg* pDialogParent);
103 DECL_LINK_TYPED( StyleSelectHdl, ListBox&, void );
104 DECL_LINK_TYPED( ConditionTypeSelectHdl, ListBox&, void );
105 DECL_LINK_TYPED( OnEdChanged, Edit&, void );
107 // Searches the lookup table for the entry position, given condition mode
108 static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode );
109 // Accesses the lookup table for the condition mode, given entry position
110 static ScConditionMode EntryPosToConditionMode( sal_Int32 aEntryPos );
111 // Returns the number of edit fields used for a given condition mode
112 static sal_Int32 GetNumberEditFields( ScConditionMode eMode );
114 protected:
115 virtual void Select() override;
116 virtual void Deselect() override;
118 public:
119 ScConditionFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
120 const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr );
121 virtual ~ScConditionFrmtEntry();
122 virtual void dispose() override;
124 virtual ScFormatEntry* GetEntry() const override;
125 virtual void SetActive() override;
126 virtual void SetInactive() override;
128 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
129 using ScCondFrmtEntry::Notify;
131 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::CONDITION; }
134 class ScFormulaFrmtEntry : public ScCondFrmtEntry
136 VclPtr<FixedText> maFtStyle;
137 VclPtr<ListBox> maLbStyle;
138 VclPtr<SvxFontPrevWindow> maWdPreview;
139 VclPtr<formula::RefEdit> maEdFormula;
141 ScFormatEntry* createFormulaEntry() const;
142 virtual OUString GetExpressionString() override;
143 void Init(ScCondFormatDlg* pDialogParent);
145 DECL_LINK_TYPED( StyleSelectHdl, ListBox&, void );
147 public:
148 ScFormulaFrmtEntry( vcl::Window* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr );
149 virtual ~ScFormulaFrmtEntry();
150 virtual void dispose() override;
152 virtual ScFormatEntry* GetEntry() const override;
153 virtual void SetActive() override;
154 virtual void SetInactive() override;
155 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::FORMULA; }
158 class ScColorScale2FrmtEntry : public ScCondFrmtEntry
161 //color format ui elements
162 VclPtr<ListBox> maLbColorFormat;
164 //color scale ui elements
165 VclPtr<ListBox> maLbEntryTypeMin;
166 VclPtr<ListBox> maLbEntryTypeMax;
168 VclPtr<Edit> maEdMin;
169 VclPtr<Edit> maEdMax;
171 VclPtr<ColorListBox> maLbColMin;
172 VclPtr<ColorListBox> maLbColMax;
174 ScFormatEntry* createColorscaleEntry() const;
176 virtual OUString GetExpressionString() override;
177 void Init();
179 DECL_LINK_TYPED( EntryTypeHdl, ListBox&, void );
180 public:
181 ScColorScale2FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr );
182 virtual ~ScColorScale2FrmtEntry();
183 virtual void dispose() override;
184 virtual ScFormatEntry* GetEntry() const override;
185 virtual void SetActive() override;
186 virtual void SetInactive() override;
187 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE2; }
190 class ScColorScale3FrmtEntry : public ScCondFrmtEntry
193 //color format ui elements
194 VclPtr<ListBox> maLbColorFormat;
196 //color scale ui elements
197 VclPtr<ListBox> maLbEntryTypeMin;
198 VclPtr<ListBox> maLbEntryTypeMiddle;
199 VclPtr<ListBox> maLbEntryTypeMax;
201 VclPtr<Edit> maEdMin;
202 VclPtr<Edit> maEdMiddle;
203 VclPtr<Edit> maEdMax;
205 VclPtr<ColorListBox> maLbColMin;
206 VclPtr<ColorListBox> maLbColMiddle;
207 VclPtr<ColorListBox> maLbColMax;
209 ScFormatEntry* createColorscaleEntry() const;
211 virtual OUString GetExpressionString() override;
212 void Init();
214 DECL_LINK_TYPED( EntryTypeHdl, ListBox&, void );
215 public:
216 ScColorScale3FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr );
217 virtual ~ScColorScale3FrmtEntry();
218 virtual void dispose() override;
219 virtual ScFormatEntry* GetEntry() const override;
220 virtual void SetActive() override;
221 virtual void SetInactive() override;
222 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE3; }
225 class ScDataBarFrmtEntry : public ScCondFrmtEntry
227 //color format ui elements
228 VclPtr<ListBox> maLbColorFormat;
230 //data bar ui elements
231 VclPtr<ListBox> maLbDataBarMinType;
232 VclPtr<ListBox> maLbDataBarMaxType;
233 VclPtr<Edit> maEdDataBarMin;
234 VclPtr<Edit> maEdDataBarMax;
236 VclPtr<PushButton> maBtOptions;
238 std::unique_ptr<ScDataBarFormatData> mpDataBarData;
240 ScFormatEntry* createDatabarEntry() const;
242 virtual OUString GetExpressionString() override;
243 void Init();
245 DECL_LINK_TYPED( OptionBtnHdl, Button*, void );
246 DECL_LINK_TYPED( DataBarTypeSelectHdl, ListBox&, void );
247 public:
248 ScDataBarFrmtEntry( vcl::Window* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr );
249 virtual ~ScDataBarFrmtEntry();
250 virtual void dispose() override;
251 virtual ScFormatEntry* GetEntry() const override;
252 virtual void SetActive() override;
253 virtual void SetInactive() override;
255 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATABAR; }
258 class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener
260 public:
261 ScDateFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = nullptr );
262 virtual ~ScDateFrmtEntry();
263 virtual void dispose() override;
264 virtual ScFormatEntry* GetEntry() const override;
265 virtual void SetActive() override;
266 virtual void SetInactive() override;
267 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATE; }
269 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
270 using ScCondFrmtEntry::Notify;
271 protected:
272 virtual OUString GetExpressionString() override;
274 private:
275 void Init();
277 DECL_LINK_TYPED( StyleSelectHdl, ListBox&, void );
279 VclPtr<ListBox> maLbDateEntry;
280 VclPtr<FixedText> maFtStyle;
281 VclPtr<ListBox> maLbStyle;
282 VclPtr<SvxFontPrevWindow> maWdPreview;
284 bool mbIsInStyleCreate;
287 class ScIconSetFrmtEntry : public ScCondFrmtEntry
289 //color format ui elements
290 VclPtr<ListBox> maLbColorFormat;
292 // icon set ui elements
293 VclPtr<ListBox> maLbIconSetType;
295 typedef std::vector<VclPtr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType;
296 ScIconSetFrmtDataEntriesType maEntries;
298 virtual OUString GetExpressionString() override;
300 void Init();
302 DECL_LINK_TYPED( IconSetTypeHdl, ListBox&, void );
304 public:
305 ScIconSetFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr );
306 virtual ~ScIconSetFrmtEntry();
307 virtual void dispose() override;
308 virtual ScFormatEntry* GetEntry() const override;
309 virtual void SetActive() override;
310 virtual void SetInactive() override;
311 virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::ICONSET; }
314 #endif
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */