Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
[pdfium.git] / fpdfsdk / src / fsdk_actionhandler.cpp
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 "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h"
9 #include "../include/fsdk_actionhandler.h"
10 #include "../include/javascript/IJavaScript.h"
11
12 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler()
13     : m_pFormActionHandler(new CPDFSDK_FormActionHandler) {
14 }
15
16 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action,
17                                                 CPDFSDK_Document* pDocument) {
18   CFX_PtrList list;
19   return ExecuteDocumentOpenAction(action, pDocument, list);
20 }
21
22 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript(
23     const CPDF_Action& JsAction,
24     CFX_WideString csJSName,
25     CPDFSDK_Document* pDocument) {
26   if (JsAction.GetType() == CPDF_Action::JavaScript) {
27     CFX_WideString swJS = JsAction.GetJavaScript();
28     if (!swJS.IsEmpty()) {
29       RunDocumentOpenJavaScript(pDocument, csJSName, swJS);
30       return TRUE;
31     }
32   }
33
34   return FALSE;
35 }
36
37 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript(
38     const CPDF_Action& JsAction,
39     CPDF_AAction::AActionType type,
40     CPDFSDK_Document* pDocument,
41     CPDF_FormField* pFormField,
42     PDFSDK_FieldAction& data) {
43   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
44   ASSERT(pEnv);
45   if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript) {
46     CFX_WideString swJS = JsAction.GetJavaScript();
47     if (!swJS.IsEmpty()) {
48       RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
49       return TRUE;
50     }
51   }
52   return FALSE;
53 }
54
55 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page(
56     const CPDF_Action& action,
57     enum CPDF_AAction::AActionType eType,
58     CPDFSDK_Document* pDocument) {
59   CFX_PtrList list;
60   return ExecuteDocumentPageAction(action, eType, pDocument, list);
61 }
62
63 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document(
64     const CPDF_Action& action,
65     enum CPDF_AAction::AActionType eType,
66     CPDFSDK_Document* pDocument) {
67   CFX_PtrList list;
68   return ExecuteDocumentPageAction(action, eType, pDocument, list);
69 }
70
71 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark,
72                                                  const CPDF_Action& action,
73                                                  CPDF_AAction::AActionType type,
74                                                  CPDFSDK_Document* pDocument) {
75   CFX_PtrList list;
76   return ExecuteBookMark(action, pDocument, pBookMark, list);
77 }
78
79 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action,
80                                                CPDF_AAction::AActionType type,
81                                                CPDFSDK_Document* pDocument,
82                                                CPDFSDK_Annot* pScreen) {
83   CFX_PtrList list;
84   return ExecuteScreenAction(action, type, pDocument, pScreen, list);
85 }
86
87 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action,
88                                              CPDFSDK_Document* pDocument) {
89   CFX_PtrList list;
90   return ExecuteLinkAction(action, pDocument, list);
91 }
92
93 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action,
94                                               CPDF_AAction::AActionType type,
95                                               CPDFSDK_Document* pDocument,
96                                               CPDF_FormField* pFormField,
97                                               PDFSDK_FieldAction& data) {
98   CFX_PtrList list;
99   return ExecuteFieldAction(action, type, pDocument, pFormField, data, list);
100 }
101
102 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
103     const CPDF_Action& action,
104     CPDFSDK_Document* pDocument,
105     CFX_PtrList& list) {
106   CPDF_Dictionary* pDict = action.GetDict();
107   if (list.Find(pDict))
108     return FALSE;
109
110   list.AddTail(pDict);
111
112   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
113   ASSERT(pEnv);
114   if (action.GetType() == CPDF_Action::JavaScript) {
115     if (pEnv->IsJSInitiated()) {
116       CFX_WideString swJS = action.GetJavaScript();
117       if (!swJS.IsEmpty()) {
118         RunDocumentOpenJavaScript(pDocument, L"", swJS);
119       }
120     }
121   } else {
122     DoAction_NoJs(action, pDocument);
123   }
124
125   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
126     CPDF_Action subaction = action.GetSubAction(i);
127     if (!ExecuteDocumentOpenAction(subaction, pDocument, list))
128       return FALSE;
129   }
130
131   return TRUE;
132 }
133
134 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action,
135                                                  CPDFSDK_Document* pDocument,
136                                                  CFX_PtrList& list) {
137   ASSERT(pDocument != NULL);
138
139   CPDF_Dictionary* pDict = action.GetDict();
140   if (list.Find(pDict))
141     return FALSE;
142
143   list.AddTail(pDict);
144
145   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
146   ASSERT(pEnv);
147   if (action.GetType() == CPDF_Action::JavaScript) {
148     if (pEnv->IsJSInitiated()) {
149       CFX_WideString swJS = action.GetJavaScript();
150       if (!swJS.IsEmpty()) {
151         IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
152         pRuntime->SetReaderDocument(pDocument);
153
154         IJS_Context* pContext = pRuntime->NewContext();
155         pContext->OnLink_MouseUp(pDocument);
156
157         CFX_WideString csInfo;
158         FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
159         if (!bRet) {
160           // FIXME: return error.
161         }
162
163         pRuntime->ReleaseContext(pContext);
164       }
165     }
166   } else {
167     DoAction_NoJs(action, pDocument);
168   }
169
170   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
171     CPDF_Action subaction = action.GetSubAction(i);
172     if (!ExecuteLinkAction(subaction, pDocument, list))
173       return FALSE;
174   }
175
176   return TRUE;
177 }
178
179 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(
180     const CPDF_Action& action,
181     CPDF_AAction::AActionType type,
182     CPDFSDK_Document* pDocument,
183     CFX_PtrList& list) {
184   ASSERT(pDocument != NULL);
185
186   CPDF_Dictionary* pDict = action.GetDict();
187   if (list.Find(pDict))
188     return FALSE;
189
190   list.AddTail(pDict);
191
192   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
193   ASSERT(pEnv);
194   if (action.GetType() == CPDF_Action::JavaScript) {
195     if (pEnv->IsJSInitiated()) {
196       CFX_WideString swJS = action.GetJavaScript();
197       if (!swJS.IsEmpty()) {
198         RunDocumentPageJavaScript(pDocument, type, swJS);
199       }
200     }
201   } else {
202     DoAction_NoJs(action, pDocument);
203   }
204
205   if (!IsValidDocView(pDocument))
206     return FALSE;
207
208   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
209     CPDF_Action subaction = action.GetSubAction(i);
210     if (!ExecuteDocumentPageAction(subaction, type, pDocument, list))
211       return FALSE;
212   }
213
214   return TRUE;
215 }
216
217 FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument,
218                                             CPDF_Dictionary* pFieldDict) {
219   ASSERT(pDocument != NULL);
220   ASSERT(pFieldDict != NULL);
221
222   CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
223   ASSERT(pInterForm != NULL);
224
225   CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
226   ASSERT(pPDFInterForm != NULL);
227
228   return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL;
229 }
230
231 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(
232     const CPDF_Action& action,
233     CPDF_AAction::AActionType type,
234     CPDFSDK_Document* pDocument,
235     CPDF_FormField* pFormField,
236     PDFSDK_FieldAction& data,
237     CFX_PtrList& list) {
238   ASSERT(pDocument != NULL);
239
240   CPDF_Dictionary* pDict = action.GetDict();
241   if (list.Find(pDict))
242     return FALSE;
243
244   list.AddTail(pDict);
245
246   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
247   ASSERT(pEnv);
248   if (action.GetType() == CPDF_Action::JavaScript) {
249     if (pEnv->IsJSInitiated()) {
250       CFX_WideString swJS = action.GetJavaScript();
251       if (!swJS.IsEmpty()) {
252         RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
253         if (!IsValidField(pDocument, pFormField->GetFieldDict()))
254           return FALSE;
255       }
256     }
257   } else {
258     DoAction_NoJs(action, pDocument);
259   }
260
261   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
262     CPDF_Action subaction = action.GetSubAction(i);
263     if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list))
264       return FALSE;
265   }
266
267   return TRUE;
268 }
269
270 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(
271     const CPDF_Action& action,
272     CPDF_AAction::AActionType type,
273     CPDFSDK_Document* pDocument,
274     CPDFSDK_Annot* pScreen,
275     CFX_PtrList& list) {
276   ASSERT(pDocument != NULL);
277
278   CPDF_Dictionary* pDict = action.GetDict();
279   if (list.Find(pDict))
280     return FALSE;
281
282   list.AddTail(pDict);
283
284   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
285   ASSERT(pEnv);
286   if (action.GetType() == CPDF_Action::JavaScript) {
287     if (pEnv->IsJSInitiated()) {
288       CFX_WideString swJS = action.GetJavaScript();
289       if (!swJS.IsEmpty()) {
290         IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
291         pRuntime->SetReaderDocument(pDocument);
292
293         IJS_Context* pContext = pRuntime->NewContext();
294         CFX_WideString csInfo;
295         FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
296         if (!bRet) {
297           // FIXME: return error.
298         }
299
300         pRuntime->ReleaseContext(pContext);
301       }
302     }
303   } else {
304     DoAction_NoJs(action, pDocument);
305   }
306
307   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
308     CPDF_Action subaction = action.GetSubAction(i);
309     if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, list))
310       return FALSE;
311   }
312
313   return TRUE;
314 }
315
316 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action,
317                                                CPDFSDK_Document* pDocument,
318                                                CPDF_Bookmark* pBookmark,
319                                                CFX_PtrList& list) {
320   ASSERT(pDocument != NULL);
321
322   CPDF_Dictionary* pDict = action.GetDict();
323   if (list.Find(pDict))
324     return FALSE;
325
326   list.AddTail(pDict);
327
328   CPDFDoc_Environment* pEnv = pDocument->GetEnv();
329   ASSERT(pEnv);
330   if (action.GetType() == CPDF_Action::JavaScript) {
331     if (pEnv->IsJSInitiated()) {
332       CFX_WideString swJS = action.GetJavaScript();
333       if (!swJS.IsEmpty()) {
334         IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
335         pRuntime->SetReaderDocument(pDocument);
336
337         IJS_Context* pContext = pRuntime->NewContext();
338         pContext->OnBookmark_MouseUp(pBookmark);
339
340         CFX_WideString csInfo;
341         FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
342         if (!bRet) {
343           // FIXME: return error.
344         }
345
346         pRuntime->ReleaseContext(pContext);
347       }
348     }
349   } else {
350     DoAction_NoJs(action, pDocument);
351   }
352
353   for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
354     CPDF_Action subaction = action.GetSubAction(i);
355     if (!ExecuteBookMark(subaction, pDocument, pBookmark, list))
356       return FALSE;
357   }
358
359   return TRUE;
360 }
361
362 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action,
363                                           CPDFSDK_Document* pDocument) {
364   ASSERT(pDocument != NULL);
365
366   switch (action.GetType()) {
367     case CPDF_Action::GoTo:
368       DoAction_GoTo(pDocument, action);
369       break;
370     case CPDF_Action::GoToR:
371       DoAction_GoToR(pDocument, action);
372       break;
373     case CPDF_Action::GoToE:
374       break;
375     case CPDF_Action::Launch:
376       DoAction_Launch(pDocument, action);
377       break;
378     case CPDF_Action::Thread:
379       break;
380     case CPDF_Action::URI:
381       DoAction_URI(pDocument, action);
382       break;
383     case CPDF_Action::Sound:
384       break;
385     case CPDF_Action::Movie:
386       break;
387     case CPDF_Action::Hide:
388       if (m_pFormActionHandler) {
389         m_pFormActionHandler->DoAction_Hide(action, pDocument);
390       }
391       break;
392     case CPDF_Action::Named:
393       DoAction_Named(pDocument, action);
394       break;
395     case CPDF_Action::SubmitForm:
396       if (m_pFormActionHandler) {
397         m_pFormActionHandler->DoAction_SubmitForm(action, pDocument);
398       }
399       break;
400     case CPDF_Action::ResetForm:
401       if (m_pFormActionHandler) {
402         m_pFormActionHandler->DoAction_ResetForm(action, pDocument);
403       }
404       break;
405     case CPDF_Action::ImportData:
406       if (m_pFormActionHandler) {
407         m_pFormActionHandler->DoAction_ImportData(action, pDocument);
408       }
409       break;
410     case CPDF_Action::JavaScript:
411       ASSERT(FALSE);
412       break;
413     case CPDF_Action::SetOCGState:
414       DoAction_SetOCGState(pDocument, action);
415       break;
416     case CPDF_Action::Rendition:
417       break;
418     case CPDF_Action::Trans:
419       break;
420     case CPDF_Action::GoTo3DView:
421       break;
422     default:
423       break;
424   }
425 }
426
427 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) {
428   ASSERT(pDocument != NULL);
429   return TRUE;
430 }
431
432 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
433                                           const CPDF_Action& action) {
434   ASSERT(action);
435
436   CPDF_Document* pPDFDocument = pDocument->GetDocument();
437   ASSERT(pPDFDocument != NULL);
438   CPDFDoc_Environment* pApp = pDocument->GetEnv();
439   ASSERT(pApp != NULL);
440
441   CPDF_Dest MyDest = action.GetDest(pPDFDocument);
442   int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
443   int nFitType = MyDest.GetZoomMode();
444   const CPDF_Array* pMyArray = (CPDF_Array*)MyDest.GetObject();
445   float* pPosAry = NULL;
446   int sizeOfAry = 0;
447   if (pMyArray != NULL) {
448     pPosAry = new float[pMyArray->GetCount()];
449     int j = 0;
450     for (int i = 2; i < (int)pMyArray->GetCount(); i++) {
451       pPosAry[j++] = pMyArray->GetFloat(i);
452     }
453     sizeOfAry = j;
454   }
455   pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
456   delete[] pPosAry;
457 }
458
459 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument,
460                                            const CPDF_Action& action) {}
461
462 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument,
463                                             const CPDF_Action& action) {}
464
465 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument,
466                                          const CPDF_Action& action) {
467   ASSERT(action);
468
469   CPDFDoc_Environment* pApp = pDocument->GetEnv();
470   ASSERT(pApp != NULL);
471
472   CFX_ByteString sURI = action.GetURI(pDocument->GetDocument());
473   pApp->FFI_DoURIAction(sURI.c_str());
474 }
475
476 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
477                                            const CPDF_Action& action) {
478   ASSERT(action);
479
480   CFX_ByteString csName = action.GetNamedAction();
481   pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
482 }
483
484 void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,
485                                                  const CPDF_Action& action) {}
486
487 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument,
488                                                CPDF_FormField* pFormField,
489                                                CPDF_AAction::AActionType type,
490                                                PDFSDK_FieldAction& data,
491                                                const CFX_WideString& script) {
492   ASSERT(type != CPDF_AAction::Calculate);
493   ASSERT(type != CPDF_AAction::Format);
494
495   ASSERT(pDocument != NULL);
496
497   IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
498   ASSERT(pRuntime != NULL);
499
500   pRuntime->SetReaderDocument(pDocument);
501
502   IJS_Context* pContext = pRuntime->NewContext();
503   ASSERT(pContext != NULL);
504
505   switch (type) {
506     case CPDF_AAction::CursorEnter:
507       pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField);
508       break;
509     case CPDF_AAction::CursorExit:
510       pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField);
511       break;
512     case CPDF_AAction::ButtonDown:
513       pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField);
514       break;
515     case CPDF_AAction::ButtonUp:
516       pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField);
517       break;
518     case CPDF_AAction::GetFocus:
519       pContext->OnField_Focus(data.bModifier, data.bShift, pFormField,
520                               data.sValue);
521       break;
522     case CPDF_AAction::LoseFocus:
523       pContext->OnField_Blur(data.bModifier, data.bShift, pFormField,
524                              data.sValue);
525       break;
526     case CPDF_AAction::KeyStroke:
527       pContext->OnField_Keystroke(data.sChange, data.sChangeEx, data.bKeyDown,
528                                   data.bModifier, data.nSelEnd, data.nSelStart,
529                                   data.bShift, pFormField, data.sValue,
530                                   data.bWillCommit, data.bFieldFull, data.bRC);
531       break;
532     case CPDF_AAction::Validate:
533       pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown,
534                                  data.bModifier, data.bShift, pFormField,
535                                  data.sValue, data.bRC);
536       break;
537     default:
538       ASSERT(FALSE);
539       break;
540   }
541
542   CFX_WideString csInfo;
543   FX_BOOL bRet = pContext->RunScript(script, &csInfo);
544   if (!bRet) {
545     // FIXME: return error.
546   }
547
548   pRuntime->ReleaseContext(pContext);
549 }
550
551 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
552     CPDFSDK_Document* pDocument,
553     const CFX_WideString& sScriptName,
554     const CFX_WideString& script) {
555   ASSERT(pDocument != NULL);
556
557   IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
558   ASSERT(pRuntime != NULL);
559
560   pRuntime->SetReaderDocument(pDocument);
561
562   IJS_Context* pContext = pRuntime->NewContext();
563   ASSERT(pContext != NULL);
564
565   pContext->OnDoc_Open(pDocument, sScriptName);
566
567   CFX_WideString csInfo;
568   FX_BOOL bRet = pContext->RunScript(script, &csInfo);
569   if (!bRet) {
570     // FIXME: return error.
571   }
572
573   pRuntime->ReleaseContext(pContext);
574 }
575
576 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
577     CPDFSDK_Document* pDocument,
578     CPDF_AAction::AActionType type,
579     const CFX_WideString& script) {
580   ASSERT(pDocument != NULL);
581
582   IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
583   ASSERT(pRuntime != NULL);
584
585   pRuntime->SetReaderDocument(pDocument);
586
587   IJS_Context* pContext = pRuntime->NewContext();
588   ASSERT(pContext != NULL);
589
590   switch (type) {
591     case CPDF_AAction::OpenPage:
592       pContext->OnPage_Open(pDocument);
593       break;
594     case CPDF_AAction::ClosePage:
595       pContext->OnPage_Close(pDocument);
596       break;
597     case CPDF_AAction::CloseDocument:
598       pContext->OnDoc_WillClose(pDocument);
599       break;
600     case CPDF_AAction::SaveDocument:
601       pContext->OnDoc_WillSave(pDocument);
602       break;
603     case CPDF_AAction::DocumentSaved:
604       pContext->OnDoc_DidSave(pDocument);
605       break;
606     case CPDF_AAction::PrintDocument:
607       pContext->OnDoc_WillPrint(pDocument);
608       break;
609     case CPDF_AAction::DocumentPrinted:
610       pContext->OnDoc_DidPrint(pDocument);
611       break;
612     case CPDF_AAction::PageVisible:
613       pContext->OnPage_InView(pDocument);
614       break;
615     case CPDF_AAction::PageInvisible:
616       pContext->OnPage_OutView(pDocument);
617       break;
618     default:
619       ASSERT(FALSE);
620       break;
621   }
622
623   CFX_WideString csInfo;
624   FX_BOOL bRet = pContext->RunScript(script, &csInfo);
625   if (!bRet) {
626     // FIXME: return error.
627   }
628
629   pRuntime->ReleaseContext(pContext);
630 }
631
632 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action,
633                                                  CPDFSDK_Document* pDocument) {
634   ASSERT(pDocument != NULL);
635
636   CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
637   ASSERT(pInterForm != NULL);
638
639   if (pInterForm->DoAction_Hide(action)) {
640     pDocument->SetChangeMark();
641     return TRUE;
642   }
643
644   return FALSE;
645 }
646
647 FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm(
648     const CPDF_Action& action,
649     CPDFSDK_Document* pDocument) {
650   ASSERT(pDocument != NULL);
651
652   CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
653   ASSERT(pInterForm != NULL);
654
655   return pInterForm->DoAction_SubmitForm(action);
656 }
657
658 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm(
659     const CPDF_Action& action,
660     CPDFSDK_Document* pDocument) {
661   ASSERT(pDocument != NULL);
662
663   CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
664   ASSERT(pInterForm != NULL);
665
666   if (pInterForm->DoAction_ResetForm(action)) {
667     return TRUE;
668   }
669
670   return FALSE;
671 }
672
673 FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData(
674     const CPDF_Action& action,
675     CPDFSDK_Document* pDocument) {
676   ASSERT(pDocument != NULL);
677
678   CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
679   ASSERT(pInterForm != NULL);
680
681   if (pInterForm->DoAction_ImportData(action)) {
682     pDocument->SetChangeMark();
683     return TRUE;
684   }
685
686   return FALSE;
687 }