xref: /trunk/main/cui/source/inc/numfmt.hxx (revision c4eee24d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_NUMFMT_HXX
24 #define _SVX_NUMFMT_HXX
25 
26 //------------------------------------------------------------------------
27 
28 #include <vcl/window.hxx>
29 #include <tools/color.hxx>
30 #include <tools/string.hxx>
31 #include <sfx2/tabdlg.hxx>
32 #include <vcl/fixed.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <vcl/edit.hxx>
35 #include <vcl/toolbox.hxx>
36 #include <vcl/field.hxx>
37 #include <svx/langbox.hxx>
38 #include <svx/fontlb.hxx>
39 
40 //CHINA001 #define SVX_NUMVAL_STANDARD		-1234.12345678901234
41 //CHINA001 #define SVX_NUMVAL_CURRENCY		-1234
42 //CHINA001 #define SVX_NUMVAL_PERCENT		-0.1295
43 //CHINA001 #define SVX_NUMVAL_TIME 		36525.5678935185
44 //CHINA001 #define SVX_NUMVAL_DATE 		36525.5678935185
45 //CHINA001 #define SVX_NUMVAL_BOOLEAN 		1
46 
47 //------------------------------------------------------------------------
48 
49 class SvxNumberFormatShell;
50 class SvxNumberInfoItem;
51 
52 //------------------------------------------------------------------------
53 
54 class SvxNumberPreviewImpl : public Window
55 {
56 private:
57 	String			aPrevStr;
58 	Color			aPrevCol;
59 
60 	void			InitSettings( sal_Bool bForeground, sal_Bool bBackground );
61 
62 protected:
63 	virtual void	Paint( const Rectangle& rRect );
64 	virtual void	StateChanged( StateChangedType nStateChange );
65 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
66 
67 public:
68 	SvxNumberPreviewImpl( Window* pParent, const ResId& rResId );
69 	~SvxNumberPreviewImpl();
70 
71     void            NotifyChange( const String& rPrevStr, const Color* pColor = NULL );
72 };
73 
74 // -----------------------------------------------------------------------
75 
76 #include <sfx2/layout.hxx>
77 #include <layout/layout-pre.hxx>
78 
79 class SvxNumberFormatTabPage : public SfxTabPage
80 {
81 	using SfxTabPage::DeactivatePage;
82 
83 public:
84 	~SvxNumberFormatTabPage();
85 
86 #undef SfxTabPage
87 #define SfxTabPage ::SfxTabPage
88 	static SfxTabPage*		Create( Window* pParent,
89 									const SfxItemSet& rAttrSet );
90 	static sal_uInt16*			GetRanges();
91 
92 	virtual	sal_Bool 			FillItemSet( SfxItemSet& rSet );
93 	virtual	void 			Reset( const SfxItemSet& rSet );
94 	virtual int 			DeactivatePage	( SfxItemSet* pSet = NULL );
95 
96 	void					SetInfoItem( const SvxNumberInfoItem& rItem );
97 	void					SetNumberFormatList( const SvxNumberInfoItem& rItem )
98 								{ SetInfoItem( rItem ); }
99 
100 	void					SetOkHdl( const Link& rOkHandler );
101 	void					HideLanguage(sal_Bool nFlag=sal_True);
102 	virtual long			PreNotify( NotifyEvent& rNEvt );
103 	virtual void			PageCreated (SfxAllItemSet aSet); //add CHINA001
104 private:
105 	SvxNumberFormatTabPage( Window*	pParent,
106 							const SfxItemSet& rCoreAttrs );
107 	FixedText				aFtCategory;
108 	ListBox					aLbCategory;
109 	FixedText				aFtFormat;
110 	ListBox					aLbCurrency;
111 	SvxFontListBox			aLbFormat;
112 	FixedText				aFtLanguage;
113 	SvxLanguageBox			aLbLanguage;
114     CheckBox                aCbSourceFormat;
115 	SvxNumberPreviewImpl	aWndPreview;
116 	FixedLine               aFlOptions;
117 	FixedText				aFtDecimals;
118 	NumericField			aEdDecimals;
119 	CheckBox				aBtnNegRed;
120 	FixedText				aFtLeadZeroes;
121 	NumericField			aEdLeadZeroes;
122 	CheckBox				aBtnThousand;
123 
124 	FixedText				aFtEdFormat;
125 	Edit					aEdFormat;
126 	ImageButton				aIbAdd;
127 	ImageButton				aIbInfo;
128 	ImageButton				aIbRemove;
129 
130 	FixedText				aFtComment;
131 	Edit					aEdComment;
132 	Timer					aResetWinTimer;
133 
134 
135 	SvxNumberInfoItem*		pNumItem;
136 	SvxNumberFormatShell* 	pNumFmtShell;
137 	sal_uLong					nInitFormat;
138 	Link					fnOkHdl;
139 
140 	sal_Bool					bNumItemFlag; //Fuer Handling mit DocShell
141 	sal_Bool					bOneAreaFlag;
142 	short					nFixedCategory;
143 
144 	long					nCatHeight;
145 
146 	long					nCurFormatY;
147 	long					nCurFormatHeight;
148 	long					nStdFormatY;
149 	long					nStdFormatHeight;
150     LocalizedString sAutomaticEntry;
151 
152 	Window*					pLastActivWindow;
153 
154 #ifdef _SVX_NUMFMT_CXX
155 	void 	Init_Impl();
156 	void	FillCurrencyBox();
157 	void 	FillFormatListBox_Impl( SvxDelStrgs& rEntries );
158 	void 	UpdateOptions_Impl( sal_Bool bCheckCatChange );
159 	void	UpdateFormatListBox_Impl( sal_uInt16 bCat, sal_Bool bUpdateEdit );
160 	void	DeleteEntryList_Impl( SvxDelStrgs& rEntries );
161 	void	Obstructing();
162     void    EnableBySourceFormat_Impl();
163 	void	SetCategory( sal_uInt16 nPos );
164     String  GetExpColorString( Color*& rpPreviewColor, const String& aFormatStr, short nTmpCatPos );
165     void    MakePreviewText( const String& rFormat );
166     void    ChangePreviewText( sal_uInt16 nPos );
167     void    AddAutomaticLanguage_Impl(LanguageType eAutoLang, sal_Bool bSelect);
168 	// Handler
169 	DECL_LINK( LostFocusHdl_Impl, Edit* pEd );
170 	DECL_LINK( DoubleClickHdl_Impl, SvxFontListBox* pLb );
171 	DECL_LINK( SelFormatHdl_Impl, void * );
172 	DECL_LINK( ClickHdl_Impl, ImageButton* pIB );
173 	DECL_LINK( EditHdl_Impl, Edit* pEdFormat );
174 	DECL_LINK( OptHdl_Impl, void * );
175 	DECL_LINK( TimeHdl_Impl, Timer * );
176 
177 #endif
178 };
179 
180 #include <layout/layout-post.hxx>
181 
182 #endif
183 
184