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

Side by Side Diff: xfa/fxfa/parser/xfa_locale.cpp

Issue 2241863002: Clean up XFA locale and locale manager (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: const funcs Created 4 years, 4 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
OLDNEW
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/fxfa/parser/xfa_locale.h" 7 #include "xfa/fxfa/parser/xfa_locale.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "core/fxcrt/include/fx_xml.h" 11 #include "core/fxcrt/include/fx_xml.h"
12 #include "xfa/fxfa/parser/cxfa_document.h" 12 #include "xfa/fxfa/parser/cxfa_document.h"
13 #include "xfa/fxfa/parser/xfa_localemgr.h" 13 #include "xfa/fxfa/parser/xfa_localemgr.h"
14 #include "xfa/fxfa/parser/xfa_object.h" 14 #include "xfa/fxfa/parser/xfa_object.h"
15 #include "xfa/fxfa/parser/xfa_utils.h" 15 #include "xfa/fxfa/parser/xfa_utils.h"
16 16
17 static const FX_WCHAR g_FX_Percent[] = L"z,zzz,zzz,zzz,zzz,zzz%"; 17 static const FX_WCHAR g_FX_Percent[] = L"z,zzz,zzz,zzz,zzz,zzz%";
18 static const FX_WCHAR g_FX_Currency[] = L"$z,zzz,zzz,zzz,zzz,zz9.99"; 18 static const FX_WCHAR g_FX_Currency[] = L"$z,zzz,zzz,zzz,zzz,zz9.99";
19 static const FX_WCHAR g_FX_Decimal[] = L"z,zzz,zzz,zzz,zzz,zz9.zzz"; 19 static const FX_WCHAR g_FX_Decimal[] = L"z,zzz,zzz,zzz,zzz,zz9.zzz";
20 static const FX_WCHAR g_FX_Integer[] = L"z,zzz,zzz,zzz,zzz,zzz"; 20 static const FX_WCHAR g_FX_Integer[] = L"z,zzz,zzz,zzz,zzz,zzz";
21 21
22 CXFA_XMLLocale::CXFA_XMLLocale(std::unique_ptr<CXML_Element> pLocaleData) 22 CXFA_XMLLocale::CXFA_XMLLocale(std::unique_ptr<CXML_Element> pLocaleData)
23 : m_pLocaleData(std::move(pLocaleData)) {} 23 : m_pLocaleData(std::move(pLocaleData)) {}
24 24
25 CXFA_XMLLocale::~CXFA_XMLLocale() {} 25 CXFA_XMLLocale::~CXFA_XMLLocale() {}
26 26
27 void CXFA_XMLLocale::Release() { 27 CFX_WideString CXFA_XMLLocale::GetName() const {
28 delete this;
29 }
30
31 CFX_WideString CXFA_XMLLocale::GetName() {
32 return m_pLocaleData ? m_pLocaleData->GetAttrValue("name") : CFX_WideString(); 28 return m_pLocaleData ? m_pLocaleData->GetAttrValue("name") : CFX_WideString();
33 } 29 }
34 30
35 void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, 31 void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
36 CFX_WideString& wsNumSymbol) const { 32 CFX_WideString& wsNumSymbol) const {
37 CFX_ByteString bsSymbols; 33 CFX_ByteString bsSymbols;
38 CFX_WideString wsName; 34 CFX_WideString wsName;
39 switch (eType) { 35 switch (eType) {
40 case FX_LOCALENUMSYMBOL_Decimal: 36 case FX_LOCALENUMSYMBOL_Decimal:
41 bsSymbols = "numberSymbols"; 37 bsSymbols = "numberSymbols";
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 wsPattern = pChild->GetContent(0); 221 wsPattern = pChild->GetContent(0);
226 return; 222 return;
227 } 223 }
228 } 224 }
229 } 225 }
230 226
231 CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) : m_pLocale(pLocale) {} 227 CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) : m_pLocale(pLocale) {}
232 228
233 CXFA_NodeLocale::~CXFA_NodeLocale() {} 229 CXFA_NodeLocale::~CXFA_NodeLocale() {}
234 230
235 void CXFA_NodeLocale::Release() { 231 CFX_WideString CXFA_NodeLocale::GetName() const {
236 delete this;
237 }
238
239 CFX_WideString CXFA_NodeLocale::GetName() {
240 return CFX_WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name) 232 return CFX_WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name)
241 : nullptr); 233 : nullptr);
242 } 234 }
243 235
244 void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, 236 void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
245 CFX_WideString& wsNumSymbol) const { 237 CFX_WideString& wsNumSymbol) const {
246 switch (eType) { 238 switch (eType) {
247 case FX_LOCALENUMSYMBOL_Decimal: 239 case FX_LOCALENUMSYMBOL_Decimal:
248 wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"decimal")); 240 wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"decimal"));
249 break; 241 break;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); 386 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
395 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { 387 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
396 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { 388 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) {
397 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown); 389 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown);
398 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); 390 return pSymbol ? pSymbol->GetContent() : CFX_WideString();
399 } 391 }
400 } 392 }
401 } 393 }
402 return CFX_WideString(); 394 return CFX_WideString();
403 } 395 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698