Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 1 | // 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 Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/javascript/resource.h" |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 8 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 9 | WideString JSGetStringFromID(uint32_t id) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 10 | switch (id) { |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 11 | case IDS_STRING_JSALERT: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 12 | return L"Alert"; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 13 | case IDS_STRING_JSPARAMERROR: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 14 | return L"Incorrect number of parameters passed to function."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 15 | case IDS_STRING_JSAFNUMBER_KEYSTROKE: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 16 | return L"The input value is invalid."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 17 | case IDS_STRING_JSPARAM_TOOLONG: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 18 | return L"The input value is too long."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 19 | case IDS_STRING_JSPARSEDATE: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 20 | return L"The input value can't be parsed as a valid date/time (%s)."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 21 | case IDS_STRING_JSRANGE1: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 22 | return L"The input value must be greater than or equal to %s" |
| 23 | L" and less than or equal to %s."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 24 | case IDS_STRING_JSRANGE2: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 25 | return L"The input value must be greater than or equal to %s."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 26 | case IDS_STRING_JSRANGE3: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 27 | return L"The input value must be less than or equal to %s."; |
tsepez | cd5dc85 | 2016-09-08 11:23:24 -0700 | [diff] [blame] | 28 | case IDS_STRING_JSNOTSUPPORT: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 29 | return L"Operation not supported."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 30 | case IDS_STRING_JSBUSY: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 31 | return L"System is busy."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 32 | case IDS_STRING_JSEVENT: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | return L"Duplicate formfield event found."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 34 | case IDS_STRING_RUN: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 35 | return L"Script ran successfully."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 36 | case IDS_STRING_JSPRINT1: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 37 | return L"The second parameter can't be converted to a Date."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 38 | case IDS_STRING_JSPRINT2: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 39 | return L"The second parameter is an invalid Date!"; |
Tom Sepez | 3a83266 | 2015-03-02 12:59:05 -0800 | [diff] [blame] | 40 | case IDS_STRING_JSNOGLOBAL: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 41 | return L"Global value not found."; |
Tom Sepez | 3a83266 | 2015-03-02 12:59:05 -0800 | [diff] [blame] | 42 | case IDS_STRING_JSREADONLY: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 43 | return L"Cannot assign to readonly property."; |
Tom Sepez | e5350ef | 2015-04-23 18:14:26 -0700 | [diff] [blame] | 44 | case IDS_STRING_JSTYPEERROR: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 45 | return L"Incorrect parameter type."; |
Tom Sepez | e5350ef | 2015-04-23 18:14:26 -0700 | [diff] [blame] | 46 | case IDS_STRING_JSVALUEERROR: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 47 | return L"Incorrect parameter value."; |
tsepez | cd5dc85 | 2016-09-08 11:23:24 -0700 | [diff] [blame] | 48 | case IDS_STRING_JSNOPERMISSION: |
| 49 | return L"Permission denied."; |
| 50 | case IDS_STRING_JSBADOBJECT: |
| 51 | return L"Object no longer exists."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 52 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | return L""; |
| 54 | } |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 55 | } |
Tom Sepez | 3a83266 | 2015-03-02 12:59:05 -0800 | [diff] [blame] | 56 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 57 | WideString JSFormatErrorString(const char* class_name, |
| 58 | const char* property_name, |
| 59 | const WideString& details) { |
| 60 | WideString result = WideString::FromLocal(class_name); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 61 | if (property_name) { |
| 62 | result += L"."; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 63 | result += WideString::FromLocal(property_name); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | } |
| 65 | result += L": "; |
| 66 | result += details; |
| 67 | return result; |
Tom Sepez | 3a83266 | 2015-03-02 12:59:05 -0800 | [diff] [blame] | 68 | } |