• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FXFA_PARSER_XFA_LOCALE_H_
8 #define XFA_FXFA_PARSER_XFA_LOCALE_H_
9 
10 #include <memory>
11 
12 #include "xfa/fgas/localization/fgas_locale.h"
13 #include "xfa/fxfa/parser/xfa_object.h"
14 
15 class CXFA_XMLLocale : public IFX_Locale {
16  public:
17   explicit CXFA_XMLLocale(std::unique_ptr<CXML_Element> pLocaleData);
18   ~CXFA_XMLLocale() override;
19 
20   // IFX_Locale
21   CFX_WideString GetName() const override;
22   void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
23                          CFX_WideString& wsNumSymbol) const override;
24 
25   void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const override;
26   void GetMonthName(int32_t nMonth,
27                     CFX_WideString& wsMonthName,
28                     bool bAbbr = true) const override;
29   void GetDayName(int32_t nWeek,
30                   CFX_WideString& wsDayName,
31                   bool bAbbr = true) const override;
32   void GetMeridiemName(CFX_WideString& wsMeridiemName,
33                        bool bAM = true) const override;
34   void GetTimeZone(FX_TIMEZONE* tz) const override;
35   void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const override;
36 
37   void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
38                       CFX_WideString& wsPattern) const override;
39   void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
40                       CFX_WideString& wsPattern) const override;
41   void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
42                      CFX_WideString& wsPattern) const override;
43 
44  protected:
45   void GetPattern(CXML_Element* pElement,
46                   const CFX_ByteStringC& bsTag,
47                   const CFX_WideStringC& wsName,
48                   CFX_WideString& wsPattern) const;
49   CFX_WideString GetCalendarSymbol(const CFX_ByteStringC& symbol,
50                                    int index,
51                                    bool bAbbr) const;
52 
53  private:
54   std::unique_ptr<CXML_Element> m_pLocaleData;
55 };
56 
57 class CXFA_NodeLocale : public IFX_Locale {
58  public:
59   explicit CXFA_NodeLocale(CXFA_Node* pLocale);
60   ~CXFA_NodeLocale() override;
61 
62   // IFX_Locale
63   CFX_WideString GetName() const override;
64   void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
65                          CFX_WideString& wsNumSymbol) const override;
66 
67   void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const override;
68   void GetMonthName(int32_t nMonth,
69                     CFX_WideString& wsMonthName,
70                     bool bAbbr = true) const override;
71   void GetDayName(int32_t nWeek,
72                   CFX_WideString& wsDayName,
73                   bool bAbbr = true) const override;
74   void GetMeridiemName(CFX_WideString& wsMeridiemName,
75                        bool bAM = true) const override;
76   void GetTimeZone(FX_TIMEZONE* tz) const override;
77   void GetEraName(CFX_WideString& wsEraName, bool bAD = true) const override;
78 
79   void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
80                       CFX_WideString& wsPattern) const override;
81   void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
82                       CFX_WideString& wsPattern) const override;
83   void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
84                      CFX_WideString& wsPattern) const override;
85 
86  protected:
87   CXFA_Node* GetNodeByName(CXFA_Node* pParent,
88                            const CFX_WideStringC& wsName) const;
89   CFX_WideString GetSymbol(XFA_Element eElement,
90                            const CFX_WideStringC& symbol_type) const;
91   CFX_WideString GetCalendarSymbol(XFA_Element eElement,
92                                    int index,
93                                    bool bAbbr) const;
94 
95   CXFA_Node* const m_pLocale;
96 };
97 
98 #endif  // XFA_FXFA_PARSER_XFA_LOCALE_H_
99