| 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 "PublicMethods.h" | 7 #include "PublicMethods.h" |
| 8 | 8 |
| 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 10 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 351 } |
| 352 CFX_WideString wsStr = val.ToCFXWideString(); | 352 CFX_WideString wsStr = val.ToCFXWideString(); |
| 353 CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr); | 353 CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr); |
| 354 const char* p = (const char*)t; | 354 const char* p = (const char*)t; |
| 355 | 355 |
| 356 int ch = ','; | 356 int ch = ','; |
| 357 int nIndex = 0; | 357 int nIndex = 0; |
| 358 | 358 |
| 359 while (*p) { | 359 while (*p) { |
| 360 const char* pTemp = strchr(p, ch); | 360 const char* pTemp = strchr(p, ch); |
| 361 if (pTemp == NULL) { | 361 if (!pTemp) { |
| 362 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(p).c_str())); | 362 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(p).c_str())); |
| 363 break; | 363 break; |
| 364 } else { | 364 } |
| 365 char* pSub = new char[pTemp - p + 1]; | |
| 366 strncpy(pSub, p, pTemp - p); | |
| 367 *(pSub + (pTemp - p)) = '\0'; | |
| 368 | 365 |
| 369 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(pSub).c_str())); | 366 char* pSub = new char[pTemp - p + 1]; |
| 370 delete[] pSub; | 367 strncpy(pSub, p, pTemp - p); |
| 368 *(pSub + (pTemp - p)) = '\0'; |
| 371 | 369 |
| 372 nIndex++; | 370 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(pSub).c_str())); |
| 373 p = ++pTemp; | 371 delete[] pSub; |
| 374 } | 372 |
| 373 nIndex++; |
| 374 p = ++pTemp; |
| 375 } | 375 } |
| 376 return StrArray; | 376 return StrArray; |
| 377 } | 377 } |
| 378 | 378 |
| 379 int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string, | 379 int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string, |
| 380 int nStart, | 380 int nStart, |
| 381 int& nSkip, | 381 int& nSkip, |
| 382 int nMaxStep) { | 382 int nMaxStep) { |
| 383 int nRet = 0; | 383 int nRet = 0; |
| 384 nSkip = 0; | 384 nSkip = 0; |
| (...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 ASSERT(pContext != NULL); | 1789 ASSERT(pContext != NULL); |
| 1790 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); | 1790 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); |
| 1791 ASSERT(pEventHandler != NULL); | 1791 ASSERT(pEventHandler != NULL); |
| 1792 | 1792 |
| 1793 if (params.size() != 1) { | 1793 if (params.size() != 1) { |
| 1794 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1794 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1795 return FALSE; | 1795 return FALSE; |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 CFX_WideString swValue; | 1798 CFX_WideString swValue; |
| 1799 if (pEventHandler->m_pValue != NULL) | 1799 if (pEventHandler->m_pValue) |
| 1800 swValue = pEventHandler->Value(); | 1800 swValue = pEventHandler->Value(); |
| 1801 | 1801 |
| 1802 if (pEventHandler->WillCommit()) { | 1802 if (pEventHandler->WillCommit()) { |
| 1803 vRet = swValue.c_str(); | 1803 vRet = swValue.c_str(); |
| 1804 return TRUE; | 1804 return TRUE; |
| 1805 } | 1805 } |
| 1806 | 1806 |
| 1807 CFX_WideString prefix, postfix; | 1807 CFX_WideString prefix, postfix; |
| 1808 | 1808 |
| 1809 if (pEventHandler->SelStart() >= 0) | 1809 if (pEventHandler->SelStart() >= 0) |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 2069 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
| 2070 } | 2070 } |
| 2071 | 2071 |
| 2072 if (nums.GetLength() > 0) | 2072 if (nums.GetLength() > 0) |
| 2073 vRet = nums; | 2073 vRet = nums; |
| 2074 else | 2074 else |
| 2075 vRet.SetNull(); | 2075 vRet.SetNull(); |
| 2076 | 2076 |
| 2077 return TRUE; | 2077 return TRUE; |
| 2078 } | 2078 } |
| OLD | NEW |