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 "fpdfsdk/javascript/PublicMethods.h" | 7 #include "fpdfsdk/javascript/PublicMethods.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 const std::vector<CJS_Value>& params, | 1647 const std::vector<CJS_Value>& params, |
1648 CJS_Value& vRet, | 1648 CJS_Value& vRet, |
1649 CFX_WideString& sError) { | 1649 CFX_WideString& sError) { |
1650 CJS_Context* pContext = (CJS_Context*)cc; | 1650 CJS_Context* pContext = (CJS_Context*)cc; |
1651 if (params.size() != 1) { | 1651 if (params.size() != 1) { |
1652 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1652 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1653 return FALSE; | 1653 return FALSE; |
1654 } | 1654 } |
1655 CFX_WideString ws = params[0].ToCFXWideString(); | 1655 CFX_WideString ws = params[0].ToCFXWideString(); |
1656 ws.Replace(L",", L"."); | 1656 ws.Replace(L",", L"."); |
1657 vRet = ws; | 1657 vRet = ws.c_str(); |
1658 vRet.MaybeCoerceToNumber(); | 1658 vRet.MaybeCoerceToNumber(); |
1659 if (vRet.GetType() != CJS_Value::VT_number) | 1659 if (vRet.GetType() != CJS_Value::VT_number) |
1660 vRet = 0; | 1660 vRet = 0; |
1661 return TRUE; | 1661 return TRUE; |
1662 } | 1662 } |
1663 | 1663 |
1664 FX_BOOL CJS_PublicMethods::AFSimple_Calculate( | 1664 FX_BOOL CJS_PublicMethods::AFSimple_Calculate( |
1665 IJS_Context* cc, | 1665 IJS_Context* cc, |
1666 const std::vector<CJS_Value>& params, | 1666 const std::vector<CJS_Value>& params, |
1667 CJS_Value& vRet, | 1667 CJS_Value& vRet, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 1845 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
1846 } | 1846 } |
1847 | 1847 |
1848 if (nums.GetLength() > 0) | 1848 if (nums.GetLength() > 0) |
1849 vRet = nums; | 1849 vRet = nums; |
1850 else | 1850 else |
1851 vRet.SetNull(); | 1851 vRet.SetNull(); |
1852 | 1852 |
1853 return TRUE; | 1853 return TRUE; |
1854 } | 1854 } |
OLD | NEW |