android: Update app-specific/MIME type icons
[LibreOffice.git] / lotuswordpro / source / filter / lwpnumericfmt.hxx
blobcc3b8f5d0ee2903ebe7f1dfdda61530ebe7e04dc
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 <map>
66 #include <lwpatomholder.hxx>
67 #include <lwpcolor.hxx>
68 #include "lwppiece.hxx"
70 //For converting to xml
71 #include <utility>
72 #include <xfilter/xfnumberstyle.hxx>
74 class LwpObjectStream;
76 class LwpNumericFormatSubset final
78 public:
79 LwpNumericFormatSubset();
80 void QuickRead(LwpObjectStream* pStrm);
81 OUString const & GetPrefix() const { return cPrefix.str();}
82 OUString const & GetSuffix() const { return cSuffix.str();}
83 bool IsDefaultPrefix() const { return !(cSubFlags&SF_OVER_PREFIX); }
84 bool IsDefaultSuffix() const { return !(cSubFlags&SF_OVER_SUFFIX); }
85 LwpColor GetColor() const;
87 private:
88 LwpColor cColor;
89 LwpAtomHolder cPrefix;
90 LwpAtomHolder cSuffix;
91 sal_uInt16 cSubFlags;
93 enum // for cSubFlags
95 SF_OVER_PREFIX = 0x0001,
96 SF_OVER_SUFFIX = 0x0002,
97 SF_OVER_COLOR = 0x0004
101 struct LwpCurrencyInfo
103 OUString sSymbol;
104 bool bPost;
105 bool bShowSpace;
106 explicit LwpCurrencyInfo(OUString sSym)
107 : sSymbol(std::move(sSym)), bPost(false), bShowSpace(false)
110 LwpCurrencyInfo() : bPost(false), bShowSpace(false)
113 LwpCurrencyInfo(OUString sSym, bool bPost_, bool bShowSpace_)
114 : sSymbol(std::move(sSym)), bPost(bPost_), bShowSpace(bShowSpace_)
119 enum
121 /* These are types of formats. They are mutually exclusive.
123 FMT_NONE = 0,
124 FMT_ARGENTINEANPESO = 1,
125 FMT_AUSTRALIANDOLLAR = 2,
126 FMT_AUSTRIANSCHILLING = 3,
127 FMT_BELGIANFRANC = 4,
128 FMT_BRAZILIANCRUZEIRO = 5,
129 FMT_BRITISHPOUND = 6,
130 FMT_CANADIANDOLLAR = 7,
131 FMT_CHINESEYUAN = 8,
132 FMT_CZECHKORUNA = 9,
133 FMT_DANISHKRONE = 10,
134 FMT_ECU = 11,
135 FMT_FINNISHMARKKA = 12,
136 FMT_FRENCHFRANC = 13,
137 FMT_GERMANMARK = 14,
138 FMT_GREEKDRACHMA = 15,
139 FMT_HONGKONGDOLLAR = 16,
140 FMT_HUNGARIANFORINT = 17,
141 FMT_INDIANRUPEE = 18,
142 FMT_INDONESIANRUPIAH = 19,
143 FMT_IRISHPUNT = 20,
144 FMT_ITALIANLIRA = 21,
145 FMT_JAPANESEYEN = 22,
146 FMT_LUXEMBOURGFRANC = 23,
147 FMT_MALAYSIANRINGGIT = 24,
148 FMT_MEXICANPESO = 25,
149 FMT_NETHERLANDSGUILDER = 26,
150 FMT_NEWZEALANDDOLLAR = 27,
151 FMT_NORWEGIANKRONE = 28,
152 FMT_POLISHZLOTY = 29,
153 FMT_PORTUGUESEESCUDO = 30,
154 FMT_ROMANIANLEI = 31,
155 FMT_RUSSIANRUBLE = 32,
156 FMT_SINGAPOREDOLLAR = 33,
157 FMT_SLOVAKIANKORUNA = 34,
158 FMT_SLOVENIANTHOLAR = 35,
159 FMT_SOUTHAFRICANRAND = 36,
160 FMT_SOUTHKOREANWON = 37,
161 FMT_SPANISHPESETA = 38,
162 FMT_SWEDISHKRONA = 39,
163 FMT_SWISSFRANC = 40,
164 FMT_TAIWANDOLLAR = 41,
165 FMT_THAIBAHT = 42,
166 FMT_USDOLLAR = 43,
167 FMT_OTHERCURRENCY = 44,
168 FMT_DEFAULT = 45,
169 FMT_GENERAL = 46,
170 FMT_FIXED = 47,
171 FMT_COMMA = 48,
172 FMT_PERCENT = 49,
173 FMT_SCIENTIFIC = 50,
174 FMT_LABEL = 51,
175 FMT_EURO = 52
178 class LwpCurrencyPool
180 public:
181 LwpCurrencyPool(){InitCurrencySymbol();}
182 OUString GetCurrencySymbol(sal_uInt16 nFormat);
183 bool IsShowSpace(sal_uInt16 nFormat);
184 bool IsSymbolPost(sal_uInt16 nFormat);
186 private:
187 std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
188 void InitCurrencySymbol()
190 sal_uInt16 nC=FMT_ARGENTINEANPESO;
191 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A"); //FMT_ARGENTINEANPESO = 1,
192 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A$"); //FMT_AUSTRALIANDOLLAR = 2,
193 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("oS",true, true);//FMT_AUSTRIANSCHILLING = 3,
194 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("BF",true, true);//FMT_BELGIANFRANC = 4,
195 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R$",false, true);//FMT_BRAZILIANCRUZEIRO = 5,
196 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"\uFFE1")); //FMT_BRITISHPOUND = 6,
197 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("C$"); //FMT_CANADIANDOLLAR = 7,
198 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"PRC\uFFE5"),false,true); //FMT_CHINESEYUAN = 8,
199 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Kc",true, true);//FMT_CZECHKORUNA = 9,
200 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dkr",false, true);//FMT_DANISHKRONE = 10,
201 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("ECU",true, true);//FMT_ECU = 11,
202 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("mk",true, true);//FMT_FINNISHMARKKA = 12,
203 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",true, true);//FMT_FRENCHFRANC = 13,
204 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("DM",true, true);//FMT_GERMANMARK = 14,
205 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dr",true, true);//FMT_GREEKDRACHMA = 15,
206 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("HK$"); //FMT_HONGKONGDOLLAR = 16,
207 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Ft",true, true);//FMT_HUNGARIANFORINT = 17,
208 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rs",false, true);//FMT_INDIANRUPEE = 18,
209 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rp",false, true);//FMT_INDONESIANRUPIAH = 19,
210 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"IR\uFFE1")); //FMT_IRISHPUNT = 20,
211 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("L.",false, true);//FMT_ITALIANLIRA = 21,
212 m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"\uFFE5")); //FMT_JAPANESEYEN = 22,
213 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("LF",true, true);//FMT_LUXEMBOURGFRANC = 23,
214 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rm",false, true);//FMT_MALAYSIANRINGGIT = 24,
215 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Mex$"); //FMT_MEXICANPESO = 25,
216 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",false, true);//FMT_NETHERLANDSGUILDER = 26,
217 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NZ$"); //FMT_NEWZEALANDDOLLAR = 27,
218 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Nkr",false, true);//FMT_NORWEGIANKRONE = 28,
219 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Zl",true, true);//FMT_POLISHZLOTY = 29,
220 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Esc.",true, true);//FMT_PORTUGUESEESCUDO = 30,
221 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Leu",true, true);//FMT_ROMANIANLEI = 31,
222 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R",true, true);//FMT_RUSSIANRUBLE = 32,
223 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("S$"); //FMT_SINGAPOREDOLLAR = 33,
224 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Sk",true, true);//FMT_SLOVAKIANKORUNA = 34,
225 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SIT",false, true);//FMT_SLOVENIANTHOLAR = 35,
226 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R"); //FMT_SOUTHAFRICANRAND = 36,
227 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("W"); //FMT_SOUTHKOREANWON = 37,
228 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Pts",true, true);//FMT_SPANISHPESETA = 38,
229 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Skr",true, true);//FMT_SWEDISHKRONA = 39,
230 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SFr",false, true);//FMT_SWISSFRANC = 40,
231 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NT$"); //FMT_TAIWANDOLLAR = 41,
232 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Bt",true, true);//FMT_THAIBAHT = 42,
233 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("$"); //FMT_USDOLLAR = 43,
234 m_aCurrencyInfo[nC++]=LwpCurrencyInfo("OTH",false, true);//FMT_OTHERCURRENCY = 44,
236 m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(OUString(u"\u20AC")); //FMT_EURO = 52
240 class LwpNumericFormat
242 public:
243 explicit LwpNumericFormat(LwpObjectStream * pStrm);
244 void Read();
245 static bool IsCurrencyFormat(sal_uInt16 Format);
246 sal_uInt16 GetDecimalPlaces();
247 bool IsDecimalPlacesOverridden() const;
248 bool IsNegativeOverridden() const;
249 XFStyle* Convert();
251 private:
252 LwpObjectStream * m_pObjStrm;
254 sal_uInt16 cFlags;
255 enum // for cFlags
257 NF_OVER_ZERO = 0x0001,
258 NF_OVER_NEGATIVE = 0x0002,
259 NF_OVER_DECIMAL_PLACES = 0x0004
262 sal_uInt16 cFormat;
264 LwpNumericFormatSubset cAnyNumber;
265 LwpNumericFormatSubset cZero;
266 LwpNumericFormatSubset cNegative;
268 sal_uInt16 cDecimalPlaces;
270 static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
271 static LwpCurrencyPool m_aCurrencyInfo;
273 void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegative=false);
274 void SetNumberType(XFNumberStyle* pStyle);
275 static OUString reencode(const OUString& sCode);
278 inline bool
279 LwpNumericFormat::IsDecimalPlacesOverridden() const
281 return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
284 inline bool
285 LwpNumericFormat::IsNegativeOverridden() const
287 return (cFlags & NF_OVER_NEGATIVE) != 0;
290 class LwpLayoutNumerics final : public LwpVirtualPiece
292 public:
293 LwpLayoutNumerics(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
294 :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm.get()){}
295 XFStyle* Convert();
296 virtual void Read() override;
298 private:
299 virtual ~LwpLayoutNumerics() override {}
301 LwpNumericFormat cNumerics;
304 #endif
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */