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: |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 wsPattern = g_FX_Decimal; | 333 wsPattern = g_FX_Decimal; |
334 break; | 334 break; |
335 case FX_LOCALENUMPATTERN_Integer: | 335 case FX_LOCALENUMPATTERN_Integer: |
336 wsPattern = g_FX_Integer; | 336 wsPattern = g_FX_Integer; |
337 break; | 337 break; |
338 } | 338 } |
339 } | 339 } |
340 CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, | 340 CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, |
341 const CFX_WideStringC& wsName) const { | 341 const CFX_WideStringC& wsName) const { |
342 CXFA_Node* pChild = | 342 CXFA_Node* pChild = |
343 pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; | 343 pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr; |
344 while (pChild) { | 344 while (pChild) { |
345 CFX_WideString wsChild; | 345 CFX_WideString wsChild; |
346 if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { | 346 if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) { |
347 if (wsChild == wsName) { | 347 if (wsChild == wsName) { |
348 return pChild; | 348 return pChild; |
349 } | 349 } |
350 } | 350 } |
351 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 351 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); |
352 } | 352 } |
353 return NULL; | 353 return nullptr; |
354 } | 354 } |
355 CFX_WideString CXFA_NodeLocale::GetSymbol( | 355 CFX_WideString CXFA_NodeLocale::GetSymbol( |
356 XFA_Element eElement, | 356 XFA_Element eElement, |
357 const CFX_WideStringC& symbol_type) const { | 357 const CFX_WideStringC& symbol_type) const { |
358 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr; | 358 CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr; |
359 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); | 359 CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); |
360 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); | 360 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); |
361 } | 361 } |
362 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, | 362 CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, |
363 int index, | 363 int index, |
364 FX_BOOL bAbbr) const { | 364 FX_BOOL bAbbr) const { |
365 CXFA_Node* pCalendar = | 365 CXFA_Node* pCalendar = |
366 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols) | 366 m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols) |
367 : nullptr; | 367 : nullptr; |
368 if (pCalendar) { | 368 if (pCalendar) { |
369 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); | 369 CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); |
370 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { | 370 for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { |
371 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { | 371 if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) { |
372 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown); | 372 CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown); |
373 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); | 373 return pSymbol ? pSymbol->GetContent() : CFX_WideString(); |
374 } | 374 } |
375 } | 375 } |
376 } | 376 } |
377 return CFX_WideString(); | 377 return CFX_WideString(); |
378 } | 378 } |
OLD | NEW |