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

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

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks Created 4 years, 6 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/fxfa/parser/xfa_locale.h ('k') | xfa/fxfa/parser/xfa_localemgr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "core/fxcrt/include/fx_xml.h" 9 #include "core/fxcrt/include/fx_xml.h"
10 #include "xfa/fxfa/parser/xfa_doclayout.h" 10 #include "xfa/fxfa/parser/xfa_doclayout.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 delete this; 225 delete this;
226 } 226 }
227 CFX_WideString CXFA_NodeLocale::GetName() { 227 CFX_WideString CXFA_NodeLocale::GetName() {
228 return CFX_WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name) 228 return CFX_WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name)
229 : nullptr); 229 : nullptr);
230 } 230 }
231 void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, 231 void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
232 CFX_WideString& wsNumSymbol) const { 232 CFX_WideString& wsNumSymbol) const {
233 switch (eType) { 233 switch (eType) {
234 case FX_LOCALENUMSYMBOL_Decimal: 234 case FX_LOCALENUMSYMBOL_Decimal:
235 wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"decimal")); 235 wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"decimal"));
236 break; 236 break;
237 case FX_LOCALENUMSYMBOL_Grouping: 237 case FX_LOCALENUMSYMBOL_Grouping:
238 wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"grouping")); 238 wsNumSymbol =
239 GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"grouping"));
239 break; 240 break;
240 case FX_LOCALENUMSYMBOL_Percent: 241 case FX_LOCALENUMSYMBOL_Percent:
241 wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"percent")); 242 wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"percent"));
242 break; 243 break;
243 case FX_LOCALENUMSYMBOL_Minus: 244 case FX_LOCALENUMSYMBOL_Minus:
244 wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"minus")); 245 wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"minus"));
245 break; 246 break;
246 case FX_LOCALENUMSYMBOL_Zero: 247 case FX_LOCALENUMSYMBOL_Zero:
247 wsNumSymbol = GetSymbol(XFA_ELEMENT_NumberSymbols, FX_WSTRC(L"zero")); 248 wsNumSymbol = GetSymbol(XFA_Element::NumberSymbols, FX_WSTRC(L"zero"));
248 break; 249 break;
249 case FX_LOCALENUMSYMBOL_CurrencySymbol: 250 case FX_LOCALENUMSYMBOL_CurrencySymbol:
250 wsNumSymbol = GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"symbol")); 251 wsNumSymbol =
252 GetSymbol(XFA_Element::CurrencySymbols, FX_WSTRC(L"symbol"));
251 break; 253 break;
252 case FX_LOCALENUMSYMBOL_CurrencyName: 254 case FX_LOCALENUMSYMBOL_CurrencyName:
253 wsNumSymbol = 255 wsNumSymbol =
254 GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"isoname")); 256 GetSymbol(XFA_Element::CurrencySymbols, FX_WSTRC(L"isoname"));
255 break; 257 break;
256 } 258 }
257 } 259 }
258 void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { 260 void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
259 CXFA_Node* pSymbols = 261 CXFA_Node* pSymbols =
260 m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_DateTimeSymbols) : NULL; 262 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols)
263 : nullptr;
261 wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); 264 wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString();
262 } 265 }
263 void CXFA_NodeLocale::GetMonthName(int32_t nMonth, 266 void CXFA_NodeLocale::GetMonthName(int32_t nMonth,
264 CFX_WideString& wsMonthName, 267 CFX_WideString& wsMonthName,
265 FX_BOOL bAbbr) const { 268 FX_BOOL bAbbr) const {
266 wsMonthName = GetCalendarSymbol(XFA_ELEMENT_MonthNames, nMonth, bAbbr); 269 wsMonthName = GetCalendarSymbol(XFA_Element::MonthNames, nMonth, bAbbr);
267 } 270 }
268 void CXFA_NodeLocale::GetDayName(int32_t nWeek, 271 void CXFA_NodeLocale::GetDayName(int32_t nWeek,
269 CFX_WideString& wsDayName, 272 CFX_WideString& wsDayName,
270 FX_BOOL bAbbr) const { 273 FX_BOOL bAbbr) const {
271 wsDayName = GetCalendarSymbol(XFA_ELEMENT_DayNames, nWeek, bAbbr); 274 wsDayName = GetCalendarSymbol(XFA_Element::DayNames, nWeek, bAbbr);
272 } 275 }
273 void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, 276 void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName,
274 FX_BOOL bAM) const { 277 FX_BOOL bAM) const {
275 wsMeridiemName = 278 wsMeridiemName =
276 GetCalendarSymbol(XFA_ELEMENT_MeridiemNames, bAM ? 0 : 1, FALSE); 279 GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, FALSE);
277 } 280 }
278 void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const { 281 void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const {
279 CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); 282 CXFA_TimeZoneProvider::Get()->GetTimeZone(tz);
280 } 283 }
281 void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { 284 void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const {
282 wsEraName = GetCalendarSymbol(XFA_ELEMENT_EraNames, bAD ? 1 : 0, FALSE); 285 wsEraName = GetCalendarSymbol(XFA_Element::EraNames, bAD ? 1 : 0, FALSE);
283 } 286 }
284 void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, 287 void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
285 CFX_WideString& wsPattern) const { 288 CFX_WideString& wsPattern) const {
286 switch (eType) { 289 switch (eType) {
287 case FX_LOCALEDATETIMESUBCATEGORY_Short: 290 case FX_LOCALEDATETIMESUBCATEGORY_Short:
288 wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"short")); 291 wsPattern = GetSymbol(XFA_Element::DatePatterns, FX_WSTRC(L"short"));
289 break; 292 break;
290 case FX_LOCALEDATETIMESUBCATEGORY_Medium: 293 case FX_LOCALEDATETIMESUBCATEGORY_Medium:
291 case FX_LOCALEDATETIMESUBCATEGORY_Default: 294 case FX_LOCALEDATETIMESUBCATEGORY_Default:
292 wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"med")); 295 wsPattern = GetSymbol(XFA_Element::DatePatterns, FX_WSTRC(L"med"));
293 break; 296 break;
294 case FX_LOCALEDATETIMESUBCATEGORY_Full: 297 case FX_LOCALEDATETIMESUBCATEGORY_Full:
295 wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"full")); 298 wsPattern = GetSymbol(XFA_Element::DatePatterns, FX_WSTRC(L"full"));
296 break; 299 break;
297 case FX_LOCALEDATETIMESUBCATEGORY_Long: 300 case FX_LOCALEDATETIMESUBCATEGORY_Long:
298 wsPattern = GetSymbol(XFA_ELEMENT_DatePatterns, FX_WSTRC(L"long")); 301 wsPattern = GetSymbol(XFA_Element::DatePatterns, FX_WSTRC(L"long"));
299 break; 302 break;
300 } 303 }
301 } 304 }
302 void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, 305 void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
303 CFX_WideString& wsPattern) const { 306 CFX_WideString& wsPattern) const {
304 switch (eType) { 307 switch (eType) {
305 case FX_LOCALEDATETIMESUBCATEGORY_Short: 308 case FX_LOCALEDATETIMESUBCATEGORY_Short:
306 wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"short")); 309 wsPattern = GetSymbol(XFA_Element::TimePatterns, FX_WSTRC(L"short"));
307 break; 310 break;
308 case FX_LOCALEDATETIMESUBCATEGORY_Medium: 311 case FX_LOCALEDATETIMESUBCATEGORY_Medium:
309 case FX_LOCALEDATETIMESUBCATEGORY_Default: 312 case FX_LOCALEDATETIMESUBCATEGORY_Default:
310 wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"med")); 313 wsPattern = GetSymbol(XFA_Element::TimePatterns, FX_WSTRC(L"med"));
311 break; 314 break;
312 case FX_LOCALEDATETIMESUBCATEGORY_Full: 315 case FX_LOCALEDATETIMESUBCATEGORY_Full:
313 wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"full")); 316 wsPattern = GetSymbol(XFA_Element::TimePatterns, FX_WSTRC(L"full"));
314 break; 317 break;
315 case FX_LOCALEDATETIMESUBCATEGORY_Long: 318 case FX_LOCALEDATETIMESUBCATEGORY_Long:
316 wsPattern = GetSymbol(XFA_ELEMENT_TimePatterns, FX_WSTRC(L"long")); 319 wsPattern = GetSymbol(XFA_Element::TimePatterns, FX_WSTRC(L"long"));
317 break; 320 break;
318 } 321 }
319 } 322 }
320 void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, 323 void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
321 CFX_WideString& wsPattern) const { 324 CFX_WideString& wsPattern) const {
322 switch (eType) { 325 switch (eType) {
323 case FX_LOCALENUMPATTERN_Percent: 326 case FX_LOCALENUMPATTERN_Percent:
324 wsPattern = g_FX_Percent; 327 wsPattern = g_FX_Percent;
325 break; 328 break;
326 case FX_LOCALENUMPATTERN_Currency: 329 case FX_LOCALENUMPATTERN_Currency:
(...skipping 16 matching lines...) Expand all
343 if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { 346 if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) {
344 if (wsChild == wsName) { 347 if (wsChild == wsName) {
345 return pChild; 348 return pChild;
346 } 349 }
347 } 350 }
348 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); 351 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
349 } 352 }
350 return NULL; 353 return NULL;
351 } 354 }
352 CFX_WideString CXFA_NodeLocale::GetSymbol( 355 CFX_WideString CXFA_NodeLocale::GetSymbol(
353 XFA_ELEMENT eElement, 356 XFA_Element eElement,
354 const CFX_WideStringC& symbol_type) const { 357 const CFX_WideStringC& symbol_type) const {
355 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : NULL; 358 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr;
356 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); 359 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type);
357 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); 360 return pSymbol ? pSymbol->GetContent() : CFX_WideString();
358 } 361 }
359 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_ELEMENT eElement, 362 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
360 int index, 363 int index,
361 FX_BOOL bAbbr) const { 364 FX_BOOL bAbbr) const {
362 CXFA_Node* pCalendar = 365 CXFA_Node* pCalendar =
363 m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_CalendarSymbols) : NULL; 366 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols)
367 : nullptr;
364 if (pCalendar) { 368 if (pCalendar) {
365 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); 369 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
366 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { 370 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
367 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { 371 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) {
368 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_ELEMENT_UNKNOWN); 372 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown);
369 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); 373 return pSymbol ? pSymbol->GetContent() : CFX_WideString();
370 } 374 }
371 } 375 }
372 } 376 }
373 return CFX_WideString(); 377 return CFX_WideString();
374 } 378 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_locale.h ('k') | xfa/fxfa/parser/xfa_localemgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698