Initial commit.
[pdfium.git] / fpdfsdk / src / javascript / Consts.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../include/javascript/JavaScript.h"\r
8 #include "../../include/javascript/IJavaScript.h"\r
9 #include "../../include/javascript/JS_Define.h"\r
10 #include "../../include/javascript/JS_Object.h"\r
11 #include "../../include/javascript/JS_Value.h"\r
12 #include "../../include/javascript/Consts.h"\r
13 \r
14 /* ------------------------------ border ------------------------------ */\r
15 \r
16 BEGIN_JS_STATIC_CONST(CJS_Border)\r
17         JS_STATIC_CONST_ENTRY_STRING(s, solid)\r
18         JS_STATIC_CONST_ENTRY_STRING(b, beveled)\r
19         JS_STATIC_CONST_ENTRY_STRING(d, dashed)\r
20         JS_STATIC_CONST_ENTRY_STRING(i, inset)\r
21         JS_STATIC_CONST_ENTRY_STRING(u, underline)\r
22 END_JS_STATIC_CONST()\r
23 \r
24 IMPLEMENT_JS_CLASS_CONST(CJS_Border,border)\r
25 \r
26 /* ------------------------------ display ------------------------------ */\r
27 \r
28 BEGIN_JS_STATIC_CONST(CJS_Display)\r
29         JS_STATIC_CONST_ENTRY_NUMBER(visible,   0)\r
30         JS_STATIC_CONST_ENTRY_NUMBER(hidden,    1)\r
31         JS_STATIC_CONST_ENTRY_NUMBER(noPrint,   2)\r
32         JS_STATIC_CONST_ENTRY_NUMBER(noView,    3)\r
33 END_JS_STATIC_CONST()\r
34 \r
35 IMPLEMENT_JS_CLASS_CONST(CJS_Display,display)\r
36 \r
37 /* ------------------------------ font ------------------------------ */\r
38 \r
39 BEGIN_JS_STATIC_CONST(CJS_Font)\r
40         JS_STATIC_CONST_ENTRY_STRING(Times,             Times-Roman)\r
41         JS_STATIC_CONST_ENTRY_STRING(TimesB,    Times-Bold)\r
42         JS_STATIC_CONST_ENTRY_STRING(TimesI,    Times-Italic)\r
43         JS_STATIC_CONST_ENTRY_STRING(TimesBI,   Times-BoldItalic)\r
44         JS_STATIC_CONST_ENTRY_STRING(Helv,              Helvetica)\r
45         JS_STATIC_CONST_ENTRY_STRING(HelvB,             Helvetica-Bold)\r
46         JS_STATIC_CONST_ENTRY_STRING(HelvI,             Helvetica-Oblique)\r
47         JS_STATIC_CONST_ENTRY_STRING(HelvBI,    Helvetica-BoldOblique)\r
48         JS_STATIC_CONST_ENTRY_STRING(Cour,              Courier)\r
49         JS_STATIC_CONST_ENTRY_STRING(CourB,             Courier-Bold)\r
50         JS_STATIC_CONST_ENTRY_STRING(CourI,             Courier-Oblique)\r
51         JS_STATIC_CONST_ENTRY_STRING(CourBI,    Courier-BoldOblique)\r
52         JS_STATIC_CONST_ENTRY_STRING(Symbol,    Symbol)\r
53         JS_STATIC_CONST_ENTRY_STRING(ZapfD,             ZapfDingbats)\r
54 END_JS_STATIC_CONST()\r
55 \r
56 IMPLEMENT_JS_CLASS_CONST(CJS_Font,font)\r
57 \r
58 /* ------------------------------ highlight ------------------------------ */\r
59 \r
60 BEGIN_JS_STATIC_CONST(CJS_Highlight)\r
61         JS_STATIC_CONST_ENTRY_STRING(n, none)\r
62         JS_STATIC_CONST_ENTRY_STRING(i, invert)\r
63         JS_STATIC_CONST_ENTRY_STRING(p, push)\r
64         JS_STATIC_CONST_ENTRY_STRING(o, outline)\r
65 END_JS_STATIC_CONST()\r
66 \r
67 IMPLEMENT_JS_CLASS_CONST(CJS_Highlight,highlight)\r
68 \r
69 /* ------------------------------ position ------------------------------ */\r
70 \r
71 BEGIN_JS_STATIC_CONST(CJS_Position)\r
72         JS_STATIC_CONST_ENTRY_NUMBER(textOnly,          0)\r
73         JS_STATIC_CONST_ENTRY_NUMBER(iconOnly,          1)\r
74         JS_STATIC_CONST_ENTRY_NUMBER(iconTextV,         2)\r
75         JS_STATIC_CONST_ENTRY_NUMBER(textIconV,         3)\r
76         JS_STATIC_CONST_ENTRY_NUMBER(iconTextH,         4)\r
77         JS_STATIC_CONST_ENTRY_NUMBER(textIconH,         5)\r
78         JS_STATIC_CONST_ENTRY_NUMBER(overlay,           6)\r
79 END_JS_STATIC_CONST()\r
80 \r
81 IMPLEMENT_JS_CLASS_CONST(CJS_Position,position)\r
82 \r
83 /* ------------------------------ scaleHow ------------------------------ */\r
84 \r
85 BEGIN_JS_STATIC_CONST(CJS_ScaleHow)\r
86         JS_STATIC_CONST_ENTRY_NUMBER(proportional,      0)\r
87         JS_STATIC_CONST_ENTRY_NUMBER(anamorphic,        1)\r
88 END_JS_STATIC_CONST()\r
89 \r
90 IMPLEMENT_JS_CLASS_CONST(CJS_ScaleHow,scaleHow)\r
91 \r
92 /* ------------------------------ scaleWhen ------------------------------ */\r
93 \r
94 BEGIN_JS_STATIC_CONST(CJS_ScaleWhen)\r
95         JS_STATIC_CONST_ENTRY_NUMBER(always,    0)\r
96         JS_STATIC_CONST_ENTRY_NUMBER(never,             1)\r
97         JS_STATIC_CONST_ENTRY_NUMBER(tooBig,    2)\r
98         JS_STATIC_CONST_ENTRY_NUMBER(tooSmall,  3)\r
99 END_JS_STATIC_CONST()\r
100 \r
101 IMPLEMENT_JS_CLASS_CONST(CJS_ScaleWhen,scaleWhen)\r
102 \r
103 /* ------------------------------ style ------------------------------ */\r
104 \r
105 BEGIN_JS_STATIC_CONST(CJS_Style)\r
106         JS_STATIC_CONST_ENTRY_STRING(ch,        check)\r
107         JS_STATIC_CONST_ENTRY_STRING(cr,        cross)\r
108         JS_STATIC_CONST_ENTRY_STRING(di,        diamond)\r
109         JS_STATIC_CONST_ENTRY_STRING(ci,        circle)\r
110         JS_STATIC_CONST_ENTRY_STRING(st,        star)\r
111         JS_STATIC_CONST_ENTRY_STRING(sq,        square)\r
112 END_JS_STATIC_CONST()\r
113 \r
114 IMPLEMENT_JS_CLASS_CONST(CJS_Style,style)\r
115 \r
116 \r
117 /* ------------------------------ zoomtype ------------------------------ */\r
118 \r
119 BEGIN_JS_STATIC_CONST(CJS_Zoomtype)\r
120         JS_STATIC_CONST_ENTRY_STRING(none,      NoVary)\r
121         JS_STATIC_CONST_ENTRY_STRING(fitP,      FitPage)\r
122         JS_STATIC_CONST_ENTRY_STRING(fitW,      FitWidth)\r
123         JS_STATIC_CONST_ENTRY_STRING(fitH,      FitHeight)\r
124         JS_STATIC_CONST_ENTRY_STRING(fitV,      FitVisibleWidth)\r
125         JS_STATIC_CONST_ENTRY_STRING(pref,      Preferred)\r
126         JS_STATIC_CONST_ENTRY_STRING(refW,      ReflowWidth)\r
127 END_JS_STATIC_CONST()\r
128 \r
129 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype,zoomtype)\r
130 \r
131 /* ------------------------------ CJS_GlobalConsts ------------------------------ */\r
132 \r
133 int     CJS_GlobalConsts::Init(IJS_Runtime* pRuntime)\r
134 {\r
135         DEFINE_GLOBAL_CONST(pRuntime, IDS_GREATER_THAN , Invalid value: must be greater than or equal to %s.);\r
136         DEFINE_GLOBAL_CONST(pRuntime, IDS_GT_AND_LT,Invalid value: must be greater than or equal to %s and less than or equal to %s.);\r
137         DEFINE_GLOBAL_CONST(pRuntime, IDS_LESS_THAN,Invalid value: must be less than or equal to %s.);\r
138         DEFINE_GLOBAL_CONST(pRuntime, IDS_INVALID_MONTH,** Invalid **);\r
139         DEFINE_GLOBAL_CONST(pRuntime, IDS_INVALID_DATE,Invalid date/time: please ensure that the date/time exists. Field);\r
140         DEFINE_GLOBAL_CONST(pRuntime, IDS_INVALID_VALUE,The value entered does not match the format of the field);\r
141         DEFINE_GLOBAL_CONST(pRuntime, IDS_AM,am);\r
142         DEFINE_GLOBAL_CONST(pRuntime, IDS_PM,pm);\r
143         DEFINE_GLOBAL_CONST(pRuntime, IDS_MONTH_INFO,January[1]February[2]March[3]April[4]May[5]June[6]July[7]August[8]September[9]October[10]November[11]December[12]Sept[9]Jan[1]Feb[2]Mar[3]Apr[4]Jun[6]Jul[7]Aug[8]Sep[9]Oct[10]Nov[11]Dec[12]);\r
144         DEFINE_GLOBAL_CONST(pRuntime, IDS_STARTUP_CONSOLE_MSG, ** ^_^ **);\r
145 \r
146         return 0;\r
147 }\r
148 \r
149 /* ------------------------------ CJS_GlobalArrays ------------------------------ */\r
150 \r
151 int     CJS_GlobalArrays::Init(IJS_Runtime* pRuntime)\r
152 {\r
153         {\r
154                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_NUMBER_ENTRY_DOT_SEP";\r
155                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"[+-]?\\d*\\.?\\d*"};\r
156                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
157         }\r
158 \r
159         {\r
160                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_NUMBER_COMMIT_DOT_SEP";\r
161                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"[+-]?\\d+(\\.\\d+)?",                /* -1.0 or -1 */\r
162                                                                                 (FX_LPCWSTR)L"[+-]?\\.\\d+",                            /* -.1 */\r
163                                                                                 (FX_LPCWSTR)L"[+-]?\\d+\\."                             /* -1. */\r
164                                                                                 };\r
165                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
166         }\r
167 \r
168         {\r
169                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_NUMBER_ENTRY_COMMA_SEP";\r
170                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"[+-]?\\d*,?\\d*"};\r
171                 \r
172                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
173         }\r
174 \r
175         {\r
176                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_NUMBER_COMMIT_COMMA_SEP";\r
177                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"[+-]?\\d+([.,]\\d+)?",               /* -1,0 or -1 */\r
178                                                                                 (FX_LPCWSTR)L"[+-]?[.,]\\d+",                   /* -,1 */\r
179                                         (FX_LPCWSTR)L"[+-]?\\d+[.,]"                            /* -1, */\r
180                                         };\r
181                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
182         }\r
183 \r
184         {\r
185                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_ZIP_ENTRY";\r
186         FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"\\d{0,5}"};\r
187                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
188         }\r
189 \r
190         {\r
191                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_ZIP_COMMIT";\r
192                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"\\d{5}"};\r
193                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
194         }\r
195 \r
196         {\r
197                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_ZIP4_ENTRY";\r
198                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"\\d{0,5}(\\.|[- ])?\\d{0,4}"};\r
199                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
200         }\r
201 \r
202         {\r
203                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_ZIP4_COMMIT";\r
204                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"\\d{5}(\\.|[- ])?\\d{4}"};\r
205                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
206         }\r
207 \r
208         {\r
209                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_PHONE_ENTRY";\r
210                 FX_LPCWSTR ArrayContent[] = {\r
211                                 (FX_LPCWSTR)L"\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",          /* 555-1234 or 408 555-1234 */\r
212                                 (FX_LPCWSTR)L"\\(\\d{0,3}",                                                                                     /* (408 */\r
213                                 (FX_LPCWSTR)L"\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",    /* (408) 555-1234 */\r
214                                         /* (allow the addition of parens as an afterthought) */\r
215                                 (FX_LPCWSTR)L"\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",       /* (408 555-1234 */\r
216                                 (FX_LPCWSTR)L"\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",       /* 408) 555-1234 */\r
217                                 (FX_LPCWSTR)L"011(\\.|[- \\d])*"                                                                                /* international */\r
218                         };\r
219                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
220         }\r
221 \r
222         {\r
223                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_PHONE_COMMIT";\r
224                 FX_LPCWSTR ArrayContent[] = {\r
225                                         (FX_LPCWSTR)L"\\d{3}(\\.|[- ])?\\d{4}",                                                 /* 555-1234 */\r
226                                         (FX_LPCWSTR)L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}",                        /* 408 555-1234 */\r
227                                         (FX_LPCWSTR)L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}",  /* (408) 555-1234 */\r
228                                         (FX_LPCWSTR)L"011(\\.|[- \\d])*"                                                                        /* international */\r
229                                 };\r
230                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
231         }\r
232 \r
233         {\r
234                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_SSN_ENTRY";\r
235                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}"};\r
236                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
237         }\r
238 \r
239         {\r
240                 FX_LPCWSTR ArrayName = (FX_LPCWSTR)L"RE_SSN_COMMIT";\r
241                 FX_LPCWSTR ArrayContent[] = {(FX_LPCWSTR)L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"};\r
242                 DEFINE_GLOBAL_ARRAY(pRuntime);\r
243         }\r
244 \r
245         return 0;\r
246 }\r
247 \r