Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: xfa/src/fgas/localization/fgas_locale.h

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fgas/localization/fgas_datetime.cpp ('k') | xfa/src/fgas/localization/fgas_locale.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_
8 #define XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_
9
10 #include "core/include/fxcrt/fx_xml.h"
11 #include "xfa/src/fgas/localization/fgas_datetime.h"
12
13 class CFX_Unitime;
14
15 enum FX_LOCALENUMSYMBOL {
16 FX_LOCALENUMSYMBOL_Decimal,
17 FX_LOCALENUMSYMBOL_Grouping,
18 FX_LOCALENUMSYMBOL_Percent,
19 FX_LOCALENUMSYMBOL_Minus,
20 FX_LOCALENUMSYMBOL_Zero,
21 FX_LOCALENUMSYMBOL_CurrencySymbol,
22 FX_LOCALENUMSYMBOL_CurrencyName,
23 };
24 enum FX_LOCALEDATETIMESUBCATEGORY {
25 FX_LOCALEDATETIMESUBCATEGORY_Default,
26 FX_LOCALEDATETIMESUBCATEGORY_Short,
27 FX_LOCALEDATETIMESUBCATEGORY_Medium,
28 FX_LOCALEDATETIMESUBCATEGORY_Full,
29 FX_LOCALEDATETIMESUBCATEGORY_Long,
30 };
31 enum FX_LOCALENUMSUBCATEGORY {
32 FX_LOCALENUMPATTERN_Percent,
33 FX_LOCALENUMPATTERN_Currency,
34 FX_LOCALENUMPATTERN_Decimal,
35 FX_LOCALENUMPATTERN_Integer,
36 };
37 enum FX_LOCALECATEGORY {
38 FX_LOCALECATEGORY_Unknown,
39 FX_LOCALECATEGORY_Date,
40 FX_LOCALECATEGORY_Time,
41 FX_LOCALECATEGORY_DateTime,
42 FX_LOCALECATEGORY_Num,
43 FX_LOCALECATEGORY_Text,
44 FX_LOCALECATEGORY_Zero,
45 FX_LOCALECATEGORY_Null,
46 };
47 enum FX_DATETIMETYPE {
48 FX_DATETIMETYPE_Unknown,
49 FX_DATETIMETYPE_Date,
50 FX_DATETIMETYPE_Time,
51 FX_DATETIMETYPE_DateTime,
52 FX_DATETIMETYPE_TimeDate,
53 };
54
55 class IFX_Locale {
56 public:
57 static IFX_Locale* Create(CXML_Element* pLocaleData);
58
59 virtual ~IFX_Locale() {}
60 virtual void Release() = 0;
61
62 virtual CFX_WideString GetName() = 0;
63
64 virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
65 CFX_WideString& wsNumSymbol) const = 0;
66 virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const = 0;
67 virtual void GetMonthName(int32_t nMonth,
68 CFX_WideString& wsMonthName,
69 FX_BOOL bAbbr = TRUE) const = 0;
70 virtual void GetDayName(int32_t nWeek,
71 CFX_WideString& wsDayName,
72 FX_BOOL bAbbr = TRUE) const = 0;
73 virtual void GetMeridiemName(CFX_WideString& wsMeridiemName,
74 FX_BOOL bAM = TRUE) const = 0;
75 virtual void GetTimeZone(FX_TIMEZONE& tz) const = 0;
76 virtual void GetEraName(CFX_WideString& wsEraName,
77 FX_BOOL bAD = TRUE) const = 0;
78 virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
79 CFX_WideString& wsPattern) const = 0;
80 virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
81 CFX_WideString& wsPattern) const = 0;
82 virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
83 CFX_WideString& wsPattern) const = 0;
84 };
85
86 class IFX_LocaleMgr {
87 public:
88 virtual ~IFX_LocaleMgr() {}
89 virtual void Release() = 0;
90 virtual FX_WORD GetDefLocaleID() = 0;
91 virtual IFX_Locale* GetDefLocale() = 0;
92 virtual IFX_Locale* GetLocale(FX_WORD lcid) = 0;
93 virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName) = 0;
94 };
95 IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
96 FX_WORD wDefaultLCID);
97 void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult);
98 FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate,
99 CFX_Unitime& datetime);
100 FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
101 CFX_Unitime& datetime,
102 IFX_Locale* pLocale);
103 class IFX_FormatString {
104 public:
105 static IFX_FormatString* Create(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);
106
107 virtual ~IFX_FormatString() {}
108 virtual void Release() = 0;
109 virtual void SplitFormatString(const CFX_WideString& wsFormatString,
110 CFX_WideStringArray& wsPatterns) = 0;
111 virtual FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern) = 0;
112 virtual FX_WORD GetLCID(const CFX_WideString& wsPattern) = 0;
113 virtual CFX_WideString GetLocaleName(const CFX_WideString& wsPattern) = 0;
114 virtual FX_BOOL ParseText(const CFX_WideString& wsSrcText,
115 const CFX_WideString& wsPattern,
116 CFX_WideString& wsValue) = 0;
117 virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
118 const CFX_WideString& wsPattern,
119 FX_FLOAT& fValue) = 0;
120 virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
121 const CFX_WideString& wsPattern,
122 CFX_WideString& wsValue) = 0;
123 virtual FX_BOOL ParseDateTime(const CFX_WideString& wsSrcDateTime,
124 const CFX_WideString& wsPattern,
125 FX_DATETIMETYPE eDateTimeType,
126 CFX_Unitime& dtValue) = 0;
127 virtual FX_BOOL ParseZero(const CFX_WideString& wsSrcText,
128 const CFX_WideString& wsPattern) = 0;
129 virtual FX_BOOL ParseNull(const CFX_WideString& wsSrcText,
130 const CFX_WideString& wsPattern) = 0;
131 virtual FX_BOOL FormatText(const CFX_WideString& wsSrcText,
132 const CFX_WideString& wsPattern,
133 CFX_WideString& wsOutput) = 0;
134 virtual FX_BOOL FormatNum(const CFX_WideString& wsSrcNum,
135 const CFX_WideString& wsPattern,
136 CFX_WideString& wsOutput) = 0;
137 virtual FX_BOOL FormatNum(FX_FLOAT fNum,
138 const CFX_WideString& wsPattern,
139 CFX_WideString& wsOutput) = 0;
140 virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
141 const CFX_WideString& wsPattern,
142 CFX_WideString& wsOutput) = 0;
143 virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
144 const CFX_WideString& wsPattern,
145 CFX_WideString& wsOutput,
146 FX_DATETIMETYPE eDateTimeType) = 0;
147 virtual FX_BOOL FormatDateTime(const CFX_Unitime& dt,
148 const CFX_WideString& wsPattern,
149 CFX_WideString& wsOutput) = 0;
150 virtual FX_BOOL FormatZero(const CFX_WideString& wsPattern,
151 CFX_WideString& wsOutput) = 0;
152 virtual FX_BOOL FormatNull(const CFX_WideString& wsPattern,
153 CFX_WideString& wsOutput) = 0;
154 };
155 class CFX_Decimal {
156 public:
157 CFX_Decimal();
158 CFX_Decimal(uint32_t val);
159 CFX_Decimal(uint64_t val);
160 CFX_Decimal(int32_t val);
161 CFX_Decimal(int64_t val);
162 CFX_Decimal(FX_FLOAT val, uint8_t scale = 3);
163 CFX_Decimal(const CFX_WideStringC& str);
164 CFX_Decimal(const CFX_ByteStringC& str);
165 operator CFX_WideString() const;
166 operator double() const;
167 bool operator==(const CFX_Decimal& val) const;
168 bool operator<=(const CFX_Decimal& val) const;
169 bool operator>=(const CFX_Decimal& val) const;
170 bool operator!=(const CFX_Decimal& val) const;
171 bool operator<(const CFX_Decimal& val) const;
172 bool operator>(const CFX_Decimal& val) const;
173 CFX_Decimal operator+(const CFX_Decimal& val) const;
174 CFX_Decimal operator-(const CFX_Decimal& val) const;
175 CFX_Decimal operator*(const CFX_Decimal& val) const;
176 CFX_Decimal operator/(const CFX_Decimal& val) const;
177 CFX_Decimal operator%(const CFX_Decimal& val) const;
178 void SetScale(uint8_t newScale);
179 uint8_t GetScale();
180 void SetAbs();
181 void SetNegate();
182 void SetFloor();
183 void SetCeiling();
184 void SetTruncate();
185
186 protected:
187 CFX_Decimal(uint32_t hi,
188 uint32_t mid,
189 uint32_t lo,
190 FX_BOOL neg,
191 uint8_t scale);
192 inline FX_BOOL IsNotZero() const { return m_uHi || m_uMid || m_uLo; }
193 inline int8_t Compare(const CFX_Decimal& val) const;
194 inline void Swap(CFX_Decimal& val);
195 inline void FloorOrCeil(FX_BOOL bFloor);
196 CFX_Decimal AddOrMinus(const CFX_Decimal& val, FX_BOOL isAdding) const;
197 CFX_Decimal Multiply(const CFX_Decimal& val) const;
198 CFX_Decimal Divide(const CFX_Decimal& val) const;
199 CFX_Decimal Modulus(const CFX_Decimal& val) const;
200 uint32_t m_uFlags;
201 uint32_t m_uHi;
202 uint32_t m_uLo;
203 uint32_t m_uMid;
204 };
205
206 #endif // XFA_SRC_FGAS_LOCALIZATION_FGAS_LOCALE_H_
OLDNEW
« no previous file with comments | « xfa/src/fgas/localization/fgas_datetime.cpp ('k') | xfa/src/fgas/localization/fgas_locale.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698