blob: 5b6bd487032fdb093b10c8c14966b37195373053 [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
7#include "../../include/javascript/resource.h"
8
Nico Weber9d8ec5a2015-08-04 13:00:21 -07009CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT id) {
10 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.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080028 case IDS_STRING_NOTSUPPORT:
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.";
Tom Sepez2b0ed942015-02-27 13:58:29 -080048 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070049 return L"";
50 }
Tom Sepez2b0ed942015-02-27 13:58:29 -080051}
Tom Sepez3a832662015-03-02 12:59:05 -080052
53CFX_WideString JSFormatErrorString(const char* class_name,
54 const char* property_name,
55 const CFX_WideString& details) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070056 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 Sepez3a832662015-03-02 12:59:05 -080064}