tdf#163948: fix crash when NotesPane is enabled on Tabbed UI
[LibreOffice.git] / lotuswordpro / source / filter / lwpnumericfmt.hxx
blob38490303b967e2db5b231b1867ab6607b27dc27b
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(){};
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
189 { FMT_ARGENTINEANPESO, LwpCurrencyInfo(u"A"_ustr) },
190 { FMT_AUSTRALIANDOLLAR, LwpCurrencyInfo(u"A$"_ustr) },
191 { FMT_AUSTRIANSCHILLING, LwpCurrencyInfo(u"oS"_ustr,true, true) },
192 { FMT_BELGIANFRANC, LwpCurrencyInfo(u"BF"_ustr,true, true) },
193 { FMT_BRAZILIANCRUZEIRO, LwpCurrencyInfo(u"R$"_ustr,false, true) },
194 { FMT_BRITISHPOUND, LwpCurrencyInfo(u"\uFFE1"_ustr) },
195 { FMT_CANADIANDOLLAR, LwpCurrencyInfo(u"C$"_ustr) },
196 { FMT_CHINESEYUAN, LwpCurrencyInfo(u"PRC\uFFE5"_ustr,false,true) },
197 { FMT_CZECHKORUNA, LwpCurrencyInfo(u"Kc"_ustr,true, true) },
198 { FMT_DANISHKRONE, LwpCurrencyInfo(u"Dkr"_ustr,false, true) },
199 { FMT_ECU, LwpCurrencyInfo(u"ECU"_ustr,true, true) },
200 { FMT_FINNISHMARKKA, LwpCurrencyInfo(u"mk"_ustr,true, true) },
201 { FMT_FRENCHFRANC, LwpCurrencyInfo(u"F"_ustr,true, true) },
202 { FMT_GERMANMARK, LwpCurrencyInfo(u"DM"_ustr,true, true) },
203 { FMT_GREEKDRACHMA, LwpCurrencyInfo(u"Dr"_ustr,true, true) },
204 { FMT_HONGKONGDOLLAR, LwpCurrencyInfo(u"HK$"_ustr) },
205 { FMT_HUNGARIANFORINT, LwpCurrencyInfo(u"Ft"_ustr,true, true) },
206 { FMT_INDIANRUPEE, LwpCurrencyInfo(u"Rs"_ustr,false, true) },
207 { FMT_INDONESIANRUPIAH, LwpCurrencyInfo(u"Rp"_ustr,false, true) },
208 { FMT_IRISHPUNT, LwpCurrencyInfo(u"IR\uFFE1"_ustr) },
209 { FMT_ITALIANLIRA, LwpCurrencyInfo(u"L."_ustr,false, true) },
210 { FMT_JAPANESEYEN, LwpCurrencyInfo(u"\uFFE5"_ustr) },
211 { FMT_LUXEMBOURGFRANC, LwpCurrencyInfo(u"LF"_ustr,true, true) },
212 { FMT_MALAYSIANRINGGIT, LwpCurrencyInfo(u"Rm"_ustr,false, true) },
213 { FMT_MEXICANPESO, LwpCurrencyInfo(u"Mex$"_ustr) },
214 { FMT_NETHERLANDSGUILDER, LwpCurrencyInfo(u"F"_ustr,false, true) },
215 { FMT_NEWZEALANDDOLLAR, LwpCurrencyInfo(u"NZ$"_ustr) },
216 { FMT_NORWEGIANKRONE, LwpCurrencyInfo(u"Nkr"_ustr,false, true) },
217 { FMT_POLISHZLOTY, LwpCurrencyInfo(u"Zl"_ustr,true, true) },
218 { FMT_PORTUGUESEESCUDO, LwpCurrencyInfo(u"Esc."_ustr,true, true) },
219 { FMT_ROMANIANLEI, LwpCurrencyInfo(u"Leu"_ustr,true, true) },
220 { FMT_RUSSIANRUBLE, LwpCurrencyInfo(u"R"_ustr,true, true) },
221 { FMT_SINGAPOREDOLLAR, LwpCurrencyInfo(u"S$"_ustr) },
222 { FMT_SLOVAKIANKORUNA, LwpCurrencyInfo(u"Sk"_ustr,true, true) },
223 { FMT_SLOVENIANTHOLAR, LwpCurrencyInfo(u"SIT"_ustr,false, true) },
224 { FMT_SOUTHAFRICANRAND, LwpCurrencyInfo(u"R"_ustr) },
225 { FMT_SOUTHKOREANWON, LwpCurrencyInfo(u"W"_ustr) },
226 { FMT_SPANISHPESETA, LwpCurrencyInfo(u"Pts"_ustr,true, true) },
227 { FMT_SWEDISHKRONA, LwpCurrencyInfo(u"Skr"_ustr,true, true) },
228 { FMT_SWISSFRANC, LwpCurrencyInfo(u"SFr"_ustr,false, true) },
229 { FMT_TAIWANDOLLAR, LwpCurrencyInfo(u"NT$"_ustr) },
230 { FMT_THAIBAHT, LwpCurrencyInfo(u"Bt"_ustr,true, true) },
231 { FMT_USDOLLAR, LwpCurrencyInfo(u"$"_ustr) },
232 { FMT_OTHERCURRENCY, LwpCurrencyInfo(u"OTH"_ustr,false, true) },
233 { FMT_EURO, LwpCurrencyInfo(u"\u20AC"_ustr) }
237 class LwpNumericFormat
239 public:
240 explicit LwpNumericFormat(LwpObjectStream * pStrm);
241 void Read();
242 static bool IsCurrencyFormat(sal_uInt16 Format);
243 sal_uInt16 GetDecimalPlaces();
244 bool IsDecimalPlacesOverridden() const;
245 bool IsNegativeOverridden() const;
246 XFStyle* Convert();
248 private:
249 LwpObjectStream * m_pObjStrm;
251 sal_uInt16 cFlags;
252 enum // for cFlags
254 NF_OVER_ZERO = 0x0001,
255 NF_OVER_NEGATIVE = 0x0002,
256 NF_OVER_DECIMAL_PLACES = 0x0004
259 sal_uInt16 cFormat;
261 LwpNumericFormatSubset cAnyNumber;
262 LwpNumericFormatSubset cZero;
263 LwpNumericFormatSubset cNegative;
265 sal_uInt16 cDecimalPlaces;
267 static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
268 static LwpCurrencyPool m_aCurrencyInfo;
270 void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegative=false);
271 void SetNumberType(XFNumberStyle* pStyle);
272 static OUString reencode(const OUString& sCode);
275 inline bool
276 LwpNumericFormat::IsDecimalPlacesOverridden() const
278 return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
281 inline bool
282 LwpNumericFormat::IsNegativeOverridden() const
284 return (cFlags & NF_OVER_NEGATIVE) != 0;
287 class LwpLayoutNumerics final : public LwpVirtualPiece
289 public:
290 LwpLayoutNumerics(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
291 :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm.get()){}
292 XFStyle* Convert();
293 virtual void Read() override;
295 private:
296 virtual ~LwpLayoutNumerics() override {}
298 LwpNumericFormat cNumerics;
301 #endif
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */