fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / lotuswordpro / source / filter / lwpnumericfmt.hxx
blobc4881f7ba066e6c854d7a8db54057ebcf86c4ce2
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,
29 * MA 02111-1307 USA
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 ************************************************************************/
56 /**
57 * @file
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
75 public:
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); }
84 LwpColor GetColor();
86 protected:
87 LwpColor cColor;
88 LwpAtomHolder cPrefix;
89 LwpAtomHolder cSuffix;
90 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 OUString sSymbol;
103 bool bPost;
104 bool bShowSpace;
105 LwpCurrencyInfo(const OUString& sSym)
107 sSymbol = sSym;
108 bPost = false;
109 bShowSpace = false;
111 LwpCurrencyInfo()
113 bPost = false;
114 bShowSpace = false;
116 LwpCurrencyInfo(const OUString& sSym, bool bPost_, bool bShowSpace_)
118 sSymbol = sSym;
119 bPost = bPost_;
120 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 #define RTL_CONSTUTF8_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
184 ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_UTF8
186 class LwpCurrencyPool
188 public:
189 LwpCurrencyPool(){InitCurrencySymbol();}
190 OUString GetCurrencySymbol(sal_uInt16 nFormat);
191 bool IsShowSpace(sal_uInt16 nFormat);
192 bool IsSymbolPost(sal_uInt16 nFormat);
194 private:
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
250 public:
251 LwpNumericFormat(LwpObjectStream * pStrm);
252 ~LwpNumericFormat(){}
253 void Read();
254 static bool IsCurrencyFormat(sal_uInt16 Format);
255 sal_uInt16 GetDecimalPlaces();
256 bool IsDecimalPlacesOverridden();
257 bool IsNegativeOverridden();
258 bool IsZeroOverridden();
259 XFStyle* Convert();
261 private:
262 LwpObjectStream * m_pObjStrm;
264 sal_uInt16 cFlags;
265 enum // for cFlags
267 NF_OVER_ZERO = 0x0001,
268 NF_OVER_NEGATIVE = 0x0002,
269 NF_OVER_DECIMAL_PLACES = 0x0004
272 sal_uInt16 cFormat;
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 static OUString reencode(const OUString& sCode);
288 inline bool
289 LwpNumericFormat::IsDecimalPlacesOverridden()
291 return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
294 inline bool
295 LwpNumericFormat::IsNegativeOverridden()
297 return (cFlags & NF_OVER_NEGATIVE) != 0;
300 inline bool
301 LwpNumericFormat::IsZeroOverridden()
303 return (cFlags & NF_OVER_ZERO) != 0;
306 #include "lwppiece.hxx"
307 class LwpLayoutNumerics : public LwpVirtualPiece
309 public:
310 LwpLayoutNumerics(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
311 :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm){}
312 XFStyle* Convert();
313 virtual void Read() SAL_OVERRIDE;
315 protected:
316 LwpNumericFormat cNumerics;
318 private:
319 virtual ~LwpLayoutNumerics(){}
322 #endif
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */