| 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 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? | 152 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 153 ASSERT(pRuntime != NULL); | |
| 154 | |
| 155 pRuntime->SetReaderDocument(pDocument); | 153 pRuntime->SetReaderDocument(pDocument); |
| 156 | 154 |
| 157 IJS_Context* pContext = pRuntime->NewContext(); | 155 IJS_Context* pContext = pRuntime->NewContext(); |
| 158 ASSERT(pContext != NULL); | |
| 159 | |
| 160 pContext->OnLink_MouseUp(pDocument); | 156 pContext->OnLink_MouseUp(pDocument); |
| 161 | 157 |
| 162 CFX_WideString csInfo; | 158 CFX_WideString csInfo; |
| 163 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); | 159 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
| 164 if (!bRet) { | 160 if (!bRet) { |
| 165 // FIXME: return error. | 161 // FIXME: return error. |
| 166 } | 162 } |
| 167 | 163 |
| 168 pRuntime->ReleaseContext(pContext); | 164 pRuntime->ReleaseContext(pContext); |
| 169 } | 165 } |
| 170 } | 166 } |
| 171 } else { | 167 } else { |
| 172 DoAction_NoJs(action, pDocument); | 168 DoAction_NoJs(action, pDocument); |
| 173 } | 169 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 282 |
| 287 list.AddTail(pDict); | 283 list.AddTail(pDict); |
| 288 | 284 |
| 289 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 285 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 290 ASSERT(pEnv); | 286 ASSERT(pEnv); |
| 291 if (action.GetType() == CPDF_Action::JavaScript) { | 287 if (action.GetType() == CPDF_Action::JavaScript) { |
| 292 if (pEnv->IsJSInitiated()) { | 288 if (pEnv->IsJSInitiated()) { |
| 293 CFX_WideString swJS = action.GetJavaScript(); | 289 CFX_WideString swJS = action.GetJavaScript(); |
| 294 if (!swJS.IsEmpty()) { | 290 if (!swJS.IsEmpty()) { |
| 295 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 291 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 296 ASSERT(pRuntime != NULL); | |
| 297 | |
| 298 pRuntime->SetReaderDocument(pDocument); | 292 pRuntime->SetReaderDocument(pDocument); |
| 299 | 293 |
| 300 IJS_Context* pContext = pRuntime->NewContext(); | 294 IJS_Context* pContext = pRuntime->NewContext(); |
| 301 ASSERT(pContext != NULL); | |
| 302 | |
| 303 // switch (type) | |
| 304 // { | |
| 305 // case CPDF_AAction::CursorEnter: | |
| 306 // pContext->OnScreen_MouseEnter(IsCTRLpres
sed(), | |
| 307 // IsSHIFTpressed(), pScreen); | |
| 308 // break; | |
| 309 // case CPDF_AAction::CursorExit: | |
| 310 // pContext->OnScreen_MouseExit(IsCTRLpress
ed(), | |
| 311 // IsSHIFTpressed(), pScreen); | |
| 312 // break; | |
| 313 // case CPDF_AAction::ButtonDown: | |
| 314 // pContext->OnScreen_MouseDown(IsCTRLpress
ed(), | |
| 315 // IsSHIFTpressed(), pScreen); | |
| 316 // break; | |
| 317 // case CPDF_AAction::ButtonUp: | |
| 318 // pContext->OnScreen_MouseUp(IsCTRLpressed
(), | |
| 319 // IsSHIFTpressed(), pScreen); | |
| 320 // break; | |
| 321 // case CPDF_AAction::GetFocus: | |
| 322 // pContext->OnScreen_Focus(IsCTRLpressed()
, | |
| 323 // IsSHIFTpressed(), pScreen); | |
| 324 // break; | |
| 325 // case CPDF_AAction::LoseFocus: | |
| 326 // pContext->OnScreen_Blur(IsCTRLpressed(), | |
| 327 // IsSHIFTpressed(), pScreen); | |
| 328 // break; | |
| 329 // case CPDF_AAction::PageOpen: | |
| 330 // pContext->OnScreen_Open(IsCTRLpressed(), | |
| 331 // IsSHIFTpressed(), pScreen); | |
| 332 // break; | |
| 333 // case CPDF_AAction::PageClose: | |
| 334 // pContext->OnScreen_Close(IsCTRLpressed()
, | |
| 335 // IsSHIFTpressed(), pScreen); | |
| 336 // break; | |
| 337 // case CPDF_AAction::PageVisible: | |
| 338 // pContext->OnScreen_InView(IsCTRLpressed(
), | |
| 339 // IsSHIFTpressed(), pScreen); | |
| 340 // break; | |
| 341 // case CPDF_AAction::PageInvisible: | |
| 342 // pContext->OnScreen_OutView(IsCTRLpressed
(), | |
| 343 // IsSHIFTpressed(), pScreen); | |
| 344 // break; | |
| 345 // default: | |
| 346 // ASSERT(FALSE); | |
| 347 // break; | |
| 348 // } | |
| 349 | |
| 350 CFX_WideString csInfo; | 295 CFX_WideString csInfo; |
| 351 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); | 296 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
| 352 if (!bRet) { | 297 if (!bRet) { |
| 353 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), | 298 // FIXME: return error. |
| 354 // csInfo); | |
| 355 } | 299 } |
| 356 | 300 |
| 357 pRuntime->ReleaseContext(pContext); | 301 pRuntime->ReleaseContext(pContext); |
| 358 } | 302 } |
| 359 } | 303 } |
| 360 } else { | 304 } else { |
| 361 DoAction_NoJs(action, pDocument); | 305 DoAction_NoJs(action, pDocument); |
| 362 } | 306 } |
| 363 | 307 |
| 364 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 308 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 382 | 326 |
| 383 list.AddTail(pDict); | 327 list.AddTail(pDict); |
| 384 | 328 |
| 385 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 329 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 386 ASSERT(pEnv); | 330 ASSERT(pEnv); |
| 387 if (action.GetType() == CPDF_Action::JavaScript) { | 331 if (action.GetType() == CPDF_Action::JavaScript) { |
| 388 if (pEnv->IsJSInitiated()) { | 332 if (pEnv->IsJSInitiated()) { |
| 389 CFX_WideString swJS = action.GetJavaScript(); | 333 CFX_WideString swJS = action.GetJavaScript(); |
| 390 if (!swJS.IsEmpty()) { | 334 if (!swJS.IsEmpty()) { |
| 391 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 335 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 392 ASSERT(pRuntime != NULL); | |
| 393 | |
| 394 pRuntime->SetReaderDocument(pDocument); | 336 pRuntime->SetReaderDocument(pDocument); |
| 395 | 337 |
| 396 IJS_Context* pContext = pRuntime->NewContext(); | 338 IJS_Context* pContext = pRuntime->NewContext(); |
| 397 ASSERT(pContext != NULL); | |
| 398 | |
| 399 pContext->OnBookmark_MouseUp(pBookmark); | 339 pContext->OnBookmark_MouseUp(pBookmark); |
| 400 | 340 |
| 401 CFX_WideString csInfo; | 341 CFX_WideString csInfo; |
| 402 FX_BOOL bRet = pContext->RunScript(swJS, csInfo); | 342 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
| 403 if (!bRet) { | 343 if (!bRet) { |
| 404 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), | 344 // FIXME: return error. |
| 405 // csInfo); | |
| 406 } | 345 } |
| 407 | 346 |
| 408 pRuntime->ReleaseContext(pContext); | 347 pRuntime->ReleaseContext(pContext); |
| 409 } | 348 } |
| 410 } | 349 } |
| 411 } else { | 350 } else { |
| 412 DoAction_NoJs(action, pDocument); | 351 DoAction_NoJs(action, pDocument); |
| 413 } | 352 } |
| 414 | 353 |
| 415 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 354 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, | 534 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, |
| 596 data.bModifier, data.bShift, pFormField, | 535 data.bModifier, data.bShift, pFormField, |
| 597 data.sValue, data.bRC); | 536 data.sValue, data.bRC); |
| 598 break; | 537 break; |
| 599 default: | 538 default: |
| 600 ASSERT(FALSE); | 539 ASSERT(FALSE); |
| 601 break; | 540 break; |
| 602 } | 541 } |
| 603 | 542 |
| 604 CFX_WideString csInfo; | 543 CFX_WideString csInfo; |
| 605 FX_BOOL bRet = pContext->RunScript(script, csInfo); | 544 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
| 606 if (!bRet) { | 545 if (!bRet) { |
| 607 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); | 546 // FIXME: return error. |
| 608 } | 547 } |
| 609 | 548 |
| 610 pRuntime->ReleaseContext(pContext); | 549 pRuntime->ReleaseContext(pContext); |
| 611 } | 550 } |
| 612 | 551 |
| 613 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( | 552 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( |
| 614 CPDFSDK_Document* pDocument, | 553 CPDFSDK_Document* pDocument, |
| 615 const CFX_WideString& sScriptName, | 554 const CFX_WideString& sScriptName, |
| 616 const CFX_WideString& script) { | 555 const CFX_WideString& script) { |
| 617 ASSERT(pDocument != NULL); | 556 ASSERT(pDocument != NULL); |
| 618 | 557 |
| 619 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 558 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 620 ASSERT(pRuntime != NULL); | 559 ASSERT(pRuntime != NULL); |
| 621 | 560 |
| 622 pRuntime->SetReaderDocument(pDocument); | 561 pRuntime->SetReaderDocument(pDocument); |
| 623 | 562 |
| 624 IJS_Context* pContext = pRuntime->NewContext(); | 563 IJS_Context* pContext = pRuntime->NewContext(); |
| 625 ASSERT(pContext != NULL); | 564 ASSERT(pContext != NULL); |
| 626 | 565 |
| 627 pContext->OnDoc_Open(pDocument, sScriptName); | 566 pContext->OnDoc_Open(pDocument, sScriptName); |
| 628 | 567 |
| 629 CFX_WideString csInfo; | 568 CFX_WideString csInfo; |
| 630 FX_BOOL bRet = pContext->RunScript(script, csInfo); | 569 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
| 631 if (!bRet) { | 570 if (!bRet) { |
| 632 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); | 571 // FIXME: return error. |
| 633 } | 572 } |
| 634 | 573 |
| 635 pRuntime->ReleaseContext(pContext); | 574 pRuntime->ReleaseContext(pContext); |
| 636 } | 575 } |
| 637 | 576 |
| 638 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( | 577 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( |
| 639 CPDFSDK_Document* pDocument, | 578 CPDFSDK_Document* pDocument, |
| 640 CPDF_AAction::AActionType type, | 579 CPDF_AAction::AActionType type, |
| 641 const CFX_WideString& script) { | 580 const CFX_WideString& script) { |
| 642 ASSERT(pDocument != NULL); | 581 ASSERT(pDocument != NULL); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 break; | 615 break; |
| 677 case CPDF_AAction::PageInvisible: | 616 case CPDF_AAction::PageInvisible: |
| 678 pContext->OnPage_OutView(pDocument); | 617 pContext->OnPage_OutView(pDocument); |
| 679 break; | 618 break; |
| 680 default: | 619 default: |
| 681 ASSERT(FALSE); | 620 ASSERT(FALSE); |
| 682 break; | 621 break; |
| 683 } | 622 } |
| 684 | 623 |
| 685 CFX_WideString csInfo; | 624 CFX_WideString csInfo; |
| 686 FX_BOOL bRet = pContext->RunScript(script, csInfo); | 625 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
| 687 if (!bRet) { | 626 if (!bRet) { |
| 688 // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); | 627 // FIXME: return error. |
| 689 } | 628 } |
| 690 | 629 |
| 691 pRuntime->ReleaseContext(pContext); | 630 pRuntime->ReleaseContext(pContext); |
| 692 } | 631 } |
| 693 | 632 |
| 694 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, | 633 FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, |
| 695 CPDFSDK_Document* pDocument) { | 634 CPDFSDK_Document* pDocument) { |
| 696 ASSERT(pDocument != NULL); | 635 ASSERT(pDocument != NULL); |
| 697 | 636 |
| 698 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 637 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); | 679 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 741 ASSERT(pInterForm != NULL); | 680 ASSERT(pInterForm != NULL); |
| 742 | 681 |
| 743 if (pInterForm->DoAction_ImportData(action)) { | 682 if (pInterForm->DoAction_ImportData(action)) { |
| 744 pDocument->SetChangeMark(); | 683 pDocument->SetChangeMark(); |
| 745 return TRUE; | 684 return TRUE; |
| 746 } | 685 } |
| 747 | 686 |
| 748 return FALSE; | 687 return FALSE; |
| 749 } | 688 } |
| OLD | NEW |