Initial commit.
[pdfium.git] / fpdfsdk / src / javascript / JS_EventHandler.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_EventHandler.h"\r
10 //#include "../../include/javascript/JS_ResMgr.h"\r
11 #include "../../include/javascript/JS_Context.h"\r
12 #include "../../include/javascript/JS_Runtime.h"\r
13 #include "../../include/javascript/JS_Define.h"\r
14 #include "../../include/javascript/JS_Object.h"\r
15 #include "../../include/javascript/JS_Value.h"\r
16 #include "../../include/javascript/Document.h"\r
17 #include "../../include/javascript/Field.h"\r
18 \r
19 /* ---------------------------- CJS_EventHandler ---------------------------- */\r
20 \r
21 CJS_EventHandler::CJS_EventHandler(CJS_Context * pContext)       :\r
22         m_pJSContext(pContext),\r
23         m_eEventType(JET_UNKNOWN),\r
24         m_bValid(FALSE),\r
25         m_pWideStrChange(NULL),\r
26         m_nCommitKey(-1),\r
27         m_bKeyDown(FALSE),\r
28         m_bModifier(FALSE),\r
29         m_bShift(FALSE),\r
30         m_pISelEnd(NULL),\r
31         m_nSelEndDu(0),\r
32         m_pISelStart(NULL),\r
33         m_nSelStartDu(0),\r
34         m_bWillCommit(FALSE),\r
35         m_pValue(NULL),\r
36         m_bFieldFull(FALSE),\r
37         m_pbRc(NULL),\r
38         m_bRcDu(FALSE),\r
39         m_pSourceDoc(NULL),\r
40         m_pTargetBookMark(NULL),\r
41         m_pTargetDoc(NULL),\r
42         m_pTargetAnnot(NULL)\r
43 {\r
44 }\r
45 \r
46 CJS_EventHandler::~CJS_EventHandler()\r
47 {\r
48 }\r
49 \r
50 void CJS_EventHandler::OnApp_Init()\r
51 {\r
52         Initial(JET_APP_INIT);\r
53 }\r
54 \r
55 void CJS_EventHandler::OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName)\r
56 {\r
57         Initial(JET_DOC_OPEN);\r
58 \r
59         m_pTargetDoc = pDoc;\r
60         m_strTargetName = strTargetName;        \r
61 }\r
62 \r
63 void CJS_EventHandler::OnDoc_WillPrint(CPDFSDK_Document* pDoc)\r
64 {\r
65         Initial(JET_DOC_WILLPRINT);\r
66 \r
67         m_pTargetDoc = pDoc;    \r
68 }\r
69 \r
70 void CJS_EventHandler::OnDoc_DidPrint(CPDFSDK_Document* pDoc)\r
71 {\r
72         Initial(JET_DOC_DIDPRINT);\r
73         \r
74         m_pTargetDoc = pDoc;            \r
75 }\r
76 \r
77 void CJS_EventHandler::OnDoc_WillSave(CPDFSDK_Document* pDoc)\r
78 {\r
79         Initial(JET_DOC_WILLSAVE);\r
80         m_pTargetDoc = pDoc;            \r
81 }\r
82 \r
83 void CJS_EventHandler::OnDoc_DidSave(CPDFSDK_Document* pDoc)\r
84 {\r
85         Initial(JET_DOC_DIDSAVE);       \r
86         \r
87         m_pTargetDoc = pDoc;    \r
88 }\r
89 \r
90 void CJS_EventHandler::OnDoc_WillClose(CPDFSDK_Document* pDoc)\r
91 {\r
92         Initial(JET_DOC_WILLCLOSE);\r
93 \r
94         m_pTargetDoc = pDoc;    \r
95 }\r
96 \r
97 void CJS_EventHandler::OnPage_Open(CPDFSDK_Document* pDoc)\r
98 {\r
99         Initial(JET_PAGE_OPEN);\r
100 \r
101         m_pTargetDoc = pDoc;\r
102 }\r
103 \r
104 void CJS_EventHandler::OnPage_Close(CPDFSDK_Document* pDoc)\r
105 {\r
106         Initial(JET_PAGE_CLOSE);\r
107         \r
108         m_pTargetDoc = pDoc;\r
109 }\r
110 \r
111 void CJS_EventHandler::OnPage_InView(CPDFSDK_Document* pDoc)\r
112 {\r
113         Initial(JET_PAGE_INVIEW);\r
114         \r
115         m_pTargetDoc = pDoc;\r
116 }\r
117 \r
118 void CJS_EventHandler::OnPage_OutView(CPDFSDK_Document* pDoc)\r
119 {\r
120         Initial(JET_PAGE_OUTVIEW);\r
121         \r
122         m_pTargetDoc = pDoc;\r
123 }\r
124 \r
125 void CJS_EventHandler::OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)\r
126 {\r
127         Initial(JET_FIELD_MOUSEENTER);\r
128 \r
129         m_bModifier = bModifier;\r
130         m_bShift = bShift;\r
131 \r
132         ASSERT(pTarget != NULL);\r
133         m_strTargetName = pTarget->GetFullName();\r
134 }\r
135 \r
136 void CJS_EventHandler::OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)\r
137 {\r
138         Initial(JET_FIELD_MOUSEEXIT);\r
139 \r
140         m_bModifier = bModifier;\r
141         m_bShift = bShift;\r
142         ASSERT(pTarget != NULL);\r
143         m_strTargetName = pTarget->GetFullName();       \r
144 }\r
145 \r
146 void CJS_EventHandler::OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)\r
147 {\r
148         Initial(JET_FIELD_MOUSEDOWN);\r
149         m_eEventType = JET_FIELD_MOUSEDOWN;\r
150         \r
151         m_bModifier = bModifier;\r
152         m_bShift = bShift;      \r
153         ASSERT(pTarget != NULL);\r
154         m_strTargetName = pTarget->GetFullName();\r
155 }\r
156 \r
157 void CJS_EventHandler::OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget)\r
158 {\r
159         Initial(JET_FIELD_MOUSEUP);\r
160 \r
161         m_bModifier = bModifier;\r
162         m_bShift = bShift;\r
163         ASSERT(pTarget != NULL);\r
164         m_strTargetName = pTarget->GetFullName();\r
165 }\r
166 \r
167 void CJS_EventHandler::OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, \r
168                                                                          const CFX_WideString& Value)\r
169 {\r
170         Initial(JET_FIELD_FOCUS);\r
171 \r
172         m_bModifier = bModifier;\r
173         m_bShift = bShift;  \r
174         ASSERT(pTarget != NULL);\r
175         m_strTargetName = pTarget->GetFullName();\r
176         m_pValue = (CFX_WideString*)&Value;\r
177 }\r
178 \r
179 void CJS_EventHandler::OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget,\r
180                                                                         const CFX_WideString& Value)\r
181 {\r
182         Initial(JET_FIELD_BLUR);\r
183 \r
184         m_bModifier = bModifier;\r
185         m_bShift = bShift;\r
186         ASSERT(pTarget != NULL);\r
187         m_strTargetName = pTarget->GetFullName();\r
188         m_pValue = (CFX_WideString*)&Value;     \r
189 }\r
190 \r
191 void CJS_EventHandler::OnField_Keystroke(int nCommitKey, CFX_WideString &strChange,\r
192                                                                                  const CFX_WideString& strChangeEx, FX_BOOL KeyDown,\r
193                                                                                  FX_BOOL bModifier, int& nSelEnd, int& nSelStart,\r
194                                                                                  FX_BOOL bShift, CPDF_FormField* pTarget,\r
195                                                                                  CFX_WideString& Value, FX_BOOL bWillCommit,\r
196                                                                                   FX_BOOL bFieldFull, FX_BOOL& bRc)\r
197 {\r
198         Initial(JET_FIELD_KEYSTROKE);\r
199         \r
200         m_nCommitKey = nCommitKey;\r
201         m_pWideStrChange = &strChange;\r
202         m_WideStrChangeEx = strChangeEx;\r
203         m_bKeyDown = KeyDown;\r
204         m_bModifier = bModifier;\r
205         m_pISelEnd = &nSelEnd;\r
206         m_pISelStart = &nSelStart;\r
207         m_bShift = bShift;      \r
208         ASSERT(pTarget != NULL);\r
209         m_strTargetName = pTarget->GetFullName();\r
210         m_pValue = &Value;\r
211         m_bWillCommit = bWillCommit;    \r
212         m_pbRc = &bRc;\r
213         m_bFieldFull = bFieldFull;\r
214 }\r
215 \r
216 void CJS_EventHandler::OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx,\r
217                                                                                 FX_BOOL bKeyDown, FX_BOOL bModifier, FX_BOOL bShift,\r
218                                                                                 CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc)\r
219 {\r
220         Initial(JET_FIELD_VALIDATE);\r
221         \r
222         m_pWideStrChange = &strChange;\r
223         m_WideStrChangeEx = strChangeEx;        \r
224         m_bKeyDown = bKeyDown;\r
225         m_bModifier = bModifier;\r
226         m_bShift = bShift;\r
227         ASSERT(pTarget != NULL);\r
228         m_strTargetName = pTarget->GetFullName();\r
229         m_pValue = &Value;      \r
230         m_pbRc = &bRc;  \r
231 }\r
232 \r
233 void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, \r
234                                                                                  CFX_WideString& Value, FX_BOOL& bRc)\r
235 {\r
236         Initial(JET_FIELD_CALCULATE);\r
237 \r
238         if (pSource)\r
239                 m_strSourceName = pSource->GetFullName();\r
240         ASSERT(pTarget != NULL);\r
241         m_strTargetName = pTarget->GetFullName();\r
242     m_pValue = &Value;\r
243         m_pbRc = &bRc;\r
244 }\r
245 \r
246 void CJS_EventHandler::OnField_Format(int nCommitKey, CPDF_FormField* pTarget,\r
247                                                                           CFX_WideString& Value, FX_BOOL bWillCommit)\r
248 {\r
249         Initial(JET_FIELD_FORMAT);\r
250         \r
251         m_nCommitKey = nCommitKey;        \r
252         ASSERT(pTarget != NULL);\r
253         m_strTargetName = pTarget->GetFullName();\r
254         m_pValue = &Value;\r
255         m_bWillCommit = bWillCommit;\r
256 }\r
257 \r
258 void CJS_EventHandler::OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
259 {\r
260         Initial(JET_SCREEN_FOCUS);\r
261 \r
262         m_bModifier = bModifier;\r
263         m_bShift = bShift;\r
264         m_pTargetAnnot = pScreen;\r
265 }\r
266 \r
267 void CJS_EventHandler::OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
268 {\r
269         Initial(JET_SCREEN_BLUR);\r
270 \r
271         m_bModifier = bModifier;\r
272         m_bShift = bShift;\r
273         m_pTargetAnnot = pScreen;\r
274 }\r
275 \r
276 void CJS_EventHandler::OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
277 {\r
278         Initial(JET_SCREEN_OPEN);\r
279 \r
280         m_bModifier = bModifier;\r
281         m_bShift = bShift;\r
282         m_pTargetAnnot = pScreen;\r
283 }\r
284 \r
285 void CJS_EventHandler::OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
286 {\r
287         Initial(JET_SCREEN_CLOSE);\r
288 \r
289         m_bModifier = bModifier;\r
290         m_bShift = bShift;\r
291         m_pTargetAnnot = pScreen;\r
292 }\r
293 \r
294 void CJS_EventHandler::OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
295 {\r
296         Initial(JET_SCREEN_MOUSEDOWN);\r
297 \r
298         m_bModifier = bModifier;\r
299         m_bShift = bShift;\r
300         m_pTargetAnnot = pScreen;\r
301 }\r
302 \r
303 void CJS_EventHandler::OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
304 {\r
305         Initial(JET_SCREEN_MOUSEUP);\r
306 \r
307         m_bModifier = bModifier;\r
308         m_bShift = bShift;\r
309         m_pTargetAnnot = pScreen;\r
310 }\r
311 \r
312 void CJS_EventHandler::OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
313 {\r
314         Initial(JET_SCREEN_MOUSEENTER);\r
315 \r
316         m_bModifier = bModifier;\r
317         m_bShift = bShift;\r
318         m_pTargetAnnot = pScreen;\r
319 }\r
320 \r
321 void CJS_EventHandler::OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
322 {\r
323         Initial(JET_SCREEN_MOUSEEXIT);\r
324 \r
325         m_bModifier = bModifier;\r
326         m_bShift = bShift;\r
327         m_pTargetAnnot = pScreen;\r
328 }\r
329 \r
330 void CJS_EventHandler::OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
331 {\r
332         Initial(JET_SCREEN_INVIEW);\r
333 \r
334         m_bModifier = bModifier;\r
335         m_bShift = bShift;\r
336         m_pTargetAnnot = pScreen;\r
337 }\r
338 \r
339 void CJS_EventHandler::OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen)\r
340 {\r
341         Initial(JET_SCREEN_OUTVIEW);\r
342 \r
343         m_bModifier = bModifier;\r
344         m_bShift = bShift;\r
345         m_pTargetAnnot = pScreen;\r
346 }\r
347 \r
348 void CJS_EventHandler::OnLink_MouseUp(CPDFSDK_Document* pTarget)\r
349 {\r
350         Initial(JET_LINK_MOUSEUP);\r
351         \r
352         m_pTargetDoc = pTarget; \r
353 }\r
354 \r
355 void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark)\r
356 {\r
357         Initial(JET_BOOKMARK_MOUSEUP);\r
358 \r
359         m_pTargetBookMark = pBookMark;  \r
360 }\r
361 \r
362 void CJS_EventHandler::OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName)\r
363 {\r
364         Initial(JET_MENU_EXEC);\r
365 \r
366         m_pTargetDoc = pTarget;\r
367         m_strTargetName = strTargetName;\r
368 }\r
369 \r
370 void CJS_EventHandler::OnExternal_Exec()\r
371 {\r
372         Initial(JET_EXTERNAL_EXEC);\r
373 }\r
374 \r
375 void CJS_EventHandler::OnBatchExec(CPDFSDK_Document* pTarget)\r
376 {\r
377         Initial(JET_BATCH_EXEC);\r
378 \r
379         m_pTargetDoc = pTarget; \r
380 }\r
381 \r
382 void CJS_EventHandler::OnConsole_Exec()\r
383 {\r
384         Initial(JET_CONSOLE_EXEC);\r
385 }\r
386 \r
387 \r
388 void CJS_EventHandler::Initial(JS_EVENT_T type)\r
389 {\r
390         m_eEventType = type;\r
391 \r
392         m_strTargetName = L"";\r
393         m_strSourceName = L"";\r
394         m_pWideStrChange = NULL;\r
395         m_WideStrChangeDu = L"";\r
396         m_WideStrChangeEx = L"";\r
397         m_nCommitKey = -1;\r
398         m_bKeyDown = FALSE;\r
399         m_bModifier = FALSE;\r
400         m_bShift = FALSE;\r
401         m_pISelEnd = NULL;\r
402         m_nSelEndDu = 0;\r
403         m_pISelStart = NULL;\r
404         m_nSelStartDu = 0;\r
405         m_bWillCommit = FALSE;\r
406         m_pValue = NULL;\r
407         m_bFieldFull = FALSE;\r
408         m_pbRc = NULL;\r
409         m_bRcDu = FALSE;\r
410 \r
411         m_pSourceDoc = NULL;\r
412         m_pTargetBookMark = NULL;\r
413         m_pTargetDoc = NULL;\r
414         m_pTargetAnnot = NULL;\r
415 \r
416         m_bValid = TRUE;\r
417 }\r
418 \r
419 void CJS_EventHandler::Destroy()\r
420 {\r
421         m_bValid = FALSE;\r
422 }\r
423 \r
424 FX_BOOL CJS_EventHandler::IsValid()\r
425 {\r
426         return m_bValid;\r
427 }\r
428 \r
429 CFX_WideString & CJS_EventHandler::Change()\r
430 {\r
431         if (m_pWideStrChange != NULL)\r
432                 return *m_pWideStrChange;\r
433         else\r
434         {\r
435                 return m_WideStrChangeDu;\r
436         }\r
437 }\r
438 \r
439 CFX_WideString CJS_EventHandler::ChangeEx()\r
440 {\r
441         return m_WideStrChangeEx;\r
442 }\r
443 \r
444 int CJS_EventHandler::CommitKey()\r
445 {\r
446         return m_nCommitKey;\r
447 }\r
448 \r
449 FX_BOOL CJS_EventHandler::FieldFull()\r
450 {\r
451         return m_bFieldFull;\r
452 }\r
453 \r
454 FX_BOOL CJS_EventHandler::KeyDown()\r
455 {\r
456         return m_bKeyDown;\r
457 }\r
458 \r
459 FX_BOOL CJS_EventHandler::Modifier()\r
460 {\r
461         return m_bModifier;\r
462 }\r
463 \r
464 FX_LPCWSTR CJS_EventHandler::Name()\r
465 {\r
466         switch (m_eEventType)\r
467         {\r
468         case JET_APP_INIT:                      return (FX_LPCWSTR)L"Init";\r
469         case JET_BATCH_EXEC:            return (FX_LPCWSTR)L"Exec";\r
470         case JET_BOOKMARK_MOUSEUP:      return (FX_LPCWSTR)L"Mouse Up";\r
471         case JET_CONSOLE_EXEC:          return (FX_LPCWSTR)L"Exec";\r
472         case JET_DOC_DIDPRINT:          return (FX_LPCWSTR)L"DidPrint";\r
473         case JET_DOC_DIDSAVE:           return (FX_LPCWSTR)L"DidSave";\r
474         case JET_DOC_OPEN:                      return (FX_LPCWSTR)L"Open";\r
475         case JET_DOC_WILLCLOSE:         return (FX_LPCWSTR)L"WillClose";\r
476         case JET_DOC_WILLPRINT:         return (FX_LPCWSTR)L"WillPrint";\r
477         case JET_DOC_WILLSAVE:          return (FX_LPCWSTR)L"WillSave";\r
478         case JET_EXTERNAL_EXEC:         return (FX_LPCWSTR)L"Exec";\r
479         case JET_FIELD_FOCUS:           \r
480         case JET_SCREEN_FOCUS:          return (FX_LPCWSTR)L"Focus";\r
481         case JET_FIELD_BLUR:            \r
482         case JET_SCREEN_BLUR:           return (FX_LPCWSTR)L"Blur";\r
483         case JET_FIELD_MOUSEDOWN:\r
484         case JET_SCREEN_MOUSEDOWN:      return (FX_LPCWSTR)L"Mouse Down";\r
485         case JET_FIELD_MOUSEUP:         \r
486         case JET_SCREEN_MOUSEUP:        return (FX_LPCWSTR)L"Mouse Up";\r
487         case JET_FIELD_MOUSEENTER:\r
488         case JET_SCREEN_MOUSEENTER:     return (FX_LPCWSTR)L"Mouse Enter";\r
489         case JET_FIELD_MOUSEEXIT:\r
490         case JET_SCREEN_MOUSEEXIT:      return (FX_LPCWSTR)L"Mouse Exit";\r
491         case JET_FIELD_CALCULATE:       return (FX_LPCWSTR)L"Calculate";\r
492         case JET_FIELD_FORMAT:          return (FX_LPCWSTR)L"Format";\r
493         case JET_FIELD_KEYSTROKE:       return (FX_LPCWSTR)L"Keystroke";\r
494         case JET_FIELD_VALIDATE:        return (FX_LPCWSTR)L"Validate";\r
495         case JET_LINK_MOUSEUP:          return (FX_LPCWSTR)L"Mouse Up";\r
496         case JET_MENU_EXEC:                     return (FX_LPCWSTR)L"Exec";\r
497         case JET_PAGE_OPEN:             \r
498         case JET_SCREEN_OPEN:           return (FX_LPCWSTR)L"Open";\r
499         case JET_PAGE_CLOSE:\r
500         case JET_SCREEN_CLOSE:          return (FX_LPCWSTR)L"Close";\r
501         case JET_SCREEN_INVIEW: \r
502         case JET_PAGE_INVIEW:           return (FX_LPCWSTR)L"InView";\r
503         case JET_PAGE_OUTVIEW:\r
504         case JET_SCREEN_OUTVIEW:        return (FX_LPCWSTR)L"OutView";\r
505         default:\r
506                 return (FX_LPCWSTR)L"";\r
507         }\r
508 \r
509         return (FX_LPCWSTR)L"";\r
510 }\r
511 \r
512 FX_LPCWSTR CJS_EventHandler::Type()\r
513 {\r
514         switch (m_eEventType)\r
515         {\r
516         case JET_APP_INIT:                      return (FX_LPCWSTR)L"App";\r
517         case JET_BATCH_EXEC:            return (FX_LPCWSTR)L"Batch";\r
518         case JET_BOOKMARK_MOUSEUP:      return (FX_LPCWSTR)L"BookMark"; \r
519         case JET_CONSOLE_EXEC:          return (FX_LPCWSTR)L"Console";\r
520         case JET_DOC_DIDPRINT:\r
521         case JET_DOC_DIDSAVE:\r
522         case JET_DOC_OPEN:\r
523         case JET_DOC_WILLCLOSE:\r
524         case JET_DOC_WILLPRINT:\r
525         case JET_DOC_WILLSAVE:          return (FX_LPCWSTR)L"Doc";\r
526         case JET_EXTERNAL_EXEC:         return (FX_LPCWSTR)L"External";\r
527         case JET_FIELD_BLUR:\r
528         case JET_FIELD_FOCUS:\r
529         case JET_FIELD_MOUSEDOWN:\r
530         case JET_FIELD_MOUSEENTER:\r
531         case JET_FIELD_MOUSEEXIT:\r
532         case JET_FIELD_MOUSEUP:\r
533         case JET_FIELD_CALCULATE:\r
534         case JET_FIELD_FORMAT:\r
535         case JET_FIELD_KEYSTROKE:\r
536         case JET_FIELD_VALIDATE:        return (FX_LPCWSTR)L"Field";\r
537         case JET_SCREEN_FOCUS:\r
538         case JET_SCREEN_BLUR:\r
539         case JET_SCREEN_OPEN:\r
540         case JET_SCREEN_CLOSE:\r
541         case JET_SCREEN_MOUSEDOWN:\r
542         case JET_SCREEN_MOUSEUP:\r
543         case JET_SCREEN_MOUSEENTER:\r
544         case JET_SCREEN_MOUSEEXIT:\r
545         case JET_SCREEN_INVIEW:\r
546         case JET_SCREEN_OUTVIEW:        return (FX_LPCWSTR)L"Screen";\r
547         case JET_LINK_MOUSEUP:          return (FX_LPCWSTR)L"Link";     \r
548         case JET_MENU_EXEC:                     return (FX_LPCWSTR)L"Menu";\r
549         case JET_PAGE_OPEN:\r
550         case JET_PAGE_CLOSE:\r
551         case JET_PAGE_INVIEW:\r
552         case JET_PAGE_OUTVIEW:return (FX_LPCWSTR)L"Page";\r
553         default:\r
554                 return (FX_LPCWSTR)L"";\r
555         }\r
556 \r
557         return (FX_LPCWSTR)L"";\r
558 }\r
559 \r
560 FX_BOOL& CJS_EventHandler::Rc()\r
561 {\r
562         if (m_pbRc != NULL)\r
563                 return *m_pbRc;\r
564         else\r
565         {           \r
566                 return m_bRcDu;\r
567         }\r
568 }\r
569 \r
570 int & CJS_EventHandler::SelEnd()\r
571 {\r
572         if (m_pISelEnd != NULL)\r
573         {\r
574                 return *m_pISelEnd;\r
575         }\r
576         else\r
577         {\r
578                 return m_nSelEndDu;\r
579         }\r
580 }\r
581 \r
582 int & CJS_EventHandler::SelStart()\r
583 {\r
584         if (m_pISelStart != NULL)\r
585                 return * m_pISelStart;\r
586         else\r
587         {\r
588                 return m_nSelStartDu;\r
589         }\r
590 }\r
591 \r
592 FX_BOOL CJS_EventHandler::Shift()\r
593 {\r
594         return m_bShift;\r
595 }\r
596 \r
597 Field* CJS_EventHandler::Source()\r
598 {\r
599         ASSERT(m_pJSContext != NULL);\r
600 \r
601         CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();\r
602 \r
603         JSFXObject  pDocObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));\r
604         ASSERT(pDocObj.IsEmpty() == FALSE);\r
605         JSFXObject  pFieldObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));\r
606         ASSERT(pFieldObj.IsEmpty() == FALSE);\r
607 \r
608         CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);\r
609         ASSERT(pJSDocument != NULL);\r
610         Document* pDocument = (Document*)pJSDocument->GetEmbedObject();\r
611         ASSERT(pDocument != NULL);\r
612         if (m_pTargetDoc != NULL)\r
613                 pDocument->AttachDoc(m_pTargetDoc);\r
614         else\r
615                 pDocument->AttachDoc(m_pJSContext->GetReaderDocument());\r
616         \r
617         //if (m_pSourceField == NULL)\r
618         //      return NULL;\r
619         //CRAO_Widget *pWidget = IBCL_Widget::GetWidget(m_pSourceField);\r
620         //CPDF_FormField* pFormField = pWidget->GetFormField();\r
621         //ASSERT(pFormField);\r
622         //CFX_WideString csFieldName = pFormField->GetFullName();\r
623         CJS_Field * pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj);\r
624         ASSERT(pJSField != NULL);\r
625         Field * pField = (Field *)pJSField->GetEmbedObject(); \r
626         ASSERT(pField != NULL);\r
627         pField->AttachField(pDocument, m_strSourceName);\r
628         return pField;  \r
629 }\r
630 \r
631 Field* CJS_EventHandler::Target_Field()\r
632 {\r
633         ASSERT(m_pJSContext != NULL);\r
634 \r
635         CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();\r
636 \r
637         JSFXObject pDocObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));\r
638         ASSERT(pDocObj.IsEmpty() == FALSE);\r
639         JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));\r
640         ASSERT(pFieldObj.IsEmpty() == FALSE);\r
641 \r
642         CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);\r
643         ASSERT(pJSDocument != NULL);\r
644         Document* pDocument = (Document*)pJSDocument->GetEmbedObject();\r
645         ASSERT(pDocument != NULL);\r
646         if (m_pTargetDoc != NULL)\r
647                 pDocument->AttachDoc(m_pTargetDoc);\r
648         else\r
649                 pDocument->AttachDoc(m_pJSContext->GetReaderDocument());\r
650         \r
651         CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pFieldObj);\r
652         ASSERT(pJSField != NULL);\r
653 \r
654         Field* pField = (Field *)pJSField->GetEmbedObject(); \r
655         ASSERT(pField != NULL);\r
656 \r
657         pField->AttachField(pDocument, m_strTargetName);\r
658         return pField;  \r
659 }\r
660 \r
661 CFX_WideString& CJS_EventHandler::Value()\r
662 {\r
663         return *m_pValue;\r
664 }\r
665 \r
666 FX_BOOL CJS_EventHandler::WillCommit()\r
667 {\r
668         return m_bWillCommit;\r
669 }\r
670 \r
671 CFX_WideString CJS_EventHandler::TargetName()\r
672 {\r
673         return m_strTargetName;\r
674 }\r
675 \r
676 \r