xref: /trunk/main/cui/source/inc/numfmt.hxx (revision 41f6d156)
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 	static SfxTabPage*		Create( Window* pParent,
87 									const SfxItemSet& rAttrSet );
88 	static sal_uInt16*			GetRanges();
89 
90 	virtual	sal_Bool 			FillItemSet( SfxItemSet& rSet );
91 	virtual	void 			Reset( const SfxItemSet& rSet );
92 	virtual int 			DeactivatePage	( SfxItemSet* pSet = NULL );
93 
94 	void					SetInfoItem( const SvxNumberInfoItem& rItem );
SetNumberFormatList(const SvxNumberInfoItem & rItem)95 	void					SetNumberFormatList( const SvxNumberInfoItem& rItem )
96 								{ SetInfoItem( rItem ); }
97 
98 	void					SetOkHdl( const Link& rOkHandler );
99 	void					HideLanguage(sal_Bool nFlag=sal_True);
100 	virtual long			PreNotify( NotifyEvent& rNEvt );
101 	virtual void			PageCreated (SfxAllItemSet aSet); //add CHINA001
102 private:
103 	SvxNumberFormatTabPage( Window*	pParent,
104 							const SfxItemSet& rCoreAttrs );
105 	FixedText				aFtCategory;
106 	ListBox					aLbCategory;
107 	FixedText				aFtFormat;
108 	ListBox					aLbCurrency;
109 	SvxFontListBox			aLbFormat;
110 	FixedText				aFtLanguage;
111 	SvxLanguageBox			aLbLanguage;
112     CheckBox                aCbSourceFormat;
113 	SvxNumberPreviewImpl	aWndPreview;
114 	FixedLine               aFlOptions;
115 	FixedText				aFtDecimals;
116 	NumericField			aEdDecimals;
117 	CheckBox				aBtnNegRed;
118 	FixedText				aFtLeadZeroes;
119 	NumericField			aEdLeadZeroes;
120 	CheckBox				aBtnThousand;
121 
122 	FixedText				aFtEdFormat;
123 	Edit					aEdFormat;
124 	ImageButton				aIbAdd;
125 	ImageButton				aIbInfo;
126 	ImageButton				aIbRemove;
127 
128 	FixedText				aFtComment;
129 	Edit					aEdComment;
130 	Timer					aResetWinTimer;
131 
132 
133 	SvxNumberInfoItem*		pNumItem;
134 	SvxNumberFormatShell* 	pNumFmtShell;
135 	sal_uLong					nInitFormat;
136 	Link					fnOkHdl;
137 
138 	sal_Bool					bNumItemFlag; //Fuer Handling mit DocShell
139 	sal_Bool					bOneAreaFlag;
140 	short					nFixedCategory;
141 
142 	long					nCatHeight;
143 
144 	long					nCurFormatY;
145 	long					nCurFormatHeight;
146 	long					nStdFormatY;
147 	long					nStdFormatHeight;
148     LocalizedString sAutomaticEntry;
149 
150 	Window*					pLastActivWindow;
151 
152 #ifdef _SVX_NUMFMT_CXX
153 	void 	Init_Impl();
154 	void	FillCurrencyBox();
155 	void 	FillFormatListBox_Impl( SvxDelStrgs& rEntries );
156 	void 	UpdateOptions_Impl( sal_Bool bCheckCatChange );
157 	void	UpdateFormatListBox_Impl( sal_uInt16 bCat, sal_Bool bUpdateEdit );
158 	void	DeleteEntryList_Impl( SvxDelStrgs& rEntries );
159 	void	Obstructing();
160     void    EnableBySourceFormat_Impl();
161 	void	SetCategory( sal_uInt16 nPos );
162     String  GetExpColorString( Color*& rpPreviewColor, const String& aFormatStr, short nTmpCatPos );
163     void    MakePreviewText( const String& rFormat );
164     void    ChangePreviewText( sal_uInt16 nPos );
165     void    AddAutomaticLanguage_Impl(LanguageType eAutoLang, sal_Bool bSelect);
166 	// Handler
167 	DECL_LINK( LostFocusHdl_Impl, Edit* pEd );
168 	DECL_LINK( DoubleClickHdl_Impl, SvxFontListBox* pLb );
169 	DECL_LINK( SelFormatHdl_Impl, void * );
170 	DECL_LINK( ClickHdl_Impl, ImageButton* pIB );
171 	DECL_LINK( EditHdl_Impl, Edit* pEdFormat );
172 	DECL_LINK( OptHdl_Impl, void * );
173 	DECL_LINK( TimeHdl_Impl, Timer * );
174 
175 #endif
176 };
177 
178 #include <layout/layout-post.hxx>
179 
180 #endif
181 
182