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 IsDefaultPrefix(){ return !(cSubFlags
&SF_OVER_PREFIX
); }
82 bool IsDefaultSuffix(){ return !(cSubFlags
&SF_OVER_SUFFIX
); }
87 LwpAtomHolder cPrefix
;
88 LwpAtomHolder cSuffix
;
93 SF_OVER_PREFIX
= 0x0001,
94 SF_OVER_SUFFIX
= 0x0002,
95 SF_OVER_COLOR
= 0x0004
99 struct LwpCurrencyInfo
104 explicit LwpCurrencyInfo(const OUString
& sSym
)
115 LwpCurrencyInfo(const OUString
& sSym
, bool bPost_
, bool bShowSpace_
)
119 bShowSpace
= bShowSpace_
;
125 /* These are types of formats. They are mutually exclusive.
128 FMT_ARGENTINEANPESO
= 1,
129 FMT_AUSTRALIANDOLLAR
= 2,
130 FMT_AUSTRIANSCHILLING
= 3,
131 FMT_BELGIANFRANC
= 4,
132 FMT_BRAZILIANCRUZEIRO
= 5,
133 FMT_BRITISHPOUND
= 6,
134 FMT_CANADIANDOLLAR
= 7,
137 FMT_DANISHKRONE
= 10,
139 FMT_FINNISHMARKKA
= 12,
140 FMT_FRENCHFRANC
= 13,
142 FMT_GREEKDRACHMA
= 15,
143 FMT_HONGKONGDOLLAR
= 16,
144 FMT_HUNGARIANFORINT
= 17,
145 FMT_INDIANRUPEE
= 18,
146 FMT_INDONESIANRUPIAH
= 19,
148 FMT_ITALIANLIRA
= 21,
149 FMT_JAPANESEYEN
= 22,
150 FMT_LUXEMBOURGFRANC
= 23,
151 FMT_MALAYSIANRINGGIT
= 24,
152 FMT_MEXICANPESO
= 25,
153 FMT_NETHERLANDSGUILDER
= 26,
154 FMT_NEWZEALANDDOLLAR
= 27,
155 FMT_NORWEGIANKRONE
= 28,
156 FMT_POLISHZLOTY
= 29,
157 FMT_PORTUGUESEESCUDO
= 30,
158 FMT_ROMANIANLEI
= 31,
159 FMT_RUSSIANRUBLE
= 32,
160 FMT_SINGAPOREDOLLAR
= 33,
161 FMT_SLOVAKIANKORUNA
= 34,
162 FMT_SLOVENIANTHOLAR
= 35,
163 FMT_SOUTHAFRICANRAND
= 36,
164 FMT_SOUTHKOREANWON
= 37,
165 FMT_SPANISHPESETA
= 38,
166 FMT_SWEDISHKRONA
= 39,
168 FMT_TAIWANDOLLAR
= 41,
171 FMT_OTHERCURRENCY
= 44,
182 #define RTL_CONSTUTF8_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
183 ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_UTF8
185 class LwpCurrencyPool
188 LwpCurrencyPool(){InitCurrencySymbol();}
189 OUString
GetCurrencySymbol(sal_uInt16 nFormat
);
190 bool IsShowSpace(sal_uInt16 nFormat
);
191 bool IsSymbolPost(sal_uInt16 nFormat
);
194 std::map
<sal_uInt16
,LwpCurrencyInfo
> m_aCurrencyInfo
;
195 void InitCurrencySymbol()
197 sal_uInt16 nC
=FMT_ARGENTINEANPESO
;
198 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("A"); //FMT_ARGENTINEANPESO = 1,
199 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("A$"); //FMT_AUSTRALIANDOLLAR = 2,
200 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("oS",true, true);//FMT_AUSTRIANSCHILLING = 3,
201 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("BF",true, true);//FMT_BELGIANFRANC = 4,
202 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("R$",false, true);//FMT_BRAZILIANCRUZEIRO = 5,
203 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\357\277\241"))); //FMT_BRITISHPOUND = 6,
204 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("C$"); //FMT_CANADIANDOLLAR = 7,
205 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("PRC\357\277\245")),false,true); //FMT_CHINESEYUAN = 8,
206 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Kc",true, true);//FMT_CZECHKORUNA = 9,
207 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Dkr",false, true);//FMT_DANISHKRONE = 10,
208 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("ECU",true, true);//FMT_ECU = 11,
209 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("mk",true, true);//FMT_FINNISHMARKKA = 12,
210 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("F",true, true);//FMT_FRENCHFRANC = 13,
211 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("DM",true, true);//FMT_GERMANMARK = 14,
212 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Dr",true, true);//FMT_GREEKDRACHMA = 15,
213 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("HK$"); //FMT_HONGKONGDOLLAR = 16,
214 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Ft",true, true);//FMT_HUNGARIANFORINT = 17,
215 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Rs",false, true);//FMT_INDIANRUPEE = 18,
216 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Rp",false, true);//FMT_INDONESIANRUPIAH = 19,
217 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("IR\357\277\241"))); //FMT_IRISHPUNT = 20,
218 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("L.",false, true);//FMT_ITALIANLIRA = 21,
219 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\357\277\245"))); //FMT_JAPANESEYEN = 22,
220 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("LF",true, true);//FMT_LUXEMBOURGFRANC = 23,
221 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Rm",false, true);//FMT_MALAYSIANRINGGIT = 24,
222 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Mex$"); //FMT_MEXICANPESO = 25,
223 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("F",false, true);//FMT_NETHERLANDSGUILDER = 26,
224 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("NZ$"); //FMT_NEWZEALANDDOLLAR = 27,
225 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Nkr",false, true);//FMT_NORWEGIANKRONE = 28,
226 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Zl",true, true);//FMT_POLISHZLOTY = 29,
227 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Esc.",true, true);//FMT_PORTUGUESEESCUDO = 30,
228 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Leu",true, true);//FMT_ROMANIANLEI = 31,
229 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("R",true, true);//FMT_RUSSIANRUBLE = 32,
230 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("S$"); //FMT_SINGAPOREDOLLAR = 33,
231 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Sk",true, true);//FMT_SLOVAKIANKORUNA = 34,
232 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("SIT",false, true);//FMT_SLOVENIANTHOLAR = 35,
233 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("R"); //FMT_SOUTHAFRICANRAND = 36,
234 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("W"); //FMT_SOUTHKOREANWON = 37,
235 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Pts",true, true);//FMT_SPANISHPESETA = 38,
236 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Skr",true, true);//FMT_SWEDISHKRONA = 39,
237 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("SFr",false, true);//FMT_SWISSFRANC = 40,
238 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("NT$"); //FMT_TAIWANDOLLAR = 41,
239 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("Bt",true, true);//FMT_THAIBAHT = 42,
240 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("$"); //FMT_USDOLLAR = 43,
241 m_aCurrencyInfo
[nC
++]=LwpCurrencyInfo("OTH",false, true);//FMT_OTHERCURRENCY = 44,
243 m_aCurrencyInfo
[FMT_EURO
]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\342\202\254"))); //FMT_EURO = 52
247 class LwpNumericFormat
250 explicit LwpNumericFormat(LwpObjectStream
* pStrm
);
251 ~LwpNumericFormat(){}
253 static bool IsCurrencyFormat(sal_uInt16 Format
);
254 sal_uInt16
GetDecimalPlaces();
255 bool IsDecimalPlacesOverridden();
256 bool IsNegativeOverridden();
260 LwpObjectStream
* m_pObjStrm
;
265 NF_OVER_ZERO
= 0x0001,
266 NF_OVER_NEGATIVE
= 0x0002,
267 NF_OVER_DECIMAL_PLACES
= 0x0004
272 LwpNumericFormatSubset cAnyNumber
;
273 LwpNumericFormatSubset cZero
;
274 LwpNumericFormatSubset cNegative
;
276 sal_uInt16 cDecimalPlaces
;
278 static sal_uInt16
GetDefaultDecimalPlaces(sal_uInt16 Format
);
279 static LwpCurrencyPool m_aCurrencyInfo
;
281 void GetCurrencyStr(LwpNumericFormatSubset aNumber
, OUString
& aPrefix
, OUString
& aSuffix
, bool bNegtive
=false);
282 void SetNumberType(XFNumberStyle
* pStyle
);
283 static OUString
reencode(const OUString
& sCode
);
287 LwpNumericFormat::IsDecimalPlacesOverridden()
289 return (cFlags
& NF_OVER_DECIMAL_PLACES
) != 0;
293 LwpNumericFormat::IsNegativeOverridden()
295 return (cFlags
& NF_OVER_NEGATIVE
) != 0;
298 #include "lwppiece.hxx"
299 class LwpLayoutNumerics
: public LwpVirtualPiece
302 LwpLayoutNumerics(LwpObjectHeader
& objHdr
, LwpSvStream
* pStrm
)
303 :LwpVirtualPiece(objHdr
, pStrm
),cNumerics(m_pObjStrm
){}
305 virtual void Read() override
;
308 LwpNumericFormat cNumerics
;
311 virtual ~LwpLayoutNumerics(){}
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */