| 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 <time.h> | 7 #include <time.h> |
| 8 | 8 |
| 9 #include "xfa/src/fxfa/src/common/fxfa_localevalue.h" | 9 #include "xfa/src/fxfa/src/common/fxfa_localevalue.h" |
| 10 #include "xfa/src/fxfa/src/fm2js/xfa_fm2js.h" | 10 #include "xfa/src/fxfa/src/fm2js/xfa_fm2js.h" |
| (...skipping 4040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4051 ++i; | 4051 ++i; |
| 4052 } | 4052 } |
| 4053 if (i < iCount) { | 4053 if (i < iCount) { |
| 4054 continue; | 4054 continue; |
| 4055 } | 4055 } |
| 4056 if (ch >= 0x80 && ch <= 0xff) { | 4056 if (ch >= 0x80 && ch <= 0xff) { |
| 4057 int32_t iIndex = ch / 16; | 4057 int32_t iIndex = ch / 16; |
| 4058 strEncode[1] = strCode[iIndex]; | 4058 strEncode[1] = strCode[iIndex]; |
| 4059 strEncode[2] = strCode[ch - iIndex * 16]; | 4059 strEncode[2] = strCode[ch - iIndex * 16]; |
| 4060 wsResultBuf << FX_WSTRC(strEncode); | 4060 wsResultBuf << FX_WSTRC(strEncode); |
| 4061 } else if ((ch >= 0x0 && ch <= 0x1f) || ch == 0x7f) { | 4061 } else if (ch <= 0x1f || ch == 0x7f) { |
| 4062 int32_t iIndex = ch / 16; | 4062 int32_t iIndex = ch / 16; |
| 4063 strEncode[1] = strCode[iIndex]; | 4063 strEncode[1] = strCode[iIndex]; |
| 4064 strEncode[2] = strCode[ch - iIndex * 16]; | 4064 strEncode[2] = strCode[ch - iIndex * 16]; |
| 4065 wsResultBuf << FX_WSTRC(strEncode); | 4065 wsResultBuf << FX_WSTRC(strEncode); |
| 4066 } else if (ch >= 0x20 && ch <= 0x7e) { | 4066 } else if (ch >= 0x20 && ch <= 0x7e) { |
| 4067 wsResultBuf.AppendChar(ch); | 4067 wsResultBuf.AppendChar(ch); |
| 4068 } else { | 4068 } else { |
| 4069 int32_t iRadix = 16; | 4069 int32_t iRadix = 16; |
| 4070 CFX_WideString strTmp; | 4070 CFX_WideString strTmp; |
| 4071 while (ch >= iRadix) { | 4071 while (ch >= iRadix) { |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4711 } else { | 4711 } else { |
| 4712 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4712 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4713 L"Parse"); | 4713 L"Parse"); |
| 4714 } | 4714 } |
| 4715 } | 4715 } |
| 4716 void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, | 4716 void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, |
| 4717 const CFX_ByteStringC& szFuncName, | 4717 const CFX_ByteStringC& szFuncName, |
| 4718 CFXJSE_Arguments& args) { | 4718 CFXJSE_Arguments& args) { |
| 4719 int32_t argc = args.GetLength(); | 4719 int32_t argc = args.GetLength(); |
| 4720 if ((argc == 2) || (argc == 3)) { | 4720 if ((argc == 2) || (argc == 3)) { |
| 4721 FX_BOOL bFlags = FALSE; | |
| 4722 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); | 4721 FXJSE_HVALUE argOne = GetSimpleHValue(hThis, args, 0); |
| 4723 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); | 4722 FXJSE_HVALUE argTwo = GetSimpleHValue(hThis, args, 1); |
| 4724 FXJSE_HVALUE argThree = 0; | 4723 FXJSE_HVALUE argThree = 0; |
| 4725 CFX_ByteString oneString; | 4724 CFX_ByteString oneString; |
| 4726 CFX_ByteString twoString; | 4725 CFX_ByteString twoString; |
| 4727 CFX_ByteString threeString; | 4726 CFX_ByteString threeString; |
| 4728 if ((HValueIsNull(hThis, argOne)) || (HValueIsNull(hThis, argTwo))) { | 4727 if (!HValueIsNull(hThis, argOne) && !HValueIsNull(hThis, argTwo)) { |
| 4729 bFlags = TRUE; | |
| 4730 } else { | |
| 4731 HValueToUTF8String(argOne, oneString); | 4728 HValueToUTF8String(argOne, oneString); |
| 4732 HValueToUTF8String(argTwo, twoString); | 4729 HValueToUTF8String(argTwo, twoString); |
| 4733 } | 4730 } |
| 4734 if (argc == 3) { | 4731 if (argc == 3) { |
| 4735 argThree = GetSimpleHValue(hThis, args, 2); | 4732 argThree = GetSimpleHValue(hThis, args, 2); |
| 4736 HValueToUTF8String(argThree, threeString); | 4733 HValueToUTF8String(argThree, threeString); |
| 4737 } | 4734 } |
| 4738 int32_t iSrcLen = oneString.GetLength(); | 4735 int32_t iSrcLen = oneString.GetLength(); |
| 4739 int32_t iFindLen = twoString.GetLength(); | 4736 int32_t iFindLen = twoString.GetLength(); |
| 4740 CFX_ByteTextBuf resultString; | 4737 CFX_ByteTextBuf resultString; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4988 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 4985 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
| 4989 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4986 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4990 L"Str"); | 4987 L"Str"); |
| 4991 } | 4988 } |
| 4992 } | 4989 } |
| 4993 void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, | 4990 void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, |
| 4994 const CFX_ByteStringC& szFuncName, | 4991 const CFX_ByteStringC& szFuncName, |
| 4995 CFXJSE_Arguments& args) { | 4992 CFXJSE_Arguments& args) { |
| 4996 int32_t argc = args.GetLength(); | 4993 int32_t argc = args.GetLength(); |
| 4997 if ((argc == 3) || (argc == 4)) { | 4994 if ((argc == 3) || (argc == 4)) { |
| 4998 FX_BOOL bFlags = FALSE; | |
| 4999 CFX_ByteString sourceString; | 4995 CFX_ByteString sourceString; |
| 5000 CFX_ByteString insertString; | 4996 CFX_ByteString insertString; |
| 5001 int32_t iLength = 0; | 4997 int32_t iLength = 0; |
| 5002 int32_t iStart = 0; | 4998 int32_t iStart = 0; |
| 5003 int32_t iDelete = 0; | 4999 int32_t iDelete = 0; |
| 5004 FXJSE_HVALUE sourceValue = GetSimpleHValue(hThis, args, 0); | 5000 FXJSE_HVALUE sourceValue = GetSimpleHValue(hThis, args, 0); |
| 5005 FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); | 5001 FXJSE_HVALUE startValue = GetSimpleHValue(hThis, args, 1); |
| 5006 FXJSE_HVALUE deleteValue = GetSimpleHValue(hThis, args, 2); | 5002 FXJSE_HVALUE deleteValue = GetSimpleHValue(hThis, args, 2); |
| 5007 FXJSE_HVALUE insertValue = 0; | 5003 FXJSE_HVALUE insertValue = 0; |
| 5008 if ((FXJSE_Value_IsNull(sourceValue)) || (FXJSE_Value_IsNull(startValue)) || | 5004 if (!FXJSE_Value_IsNull(sourceValue) && !FXJSE_Value_IsNull(startValue) && |
| 5009 (FXJSE_Value_IsNull(deleteValue))) { | 5005 !FXJSE_Value_IsNull(deleteValue)) { |
| 5010 bFlags = TRUE; | |
| 5011 } else { | |
| 5012 HValueToUTF8String(sourceValue, sourceString); | 5006 HValueToUTF8String(sourceValue, sourceString); |
| 5013 iLength = sourceString.GetLength(); | 5007 iLength = sourceString.GetLength(); |
| 5014 iStart = (int32_t)HValueToFloat(hThis, startValue); | 5008 iStart = (int32_t)HValueToFloat(hThis, startValue); |
| 5015 if (iStart < 1) { | 5009 if (iStart < 1) { |
| 5016 iStart = 1; | 5010 iStart = 1; |
| 5017 } | 5011 } |
| 5018 if (iStart > iLength) { | 5012 if (iStart > iLength) { |
| 5019 iStart = iLength; | 5013 iStart = iLength; |
| 5020 } | 5014 } |
| 5021 iDelete = (int32_t)HValueToFloat(hThis, deleteValue); | 5015 iDelete = (int32_t)HValueToFloat(hThis, deleteValue); |
| (...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7214 FXSYS_assert(pAppProvider); | 7208 FXSYS_assert(pAppProvider); |
| 7215 CFX_WideString wsFormat; | 7209 CFX_WideString wsFormat; |
| 7216 pAppProvider->LoadString(iStringID, wsFormat); | 7210 pAppProvider->LoadString(iStringID, wsFormat); |
| 7217 CFX_WideString wsMessage; | 7211 CFX_WideString wsMessage; |
| 7218 va_list arg_ptr; | 7212 va_list arg_ptr; |
| 7219 va_start(arg_ptr, iStringID); | 7213 va_start(arg_ptr, iStringID); |
| 7220 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7214 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
| 7221 va_end(arg_ptr); | 7215 va_end(arg_ptr); |
| 7222 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); | 7216 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); |
| 7223 } | 7217 } |
| OLD | NEW |