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 | |
| 7 | #include "../../include/javascript/resource.h" |
| 8 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame^] | 9 | CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT id) { |
| 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."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 28 | case IDS_STRING_NOTSUPPORT: |
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."; |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 48 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame^] | 49 | return L""; |
| 50 | } |
Tom Sepez | 2b0ed94 | 2015-02-27 13:58:29 -0800 | [diff] [blame] | 51 | } |
Tom Sepez | 3a83266 | 2015-03-02 12:59:05 -0800 | [diff] [blame] | 52 | |
| 53 | CFX_WideString JSFormatErrorString(const char* class_name, |
| 54 | const char* property_name, |
| 55 | const CFX_WideString& details) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame^] | 56 | CFX_WideString result = CFX_WideString::FromLocal(class_name); |
| 57 | if (property_name) { |
| 58 | result += L"."; |
| 59 | result += CFX_WideString::FromLocal(property_name); |
| 60 | } |
| 61 | result += L": "; |
| 62 | result += details; |
| 63 | return result; |
Tom Sepez | 3a83266 | 2015-03-02 12:59:05 -0800 | [diff] [blame] | 64 | } |