blob: 8ca5b2a3b78f0e504e57177dfa46c55541e2876c [file] [log] [blame]
Tom Sepez2b0ed942015-02-27 13:58:29 -08001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Dan Sinclairf766ad22016-03-14 13:51:24 -04007#include "fpdfsdk/javascript/resource.h"
Tom Sepez2b0ed942015-02-27 13:58:29 -08008
Ryan Harrison275e2602017-09-18 14:23:18 -04009WideString JSGetStringFromID(uint32_t id) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070010 switch (id) {
Tom Sepez2b0ed942015-02-27 13:58:29 -080011 case IDS_STRING_JSALERT:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070012 return L"Alert";
Tom Sepez2b0ed942015-02-27 13:58:29 -080013 case IDS_STRING_JSPARAMERROR:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070014 return L"Incorrect number of parameters passed to function.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080015 case IDS_STRING_JSAFNUMBER_KEYSTROKE:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070016 return L"The input value is invalid.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080017 case IDS_STRING_JSPARAM_TOOLONG:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070018 return L"The input value is too long.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080019 case IDS_STRING_JSPARSEDATE:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070020 return L"The input value can't be parsed as a valid date/time (%s).";
Tom Sepez2b0ed942015-02-27 13:58:29 -080021 case IDS_STRING_JSRANGE1:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070022 return L"The input value must be greater than or equal to %s"
23 L" and less than or equal to %s.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080024 case IDS_STRING_JSRANGE2:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070025 return L"The input value must be greater than or equal to %s.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080026 case IDS_STRING_JSRANGE3:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070027 return L"The input value must be less than or equal to %s.";
tsepezcd5dc852016-09-08 11:23:24 -070028 case IDS_STRING_JSNOTSUPPORT:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070029 return L"Operation not supported.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080030 case IDS_STRING_JSBUSY:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070031 return L"System is busy.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080032 case IDS_STRING_JSEVENT:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070033 return L"Duplicate formfield event found.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080034 case IDS_STRING_RUN:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070035 return L"Script ran successfully.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080036 case IDS_STRING_JSPRINT1:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070037 return L"The second parameter can't be converted to a Date.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080038 case IDS_STRING_JSPRINT2:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070039 return L"The second parameter is an invalid Date!";
Tom Sepez3a832662015-03-02 12:59:05 -080040 case IDS_STRING_JSNOGLOBAL:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070041 return L"Global value not found.";
Tom Sepez3a832662015-03-02 12:59:05 -080042 case IDS_STRING_JSREADONLY:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070043 return L"Cannot assign to readonly property.";
Tom Sepeze5350ef2015-04-23 18:14:26 -070044 case IDS_STRING_JSTYPEERROR:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070045 return L"Incorrect parameter type.";
Tom Sepeze5350ef2015-04-23 18:14:26 -070046 case IDS_STRING_JSVALUEERROR:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070047 return L"Incorrect parameter value.";
tsepezcd5dc852016-09-08 11:23:24 -070048 case IDS_STRING_JSNOPERMISSION:
49 return L"Permission denied.";
50 case IDS_STRING_JSBADOBJECT:
51 return L"Object no longer exists.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080052 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070053 return L"";
54 }
Tom Sepez2b0ed942015-02-27 13:58:29 -080055}
Tom Sepez3a832662015-03-02 12:59:05 -080056
Ryan Harrison275e2602017-09-18 14:23:18 -040057WideString JSFormatErrorString(const char* class_name,
58 const char* property_name,
59 const WideString& details) {
60 WideString result = WideString::FromLocal(class_name);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070061 if (property_name) {
62 result += L".";
Ryan Harrison275e2602017-09-18 14:23:18 -040063 result += WideString::FromLocal(property_name);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070064 }
65 result += L": ";
66 result += details;
67 return result;
Tom Sepez3a832662015-03-02 12:59:05 -080068}