update dev300-m57
[ooovba.git] / lotuswordpro / source / filter / lwpnumericfmt.hxx
bloba2633804ba9315fbf93fc5ecf9aab44c18e710d7
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /**
56 * @file
57 * For LWP filter architecture prototype - table object
59 /*************************************************************************
60 * Change History
61 Mar 2005 Created
62 ************************************************************************/
63 #ifndef _LWPNUMBERICFMT_HXX
64 #define _LWPNUMBERICFMT_HXX
66 #include "lwpatomholder.hxx"
67 #include "lwptblcell.hxx"
68 #include "lwpcolor.hxx"
70 //For converting to xml
71 #include "xfilter/xfnumberstyle.hxx"
73 class LwpObjectStream;
75 class LwpNumericFormatSubset
77 public:
78 LwpNumericFormatSubset();
79 ~LwpNumericFormatSubset();
80 void QuickRead(LwpObjectStream* pStrm);
81 String GetPrefix(){ return cPrefix.str();}
82 String GetSuffix(){ return cSuffix.str();}
83 sal_Bool IsBlack(){ return (cColor.GetBlue()==0 && cColor.GetGreen()==0 && cColor.GetRed()==0);}
84 sal_Bool IsDefaultPrefix(){ return !(cSubFlags&SF_OVER_PREFIX); }
85 sal_Bool IsDefaultSuffix(){ return !(cSubFlags&SF_OVER_SUFFIX); }
86 LwpColor GetColor();
87 protected:
88 LwpColor cColor;
89 LwpAtomHolder cPrefix;
90 LwpAtomHolder cSuffix;
91 sal_uInt16 cSubFlags;
92 enum // for cSubFlags
94 SF_OVER_PREFIX = 0x0001,
95 SF_OVER_SUFFIX = 0x0002,
96 SF_OVER_COLOR = 0x0004
100 struct LwpCurrencyInfo
102 String sSymbol;
103 sal_Bool bPost;
104 sal_Bool bShowSpace;
105 LwpCurrencyInfo(String sSym)
107 sSymbol = sSym;
108 bPost = sal_False;
109 bShowSpace = sal_False;
111 LwpCurrencyInfo()
113 bPost = sal_False;
114 bShowSpace = sal_False;
116 LwpCurrencyInfo(String sSym,sal_Bool bPost, sal_Bool bShowSpace)
118 this->sSymbol = sSym;
119 this->bPost = bPost;
120 this->bShowSpace = bShowSpace;
124 enum
126 /* These are types of formats. They are mutually exclusive.
128 FMT_NONE = 0,
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,
136 FMT_CHINESEYUAN = 8,
137 FMT_CZECHKORUNA = 9,
138 FMT_DANISHKRONE = 10,
139 FMT_ECU = 11,
140 FMT_FINNISHMARKKA = 12,
141 FMT_FRENCHFRANC = 13,
142 FMT_GERMANMARK = 14,
143 FMT_GREEKDRACHMA = 15,
144 FMT_HONGKONGDOLLAR = 16,
145 FMT_HUNGARIANFORINT = 17,
146 FMT_INDIANRUPEE = 18,
147 FMT_INDONESIANRUPIAH = 19,
148 FMT_IRISHPUNT = 20,
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,
168 FMT_SWISSFRANC = 40,
169 FMT_TAIWANDOLLAR = 41,
170 FMT_THAIBAHT = 42,
171 FMT_USDOLLAR = 43,
172 FMT_OTHERCURRENCY = 44,
173 FMT_DEFAULT = 45,
174 FMT_GENERAL = 46,
175 FMT_FIXED = 47,
176 FMT_COMMA = 48,
177 FMT_PERCENT = 49,
178 FMT_SCIENTIFIC = 50,
179 FMT_LABEL = 51,
180 FMT_EURO = 52
183 class LwpCurrencyPool
185 public:
186 LwpCurrencyPool(){InitCurrencySymbol();}
187 String GetCurrencySymbol(sal_uInt16 nFormat);
188 sal_Bool IsShowSpace(sal_uInt16 nFormat);
189 sal_Bool IsSymbolPost(sal_uInt16 nFormat);
190 private:
191 std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
192 void InitCurrencySymbol()
194 USHORT nC=FMT_ARGENTINEANPESO;
195 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("A")); //FMT_ARGENTINEANPESO = 1,
196 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("A$")); //FMT_AUSTRALIANDOLLAR = 2,
197 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("oS"),sal_True, sal_True);//FMT_AUSTRIANSCHILLING = 3,
198 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("BF"),sal_True, sal_True);//FMT_BELGIANFRANC = 4,
199 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("R$"),sal_False, sal_True);//FMT_BRAZILIANCRUZEIRO = 5,
200 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("£",RTL_TEXTENCODING_UTF8)); //FMT_BRITISHPOUND = 6,
201 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("C$")); //FMT_CANADIANDOLLAR = 7,
202 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("PRC¥",RTL_TEXTENCODING_UTF8),sal_False,sal_True); //FMT_CHINESEYUAN = 8,
203 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Kc"),sal_True, sal_True);//FMT_CZECHKORUNA = 9,
204 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Dkr"),sal_False, sal_True);//FMT_DANISHKRONE = 10,
205 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("ECU"),sal_True, sal_True);//FMT_ECU = 11,
206 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("mk"),sal_True, sal_True);//FMT_FINNISHMARKKA = 12,
207 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("F"),sal_True, sal_True);//FMT_FRENCHFRANC = 13,
208 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("DM"),sal_True, sal_True);//FMT_GERMANMARK = 14,
209 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Dr"),sal_True, sal_True);//FMT_GREEKDRACHMA = 15,
210 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("HK$")); //FMT_HONGKONGDOLLAR = 16,
211 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Ft"),sal_True, sal_True);//FMT_HUNGARIANFORINT = 17,
212 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Rs"),sal_False, sal_True);//FMT_INDIANRUPEE = 18,
213 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Rp"),sal_False, sal_True);//FMT_INDONESIANRUPIAH = 19,
214 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("IR£",RTL_TEXTENCODING_UTF8)); //FMT_IRISHPUNT = 20,
215 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("L."),sal_False, sal_True);//FMT_ITALIANLIRA = 21,
216 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("¥",RTL_TEXTENCODING_UTF8)); //FMT_JAPANESEYEN = 22,
217 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("LF"),sal_True, sal_True);//FMT_LUXEMBOURGFRANC = 23,
218 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Rm"),sal_False, sal_True);//FMT_MALAYSIANRINGGIT = 24,
219 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Mex$")); //FMT_MEXICANPESO = 25,
220 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("F"),sal_False, sal_True);//FMT_NETHERLANDSGUILDER = 26,
221 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("NZ$")); //FMT_NEWZEALANDDOLLAR = 27,
222 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Nkr"),sal_False, sal_True);//FMT_NORWEGIANKRONE = 28,
223 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Zl"),sal_True, sal_True);//FMT_POLISHZLOTY = 29,
224 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Esc."),sal_True, sal_True);//FMT_PORTUGUESEESCUDO = 30,
225 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Leu"),sal_True, sal_True);//FMT_ROMANIANLEI = 31,
226 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("R"),sal_True, sal_True);//FMT_RUSSIANRUBLE = 32,
227 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("S$")); //FMT_SINGAPOREDOLLAR = 33,
228 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Sk"),sal_True, sal_True);//FMT_SLOVAKIANKORUNA = 34,
229 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("SIT"),sal_False, sal_True);//FMT_SLOVENIANTHOLAR = 35,
230 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("R")); //FMT_SOUTHAFRICANRAND = 36,
231 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("W")); //FMT_SOUTHKOREANWON = 37,
232 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Pts"),sal_True, sal_True);//FMT_SPANISHPESETA = 38,
233 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Skr"),sal_True, sal_True);//FMT_SWEDISHKRONA = 39,
234 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("SFr"),sal_False, sal_True);//FMT_SWISSFRANC = 40,
235 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("NT$")); //FMT_TAIWANDOLLAR = 41,
236 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("Bt"),sal_True, sal_True);//FMT_THAIBAHT = 42,
237 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("$")); //FMT_USDOLLAR = 43,
238 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String::CreateFromAscii("OTH"),sal_False, sal_True);//FMT_OTHERCURRENCY = 44,
240 m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(String("€",RTL_TEXTENCODING_UTF8)); //FMT_EURO = 52
244 class LwpNumericFormat
246 public:
247 LwpNumericFormat(LwpObjectStream * pStrm);
248 ~LwpNumericFormat(){};
249 void Read();
250 static sal_Bool IsCurrencyFormat(USHORT Format);
251 USHORT GetDecimalPlaces(void);
252 sal_Bool IsDecimalPlacesOverridden(void);
253 sal_Bool IsNegativeOverridden(void);
254 sal_Bool IsZeroOverridden(void);
255 XFStyle* Convert();
256 private:
257 LwpObjectStream * m_pObjStrm;
259 sal_uInt16 cFlags;
260 enum // for cFlags
262 NF_OVER_ZERO = 0x0001,
263 NF_OVER_NEGATIVE = 0x0002,
264 NF_OVER_DECIMAL_PLACES = 0x0004
267 sal_uInt16 cFormat;
269 LwpNumericFormatSubset cAnyNumber;
270 LwpNumericFormatSubset cZero;
271 LwpNumericFormatSubset cNegative;
273 sal_uInt16 cDecimalPlaces;
275 static USHORT GetDefaultDecimalPlaces(USHORT Format);
276 static LwpCurrencyPool m_aCurrencyInfo;
278 void GetCurrencyStr(LwpNumericFormatSubset aNumber, String& aPrefix, String& aSuffix, sal_Bool bNegtive=sal_False);
279 void SetNumberType(XFNumberStyle* pStyle);
280 OUString reencode(OUString sCode);
283 inline sal_Bool
284 LwpNumericFormat::IsDecimalPlacesOverridden(void)
286 return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
288 inline sal_Bool
289 LwpNumericFormat::IsNegativeOverridden(void)
291 return (cFlags & NF_OVER_NEGATIVE) != 0;
293 inline sal_Bool
294 LwpNumericFormat::IsZeroOverridden(void)
296 return (cFlags & NF_OVER_ZERO) != 0;
299 #include "lwppiece.hxx"
300 class LwpLayoutNumerics : public LwpVirtualPiece
302 public:
303 LwpLayoutNumerics(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
304 :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm){};
305 ~LwpLayoutNumerics(){};
306 XFStyle* Convert();
307 virtual void Read();
308 protected:
309 LwpNumericFormat cNumerics;
312 #endif