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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 } | 1127 } |
1128 return TRUE; // it happens after the last keystroke and before validating, | 1128 return TRUE; // it happens after the last keystroke and before validating, |
1129 } | 1129 } |
1130 | 1130 |
1131 std::wstring w_strValue2 = w_strValue.c_str(); | 1131 std::wstring w_strValue2 = w_strValue.c_str(); |
1132 std::wstring w_strChange2 = w_strChange.c_str(); | 1132 std::wstring w_strChange2 = w_strChange.c_str(); |
1133 std::wstring w_strSelected; | 1133 std::wstring w_strSelected; |
1134 if (-1 != pEvent->SelStart()) | 1134 if (-1 != pEvent->SelStart()) |
1135 w_strSelected = w_strValue2.substr(pEvent->SelStart(), | 1135 w_strSelected = w_strValue2.substr(pEvent->SelStart(), |
1136 (pEvent->SelEnd() - pEvent->SelStart())); | 1136 (pEvent->SelEnd() - pEvent->SelStart())); |
1137 FX_BOOL bHasSign = | 1137 bool bHasSign = (w_strValue2.find('-') != std::wstring::npos) && |
1138 (w_strValue2.find('-') != -1) && (w_strSelected.find('-') == -1); | 1138 (w_strSelected.find('-') == std::wstring::npos); |
1139 if (bHasSign) { | 1139 if (bHasSign) { |
1140 // can't insert "change" in front to sign postion. | 1140 // can't insert "change" in front to sign postion. |
1141 if (pEvent->SelStart() == 0) { | 1141 if (pEvent->SelStart() == 0) { |
1142 FX_BOOL& bRc = pEvent->Rc(); | 1142 FX_BOOL& bRc = pEvent->Rc(); |
1143 bRc = FALSE; | 1143 bRc = FALSE; |
1144 return TRUE; | 1144 return TRUE; |
1145 } | 1145 } |
1146 } | 1146 } |
1147 | 1147 |
1148 char cSep = L'.'; | 1148 char cSep = L'.'; |
1149 | 1149 |
1150 switch (iSepStyle) { | 1150 switch (iSepStyle) { |
1151 case 0: | 1151 case 0: |
1152 case 1: | 1152 case 1: |
1153 cSep = L'.'; | 1153 cSep = L'.'; |
1154 break; | 1154 break; |
1155 case 2: | 1155 case 2: |
1156 case 3: | 1156 case 3: |
1157 cSep = L','; | 1157 cSep = L','; |
1158 break; | 1158 break; |
1159 } | 1159 } |
1160 | 1160 |
1161 FX_BOOL bHasSep = (w_strValue2.find(cSep) != -1); | 1161 bool bHasSep = (w_strValue2.find(cSep) != std::wstring::npos); |
1162 for (std::wstring::iterator it = w_strChange2.begin(); | 1162 for (std::wstring::iterator it = w_strChange2.begin(); |
1163 it != w_strChange2.end(); it++) { | 1163 it != w_strChange2.end(); it++) { |
1164 if (*it == cSep) { | 1164 if (*it == cSep) { |
1165 if (bHasSep) { | 1165 if (bHasSep) { |
1166 FX_BOOL& bRc = pEvent->Rc(); | 1166 FX_BOOL& bRc = pEvent->Rc(); |
1167 bRc = FALSE; | 1167 bRc = FALSE; |
1168 return TRUE; | 1168 return TRUE; |
1169 } | 1169 } |
1170 bHasSep = TRUE; | 1170 bHasSep = TRUE; |
1171 continue; | 1171 continue; |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 nums.SetElement(nIndex, CJS_Value(isolate, sPart.c_str())); | 2132 nums.SetElement(nIndex, CJS_Value(isolate, sPart.c_str())); |
2133 } | 2133 } |
2134 | 2134 |
2135 if (nums.GetLength() > 0) | 2135 if (nums.GetLength() > 0) |
2136 vRet = nums; | 2136 vRet = nums; |
2137 else | 2137 else |
2138 vRet.SetNull(); | 2138 vRet.SetNull(); |
2139 | 2139 |
2140 return TRUE; | 2140 return TRUE; |
2141 } | 2141 } |
OLD | NEW |