xref: /aoo41x/main/svtools/inc/svtools/fmtfield.hxx (revision 01aa44aa)
1*01aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*01aa44aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*01aa44aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*01aa44aaSAndrew Rist  * distributed with this work for additional information
6*01aa44aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*01aa44aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*01aa44aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*01aa44aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*01aa44aaSAndrew Rist  *
11*01aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*01aa44aaSAndrew Rist  *
13*01aa44aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*01aa44aaSAndrew Rist  * software distributed under the License is distributed on an
15*01aa44aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*01aa44aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*01aa44aaSAndrew Rist  * specific language governing permissions and limitations
18*01aa44aaSAndrew Rist  * under the License.
19*01aa44aaSAndrew Rist  *
20*01aa44aaSAndrew Rist  *************************************************************/
21*01aa44aaSAndrew Rist 
22*01aa44aaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _FMTFIELD_HXX_
25cdf0e10cSrcweir #define _FMTFIELD_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "svtools/svtdllapi.h"
28cdf0e10cSrcweir #include <vcl/spinfld.hxx>
29cdf0e10cSrcweir #include <svl/zforlist.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //#define REGEXP_SUPPORT
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #ifdef REGEXP_SUPPORT
34cdf0e10cSrcweir 	#ifndef _UNOTOOLS_TEXTSEARCH_HXX
35cdf0e10cSrcweir 	#include <unotools/textsearch.hxx>
36cdf0e10cSrcweir 	#endif
37cdf0e10cSrcweir #else
38cdf0e10cSrcweir 	// use a hand-made regular expression parsing for the small expression we're interested in
39cdf0e10cSrcweir 	// as soon as OOo does have regular expression support, we can switch on the REGEXP_SUPPORT define
40cdf0e10cSrcweir 	namespace validation { class NumberValidator; }
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir typedef sal_uInt16 FORMAT_CHANGE_TYPE;
44cdf0e10cSrcweir #define FCT_KEYONLY			0x00		// only a new key was set
45cdf0e10cSrcweir #define FCT_FORMATTER		0x01		// a new formatter weas set, usually implies a change of the key, too
46cdf0e10cSrcweir #define FCT_PRECISION		0x02		// a new precision was set
47cdf0e10cSrcweir #define FCT_THOUSANDSSEP	0x03		// the thousands separator setting changed
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //------------------------------------------------------------------------------
50cdf0e10cSrcweir class SVT_DLLPUBLIC FormattedField : public SpinField
51cdf0e10cSrcweir {
52cdf0e10cSrcweir private:
53cdf0e10cSrcweir 	// Da ein SvNumberFormatter eine ziemlich teure (sowohl zeit- als auch platz-maessig) Angelegenheit ist,
54cdf0e10cSrcweir 	// haelt sich nicht jedes Field, an dem kein Formatter gesetzt wurde, eine eigenen Instanz, sondern es gibt nur eine
55cdf0e10cSrcweir 	// einzige statische.
56cdf0e10cSrcweir 	class StaticFormatter
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		static SvNumberFormatter*	s_cFormatter;
59cdf0e10cSrcweir 		static sal_uLong				s_nReferences;
60cdf0e10cSrcweir 	public:
61cdf0e10cSrcweir 		StaticFormatter();
62cdf0e10cSrcweir 		~StaticFormatter();
63cdf0e10cSrcweir 
operator SvNumberFormatter*()64cdf0e10cSrcweir 		operator SvNumberFormatter* () { return GetFormatter(); }
65cdf0e10cSrcweir 		SVT_DLLPUBLIC SvNumberFormatter* GetFormatter();
66cdf0e10cSrcweir 	};
67cdf0e10cSrcweir 
68cdf0e10cSrcweir protected:
69cdf0e10cSrcweir 	String		m_sLastValidText;
70cdf0e10cSrcweir 		// hat nichts mit dem current value zu tun, ist der letzte Text, der waehrend einer Eingabe als gueltig erkannt
71cdf0e10cSrcweir 		// wurde (also durch CheckText geprueft, nicht durch den Formatter gejagt)
72cdf0e10cSrcweir 	Selection	m_aLastSelection;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	double				m_dMinValue;
75cdf0e10cSrcweir 	double				m_dMaxValue;
76cdf0e10cSrcweir 	sal_Bool				m_bHasMin : 1;
77cdf0e10cSrcweir 	sal_Bool				m_bHasMax : 1;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	sal_Bool				m_bStrictFormat : 1;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	sal_Bool				m_bValueDirty : 1;
82cdf0e10cSrcweir 	sal_Bool				m_bEnableEmptyField : 1;
83cdf0e10cSrcweir 	sal_Bool				m_bAutoColor : 1;
84cdf0e10cSrcweir     sal_Bool				m_bEnableNaN : 1;
85cdf0e10cSrcweir 	double				m_dCurrentValue;
86cdf0e10cSrcweir 	double				m_dDefaultValue;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	sal_uLong				m_nFormatKey;
89cdf0e10cSrcweir 	SvNumberFormatter*	m_pFormatter;
90cdf0e10cSrcweir 	StaticFormatter		m_aStaticFormatter;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	double				m_dSpinSize;
93cdf0e10cSrcweir 	double				m_dSpinFirst;
94cdf0e10cSrcweir 	double				m_dSpinLast;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	// es macht einen Unterschied, ob man bei eingestellter Textformatierung beim LostFocus den aktuellen String durch
97cdf0e10cSrcweir 	// den Formatter jagt und das Ergebnis anzeigt oder erst aus dem String ein double macht, das formatiert und dann
98cdf0e10cSrcweir 	// ausgibt
99cdf0e10cSrcweir 	sal_Bool				m_bTreatAsNumber;
100cdf0e10cSrcweir 	// und mit den folgenden Members koennen wir das Ganze hier auch zur formatierten Text-Ausgabe benutzen ...
101cdf0e10cSrcweir 	String				m_sCurrentTextValue;
102cdf0e10cSrcweir 	String				m_sDefaultText;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	// die bei der letzten Ausgabe-Operation vom Formatter gelieferte Farbe (nicht dass wir sie beachten wuerden, aber
105cdf0e10cSrcweir 	// man kann sie von aussen abfragen)
106cdf0e10cSrcweir 	Color*				m_pLastOutputColor;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     bool                m_bUseInputStringForFormatting;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir public:
111cdf0e10cSrcweir 	FormattedField(Window* pParent, WinBits nStyle = 0, SvNumberFormatter* pInitialFormatter = NULL, sal_Int32 nFormatKey = 0);
112cdf0e10cSrcweir 	FormattedField(Window* pParent, const ResId& rResId, SvNumberFormatter* pInitialFormatter = NULL, sal_Int32 nFormatKey = 0);
113cdf0e10cSrcweir 	virtual ~FormattedField();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	// Min-/Max-Verwaltung
HasMinValue() const116cdf0e10cSrcweir 	sal_Bool	HasMinValue() const			{ return m_bHasMin; }
ClearMinValue()117cdf0e10cSrcweir 	void	ClearMinValue()				{ m_bHasMin = sal_False; }
118cdf0e10cSrcweir 	void	SetMinValue(double dMin);
GetMinValue() const119cdf0e10cSrcweir 	double	GetMinValue() const			{ return m_dMinValue; }
120cdf0e10cSrcweir 
HasMaxValue() const121cdf0e10cSrcweir 	sal_Bool	HasMaxValue() const			{ return m_bHasMax; }
ClearMaxValue()122cdf0e10cSrcweir 	void	ClearMaxValue()				{ m_bHasMax = sal_False; }
123cdf0e10cSrcweir 	void	SetMaxValue(double dMax);
GetMaxValue() const124cdf0e10cSrcweir 	double	GetMaxValue() const			{ return m_dMaxValue; }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	// aktueller Wert
127cdf0e10cSrcweir 	virtual void	SetValue(double dVal);
128cdf0e10cSrcweir 	virtual double	GetValue();
129cdf0e10cSrcweir 		// die Standard-Implementierung jagt die Eingabe jeweils durch den Formatter, so einer vorhanden ist
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	void	GetColor() const;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	void	SetTextValue(const XubString& rText);
134cdf0e10cSrcweir 		// der String wird in ein double umgewandelt (durch den Formatter) und anschliessen in SetValue gesteckt
135cdf0e10cSrcweir 
IsEmptyFieldEnabled() const136cdf0e10cSrcweir 	sal_Bool	IsEmptyFieldEnabled() const			{ return m_bEnableEmptyField; }
137cdf0e10cSrcweir 	void	EnableEmptyField(sal_Bool bEnable);
138cdf0e10cSrcweir 		// wenn nicht enabled, wird beim Verlassen des Feldes der Text auf den letzten gueltigen zurueckgesetzt
139cdf0e10cSrcweir 
SetDefaultValue(double dDefault)140cdf0e10cSrcweir 	void	SetDefaultValue(double dDefault)	{ m_dDefaultValue = dDefault; m_bValueDirty = sal_True; }
141cdf0e10cSrcweir 		// wenn der aktuelle String ungueltig ist, liefert GetValue() diesen Default-Wert
GetDefaultValue() const142cdf0e10cSrcweir 	double	GetDefaultValue() const				{ return m_dDefaultValue; }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	// Einstellungen fuer das Format
GetFormatKey() const145cdf0e10cSrcweir 	sal_uLong	GetFormatKey() const				{ return m_nFormatKey; }
146cdf0e10cSrcweir 	void	SetFormatKey(sal_uLong nFormatKey);
147cdf0e10cSrcweir 
GetFormatter() const148cdf0e10cSrcweir 	SvNumberFormatter*	GetFormatter() const	{ return m_pFormatter; }
149cdf0e10cSrcweir 	void	SetFormatter(SvNumberFormatter* pFormatter, sal_Bool bResetFormat = sal_True);
150cdf0e10cSrcweir 		// wenn bResetFormat sal_False ist, wird versucht, das alte eingestellte Format mit 'hinueberzuretten' (teuer, wenn es sich nicht
151cdf0e10cSrcweir 		// um eines der Standard-Formate handelt, die in allen Formattern gleich sind)
152cdf0e10cSrcweir 		// wenn sal_True, wird als neuer FormatKey 0 gesetzt
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	sal_Bool	GetThousandsSep() const;
155cdf0e10cSrcweir 	void	SetThousandsSep(sal_Bool _bUseSeparator);
156cdf0e10cSrcweir 		// the is no check if the current format is numeric, so be cautious when calling these functions
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	sal_uInt16	GetDecimalDigits() const;
159cdf0e10cSrcweir 	void	SetDecimalDigits(sal_uInt16 _nPrecision);
160cdf0e10cSrcweir 		// the is no check if the current format is numeric, so be cautious when calling these functions
161cdf0e10cSrcweir 
StandardFormatter()162cdf0e10cSrcweir 	SvNumberFormatter*	StandardFormatter() { return m_aStaticFormatter; }
163cdf0e10cSrcweir 		// Wenn man keinen eigenen Formatter explizit anlegen will, kann man diesen hier in SetFormatter stecken ...
164cdf0e10cSrcweir 		// Das hier gelieferte Objekt wird allerdings zwischen allen Instanzen der Klasse geteilt (aus Zeit- und Platzgruenden),
165cdf0e10cSrcweir 		// also ist etwas Vorsicht angebracht ...
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	void		GetFormat(XubString& rFormatString, LanguageType& eLang) const;
168cdf0e10cSrcweir 	sal_Bool		SetFormat(const XubString& rFormatString, LanguageType eLang);
169cdf0e10cSrcweir 		// sal_False, wenn der FormatString nicht gesetzt werden konnte (also wahrscheinlich ungueltig ist)
170cdf0e10cSrcweir 
IsStrictFormat() const171cdf0e10cSrcweir 	sal_Bool	IsStrictFormat() const				{ return m_bStrictFormat; }
SetStrictFormat(sal_Bool bEnable)172cdf0e10cSrcweir 	void	SetStrictFormat(sal_Bool bEnable)		{ m_bStrictFormat = bEnable; }
173cdf0e10cSrcweir 		// Formatueberpruefung waehrend der Eingabe ?
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	// Spin-Handling
176cdf0e10cSrcweir 	virtual void Up();
177cdf0e10cSrcweir 	virtual void Down();
178cdf0e10cSrcweir 		// Standard-Implementierung : hoch- oder runterzaehlen des aktuellen double einfach um die gesetzte SpinSize
179cdf0e10cSrcweir 	virtual void First();
180cdf0e10cSrcweir 	virtual void Last();
181cdf0e10cSrcweir 		// Standard-Implementierung : aktuelles double setzen auf eingestellten first respektive last value
182cdf0e10cSrcweir 
SetSpinSize(double dStep)183cdf0e10cSrcweir 	void	SetSpinSize(double dStep)	{ m_dSpinSize = dStep; }
GetSpinSize() const184cdf0e10cSrcweir 	double	GetSpinSize() const			{ return m_dSpinSize; }
185cdf0e10cSrcweir 
SetSpinFirst(double dFirst)186cdf0e10cSrcweir 	void	SetSpinFirst(double dFirst)	{ m_dSpinFirst = dFirst; }
GetSpinFirst() const187cdf0e10cSrcweir 	double	GetSpinFirst() const		{ return m_dSpinFirst; }
188cdf0e10cSrcweir 
SetSpinLast(double dLast)189cdf0e10cSrcweir 	void	SetSpinLast(double dLast)	{ m_dSpinLast = dLast; }
GetSpinLast() const190cdf0e10cSrcweir 	double	GetSpinLast() const			{ return m_dSpinLast; }
191cdf0e10cSrcweir 
TreatingAsNumber() const192cdf0e10cSrcweir 	sal_Bool	TreatingAsNumber() const	{ return m_bTreatAsNumber; }
TreatAsNumber(sal_Bool bDoSo)193cdf0e10cSrcweir 	void	TreatAsNumber(sal_Bool bDoSo) { m_bTreatAsNumber = bDoSo; }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir public:
196cdf0e10cSrcweir 	virtual void SetText( const XubString& rStr );
197cdf0e10cSrcweir     virtual void SetText( const XubString& rStr, const Selection& rNewSelection );
198cdf0e10cSrcweir 	void	SetValidateText(const XubString& rText, const String* pErrorText = NULL);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	// die folgenden Methoden sind interesant, wenn m_bTreatAsNumber auf sal_False sitzt
201cdf0e10cSrcweir 	/**	nehmen wir mal an, irgendjemand will das ganze schoene double-Handling gar nicht haben, sondern
202cdf0e10cSrcweir 		einfach den Text formatiert ausgeben ...
203cdf0e10cSrcweir 		(der Text wird einfach nur durch den Formatter gejagt und dann gesetzt)
204cdf0e10cSrcweir 	*/
205cdf0e10cSrcweir 	void SetTextFormatted(const XubString& rText);
206cdf0e10cSrcweir 	String	GetTextValue() const;
207cdf0e10cSrcweir 
SetDefaultText(const XubString & rDefault)208cdf0e10cSrcweir 	void	SetDefaultText(const XubString& rDefault) { m_sDefaultText = rDefault; }
GetDefaultText() const209cdf0e10cSrcweir 	String	GetDefaultText() const { return m_sDefaultText; }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	// die bei der letzten Ausgabe-Operation vom Formatter gelieferte Farbe (Ausgabe-Operationen werden getriggert durch
212cdf0e10cSrcweir 	// SetValue, SetTextValue, SetTextFormatted, also indirekt eventuell auch durch SetMin-/-MaxValue)
GetLastOutputColor() const213cdf0e10cSrcweir 	Color*	GetLastOutputColor() const { return m_pLastOutputColor; }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	/** reformats the current text. Interesting if the user entered some text in an "input format", and
216cdf0e10cSrcweir 		this should be formatted in the "output format" (which may differ, e.g. by additional numeric
217cdf0e10cSrcweir 		digits or such).
218cdf0e10cSrcweir 	*/
219cdf0e10cSrcweir 	void	Commit();
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	// enable automatic coloring. if set to sal_True, and the format the field is working with for any current value
222cdf0e10cSrcweir 	// says that it has to be painted in a special color (e.g. a format where negative numbers should be printed
223cdf0e10cSrcweir 	// red), the text is painted with that color automatically.
224cdf0e10cSrcweir 	// The color used is the same as returned by GetLastOutputColor()
225cdf0e10cSrcweir 	void	SetAutoColor(sal_Bool _bAutomatic);
GetAutoColor() const226cdf0e10cSrcweir 	sal_Bool	GetAutoColor() const { return m_bAutoColor; }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     /** enables handling of not-a-number value.
229cdf0e10cSrcweir 
230cdf0e10cSrcweir         When this is set to <FALSE/> (the default), then invalid inputs (i.e. text which cannot be
231cdf0e10cSrcweir         intepreted, according to the current formatting) will be handled as if the default value
232cdf0e10cSrcweir         has been entered. GetValue the will return this default value.
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         When set to <TRUE/>, then GetValue will return NaN (not a number, see <method scope="rtl::math">isNan</method>)
235cdf0e10cSrcweir         when the current input is invalid.
236cdf0e10cSrcweir 
237cdf0e10cSrcweir         Note that setting this to <TRUE/> implies that upon leaving the control, the input
238cdf0e10cSrcweir         will *not* be corrected to a valid value. For example, if the user enters "foo" in the
239cdf0e10cSrcweir         control, and then tabs out of it, the text "foo" will persist, and GetValue will
240cdf0e10cSrcweir         return NaN in subsequent calls.
241cdf0e10cSrcweir     */
242cdf0e10cSrcweir     void    EnableNotANumber( sal_Bool _bEnable );
IsNotANumberEnabled() const243cdf0e10cSrcweir     sal_Bool    IsNotANumberEnabled( ) const { return m_bEnableNaN; }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     /** When being set to true, the strings in the field are formatted using the
246cdf0e10cSrcweir         InputLine format.  That's also what you get in Calc when you edit a cell
247cdf0e10cSrcweir         using F2
248cdf0e10cSrcweir      */
249cdf0e10cSrcweir     void    UseInputStringForFormatting( bool bUseInputStr = true );
250cdf0e10cSrcweir     bool    IsUsingInputStringForFormatting() const;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir protected:
253cdf0e10cSrcweir 	virtual long Notify(NotifyEvent& rNEvt);
254cdf0e10cSrcweir 	virtual void Modify();
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	// CheckText ueberschreiben fuer Ueberpruefung zur Eingabezeit
CheckText(const XubString &) const257cdf0e10cSrcweir 	virtual sal_Bool CheckText(const XubString&) const { return sal_True; }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	// any aspect of the current format has changed
260cdf0e10cSrcweir 	virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat);
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 	void ImplSetTextImpl(const XubString& rNew, Selection* pNewSel);
263cdf0e10cSrcweir 	void ImplSetValue(double dValue, sal_Bool bForce);
264cdf0e10cSrcweir 	sal_Bool ImplGetValue(double& dNewVal);
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	void ImplSetFormatKey(sal_uLong nFormatKey);
267cdf0e10cSrcweir 		// SetFormatKey without FormatChanged notification
268cdf0e10cSrcweir 
CreateFormatter()269cdf0e10cSrcweir 	virtual SvNumberFormatter*	CreateFormatter() { SetFormatter(StandardFormatter()); return m_pFormatter; }
ImplGetFormatter() const270cdf0e10cSrcweir 	SvNumberFormatter*	ImplGetFormatter() const { return m_pFormatter ? m_pFormatter : ((FormattedField*)this)->CreateFormatter(); }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	long PreNotify(NotifyEvent& rNEvt);
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	virtual void ReFormat();
275cdf0e10cSrcweir };
276cdf0e10cSrcweir 
277cdf0e10cSrcweir //------------------------------------------------------------------------------
278cdf0e10cSrcweir class SVT_DLLPUBLIC DoubleNumericField : public FormattedField
279cdf0e10cSrcweir {
280cdf0e10cSrcweir protected:
281cdf0e10cSrcweir #ifdef REGEXP_SUPPORT
282cdf0e10cSrcweir 	::utl::TextSearch*				m_pConformanceTester;
283cdf0e10cSrcweir #else
284cdf0e10cSrcweir 	validation::NumberValidator*	m_pNumberValidator;
285cdf0e10cSrcweir #endif
286cdf0e10cSrcweir 
287cdf0e10cSrcweir public:
DoubleNumericField(Window * pParent,WinBits nStyle=0)288cdf0e10cSrcweir 	DoubleNumericField(Window* pParent, WinBits nStyle = 0)
289cdf0e10cSrcweir 		:FormattedField(pParent, nStyle)
290cdf0e10cSrcweir #ifdef REGEXP_SUPPORT
291cdf0e10cSrcweir 		,m_pConformanceTester( NULL )
292cdf0e10cSrcweir #else
293cdf0e10cSrcweir 		,m_pNumberValidator( NULL )
294cdf0e10cSrcweir #endif
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir         ResetConformanceTester();
297cdf0e10cSrcweir 	}
298cdf0e10cSrcweir 
DoubleNumericField(Window * pParent,const ResId & rResId)299cdf0e10cSrcweir 	DoubleNumericField(Window* pParent, const ResId& rResId)
300cdf0e10cSrcweir 		:FormattedField(pParent, rResId)
301cdf0e10cSrcweir #ifdef REGEXP_SUPPORT
302cdf0e10cSrcweir 		,m_pConformanceTester( NULL )
303cdf0e10cSrcweir #else
304cdf0e10cSrcweir 		,m_pNumberValidator( NULL )
305cdf0e10cSrcweir #endif
306cdf0e10cSrcweir 	{
307cdf0e10cSrcweir         ResetConformanceTester();
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 	virtual ~DoubleNumericField();
310cdf0e10cSrcweir 
311cdf0e10cSrcweir protected:
312cdf0e10cSrcweir 	virtual sal_Bool CheckText(const XubString& sText) const;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat);
315cdf0e10cSrcweir 	void ResetConformanceTester();
316cdf0e10cSrcweir };
317cdf0e10cSrcweir 
318cdf0e10cSrcweir //==============================================================================
319cdf0e10cSrcweir #define FCT_CURRENCY_SYMBOL		0x10
320cdf0e10cSrcweir #define FCT_CURRSYM_POSITION	0x20
321cdf0e10cSrcweir 
322cdf0e10cSrcweir //------------------------------------------------------------------------------
323cdf0e10cSrcweir class DoubleCurrencyField : public FormattedField
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	XubString	m_sCurrencySymbol;
326cdf0e10cSrcweir 	sal_Bool		m_bPrependCurrSym;
327cdf0e10cSrcweir 	sal_Bool		m_bChangingFormat;
328cdf0e10cSrcweir 
329cdf0e10cSrcweir public:
330cdf0e10cSrcweir 	DoubleCurrencyField(Window* pParent, WinBits nStyle = 0);
331cdf0e10cSrcweir 	DoubleCurrencyField(Window* pParent, const ResId& rResId);
332cdf0e10cSrcweir 
getCurrencySymbol() const333cdf0e10cSrcweir 	XubString	getCurrencySymbol() const { return m_sCurrencySymbol; }
334cdf0e10cSrcweir 	void		setCurrencySymbol(const XubString& _sSymbol);
335cdf0e10cSrcweir 
getPrependCurrSym() const336cdf0e10cSrcweir 	sal_Bool		getPrependCurrSym() const { return m_bPrependCurrSym; }
337cdf0e10cSrcweir 	void		setPrependCurrSym(sal_Bool _bPrepend);
338cdf0e10cSrcweir 
339cdf0e10cSrcweir protected:
340cdf0e10cSrcweir 	virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat);
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 	void UpdateCurrencyFormat();
343cdf0e10cSrcweir };
344cdf0e10cSrcweir 
345cdf0e10cSrcweir #endif // _FMTFIELD_HXX_
346cdf0e10cSrcweir 
347