1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
58 * For LWP filter architecture prototype - table object
60 /*************************************************************************
63 ************************************************************************/
64 #ifndef _LWPNUMBERICFMT_HXX
65 #define _LWPNUMBERICFMT_HXX
67 #include "lwpatomholder.hxx"
68 #include "lwptblcell.hxx"
69 #include "lwpcolor.hxx"
71 //For converting to xml
72 #include "xfilter/xfnumberstyle.hxx"
74 class LwpObjectStream
;
76 class LwpNumericFormatSubset
79 LwpNumericFormatSubset();
80 ~LwpNumericFormatSubset();
81 void QuickRead(LwpObjectStream
* pStrm
);
82 String
GetPrefix(){ return cPrefix
.str();}
83 String
GetSuffix(){ return cSuffix
.str();}
84 sal_Bool
IsBlack(){ return (cColor
.GetBlue()==0 && cColor
.GetGreen()==0 && cColor
.GetRed()==0);}
85 sal_Bool
IsDefaultPrefix(){ return !(cSubFlags
&SF_OVER_PREFIX
); }
86 sal_Bool
IsDefaultSuffix(){ return !(cSubFlags
&SF_OVER_SUFFIX
); }
90 LwpAtomHolder cPrefix
;
91 LwpAtomHolder cSuffix
;
95 SF_OVER_PREFIX
= 0x0001,
96 SF_OVER_SUFFIX
= 0x0002,
97 SF_OVER_COLOR
= 0x0004
101 struct LwpCurrencyInfo
106 LwpCurrencyInfo(String sSym
)
110 bShowSpace
= sal_False
;
115 bShowSpace
= sal_False
;
117 LwpCurrencyInfo(String sSym
,sal_Bool bPost_
, sal_Bool bShowSpace_
)
121 bShowSpace
= bShowSpace_
;
127 /* These are types of formats. They are mutually exclusive.
130 FMT_ARGENTINEANPESO
= 1,
131 FMT_AUSTRALIANDOLLAR
= 2,
132 FMT_AUSTRIANSCHILLING
= 3,
133 FMT_BELGIANFRANC
= 4,
134 FMT_BRAZILIANCRUZEIRO
= 5,
135 FMT_BRITISHPOUND
= 6,
136 FMT_CANADIANDOLLAR
= 7,
139 FMT_DANISHKRONE
= 10,
141 FMT_FINNISHMARKKA
= 12,
142 FMT_FRENCHFRANC
= 13,
144 FMT_GREEKDRACHMA
= 15,
145 FMT_HONGKONGDOLLAR
= 16,
146 FMT_HUNGARIANFORINT
= 17,
147 FMT_INDIANRUPEE
= 18,
148 FMT_INDONESIANRUPIAH
= 19,
150 FMT_ITALIANLIRA
= 21,
151 FMT_JAPANESEYEN
= 22,
152 FMT_LUXEMBOURGFRANC
= 23,
153 FMT_MALAYSIANRINGGIT
= 24,
154 FMT_MEXICANPESO
= 25,
155 FMT_NETHERLANDSGUILDER
= 26,
156 FMT_NEWZEALANDDOLLAR
= 27,
157 FMT_NORWEGIANKRONE
= 28,
158 FMT_POLISHZLOTY
= 29,
159 FMT_PORTUGUESEESCUDO
= 30,
160 FMT_ROMANIANLEI
= 31,
161 FMT_RUSSIANRUBLE
= 32,
162 FMT_SINGAPOREDOLLAR
= 33,
163 FMT_SLOVAKIANKORUNA
= 34,
164 FMT_SLOVENIANTHOLAR
= 35,
165 FMT_SOUTHAFRICANRAND
= 36,
166 FMT_SOUTHKOREANWON
= 37,
167 FMT_SPANISHPESETA
= 38,
168 FMT_SWEDISHKRONA
= 39,
170 FMT_TAIWANDOLLAR
= 41,
173 FMT_OTHERCURRENCY
= 44,
184 class LwpCurrencyPool
187 LwpCurrencyPool(){InitCurrencySymbol();}
188 String
GetCurrencySymbol(sal_uInt16 nFormat
);
189 sal_Bool
IsShowSpace(sal_uInt16 nFormat
);
190 sal_Bool
IsSymbolPost(sal_uInt16 nFormat
);
192 std::map
<sal_uInt16
,LwpCurrencyInfo
> m_aCurrencyInfo
;
193 void InitCurrencySymbol()
195 sal_uInt16 nC
=FMT_ARGENTINEANPESO
;
196 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("A")); //FMT_ARGENTINEANPESO = 1,
197 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("A$")); //FMT_AUSTRALIANDOLLAR = 2,
198 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("oS"),sal_True
, sal_True
);//FMT_AUSTRIANSCHILLING = 3,
199 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("BF"),sal_True
, sal_True
);//FMT_BELGIANFRANC = 4,
200 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("R$"),sal_False
, sal_True
);//FMT_BRAZILIANCRUZEIRO = 5,
201 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(String("£",RTL_TEXTENCODING_UTF8
)); //FMT_BRITISHPOUND = 6,
202 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("C$")); //FMT_CANADIANDOLLAR = 7,
203 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(String("PRC¥",RTL_TEXTENCODING_UTF8
),sal_False
,sal_True
); //FMT_CHINESEYUAN = 8,
204 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Kc"),sal_True
, sal_True
);//FMT_CZECHKORUNA = 9,
205 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Dkr"),sal_False
, sal_True
);//FMT_DANISHKRONE = 10,
206 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("ECU"),sal_True
, sal_True
);//FMT_ECU = 11,
207 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("mk"),sal_True
, sal_True
);//FMT_FINNISHMARKKA = 12,
208 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("F"),sal_True
, sal_True
);//FMT_FRENCHFRANC = 13,
209 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("DM"),sal_True
, sal_True
);//FMT_GERMANMARK = 14,
210 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Dr"),sal_True
, sal_True
);//FMT_GREEKDRACHMA = 15,
211 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("HK$")); //FMT_HONGKONGDOLLAR = 16,
212 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Ft"),sal_True
, sal_True
);//FMT_HUNGARIANFORINT = 17,
213 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Rs"),sal_False
, sal_True
);//FMT_INDIANRUPEE = 18,
214 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Rp"),sal_False
, sal_True
);//FMT_INDONESIANRUPIAH = 19,
215 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(String("IR£",RTL_TEXTENCODING_UTF8
)); //FMT_IRISHPUNT = 20,
216 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("L."),sal_False
, sal_True
);//FMT_ITALIANLIRA = 21,
217 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(String("¥",RTL_TEXTENCODING_UTF8
)); //FMT_JAPANESEYEN = 22,
218 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("LF"),sal_True
, sal_True
);//FMT_LUXEMBOURGFRANC = 23,
219 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Rm"),sal_False
, sal_True
);//FMT_MALAYSIANRINGGIT = 24,
220 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Mex$")); //FMT_MEXICANPESO = 25,
221 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("F"),sal_False
, sal_True
);//FMT_NETHERLANDSGUILDER = 26,
222 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("NZ$")); //FMT_NEWZEALANDDOLLAR = 27,
223 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Nkr"),sal_False
, sal_True
);//FMT_NORWEGIANKRONE = 28,
224 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Zl"),sal_True
, sal_True
);//FMT_POLISHZLOTY = 29,
225 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Esc."),sal_True
, sal_True
);//FMT_PORTUGUESEESCUDO = 30,
226 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Leu"),sal_True
, sal_True
);//FMT_ROMANIANLEI = 31,
227 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("R"),sal_True
, sal_True
);//FMT_RUSSIANRUBLE = 32,
228 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("S$")); //FMT_SINGAPOREDOLLAR = 33,
229 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Sk"),sal_True
, sal_True
);//FMT_SLOVAKIANKORUNA = 34,
230 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("SIT"),sal_False
, sal_True
);//FMT_SLOVENIANTHOLAR = 35,
231 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("R")); //FMT_SOUTHAFRICANRAND = 36,
232 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("W")); //FMT_SOUTHKOREANWON = 37,
233 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Pts"),sal_True
, sal_True
);//FMT_SPANISHPESETA = 38,
234 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Skr"),sal_True
, sal_True
);//FMT_SWEDISHKRONA = 39,
235 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("SFr"),sal_False
, sal_True
);//FMT_SWISSFRANC = 40,
236 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("NT$")); //FMT_TAIWANDOLLAR = 41,
237 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("Bt"),sal_True
, sal_True
);//FMT_THAIBAHT = 42,
238 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("$")); //FMT_USDOLLAR = 43,
239 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString("OTH"),sal_False
, sal_True
);//FMT_OTHERCURRENCY = 44,
241 m_aCurrencyInfo
[FMT_EURO
]=LwpCurrencyInfo(String("€",RTL_TEXTENCODING_UTF8
)); //FMT_EURO = 52
245 class LwpNumericFormat
248 LwpNumericFormat(LwpObjectStream
* pStrm
);
249 ~LwpNumericFormat(){}
251 static sal_Bool
IsCurrencyFormat(sal_uInt16 Format
);
252 sal_uInt16
GetDecimalPlaces(void);
253 sal_Bool
IsDecimalPlacesOverridden(void);
254 sal_Bool
IsNegativeOverridden(void);
255 sal_Bool
IsZeroOverridden(void);
258 LwpObjectStream
* m_pObjStrm
;
263 NF_OVER_ZERO
= 0x0001,
264 NF_OVER_NEGATIVE
= 0x0002,
265 NF_OVER_DECIMAL_PLACES
= 0x0004
270 LwpNumericFormatSubset cAnyNumber
;
271 LwpNumericFormatSubset cZero
;
272 LwpNumericFormatSubset cNegative
;
274 sal_uInt16 cDecimalPlaces
;
276 static sal_uInt16
GetDefaultDecimalPlaces(sal_uInt16 Format
);
277 static LwpCurrencyPool m_aCurrencyInfo
;
279 void GetCurrencyStr(LwpNumericFormatSubset aNumber
, String
& aPrefix
, String
& aSuffix
, sal_Bool bNegtive
=sal_False
);
280 void SetNumberType(XFNumberStyle
* pStyle
);
281 OUString
reencode(OUString sCode
);
285 LwpNumericFormat::IsDecimalPlacesOverridden(void)
287 return (cFlags
& NF_OVER_DECIMAL_PLACES
) != 0;
290 LwpNumericFormat::IsNegativeOverridden(void)
292 return (cFlags
& NF_OVER_NEGATIVE
) != 0;
295 LwpNumericFormat::IsZeroOverridden(void)
297 return (cFlags
& NF_OVER_ZERO
) != 0;
300 #include "lwppiece.hxx"
301 class LwpLayoutNumerics
: public LwpVirtualPiece
304 LwpLayoutNumerics(LwpObjectHeader
& objHdr
, LwpSvStream
* pStrm
)
305 :LwpVirtualPiece(objHdr
, pStrm
),cNumerics(m_pObjStrm
){}
306 ~LwpLayoutNumerics(){}
310 LwpNumericFormat cNumerics
;
315 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */