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  int get_grid_top_attach() const { return mxBorder->get_grid_top_attach(); }
81 
82  Size get_preferred_size() const { return mxBorder->get_preferred_size(); }
83 
84  void SetPos(const ScAddress& rPos) { maPos = rPos; };
85  bool IsSelected() const { return mbActive;}
86  void SetIndex(sal_Int32 nIndex);
87 
88  virtual ScFormatEntry* GetEntry() const = 0;
89  virtual void SetActive() = 0;
90  virtual void SetInactive() = 0;
91 
93 };
94 
96 {
97  //cond format ui elements
99  std::unique_ptr<weld::ComboBox> mxLbCondType;
100  std::unique_ptr<formula::RefEdit> mxEdVal1;
101  std::unique_ptr<formula::RefEdit> mxEdVal2;
102  std::unique_ptr<weld::Label> mxFtVal;
103  std::unique_ptr<weld::Label> mxFtStyle;
104  std::unique_ptr<weld::ComboBox> mxLbStyle;
105  std::unique_ptr<weld::Widget> mxWdPreviewWin;
106  std::unique_ptr<weld::CustomWeld> mxWdPreview;
108 
109  static const sal_Int32 NUM_COND_ENTRIES = 24;
110  // Lookup table from positions in maLbCondType to the condition mode enum
112 
114 
115  virtual OUString GetExpressionString() override;
116  void Init(ScCondFormatDlg* pDialogParent);
117  DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
118  DECL_LINK( ConditionTypeSelectHdl, weld::ComboBox&, void );
119  DECL_LINK( OnEdChanged, formula::RefEdit&, void );
120 
121  // Searches the lookup table for the entry position, given condition mode
122  static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode );
123  // Accesses the lookup table for the condition mode, given entry position
124  static ScConditionMode EntryPosToConditionMode( sal_Int32 aEntryPos );
125  // Returns the number of edit fields used for a given condition mode
126  static sal_Int32 GetNumberEditFields( ScConditionMode eMode );
127 
128 protected:
129  virtual void Select() override;
130  virtual void Deselect() override;
131 
132 public:
133  ScConditionFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
134  const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
135  virtual ~ScConditionFrmtEntry() override;
136 
137  virtual ScFormatEntry* GetEntry() const override;
138  virtual void SetActive() override;
139  virtual void SetInactive() override;
140 
141  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
142 
144 };
145 
147 {
149  std::unique_ptr<weld::Label> mxFtStyle;
150  std::unique_ptr<weld::ComboBox> mxLbStyle;
151  std::unique_ptr<weld::Widget> mxWdPreviewWin;
152  std::unique_ptr<weld::CustomWeld> mxWdPreview;
153  std::unique_ptr<formula::RefEdit> mxEdFormula;
154 
156  virtual OUString GetExpressionString() override;
157  void Init(ScCondFormatDlg* pDialogParent);
158 
159  DECL_LINK(StyleSelectHdl, weld::ComboBox&, void);
160 
161 public:
162  ScFormulaFrmtEntry(ScCondFormatList* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = nullptr);
163  virtual ~ScFormulaFrmtEntry() override;
164 
165  virtual ScFormatEntry* GetEntry() const override;
166  virtual void SetActive() override;
167  virtual void SetInactive() override;
169 };
170 
172 {
173 
174  //color format ui elements
175  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
176 
177  //color scale ui elements
178  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
179  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;
180 
181  std::unique_ptr<weld::Entry> mxEdMin;
182  std::unique_ptr<weld::Entry> mxEdMax;
183 
184  std::unique_ptr<ColorListBox> mxLbColMin;
185  std::unique_ptr<ColorListBox> mxLbColMax;
186 
187  std::unique_ptr<weld::Label> mxFtMin;
188  std::unique_ptr<weld::Label> mxFtMax;
189 
191 
192  virtual OUString GetExpressionString() override;
193  void Init();
194 
195  DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
196 public:
197  ScColorScale2FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
198  virtual ~ScColorScale2FrmtEntry() override;
199  virtual ScFormatEntry* GetEntry() const override;
200  virtual void SetActive() override;
201  virtual void SetInactive() override;
203 };
204 
206 {
207 
208  //color format ui elements
209  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
210 
211  //color scale ui elements
212  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMin;
213  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMiddle;
214  std::unique_ptr<weld::ComboBox> mxLbEntryTypeMax;
215 
216  std::unique_ptr<weld::Entry> mxEdMin;
217  std::unique_ptr<weld::Entry> mxEdMiddle;
218  std::unique_ptr<weld::Entry> mxEdMax;
219 
220  std::unique_ptr<ColorListBox> mxLbColMin;
221  std::unique_ptr<ColorListBox> mxLbColMiddle;
222  std::unique_ptr<ColorListBox> mxLbColMax;
223 
224  std::unique_ptr<weld::Label> mxFtMin;
225  std::unique_ptr<weld::Label> mxFtMax;
226 
228 
229  virtual OUString GetExpressionString() override;
230  void Init();
231 
232  DECL_LINK( EntryTypeHdl, weld::ComboBox&, void );
233 public:
234  ScColorScale3FrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = nullptr);
235  virtual ~ScColorScale3FrmtEntry() override;
236  virtual ScFormatEntry* GetEntry() const override;
237  virtual void SetActive() override;
238  virtual void SetInactive() override;
240 };
241 
243 {
244  //color format ui elements
245  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
246 
247  //data bar ui elements
248  std::unique_ptr<weld::ComboBox> mxLbDataBarMinType;
249  std::unique_ptr<weld::ComboBox> mxLbDataBarMaxType;
250  std::unique_ptr<weld::Entry> mxEdDataBarMin;
251  std::unique_ptr<weld::Entry> mxEdDataBarMax;
252  std::unique_ptr<weld::Button> mxBtOptions;
253 
254  std::unique_ptr<weld::Label> mxFtMin;
255  std::unique_ptr<weld::Label> mxFtMax;
256 
257  std::unique_ptr<ScDataBarFormatData> mpDataBarData;
258 
260 
261  virtual OUString GetExpressionString() override;
262  void Init();
263 
264  DECL_LINK( OptionBtnHdl, weld::Button&, void );
265  DECL_LINK( DataBarTypeSelectHdl, weld::ComboBox&, void );
266 public:
267  ScDataBarFrmtEntry(ScCondFormatList* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = nullptr);
268  virtual ~ScDataBarFrmtEntry() override;
269  virtual ScFormatEntry* GetEntry() const override;
270  virtual void SetActive() override;
271  virtual void SetInactive() override;
272 
274 };
275 
277 {
278 public:
279  ScDateFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = nullptr);
280  virtual ~ScDateFrmtEntry() override;
281  virtual ScFormatEntry* GetEntry() const override;
282  virtual void SetActive() override;
283  virtual void SetInactive() override;
285 
286  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
287 
288 protected:
289  virtual OUString GetExpressionString() override;
290 
291 private:
292  void Init();
293 
294  DECL_LINK( StyleSelectHdl, weld::ComboBox&, void );
295 
297  std::unique_ptr<weld::ComboBox> mxLbDateEntry;
298  std::unique_ptr<weld::Label> mxFtStyle;
299  std::unique_ptr<weld::ComboBox> mxLbStyle;
300  std::unique_ptr<weld::Widget> mxWdPreviewWin;
301  std::unique_ptr<weld::CustomWeld> mxWdPreview;
302 
304 };
305 
307 {
308  //color format ui elements
309  std::unique_ptr<weld::ComboBox> mxLbColorFormat;
310 
311  // icon set ui elements
312  std::unique_ptr<weld::ComboBox> mxLbIconSetType;
313 
314  std::unique_ptr<weld::Container> mxIconParent;
315 
316  typedef std::vector<std::unique_ptr<ScIconSetFrmtDataEntry>> ScIconSetFrmtDataEntriesType;
317  ScIconSetFrmtDataEntriesType maEntries;
318 
319  virtual OUString GetExpressionString() override;
320 
321  void Init();
322 
323  DECL_LINK(IconSetTypeHdl, weld::ComboBox&, void);
324 
325 public:
326  ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = nullptr);
327  virtual ~ScIconSetFrmtEntry() override;
328  virtual ScFormatEntry* GetEntry() const override;
329  virtual void SetActive() override;
330  virtual void SetInactive() override;
332 };
333 
334 #endif
335 
336 /* 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
Size get_preferred_size() const
std::unique_ptr< weld::Widget > mxWdPreviewWin
void Init(ScCondFormatDlg *pDialogParent)
SvxFontPrevWindow maWdPreview
virtual void SetActive() override
virtual void SetInactive() override
virtual OUString GetExpressionString() override
int get_grid_top_attach() const
virtual condformat::entry::ScCondFrmtEntryType GetType() override
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMin
std::unique_ptr< weld::ComboBox > mxLbColorFormat
std::unique_ptr< weld::Entry > mxEdMin