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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return L""; | 104 return L""; |
105 } | 105 } |
106 void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, | 106 void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, |
107 CFX_WideString& wsNumSymbol) const { | 107 CFX_WideString& wsNumSymbol) const { |
108 if (!m_pElement) { | 108 if (!m_pElement) { |
109 return; | 109 return; |
110 } | 110 } |
111 CFX_ByteString bsSpace; | 111 CFX_ByteString bsSpace; |
112 CFX_WideString wsName = gs_LocalNumberSymbols[eType]; | 112 CFX_WideString wsName = gs_LocalNumberSymbols[eType]; |
113 CXML_Element* pNumberSymbols = | 113 CXML_Element* pNumberSymbols = |
114 m_pElement->GetElement(bsSpace.AsByteStringC(), "numberSymbols"); | 114 m_pElement->GetElement(bsSpace.AsStringC(), "numberSymbols"); |
115 if (!pNumberSymbols) { | 115 if (!pNumberSymbols) { |
116 return; | 116 return; |
117 } | 117 } |
118 wsNumSymbol = FX_GetXMLContent(bsSpace.AsByteStringC(), pNumberSymbols, | 118 wsNumSymbol = FX_GetXMLContent(bsSpace.AsStringC(), pNumberSymbols, |
119 "numberSymbol", wsName.AsWideStringC()); | 119 "numberSymbol", wsName.AsStringC()); |
120 } | 120 } |
121 void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { | 121 void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { |
122 if (!m_pElement) { | 122 if (!m_pElement) { |
123 return; | 123 return; |
124 } | 124 } |
125 CFX_ByteString bsSpace; | 125 CFX_ByteString bsSpace; |
126 CXML_Element* pNumberSymbols = | 126 CXML_Element* pNumberSymbols = |
127 m_pElement->GetElement(bsSpace.AsByteStringC(), "dateTimeSymbols"); | 127 m_pElement->GetElement(bsSpace.AsStringC(), "dateTimeSymbols"); |
128 if (!pNumberSymbols) { | 128 if (!pNumberSymbols) { |
129 return; | 129 return; |
130 } | 130 } |
131 wsDtSymbol = pNumberSymbols->GetContent(0); | 131 wsDtSymbol = pNumberSymbols->GetContent(0); |
132 } | 132 } |
133 static void FX_GetCalendarSymbol(CXML_Element* pXmlElement, | 133 static void FX_GetCalendarSymbol(CXML_Element* pXmlElement, |
134 const CFX_ByteString& symbol_type, | 134 const CFX_ByteString& symbol_type, |
135 int32_t index, | 135 int32_t index, |
136 FX_BOOL bAbbr, | 136 FX_BOOL bAbbr, |
137 CFX_WideString& wsName) { | 137 CFX_WideString& wsName) { |
138 CFX_ByteString bsSpace; | 138 CFX_ByteString bsSpace; |
139 CFX_ByteString pstrSymbolNames = symbol_type + "Names"; | 139 CFX_ByteString pstrSymbolNames = symbol_type + "Names"; |
140 CXML_Element* pChild = | 140 CXML_Element* pChild = |
141 pXmlElement->GetElement(bsSpace.AsByteStringC(), "calendarSymbols"); | 141 pXmlElement->GetElement(bsSpace.AsStringC(), "calendarSymbols"); |
142 if (!pChild) { | 142 if (!pChild) { |
143 return; | 143 return; |
144 } | 144 } |
145 CXML_Element* pSymbolNames = pChild->GetElement( | 145 CXML_Element* pSymbolNames = |
146 bsSpace.AsByteStringC(), pstrSymbolNames.AsByteStringC()); | 146 pChild->GetElement(bsSpace.AsStringC(), pstrSymbolNames.AsStringC()); |
147 if (!pSymbolNames) { | 147 if (!pSymbolNames) { |
148 return; | 148 return; |
149 } | 149 } |
150 if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { | 150 if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) { |
151 pSymbolNames = pChild->GetElement(bsSpace.AsByteStringC(), | 151 pSymbolNames = |
152 pstrSymbolNames.AsByteStringC(), 1); | 152 pChild->GetElement(bsSpace.AsStringC(), pstrSymbolNames.AsStringC(), 1); |
153 } | 153 } |
154 if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { | 154 if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) { |
155 CXML_Element* pSymbolName = pSymbolNames->GetElement( | 155 CXML_Element* pSymbolName = pSymbolNames->GetElement( |
156 bsSpace.AsByteStringC(), symbol_type.AsByteStringC(), index); | 156 bsSpace.AsStringC(), symbol_type.AsStringC(), index); |
157 if (pSymbolName) { | 157 if (pSymbolName) { |
158 wsName = pSymbolName->GetContent(0); | 158 wsName = pSymbolName->GetContent(0); |
159 } | 159 } |
160 } | 160 } |
161 } | 161 } |
162 void CFX_Locale::GetMonthName(int32_t nMonth, | 162 void CFX_Locale::GetMonthName(int32_t nMonth, |
163 CFX_WideString& wsMonthName, | 163 CFX_WideString& wsMonthName, |
164 FX_BOOL bAbbr) const { | 164 FX_BOOL bAbbr) const { |
165 if (!m_pElement) { | 165 if (!m_pElement) { |
166 return; | 166 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 return; | 225 return; |
226 } | 226 } |
227 FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); | 227 FX_GetCalendarSymbol(m_pElement, "era", bAD ? 0 : 1, FALSE, wsEraName); |
228 } | 228 } |
229 static void FX_GetPattern(CXML_Element* pXmlElement, | 229 static void FX_GetPattern(CXML_Element* pXmlElement, |
230 const CFX_ByteString& bsCategory, | 230 const CFX_ByteString& bsCategory, |
231 const CFX_WideString& wsSubCategory, | 231 const CFX_WideString& wsSubCategory, |
232 CFX_WideString& wsPattern) { | 232 CFX_WideString& wsPattern) { |
233 CFX_ByteString bsSpace; | 233 CFX_ByteString bsSpace; |
234 CXML_Element* pDatePatterns = pXmlElement->GetElement( | 234 CXML_Element* pDatePatterns = pXmlElement->GetElement( |
235 bsSpace.AsByteStringC(), (bsCategory + "s").AsByteStringC()); | 235 bsSpace.AsStringC(), (bsCategory + "s").AsStringC()); |
236 if (!pDatePatterns) { | 236 if (!pDatePatterns) { |
237 return; | 237 return; |
238 } | 238 } |
239 wsPattern = FX_GetXMLContent(bsSpace.AsByteStringC(), pDatePatterns, | 239 wsPattern = |
240 bsCategory.AsByteStringC(), | 240 FX_GetXMLContent(bsSpace.AsStringC(), pDatePatterns, |
241 wsSubCategory.AsWideStringC()); | 241 bsCategory.AsStringC(), wsSubCategory.AsStringC()); |
242 } | 242 } |
243 static void FX_GetDateTimePattern(CXML_Element* pXmlElement, | 243 static void FX_GetDateTimePattern(CXML_Element* pXmlElement, |
244 const CFX_ByteString& bsCategory, | 244 const CFX_ByteString& bsCategory, |
245 FX_LOCALEDATETIMESUBCATEGORY eType, | 245 FX_LOCALEDATETIMESUBCATEGORY eType, |
246 CFX_WideString& wsPattern) { | 246 CFX_WideString& wsPattern) { |
247 CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName; | 247 CFX_WideString wsType = g_FXLocaleDateTimeSubCatData[eType].pName; |
248 FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern); | 248 FX_GetPattern(pXmlElement, bsCategory, wsType, wsPattern); |
249 } | 249 } |
250 void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, | 250 void CFX_Locale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, |
251 CFX_WideString& wsPattern) const { | 251 CFX_WideString& wsPattern) const { |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 if (wsSearchCategory != wsCategory) { | 686 if (wsSearchCategory != wsCategory) { |
687 continue; | 687 continue; |
688 } | 688 } |
689 while (ccf < iLenf) { | 689 while (ccf < iLenf) { |
690 if (pStr[ccf] == '(') { | 690 if (pStr[ccf] == '(') { |
691 ccf++; | 691 ccf++; |
692 CFX_WideString wsLCID; | 692 CFX_WideString wsLCID; |
693 while (ccf < iLenf && pStr[ccf] != ')') { | 693 while (ccf < iLenf && pStr[ccf] != ')') { |
694 wsLCID += pStr[ccf++]; | 694 wsLCID += pStr[ccf++]; |
695 } | 695 } |
696 pLocale = GetPatternLocale(wsLCID.AsWideStringC()); | 696 pLocale = GetPatternLocale(wsLCID.AsStringC()); |
697 } else if (pStr[ccf] == '{') { | 697 } else if (pStr[ccf] == '{') { |
698 bBrackOpen = TRUE; | 698 bBrackOpen = TRUE; |
699 break; | 699 break; |
700 } | 700 } |
701 ccf++; | 701 ccf++; |
702 } | 702 } |
703 } else if (pStr[ccf] != '}') { | 703 } else if (pStr[ccf] != '}') { |
704 wsPurgePattern += pStr[ccf]; | 704 wsPurgePattern += pStr[ccf]; |
705 } | 705 } |
706 ccf++; | 706 ccf++; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 ccf = 0; | 745 ccf = 0; |
746 continue; | 746 continue; |
747 } | 747 } |
748 while (ccf < iLenf) { | 748 while (ccf < iLenf) { |
749 if (pStr[ccf] == '(') { | 749 if (pStr[ccf] == '(') { |
750 ccf++; | 750 ccf++; |
751 CFX_WideString wsLCID; | 751 CFX_WideString wsLCID; |
752 while (ccf < iLenf && pStr[ccf] != ')') { | 752 while (ccf < iLenf && pStr[ccf] != ')') { |
753 wsLCID += pStr[ccf++]; | 753 wsLCID += pStr[ccf++]; |
754 } | 754 } |
755 pLocale = GetPatternLocale(wsLCID.AsWideStringC()); | 755 pLocale = GetPatternLocale(wsLCID.AsStringC()); |
756 } else if (pStr[ccf] == '{') { | 756 } else if (pStr[ccf] == '{') { |
757 bBrackOpen = TRUE; | 757 bBrackOpen = TRUE; |
758 break; | 758 break; |
759 } else if (pStr[ccf] == '.') { | 759 } else if (pStr[ccf] == '.') { |
760 CFX_WideString wsSubCategory; | 760 CFX_WideString wsSubCategory; |
761 ccf++; | 761 ccf++; |
762 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 762 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
763 wsSubCategory += pStr[ccf++]; | 763 wsSubCategory += pStr[ccf++]; |
764 } | 764 } |
765 uint32_t dwSubHash = | 765 uint32_t dwSubHash = |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 } | 2150 } |
2151 cc++; | 2151 cc++; |
2152 ccf++; | 2152 ccf++; |
2153 } | 2153 } |
2154 } | 2154 } |
2155 if (cc != len) { | 2155 if (cc != len) { |
2156 return FALSE; | 2156 return FALSE; |
2157 } | 2157 } |
2158 } | 2158 } |
2159 if (iExponent || bHavePercentSymbol) { | 2159 if (iExponent || bHavePercentSymbol) { |
2160 CFX_Decimal decimal = CFX_Decimal(wsValue.AsWideStringC()); | 2160 CFX_Decimal decimal = CFX_Decimal(wsValue.AsStringC()); |
2161 if (iExponent) { | 2161 if (iExponent) { |
2162 decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); | 2162 decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); |
2163 } | 2163 } |
2164 if (bHavePercentSymbol) { | 2164 if (bHavePercentSymbol) { |
2165 decimal = decimal / CFX_Decimal(100); | 2165 decimal = decimal / CFX_Decimal(100); |
2166 } | 2166 } |
2167 wsValue = decimal; | 2167 wsValue = decimal; |
2168 } | 2168 } |
2169 if (bNeg) { | 2169 if (bNeg) { |
2170 wsValue = L'-' + wsValue; | 2170 wsValue = L'-' + wsValue; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 } else { | 2222 } else { |
2223 continue; | 2223 continue; |
2224 } | 2224 } |
2225 while (ccf < iLenf) { | 2225 while (ccf < iLenf) { |
2226 if (pStr[ccf] == '(') { | 2226 if (pStr[ccf] == '(') { |
2227 ccf++; | 2227 ccf++; |
2228 CFX_WideString wsLCID; | 2228 CFX_WideString wsLCID; |
2229 while (ccf < iLenf && pStr[ccf] != ')') { | 2229 while (ccf < iLenf && pStr[ccf] != ')') { |
2230 wsLCID += pStr[ccf++]; | 2230 wsLCID += pStr[ccf++]; |
2231 } | 2231 } |
2232 pLocale = GetPatternLocale(wsLCID.AsWideStringC()); | 2232 pLocale = GetPatternLocale(wsLCID.AsStringC()); |
2233 } else if (pStr[ccf] == '{') { | 2233 } else if (pStr[ccf] == '{') { |
2234 bBraceOpen = TRUE; | 2234 bBraceOpen = TRUE; |
2235 break; | 2235 break; |
2236 } else if (pStr[ccf] == '.') { | 2236 } else if (pStr[ccf] == '.') { |
2237 CFX_WideString wsSubCategory; | 2237 CFX_WideString wsSubCategory; |
2238 ccf++; | 2238 ccf++; |
2239 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 2239 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
2240 wsSubCategory += pStr[ccf++]; | 2240 wsSubCategory += pStr[ccf++]; |
2241 } | 2241 } |
2242 uint32_t dwSubHash = | 2242 uint32_t dwSubHash = |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2920 return FALSE; | 2920 return FALSE; |
2921 } | 2921 } |
2922 int32_t cc = 0, ccf = 0; | 2922 int32_t cc = 0, ccf = 0; |
2923 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; | 2923 const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat; |
2924 int lenf = wsNumFormat.GetLength(); | 2924 int lenf = wsNumFormat.GetLength(); |
2925 CFX_WideString wsSrcNum = wsInputNum; | 2925 CFX_WideString wsSrcNum = wsInputNum; |
2926 wsSrcNum.TrimLeft('0'); | 2926 wsSrcNum.TrimLeft('0'); |
2927 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { | 2927 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { |
2928 wsSrcNum.Insert(0, '0'); | 2928 wsSrcNum.Insert(0, '0'); |
2929 } | 2929 } |
2930 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsWideStringC()); | 2930 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); |
2931 if (dwNumStyle & FX_NUMSTYLE_Percent) { | 2931 if (dwNumStyle & FX_NUMSTYLE_Percent) { |
2932 decimal = decimal * CFX_Decimal(100); | 2932 decimal = decimal * CFX_Decimal(100); |
2933 wsSrcNum = decimal; | 2933 wsSrcNum = decimal; |
2934 } | 2934 } |
2935 int32_t exponent = 0; | 2935 int32_t exponent = 0; |
2936 if (dwNumStyle & FX_NUMSTYLE_Exponent) { | 2936 if (dwNumStyle & FX_NUMSTYLE_Exponent) { |
2937 int fixed_count = 0; | 2937 int fixed_count = 0; |
2938 while (ccf < dot_index_f) { | 2938 while (ccf < dot_index_f) { |
2939 switch (strf[ccf]) { | 2939 switch (strf[ccf]) { |
2940 case '\'': | 2940 case '\'': |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3748 wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); | 3748 wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); |
3749 } | 3749 } |
3750 return TRUE; | 3750 return TRUE; |
3751 } | 3751 } |
3752 FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, | 3752 FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, |
3753 const CFX_WideString& wsPattern, | 3753 const CFX_WideString& wsPattern, |
3754 CFX_WideString& wsOutput) { | 3754 CFX_WideString& wsOutput) { |
3755 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 3755 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
3756 return FALSE; | 3756 return FALSE; |
3757 } | 3757 } |
3758 return FormatStrNum(wsSrcNum.AsWideStringC(), wsPattern, wsOutput); | 3758 return FormatStrNum(wsSrcNum.AsStringC(), wsPattern, wsOutput); |
3759 } | 3759 } |
3760 FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, | 3760 FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, |
3761 const CFX_WideString& wsPattern, | 3761 const CFX_WideString& wsPattern, |
3762 CFX_WideString& wsOutput) { | 3762 CFX_WideString& wsOutput) { |
3763 if (wsPattern.IsEmpty()) { | 3763 if (wsPattern.IsEmpty()) { |
3764 return FALSE; | 3764 return FALSE; |
3765 } | 3765 } |
3766 CFX_LCNumeric lcNum(fNum); | 3766 CFX_LCNumeric lcNum(fNum); |
3767 return FormatLCNumeric(lcNum, wsPattern, wsOutput); | 3767 return FormatLCNumeric(lcNum, wsPattern, wsOutput); |
3768 } | 3768 } |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 4250 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
4251 if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { | 4251 if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { |
4252 return FALSE; | 4252 return FALSE; |
4253 } | 4253 } |
4254 CFX_Unitime dt(0); | 4254 CFX_Unitime dt(0); |
4255 int32_t iT = wsSrcDateTime.Find(L"T"); | 4255 int32_t iT = wsSrcDateTime.Find(L"T"); |
4256 if (iT < 0) { | 4256 if (iT < 0) { |
4257 if (eCategory == FX_DATETIMETYPE_Date) { | 4257 if (eCategory == FX_DATETIMETYPE_Date) { |
4258 FX_DateFromCanonical(wsSrcDateTime, dt); | 4258 FX_DateFromCanonical(wsSrcDateTime, dt); |
4259 } else if (eCategory == FX_DATETIMETYPE_Time) { | 4259 } else if (eCategory == FX_DATETIMETYPE_Time) { |
4260 FX_TimeFromCanonical(wsSrcDateTime.AsWideStringC(), dt, pLocale); | 4260 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale); |
4261 } | 4261 } |
4262 } else { | 4262 } else { |
4263 FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); | 4263 FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); |
4264 FX_TimeFromCanonical( | 4264 FX_TimeFromCanonical( |
4265 wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsWideStringC(), | 4265 wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsStringC(), dt, |
4266 dt, pLocale); | 4266 pLocale); |
4267 } | 4267 } |
4268 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, | 4268 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, |
4269 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 4269 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
4270 wsOutput); | 4270 wsOutput); |
4271 } | 4271 } |
4272 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, | 4272 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, |
4273 const CFX_WideString& wsPattern, | 4273 const CFX_WideString& wsPattern, |
4274 CFX_WideString& wsOutput, | 4274 CFX_WideString& wsOutput, |
4275 FX_DATETIMETYPE eDateTimeType) { | 4275 FX_DATETIMETYPE eDateTimeType) { |
4276 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { | 4276 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { |
(...skipping 17 matching lines...) Expand all Loading... |
4294 return FALSE; | 4294 return FALSE; |
4295 } | 4295 } |
4296 CFX_Unitime dt(0); | 4296 CFX_Unitime dt(0); |
4297 int32_t iT = wsSrcDateTime.Find(L"T"); | 4297 int32_t iT = wsSrcDateTime.Find(L"T"); |
4298 if (iT < 0) { | 4298 if (iT < 0) { |
4299 if (eCategory == FX_DATETIMETYPE_Date && | 4299 if (eCategory == FX_DATETIMETYPE_Date && |
4300 FX_DateFromCanonical(wsSrcDateTime, dt)) { | 4300 FX_DateFromCanonical(wsSrcDateTime, dt)) { |
4301 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4301 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
4302 wsOutput); | 4302 wsOutput); |
4303 } else if (eCategory == FX_DATETIMETYPE_Time && | 4303 } else if (eCategory == FX_DATETIMETYPE_Time && |
4304 FX_TimeFromCanonical(wsSrcDateTime.AsWideStringC(), dt, | 4304 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { |
4305 pLocale)) { | |
4306 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4305 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, |
4307 wsOutput); | 4306 wsOutput); |
4308 } | 4307 } |
4309 } else { | 4308 } else { |
4310 CFX_WideStringC wsSrcDate((const FX_WCHAR*)wsSrcDateTime, iT); | 4309 CFX_WideStringC wsSrcDate((const FX_WCHAR*)wsSrcDateTime, iT); |
4311 CFX_WideStringC wsSrcTime((const FX_WCHAR*)wsSrcDateTime + iT + 1, | 4310 CFX_WideStringC wsSrcTime((const FX_WCHAR*)wsSrcDateTime + iT + 1, |
4312 wsSrcDateTime.GetLength() - iT - 1); | 4311 wsSrcDateTime.GetLength() - iT - 1); |
4313 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { | 4312 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { |
4314 return FALSE; | 4313 return FALSE; |
4315 } | 4314 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4732 scale++; | 4731 scale++; |
4733 } | 4732 } |
4734 } | 4733 } |
4735 cont: | 4734 cont: |
4736 str++; | 4735 str++; |
4737 } | 4736 } |
4738 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale); | 4737 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(negmet && IsNotZero(), scale); |
4739 } | 4738 } |
4740 | 4739 |
4741 CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) { | 4740 CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) { |
4742 *this = CFX_Decimal(CFX_WideString::FromLocal(strObj).AsWideStringC()); | 4741 *this = CFX_Decimal(CFX_WideString::FromLocal(strObj).AsStringC()); |
4743 } | 4742 } |
4744 | 4743 |
4745 CFX_Decimal::operator CFX_WideString() const { | 4744 CFX_Decimal::operator CFX_WideString() const { |
4746 CFX_WideString retString; | 4745 CFX_WideString retString; |
4747 CFX_WideString tmpbuf; | 4746 CFX_WideString tmpbuf; |
4748 uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; | 4747 uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; |
4749 while (phi || pmid || plo) { | 4748 while (phi || pmid || plo) { |
4750 tmpbuf += fxmath_decimal_helper_div10(phi, pmid, plo) + '0'; | 4749 tmpbuf += fxmath_decimal_helper_div10(phi, pmid, plo) + '0'; |
4751 } | 4750 } |
4752 uint8_t outputlen = (uint8_t)tmpbuf.GetLength(); | 4751 uint8_t outputlen = (uint8_t)tmpbuf.GetLength(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5026 } | 5025 } |
5027 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 5026 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
5028 return Multiply(val); | 5027 return Multiply(val); |
5029 } | 5028 } |
5030 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 5029 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
5031 return Divide(val); | 5030 return Divide(val); |
5032 } | 5031 } |
5033 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5032 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
5034 return Modulus(val); | 5033 return Modulus(val); |
5035 } | 5034 } |
OLD | NEW |