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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: IBM Corporation
*
* Copyright: 2008 by IBM Corporation
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/**
* @file
* For LWP filter architecture prototype - table object
*/
#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
#include <lwpatomholder.hxx>
#include "lwptblcell.hxx"
#include <lwpcolor.hxx>
#include "lwppiece.hxx"
//For converting to xml
#include <xfilter/xfnumberstyle.hxx>
class LwpObjectStream;
class LwpNumericFormatSubset final
{
public:
LwpNumericFormatSubset();
~LwpNumericFormatSubset();
void QuickRead(LwpObjectStream* pStrm);
OUString GetPrefix(){ return cPrefix.str();}
OUString GetSuffix(){ return cSuffix.str();}
bool IsDefaultPrefix(){ return !(cSubFlags&SF_OVER_PREFIX); }
bool IsDefaultSuffix(){ return !(cSubFlags&SF_OVER_SUFFIX); }
LwpColor GetColor();
private:
LwpColor cColor;
LwpAtomHolder cPrefix;
LwpAtomHolder cSuffix;
sal_uInt16 cSubFlags;
enum // for cSubFlags
{
SF_OVER_PREFIX = 0x0001,
SF_OVER_SUFFIX = 0x0002,
SF_OVER_COLOR = 0x0004
};
};
struct LwpCurrencyInfo
{
OUString sSymbol;
bool bPost;
bool bShowSpace;
explicit LwpCurrencyInfo(const OUString& sSym)
{
sSymbol = sSym;
bPost = false;
bShowSpace = false;
}
LwpCurrencyInfo()
{
bPost = false;
bShowSpace = false;
}
LwpCurrencyInfo(const OUString& sSym, bool bPost_, bool bShowSpace_)
{
sSymbol = sSym;
bPost = bPost_;
bShowSpace = bShowSpace_;
}
};
enum
{
/* These are types of formats. They are mutually exclusive.
*/
FMT_NONE = 0,
FMT_ARGENTINEANPESO = 1,
FMT_AUSTRALIANDOLLAR = 2,
FMT_AUSTRIANSCHILLING = 3,
FMT_BELGIANFRANC = 4,
FMT_BRAZILIANCRUZEIRO = 5,
FMT_BRITISHPOUND = 6,
FMT_CANADIANDOLLAR = 7,
FMT_CHINESEYUAN = 8,
FMT_CZECHKORUNA = 9,
FMT_DANISHKRONE = 10,
FMT_ECU = 11,
FMT_FINNISHMARKKA = 12,
FMT_FRENCHFRANC = 13,
FMT_GERMANMARK = 14,
FMT_GREEKDRACHMA = 15,
FMT_HONGKONGDOLLAR = 16,
FMT_HUNGARIANFORINT = 17,
FMT_INDIANRUPEE = 18,
FMT_INDONESIANRUPIAH = 19,
FMT_IRISHPUNT = 20,
FMT_ITALIANLIRA = 21,
FMT_JAPANESEYEN = 22,
FMT_LUXEMBOURGFRANC = 23,
FMT_MALAYSIANRINGGIT = 24,
FMT_MEXICANPESO = 25,
FMT_NETHERLANDSGUILDER = 26,
FMT_NEWZEALANDDOLLAR = 27,
FMT_NORWEGIANKRONE = 28,
FMT_POLISHZLOTY = 29,
FMT_PORTUGUESEESCUDO = 30,
FMT_ROMANIANLEI = 31,
FMT_RUSSIANRUBLE = 32,
FMT_SINGAPOREDOLLAR = 33,
FMT_SLOVAKIANKORUNA = 34,
FMT_SLOVENIANTHOLAR = 35,
FMT_SOUTHAFRICANRAND = 36,
FMT_SOUTHKOREANWON = 37,
FMT_SPANISHPESETA = 38,
FMT_SWEDISHKRONA = 39,
FMT_SWISSFRANC = 40,
FMT_TAIWANDOLLAR = 41,
FMT_THAIBAHT = 42,
FMT_USDOLLAR = 43,
FMT_OTHERCURRENCY = 44,
FMT_DEFAULT = 45,
FMT_GENERAL = 46,
FMT_FIXED = 47,
FMT_COMMA = 48,
FMT_PERCENT = 49,
FMT_SCIENTIFIC = 50,
FMT_LABEL = 51,
FMT_EURO = 52
};
class LwpCurrencyPool
{
public:
LwpCurrencyPool(){InitCurrencySymbol();}
OUString GetCurrencySymbol(sal_uInt16 nFormat);
bool IsShowSpace(sal_uInt16 nFormat);
bool IsSymbolPost(sal_uInt16 nFormat);
private:
std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
void InitCurrencySymbol()
{
sal_uInt16 nC=FMT_ARGENTINEANPESO;
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A"); //FMT_ARGENTINEANPESO = 1,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A$"); //FMT_AUSTRALIANDOLLAR = 2,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("oS",true, true);//FMT_AUSTRIANSCHILLING = 3,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("BF",true, true);//FMT_BELGIANFRANC = 4,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R$",false, true);//FMT_BRAZILIANCRUZEIRO = 5,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"\uFFE1")); //FMT_BRITISHPOUND = 6,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("C$"); //FMT_CANADIANDOLLAR = 7,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"PRC\uFFE5"),false,true); //FMT_CHINESEYUAN = 8,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Kc",true, true);//FMT_CZECHKORUNA = 9,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dkr",false, true);//FMT_DANISHKRONE = 10,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("ECU",true, true);//FMT_ECU = 11,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("mk",true, true);//FMT_FINNISHMARKKA = 12,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",true, true);//FMT_FRENCHFRANC = 13,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("DM",true, true);//FMT_GERMANMARK = 14,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dr",true, true);//FMT_GREEKDRACHMA = 15,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("HK$"); //FMT_HONGKONGDOLLAR = 16,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Ft",true, true);//FMT_HUNGARIANFORINT = 17,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rs",false, true);//FMT_INDIANRUPEE = 18,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rp",false, true);//FMT_INDONESIANRUPIAH = 19,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"IR\uFFE1")); //FMT_IRISHPUNT = 20,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("L.",false, true);//FMT_ITALIANLIRA = 21,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"\uFFE5")); //FMT_JAPANESEYEN = 22,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("LF",true, true);//FMT_LUXEMBOURGFRANC = 23,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rm",false, true);//FMT_MALAYSIANRINGGIT = 24,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Mex$"); //FMT_MEXICANPESO = 25,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",false, true);//FMT_NETHERLANDSGUILDER = 26,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NZ$"); //FMT_NEWZEALANDDOLLAR = 27,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Nkr",false, true);//FMT_NORWEGIANKRONE = 28,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Zl",true, true);//FMT_POLISHZLOTY = 29,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Esc.",true, true);//FMT_PORTUGUESEESCUDO = 30,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Leu",true, true);//FMT_ROMANIANLEI = 31,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R",true, true);//FMT_RUSSIANRUBLE = 32,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("S$"); //FMT_SINGAPOREDOLLAR = 33,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Sk",true, true);//FMT_SLOVAKIANKORUNA = 34,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SIT",false, true);//FMT_SLOVENIANTHOLAR = 35,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R"); //FMT_SOUTHAFRICANRAND = 36,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("W"); //FMT_SOUTHKOREANWON = 37,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Pts",true, true);//FMT_SPANISHPESETA = 38,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Skr",true, true);//FMT_SWEDISHKRONA = 39,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SFr",false, true);//FMT_SWISSFRANC = 40,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NT$"); //FMT_TAIWANDOLLAR = 41,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Bt",true, true);//FMT_THAIBAHT = 42,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("$"); //FMT_USDOLLAR = 43,
m_aCurrencyInfo[nC++]=LwpCurrencyInfo("OTH",false, true);//FMT_OTHERCURRENCY = 44,
m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(OUString(u"\u20AC")); //FMT_EURO = 52
}
};
class LwpNumericFormat
{
public:
explicit LwpNumericFormat(LwpObjectStream * pStrm);
void Read();
static bool IsCurrencyFormat(sal_uInt16 Format);
sal_uInt16 GetDecimalPlaces();
bool IsDecimalPlacesOverridden();
bool IsNegativeOverridden();
XFStyle* Convert();
private:
LwpObjectStream * m_pObjStrm;
sal_uInt16 cFlags;
enum // for cFlags
{
NF_OVER_ZERO = 0x0001,
NF_OVER_NEGATIVE = 0x0002,
NF_OVER_DECIMAL_PLACES = 0x0004
};
sal_uInt16 cFormat;
LwpNumericFormatSubset cAnyNumber;
LwpNumericFormatSubset cZero;
LwpNumericFormatSubset cNegative;
sal_uInt16 cDecimalPlaces;
static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
static LwpCurrencyPool m_aCurrencyInfo;
void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegtive=false);
void SetNumberType(XFNumberStyle* pStyle);
static OUString reencode(const OUString& sCode);
};
inline bool
LwpNumericFormat::IsDecimalPlacesOverridden()
{
return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
}
inline bool
LwpNumericFormat::IsNegativeOverridden()
{
return (cFlags & NF_OVER_NEGATIVE) != 0;
}
class LwpLayoutNumerics final : public LwpVirtualPiece
{
public:
LwpLayoutNumerics(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
:LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm.get()){}
XFStyle* Convert();
virtual void Read() override;
private:
virtual ~LwpLayoutNumerics() override {}
LwpNumericFormat cNumerics;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|