LibreOffice Module sc (master)  1
condformatdlgentry.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 
10 #ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX
11 #define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX
12 
13 #include <conditio.hxx>
14 #include <formula/funcutl.hxx>
15 #include <vcl/weld.hxx>
16 #include <svl/lstner.hxx>
17 #include <svx/fntctrl.hxx>
18 
20 class ScCondFormatDlg;
21 class ScCondFormatList;
22 class ColorListBox;
23 class ScColorScaleFormat;
24 class ScDataBarFormat;
25 class ScIconSetFormat;
26 struct ScDataBarFormatData;
27 
28 namespace condformat::entry {
29 
31 {
39 };
40 
41 }
42 
44 {
45 protected:
47  std::unique_ptr<weld::Builder> mxBuilder;
48 
49 private:
50  //general ui elements
51  std::unique_ptr<weld::Widget> mxBorder;
52  std::unique_ptr<weld::Container> mxGrid;
53  std::unique_ptr<weld::Label> mxFtCondNr;
54  std::unique_ptr<weld::Label> mxFtCondition;
55 
56  bool mbActive;
57  OUString const maStrCondition;
59 
60  DECL_LINK( EntrySelectHdl, const MouseEvent&, bool );
61 
62 protected:
63  std::unique_ptr<weld::ComboBox> mxLbType;
64 
67 
68  virtual void Select();
69  virtual void Deselect();
70 
71  virtual OUString GetExpressionString() = 0;
72 
73 public:
74  ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos);
75  virtual ~ScCondFrmtEntry();
76 
77  void Show() { mxGrid->show(); }
78 
79  void set_grid_top_attach(int nAttach) { mxBorder->set_grid_top_attach(nAttach); }
80 
81  void SetPos(const ScAddress& rPos) { maPos = rPos; };
82  bool IsSelected() const { return mbActive;}
83  void SetIndex(sal_Int32 nIndex);
84 
85  virtual ScFormatEntry* GetEntry() const = 0;
86  virtual void SetActive() = 0;
87  virtual void SetInactive() = 0;
88 
90 };
91 
93 {
94  //cond format ui elements
96  std::unique_ptr<weld::ComboBox> mxLbCondType;
97  std::unique_ptr<formula::RefEdit> mxEdVal1;
98  std::unique_ptr<formula::RefEdit> mxEdVal2;
99  std::unique_ptr<weld::Label> mxFtVal;
100  std::unique_ptr<weld::Label> mxFtStyle;
101  std::unique_ptr<weld::ComboBox> mxLbStyle;
102  std::unique_ptr<weld::Widget> mxWdPreviewWin;
103  std::unique_ptr<weld::CustomWeld> mxWdPreview;
105 
106  static const sal_Int32 NUM_COND_ENTRIES = 24;
107  // Lookup table from positions in maLbCondType to the condition mode enum
109 
111 
112  virtual OUString GetExpressionString() override;
113  void Init(ScCondFormatDlg* pDialogParent);
114  DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
115  DECL_LINK( ConditionTypeSelectHdl, weld::ComboBox&, void );
116  DECL_LINK( OnEdChanged, formula::RefEdit&, void );
117 
118  // Searches the lookup table for the entry position, given condition mode
119  static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode );
120  // Accesses the lookup table for the condition mode, given entry position
121  static ScConditionMode EntryPosToConditionMode( sal_Int32 aEntryPos );
122  // Returns the number of edit fields used for a given condition mode
123  static sal_Int32 GetNumberEditFields( ScConditionMode eMode );
124 
125 protected:
126  virtual void Select() override;
127  virtual void Deselect() override;
128 
129 public:
130  ScConditionFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
131  const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
132  virtual ~ScConditionFrmtEntry() override;
133 
134  virtual ScFormatEntry* GetEntry() const override;
135  virtual void SetActive() override;
136  virtual void SetInactive() override;
137 
138  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
139 
141 };
142 
144 {
146  std::unique_ptr<weld::Label> mxFtStyle;
147  std::unique_ptr<weld::ComboBox> mxLbStyle;
148  std::unique_ptr<weld::Widget> mxWdPreviewWin;
149  std::unique_ptr<weld::CustomWeld> mxWdPreview;
150  std::unique_ptr<formula::RefEdit> mxEdFormula;
151 
153  virtual OUString GetExpressionString() override;
154  void Init(ScCondFormatDlg* pDialogParent);
155 
156  DECL_LINK(StyleSelectHdl, weld::ComboBox&, void);
157 
158 public:
159  ScFormulaFrmtEntry(ScCondFormatList* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
160  virtual ~ScFormulaFrmtEntry() override;
161 
162  virtual ScFormatEntry* GetEntry() const override;
163  virtual void SetActive() override;
164  virtual void SetInactive() override;
166 };
167 
169 {
170 
171  //color format ui elements
172  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
173 
174  //color scale ui elements
175  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
176  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;
177 
178  std::unique_ptr<weld::Entry> mxEdMin;
179  std::unique_ptr<weld::Entry> mxEdMax;
180 
181  std::unique_ptr<ColorListBox> mxLbColMin;
182  std::unique_ptr<ColorListBox> mxLbColMax;
183 
184  std::unique_ptr<weld::Label> mxFtMin;
185  std::unique_ptr<weld::Label> mxFtMax;
186 
188 
189  virtual OUString GetExpressionString() override;
190  void Init();
191 
192  DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
193 public:
194  ScColorScale2FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
195  virtual ~ScColorScale2FrmtEntry() override;
196  virtual ScFormatEntry* GetEntry() const override;
197  virtual void SetActive() override;
198  virtual void SetInactive() override;
200 };
201 
203 {
204 
205  //color format ui elements
206  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
207 
208  //color scale ui elements
209  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
210  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMiddle;
211  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;
212 
213  std::unique_ptr<weld::Entry> mxEdMin;
214  std::unique_ptr<weld::Entry> mxEdMiddle;
215  std::unique_ptr<weld::Entry> mxEdMax;
216 
217  std::unique_ptr<ColorListBox> mxLbColMin;
218  std::unique_ptr<ColorListBox> mxLbColMiddle;
219  std::unique_ptr<ColorListBox> mxLbColMax;
220 
221  std::unique_ptr<weld::Label> mxFtMin;
222  std::unique_ptr<weld::Label> mxFtMax;
223 
225 
226  virtual OUString GetExpressionString() override;
227  void Init();
228 
229  DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
230 public:
231  ScColorScale3FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
232  virtual ~ScColorScale3FrmtEntry() override;
233  virtual ScFormatEntry* GetEntry() const override;
234  virtual void SetActive() override;
235  virtual void SetInactive() override;
237 };
238 
240 {
241  //color format ui elements
242  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
243 
244  //data bar ui elements
245  std::unique_ptr<weld::ComboBox> mxLbDataBarMinType;
246  std::unique_ptr<weld::ComboBox> mxLbDataBarMaxType;
247  std::unique_ptr<weld::Entry> mxEdDataBarMin;
248  std::unique_ptr<weld::Entry> mxEdDataBarMax;
249  std::unique_ptr<weld::Button> mxBtOptions;
250 
251  std::unique_ptr<weld::Label> mxFtMin;
252  std::unique_ptr<weld::Label> mxFtMax;
253 
254  std::unique_ptr<ScDataBarFormatData> mpDataBarData;
255 
257 
258  virtual OUString GetExpressionString() override;
259  void Init();
260 
261  DECL_LINK( OptionBtnHdl, weld::Button&, void );
262  DECL_LINK( DataBarTypeSelectHdl, weld::ComboBox&, void );
263 public:
264  ScDataBarFrmtEntry(ScCondFormatList* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr);
265  virtual ~ScDataBarFrmtEntry() override;
266  virtual ScFormatEntry* GetEntry() const override;
267  virtual void SetActive() override;
268  virtual void SetInactive() override;
269 
271 };
272 
274 {
275 public:
276  ScDateFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = nullptr);
277  virtual ~ScDateFrmtEntry() override;
278  virtual ScFormatEntry* GetEntry() const override;
279  virtual void SetActive() override;
280  virtual void SetInactive() override;
282 
283  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
284 
285 protected:
286  virtual OUString GetExpressionString() override;
287 
288 private:
289  void Init();
290 
291  DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
292 
294  std::unique_ptr<weld::ComboBox> mxLbDateEntry;
295  std::unique_ptr<weld::Label> mxFtStyle;
296  std::unique_ptr<weld::ComboBox> mxLbStyle;
297  std::unique_ptr<weld::Widget> mxWdPreviewWin;
298  std::unique_ptr<weld::CustomWeld> mxWdPreview;
299 
301 };
302 
304 {
305  //color format ui elements
306  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
307 
308  // icon set ui elements
309  std::unique_ptr<weld::ComboBox> mxLbIconSetType;
310 
311  std::unique_ptr<weld::Container> mxIconParent;
312 
313  typedef std::vector<std::unique_ptr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType;
314  ScIconSetFrmtDataEntriesType maEntries;
315 
316  virtual OUString GetExpressionString() override;
317 
318  void Init();
319 
320  DECL_LINK(IconSetTypeHdl, weld::ComboBox&, void);
321 
322 public:
323  ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr);
324  virtual ~ScIconSetFrmtEntry() override;
325  virtual ScFormatEntry* GetEntry() const override;
326  virtual void SetActive() override;
327  virtual void SetInactive() override;
329 };
330 
331 #endif
332 
333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SetActive() override
virtual void SetActive() override
void Init(ScCondFormatDlg *pDialogParent)
std::unique_ptr< ScDataBarFormatData > mpDataBarData
virtual void Select() override
std::unique_ptr< weld::Builder > mxBuilder
DECL_LINK(StyleSelectHdl, weld::ComboBox &, void)
std::unique_ptr< weld::ComboBox > mxLbType
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMax
static sal_Int32 GetNumberEditFields(ScConditionMode eMode)
ScFormatEntry * createConditionEntry() const
std::unique_ptr< formula::RefEdit > mxEdVal2
std::unique_ptr< weld::Entry > mxEdDataBarMin
static const sal_Int32 NUM_COND_ENTRIES
ScFormatEntry * createFormulaEntry() const
virtual void SetActive()=0
virtual ~ScColorScale3FrmtEntry() override
virtual ~ScColorScale2FrmtEntry() override
void SetIndex(sal_Int32 nIndex)
void set_grid_top_attach(int nAttach)
std::unique_ptr< ColorListBox > mxLbColMax
ScColorScale3FrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos, const ScColorScaleFormat *pFormat=nullptr)
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMiddle
std::unique_ptr< weld::CustomWeld > mxWdPreview
virtual ScFormatEntry * GetEntry() const =0
std::unique_ptr< weld::ComboBox > mxLbDataBarMaxType
virtual void SetActive() override
virtual ScFormatEntry * GetEntry() const override
virtual OUString GetExpressionString() override
std::unique_ptr< ColorListBox > mxLbColMax
virtual OUString GetExpressionString()=0
ScColorScale2FrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos, const ScColorScaleFormat *pFormat=nullptr)
std::unique_ptr< weld::Entry > mxEdMiddle
virtual condformat::entry::ScCondFrmtEntryType GetType() override
virtual void SetActive() override
std::unique_ptr< ColorListBox > mxLbColMin
std::unique_ptr< weld::Entry > mxEdMax
std::unique_ptr< weld::ComboBox > mxLbCondType
virtual OUString GetExpressionString() override
virtual ~ScIconSetFrmtEntry() override
virtual ScFormatEntry * GetEntry() const override
ScDataBarFrmtEntry(ScCondFormatList *pParemt, ScDocument *pDoc, const ScAddress &rPos, const ScDataBarFormat *pFormat=nullptr)
virtual void SetActive() override
DECL_LINK(EntryTypeHdl, weld::ComboBox &, void)
virtual ScFormatEntry * GetEntry() const override
Link< ScCondFrmtEntry &, void > maClickHdl
std::unique_ptr< weld::ComboBox > mxLbColorFormat
ScFormatEntry * createDatabarEntry() const
std::unique_ptr< weld::Widget > mxBorder
SvxFontPrevWindow maWdPreview
ScConditionMode
Definition: conditio.hxx:61
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
std::unique_ptr< weld::Widget > mxWdPreviewWin
virtual OUString GetExpressionString() override
virtual void Deselect() override
DECL_LINK(StyleSelectHdl, weld::ComboBox &, void)
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::ComboBox > mxLbColorFormat
std::unique_ptr< weld::Label > mxFtCondition
virtual void Deselect()
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
std::unique_ptr< weld::CustomWeld > mxWdPreview
std::unique_ptr< weld::Entry > mxEdMin
std::unique_ptr< weld::Widget > mxWdPreviewWin
std::unique_ptr< weld::CustomWeld > mxWdPreview
std::unique_ptr< weld::Label > mxFtMin
virtual OUString GetExpressionString() override
bool IsSelected() const
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::Label > mxFtMax
ScConditionFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, ScCondFormatDlg *pDialogParent, const ScAddress &rPos, const ScCondFormatEntry *pFormatEntry=nullptr)
ScFormatEntry * createColorscaleEntry() const
std::unique_ptr< weld::ComboBox > mxLbDateEntry
ScCondFormatList * mpParent
virtual OUString GetExpressionString() override
std::unique_ptr< weld::Label > mxFtStyle
DECL_LINK(IconSetTypeHdl, weld::ComboBox &, void)
std::unique_ptr< weld::Label > mxFtStyle
std::unique_ptr< weld::Label > mxFtMin
virtual void SetInactive() override
ScCondFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos)
std::unique_ptr< weld::ComboBox > mxLbStyle
virtual void SetInactive() override
ScDateFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScCondDateFormatEntry *pFormat=nullptr)
std::unique_ptr< weld::ComboBox > mxLbIconSetType
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::Entry > mxEdDataBarMax
static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES]
std::unique_ptr< weld::Label > mxFtMax
std::unique_ptr< weld::ComboBox > mxLbStyle
DECL_LINK(EntryTypeHdl, weld::ComboBox &, void)
std::unique_ptr< ColorListBox > mxLbColMin
virtual void SetInactive() override
SvxFontPrevWindow maWdPreview
virtual void SetInactive() override
std::unique_ptr< weld::ComboBox > mxLbColorFormat
virtual ~ScDateFrmtEntry() override
ScFormatEntry * createColorscaleEntry() const
std::unique_ptr< weld::Label > mxFtCondNr
virtual condformat::entry::ScCondFrmtEntryType GetType() override
virtual void Select()
virtual void SetInactive()=0
DECL_LINK(OptionBtnHdl, weld::Button &, void)
std::unique_ptr< formula::RefEdit > mxEdVal1
DECL_LINK(StyleSelectHdl, weld::ComboBox &, void)
std::unique_ptr< weld::ComboBox > mxLbDataBarMinType
OUString const maStrCondition
virtual void SetInactive() override
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMin
virtual OUString GetExpressionString() override
static sal_Int32 ConditionModeToEntryPos(ScConditionMode eMode)
virtual condformat::entry::ScCondFrmtEntryType GetType() override
virtual ~ScFormulaFrmtEntry() override
std::unique_ptr< weld::Label > mxFtMax
std::unique_ptr< weld::Label > mxFtVal
std::unique_ptr< weld::Container > mxGrid
std::vector< std::unique_ptr< ScIconSetFrmtDataEntry > > ScIconSetFrmtDataEntriesType
static ScConditionMode EntryPosToConditionMode(sal_Int32 aEntryPos)
std::unique_ptr< weld::ComboBox > mxLbStyle
virtual ~ScConditionFrmtEntry() override
virtual void SetInactive() override
ScIconSetFrmtDataEntriesType maEntries
void SetPos(const ScAddress &rPos)
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMax
DECL_LINK(EntrySelectHdl, const MouseEvent &, bool)
virtual condformat::entry::ScCondFrmtEntryType GetType() override
virtual ~ScDataBarFrmtEntry() override
std::unique_ptr< formula::RefEdit > mxEdFormula
ScFormulaFrmtEntry(ScCondFormatList *pParent, ScDocument *PDoc, ScCondFormatDlg *pDialogParent, const ScAddress &rPos, const ScCondFormatEntry *pFormatEntry=nullptr)
virtual condformat::entry::ScCondFrmtEntryType GetType() override
std::unique_ptr< ColorListBox > mxLbColMiddle
virtual ScFormatEntry * GetEntry() const override
ScIconSetFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos, const ScIconSetFormat *pFormat=nullptr)
virtual condformat::entry::ScCondFrmtEntryType GetType() override
std::unique_ptr< weld::Button > mxBtOptions
virtual condformat::entry::ScCondFrmtEntryType GetType()=0
std::unique_ptr< weld::Label > mxFtStyle
std::unique_ptr< weld::Container > mxIconParent
virtual void SetActive() override
std::unique_ptr< weld::Entry > mxEdMax
std::unique_ptr< weld::Label > mxFtMin
std::unique_ptr< weld::Widget > mxWdPreviewWin
void Init(ScCondFormatDlg *pDialogParent)
SvxFontPrevWindow maWdPreview
virtual void SetActive() override
virtual void SetInactive() override
virtual OUString GetExpressionString() override
virtual condformat::entry::ScCondFrmtEntryType GetType() override
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMin
std::unique_ptr< weld::ComboBox > mxLbColorFormat
std::unique_ptr< weld::Entry > mxEdMin