summaryrefslogtreecommitdiff
path: root/xfa/fgas/localization
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/localization')
-rw-r--r--xfa/fgas/localization/fgas_locale.cpp215
-rw-r--r--xfa/fgas/localization/fgas_locale.h5
-rw-r--r--xfa/fgas/localization/fgas_localeimp.h33
-rw-r--r--xfa/fgas/localization/fgas_localemgr.cpp96
-rw-r--r--xfa/fgas/localization/fgas_localemgr.h30
5 files changed, 3 insertions, 376 deletions
diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp
index bb4fe93ba3..6eed202643 100644
--- a/xfa/fgas/localization/fgas_locale.cpp
+++ b/xfa/fgas/localization/fgas_locale.cpp
@@ -65,114 +65,6 @@ static const FX_WCHAR* const gs_LocalNumberSymbols[] = {
L"zero", L"currencySymbol", L"currencyName",
};
-IFX_Locale* IFX_Locale::Create(CXML_Element* pLocaleData) {
- return new CFX_Locale(pLocaleData);
-}
-CFX_Locale::CFX_Locale(CXML_Element* pLocaleData) {
- m_pElement = pLocaleData;
-}
-CFX_Locale::~CFX_Locale() {}
-CFX_WideString CFX_Locale::GetName() {
- return CFX_WideString();
-}
-static CFX_WideString FX_GetXMLContent(const CFX_ByteStringC& bsSpace,
- CXML_Element* pxmlElement,
- const CFX_ByteStringC& bsTag,
- const CFX_WideStringC& wsName) {
- CXML_Element* pDatePattern = NULL;
- int32_t nCount = pxmlElement->CountElements(bsSpace, bsTag);
- int32_t i = 0;
- for (; i < nCount; i++) {
- pDatePattern = pxmlElement->GetElement(bsSpace, bsTag, i);
- if (pDatePattern->GetAttrValue("name") == wsName) {
- break;
- }
- }
- if (i < nCount && pDatePattern) {
- return pDatePattern->GetContent(0);
- }
- return L"";
-}
-void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const {
- if (!m_pElement) {
- return;
- }
- CFX_ByteString bsSpace;
- CFX_WideString wsName = gs_LocalNumberSymbols[eType];
- CXML_Element* pNumberSymbols =
- m_pElement->GetElement(bsSpace.AsStringC(), "numberSymbols");
- if (!pNumberSymbols) {
- return;
- }
- wsNumSymbol = FX_GetXMLContent(bsSpace.AsStringC(), pNumberSymbols,
- "numberSymbol", wsName.AsStringC());
-}
-void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
- if (!m_pElement) {
- return;
- }
- CFX_ByteString bsSpace;
- CXML_Element* pNumberSymbols =
- m_pElement->GetElement(bsSpace.AsStringC(), "dateTimeSymbols");
- if (!pNumberSymbols) {
- return;
- }
- wsDtSymbol = pNumberSymbols->GetContent(0);
-}
-static void FX_GetCalendarSymbol(CXML_Element* pXmlElement,
- const CFX_ByteString& symbol_type,
- int32_t index,
- FX_BOOL bAbbr,
- CFX_WideString& wsName) {
- CFX_ByteString bsSpace;
- CFX_ByteString pstrSymbolNames = symbol_type + "Names";
- CXML_Element* pChild =
- pXmlElement->GetElement(bsSpace.AsStringC(), "calendarSymbols");
- if (!pChild) {
- return;
- }
- CXML_Element* pSymbolNames =
- pChild->GetElement(bsSpace.AsStringC(), pstrSymbolNames.AsStringC());
- if (!pSymbolNames) {
- return;
- }
- if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) {
- pSymbolNames =
- pChild->GetElement(bsSpace.AsStringC(), pstrSymbolNames.AsStringC(), 1);
- }
- if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) {
- CXML_Element* pSymbolName = pSymbolNames->GetElement(
- bsSpace.AsStringC(), symbol_type.AsStringC(), index);
- if (pSymbolName) {
- wsName = pSymbolName->GetContent(0);
- }
- }
-}
-void CFX_Locale::GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- FX_BOOL bAbbr) const {
- if (!m_pElement) {
- return;
- }
- FX_GetCalendarSymbol(m_pElement, "month", nMonth, bAbbr, wsMonthName);
-}
-void CFX_Locale::GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- FX_BOOL bAbbr) const {
- if (!m_pElement) {
- return;
- }
- FX_GetCalendarSymbol(m_pElement, "day", nWeek, bAbbr, wsDayName);
-}
-void CFX_Locale::GetMeridiemName(CFX_WideString& wsMeridiemName,
- FX_BOOL bAM) const {
- if (!m_pElement) {
- return;
- }
- FX_GetCalendarSymbol(m_pElement, "meridiem", bAM ? 0 : 1, FALSE,
- wsMeridiemName);
-}
static int32_t FX_ParseTimeZone(const FX_WCHAR* pStr,
int32_t iLen,
FX_TIMEZONE& tz) {
@@ -198,64 +90,7 @@ static int32_t FX_ParseTimeZone(const FX_WCHAR* pStr,
}
return iStart;
}
-void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const {
- tz.tzHour = 0;
- tz.tzMinute = 0;
- if (!m_pElement) {
- return;
- }
- CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone");
- if (pxmlTimeZone) {
- CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0);
- FX_ParseTimeZone(wsTimeZone.c_str(), wsTimeZone.GetLength(), tz);
- }
-}
-void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const {
- if (!m_pElement) {
- return;
- }
- FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName);
-}
-static void FX_GetPattern(CXML_Element* pXmlElement,
- const CFX_ByteString& bsCategory,
- const CFX_WideString& wsSubCategory,
- CFX_WideString& wsPattern) {
- CFX_ByteString bsSpace;
- CXML_Element* pDatePatterns = pXmlElement->GetElement(
- bsSpace.AsStringC(), (bsCategory + "s").AsStringC());
- if (!pDatePatterns) {
- return;
- }
- wsPattern =
- FX_GetXMLContent(bsSpace.AsStringC(), pDatePatterns,
- bsCategory.AsStringC(), wsSubCategory.AsStringC());
-}
-static void FX_GetDateTimePattern(CXML_Element* pXmlElement,
- const CFX_ByteString& bsCategory,
- FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) {
- CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName;
- FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern);
-}
-void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
- if (!m_pElement) {
- return;
- }
- FX_GetDateTimePattern(m_pElement, "datePattern", eType, wsPattern);
-}
-void CFX_Locale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
- if (!m_pElement) {
- return;
- }
- FX_GetDateTimePattern(m_pElement, "timePattern", eType, wsPattern);
-}
-void CFX_Locale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const {
- CFX_WideString wsType = g_FXLocaleNumSubCatData[eType].pName;
- FX_GetPattern(m_pElement, "numberPattern", wsType, wsPattern);
-}
+
static FX_BOOL FX_IsDigit(FX_WCHAR c) {
return c >= '0' && c <= '9';
}
@@ -1605,53 +1440,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
fValue = (FX_FLOAT)dbRetValue;
return TRUE;
}
-void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) {
- int32_t iCount = wsNum.GetLength();
- const FX_WCHAR* pStr = wsNum.c_str();
- FX_WCHAR* pDst = wsResult.GetBuffer(iCount);
- int32_t nIndex = 0;
- FX_BOOL bMinus = FALSE;
- int32_t i = 0;
- for (i = 0; i < iCount; i++) {
- FX_WCHAR wc = pStr[i];
- if (wc == '.') {
- break;
- }
- if ((wc == L'0' || wc == L' ' || wc == '+') && nIndex == 0) {
- continue;
- }
- if (wc == '-') {
- pDst[nIndex++] = wc;
- bMinus = TRUE;
- continue;
- }
- if (wc == L'0' && nIndex == 1 && bMinus) {
- continue;
- }
- pDst[nIndex++] = wc;
- }
- if (bMinus && nIndex == 1) {
- pDst[nIndex++] = '0';
- }
- if (nIndex == 0) {
- wsResult.ReleaseBuffer(0);
- pDst = wsResult.GetBuffer(iCount + 1);
- pDst[nIndex++] = '0';
- }
- int32_t j = 0;
- for (j = iCount - 1; j > i; j--) {
- FX_WCHAR wc = pStr[j];
- if (wc != L'0' && wc != L' ') {
- break;
- }
- }
- if (j > i) {
- pDst[nIndex++] = '.';
- FXSYS_wcsncpy(pDst + nIndex, pStr + i + 1, j - i);
- nIndex += j - i;
- }
- wsResult.ReleaseBuffer(nIndex);
-}
+
FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
const CFX_WideString& wsPattern,
CFX_WideString& wsValue) {
diff --git a/xfa/fgas/localization/fgas_locale.h b/xfa/fgas/localization/fgas_locale.h
index d1d862b0b5..3401d6ca5a 100644
--- a/xfa/fgas/localization/fgas_locale.h
+++ b/xfa/fgas/localization/fgas_locale.h
@@ -54,7 +54,6 @@ enum FX_DATETIMETYPE {
class IFX_Locale {
public:
- static IFX_Locale* Create(CXML_Element* pLocaleData);
virtual ~IFX_Locale() {}
virtual void Release() = 0;
@@ -92,9 +91,7 @@ class IFX_LocaleMgr {
virtual IFX_Locale* GetLocale(uint16_t lcid) = 0;
virtual IFX_Locale* GetLocaleByName(const CFX_WideString& wsLocaleName) = 0;
};
-IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
- uint16_t wDefaultLCID);
-void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult);
+
FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate,
CFX_Unitime& datetime);
FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
diff --git a/xfa/fgas/localization/fgas_localeimp.h b/xfa/fgas/localization/fgas_localeimp.h
index bbbdcb17e1..969fe6b625 100644
--- a/xfa/fgas/localization/fgas_localeimp.h
+++ b/xfa/fgas/localization/fgas_localeimp.h
@@ -11,39 +11,6 @@
class CFX_LCNumeric;
-class CFX_Locale : public IFX_Locale {
- public:
- CFX_Locale(CXML_Element* pLocaleData);
- virtual void Release() { delete this; }
-
- virtual CFX_WideString GetName();
- virtual void GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
- CFX_WideString& wsNumSymbol) const;
-
- virtual void GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const;
- virtual void GetMonthName(int32_t nMonth,
- CFX_WideString& wsMonthName,
- FX_BOOL bAbbr = TRUE) const;
- virtual void GetDayName(int32_t nWeek,
- CFX_WideString& wsDayName,
- FX_BOOL bAbbr = TRUE) const;
- virtual void GetMeridiemName(CFX_WideString& wsMeridiemName,
- FX_BOOL bAM = TRUE) const;
- virtual void GetTimeZone(FX_TIMEZONE& tz) const;
- virtual void GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD = TRUE) const;
-
- virtual void GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const;
- virtual void GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
- CFX_WideString& wsPattern) const;
- virtual void GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
- CFX_WideString& wsPattern) const;
-
- protected:
- virtual ~CFX_Locale();
- CXML_Element* m_pElement;
-};
-
class CFX_FormatString {
public:
CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);
diff --git a/xfa/fgas/localization/fgas_localemgr.cpp b/xfa/fgas/localization/fgas_localemgr.cpp
deleted file mode 100644
index e0ce8d9127..0000000000
--- a/xfa/fgas/localization/fgas_localemgr.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fgas/localization/fgas_localemgr.h"
-
-#include "core/fxcrt/include/fx_xml.h"
-
-IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
- uint16_t wDefaultLCID) {
- void* pPathHandle = FX_OpenFolder(pszLocalPath);
- if (!pPathHandle) {
- return NULL;
- }
- CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID);
- CFX_WideString wsFileName;
- FX_BOOL bFolder = FALSE;
- while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) {
- if (!bFolder) {
- if (wsFileName.GetLength() < 4) {
- continue;
- }
- CFX_WideString wsExt = wsFileName.Right(4);
- wsExt.MakeLower();
- if (wsExt != L".xml") {
- continue;
- }
- CFX_WideString wsFullPath(pszLocalPath);
- wsFullPath += L"\\" + wsFileName;
- IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath.c_str());
- if (!pRead) {
- continue;
- }
- CXML_Element* pXmlLocale = CXML_Element::Parse(pRead);
- pRead->Release();
- CFX_ByteString bssp = pXmlLocale->GetNamespace();
- if (bssp == "http://www.foxitsoftware.com/localization") {
- CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid");
- wchar_t* pEnd = NULL;
- uint32_t dwLCID = wcstol(wsLCID.c_str(), &pEnd, 16);
- if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) {
- delete pXmlLocale;
- } else {
- pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale);
- }
- } else {
- delete pXmlLocale;
- }
- }
- }
- FX_CloseFolder(pPathHandle);
- return pLocaleMgr;
-}
-CFX_LocaleMgr::CFX_LocaleMgr(uint16_t wDefLCID) : m_wDefLCID(wDefLCID) {}
-CFX_LocaleMgr::~CFX_LocaleMgr() {
- FX_POSITION ps = m_lcid2locale.GetStartPosition();
- while (ps) {
- void* plcid;
- IFX_Locale* pLocale = NULL;
- m_lcid2locale.GetNextAssoc(ps, plcid, (void*&)pLocale);
- pLocale->Release();
- }
- m_lcid2locale.RemoveAll();
- ps = m_lcid2xml.GetStartPosition();
- while (ps) {
- void* plcid;
- CXML_Element* pxml = NULL;
- m_lcid2xml.GetNextAssoc(ps, plcid, (void*&)pxml);
- delete pxml;
- }
- m_lcid2xml.RemoveAll();
-}
-uint16_t CFX_LocaleMgr::GetDefLocaleID() {
- return m_wDefLCID;
-}
-IFX_Locale* CFX_LocaleMgr::GetDefLocale() {
- return GetLocale(m_wDefLCID);
-}
-IFX_Locale* CFX_LocaleMgr::GetLocale(uint16_t lcid) {
- IFX_Locale* pLocale =
- (IFX_Locale*)m_lcid2locale.GetValueAt((void*)(uintptr_t)lcid);
- if (!pLocale) {
- CXML_Element* pxml =
- (CXML_Element*)m_lcid2xml.GetValueAt((void*)(uintptr_t)lcid);
- if (pxml) {
- pLocale = IFX_Locale::Create(pxml);
- m_lcid2locale.SetAt((void*)(uintptr_t)lcid, pLocale);
- }
- }
- return pLocale;
-}
-IFX_Locale* CFX_LocaleMgr::GetLocaleByName(const CFX_WideString& wsLocaleName) {
- return nullptr;
-}
diff --git a/xfa/fgas/localization/fgas_localemgr.h b/xfa/fgas/localization/fgas_localemgr.h
deleted file mode 100644
index d0ba90c9a8..0000000000
--- a/xfa/fgas/localization/fgas_localemgr.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_
-#define XFA_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_
-
-#include "xfa/fgas/localization/fgas_locale.h"
-
-class CFX_LocaleMgr : public IFX_LocaleMgr {
- public:
- CFX_LocaleMgr(uint16_t wDefLCID);
-
- void Release() override { delete this; }
- uint16_t GetDefLocaleID() override;
- IFX_Locale* GetDefLocale() override;
- IFX_Locale* GetLocale(uint16_t lcid) override;
- IFX_Locale* GetLocaleByName(const CFX_WideString& wsLocaleName) override;
-
- CFX_MapPtrToPtr m_lcid2xml;
-
- protected:
- ~CFX_LocaleMgr() override;
- CFX_MapPtrToPtr m_lcid2locale;
- uint16_t m_wDefLCID;
-};
-
-#endif // XFA_FGAS_LOCALIZATION_FGAS_LOCALEMGR_H_