OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "../include/fsdk_mgr.h" | 9 #include "../include/fsdk_mgr.h" |
10 #include "../include/fsdk_actionhandler.h" | 10 #include "../include/fsdk_actionhandler.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 return FALSE; | 142 return FALSE; |
143 | 143 |
144 list.AddTail(pDict); | 144 list.AddTail(pDict); |
145 | 145 |
146 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 146 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
147 ASSERT(pEnv); | 147 ASSERT(pEnv); |
148 if (action.GetType() == CPDF_Action::JavaScript) { | 148 if (action.GetType() == CPDF_Action::JavaScript) { |
149 if (pEnv->IsJSInitiated()) { | 149 if (pEnv->IsJSInitiated()) { |
150 CFX_WideString swJS = action.GetJavaScript(); | 150 CFX_WideString swJS = action.GetJavaScript(); |
151 if (!swJS.IsEmpty()) { | 151 if (!swJS.IsEmpty()) { |
152 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? | 152 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? |
153 ASSERT(pRuntime != NULL); | 153 ASSERT(pRuntime != NULL); |
154 | 154 |
155 pRuntime->SetReaderDocument(pDocument); | 155 pRuntime->SetReaderDocument(pDocument); |
156 | 156 |
157 IFXJS_Context* pContext = pRuntime->NewContext(); | 157 IJS_Context* pContext = pRuntime->NewContext(); |
158 ASSERT(pContext != NULL); | 158 ASSERT(pContext != NULL); |
159 | 159 |
160 pContext->OnLink_MouseUp(pDocument); | 160 pContext->OnLink_MouseUp(pDocument); |
161 | 161 |
162 CFX_WideString csInfo; | 162 CFX_WideString csInfo; |
163 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); | 163 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
164 if (!bRet) { | 164 if (!bRet) { |
165 // FIXME: return error. | 165 // FIXME: return error. |
166 } | 166 } |
167 | 167 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 return FALSE; | 285 return FALSE; |
286 | 286 |
287 list.AddTail(pDict); | 287 list.AddTail(pDict); |
288 | 288 |
289 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 289 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
290 ASSERT(pEnv); | 290 ASSERT(pEnv); |
291 if (action.GetType() == CPDF_Action::JavaScript) { | 291 if (action.GetType() == CPDF_Action::JavaScript) { |
292 if (pEnv->IsJSInitiated()) { | 292 if (pEnv->IsJSInitiated()) { |
293 CFX_WideString swJS = action.GetJavaScript(); | 293 CFX_WideString swJS = action.GetJavaScript(); |
294 if (!swJS.IsEmpty()) { | 294 if (!swJS.IsEmpty()) { |
295 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 295 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
296 ASSERT(pRuntime != NULL); | 296 ASSERT(pRuntime != NULL); |
297 | 297 |
298 pRuntime->SetReaderDocument(pDocument); | 298 pRuntime->SetReaderDocument(pDocument); |
299 | 299 |
300 IFXJS_Context* pContext = pRuntime->NewContext(); | 300 IJS_Context* pContext = pRuntime->NewContext(); |
301 ASSERT(pContext != NULL); | 301 ASSERT(pContext != NULL); |
302 | 302 |
303 // switch (type) | 303 // switch (type) |
304 // { | 304 // { |
305 // case CPDF_AAction::CursorEnter: | 305 // case CPDF_AAction::CursorEnter: |
306 // pContext->OnScreen_MouseEnter(IsCTRLpres
sed(), | 306 // pContext->OnScreen_MouseEnter(IsCTRLpres
sed(), |
307 // IsSHIFTpressed(), pScreen); | 307 // IsSHIFTpressed(), pScreen); |
308 // break; | 308 // break; |
309 // case CPDF_AAction::CursorExit: | 309 // case CPDF_AAction::CursorExit: |
310 // pContext->OnScreen_MouseExit(IsCTRLpress
ed(), | 310 // pContext->OnScreen_MouseExit(IsCTRLpress
ed(), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 return FALSE; | 381 return FALSE; |
382 | 382 |
383 list.AddTail(pDict); | 383 list.AddTail(pDict); |
384 | 384 |
385 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 385 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
386 ASSERT(pEnv); | 386 ASSERT(pEnv); |
387 if (action.GetType() == CPDF_Action::JavaScript) { | 387 if (action.GetType() == CPDF_Action::JavaScript) { |
388 if (pEnv->IsJSInitiated()) { | 388 if (pEnv->IsJSInitiated()) { |
389 CFX_WideString swJS = action.GetJavaScript(); | 389 CFX_WideString swJS = action.GetJavaScript(); |
390 if (!swJS.IsEmpty()) { | 390 if (!swJS.IsEmpty()) { |
391 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 391 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
392 ASSERT(pRuntime != NULL); | 392 ASSERT(pRuntime != NULL); |
393 | 393 |
394 pRuntime->SetReaderDocument(pDocument); | 394 pRuntime->SetReaderDocument(pDocument); |
395 | 395 |
396 IFXJS_Context* pContext = pRuntime->NewContext(); | 396 IJS_Context* pContext = pRuntime->NewContext(); |
397 ASSERT(pContext != NULL); | 397 ASSERT(pContext != NULL); |
398 | 398 |
399 pContext->OnBookmark_MouseUp(pBookmark); | 399 pContext->OnBookmark_MouseUp(pBookmark); |
400 | 400 |
401 CFX_WideString csInfo; | 401 CFX_WideString csInfo; |
402 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); | 402 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
403 if (!bRet) { | 403 if (!bRet) { |
404 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), | 404 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), |
405 // csInfo); | 405 // csInfo); |
406 } | 406 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, | 549 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, |
550 CPDF_FormField* pFormField, | 550 CPDF_FormField* pFormField, |
551 CPDF_AAction::AActionType type, | 551 CPDF_AAction::AActionType type, |
552 PDFSDK_FieldAction& data, | 552 PDFSDK_FieldAction& data, |
553 const CFX_WideString& script) { | 553 const CFX_WideString& script) { |
554 ASSERT(type != CPDF_AAction::Calculate); | 554 ASSERT(type != CPDF_AAction::Calculate); |
555 ASSERT(type != CPDF_AAction::Format); | 555 ASSERT(type != CPDF_AAction::Format); |
556 | 556 |
557 ASSERT(pDocument != NULL); | 557 ASSERT(pDocument != NULL); |
558 | 558 |
559 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 559 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
560 ASSERT(pRuntime != NULL); | 560 ASSERT(pRuntime != NULL); |
561 | 561 |
562 pRuntime->SetReaderDocument(pDocument); | 562 pRuntime->SetReaderDocument(pDocument); |
563 | 563 |
564 IFXJS_Context* pContext = pRuntime->NewContext(); | 564 IJS_Context* pContext = pRuntime->NewContext(); |
565 ASSERT(pContext != NULL); | 565 ASSERT(pContext != NULL); |
566 | 566 |
567 switch (type) { | 567 switch (type) { |
568 case CPDF_AAction::CursorEnter: | 568 case CPDF_AAction::CursorEnter: |
569 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); | 569 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); |
570 break; | 570 break; |
571 case CPDF_AAction::CursorExit: | 571 case CPDF_AAction::CursorExit: |
572 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); | 572 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); |
573 break; | 573 break; |
574 case CPDF_AAction::ButtonDown: | 574 case CPDF_AAction::ButtonDown: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 609 |
610 pRuntime->ReleaseContext(pContext); | 610 pRuntime->ReleaseContext(pContext); |
611 } | 611 } |
612 | 612 |
613 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( | 613 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( |
614 CPDFSDK_Document* pDocument, | 614 CPDFSDK_Document* pDocument, |
615 const CFX_WideString& sScriptName, | 615 const CFX_WideString& sScriptName, |
616 const CFX_WideString& script) { | 616 const CFX_WideString& script) { |
617 ASSERT(pDocument != NULL); | 617 ASSERT(pDocument != NULL); |
618 | 618 |
619 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 619 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
620 ASSERT(pRuntime != NULL); | 620 ASSERT(pRuntime != NULL); |
621 | 621 |
622 pRuntime->SetReaderDocument(pDocument); | 622 pRuntime->SetReaderDocument(pDocument); |
623 | 623 |
624 IFXJS_Context* pContext = pRuntime->NewContext(); | 624 IJS_Context* pContext = pRuntime->NewContext(); |
625 ASSERT(pContext != NULL); | 625 ASSERT(pContext != NULL); |
626 | 626 |
627 pContext->OnDoc_Open(pDocument, sScriptName); | 627 pContext->OnDoc_Open(pDocument, sScriptName); |
628 | 628 |
629 CFX_WideString csInfo; | 629 CFX_WideString csInfo; |
630 FX_BOOL bRet = pContext->RunScript(script, csInfo); | 630 FX_BOOL bRet = pContext->RunScript(script, csInfo); |
631 if (!bRet) { | 631 if (!bRet) { |
632 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); | 632 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
633 } | 633 } |
634 | 634 |
635 pRuntime->ReleaseContext(pContext); | 635 pRuntime->ReleaseContext(pContext); |
636 } | 636 } |
637 | 637 |
638 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( | 638 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( |
639 CPDFSDK_Document* pDocument, | 639 CPDFSDK_Document* pDocument, |
640 CPDF_AAction::AActionType type, | 640 CPDF_AAction::AActionType type, |
641 const CFX_WideString& script) { | 641 const CFX_WideString& script) { |
642 ASSERT(pDocument != NULL); | 642 ASSERT(pDocument != NULL); |
643 | 643 |
644 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 644 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
645 ASSERT(pRuntime != NULL); | 645 ASSERT(pRuntime != NULL); |
646 | 646 |
647 pRuntime->SetReaderDocument(pDocument); | 647 pRuntime->SetReaderDocument(pDocument); |
648 | 648 |
649 IFXJS_Context* pContext = pRuntime->NewContext(); | 649 IJS_Context* pContext = pRuntime->NewContext(); |
650 ASSERT(pContext != NULL); | 650 ASSERT(pContext != NULL); |
651 | 651 |
652 switch (type) { | 652 switch (type) { |
653 case CPDF_AAction::OpenPage: | 653 case CPDF_AAction::OpenPage: |
654 pContext->OnPage_Open(pDocument); | 654 pContext->OnPage_Open(pDocument); |
655 break; | 655 break; |
656 case CPDF_AAction::ClosePage: | 656 case CPDF_AAction::ClosePage: |
657 pContext->OnPage_Close(pDocument); | 657 pContext->OnPage_Close(pDocument); |
658 break; | 658 break; |
659 case CPDF_AAction::CloseDocument: | 659 case CPDF_AAction::CloseDocument: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 740 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
741 ASSERT(pInterForm != NULL); | 741 ASSERT(pInterForm != NULL); |
742 | 742 |
743 if (pInterForm->DoAction_ImportData(action)) { | 743 if (pInterForm->DoAction_ImportData(action)) { |
744 pDocument->SetChangeMark(); | 744 pDocument->SetChangeMark(); |
745 return TRUE; | 745 return TRUE; |
746 } | 746 } |
747 | 747 |
748 return FALSE; | 748 return FALSE; |
749 } | 749 } |
OLD | NEW |