| 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 "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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 return wsSymbolName; | 136 return wsSymbolName; |
| 137 } | 137 } |
| 138 void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, | 138 void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, |
| 139 CFX_WideString& wsPattern) const { | 139 CFX_WideString& wsPattern) const { |
| 140 CXML_Element* pElement = m_pLocaleData->GetElement("", "datePatterns"); | 140 CXML_Element* pElement = m_pLocaleData->GetElement("", "datePatterns"); |
| 141 if (pElement == NULL) { | 141 if (!pElement) |
| 142 return; | 142 return; |
| 143 } | 143 |
| 144 CFX_WideString wsName; | 144 CFX_WideString wsName; |
| 145 switch (eType) { | 145 switch (eType) { |
| 146 case FX_LOCALEDATETIMESUBCATEGORY_Short: | 146 case FX_LOCALEDATETIMESUBCATEGORY_Short: |
| 147 wsName = L"short"; | 147 wsName = L"short"; |
| 148 break; | 148 break; |
| 149 case FX_LOCALEDATETIMESUBCATEGORY_Default: | 149 case FX_LOCALEDATETIMESUBCATEGORY_Default: |
| 150 case FX_LOCALEDATETIMESUBCATEGORY_Medium: | 150 case FX_LOCALEDATETIMESUBCATEGORY_Medium: |
| 151 wsName = L"med"; | 151 wsName = L"med"; |
| 152 break; | 152 break; |
| 153 case FX_LOCALEDATETIMESUBCATEGORY_Full: | 153 case FX_LOCALEDATETIMESUBCATEGORY_Full: |
| 154 wsName = L"full"; | 154 wsName = L"full"; |
| 155 break; | 155 break; |
| 156 case FX_LOCALEDATETIMESUBCATEGORY_Long: | 156 case FX_LOCALEDATETIMESUBCATEGORY_Long: |
| 157 wsName = L"long"; | 157 wsName = L"long"; |
| 158 break; | 158 break; |
| 159 } | 159 } |
| 160 GetPattern(pElement, "datePattern", wsName.AsStringC(), wsPattern); | 160 GetPattern(pElement, "datePattern", wsName.AsStringC(), wsPattern); |
| 161 } | 161 } |
| 162 void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, | 162 void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, |
| 163 CFX_WideString& wsPattern) const { | 163 CFX_WideString& wsPattern) const { |
| 164 CXML_Element* pElement = m_pLocaleData->GetElement("", "timePatterns"); | 164 CXML_Element* pElement = m_pLocaleData->GetElement("", "timePatterns"); |
| 165 if (pElement == NULL) { | 165 if (!pElement) |
| 166 return; | 166 return; |
| 167 } | 167 |
| 168 CFX_WideString wsName; | 168 CFX_WideString wsName; |
| 169 switch (eType) { | 169 switch (eType) { |
| 170 case FX_LOCALEDATETIMESUBCATEGORY_Short: | 170 case FX_LOCALEDATETIMESUBCATEGORY_Short: |
| 171 wsName = L"short"; | 171 wsName = L"short"; |
| 172 break; | 172 break; |
| 173 case FX_LOCALEDATETIMESUBCATEGORY_Default: | 173 case FX_LOCALEDATETIMESUBCATEGORY_Default: |
| 174 case FX_LOCALEDATETIMESUBCATEGORY_Medium: | 174 case FX_LOCALEDATETIMESUBCATEGORY_Medium: |
| 175 wsName = L"med"; | 175 wsName = L"med"; |
| 176 break; | 176 break; |
| 177 case FX_LOCALEDATETIMESUBCATEGORY_Full: | 177 case FX_LOCALEDATETIMESUBCATEGORY_Full: |
| 178 wsName = L"full"; | 178 wsName = L"full"; |
| 179 break; | 179 break; |
| 180 case FX_LOCALEDATETIMESUBCATEGORY_Long: | 180 case FX_LOCALEDATETIMESUBCATEGORY_Long: |
| 181 wsName = L"long"; | 181 wsName = L"long"; |
| 182 break; | 182 break; |
| 183 } | 183 } |
| 184 GetPattern(pElement, "timePattern", wsName.AsStringC(), wsPattern); | 184 GetPattern(pElement, "timePattern", wsName.AsStringC(), wsPattern); |
| 185 } | 185 } |
| 186 void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, | 186 void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, |
| 187 CFX_WideString& wsPattern) const { | 187 CFX_WideString& wsPattern) const { |
| 188 CXML_Element* pElement = m_pLocaleData->GetElement("", "numberPatterns"); | 188 CXML_Element* pElement = m_pLocaleData->GetElement("", "numberPatterns"); |
| 189 if (pElement == NULL) { | 189 if (!pElement) |
| 190 return; | 190 return; |
| 191 } | 191 |
| 192 switch (eType) { | 192 switch (eType) { |
| 193 case FX_LOCALENUMPATTERN_Percent: | 193 case FX_LOCALENUMPATTERN_Percent: |
| 194 wsPattern = g_FX_Percent; | 194 wsPattern = g_FX_Percent; |
| 195 break; | 195 break; |
| 196 case FX_LOCALENUMPATTERN_Currency: | 196 case FX_LOCALENUMPATTERN_Currency: |
| 197 wsPattern = g_FX_Currency; | 197 wsPattern = g_FX_Currency; |
| 198 break; | 198 break; |
| 199 case FX_LOCALENUMPATTERN_Decimal: | 199 case FX_LOCALENUMPATTERN_Decimal: |
| 200 wsPattern = g_FX_Decimal; | 200 wsPattern = g_FX_Decimal; |
| 201 break; | 201 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 wsNumSymbol = GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"symbol")); | 250 wsNumSymbol = GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"symbol")); |
| 251 break; | 251 break; |
| 252 case FX_LOCALENUMSYMBOL_CurrencyName: | 252 case FX_LOCALENUMSYMBOL_CurrencyName: |
| 253 wsNumSymbol = | 253 wsNumSymbol = |
| 254 GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"isoname")); | 254 GetSymbol(XFA_ELEMENT_CurrencySymbols, FX_WSTRC(L"isoname")); |
| 255 break; | 255 break; |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { | 258 void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { |
| 259 CXFA_Node* pSymbols = | 259 CXFA_Node* pSymbols = |
| 260 m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_DateTimeSymbols) : NULL; | 260 m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_DateTimeSymbols) : nullptr; |
| 261 wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); | 261 wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); |
| 262 } | 262 } |
| 263 void CXFA_NodeLocale::GetMonthName(int32_t nMonth, | 263 void CXFA_NodeLocale::GetMonthName(int32_t nMonth, |
| 264 CFX_WideString& wsMonthName, | 264 CFX_WideString& wsMonthName, |
| 265 FX_BOOL bAbbr) const { | 265 FX_BOOL bAbbr) const { |
| 266 wsMonthName = GetCalendarSymbol(XFA_ELEMENT_MonthNames, nMonth, bAbbr); | 266 wsMonthName = GetCalendarSymbol(XFA_ELEMENT_MonthNames, nMonth, bAbbr); |
| 267 } | 267 } |
| 268 void CXFA_NodeLocale::GetDayName(int32_t nWeek, | 268 void CXFA_NodeLocale::GetDayName(int32_t nWeek, |
| 269 CFX_WideString& wsDayName, | 269 CFX_WideString& wsDayName, |
| 270 FX_BOOL bAbbr) const { | 270 FX_BOOL bAbbr) const { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 wsPattern = g_FX_Decimal; | 330 wsPattern = g_FX_Decimal; |
| 331 break; | 331 break; |
| 332 case FX_LOCALENUMPATTERN_Integer: | 332 case FX_LOCALENUMPATTERN_Integer: |
| 333 wsPattern = g_FX_Integer; | 333 wsPattern = g_FX_Integer; |
| 334 break; | 334 break; |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, | 337 CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, |
| 338 const CFX_WideStringC& wsName) const { | 338 const CFX_WideStringC& wsName) const { |
| 339 CXFA_Node* pChild = | 339 CXFA_Node* pChild = |
| 340 pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; | 340 pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr; |
| 341 while (pChild) { | 341 while (pChild) { |
| 342 CFX_WideString wsChild; | 342 CFX_WideString wsChild; |
| 343 if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { | 343 if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { |
| 344 if (wsChild == wsName) { | 344 if (wsChild == wsName) { |
| 345 return pChild; | 345 return pChild; |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 348 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 349 } | 349 } |
| 350 return NULL; | 350 return nullptr; |
| 351 } | 351 } |
| 352 CFX_WideString CXFA_NodeLocale::GetSymbol( | 352 CFX_WideString CXFA_NodeLocale::GetSymbol( |
| 353 XFA_ELEMENT eElement, | 353 XFA_ELEMENT eElement, |
| 354 const CFX_WideStringC& symbol_type) const { | 354 const CFX_WideStringC& symbol_type) const { |
| 355 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : NULL; | 355 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr; |
| 356 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); | 356 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); |
| 357 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); | 357 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); |
| 358 } | 358 } |
| 359 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_ELEMENT eElement, | 359 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_ELEMENT eElement, |
| 360 int index, | 360 int index, |
| 361 FX_BOOL bAbbr) const { | 361 FX_BOOL bAbbr) const { |
| 362 CXFA_Node* pCalendar = | 362 CXFA_Node* pCalendar = |
| 363 m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_CalendarSymbols) : NULL; | 363 m_pLocale ? m_pLocale->GetChild(0, XFA_ELEMENT_CalendarSymbols) : nullptr; |
| 364 if (pCalendar) { | 364 if (pCalendar) { |
| 365 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); | 365 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); |
| 366 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { | 366 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { |
| 367 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { | 367 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { |
| 368 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_ELEMENT_UNKNOWN); | 368 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_ELEMENT_UNKNOWN); |
| 369 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); | 369 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 return CFX_WideString(); | 373 return CFX_WideString(); |
| 374 } | 374 } |
| OLD | NEW |