| 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/fxfa/parser/xfa_locale.h" | 7 #include "xfa/fxfa/parser/xfa_locale.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 CXML_Element* pNumberSymbols = | 81 CXML_Element* pNumberSymbols = |
| 82 m_pLocaleData->GetElement(bsSpace.AsStringC(), "dateTimeSymbols"); | 82 m_pLocaleData->GetElement(bsSpace.AsStringC(), "dateTimeSymbols"); |
| 83 if (!pNumberSymbols) { | 83 if (!pNumberSymbols) { |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 wsDtSymbol = pNumberSymbols->GetContent(0); | 86 wsDtSymbol = pNumberSymbols->GetContent(0); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CXFA_XMLLocale::GetMonthName(int32_t nMonth, | 89 void CXFA_XMLLocale::GetMonthName(int32_t nMonth, |
| 90 CFX_WideString& wsMonthName, | 90 CFX_WideString& wsMonthName, |
| 91 FX_BOOL bAbbr) const { | 91 bool bAbbr) const { |
| 92 wsMonthName = GetCalendarSymbol("month", nMonth, bAbbr); | 92 wsMonthName = GetCalendarSymbol("month", nMonth, bAbbr); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void CXFA_XMLLocale::GetDayName(int32_t nWeek, | 95 void CXFA_XMLLocale::GetDayName(int32_t nWeek, |
| 96 CFX_WideString& wsDayName, | 96 CFX_WideString& wsDayName, |
| 97 FX_BOOL bAbbr) const { | 97 bool bAbbr) const { |
| 98 wsDayName = GetCalendarSymbol("day", nWeek, bAbbr); | 98 wsDayName = GetCalendarSymbol("day", nWeek, bAbbr); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, | 101 void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, |
| 102 FX_BOOL bAM) const { | 102 bool bAM) const { |
| 103 wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, FALSE); | 103 wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, false); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE& tz) const { | 106 void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE& tz) const { |
| 107 CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); | 107 CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { | 110 void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, bool bAD) const { |
| 111 wsEraName = GetCalendarSymbol("era", bAD ? 1 : 0, FALSE); | 111 wsEraName = GetCalendarSymbol("era", bAD ? 1 : 0, false); |
| 112 } | 112 } |
| 113 | 113 |
| 114 CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol, | 114 CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol, |
| 115 int index, | 115 int index, |
| 116 FX_BOOL bAbbr) const { | 116 bool bAbbr) const { |
| 117 CFX_ByteString pstrSymbolNames = symbol + "Names"; | 117 CFX_ByteString pstrSymbolNames = symbol + "Names"; |
| 118 CFX_WideString wsSymbolName = L""; | 118 CFX_WideString wsSymbolName = L""; |
| 119 if (m_pLocaleData) { | 119 if (m_pLocaleData) { |
| 120 CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols"); | 120 CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols"); |
| 121 if (pChild) { | 121 if (pChild) { |
| 122 CXML_Element* pSymbolNames = | 122 CXML_Element* pSymbolNames = |
| 123 pChild->GetElement("", pstrSymbolNames.AsStringC()); | 123 pChild->GetElement("", pstrSymbolNames.AsStringC()); |
| 124 if (pSymbolNames) { | 124 if (pSymbolNames) { |
| 125 if ((!!pSymbolNames->GetAttrInteger("abbr")) != bAbbr) { | 125 if ((!!pSymbolNames->GetAttrInteger("abbr")) != bAbbr) { |
| 126 pSymbolNames = pChild->GetElement("", pstrSymbolNames.AsStringC(), 1); | 126 pSymbolNames = pChild->GetElement("", pstrSymbolNames.AsStringC(), 1); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { | 266 void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { |
| 267 CXFA_Node* pSymbols = | 267 CXFA_Node* pSymbols = |
| 268 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols) | 268 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols) |
| 269 : nullptr; | 269 : nullptr; |
| 270 wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); | 270 wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void CXFA_NodeLocale::GetMonthName(int32_t nMonth, | 273 void CXFA_NodeLocale::GetMonthName(int32_t nMonth, |
| 274 CFX_WideString& wsMonthName, | 274 CFX_WideString& wsMonthName, |
| 275 FX_BOOL bAbbr) const { | 275 bool bAbbr) const { |
| 276 wsMonthName = GetCalendarSymbol(XFA_Element::MonthNames, nMonth, bAbbr); | 276 wsMonthName = GetCalendarSymbol(XFA_Element::MonthNames, nMonth, bAbbr); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void CXFA_NodeLocale::GetDayName(int32_t nWeek, | 279 void CXFA_NodeLocale::GetDayName(int32_t nWeek, |
| 280 CFX_WideString& wsDayName, | 280 CFX_WideString& wsDayName, |
| 281 FX_BOOL bAbbr) const { | 281 bool bAbbr) const { |
| 282 wsDayName = GetCalendarSymbol(XFA_Element::DayNames, nWeek, bAbbr); | 282 wsDayName = GetCalendarSymbol(XFA_Element::DayNames, nWeek, bAbbr); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, | 285 void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, |
| 286 FX_BOOL bAM) const { | 286 bool bAM) const { |
| 287 wsMeridiemName = | 287 wsMeridiemName = |
| 288 GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, FALSE); | 288 GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, false); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const { | 291 void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const { |
| 292 CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); | 292 CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { | 295 void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, bool bAD) const { |
| 296 wsEraName = GetCalendarSymbol(XFA_Element::EraNames, bAD ? 1 : 0, FALSE); | 296 wsEraName = GetCalendarSymbol(XFA_Element::EraNames, bAD ? 1 : 0, false); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, | 299 void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, |
| 300 CFX_WideString& wsPattern) const { | 300 CFX_WideString& wsPattern) const { |
| 301 switch (eType) { | 301 switch (eType) { |
| 302 case FX_LOCALEDATETIMESUBCATEGORY_Short: | 302 case FX_LOCALEDATETIMESUBCATEGORY_Short: |
| 303 wsPattern = GetSymbol(XFA_Element::DatePatterns, FX_WSTRC(L"short")); | 303 wsPattern = GetSymbol(XFA_Element::DatePatterns, FX_WSTRC(L"short")); |
| 304 break; | 304 break; |
| 305 case FX_LOCALEDATETIMESUBCATEGORY_Medium: | 305 case FX_LOCALEDATETIMESUBCATEGORY_Medium: |
| 306 case FX_LOCALEDATETIMESUBCATEGORY_Default: | 306 case FX_LOCALEDATETIMESUBCATEGORY_Default: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 CFX_WideString CXFA_NodeLocale::GetSymbol( | 371 CFX_WideString CXFA_NodeLocale::GetSymbol( |
| 372 XFA_Element eElement, | 372 XFA_Element eElement, |
| 373 const CFX_WideStringC& symbol_type) const { | 373 const CFX_WideStringC& symbol_type) const { |
| 374 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr; | 374 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr; |
| 375 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); | 375 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); |
| 376 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); | 376 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, | 379 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, |
| 380 int index, | 380 int index, |
| 381 FX_BOOL bAbbr) const { | 381 bool bAbbr) const { |
| 382 CXFA_Node* pCalendar = | 382 CXFA_Node* pCalendar = |
| 383 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols) | 383 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols) |
| 384 : nullptr; | 384 : nullptr; |
| 385 if (pCalendar) { | 385 if (pCalendar) { |
| 386 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); | 386 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); |
| 387 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { | 387 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { |
| 388 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { | 388 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { |
| 389 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown); | 389 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown); |
| 390 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); | 390 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 return CFX_WideString(); | 394 return CFX_WideString(); |
| 395 } | 395 } |
| OLD | NEW |