• 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_CXFA_XMLLOCALE_H_
8 #define XFA_FXFA_PARSER_CXFA_XMLLOCALE_H_
9 
10 #include <memory>
11 
12 #include "third_party/base/span.h"
13 #include "xfa/fgas/crt/locale_iface.h"
14 
15 class CFX_XMLDocument;
16 class CFX_XMLElement;
17 
18 class CXFA_XMLLocale final : public LocaleIface {
19  public:
20   static std::unique_ptr<CXFA_XMLLocale> Create(pdfium::span<uint8_t> data);
21 
22   explicit CXFA_XMLLocale(std::unique_ptr<CFX_XMLDocument> root,
23                           CFX_XMLElement* locale);
24   ~CXFA_XMLLocale() override;
25 
26   // LocaleIface
27   WideString GetName() const override;
28   WideString GetDecimalSymbol() const override;
29   WideString GetGroupingSymbol() const override;
30   WideString GetPercentSymbol() const override;
31   WideString GetMinusSymbol() const override;
32   WideString GetCurrencySymbol() const override;
33   WideString GetDateTimeSymbols() const override;
34   WideString GetMonthName(int32_t nMonth, bool bAbbr) const override;
35   WideString GetDayName(int32_t nWeek, bool bAbbr) const override;
36   WideString GetMeridiemName(bool bAM) const override;
37   FX_TIMEZONE GetTimeZone() const override;
38   WideString GetEraName(bool bAD) const override;
39 
40   WideString GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType) const override;
41   WideString GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType) const override;
42   WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const override;
43 
44  private:
45   WideString GetPattern(CFX_XMLElement* pElement,
46                         WideStringView bsTag,
47                         WideStringView wsName) const;
48   WideString GetCalendarSymbol(WideStringView symbol,
49                                size_t index,
50                                bool bAbbr) const;
51 
52   std::unique_ptr<CFX_XMLDocument> xml_doc_;
53   UnownedPtr<CFX_XMLElement> locale_;
54 };
55 
56 #endif  // XFA_FXFA_PARSER_CXFA_XMLLOCALE_H_
57