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 <vector> | 10 #include <vector> |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 return FALSE; | 896 return FALSE; |
897 | 897 |
898 if (!pEvent->m_pValue) | 898 if (!pEvent->m_pValue) |
899 return FALSE; | 899 return FALSE; |
900 | 900 |
901 CFX_WideString& val = pEvent->Value(); | 901 CFX_WideString& val = pEvent->Value(); |
902 CFX_WideString& wstrChange = pEvent->Change(); | 902 CFX_WideString& wstrChange = pEvent->Change(); |
903 CFX_WideString wstrValue = val; | 903 CFX_WideString wstrValue = val; |
904 | 904 |
905 if (pEvent->WillCommit()) { | 905 if (pEvent->WillCommit()) { |
906 CFX_WideString wstrValue = StrTrim(wstrValue); | 906 CFX_WideString swTemp = StrTrim(wstrValue); |
907 if (wstrValue.IsEmpty()) | 907 if (swTemp.IsEmpty()) |
908 return TRUE; | 908 return TRUE; |
909 | 909 |
910 CFX_WideString swTemp = wstrValue; | |
911 swTemp.Replace(L",", L"."); | 910 swTemp.Replace(L",", L"."); |
912 if (!IsNumber(swTemp.c_str())) { | 911 if (!IsNumber(swTemp.c_str())) { |
913 pEvent->Rc() = FALSE; | 912 pEvent->Rc() = FALSE; |
914 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); | 913 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); |
915 Alert(pContext, sError.c_str()); | 914 Alert(pContext, sError.c_str()); |
916 } | 915 } |
917 return TRUE; // it happens after the last keystroke and before validating, | 916 return TRUE; // it happens after the last keystroke and before validating, |
918 } | 917 } |
919 | 918 |
920 CFX_WideString wstrSelected; | 919 CFX_WideString wstrSelected; |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 1809 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
1811 } | 1810 } |
1812 | 1811 |
1813 if (nums.GetLength() > 0) | 1812 if (nums.GetLength() > 0) |
1814 vRet = nums; | 1813 vRet = nums; |
1815 else | 1814 else |
1816 vRet.SetNull(); | 1815 vRet.SetNull(); |
1817 | 1816 |
1818 return TRUE; | 1817 return TRUE; |
1819 } | 1818 } |
OLD | NEW |