Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: fpdfsdk/src/javascript/Consts.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/Consts.h ('k') | fpdfsdk/src/javascript/Document.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "fpdfsdk/src/javascript/Consts.h"
8
9 #include "fpdfsdk/include/javascript/IJavaScript.h"
10 #include "fpdfsdk/src/javascript/JS_Define.h"
11 #include "fpdfsdk/src/javascript/JS_Object.h"
12 #include "fpdfsdk/src/javascript/JS_Value.h"
13
14 BEGIN_JS_STATIC_CONST(CJS_Border)
15 JS_STATIC_CONST_ENTRY_STRING(L"s", L"solid")
16 JS_STATIC_CONST_ENTRY_STRING(L"b", L"beveled")
17 JS_STATIC_CONST_ENTRY_STRING(L"d", L"dashed")
18 JS_STATIC_CONST_ENTRY_STRING(L"i", L"inset")
19 JS_STATIC_CONST_ENTRY_STRING(L"u", L"underline")
20 END_JS_STATIC_CONST()
21 IMPLEMENT_JS_CLASS_CONST(CJS_Border, border)
22
23 BEGIN_JS_STATIC_CONST(CJS_Display)
24 JS_STATIC_CONST_ENTRY_NUMBER(L"visible", 0)
25 JS_STATIC_CONST_ENTRY_NUMBER(L"hidden", 1)
26 JS_STATIC_CONST_ENTRY_NUMBER(L"noPrint", 2)
27 JS_STATIC_CONST_ENTRY_NUMBER(L"noView", 3)
28 END_JS_STATIC_CONST()
29 IMPLEMENT_JS_CLASS_CONST(CJS_Display, display)
30
31 BEGIN_JS_STATIC_CONST(CJS_Font)
32 JS_STATIC_CONST_ENTRY_STRING(L"Times", L"Times-Roman")
33 JS_STATIC_CONST_ENTRY_STRING(L"TimesB", L"Times-Bold")
34 JS_STATIC_CONST_ENTRY_STRING(L"TimesI", L"Times-Italic")
35 JS_STATIC_CONST_ENTRY_STRING(L"TimesBI", L"Times-BoldItalic")
36 JS_STATIC_CONST_ENTRY_STRING(L"Helv", L"Helvetica")
37 JS_STATIC_CONST_ENTRY_STRING(L"HelvB", L"Helvetica-Bold")
38 JS_STATIC_CONST_ENTRY_STRING(L"HelvI", L"Helvetica-Oblique")
39 JS_STATIC_CONST_ENTRY_STRING(L"HelvBI", L"Helvetica-BoldOblique")
40 JS_STATIC_CONST_ENTRY_STRING(L"Cour", L"Courier")
41 JS_STATIC_CONST_ENTRY_STRING(L"CourB", L"Courier-Bold")
42 JS_STATIC_CONST_ENTRY_STRING(L"CourI", L"Courier-Oblique")
43 JS_STATIC_CONST_ENTRY_STRING(L"CourBI", L"Courier-BoldOblique")
44 JS_STATIC_CONST_ENTRY_STRING(L"Symbol", L"Symbol")
45 JS_STATIC_CONST_ENTRY_STRING(L"ZapfD", L"ZapfDingbats")
46 END_JS_STATIC_CONST()
47 IMPLEMENT_JS_CLASS_CONST(CJS_Font, font)
48
49 BEGIN_JS_STATIC_CONST(CJS_Highlight)
50 JS_STATIC_CONST_ENTRY_STRING(L"n", L"none")
51 JS_STATIC_CONST_ENTRY_STRING(L"i", L"invert")
52 JS_STATIC_CONST_ENTRY_STRING(L"p", L"push")
53 JS_STATIC_CONST_ENTRY_STRING(L"o", L"outline")
54 END_JS_STATIC_CONST()
55 IMPLEMENT_JS_CLASS_CONST(CJS_Highlight, highlight)
56
57 BEGIN_JS_STATIC_CONST(CJS_Position)
58 JS_STATIC_CONST_ENTRY_NUMBER(L"textOnly", 0)
59 JS_STATIC_CONST_ENTRY_NUMBER(L"iconOnly", 1)
60 JS_STATIC_CONST_ENTRY_NUMBER(L"iconTextV", 2)
61 JS_STATIC_CONST_ENTRY_NUMBER(L"textIconV", 3)
62 JS_STATIC_CONST_ENTRY_NUMBER(L"iconTextH", 4)
63 JS_STATIC_CONST_ENTRY_NUMBER(L"textIconH", 5)
64 JS_STATIC_CONST_ENTRY_NUMBER(L"overlay", 6)
65 END_JS_STATIC_CONST()
66 IMPLEMENT_JS_CLASS_CONST(CJS_Position, position)
67
68 BEGIN_JS_STATIC_CONST(CJS_ScaleHow)
69 JS_STATIC_CONST_ENTRY_NUMBER(L"proportional", 0)
70 JS_STATIC_CONST_ENTRY_NUMBER(L"anamorphic", 1)
71 END_JS_STATIC_CONST()
72 IMPLEMENT_JS_CLASS_CONST(CJS_ScaleHow, scaleHow)
73
74 BEGIN_JS_STATIC_CONST(CJS_ScaleWhen)
75 JS_STATIC_CONST_ENTRY_NUMBER(L"always", 0)
76 JS_STATIC_CONST_ENTRY_NUMBER(L"never", 1)
77 JS_STATIC_CONST_ENTRY_NUMBER(L"tooBig", 2)
78 JS_STATIC_CONST_ENTRY_NUMBER(L"tooSmall", 3)
79 END_JS_STATIC_CONST()
80 IMPLEMENT_JS_CLASS_CONST(CJS_ScaleWhen, scaleWhen)
81
82 BEGIN_JS_STATIC_CONST(CJS_Style)
83 JS_STATIC_CONST_ENTRY_STRING(L"ch", L"check")
84 JS_STATIC_CONST_ENTRY_STRING(L"cr", L"cross")
85 JS_STATIC_CONST_ENTRY_STRING(L"di", L"diamond")
86 JS_STATIC_CONST_ENTRY_STRING(L"ci", L"circle")
87 JS_STATIC_CONST_ENTRY_STRING(L"st", L"star")
88 JS_STATIC_CONST_ENTRY_STRING(L"sq", L"square")
89 END_JS_STATIC_CONST()
90 IMPLEMENT_JS_CLASS_CONST(CJS_Style, style)
91
92 BEGIN_JS_STATIC_CONST(CJS_Zoomtype)
93 JS_STATIC_CONST_ENTRY_STRING(L"none", L"NoVary")
94 JS_STATIC_CONST_ENTRY_STRING(L"fitP", L"FitPage")
95 JS_STATIC_CONST_ENTRY_STRING(L"fitW", L"FitWidth")
96 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight")
97 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth")
98 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred")
99 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth")
100 END_JS_STATIC_CONST()
101 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
102
103 #define GLOBAL_STRING(rt, name, value) \
104 FXJS_DefineGlobalConst( \
105 (rt)->GetIsolate(), (name), \
106 [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
107 info.GetReturnValue().Set(FXJS_NewString(info.GetIsolate(), (value))); \
108 })
109
110 void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) {
111 GLOBAL_STRING(pRuntime, L"IDS_GREATER_THAN",
112 L"Invalid value: must be greater than or equal to % s.");
113
114 GLOBAL_STRING(pRuntime, L"IDS_GT_AND_LT",
115 L"Invalid value: must be greater than or equal to % s "
116 L"and less than or equal to % s.");
117
118 GLOBAL_STRING(pRuntime, L"IDS_LESS_THAN",
119 L"Invalid value: must be less than or equal to % s.");
120
121 GLOBAL_STRING(pRuntime, L"IDS_INVALID_MONTH", L"**Invalid**");
122 GLOBAL_STRING(
123 pRuntime, L"IDS_INVALID_DATE",
124 L"Invalid date / time: please ensure that the date / time exists.Field");
125
126 GLOBAL_STRING(pRuntime, L"IDS_INVALID_VALUE",
127 L"The value entered does not match the format of the field");
128
129 GLOBAL_STRING(pRuntime, L"IDS_AM", L"am");
130 GLOBAL_STRING(pRuntime, L"IDS_PM", L"pm");
131 GLOBAL_STRING(pRuntime, L"IDS_MONTH_INFO",
132 L"January[1] February[2] March[3] April[4] May[5] "
133 L"June[6] July[7] August[8] September[9] October[10] "
134 L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] "
135 L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] "
136 L"Dec[12]");
137
138 GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **");
139 }
140
141 #define GLOBAL_ARRAY(rt, name, ...) \
142 { \
143 const FX_WCHAR* values[] = {__VA_ARGS__}; \
144 v8::Local<v8::Array> array = FXJS_NewArray((rt)->GetIsolate()); \
145 for (size_t i = 0; i < FX_ArraySize(values); ++i) \
146 array->Set(i, FXJS_NewString((rt)->GetIsolate(), values[i])); \
147 rt->SetConstArray(name, array); \
148 FXJS_DefineGlobalConst( \
149 (rt)->GetIsolate(), (name), \
150 [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
151 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>( \
152 FXJS_GetRuntimeFromIsolate(info.GetIsolate())); \
153 if (pRuntime) \
154 info.GetReturnValue().Set(pRuntime->GetConstArray(name)); \
155 }); \
156 }
157
158 void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) {
159 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_DOT_SEP", L"[+-]?\\d*\\.?\\d*");
160 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_COMMIT_DOT_SEP",
161 L"[+-]?\\d+(\\.\\d+)?", // -1.0 or -1
162 L"[+-]?\\.\\d+", // -.1
163 L"[+-]?\\d+\\."); // -1.
164
165 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_COMMA_SEP", L"[+-]?\\d*,?\\d*");
166 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_COMMIT_COMMA_SEP",
167 L"[+-]?\\d+([.,]\\d+)?", // -1,0 or -1
168 L"[+-]?[.,]\\d+", // -,1
169 L"[+-]?\\d+[.,]"); // -1,
170
171 GLOBAL_ARRAY(pRuntime, L"RE_ZIP_ENTRY", L"\\d{0,5}");
172 GLOBAL_ARRAY(pRuntime, L"RE_ZIP_COMMIT", L"\\d{5}");
173 GLOBAL_ARRAY(pRuntime, L"RE_ZIP4_ENTRY", L"\\d{0,5}(\\.|[- ])?\\d{0,4}");
174 GLOBAL_ARRAY(pRuntime, L"RE_ZIP4_COMMIT", L"\\d{5}(\\.|[- ])?\\d{4}");
175 GLOBAL_ARRAY(pRuntime, L"RE_PHONE_ENTRY",
176 // 555-1234 or 408 555-1234
177 L"\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
178
179 // (408
180 L"\\(\\d{0,3}",
181
182 // (408) 555-1234
183 // (allow the addition of parens as an afterthought)
184 L"\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
185
186 // (408 555-1234
187 L"\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
188
189 // 408) 555-1234
190 L"\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
191
192 // international
193 L"011(\\.|[- \\d])*");
194
195 GLOBAL_ARRAY(
196 pRuntime, L"RE_PHONE_COMMIT", L"\\d{3}(\\.|[- ])?\\d{4}", // 555-1234
197 L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // 408 555-1234
198 L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // (408) 555-1234
199 L"011(\\.|[- \\d])*"); // international
200
201 GLOBAL_ARRAY(pRuntime, L"RE_SSN_ENTRY",
202 L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}");
203
204 GLOBAL_ARRAY(pRuntime, L"RE_SSN_COMMIT",
205 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}");
206 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/Consts.h ('k') | fpdfsdk/src/javascript/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698