summaryrefslogtreecommitdiff
path: root/xfa/src/fgas/include/fx_locale.h
blob: 6886974fd210d10e1ecc50f975a74d0ff05f0a92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef _FX_LOCALE_H_
#define _FX_LOCALE_H_
class CFX_Unitime;
class IFX_Locale;
class IFX_FormatString;
class IFX_LocaleMgr;
enum FX_LOCALENUMSYMBOL {
    FX_LOCALENUMSYMBOL_Decimal,
    FX_LOCALENUMSYMBOL_Grouping,
    FX_LOCALENUMSYMBOL_Percent,
    FX_LOCALENUMSYMBOL_Minus,
    FX_LOCALENUMSYMBOL_Zero,
    FX_LOCALENUMSYMBOL_CurrencySymbol,
    FX_LOCALENUMSYMBOL_CurrencyName,
};
enum FX_LOCALEDATETIMESUBCATEGORY {
    FX_LOCALEDATETIMESUBCATEGORY_Default,
    FX_LOCALEDATETIMESUBCATEGORY_Short,
    FX_LOCALEDATETIMESUBCATEGORY_Medium,
    FX_LOCALEDATETIMESUBCATEGORY_Full,
    FX_LOCALEDATETIMESUBCATEGORY_Long,
};
enum FX_LOCALENUMSUBCATEGORY {
    FX_LOCALENUMPATTERN_Percent,
    FX_LOCALENUMPATTERN_Currency,
    FX_LOCALENUMPATTERN_Decimal,
    FX_LOCALENUMPATTERN_Integer,
};
enum FX_LOCALECATEGORY {
    FX_LOCALECATEGORY_Unknown,
    FX_LOCALECATEGORY_Date,
    FX_LOCALECATEGORY_Time,
    FX_LOCALECATEGORY_DateTime,
    FX_LOCALECATEGORY_Num,
    FX_LOCALECATEGORY_Text,
    FX_LOCALECATEGORY_Zero,
    FX_LOCALECATEGORY_Null,
};
enum FX_DATETIMETYPE {
    FX_DATETIMETYPE_Unknown,
    FX_DATETIMETYPE_Date,
    FX_DATETIMETYPE_Time,
    FX_DATETIMETYPE_DateTime,
    FX_DATETIMETYPE_TimeDate,
};
class IFX_Locale
{
public:
    static IFX_Locale* Create(CXML_Element* pLocaleData);

    virtual void	Release() = 0;


    virtual CFX_WideString GetName() = 0;

    virtual void	GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, CFX_WideString& wsNumSymbol) const = 0;
    virtual void	GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const = 0;
    virtual void	GetMonthName(FX_INT32 nMonth, CFX_WideString& wsMonthName, FX_BOOL bAbbr = TRUE) const = 0;
    virtual void	GetDayName(FX_INT32 nWeek, CFX_WideString& wsDayName, FX_BOOL bAbbr = TRUE) const = 0;
    virtual void	GetMeridiemName(CFX_WideString& wsMeridiemName, FX_BOOL bAM = TRUE) const = 0;
    virtual void	GetTimeZone(FX_TIMEZONE& tz) const = 0;
    virtual void	GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const = 0;
    virtual void	GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const = 0;
    virtual void	GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const = 0;
    virtual void	GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, CFX_WideString& wsPattern) const = 0;
};
class IFX_LocaleMgr
{
public:
    virtual void			Release() = 0;
    virtual FX_WORD			GetDefLocaleID() = 0;
    virtual IFX_Locale* 	GetDefLocale() = 0;
    virtual IFX_Locale* 	GetLocale(FX_WORD lcid) = 0;
    virtual IFX_Locale* 	GetLocaleByName(FX_WSTR wsLocaleName) = 0;
};
IFX_LocaleMgr*	FX_LocaleMgr_Create(FX_LPCWSTR pszLocalPath, FX_WORD wDefaultLCID);
void			FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult);
FX_BOOL			FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime& datetime);
FX_BOOL			FX_TimeFromCanonical(FX_WSTR wsTime, CFX_Unitime& datetime, IFX_Locale* pLocale);
class IFX_FormatString
{
public:
    static IFX_FormatString* Create(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);

    virtual void Release() = 0;
    virtual void SplitFormatString(const CFX_WideString& wsFormatString, CFX_WideStringArray& wsPatterns) = 0;
    virtual FX_LOCALECATEGORY	GetCategory(const CFX_WideString& wsPattern) = 0;
    virtual FX_WORD				GetLCID(const CFX_WideString& wsPattern) = 0;
    virtual CFX_WideString		GetLocaleName(const CFX_WideString& wsPattern) = 0;
    virtual FX_BOOL	ParseText(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern, CFX_WideString& wsValue) = 0;
    virtual FX_BOOL	ParseNum(const CFX_WideString& wsSrcNum, const CFX_WideString& wsPattern, FX_FLOAT &fValue) = 0;
    virtual FX_BOOL	ParseNum(const CFX_WideString& wsSrcNum, const CFX_WideString& wsPattern, CFX_WideString &wsValue) = 0;
    virtual FX_BOOL	ParseDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, FX_DATETIMETYPE eDateTimeType, CFX_Unitime& dtValue) = 0;
    virtual FX_BOOL ParseZero(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern) = 0;
    virtual FX_BOOL ParseNull(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern) = 0;
    virtual FX_BOOL	FormatText(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
    virtual FX_BOOL	FormatNum(const CFX_WideString& wsSrcNum, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
    virtual FX_BOOL	FormatNum(FX_FLOAT fNum, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
    virtual FX_BOOL	FormatDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
    virtual FX_BOOL	FormatDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, CFX_WideString& wsOutput, FX_DATETIMETYPE eDateTimeType) = 0;
    virtual FX_BOOL	FormatDateTime(const CFX_Unitime& dt, const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
    virtual FX_BOOL FormatZero(const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
    virtual FX_BOOL FormatNull(const CFX_WideString& wsPattern, CFX_WideString& wsOutput) = 0;
};
class CFX_Decimal : CFX_Object
{
public:
    CFX_Decimal();
    CFX_Decimal(FX_UINT32 val);
    CFX_Decimal(FX_UINT64 val);
    CFX_Decimal(FX_INT32 val);
    CFX_Decimal(FX_INT64 val);
    CFX_Decimal(FX_FLOAT val, FX_UINT8 scale = 3);
    CFX_Decimal(FX_WSTR str);
    CFX_Decimal(FX_BSTR str);
    operator CFX_WideString() const;
    operator double() const;
    FX_BOOL operator == (const CFX_Decimal& val) const;
    FX_BOOL operator <= (const CFX_Decimal& val) const;
    FX_BOOL operator >= (const CFX_Decimal& val) const;
    FX_BOOL operator != (const CFX_Decimal& val) const;
    FX_BOOL operator <  (const CFX_Decimal& val) const;
    FX_BOOL operator >  (const CFX_Decimal& val) const;
    CFX_Decimal operator + (const CFX_Decimal& val) const;
    CFX_Decimal operator - (const CFX_Decimal& val) const;
    CFX_Decimal operator * (const CFX_Decimal& val) const;
    CFX_Decimal operator / (const CFX_Decimal& val) const;
    CFX_Decimal operator % (const CFX_Decimal& val) const;
    void		SetScale(FX_UINT8 newScale);
    FX_UINT8	GetScale();
    void		SetAbs();
    void		SetNegate();
    void		SetFloor();
    void		SetCeiling();
    void		SetTruncate();
protected:
    CFX_Decimal(FX_UINT32 hi, FX_UINT32 mid, FX_UINT32 lo, FX_BOOL neg, FX_UINT8 scale);
    inline FX_BOOL	IsNotZero() const
    {
        return m_uHi || m_uMid || m_uLo;
    }
    inline FX_INT8	Compare (const CFX_Decimal& val) const;
    inline void		Swap(CFX_Decimal& val);
    inline void		FloorOrCeil(FX_BOOL bFloor);
    CFX_Decimal		AddOrMinus(const CFX_Decimal& val, FX_BOOL isAdding) const;
    CFX_Decimal		Multiply(const CFX_Decimal& val) const;
    CFX_Decimal		Divide(const CFX_Decimal& val) const;
    CFX_Decimal		Modulus(const CFX_Decimal& val) const;
    FX_UINT32		m_uFlags;
    FX_UINT32		m_uHi;
    FX_UINT32		m_uLo;
    FX_UINT32		m_uMid;
};
#endif