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
61 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
62 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
64 #include "lwpatomholder.hxx"
65 #include "lwptblcell.hxx"
66 #include "lwpcolor.hxx"
68 //For converting to xml
69 #include "xfilter/xfnumberstyle.hxx"
71 class LwpObjectStream
;
73 class LwpNumericFormatSubset
76 LwpNumericFormatSubset();
77 ~LwpNumericFormatSubset();
78 void QuickRead(LwpObjectStream
* pStrm
);
79 OUString
GetPrefix(){ return cPrefix
.str();}
80 OUString
GetSuffix(){ return cSuffix
.str();}
81 bool IsBlack(){ return (cColor
.GetBlue()==0 && cColor
.GetGreen()==0 && cColor
.GetRed()==0);}
82 bool IsDefaultPrefix(){ return !(cSubFlags
&SF_OVER_PREFIX
); }
83 bool IsDefaultSuffix(){ return !(cSubFlags
&SF_OVER_SUFFIX
); }
88 LwpAtomHolder cPrefix
;
89 LwpAtomHolder cSuffix
;
94 SF_OVER_PREFIX
= 0x0001,
95 SF_OVER_SUFFIX
= 0x0002,
96 SF_OVER_COLOR
= 0x0004
100 struct LwpCurrencyInfo
105 LwpCurrencyInfo(const OUString
& sSym
)
116 LwpCurrencyInfo(const OUString
& sSym
, bool bPost_
, bool bShowSpace_
)
120 bShowSpace
= bShowSpace_
;
126 /* These are types of formats. They are mutually exclusive.
129 FMT_ARGENTINEANPESO
= 1,
130 FMT_AUSTRALIANDOLLAR
= 2,
131 FMT_AUSTRIANSCHILLING
= 3,
132 FMT_BELGIANFRANC
= 4,
133 FMT_BRAZILIANCRUZEIRO
= 5,
134 FMT_BRITISHPOUND
= 6,
135 FMT_CANADIANDOLLAR
= 7,
138 FMT_DANISHKRONE
= 10,
140 FMT_FINNISHMARKKA
= 12,
141 FMT_FRENCHFRANC
= 13,
143 FMT_GREEKDRACHMA
= 15,
144 FMT_HONGKONGDOLLAR
= 16,
145 FMT_HUNGARIANFORINT
= 17,
146 FMT_INDIANRUPEE
= 18,
147 FMT_INDONESIANRUPIAH
= 19,
149 FMT_ITALIANLIRA
= 21,
150 FMT_JAPANESEYEN
= 22,
151 FMT_LUXEMBOURGFRANC
= 23,
152 FMT_MALAYSIANRINGGIT
= 24,
153 FMT_MEXICANPESO
= 25,
154 FMT_NETHERLANDSGUILDER
= 26,
155 FMT_NEWZEALANDDOLLAR
= 27,
156 FMT_NORWEGIANKRONE
= 28,
157 FMT_POLISHZLOTY
= 29,
158 FMT_PORTUGUESEESCUDO
= 30,
159 FMT_ROMANIANLEI
= 31,
160 FMT_RUSSIANRUBLE
= 32,
161 FMT_SINGAPOREDOLLAR
= 33,
162 FMT_SLOVAKIANKORUNA
= 34,
163 FMT_SLOVENIANTHOLAR
= 35,
164 FMT_SOUTHAFRICANRAND
= 36,
165 FMT_SOUTHKOREANWON
= 37,
166 FMT_SPANISHPESETA
= 38,
167 FMT_SWEDISHKRONA
= 39,
169 FMT_TAIWANDOLLAR
= 41,
172 FMT_OTHERCURRENCY
= 44,
183 #define RTL_CONSTUTF8_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
184 ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_UTF8
186 class LwpCurrencyPool
189 LwpCurrencyPool(){InitCurrencySymbol();}
190 OUString
GetCurrencySymbol(sal_uInt16 nFormat
);
191 bool IsShowSpace(sal_uInt16 nFormat
);
192 bool IsSymbolPost(sal_uInt16 nFormat
);
195 std::map
<sal_uInt16
,LwpCurrencyInfo
> m_aCurrencyInfo
;
196 void InitCurrencySymbol()
198 sal_uInt16 nC
=FMT_ARGENTINEANPESO
;
199 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("A"); //FMT_ARGENTINEANPESO = 1,
200 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("A$"); //FMT_AUSTRALIANDOLLAR = 2,
201 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("oS",true, true);//FMT_AUSTRIANSCHILLING = 3,
202 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("BF",true, true);//FMT_BELGIANFRANC = 4,
203 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("R$",false, true);//FMT_BRAZILIANCRUZEIRO = 5,
204 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\357\277\241"))); //FMT_BRITISHPOUND = 6,
205 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("C$"); //FMT_CANADIANDOLLAR = 7,
206 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("PRC\357\277\245")),false,true); //FMT_CHINESEYUAN = 8,
207 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Kc",true, true);//FMT_CZECHKORUNA = 9,
208 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Dkr",false, true);//FMT_DANISHKRONE = 10,
209 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("ECU",true, true);//FMT_ECU = 11,
210 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("mk",true, true);//FMT_FINNISHMARKKA = 12,
211 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("F",true, true);//FMT_FRENCHFRANC = 13,
212 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("DM",true, true);//FMT_GERMANMARK = 14,
213 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Dr",true, true);//FMT_GREEKDRACHMA = 15,
214 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("HK$"); //FMT_HONGKONGDOLLAR = 16,
215 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Ft",true, true);//FMT_HUNGARIANFORINT = 17,
216 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Rs",false, true);//FMT_INDIANRUPEE = 18,
217 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Rp",false, true);//FMT_INDONESIANRUPIAH = 19,
218 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("IR\357\277\241"))); //FMT_IRISHPUNT = 20,
219 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("L.",false, true);//FMT_ITALIANLIRA = 21,
220 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\357\277\245"))); //FMT_JAPANESEYEN = 22,
221 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("LF",true, true);//FMT_LUXEMBOURGFRANC = 23,
222 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Rm",false, true);//FMT_MALAYSIANRINGGIT = 24,
223 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Mex$"); //FMT_MEXICANPESO = 25,
224 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("F",false, true);//FMT_NETHERLANDSGUILDER = 26,
225 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("NZ$"); //FMT_NEWZEALANDDOLLAR = 27,
226 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Nkr",false, true);//FMT_NORWEGIANKRONE = 28,
227 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Zl",true, true);//FMT_POLISHZLOTY = 29,
228 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Esc.",true, true);//FMT_PORTUGUESEESCUDO = 30,
229 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Leu",true, true);//FMT_ROMANIANLEI = 31,
230 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("R",true, true);//FMT_RUSSIANRUBLE = 32,
231 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("S$"); //FMT_SINGAPOREDOLLAR = 33,
232 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Sk",true, true);//FMT_SLOVAKIANKORUNA = 34,
233 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("SIT",false, true);//FMT_SLOVENIANTHOLAR = 35,
234 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("R"); //FMT_SOUTHAFRICANRAND = 36,
235 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("W"); //FMT_SOUTHKOREANWON = 37,
236 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Pts",true, true);//FMT_SPANISHPESETA = 38,
237 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Skr",true, true);//FMT_SWEDISHKRONA = 39,
238 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("SFr",false, true);//FMT_SWISSFRANC = 40,
239 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("NT$"); //FMT_TAIWANDOLLAR = 41,
240 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Bt",true, true);//FMT_THAIBAHT = 42,
241 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("$"); //FMT_USDOLLAR = 43,
242 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("OTH",false, true);//FMT_OTHERCURRENCY = 44,
244 m_aCurrencyInfo
[FMT_EURO
]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\342\202\254"))); //FMT_EURO = 52
248 class LwpNumericFormat
251 LwpNumericFormat(LwpObjectStream
* pStrm
);
252 ~LwpNumericFormat(){}
254 static bool IsCurrencyFormat(sal_uInt16 Format
);
255 sal_uInt16
GetDecimalPlaces(void);
256 bool IsDecimalPlacesOverridden(void);
257 bool IsNegativeOverridden(void);
258 bool IsZeroOverridden(void);
262 LwpObjectStream
* m_pObjStrm
;
267 NF_OVER_ZERO
= 0x0001,
268 NF_OVER_NEGATIVE
= 0x0002,
269 NF_OVER_DECIMAL_PLACES
= 0x0004
274 LwpNumericFormatSubset cAnyNumber
;
275 LwpNumericFormatSubset cZero
;
276 LwpNumericFormatSubset cNegative
;
278 sal_uInt16 cDecimalPlaces
;
280 static sal_uInt16
GetDefaultDecimalPlaces(sal_uInt16 Format
);
281 static LwpCurrencyPool m_aCurrencyInfo
;
283 void GetCurrencyStr(LwpNumericFormatSubset aNumber
, OUString
& aPrefix
, OUString
& aSuffix
, bool bNegtive
=false);
284 void SetNumberType(XFNumberStyle
* pStyle
);
285 OUString
reencode(const OUString
& sCode
);
289 LwpNumericFormat::IsDecimalPlacesOverridden(void)
291 return (cFlags
& NF_OVER_DECIMAL_PLACES
) != 0;
295 LwpNumericFormat::IsNegativeOverridden(void)
297 return (cFlags
& NF_OVER_NEGATIVE
) != 0;
301 LwpNumericFormat::IsZeroOverridden(void)
303 return (cFlags
& NF_OVER_ZERO
) != 0;
306 #include "lwppiece.hxx"
307 class LwpLayoutNumerics
: public LwpVirtualPiece
310 LwpLayoutNumerics(LwpObjectHeader
& objHdr
, LwpSvStream
* pStrm
)
311 :LwpVirtualPiece(objHdr
, pStrm
),cNumerics(m_pObjStrm
){}
312 virtual ~LwpLayoutNumerics(){}
314 virtual void Read() SAL_OVERRIDE
;
317 LwpNumericFormat cNumerics
;
322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */