• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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 "fxjs/js_resources.h"
8 
JSGetStringFromID(JSMessage msg)9 WideString JSGetStringFromID(JSMessage msg) {
10   const char* msg_string = "";
11   switch (msg) {
12     case JSMessage::kAlert:
13       msg_string = "Alert";
14       break;
15     case JSMessage::kParamError:
16       msg_string = "Incorrect number of parameters passed to function.";
17       break;
18     case JSMessage::kInvalidInputError:
19       msg_string = "The input value is invalid.";
20       break;
21     case JSMessage::kParamTooLongError:
22       msg_string = "The input value is too long.";
23       break;
24     case JSMessage::kParseDateError:
25       msg_string =
26           "The input value can't be parsed as a valid date/time (%ls).";
27       break;
28     case JSMessage::kRangeBetweenError:
29       msg_string =
30           "The input value must be greater than or equal to %ls"
31           " and less than or equal to %ls.";
32       break;
33     case JSMessage::kRangeGreaterError:
34       msg_string = "The input value must be greater than or equal to %ls.";
35       break;
36     case JSMessage::kRangeLessError:
37       msg_string = "The input value must be less than or equal to %ls.";
38       break;
39     case JSMessage::kNotSupportedError:
40       msg_string = "Operation not supported.";
41       break;
42     case JSMessage::kBusyError:
43       msg_string = "System is busy.";
44       break;
45     case JSMessage::kDuplicateEventError:
46       msg_string = "Duplicate formfield event found.";
47       break;
48     case JSMessage::kSecondParamNotDateError:
49       msg_string = "The second parameter can't be converted to a Date.";
50       break;
51     case JSMessage::kSecondParamInvalidDateError:
52       msg_string = "The second parameter is an invalid Date.";
53       break;
54     case JSMessage::kGlobalNotFoundError:
55       msg_string = "Global value not found.";
56       break;
57     case JSMessage::kReadOnlyError:
58       msg_string = "Cannot assign to readonly property.";
59       break;
60     case JSMessage::kTypeError:
61       msg_string = "Incorrect parameter type.";
62       break;
63     case JSMessage::kValueError:
64       msg_string = "Incorrect parameter value.";
65       break;
66     case JSMessage::kPermissionError:
67       msg_string = "Permission denied.";
68       break;
69     case JSMessage::kBadObjectError:
70       msg_string = "Object no longer exists.";
71       break;
72     case JSMessage::kObjectTypeError:
73       msg_string = "Object is of the wrong type.";
74       break;
75     case JSMessage::kUnknownProperty:
76       msg_string = "Unknown property.";
77       break;
78     case JSMessage::kInvalidSetError:
79       msg_string = "Set not possible, invalid or unknown.";
80       break;
81     case JSMessage::kUserGestureRequiredError:
82       msg_string = "User gesture required.";
83       break;
84     case JSMessage::kTooManyOccurances:
85       msg_string = "Too many occurances.";
86       break;
87     case JSMessage::kUnknownMethod:
88       msg_string = "Unknown method.";
89       break;
90     default:
91       NOTREACHED();
92       break;
93   }
94   return WideString::FromASCII(msg_string);
95 }
96 
JSFormatErrorString(const char * class_name,const char * property_name,const WideString & details)97 WideString JSFormatErrorString(const char* class_name,
98                                const char* property_name,
99                                const WideString& details) {
100   WideString result = WideString::FromDefANSI(class_name);
101   if (property_name) {
102     result += L".";
103     result += WideString::FromDefANSI(property_name);
104   }
105   result += L": ";
106   result += details;
107   return result;
108 }
109