| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "core/fxcrt/include/fx_xml.h" | 10 #include "core/fxcrt/include/fx_xml.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return CFX_WideString(); | 87 return CFX_WideString(); |
| 88 } | 88 } |
| 89 static CFX_WideString FX_GetXMLContent(const CFX_ByteStringC& bsSpace, | 89 static CFX_WideString FX_GetXMLContent(const CFX_ByteStringC& bsSpace, |
| 90 CXML_Element* pxmlElement, | 90 CXML_Element* pxmlElement, |
| 91 const CFX_ByteStringC& bsTag, | 91 const CFX_ByteStringC& bsTag, |
| 92 const CFX_WideStringC& wsName) { | 92 const CFX_WideStringC& wsName) { |
| 93 CXML_Element* pDatePattern = NULL; | 93 CXML_Element* pDatePattern = NULL; |
| 94 int32_t nCount = pxmlElement->CountElements(bsSpace, bsTag); | 94 int32_t nCount = pxmlElement->CountElements(bsSpace, bsTag); |
| 95 int32_t i = 0; | 95 int32_t i = 0; |
| 96 for (; i < nCount; i++) { | 96 for (; i < nCount; i++) { |
| 97 pDatePattern = pxmlElement->GetElement(bsSpace, bsTag, i); | 97 pDatePattern = pxmlElement->GetObjectBy(bsSpace, bsTag, i); |
| 98 if (pDatePattern->GetAttrValue("name") == wsName) { | 98 if (pDatePattern->GetAttrValue("name") == wsName) { |
| 99 break; | 99 break; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 if (i < nCount && pDatePattern) { | 102 if (i < nCount && pDatePattern) { |
| 103 return pDatePattern->GetContent(0); | 103 return pDatePattern->GetContent(0); |
| 104 } | 104 } |
| 105 return L""; | 105 return L""; |
| 106 } | 106 } |
| 107 void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, | 107 void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, |
| 108 CFX_WideString& wsNumSymbol) const { | 108 CFX_WideString& wsNumSymbol) const { |
| 109 if (!m_pElement) { | 109 if (!m_pElement) { |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 CFX_ByteString bsSpace; | 112 CFX_ByteString bsSpace; |
| 113 CFX_WideString wsName = gs_LocalNumberSymbols[eType]; | 113 CFX_WideString wsName = gs_LocalNumberSymbols[eType]; |
| 114 CXML_Element* pNumberSymbols = | 114 CXML_Element* pNumberSymbols = |
| 115 m_pElement->GetElement(bsSpace, "numberSymbols"); | 115 m_pElement->GetObjectBy(bsSpace, "numberSymbols"); |
| 116 if (!pNumberSymbols) { | 116 if (!pNumberSymbols) { |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 wsNumSymbol = | 119 wsNumSymbol = |
| 120 FX_GetXMLContent(bsSpace, pNumberSymbols, "numberSymbol", wsName); | 120 FX_GetXMLContent(bsSpace, pNumberSymbols, "numberSymbol", wsName); |
| 121 } | 121 } |
| 122 void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { | 122 void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { |
| 123 if (!m_pElement) { | 123 if (!m_pElement) { |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 CFX_ByteString bsSpace; | 126 CFX_ByteString bsSpace; |
| 127 CXML_Element* pNumberSymbols = | 127 CXML_Element* pNumberSymbols = |
| 128 m_pElement->GetElement(bsSpace, "dateTimeSymbols"); | 128 m_pElement->GetObjectBy(bsSpace, "dateTimeSymbols"); |
| 129 if (!pNumberSymbols) { | 129 if (!pNumberSymbols) { |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 wsDtSymbol = pNumberSymbols->GetContent(0); | 132 wsDtSymbol = pNumberSymbols->GetContent(0); |
| 133 } | 133 } |
| 134 static void FX_GetCalendarSymbol(CXML_Element* pXmlElement, | 134 static void FX_GetCalendarSymbol(CXML_Element* pXmlElement, |
| 135 const CFX_ByteString& symbol_type, | 135 const CFX_ByteString& symbol_type, |
| 136 int32_t index, | 136 int32_t index, |
| 137 FX_BOOL bAbbr, | 137 FX_BOOL bAbbr, |
| 138 CFX_WideString& wsName) { | 138 CFX_WideString& wsName) { |
| 139 CFX_ByteString bsSpace; | 139 CFX_ByteString bsSpace; |
| 140 CFX_ByteString pstrSymbolNames = symbol_type + "Names"; | 140 CFX_ByteString pstrSymbolNames = symbol_type + "Names"; |
| 141 CXML_Element* pChild = pXmlElement->GetElement(bsSpace, "calendarSymbols"); | 141 CXML_Element* pChild = pXmlElement->GetObjectBy(bsSpace, "calendarSymbols"); |
| 142 if (!pChild) { | 142 if (!pChild) { |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 CXML_Element* pSymbolNames = pChild->GetElement(bsSpace, pstrSymbolNames); | 145 CXML_Element* pSymbolNames = pChild->GetObjectBy(bsSpace, pstrSymbolNames); |
| 146 if (!pSymbolNames) { | 146 if (!pSymbolNames) { |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { | 149 if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { |
| 150 pSymbolNames = pChild->GetElement(bsSpace, pstrSymbolNames, 1); | 150 pSymbolNames = pChild->GetObjectBy(bsSpace, pstrSymbolNames, 1); |
| 151 } | 151 } |
| 152 if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { | 152 if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { |
| 153 CXML_Element* pSymbolName = | 153 CXML_Element* pSymbolName = |
| 154 pSymbolNames->GetElement(bsSpace, symbol_type, index); | 154 pSymbolNames->GetObjectBy(bsSpace, symbol_type, index); |
| 155 if (pSymbolName) { | 155 if (pSymbolName) { |
| 156 wsName = pSymbolName->GetContent(0); | 156 wsName = pSymbolName->GetContent(0); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 void CFX_Locale::GetMonthName(int32_t nMonth, | 160 void CFX_Locale::GetMonthName(int32_t nMonth, |
| 161 CFX_WideString& wsMonthName, | 161 CFX_WideString& wsMonthName, |
| 162 FX_BOOL bAbbr) const { | 162 FX_BOOL bAbbr) const { |
| 163 if (!m_pElement) { | 163 if (!m_pElement) { |
| 164 return; | 164 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 tz.tzHour = -tz.tzHour; | 205 tz.tzHour = -tz.tzHour; |
| 206 } | 206 } |
| 207 return iStart; | 207 return iStart; |
| 208 } | 208 } |
| 209 void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const { | 209 void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const { |
| 210 tz.tzHour = 0; | 210 tz.tzHour = 0; |
| 211 tz.tzMinute = 0; | 211 tz.tzMinute = 0; |
| 212 if (!m_pElement) { | 212 if (!m_pElement) { |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone"); | 215 CXML_Element* pxmlTimeZone = m_pElement->GetObjectBy("", "timeZone"); |
| 216 if (pxmlTimeZone) { | 216 if (pxmlTimeZone) { |
| 217 CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0); | 217 CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0); |
| 218 FX_ParseTimeZone(wsTimeZone, wsTimeZone.GetLength(), tz); | 218 FX_ParseTimeZone(wsTimeZone, wsTimeZone.GetLength(), tz); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { | 221 void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { |
| 222 if (!m_pElement) { | 222 if (!m_pElement) { |
| 223 return; | 223 return; |
| 224 } | 224 } |
| 225 FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); | 225 FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); |
| 226 } | 226 } |
| 227 static void FX_GetPattern(CXML_Element* pXmlElement, | 227 static void FX_GetPattern(CXML_Element* pXmlElement, |
| 228 const CFX_ByteString& bsCategory, | 228 const CFX_ByteString& bsCategory, |
| 229 const CFX_WideString& wsSubCategory, | 229 const CFX_WideString& wsSubCategory, |
| 230 CFX_WideString& wsPattern) { | 230 CFX_WideString& wsPattern) { |
| 231 CFX_ByteString bsSpace; | 231 CFX_ByteString bsSpace; |
| 232 CXML_Element* pDatePatterns = | 232 CXML_Element* pDatePatterns = |
| 233 pXmlElement->GetElement(bsSpace, bsCategory + "s"); | 233 pXmlElement->GetObjectBy(bsSpace, bsCategory + "s"); |
| 234 if (!pDatePatterns) { | 234 if (!pDatePatterns) { |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 wsPattern = | 237 wsPattern = |
| 238 FX_GetXMLContent(bsSpace, pDatePatterns, bsCategory, wsSubCategory); | 238 FX_GetXMLContent(bsSpace, pDatePatterns, bsCategory, wsSubCategory); |
| 239 } | 239 } |
| 240 static void FX_GetDateTimePattern(CXML_Element* pXmlElement, | 240 static void FX_GetDateTimePattern(CXML_Element* pXmlElement, |
| 241 const CFX_ByteString& bsCategory, | 241 const CFX_ByteString& bsCategory, |
| 242 FX_LOCALEDATETIMESUBCATEGORY eType, | 242 FX_LOCALEDATETIMESUBCATEGORY eType, |
| 243 CFX_WideString& wsPattern) { | 243 CFX_WideString& wsPattern) { |
| (...skipping 4777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5021 } | 5021 } |
| 5022 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 5022 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
| 5023 return Multiply(val); | 5023 return Multiply(val); |
| 5024 } | 5024 } |
| 5025 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 5025 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
| 5026 return Divide(val); | 5026 return Divide(val); |
| 5027 } | 5027 } |
| 5028 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5028 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
| 5029 return Modulus(val); | 5029 return Modulus(val); |
| 5030 } | 5030 } |
| OLD | NEW |