Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _SVX_NUMFMTSH_HXX
20 : #define _SVX_NUMFMTSH_HXX
21 :
22 : #include <tools/string.hxx>
23 : #include <i18nlangtag/lang.h>
24 :
25 : #include "svx/svxdllapi.h"
26 :
27 : #include <svl/zforlist.hxx>
28 :
29 : #include <vector>
30 : #include <map>
31 :
32 : class Color;
33 :
34 : enum SvxNumberValueType
35 : {
36 : SVX_VALUE_TYPE_UNDEFINED = 0,
37 : SVX_VALUE_TYPE_NUMBER,
38 : SVX_VALUE_TYPE_STRING
39 : };
40 :
41 : // sort order of the category ListBox entries in the TabPage
42 : #define CAT_ALL 0
43 : #define CAT_USERDEFINED 1
44 : #define CAT_NUMBER 2
45 : #define CAT_PERCENT 3
46 : #define CAT_CURRENCY 4
47 : #define CAT_DATE 5
48 : #define CAT_TIME 6
49 : #define CAT_SCIENTIFIC 7
50 : #define CAT_FRACTION 8
51 : #define CAT_BOOLEAN 9
52 : #define CAT_TEXT 10
53 :
54 : #define SELPOS_NONE -1
55 :
56 : #define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
57 :
58 :
59 : class SVX_DLLPUBLIC SvxNumberFormatShell
60 : {
61 : public:
62 : SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
63 : sal_uInt32 nFormatKey,
64 : SvxNumberValueType eNumValType,
65 : const String& rNumStr );
66 :
67 : SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
68 : sal_uInt32 nFormatKey,
69 : SvxNumberValueType eNumValType,
70 : double nNumVal,
71 : const String* pNumStr = NULL );
72 :
73 : ~SvxNumberFormatShell();
74 :
75 :
76 : static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
77 : sal_uInt32 nFormatKey,
78 : SvxNumberValueType eNumValType,
79 : const String& rNumStr );
80 :
81 : static SvxNumberFormatShell* Create( SvNumberFormatter* pNumFormatter,
82 : sal_uInt32 nFormatKey,
83 : SvxNumberValueType eNumValType,
84 : double nNumVal,
85 : const String* pNumStr = NULL );
86 :
87 :
88 : void GetInitSettings( sal_uInt16& nCatLbPos,
89 : LanguageType& rLangType,
90 : sal_uInt16& nFmtLbSelPos,
91 : std::vector<String*>& rFmtEntries,
92 : String& rPrevString,
93 : Color*& rpPrevColor );
94 :
95 : void CategoryChanged( sal_uInt16 nCatLbPos,
96 : short& rFmtSelPos,
97 : std::vector<String*>& rFmtEntries );
98 :
99 : void LanguageChanged( LanguageType eLangType,
100 : short& rFmtSelPos,
101 : std::vector<String*>& rFmtEntries );
102 :
103 : void FormatChanged( sal_uInt16 nFmtLbPos,
104 : String& rPreviewStr,
105 : Color*& rpFontColor );
106 :
107 : bool AddFormat( String& rFormat,
108 : xub_StrLen& rErrPos,
109 : sal_uInt16& rCatLbSelPos,
110 : short& rFmtSelPos,
111 : std::vector<String*>& rFmtEntries );
112 :
113 : bool RemoveFormat( const String& rFormat,
114 : sal_uInt16& rCatLbSelPos,
115 : short& rFmtSelPos,
116 : std::vector<String*>& rFmtEntries );
117 :
118 : void MakeFormat( String& rFormat,
119 : bool bThousand,
120 : bool bNegRed,
121 : sal_uInt16 nPrecision,
122 : sal_uInt16 nLeadingZeroes,
123 : sal_uInt16 nCurrencyEntryPos);
124 :
125 : void GetOptions( const String& rFormat,
126 : bool& rThousand,
127 : bool& rNegRed,
128 : sal_uInt16& rPrecision,
129 : sal_uInt16& rLeadingZeroes,
130 : sal_uInt16& rCatLbPos );
131 :
132 : void MakePreviewString( const String& rFormatStr,
133 : String& rPreviewStr,
134 : Color*& rpFontColor );
135 :
136 : void MakePrevStringFromVal( const String& rFormatStr,
137 : String& rPreviewStr,
138 : Color*& rpFontColor,
139 : double nValue);
140 :
141 : bool IsUserDefined( const String& rFmtString );
142 : bool IsTmpCurrencyFormat( const String& rFmtString );
143 : bool FindEntry( const String& rFmtString, sal_uInt32* pAt = NULL );
144 :
145 0 : void ValidateNewEntries( bool bValidate = true ) { bUndoAddList = !bValidate; }
146 : size_t GetUpdateDataCount() const;
147 : void GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize );
148 :
149 0 : void SetCurNumFmtKey( sal_uInt32 nNew ) { nCurFormatKey = nNew; }
150 : void SetCurLanguage( LanguageType eNew ) { eCurLanguage = eNew; }
151 0 : sal_uInt32 GetCurNumFmtKey() const { return nCurFormatKey; }
152 0 : LanguageType GetCurLanguage() const { return eCurLanguage; }
153 :
154 : /** Returns the name of Standard, General, ... for the
155 : current language. */
156 : String GetStandardName() const;
157 :
158 : String GetComment4Entry(short nEntry);
159 : short GetCategory4Entry(short nEntry);
160 : bool GetUserDefined4Entry(short nEntry);
161 : String GetFormat4Entry(short nEntry);
162 : void SetComment4Entry(short nEntry,String aCommentString);
163 :
164 : void SetCurrencySymbol(sal_uInt16 nPos);
165 : sal_uInt32 GetCurrencySymbol();
166 : sal_uInt16 FindCurrencyFormat( const String& rFmtString );
167 : sal_uInt16 FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,bool bTmpBanking);
168 : void SetCurCurrencyEntry(NfCurrencyEntry*);
169 : short GetListPos4Entry(sal_uInt32 nIdx);
170 : short GetListPos4Entry( const String& rFmtString );
171 :
172 : void GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos );
173 : void GetCurrencySymbols(std::vector<OUString>& rList, bool bFlag );
174 :
175 : sal_uInt16 FindCurrencyTableEntry( const String& rFmtString, bool &bTestBanking );
176 : bool IsInTable(sal_uInt16 nPos, bool bTmpBanking,
177 : OUString const& rFmtString);
178 :
179 0 : void SetUseStarFormat( bool bUse ) { bUseStarFormat = bUse; }
180 : bool IsUseStarFormat( void ) { return bUseStarFormat; }
181 : private:
182 : static const double DEFAULT_NUMVALUE;
183 :
184 : SvNumberFormatter* pFormatter;
185 : SvNumberFormatTable* pCurFmtTable;
186 : SvxNumberValueType eValType;
187 : String aValStr;
188 : double nValNum;
189 : bool bUndoAddList;
190 : std::vector<sal_uInt32> aAddList;
191 : std::vector<sal_uInt32> aDelList;
192 : std::vector<sal_uInt32> aCurEntryList;
193 : sal_uInt32 nCurFormatKey;
194 : short nCurCategory;
195 : LanguageType eCurLanguage;
196 : std::vector<sal_uInt16> aCurCurrencyList;
197 : NfCurrencyEntry* pCurCurrencyEntry;
198 : bool bBankingSymbol;
199 : sal_uInt16 nCurCurrencyEntryPos;
200 : std::vector<String*> aCurrencyFormatList;
201 : bool bUseStarFormat;
202 :
203 : SVX_DLLPRIVATE short FillEntryList_Impl( std::vector<String*>& rList );
204 : SVX_DLLPRIVATE void FillEListWithStd_Impl( std::vector<String*>& rList,sal_uInt16 aPrivCat, short &Pos);
205 : SVX_DLLPRIVATE short FillEListWithFormats_Impl( std::vector<String*>& rList,short nSelPos,
206 : NfIndexTableOffset eOffsetStart,
207 : NfIndexTableOffset eOffsetEnd);
208 : SVX_DLLPRIVATE short FillEListWithDateTime_Impl( std::vector<String*>& rList,short nSelPos);
209 : SVX_DLLPRIVATE short FillEListWithCurrency_Impl( std::vector<String*>& rList,short nSelPos);
210 : SVX_DLLPRIVATE short FillEListWithSysCurrencys( std::vector<String*>& rList,short nSelPos);
211 : SVX_DLLPRIVATE short FillEListWithUserCurrencys( std::vector<String*>& rList,short nSelPos);
212 : SVX_DLLPRIVATE short FillEListWithUsD_Impl( std::vector<String*>& rList, sal_uInt16 nPrivCat, short Pos );
213 :
214 : SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetRemoved_Impl( size_t nKey );
215 : SVX_DLLPRIVATE bool IsRemoved_Impl( size_t nKey );
216 : SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetAdded_Impl( size_t nKey );
217 : SVX_DLLPRIVATE bool IsAdded_Impl( size_t nKey );
218 :
219 : SVX_DLLPRIVATE void GetPreviewString_Impl( String& rString,
220 : Color*& rpColor );
221 : SVX_DLLPRIVATE void PosToCategory_Impl( sal_uInt16 nPos, short& rCategory );
222 : SVX_DLLPRIVATE void CategoryToPos_Impl( short nCategory, sal_uInt16& rPos );
223 : };
224 :
225 : #endif
226 :
227 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|