Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
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
16 : *
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.
20 : *
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.
25 : *
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,
29 : * MA 02111-1307 USA
30 : *
31 : *
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.
38 : *
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.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /**
57 : * @file
58 : * For LWP filter architecture prototype - table object
59 : */
60 : /*************************************************************************
61 : * Change History
62 : Mar 2005 Created
63 : ************************************************************************/
64 : #ifndef _LWPNUMBERICFMT_HXX
65 : #define _LWPNUMBERICFMT_HXX
66 :
67 : #include "lwpatomholder.hxx"
68 : #include "lwptblcell.hxx"
69 : #include "lwpcolor.hxx"
70 :
71 : //For converting to xml
72 : #include "xfilter/xfnumberstyle.hxx"
73 :
74 : class LwpObjectStream;
75 :
76 0 : class LwpNumericFormatSubset
77 : {
78 : public:
79 : LwpNumericFormatSubset();
80 : ~LwpNumericFormatSubset();
81 : void QuickRead(LwpObjectStream* pStrm);
82 27 : String GetPrefix(){ return cPrefix.str();}
83 27 : String GetSuffix(){ return cSuffix.str();}
84 : sal_Bool IsBlack(){ return (cColor.GetBlue()==0 && cColor.GetGreen()==0 && cColor.GetRed()==0);}
85 0 : sal_Bool IsDefaultPrefix(){ return !(cSubFlags&SF_OVER_PREFIX); }
86 0 : sal_Bool IsDefaultSuffix(){ return !(cSubFlags&SF_OVER_SUFFIX); }
87 : LwpColor GetColor();
88 : protected:
89 : LwpColor cColor;
90 : LwpAtomHolder cPrefix;
91 : LwpAtomHolder cSuffix;
92 : sal_uInt16 cSubFlags;
93 : enum // for cSubFlags
94 : {
95 : SF_OVER_PREFIX = 0x0001,
96 : SF_OVER_SUFFIX = 0x0002,
97 : SF_OVER_COLOR = 0x0004
98 : };
99 : };
100 :
101 315 : struct LwpCurrencyInfo
102 : {
103 : String sSymbol;
104 : sal_Bool bPost;
105 : sal_Bool bShowSpace;
106 15 : LwpCurrencyInfo(String sSym)
107 15 : {
108 15 : sSymbol = sSym;
109 15 : bPost = sal_False;
110 15 : bShowSpace = sal_False;
111 15 : }
112 45 : LwpCurrencyInfo()
113 45 : {
114 45 : bPost = sal_False;
115 45 : bShowSpace = sal_False;
116 45 : }
117 30 : LwpCurrencyInfo(String sSym,sal_Bool bPost_, sal_Bool bShowSpace_)
118 30 : {
119 30 : sSymbol = sSym;
120 30 : bPost = bPost_;
121 30 : bShowSpace = bShowSpace_;
122 30 : }
123 : };
124 :
125 : enum
126 : {
127 : /* These are types of formats. They are mutually exclusive.
128 : */
129 : FMT_NONE = 0,
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,
137 : FMT_CHINESEYUAN = 8,
138 : FMT_CZECHKORUNA = 9,
139 : FMT_DANISHKRONE = 10,
140 : FMT_ECU = 11,
141 : FMT_FINNISHMARKKA = 12,
142 : FMT_FRENCHFRANC = 13,
143 : FMT_GERMANMARK = 14,
144 : FMT_GREEKDRACHMA = 15,
145 : FMT_HONGKONGDOLLAR = 16,
146 : FMT_HUNGARIANFORINT = 17,
147 : FMT_INDIANRUPEE = 18,
148 : FMT_INDONESIANRUPIAH = 19,
149 : FMT_IRISHPUNT = 20,
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,
169 : FMT_SWISSFRANC = 40,
170 : FMT_TAIWANDOLLAR = 41,
171 : FMT_THAIBAHT = 42,
172 : FMT_USDOLLAR = 43,
173 : FMT_OTHERCURRENCY = 44,
174 : FMT_DEFAULT = 45,
175 : FMT_GENERAL = 46,
176 : FMT_FIXED = 47,
177 : FMT_COMMA = 48,
178 : FMT_PERCENT = 49,
179 : FMT_SCIENTIFIC = 50,
180 : FMT_LABEL = 51,
181 : FMT_EURO = 52
182 : };
183 :
184 1 : class LwpCurrencyPool
185 : {
186 : public:
187 1 : LwpCurrencyPool(){InitCurrencySymbol();}
188 : String GetCurrencySymbol(sal_uInt16 nFormat);
189 : sal_Bool IsShowSpace(sal_uInt16 nFormat);
190 : sal_Bool IsSymbolPost(sal_uInt16 nFormat);
191 : private:
192 : std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
193 1 : void InitCurrencySymbol()
194 : {
195 1 : sal_uInt16 nC=FMT_ARGENTINEANPESO;
196 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("A")); //FMT_ARGENTINEANPESO = 1,
197 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("A$")); //FMT_AUSTRALIANDOLLAR = 2,
198 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("oS"),sal_True, sal_True);//FMT_AUSTRIANSCHILLING = 3,
199 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("BF"),sal_True, sal_True);//FMT_BELGIANFRANC = 4,
200 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("R$"),sal_False, sal_True);//FMT_BRAZILIANCRUZEIRO = 5,
201 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("£",RTL_TEXTENCODING_UTF8)); //FMT_BRITISHPOUND = 6,
202 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("C$")); //FMT_CANADIANDOLLAR = 7,
203 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("PRC¥",RTL_TEXTENCODING_UTF8),sal_False,sal_True); //FMT_CHINESEYUAN = 8,
204 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Kc"),sal_True, sal_True);//FMT_CZECHKORUNA = 9,
205 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Dkr"),sal_False, sal_True);//FMT_DANISHKRONE = 10,
206 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("ECU"),sal_True, sal_True);//FMT_ECU = 11,
207 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("mk"),sal_True, sal_True);//FMT_FINNISHMARKKA = 12,
208 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("F"),sal_True, sal_True);//FMT_FRENCHFRANC = 13,
209 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("DM"),sal_True, sal_True);//FMT_GERMANMARK = 14,
210 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Dr"),sal_True, sal_True);//FMT_GREEKDRACHMA = 15,
211 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("HK$")); //FMT_HONGKONGDOLLAR = 16,
212 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Ft"),sal_True, sal_True);//FMT_HUNGARIANFORINT = 17,
213 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Rs"),sal_False, sal_True);//FMT_INDIANRUPEE = 18,
214 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Rp"),sal_False, sal_True);//FMT_INDONESIANRUPIAH = 19,
215 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("IR£",RTL_TEXTENCODING_UTF8)); //FMT_IRISHPUNT = 20,
216 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("L."),sal_False, sal_True);//FMT_ITALIANLIRA = 21,
217 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(String("¥",RTL_TEXTENCODING_UTF8)); //FMT_JAPANESEYEN = 22,
218 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("LF"),sal_True, sal_True);//FMT_LUXEMBOURGFRANC = 23,
219 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Rm"),sal_False, sal_True);//FMT_MALAYSIANRINGGIT = 24,
220 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Mex$")); //FMT_MEXICANPESO = 25,
221 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("F"),sal_False, sal_True);//FMT_NETHERLANDSGUILDER = 26,
222 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("NZ$")); //FMT_NEWZEALANDDOLLAR = 27,
223 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Nkr"),sal_False, sal_True);//FMT_NORWEGIANKRONE = 28,
224 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Zl"),sal_True, sal_True);//FMT_POLISHZLOTY = 29,
225 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Esc."),sal_True, sal_True);//FMT_PORTUGUESEESCUDO = 30,
226 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Leu"),sal_True, sal_True);//FMT_ROMANIANLEI = 31,
227 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("R"),sal_True, sal_True);//FMT_RUSSIANRUBLE = 32,
228 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("S$")); //FMT_SINGAPOREDOLLAR = 33,
229 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Sk"),sal_True, sal_True);//FMT_SLOVAKIANKORUNA = 34,
230 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("SIT"),sal_False, sal_True);//FMT_SLOVENIANTHOLAR = 35,
231 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("R")); //FMT_SOUTHAFRICANRAND = 36,
232 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("W")); //FMT_SOUTHKOREANWON = 37,
233 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Pts"),sal_True, sal_True);//FMT_SPANISHPESETA = 38,
234 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Skr"),sal_True, sal_True);//FMT_SWEDISHKRONA = 39,
235 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("SFr"),sal_False, sal_True);//FMT_SWISSFRANC = 40,
236 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("NT$")); //FMT_TAIWANDOLLAR = 41,
237 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("Bt"),sal_True, sal_True);//FMT_THAIBAHT = 42,
238 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("$")); //FMT_USDOLLAR = 43,
239 1 : m_aCurrencyInfo[nC++]=LwpCurrencyInfo(rtl::OUString("OTH"),sal_False, sal_True);//FMT_OTHERCURRENCY = 44,
240 :
241 1 : m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(String("€",RTL_TEXTENCODING_UTF8)); //FMT_EURO = 52
242 1 : }
243 : };
244 :
245 : class LwpNumericFormat
246 : {
247 : public:
248 : LwpNumericFormat(LwpObjectStream * pStrm);
249 6 : ~LwpNumericFormat(){}
250 : void Read();
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);
256 : XFStyle* Convert();
257 : private:
258 : LwpObjectStream * m_pObjStrm;
259 :
260 : sal_uInt16 cFlags;
261 : enum // for cFlags
262 : {
263 : NF_OVER_ZERO = 0x0001,
264 : NF_OVER_NEGATIVE = 0x0002,
265 : NF_OVER_DECIMAL_PLACES = 0x0004
266 : };
267 :
268 : sal_uInt16 cFormat;
269 :
270 : LwpNumericFormatSubset cAnyNumber;
271 : LwpNumericFormatSubset cZero;
272 : LwpNumericFormatSubset cNegative;
273 :
274 : sal_uInt16 cDecimalPlaces;
275 :
276 : static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
277 : static LwpCurrencyPool m_aCurrencyInfo;
278 :
279 : void GetCurrencyStr(LwpNumericFormatSubset aNumber, String& aPrefix, String& aSuffix, sal_Bool bNegtive=sal_False);
280 : void SetNumberType(XFNumberStyle* pStyle);
281 : OUString reencode(OUString sCode);
282 : };
283 :
284 : inline sal_Bool
285 27 : LwpNumericFormat::IsDecimalPlacesOverridden(void)
286 : {
287 27 : return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
288 : }
289 : inline sal_Bool
290 27 : LwpNumericFormat::IsNegativeOverridden(void)
291 : {
292 27 : return (cFlags & NF_OVER_NEGATIVE) != 0;
293 : }
294 : inline sal_Bool
295 : LwpNumericFormat::IsZeroOverridden(void)
296 : {
297 : return (cFlags & NF_OVER_ZERO) != 0;
298 : }
299 :
300 : #include "lwppiece.hxx"
301 : class LwpLayoutNumerics : public LwpVirtualPiece
302 : {
303 : public:
304 6 : LwpLayoutNumerics(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
305 6 : :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm){}
306 12 : ~LwpLayoutNumerics(){}
307 : XFStyle* Convert();
308 : virtual void Read();
309 : protected:
310 : LwpNumericFormat cNumerics;
311 : };
312 :
313 : #endif
314 :
315 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|