| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fgas/localization/fgas_localemgr.h" | 7 #include "xfa/fgas/localization/fgas_localemgr.h" |
| 8 | 8 |
| 9 #include "core/include/fxcrt/fx_xml.h" | 9 #include "core/include/fxcrt/fx_xml.h" |
| 10 | 10 |
| 11 IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, | 11 IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, |
| 12 FX_WORD wDefaultLCID) { | 12 uint16_t wDefaultLCID) { |
| 13 void* pPathHandle = FX_OpenFolder(pszLocalPath); | 13 void* pPathHandle = FX_OpenFolder(pszLocalPath); |
| 14 if (!pPathHandle) { | 14 if (!pPathHandle) { |
| 15 return NULL; | 15 return NULL; |
| 16 } | 16 } |
| 17 CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID); | 17 CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID); |
| 18 CFX_WideString wsFileName; | 18 CFX_WideString wsFileName; |
| 19 FX_BOOL bFolder = FALSE; | 19 FX_BOOL bFolder = FALSE; |
| 20 while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) { | 20 while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) { |
| 21 if (!bFolder) { | 21 if (!bFolder) { |
| 22 if (wsFileName.GetLength() < 4) { | 22 if (wsFileName.GetLength() < 4) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale); | 46 pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale); |
| 47 } | 47 } |
| 48 } else { | 48 } else { |
| 49 delete pXmlLocale; | 49 delete pXmlLocale; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 FX_CloseFolder(pPathHandle); | 53 FX_CloseFolder(pPathHandle); |
| 54 return pLocaleMgr; | 54 return pLocaleMgr; |
| 55 } | 55 } |
| 56 CFX_LocaleMgr::CFX_LocaleMgr(FX_WORD wDefLCID) : m_wDefLCID(wDefLCID) {} | 56 CFX_LocaleMgr::CFX_LocaleMgr(uint16_t wDefLCID) : m_wDefLCID(wDefLCID) {} |
| 57 CFX_LocaleMgr::~CFX_LocaleMgr() { | 57 CFX_LocaleMgr::~CFX_LocaleMgr() { |
| 58 FX_POSITION ps = m_lcid2locale.GetStartPosition(); | 58 FX_POSITION ps = m_lcid2locale.GetStartPosition(); |
| 59 while (ps) { | 59 while (ps) { |
| 60 void* plcid; | 60 void* plcid; |
| 61 IFX_Locale* pLocale = NULL; | 61 IFX_Locale* pLocale = NULL; |
| 62 m_lcid2locale.GetNextAssoc(ps, plcid, (void*&)pLocale); | 62 m_lcid2locale.GetNextAssoc(ps, plcid, (void*&)pLocale); |
| 63 pLocale->Release(); | 63 pLocale->Release(); |
| 64 } | 64 } |
| 65 m_lcid2locale.RemoveAll(); | 65 m_lcid2locale.RemoveAll(); |
| 66 ps = m_lcid2xml.GetStartPosition(); | 66 ps = m_lcid2xml.GetStartPosition(); |
| 67 while (ps) { | 67 while (ps) { |
| 68 void* plcid; | 68 void* plcid; |
| 69 CXML_Element* pxml = NULL; | 69 CXML_Element* pxml = NULL; |
| 70 m_lcid2xml.GetNextAssoc(ps, plcid, (void*&)pxml); | 70 m_lcid2xml.GetNextAssoc(ps, plcid, (void*&)pxml); |
| 71 delete pxml; | 71 delete pxml; |
| 72 } | 72 } |
| 73 m_lcid2xml.RemoveAll(); | 73 m_lcid2xml.RemoveAll(); |
| 74 } | 74 } |
| 75 FX_WORD CFX_LocaleMgr::GetDefLocaleID() { | 75 uint16_t CFX_LocaleMgr::GetDefLocaleID() { |
| 76 return m_wDefLCID; | 76 return m_wDefLCID; |
| 77 } | 77 } |
| 78 IFX_Locale* CFX_LocaleMgr::GetDefLocale() { | 78 IFX_Locale* CFX_LocaleMgr::GetDefLocale() { |
| 79 return GetLocale(m_wDefLCID); | 79 return GetLocale(m_wDefLCID); |
| 80 } | 80 } |
| 81 IFX_Locale* CFX_LocaleMgr::GetLocale(FX_WORD lcid) { | 81 IFX_Locale* CFX_LocaleMgr::GetLocale(uint16_t lcid) { |
| 82 IFX_Locale* pLocale = | 82 IFX_Locale* pLocale = |
| 83 (IFX_Locale*)m_lcid2locale.GetValueAt((void*)(uintptr_t)lcid); | 83 (IFX_Locale*)m_lcid2locale.GetValueAt((void*)(uintptr_t)lcid); |
| 84 if (!pLocale) { | 84 if (!pLocale) { |
| 85 CXML_Element* pxml = | 85 CXML_Element* pxml = |
| 86 (CXML_Element*)m_lcid2xml.GetValueAt((void*)(uintptr_t)lcid); | 86 (CXML_Element*)m_lcid2xml.GetValueAt((void*)(uintptr_t)lcid); |
| 87 if (pxml) { | 87 if (pxml) { |
| 88 pLocale = IFX_Locale::Create(pxml); | 88 pLocale = IFX_Locale::Create(pxml); |
| 89 m_lcid2locale.SetAt((void*)(uintptr_t)lcid, pLocale); | 89 m_lcid2locale.SetAt((void*)(uintptr_t)lcid, pLocale); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 return pLocale; | 92 return pLocale; |
| 93 } | 93 } |
| 94 IFX_Locale* CFX_LocaleMgr::GetLocaleByName( | 94 IFX_Locale* CFX_LocaleMgr::GetLocaleByName( |
| 95 const CFX_WideStringC& wsLocaleName) { | 95 const CFX_WideStringC& wsLocaleName) { |
| 96 return NULL; | 96 return NULL; |
| 97 } | 97 } |
| OLD | NEW |