xref: /trunk/main/cui/source/inc/numfmt.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SVX_NUMFMT_HXX
28 #define _SVX_NUMFMT_HXX
29 
30 //------------------------------------------------------------------------
31 
32 #include <vcl/window.hxx>
33 #include <tools/color.hxx>
34 #include <tools/string.hxx>
35 #include <sfx2/tabdlg.hxx>
36 #include <vcl/fixed.hxx>
37 #include <vcl/lstbox.hxx>
38 #include <vcl/edit.hxx>
39 #include <vcl/toolbox.hxx>
40 #include <vcl/field.hxx>
41 #include <svx/langbox.hxx>
42 #include <svx/fontlb.hxx>
43 
44 //CHINA001 #define SVX_NUMVAL_STANDARD      -1234.12345678901234
45 //CHINA001 #define SVX_NUMVAL_CURRENCY      -1234
46 //CHINA001 #define SVX_NUMVAL_PERCENT       -0.1295
47 //CHINA001 #define SVX_NUMVAL_TIME      36525.5678935185
48 //CHINA001 #define SVX_NUMVAL_DATE      36525.5678935185
49 //CHINA001 #define SVX_NUMVAL_BOOLEAN       1
50 
51 //------------------------------------------------------------------------
52 
53 class SvxNumberFormatShell;
54 class SvxNumberInfoItem;
55 
56 //------------------------------------------------------------------------
57 
58 class SvxNumberPreviewImpl : public Window
59 {
60 private:
61     String          aPrevStr;
62     Color           aPrevCol;
63 
64     void            InitSettings( sal_Bool bForeground, sal_Bool bBackground );
65 
66 protected:
67     virtual void    Paint( const Rectangle& rRect );
68     virtual void    StateChanged( StateChangedType nStateChange );
69     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
70 
71 public:
72     SvxNumberPreviewImpl( Window* pParent, const ResId& rResId );
73     ~SvxNumberPreviewImpl();
74 
75     void            NotifyChange( const String& rPrevStr, const Color* pColor = NULL );
76 };
77 
78 // -----------------------------------------------------------------------
79 
80 #include <sfx2/layout.hxx>
81 #include <layout/layout-pre.hxx>
82 
83 class SvxNumberFormatTabPage : public SfxTabPage
84 {
85     using SfxTabPage::DeactivatePage;
86 
87 public:
88     ~SvxNumberFormatTabPage();
89 
90 #undef SfxTabPage
91 #define SfxTabPage ::SfxTabPage
92     static SfxTabPage*      Create( Window* pParent,
93                                     const SfxItemSet& rAttrSet );
94     static sal_uInt16*          GetRanges();
95 
96     virtual sal_Bool            FillItemSet( SfxItemSet& rSet );
97     virtual void            Reset( const SfxItemSet& rSet );
98     virtual int             DeactivatePage  ( SfxItemSet* pSet = NULL );
99 
100     void                    SetInfoItem( const SvxNumberInfoItem& rItem );
101     void                    SetNumberFormatList( const SvxNumberInfoItem& rItem )
102                                 { SetInfoItem( rItem ); }
103 
104     void                    SetOkHdl( const Link& rOkHandler );
105     void                    HideLanguage(sal_Bool nFlag=sal_True);
106     virtual long            PreNotify( NotifyEvent& rNEvt );
107     virtual void            PageCreated (SfxAllItemSet aSet); //add CHINA001
108 private:
109     SvxNumberFormatTabPage( Window* pParent,
110                             const SfxItemSet& rCoreAttrs );
111     FixedText               aFtCategory;
112     ListBox                 aLbCategory;
113     FixedText               aFtFormat;
114     ListBox                 aLbCurrency;
115     SvxFontListBox          aLbFormat;
116     FixedText               aFtLanguage;
117     SvxLanguageBox          aLbLanguage;
118     CheckBox                aCbSourceFormat;
119     SvxNumberPreviewImpl    aWndPreview;
120     FixedLine               aFlOptions;
121     FixedText               aFtDecimals;
122     NumericField            aEdDecimals;
123     CheckBox                aBtnNegRed;
124     FixedText               aFtLeadZeroes;
125     NumericField            aEdLeadZeroes;
126     CheckBox                aBtnThousand;
127 
128     FixedText               aFtEdFormat;
129     Edit                    aEdFormat;
130     ImageButton             aIbAdd;
131     ImageButton             aIbInfo;
132     ImageButton             aIbRemove;
133 
134     FixedText               aFtComment;
135     Edit                    aEdComment;
136     Timer                   aResetWinTimer;
137 
138 
139     SvxNumberInfoItem*      pNumItem;
140     SvxNumberFormatShell*   pNumFmtShell;
141     sal_uLong                   nInitFormat;
142     Link                    fnOkHdl;
143 
144     sal_Bool                    bNumItemFlag; //Fuer Handling mit DocShell
145     sal_Bool                    bOneAreaFlag;
146     short                   nFixedCategory;
147 
148     long                    nCatHeight;
149 
150     long                    nCurFormatY;
151     long                    nCurFormatHeight;
152     long                    nStdFormatY;
153     long                    nStdFormatHeight;
154     LocalizedString sAutomaticEntry;
155 
156     Window*                 pLastActivWindow;
157 
158 #ifdef _SVX_NUMFMT_CXX
159     void    Init_Impl();
160     void    FillCurrencyBox();
161     void    FillFormatListBox_Impl( SvxDelStrgs& rEntries );
162     void    UpdateOptions_Impl( sal_Bool bCheckCatChange );
163     void    UpdateFormatListBox_Impl( sal_uInt16 bCat, sal_Bool bUpdateEdit );
164     void    DeleteEntryList_Impl( SvxDelStrgs& rEntries );
165     void    Obstructing();
166     void    EnableBySourceFormat_Impl();
167     void    SetCategory( sal_uInt16 nPos );
168     String  GetExpColorString( Color*& rpPreviewColor, const String& aFormatStr, short nTmpCatPos );
169     void    MakePreviewText( const String& rFormat );
170     void    ChangePreviewText( sal_uInt16 nPos );
171     void    AddAutomaticLanguage_Impl(LanguageType eAutoLang, sal_Bool bSelect);
172     // Handler
173     DECL_LINK( LostFocusHdl_Impl, Edit* pEd );
174     DECL_LINK( DoubleClickHdl_Impl, SvxFontListBox* pLb );
175     DECL_LINK( SelFormatHdl_Impl, void * );
176     DECL_LINK( ClickHdl_Impl, ImageButton* pIB );
177     DECL_LINK( EditHdl_Impl, Edit* pEdFormat );
178     DECL_LINK( OptHdl_Impl, void * );
179     DECL_LINK( TimeHdl_Impl, Timer * );
180 
181 #endif
182 };
183 
184 #include <layout/layout-post.hxx>
185 
186 #endif
187 
188