LibreOffice Module lotuswordpro (master) 1
lwpnumericfmt.hxx
Go to the documentation of this file.
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 ************************************************************************/
61#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
62#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
63
64#include <map>
65
66#include <lwpatomholder.hxx>
67#include <lwpcolor.hxx>
68#include "lwppiece.hxx"
69
70//For converting to xml
71#include <utility>
73
74class LwpObjectStream;
75
77{
78public:
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;
86
87private:
91 sal_uInt16 cSubFlags;
92
93 enum // for cSubFlags
94 {
97 SF_OVER_COLOR = 0x0004
98 };
99};
100
102{
103 OUString sSymbol;
104 bool bPost;
106 explicit LwpCurrencyInfo(OUString sSym)
107 : sSymbol(std::move(sSym)), bPost(false), bShowSpace(false)
108 {
109 }
111 {
112 }
113 LwpCurrencyInfo(OUString sSym, bool bPost_, bool bShowSpace_)
114 : sSymbol(std::move(sSym)), bPost(bPost_), bShowSpace(bShowSpace_)
115 {
116 }
117};
118
119enum
120{
121 /* These are types of formats. They are mutually exclusive.
122 */
175 FMT_EURO = 52
177
179{
180public:
182 OUString GetCurrencySymbol(sal_uInt16 nFormat);
183 bool IsShowSpace(sal_uInt16 nFormat);
184 bool IsSymbolPost(sal_uInt16 nFormat);
185
186private:
187 std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
189 {
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,
235
236 m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(OUString(u"\u20AC")); //FMT_EURO = 52
237 }
238};
239
241{
242public:
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();
250
251private:
253
254 sal_uInt16 cFlags;
255 enum // for cFlags
256 {
257 NF_OVER_ZERO = 0x0001,
260 };
261
262 sal_uInt16 cFormat;
263
267
268 sal_uInt16 cDecimalPlaces;
269
270 static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
272
273 void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegative=false);
274 void SetNumberType(XFNumberStyle* pStyle);
275 static OUString reencode(const OUString& sCode);
276};
277
278inline bool
280{
281 return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
282}
283
284inline bool
286{
287 return (cFlags & NF_OVER_NEGATIVE) != 0;
288}
289
291{
292public:
294 :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm.get()){}
295 XFStyle* Convert();
296 virtual void Read() override;
297
298private:
299 virtual ~LwpLayoutNumerics() override {}
300
302};
303
304#endif
305
306/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AtomHolder class of Word Pro to hold a string.
const OUString & str() const
lwpcolor class (red, green, blue, extra)
Definition: lwpcolor.hxx:71
bool IsSymbolPost(sal_uInt16 nFormat)
std::map< sal_uInt16, LwpCurrencyInfo > m_aCurrencyInfo
bool IsShowSpace(sal_uInt16 nFormat)
OUString GetCurrencySymbol(sal_uInt16 nFormat)
LwpNumericFormat cNumerics
XFStyle * Convert()
virtual ~LwpLayoutNumerics() override
LwpLayoutNumerics(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
virtual void Read() override
@descr Read LwpDLVList data from object stream
OUString const & GetPrefix() const
LwpColor GetColor() const
OUString const & GetSuffix() const
void QuickRead(LwpObjectStream *pStrm)
bool IsDefaultSuffix() const
bool IsDefaultPrefix() const
sal_uInt16 GetDecimalPlaces()
static OUString reencode(const OUString &sCode)
@description for SODC_2754
LwpNumericFormat(LwpObjectStream *pStrm)
LwpNumericFormatSubset cAnyNumber
XFStyle * Convert()
Make the xml content of number format.
static LwpCurrencyPool m_aCurrencyInfo
sal_uInt16 cDecimalPlaces
LwpNumericFormatSubset cZero
LwpObjectStream * m_pObjStrm
static bool IsCurrencyFormat(sal_uInt16 Format)
static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format)
void SetNumberType(XFNumberStyle *pStyle)
bool IsDecimalPlacesOverridden() const
void Read()
Read number format from wordpro file.
bool IsNegativeOverridden() const
void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString &aPrefix, OUString &aSuffix, bool bNegative=false)
LwpNumericFormatSubset cNegative
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
std::unique_ptr< LwpObjectStream > m_pObjStrm
Definition: lwpobj.hxx:90
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
implements ixfstyle interface.
Definition: xfstyle.hxx:70
float u
@ FMT_POLISHZLOTY
@ FMT_LUXEMBOURGFRANC
@ FMT_AUSTRALIANDOLLAR
@ FMT_JAPANESEYEN
@ FMT_GENERAL
@ FMT_DEFAULT
@ FMT_CHINESEYUAN
@ FMT_INDONESIANRUPIAH
@ FMT_AUSTRIANSCHILLING
@ FMT_COMMA
@ FMT_SWEDISHKRONA
@ FMT_BELGIANFRANC
@ FMT_IRISHPUNT
@ FMT_INDIANRUPEE
@ FMT_ARGENTINEANPESO
@ FMT_PERCENT
@ FMT_FRENCHFRANC
@ FMT_SPANISHPESETA
@ FMT_SWISSFRANC
@ FMT_SOUTHAFRICANRAND
@ FMT_ECU
@ FMT_GREEKDRACHMA
@ FMT_NEWZEALANDDOLLAR
@ FMT_FIXED
@ FMT_SOUTHKOREANWON
@ FMT_NONE
@ FMT_GERMANMARK
@ FMT_EURO
@ FMT_SLOVAKIANKORUNA
@ FMT_ITALIANLIRA
@ FMT_OTHERCURRENCY
@ FMT_PORTUGUESEESCUDO
@ FMT_SCIENTIFIC
@ FMT_THAIBAHT
@ FMT_HUNGARIANFORINT
@ FMT_BRITISHPOUND
@ FMT_FINNISHMARKKA
@ FMT_MALAYSIANRINGGIT
@ FMT_SLOVENIANTHOLAR
@ FMT_MEXICANPESO
@ FMT_USDOLLAR
@ FMT_NETHERLANDSGUILDER
@ FMT_LABEL
@ FMT_NORWEGIANKRONE
@ FMT_DANISHKRONE
@ FMT_SINGAPOREDOLLAR
@ FMT_RUSSIANRUBLE
@ FMT_CANADIANDOLLAR
@ FMT_ROMANIANLEI
@ FMT_CZECHKORUNA
@ FMT_BRAZILIANCRUZEIRO
@ FMT_HONGKONGDOLLAR
@ FMT_TAIWANDOLLAR
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
LwpCurrencyInfo(OUString sSym, bool bPost_, bool bShowSpace_)
LwpCurrencyInfo(OUString sSym)