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 "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
{
26 enum ScCondFrmtEntryType
41 class ScCondFrmtEntry
: public Control
49 VclPtr
<FixedText
> maFtCondNr
;
50 VclPtr
<FixedText
> maFtCondition
;
53 OUString maStrCondition
;
55 VclPtr
<ListBox
> maLbType
;
60 DECL_LINK( EdModifyHdl
, Edit
* );
62 virtual void Select();
63 virtual void Deselect();
65 virtual OUString
GetExpressionString() = 0;
68 ScCondFrmtEntry( vcl::Window
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
);
69 virtual ~ScCondFrmtEntry();
70 virtual void dispose() SAL_OVERRIDE
;
72 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
74 bool IsSelected() const { return mbActive
;}
75 void SetIndex(sal_Int32 nIndex
);
76 sal_Int32
GetIndex() const { return mnIndex
; }
79 virtual ScFormatEntry
* GetEntry() const = 0;
80 virtual void SetActive() = 0;
81 virtual void SetInactive() = 0;
83 virtual condformat::entry::ScCondFrmtEntryType
GetType() = 0;
86 class ScConditionFrmtEntry
: public ScCondFrmtEntry
, public SfxListener
88 //cond format ui elements
89 VclPtr
<ListBox
> maLbCondType
;
90 VclPtr
<formula::RefEdit
> maEdVal1
;
91 VclPtr
<formula::RefEdit
> maEdVal2
;
92 VclPtr
<FixedText
> maFtVal
;
93 VclPtr
<FixedText
> maFtStyle
;
94 VclPtr
<ListBox
> maLbStyle
;
95 VclPtr
<SvxFontPrevWindow
> maWdPreview
;
96 bool mbIsInStyleCreate
;
98 static const sal_Int32 NUM_COND_ENTRIES
= 24;
99 // Lookup table from positions in maLbCondType to the condition mode enum
100 static const ScConditionMode mpEntryToCond
[NUM_COND_ENTRIES
];
102 ScFormatEntry
* createConditionEntry() const;
104 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
105 void Init(ScCondFormatDlg
* pDialogParent
);
106 DECL_LINK( StyleSelectHdl
, void* );
107 DECL_LINK( ConditionTypeSelectHdl
, void* );
108 DECL_LINK( OnEdChanged
, Edit
* );
110 // Searches the lookup table for the entry position, given condition mode
111 static sal_Int32
ConditionModeToEntryPos( ScConditionMode eMode
);
112 // Accesses the lookup table for the condition mode, given entry position
113 static ScConditionMode
EntryPosToConditionMode( sal_Int32 aEntryPos
);
114 // Returns the number of edit fields used for a given condition mode
115 static sal_Int32
GetNumberEditFields( ScConditionMode eMode
);
118 virtual void Select() SAL_OVERRIDE
;
119 virtual void Deselect() SAL_OVERRIDE
;
122 ScConditionFrmtEntry( vcl::Window
* pParent
, ScDocument
* pDoc
, ScCondFormatDlg
* pDialogParent
,
123 const ScAddress
& rPos
, const ScCondFormatEntry
* pFormatEntry
= NULL
);
124 virtual ~ScConditionFrmtEntry();
125 virtual void dispose() SAL_OVERRIDE
;
127 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
128 virtual void SetActive() SAL_OVERRIDE
;
129 virtual void SetInactive() SAL_OVERRIDE
;
131 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
132 using ScCondFrmtEntry::Notify
;
134 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::CONDITION
; }
137 class ScFormulaFrmtEntry
: public ScCondFrmtEntry
139 VclPtr
<FixedText
> maFtStyle
;
140 VclPtr
<ListBox
> maLbStyle
;
141 VclPtr
<SvxFontPrevWindow
> maWdPreview
;
142 VclPtr
<formula::RefEdit
> maEdFormula
;
144 ScFormatEntry
* createFormulaEntry() const;
145 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
146 void Init(ScCondFormatDlg
* pDialogParent
);
148 DECL_LINK( StyleSelectHdl
, void* );
151 ScFormulaFrmtEntry( vcl::Window
* pParent
, ScDocument
* PDoc
, ScCondFormatDlg
* pDialogParent
, const ScAddress
& rPos
, const ScCondFormatEntry
* pFormatEntry
= NULL
);
152 virtual ~ScFormulaFrmtEntry();
153 virtual void dispose() SAL_OVERRIDE
;
155 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
156 virtual void SetActive() SAL_OVERRIDE
;
157 virtual void SetInactive() SAL_OVERRIDE
;
158 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::FORMULA
; }
161 class ScColorScale2FrmtEntry
: public ScCondFrmtEntry
164 //color format ui elements
165 VclPtr
<ListBox
> maLbColorFormat
;
167 //color scale ui elements
168 VclPtr
<ListBox
> maLbEntryTypeMin
;
169 VclPtr
<ListBox
> maLbEntryTypeMax
;
171 VclPtr
<Edit
> maEdMin
;
172 VclPtr
<Edit
> maEdMax
;
174 VclPtr
<ColorListBox
> maLbColMin
;
175 VclPtr
<ColorListBox
> maLbColMax
;
177 ScFormatEntry
* createColorscaleEntry() const;
179 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
182 DECL_LINK( EntryTypeHdl
, ListBox
* );
184 ScColorScale2FrmtEntry( vcl::Window
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScColorScaleFormat
* pFormat
= NULL
);
185 virtual ~ScColorScale2FrmtEntry();
186 virtual void dispose() SAL_OVERRIDE
;
187 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
188 virtual void SetActive() SAL_OVERRIDE
;
189 virtual void SetInactive() SAL_OVERRIDE
;
190 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::COLORSCALE2
; }
193 class ScColorScale3FrmtEntry
: public ScCondFrmtEntry
196 //color format ui elements
197 VclPtr
<ListBox
> maLbColorFormat
;
199 //color scale ui elements
200 VclPtr
<ListBox
> maLbEntryTypeMin
;
201 VclPtr
<ListBox
> maLbEntryTypeMiddle
;
202 VclPtr
<ListBox
> maLbEntryTypeMax
;
204 VclPtr
<Edit
> maEdMin
;
205 VclPtr
<Edit
> maEdMiddle
;
206 VclPtr
<Edit
> maEdMax
;
208 VclPtr
<ColorListBox
> maLbColMin
;
209 VclPtr
<ColorListBox
> maLbColMiddle
;
210 VclPtr
<ColorListBox
> maLbColMax
;
212 ScFormatEntry
* createColorscaleEntry() const;
214 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
217 DECL_LINK( EntryTypeHdl
, ListBox
* );
219 ScColorScale3FrmtEntry( vcl::Window
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScColorScaleFormat
* pFormat
= NULL
);
220 virtual ~ScColorScale3FrmtEntry();
221 virtual void dispose() SAL_OVERRIDE
;
222 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
223 virtual void SetActive() SAL_OVERRIDE
;
224 virtual void SetInactive() SAL_OVERRIDE
;
225 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::COLORSCALE3
; }
228 class ScDataBarFrmtEntry
: public ScCondFrmtEntry
230 //color format ui elements
231 VclPtr
<ListBox
> maLbColorFormat
;
233 //data bar ui elements
234 VclPtr
<ListBox
> maLbDataBarMinType
;
235 VclPtr
<ListBox
> maLbDataBarMaxType
;
236 VclPtr
<Edit
> maEdDataBarMin
;
237 VclPtr
<Edit
> maEdDataBarMax
;
239 VclPtr
<PushButton
> maBtOptions
;
241 boost::scoped_ptr
<ScDataBarFormatData
> mpDataBarData
;
243 ScFormatEntry
* createDatabarEntry() const;
245 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
248 DECL_LINK( OptionBtnHdl
, void* );
249 DECL_LINK( DataBarTypeSelectHdl
, void* );
251 ScDataBarFrmtEntry( vcl::Window
* pParemt
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScDataBarFormat
* pFormat
= NULL
);
252 virtual ~ScDataBarFrmtEntry();
253 virtual void dispose() SAL_OVERRIDE
;
254 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
255 virtual void SetActive() SAL_OVERRIDE
;
256 virtual void SetInactive() SAL_OVERRIDE
;
258 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::DATABAR
; }
261 class ScDateFrmtEntry
: public ScCondFrmtEntry
, public SfxListener
264 ScDateFrmtEntry( vcl::Window
* pParent
, ScDocument
* pDoc
, const ScCondDateFormatEntry
* pFormat
= NULL
);
265 virtual ~ScDateFrmtEntry();
266 virtual void dispose() SAL_OVERRIDE
;
267 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
268 virtual void SetActive() SAL_OVERRIDE
;
269 virtual void SetInactive() SAL_OVERRIDE
;
270 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::DATE
; }
272 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
273 using ScCondFrmtEntry::Notify
;
275 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
280 DECL_LINK( StyleSelectHdl
, void* );
282 VclPtr
<ListBox
> maLbDateEntry
;
283 VclPtr
<FixedText
> maFtStyle
;
284 VclPtr
<ListBox
> maLbStyle
;
285 VclPtr
<SvxFontPrevWindow
> maWdPreview
;
287 bool mbIsInStyleCreate
;
290 class ScIconSetFrmtEntry
: public ScCondFrmtEntry
292 //color format ui elements
293 VclPtr
<ListBox
> maLbColorFormat
;
295 // icon set ui elements
296 VclPtr
<ListBox
> maLbIconSetType
;
298 typedef std::vector
<VclPtr
<ScIconSetFrmtDataEntry
>> ScIconSetFrmtDataEntriesType
;
299 ScIconSetFrmtDataEntriesType maEntries
;
301 virtual OUString
GetExpressionString() SAL_OVERRIDE
;
305 DECL_LINK( IconSetTypeHdl
, void* );
308 ScIconSetFrmtEntry( vcl::Window
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
, const ScIconSetFormat
* pFormat
= NULL
);
309 virtual ~ScIconSetFrmtEntry();
310 virtual void dispose() SAL_OVERRIDE
;
311 virtual ScFormatEntry
* GetEntry() const SAL_OVERRIDE
;
312 virtual void SetActive() SAL_OVERRIDE
;
313 virtual void SetInactive() SAL_OVERRIDE
;
314 virtual condformat::entry::ScCondFrmtEntryType
GetType() SAL_OVERRIDE
{ return condformat::entry::ICONSET
; }
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */