summaryrefslogtreecommitdiff
path: root/svx/inc/svx/numfmtsh.hxx
blob: 6ecb600909a533fcee78b7257f47c736485d3e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: numfmtsh.hxx,v $
 * $Revision: 1.3.242.1 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _SVX_NUMFMTSH_HXX
#define _SVX_NUMFMTSH_HXX

// include ---------------------------------------------------------------

#include <tools/string.hxx>
#include <i18npool/lang.h>

#ifndef	_SVSTDARR_ULONGS
#define _SVSTDARR_ULONGS
#endif
#ifndef	_SVSTDARR_USHORTS
#define _SVSTDARR_USHORTS
#endif
#ifndef	_SVSTDARR_STRINGS
#define _SVSTDARR_STRINGS
#endif
#include "svx/svxdllapi.h"

#include <svtools/svstdarr.hxx>

// forward ---------------------------------------------------------------

class Color;
class SvNumberFormatter;
class SvNumberFormatTable;
class SvStrings;
class SvStringsDtor;
class NfCurrencyEntry;
// enum ------------------------------------------------------------------

enum SvxNumberValueType
{
    SVX_VALUE_TYPE_UNDEFINED = 0,
    SVX_VALUE_TYPE_NUMBER,
    SVX_VALUE_TYPE_STRING
};

// define ----------------------------------------------------------------

#define CAT_ALL				0	// Reihenfolge der Kategorie-
#define CAT_USERDEFINED		1	// ListBox-Eintraege in der TabPage
#define CAT_NUMBER			2
#define CAT_PERCENT			3
#define CAT_CURRENCY		4
#define CAT_DATE			5
#define CAT_TIME			6
#define CAT_SCIENTIFIC		7
#define CAT_FRACTION		8
#define CAT_BOOLEAN			9
#define CAT_TEXT			10

#define SELPOS_NONE			-1

#define NUMBERFORMAT_ENTRY_NEW_CURRENCY		NUMBERFORMAT_ENTRY_NOT_FOUND-1

typedef NfCurrencyEntry* NfShCurrencyEntryPtr;
SV_DECL_PTRARR( NfShCurrencyEntries, NfShCurrencyEntryPtr, 8, 1 )


class SvxDelStrgs: public SvStrings
{

public:
        ~SvxDelStrgs() { DeleteAndDestroy(0,Count());}

};

// class SvxNumberFormatShell --------------------------------------------

class SVX_DLLPUBLIC SvxNumberFormatShell
{
public:
                        SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
                                              sal_uInt32		 nFormatKey,
                                              SvxNumberValueType eNumValType,
                                              const String&		 rNumStr );

                        SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
                                              sal_uInt32		 nFormatKey,
                                              SvxNumberValueType eNumValType,
                                              double			 nNumVal,
                                              const String*		 pNumStr = NULL );

                        ~SvxNumberFormatShell();


    static SvxNumberFormatShell*	Create( SvNumberFormatter* pNumFormatter,
                                              sal_uInt32		 nFormatKey,
                                              SvxNumberValueType eNumValType,
                                              const String&		 rNumStr );

    static SvxNumberFormatShell*	Create( SvNumberFormatter* pNumFormatter,
                                              sal_uInt32		 nFormatKey,
                                              SvxNumberValueType eNumValType,
                                              double			 nNumVal,
                                              const String*		 pNumStr = NULL );


    void				GetInitSettings( USHORT&       nCatLbPos,
                                        LanguageType& rLangType,
                                         USHORT&       nFmtLbSelPos,
                                         SvStrings&    rFmtEntries,
                                         String&	   rPrevString,
                                         Color*&       rpPrevColor );

    void				CategoryChanged( USHORT     nCatLbPos,
                                        short&     rFmtSelPos,
                                         SvStrings& rFmtEntries );

    void				LanguageChanged( LanguageType eLangType,
                                         short&       rFmtSelPos,
                                         SvStrings&   rFmtEntries );

    void				FormatChanged( USHORT  nFmtLbPos,
                                       String& rPreviewStr,
                                       Color*& rpFontColor );

    BOOL				AddFormat( String&    rFormat,
                                   xub_StrLen& rErrPos,
                                   USHORT&    rCatLbSelPos,
                                   short&     rFmtSelPos,
                                   SvStrings& rFmtEntries );

    BOOL				RemoveFormat( const String&	rFormat,
                                      USHORT&       rCatLbSelPos,
                                      short&        rFmtSelPos,
                                      SvStrings&    rFmtEntries );

    void				MakeFormat( String& rFormat,
                                    BOOL    bThousand,
                                    BOOL    bNegRed,
                                    USHORT  nPrecision,
                                    USHORT  nLeadingZeroes,
                                    USHORT  nCurrencyEntryPos);

    void				GetOptions( const String& rFormat,
                                    BOOL&         rThousand,
                                    BOOL&         rNegRed,
                                    USHORT&       rPrecision,
                                    USHORT&       rLeadingZeroes,
                                    USHORT&       rCatLbPos );

    void				MakePreviewString( const String& rFormatStr,
                                           String&       rPreviewStr,
                                           Color*&       rpFontColor );

    void				MakePrevStringFromVal( const String& rFormatStr,		//@ 19.09.97
                                                String&	rPreviewStr,
                                                Color*& rpFontColor,
                                                double	nValue);

    BOOL				IsUserDefined( const String& rFmtString );
    BOOL				IsTmpCurrencyFormat( const String& rFmtString );
    BOOL				FindEntry( const String& rFmtString, sal_uInt32* pAt = NULL );

    void				ValidateNewEntries( BOOL bValidate = TRUE ) { bUndoAddList = !bValidate; }
    sal_uInt32			GetUpdateDataCount() const;
    void				GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize );

    void				SetCurNumFmtKey( sal_uInt32 nNew )	{ nCurFormatKey = nNew; }
    void				SetCurLanguage( LanguageType eNew ) { eCurLanguage = eNew; }
    sal_uInt32			GetCurNumFmtKey() const				{ return nCurFormatKey; }
    LanguageType		GetCurLanguage() const				{ return eCurLanguage; }

                        /** Returns the name of Standard, General, ... for the
                            current language. */
    String              GetStandardName() const;

    String				GetComment4Entry(short nEntry);
    short				GetCategory4Entry(short nEntry);
    BOOL				GetUserDefined4Entry(short nEntry);
    String				GetFormat4Entry(short nEntry);
    void				SetComment4Entry(short nEntry,String aCommentString);

    BOOL				IsBankingSymbol(USHORT nPos);
    void				SetCurrencySymbol(USHORT nPos);
    sal_uInt32			GetCurrencySymbol();
    USHORT				FindCurrencyFormat( const String& rFmtString );
    USHORT				FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,BOOL bTmpBanking);
    NfCurrencyEntry*	GetCurCurrencyEntry();
    void				SetCurCurrencyEntry(NfCurrencyEntry*);
    short				GetListPos4Entry(sal_uInt32 nIdx);
    short				GetListPos4Entry( const String& rFmtString );

    void				GetCurrencySymbols(SvStringsDtor& rList,const XubString& rStrEurope,USHORT* pPos);
    void				GetCurrencySymbols(SvStringsDtor& rList,const XubString& rStrEurope, BOOL bFlag);

    USHORT				FindCurrencyTableEntry( const String& rFmtString, BOOL &bTestBanking );
    BOOL				IsInTable(USHORT nPos,BOOL bTmpBanking,const String &rFmtString);

    void				GetCurrencyFormats(SvStrings& rList);

private:
    static const double 	DEFAULT_NUMVALUE;	// 123456789

    SvNumberFormatter*		pFormatter;
    SvNumberFormatTable*	pCurFmtTable;
    SvxNumberValueType		eValType;
    String					aValStr;
    double					nValNum;
    BOOL					bUndoAddList;
    SvULongs				aAddList;
    SvULongs				aDelList;
    SvULongs				aCurEntryList;
    sal_uInt32				nInitFormatKey;
    sal_uInt32				nCurFormatKey;
    short					nCurCategory;
    LanguageType			eCurLanguage;
    SvUShorts				aCurCurrencyList;
    NfCurrencyEntry*		pCurCurrencyEntry;
    BOOL					bBankingSymbol;
    USHORT					nCurCurrencyEntryPos;
    SvStrings				aCurrencyFormatList;

#ifdef _SVX_NUMFMTSH_CXX
    SVX_DLLPRIVATE short					FillEntryList_Impl( SvStrings& rList );
    SVX_DLLPRIVATE void					FillEListWithStd_Impl( SvStrings& rList,USHORT aPrivCat, short &Pos);
    SVX_DLLPRIVATE short					FillEListWithFormats_Impl( SvStrings& rList,short nSelPos,
                                                       NfIndexTableOffset eOffsetStart,
                                                       NfIndexTableOffset eOffsetEnd);

    SVX_DLLPRIVATE short					FillEListWithDateTime_Impl( SvStrings& rList,short nSelPos);

    SVX_DLLPRIVATE short					FillEListWithCurrency_Impl( SvStrings& rList,short nSelPos);
    SVX_DLLPRIVATE short					FillEListWithSysCurrencys( SvStrings& rList,short nSelPos);
    SVX_DLLPRIVATE short					FillEListWithUserCurrencys( SvStrings& rList,short nSelPos);

    SVX_DLLPRIVATE short					FillEListWithUsD_Impl( SvStrings& rList, sal_uInt16 nPrivCat, short Pos );
    SVX_DLLPRIVATE BOOL					IsRemoved_Impl( sal_uInt32 nKey );
    SVX_DLLPRIVATE BOOL					IsAdded_Impl( sal_uInt32 nKey );
    SVX_DLLPRIVATE void					GetPreviewString_Impl( String& rString,
                                                   Color*& rpColor );
    SVX_DLLPRIVATE void					PosToCategory_Impl( USHORT nPos, short& rCategory );
    SVX_DLLPRIVATE void					CategoryToPos_Impl( short nCategory, USHORT& rPos );
#endif
};


#endif