Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: xfa/src/fgas/localization/fgas_localemgr.cpp

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fgas/localization/fgas_localemgr.h ('k') | xfa/src/fgas/xml/fgas_sax.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "xfa/src/fgas/localization/fgas_localemgr.h"
8
9 #include "core/include/fxcrt/fx_xml.h"
10
11 IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
12 FX_WORD wDefaultLCID) {
13 void* pPathHandle = FX_OpenFolder(pszLocalPath);
14 if (!pPathHandle) {
15 return NULL;
16 }
17 CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID);
18 CFX_WideString wsFileName;
19 FX_BOOL bFolder = FALSE;
20 while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) {
21 if (!bFolder) {
22 if (wsFileName.GetLength() < 4) {
23 continue;
24 }
25 CFX_WideString wsExt = wsFileName.Right(4);
26 wsExt.MakeLower();
27 if (wsExt != L".xml") {
28 continue;
29 }
30 CFX_WideString wsFullPath(pszLocalPath);
31 wsFullPath += L"\\" + wsFileName;
32 IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath);
33 if (!pRead) {
34 continue;
35 }
36 CXML_Element* pXmlLocale = CXML_Element::Parse(pRead);
37 pRead->Release();
38 CFX_ByteString bssp = pXmlLocale->GetNamespace();
39 if (bssp == "http://www.foxitsoftware.com/localization") {
40 CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid");
41 wchar_t* pEnd = NULL;
42 FX_DWORD dwLCID = wcstol(wsLCID, &pEnd, 16);
43 if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) {
44 delete pXmlLocale;
45 } else {
46 pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale);
47 }
48 } else {
49 delete pXmlLocale;
50 }
51 }
52 }
53 FX_CloseFolder(pPathHandle);
54 return pLocaleMgr;
55 }
56 CFX_LocaleMgr::CFX_LocaleMgr(FX_WORD wDefLCID) : m_wDefLCID(wDefLCID) {}
57 CFX_LocaleMgr::~CFX_LocaleMgr() {
58 FX_POSITION ps = m_lcid2locale.GetStartPosition();
59 while (ps) {
60 void* plcid;
61 IFX_Locale* pLocale = NULL;
62 m_lcid2locale.GetNextAssoc(ps, plcid, (void*&)pLocale);
63 pLocale->Release();
64 }
65 m_lcid2locale.RemoveAll();
66 ps = m_lcid2xml.GetStartPosition();
67 while (ps) {
68 void* plcid;
69 CXML_Element* pxml = NULL;
70 m_lcid2xml.GetNextAssoc(ps, plcid, (void*&)pxml);
71 delete pxml;
72 }
73 m_lcid2xml.RemoveAll();
74 }
75 FX_WORD CFX_LocaleMgr::GetDefLocaleID() {
76 return m_wDefLCID;
77 }
78 IFX_Locale* CFX_LocaleMgr::GetDefLocale() {
79 return GetLocale(m_wDefLCID);
80 }
81 IFX_Locale* CFX_LocaleMgr::GetLocale(FX_WORD lcid) {
82 IFX_Locale* pLocale =
83 (IFX_Locale*)m_lcid2locale.GetValueAt((void*)(uintptr_t)lcid);
84 if (!pLocale) {
85 CXML_Element* pxml =
86 (CXML_Element*)m_lcid2xml.GetValueAt((void*)(uintptr_t)lcid);
87 if (pxml) {
88 pLocale = IFX_Locale::Create(pxml);
89 m_lcid2locale.SetAt((void*)(uintptr_t)lcid, pLocale);
90 }
91 }
92 return pLocale;
93 }
94 IFX_Locale* CFX_LocaleMgr::GetLocaleByName(
95 const CFX_WideStringC& wsLocaleName) {
96 return NULL;
97 }
OLDNEW
« no previous file with comments | « xfa/src/fgas/localization/fgas_localemgr.h ('k') | xfa/src/fgas/xml/fgas_sax.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698