• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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 "core/fxcrt/span.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 #include "fxjs/gc/heap.h"
15 #include "v8/include/cppgc/garbage-collected.h"
16 #include "xfa/fxfa/parser/gced_locale_iface.h"
17 
18 class CFX_XMLDocument;
19 class CFX_XMLElement;
20 
21 class CXFA_XMLLocale final : public GCedLocaleIface {
22  public:
23   // Object is created on cppgc heap.
24   static CXFA_XMLLocale* Create(cppgc::Heap* heap,
25                                 pdfium::span<const uint8_t> data);
26 
27   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
28   ~CXFA_XMLLocale() override;
29 
30   // GCedLocaleIface:
31   void Trace(cppgc::Visitor* visitor) const override;
32   WideString GetName() const override;
33   WideString GetDecimalSymbol() const override;
34   WideString GetGroupingSymbol() const override;
35   WideString GetPercentSymbol() const override;
36   WideString GetMinusSymbol() const override;
37   WideString GetCurrencySymbol() const override;
38   WideString GetDateTimeSymbols() const override;
39   WideString GetMonthName(int32_t nMonth, bool bAbbr) const override;
40   WideString GetDayName(int32_t nWeek, bool bAbbr) const override;
41   WideString GetMeridiemName(bool bAM) const override;
42   int GetTimeZoneInMinutes() const override;
43   WideString GetEraName(bool bAD) const override;
44 
45   WideString GetDatePattern(DateTimeSubcategory eType) const override;
46   WideString GetTimePattern(DateTimeSubcategory eType) const override;
47   WideString GetNumPattern(NumSubcategory eType) const override;
48 
49  private:
50   CXFA_XMLLocale(std::unique_ptr<CFX_XMLDocument> root,
51                  const CFX_XMLElement* locale);
52 
53   WideString GetPattern(CFX_XMLElement* pElement,
54                         WideStringView bsTag,
55                         WideStringView wsName) const;
56   WideString GetCalendarSymbol(WideStringView symbol,
57                                size_t index,
58                                bool bAbbr) const;
59 
60   std::unique_ptr<CFX_XMLDocument> xml_doc_;
61   UnownedPtr<const CFX_XMLElement> locale_;
62 };
63 
64 #endif  // XFA_FXFA_PARSER_CXFA_XMLLOCALE_H_
65