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 _FX_LOCALE_IMP_H_ 8 #define _FX_LOCALE_IMP_H_ 9 class CFX_LCNumeric; 10 class CFX_Locale : public IFX_Locale { 11 public: 12 CFX_Locale(CXML_Element* pLocaleData); 13 virtual void Release() { delete this; } 14 15 virtual CFX_WideString GetName(); 16 virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, 17 CFX_WideString& wsNumSymbol) const; 18 19 virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const; 20 virtual void GetMonthName(int32_t nMonth, 21 CFX_WideString& wsMonthName, 22 FX_BOOL bAbbr = TRUE) const; 23 virtual void GetDayName(int32_t nWeek, 24 CFX_WideString& wsDayName, 25 FX_BOOL bAbbr = TRUE) const; 26 virtual void GetMeridiemName(CFX_WideString& wsMeridiemName, 27 FX_BOOL bAM = TRUE) const; 28 virtual void GetTimeZone(FX_TIMEZONE& tz) const; 29 virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const; 30 31 virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, 32 CFX_WideString& wsPattern) const; 33 virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, 34 CFX_WideString& wsPattern) const; 35 virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, 36 CFX_WideString& wsPattern) const; 37 38 protected: 39 virtual ~CFX_Locale(); 40 CXML_Element* m_pElement; 41 }; 42 class CFX_FormatString : public IFX_FormatString { 43 public: 44 CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID); 45 virtual void Release() { delete this; } 46 47 virtual void SplitFormatString(const CFX_WideString& wsFormatString, 48 CFX_WideStringArray& wsPatterns); 49 virtual FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern); 50 virtual FX_WORD GetLCID(const CFX_WideString& wsPattern); 51 virtual CFX_WideString GetLocaleName(const CFX_WideString& wsPattern); 52 virtual FX_BOOL ParseText(const CFX_WideString& wsSrcText, 53 const CFX_WideString& wsPattern, 54 CFX_WideString& wsValue); 55 virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum, 56 const CFX_WideString& wsPattern, 57 FX_FLOAT& fValue); 58 virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum, 59 const CFX_WideString& wsPattern, 60 CFX_WideString& wsValue); 61 virtual FX_BOOL ParseDateTime(const CFX_WideString& wsSrcDateTime, 62 const CFX_WideString& wsPattern, 63 FX_DATETIMETYPE eDateTimeType, 64 CFX_Unitime& dtValue); 65 virtual FX_BOOL ParseZero(const CFX_WideString& wsSrcText, 66 const CFX_WideString& wsPattern); 67 virtual FX_BOOL ParseNull(const CFX_WideString& wsSrcText, 68 const CFX_WideString& wsPattern); 69 virtual FX_BOOL FormatText(const CFX_WideString& wsSrcText, 70 const CFX_WideString& wsPattern, 71 CFX_WideString& wsOutput); 72 virtual FX_BOOL FormatNum(const CFX_WideString& wsSrcNum, 73 const CFX_WideString& wsPattern, 74 CFX_WideString& wsOutput); 75 virtual FX_BOOL FormatNum(FX_FLOAT fNum, 76 const CFX_WideString& wsPattern, 77 CFX_WideString& wsOutput); 78 virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime, 79 const CFX_WideString& wsPattern, 80 CFX_WideString& wsOutput); 81 virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime, 82 const CFX_WideString& wsPattern, 83 CFX_WideString& wsOutput, 84 FX_DATETIMETYPE eDateTimeType); 85 virtual FX_BOOL FormatDateTime(const CFX_Unitime& dt, 86 const CFX_WideString& wsPattern, 87 CFX_WideString& wsOutput); 88 virtual FX_BOOL FormatZero(const CFX_WideString& wsPattern, 89 CFX_WideString& wsOutput); 90 virtual FX_BOOL FormatNull(const CFX_WideString& wsPattern, 91 CFX_WideString& wsOutput); 92 93 protected: 94 virtual ~CFX_FormatString(); 95 IFX_Locale* GetTextFormat(const CFX_WideString& wsPattern, 96 const CFX_WideStringC& wsCategory, 97 CFX_WideString& wsPurgePattern); 98 IFX_Locale* GetNumericFormat(const CFX_WideString& wsPattern, 99 int32_t& iDotIndex, 100 FX_DWORD& dwStyle, 101 CFX_WideString& wsPurgePattern); 102 FX_BOOL FormatStrNum(const CFX_WideStringC& wsInputNum, 103 const CFX_WideString& wsPattern, 104 CFX_WideString& wsOutput); 105 FX_BOOL FormatLCNumeric(CFX_LCNumeric& lcNum, 106 const CFX_WideString& wsPattern, 107 CFX_WideString& wsOutput); 108 FX_DATETIMETYPE GetDateTimeFormat(const CFX_WideString& wsPattern, 109 IFX_Locale*& pLocale, 110 CFX_WideString& wsDatePattern, 111 CFX_WideString& wsTimePattern); 112 IFX_Locale* GetPatternLocale(const CFX_WideStringC& wsLocale); 113 IFX_LocaleMgr* m_pLocaleMgr; 114 FX_BOOL m_bUseLCID; 115 }; 116 #endif 117