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_utils.h" | 7 #include "xfa/fxfa/parser/xfa_utils.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } else if (str[0] == '-') { | 296 } else if (str[0] == '-') { |
297 bNegative = TRUE; | 297 bNegative = TRUE; |
298 cc++; | 298 cc++; |
299 } | 299 } |
300 int32_t nIntegralLen = 0; | 300 int32_t nIntegralLen = 0; |
301 while (cc < len) { | 301 while (cc < len) { |
302 if (str[cc] == '.' || str[cc] == 'E' || str[cc] == 'e' || | 302 if (str[cc] == '.' || str[cc] == 'E' || str[cc] == 'e' || |
303 nIntegralLen > 17) { | 303 nIntegralLen > 17) { |
304 break; | 304 break; |
305 } | 305 } |
306 if (!XFA_IsDigit(str[cc])) { | 306 if (!FXSYS_isDecimalDigit(str[cc])) { |
307 return 0; | 307 return 0; |
308 } | 308 } |
309 nIntegral = nIntegral * 10 + str[cc] - '0'; | 309 nIntegral = nIntegral * 10 + str[cc] - '0'; |
310 cc++; | 310 cc++; |
311 nIntegralLen++; | 311 nIntegralLen++; |
312 } | 312 } |
313 nIntegral = bNegative ? -nIntegral : nIntegral; | 313 nIntegral = bNegative ? -nIntegral : nIntegral; |
314 int32_t scale = 0; | 314 int32_t scale = 0; |
315 FX_DOUBLE fraction = 0.0; | 315 FX_DOUBLE fraction = 0.0; |
316 if (cc < len && str[cc] == '.') { | 316 if (cc < len && str[cc] == '.') { |
317 cc++; | 317 cc++; |
318 while (cc < len) { | 318 while (cc < len) { |
319 fraction += fraction_scales[scale] * (str[cc] - '0'); | 319 fraction += fraction_scales[scale] * (str[cc] - '0'); |
320 scale++; | 320 scale++; |
321 cc++; | 321 cc++; |
322 if (cc == len) { | 322 if (cc == len) { |
323 break; | 323 break; |
324 } | 324 } |
325 if (scale == sizeof(fraction_scales) / sizeof(FX_DOUBLE) || | 325 if (scale == sizeof(fraction_scales) / sizeof(FX_DOUBLE) || |
326 str[cc] == 'E' || str[cc] == 'e') { | 326 str[cc] == 'E' || str[cc] == 'e') { |
327 break; | 327 break; |
328 } | 328 } |
329 if (!XFA_IsDigit(str[cc])) { | 329 if (!FXSYS_isDecimalDigit(str[cc])) { |
330 return 0; | 330 return 0; |
331 } | 331 } |
332 } | 332 } |
333 dwFractional = (uint32_t)(fraction * 4294967296.0); | 333 dwFractional = (uint32_t)(fraction * 4294967296.0); |
334 } | 334 } |
335 if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { | 335 if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { |
336 cc++; | 336 cc++; |
337 if (cc < len) { | 337 if (cc < len) { |
338 if (str[cc] == '+') { | 338 if (str[cc] == '+') { |
339 cc++; | 339 cc++; |
340 } else if (str[cc] == '-') { | 340 } else if (str[cc] == '-') { |
341 bExpSign = TRUE; | 341 bExpSign = TRUE; |
342 cc++; | 342 cc++; |
343 } | 343 } |
344 } | 344 } |
345 while (cc < len) { | 345 while (cc < len) { |
346 if (str[cc] == '.' || !XFA_IsDigit(str[cc])) { | 346 if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) { |
347 return 0; | 347 return 0; |
348 } | 348 } |
349 nExponent = nExponent * 10 + str[cc] - '0'; | 349 nExponent = nExponent * 10 + str[cc] - '0'; |
350 cc++; | 350 cc++; |
351 } | 351 } |
352 nExponent = bExpSign ? -nExponent : nExponent; | 352 nExponent = bExpSign ? -nExponent : nExponent; |
353 } | 353 } |
354 FX_DOUBLE dValue = (dwFractional / 4294967296.0); | 354 FX_DOUBLE dValue = (dwFractional / 4294967296.0); |
355 dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); | 355 dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); |
356 if (nExponent != 0) { | 356 if (nExponent != 0) { |
357 dValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); | 357 dValue *= FXSYS_pow(10, (FX_FLOAT)nExponent); |
358 } | 358 } |
359 return dValue; | 359 return dValue; |
360 } | 360 } |
361 | 361 |
362 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { | 362 FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { |
363 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); | 363 CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal); |
364 return XFA_WideStringToDouble(wsValue); | 364 return XFA_WideStringToDouble(wsValue); |
365 } | 365 } |
366 | 366 |
367 int32_t XFA_MapRotation(int32_t nRotation) { | 367 int32_t XFA_MapRotation(int32_t nRotation) { |
368 nRotation = nRotation % 360; | 368 nRotation = nRotation % 360; |
369 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; | 369 nRotation = nRotation < 0 ? nRotation + 360 : nRotation; |
370 return nRotation; | 370 return nRotation; |
371 } | 371 } |
OLD | NEW |