| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
| 10 | 10 |
| 11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 12 #include "fpdfsdk/include/fsdk_define.h" | 12 #include "fpdfsdk/include/fsdk_define.h" |
| 13 #include "fpdfsdk/include/javascript/IJavaScript.h" | 13 #include "fpdfsdk/include/javascript/IJavaScript.h" |
| 14 #include "public/fpdf_ext.h" | 14 #include "public/fpdf_ext.h" |
| 15 #include "third_party/base/nonstd_unique_ptr.h" | 15 #include "third_party/base/nonstd_unique_ptr.h" |
| 16 | 16 |
| 17 #ifdef PDF_ENABLE_XFA | 17 #ifdef PDF_ENABLE_XFA |
| 18 #include "../include/fpdfxfa/fpdfxfa_app.h" | 18 #include "../include/fpdfxfa/fpdfxfa_app.h" |
| 19 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 19 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 20 #include "../include/fpdfxfa/fpdfxfa_page.h" | 20 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| 21 #include "../include/fpdfxfa/fpdfxfa_util.h" | 21 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 22 #endif // PDF_ENABLE_XFA |
| 22 | 23 |
| 23 #endif | |
| 24 #if _FX_OS_ == _FX_ANDROID_ | 24 #if _FX_OS_ == _FX_ANDROID_ |
| 25 #include "time.h" | 25 #include "time.h" |
| 26 #else | 26 #else |
| 27 #include <ctime> | 27 #include <ctime> |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 class CFX_SystemHandler : public IFX_SystemHandler { | 30 class CFX_SystemHandler : public IFX_SystemHandler { |
| 31 public: | 31 public: |
| 32 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) | 32 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) |
| 33 : m_pEnv(pEnv), m_nCharSet(-1) {} | 33 : m_pEnv(pEnv), m_nCharSet(-1) {} |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 FPDF_FORMFILLINFO* pFFinfo) | 211 FPDF_FORMFILLINFO* pFFinfo) |
| 212 : m_pInfo(pFFinfo), m_pSDKDoc(NULL), m_pUnderlyingDoc(pDoc) { | 212 : m_pInfo(pFFinfo), m_pSDKDoc(NULL), m_pUnderlyingDoc(pDoc) { |
| 213 m_pSysHandler.reset(new CFX_SystemHandler(this)); | 213 m_pSysHandler.reset(new CFX_SystemHandler(this)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 CPDFDoc_Environment::~CPDFDoc_Environment() { | 216 CPDFDoc_Environment::~CPDFDoc_Environment() { |
| 217 #ifdef PDF_ENABLE_XFA | 217 #ifdef PDF_ENABLE_XFA |
| 218 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 218 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 219 if (pProvider->m_pEnvList.GetSize() == 0) | 219 if (pProvider->m_pEnvList.GetSize() == 0) |
| 220 pProvider->SetJavaScriptInitialized(FALSE); | 220 pProvider->SetJavaScriptInitialized(FALSE); |
| 221 #endif | 221 #endif // PDF_ENABLE_XFA |
| 222 } | 222 } |
| 223 | 223 |
| 224 int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, | 224 int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, |
| 225 const FX_WCHAR* Title, | 225 const FX_WCHAR* Title, |
| 226 FX_UINT Type, | 226 FX_UINT Type, |
| 227 FX_UINT Icon) { | 227 FX_UINT Icon) { |
| 228 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) { | 228 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) { |
| 229 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); | 229 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| 230 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); | 230 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| 231 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); | 231 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 if (m_pFocusAnnot) { | 537 if (m_pFocusAnnot) { |
| 538 if (!KillFocusAnnot(nFlag)) | 538 if (!KillFocusAnnot(nFlag)) |
| 539 return FALSE; | 539 return FALSE; |
| 540 } | 540 } |
| 541 | 541 |
| 542 if (!pAnnot) | 542 if (!pAnnot) |
| 543 return FALSE; | 543 return FALSE; |
| 544 | 544 |
| 545 #ifdef PDF_ENABLE_XFA | 545 #ifdef PDF_ENABLE_XFA |
| 546 CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; | 546 CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; |
| 547 #endif | 547 #endif // PDF_ENABLE_XFA |
| 548 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 548 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 549 if (pPageView && pPageView->IsValid()) { | 549 if (pPageView && pPageView->IsValid()) { |
| 550 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); | 550 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); |
| 551 if (!m_pFocusAnnot) { | 551 if (!m_pFocusAnnot) { |
| 552 #ifdef PDF_ENABLE_XFA | 552 #ifdef PDF_ENABLE_XFA |
| 553 if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) | 553 if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) |
| 554 return FALSE; | 554 return FALSE; |
| 555 | 555 #endif // PDF_ENABLE_XFA |
| 556 #endif | |
| 557 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) | 556 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) |
| 558 return FALSE; | 557 return FALSE; |
| 559 if (!m_pFocusAnnot) { | 558 if (!m_pFocusAnnot) { |
| 560 m_pFocusAnnot = pAnnot; | 559 m_pFocusAnnot = pAnnot; |
| 561 return TRUE; | 560 return TRUE; |
| 562 } | 561 } |
| 563 } | 562 } |
| 564 } | 563 } |
| 565 return FALSE; | 564 return FALSE; |
| 566 } | 565 } |
| 567 | 566 |
| 568 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { | 567 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { |
| 569 if (m_pFocusAnnot) { | 568 if (m_pFocusAnnot) { |
| 570 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); | 569 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); |
| 571 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; | 570 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; |
| 572 m_pFocusAnnot = nullptr; | 571 m_pFocusAnnot = nullptr; |
| 572 |
| 573 #ifdef PDF_ENABLE_XFA | 573 #ifdef PDF_ENABLE_XFA |
| 574 | |
| 575 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) | 574 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) |
| 576 return FALSE; | 575 return FALSE; |
| 576 #endif // PDF_ENABLE_XFA |
| 577 | 577 |
| 578 #endif | |
| 579 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { | 578 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { |
| 580 if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { | 579 if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { |
| 581 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; | 580 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; |
| 582 int nFieldType = pWidget->GetFieldType(); | 581 int nFieldType = pWidget->GetFieldType(); |
| 583 if (FIELDTYPE_TEXTFIELD == nFieldType || | 582 if (FIELDTYPE_TEXTFIELD == nFieldType || |
| 584 FIELDTYPE_COMBOBOX == nFieldType) { | 583 FIELDTYPE_COMBOBOX == nFieldType) { |
| 585 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); | 584 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); |
| 586 } | 585 } |
| 587 } | 586 } |
| 588 | 587 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 615 | 614 |
| 616 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, | 615 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, |
| 617 UnderlyingPageType* page) | 616 UnderlyingPageType* page) |
| 618 : m_page(page), | 617 : m_page(page), |
| 619 m_pSDKDoc(pSDKDoc), | 618 m_pSDKDoc(pSDKDoc), |
| 620 m_CaptureWidget(nullptr), | 619 m_CaptureWidget(nullptr), |
| 621 m_bEnterWidget(FALSE), | 620 m_bEnterWidget(FALSE), |
| 622 m_bExitWidget(FALSE), | 621 m_bExitWidget(FALSE), |
| 623 m_bOnWidget(FALSE), | 622 m_bOnWidget(FALSE), |
| 624 m_bValid(FALSE), | 623 m_bValid(FALSE), |
| 625 #ifndef PDF_ENABLE_XFA | 624 #ifdef PDF_ENABLE_XFA |
| 625 m_bLocked(FALSE) { |
| 626 #else // PDF_ENABLE_XFA |
| 626 m_bLocked(FALSE), | 627 m_bLocked(FALSE), |
| 627 m_bTakeOverPage(FALSE) { | 628 m_bTakeOverPage(FALSE) { |
| 628 #else | 629 #endif // PDF_ENABLE_XFA |
| 629 m_bLocked(FALSE) { | |
| 630 #endif | |
| 631 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 630 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
| 632 if (pInterForm) { | 631 if (pInterForm) { |
| 633 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 632 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 634 #ifndef PDF_ENABLE_XFA | 633 #ifdef PDF_ENABLE_XFA |
| 635 pPDFInterForm->FixPageFields(page); | |
| 636 #else | |
| 637 if (page->GetPDFPage()) | 634 if (page->GetPDFPage()) |
| 638 pPDFInterForm->FixPageFields(page->GetPDFPage()); | 635 pPDFInterForm->FixPageFields(page->GetPDFPage()); |
| 639 #endif | 636 #else // PDF_ENABLE_XFA |
| 637 pPDFInterForm->FixPageFields(page); |
| 638 #endif // PDF_ENABLE_XFA |
| 640 } | 639 } |
| 641 #ifndef PDF_ENABLE_XFA | 640 #ifndef PDF_ENABLE_XFA |
| 642 m_page->SetPrivateData((void*)m_page, (void*)this, nullptr); | 641 m_page->SetPrivateData((void*)m_page, (void*)this, nullptr); |
| 643 #endif | 642 #endif // PDF_ENABLE_XFA |
| 644 } | 643 } |
| 645 | 644 |
| 646 CPDFSDK_PageView::~CPDFSDK_PageView() { | 645 CPDFSDK_PageView::~CPDFSDK_PageView() { |
| 647 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 646 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 648 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 647 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 649 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) | 648 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
| 650 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 649 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
| 650 |
| 651 m_fxAnnotArray.clear(); | 651 m_fxAnnotArray.clear(); |
| 652 | |
| 653 m_pAnnotList.reset(); | 652 m_pAnnotList.reset(); |
| 654 #ifndef PDF_ENABLE_XFA | 653 #ifndef PDF_ENABLE_XFA |
| 655 | |
| 656 m_page->RemovePrivateData((void*)m_page); | 654 m_page->RemovePrivateData((void*)m_page); |
| 657 if (m_bTakeOverPage) { | 655 if (m_bTakeOverPage) { |
| 658 delete m_page; | 656 delete m_page; |
| 659 } | 657 } |
| 660 #endif | 658 #endif // PDF_ENABLE_XFA |
| 661 } | 659 } |
| 662 | 660 |
| 663 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 661 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 664 CPDF_Matrix* pUser2Device, | 662 CPDF_Matrix* pUser2Device, |
| 665 #ifndef PDF_ENABLE_XFA | 663 #ifdef PDF_ENABLE_XFA |
| 666 CPDF_RenderOptions* pOptions) { | |
| 667 #else | |
| 668 CPDF_RenderOptions* pOptions, | 664 CPDF_RenderOptions* pOptions, |
| 669 const FX_RECT& pClip) { | 665 const FX_RECT& pClip) { |
| 670 #endif | 666 #else |
| 667 CPDF_RenderOptions* pOptions) { |
| 668 #endif // PDF_ENABLE_XFA |
| 671 m_curMatrix = *pUser2Device; | 669 m_curMatrix = *pUser2Device; |
| 672 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 670 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 671 |
| 673 #ifdef PDF_ENABLE_XFA | 672 #ifdef PDF_ENABLE_XFA |
| 674 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 673 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
| 675 if (pPage == NULL) | 674 if (pPage == NULL) |
| 676 return; | 675 return; |
| 677 | 676 |
| 678 #ifdef PDF_ENABLE_XFA | |
| 679 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 677 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 680 CFX_Graphics gs; | 678 CFX_Graphics gs; |
| 681 gs.Create(pDevice); | 679 gs.Create(pDevice); |
| 682 CFX_RectF rectClip; | 680 CFX_RectF rectClip; |
| 683 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), | 681 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), |
| 684 static_cast<FX_FLOAT>(pClip.top), | 682 static_cast<FX_FLOAT>(pClip.top), |
| 685 static_cast<FX_FLOAT>(pClip.Width()), | 683 static_cast<FX_FLOAT>(pClip.Width()), |
| 686 static_cast<FX_FLOAT>(pClip.Height())); | 684 static_cast<FX_FLOAT>(pClip.Height())); |
| 687 gs.SetClipRect(rectClip); | 685 gs.SetClipRect(rectClip); |
| 688 IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create(); | 686 IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create(); |
| 689 if (!pRenderContext) | 687 if (!pRenderContext) |
| 690 return; | 688 return; |
| 691 CXFA_RenderOptions renderOptions; | 689 CXFA_RenderOptions renderOptions; |
| 692 renderOptions.m_bHighlight = TRUE; | 690 renderOptions.m_bHighlight = TRUE; |
| 693 pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device, | 691 pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device, |
| 694 renderOptions); | 692 renderOptions); |
| 695 pRenderContext->DoRender(); | 693 pRenderContext->DoRender(); |
| 696 pRenderContext->StopRender(); | 694 pRenderContext->StopRender(); |
| 697 pRenderContext->Release(); | 695 pRenderContext->Release(); |
| 698 return; | 696 return; |
| 699 } | 697 } |
| 700 #endif // PDF_ENABLE_XFA | 698 #endif // PDF_ENABLE_XFA |
| 701 | 699 |
| 702 // for pdf/static xfa. | 700 // for pdf/static xfa. |
| 703 #endif | |
| 704 CPDFSDK_AnnotIterator annotIterator(this, true); | 701 CPDFSDK_AnnotIterator annotIterator(this, true); |
| 705 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 702 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 706 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 703 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 707 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 704 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
| 708 } | 705 } |
| 709 } | 706 } |
| 710 | 707 |
| 711 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 708 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| 712 FX_FLOAT pageY) { | 709 FX_FLOAT pageY) { |
| 713 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { | 710 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 742 |
| 746 return nullptr; | 743 return nullptr; |
| 747 } | 744 } |
| 748 | 745 |
| 749 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 746 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
| 750 FX_FLOAT pageY) { | 747 FX_FLOAT pageY) { |
| 751 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 748 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 752 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 749 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
| 753 CPDFSDK_AnnotIterator annotIterator(this, false); | 750 CPDFSDK_AnnotIterator annotIterator(this, false); |
| 754 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 751 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 755 #ifndef PDF_ENABLE_XFA | |
| 756 if (pSDKAnnot->GetType() == "Widget") { | |
| 757 #else | |
| 758 bool bHitTest = pSDKAnnot->GetType() == "Widget"; | 752 bool bHitTest = pSDKAnnot->GetType() == "Widget"; |
| 753 #ifdef PDF_ENABLE_XFA |
| 759 bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME; | 754 bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME; |
| 755 #endif // PDF_ENABLE_XFA |
| 760 if (bHitTest) { | 756 if (bHitTest) { |
| 761 #endif | |
| 762 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 757 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 763 CPDF_Point point(pageX, pageY); | 758 CPDF_Point point(pageX, pageY); |
| 764 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 759 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
| 765 return pSDKAnnot; | 760 return pSDKAnnot; |
| 766 } | 761 } |
| 767 } | 762 } |
| 768 | 763 |
| 769 return nullptr; | 764 return nullptr; |
| 770 } | 765 } |
| 771 | 766 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 805 |
| 811 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 806 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 812 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 807 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
| 813 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 808 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
| 814 if (!pSDKAnnot) | 809 if (!pSDKAnnot) |
| 815 return nullptr; | 810 return nullptr; |
| 816 | 811 |
| 817 m_fxAnnotArray.push_back(pSDKAnnot); | 812 m_fxAnnotArray.push_back(pSDKAnnot); |
| 818 return pSDKAnnot; | 813 return pSDKAnnot; |
| 819 } | 814 } |
| 815 #endif // PDF_ENABLE_XFA |
| 820 | 816 |
| 821 #endif | |
| 822 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { | 817 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { |
| 823 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; | 818 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; |
| 824 } | 819 } |
| 825 | 820 |
| 826 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, | 821 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, |
| 827 CPDF_Dictionary* pDict) { | 822 CPDF_Dictionary* pDict) { |
| 828 return NULL; | 823 return NULL; |
| 829 } | 824 } |
| 830 | 825 |
| 831 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 826 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
| 832 #ifndef PDF_ENABLE_XFA | 827 #ifdef PDF_ENABLE_XFA |
| 833 return FALSE; | |
| 834 #else | |
| 835 if (!pAnnot) | 828 if (!pAnnot) |
| 836 return FALSE; | 829 return FALSE; |
| 837 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 830 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
| 838 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && | 831 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && |
| 839 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) | 832 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) |
| 840 return FALSE; | 833 return FALSE; |
| 841 | 834 |
| 842 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); | 835 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); |
| 843 if (it != m_fxAnnotArray.end()) | 836 if (it != m_fxAnnotArray.end()) |
| 844 m_fxAnnotArray.erase(it); | 837 m_fxAnnotArray.erase(it); |
| 845 if (m_CaptureWidget == pAnnot) | 838 if (m_CaptureWidget == pAnnot) |
| 846 m_CaptureWidget = nullptr; | 839 m_CaptureWidget = nullptr; |
| 847 | 840 |
| 848 return TRUE; | 841 return TRUE; |
| 849 #endif | 842 #else // PDF_ENABLE_XFA |
| 843 return FALSE; |
| 844 #endif // PDF_ENABLE_XFA |
| 850 } | 845 } |
| 851 | 846 |
| 852 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { | 847 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
| 853 if (m_page) { | 848 if (m_page) { |
| 854 #ifndef PDF_ENABLE_XFA | 849 #ifdef PDF_ENABLE_XFA |
| 850 return m_page->GetDocument()->GetPDFDoc(); |
| 851 #else // PDF_ENABLE_XFA |
| 855 return m_page->m_pDocument; | 852 return m_page->m_pDocument; |
| 856 #else | 853 #endif // PDF_ENABLE_XFA |
| 857 return m_page->GetDocument()->GetPDFDoc(); | |
| 858 } | 854 } |
| 859 return NULL; | 855 return NULL; |
| 860 } | 856 } |
| 861 | 857 |
| 858 #ifdef PDF_ENABLE_XFA |
| 862 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { | 859 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { |
| 863 if (m_page) { | 860 if (m_page) { |
| 864 return m_page->GetPDFPage(); | 861 return m_page->GetPDFPage(); |
| 865 #endif | |
| 866 } | 862 } |
| 867 return NULL; | 863 return NULL; |
| 868 } | 864 } |
| 865 #endif // PDF_ENABLE_XFA |
| 869 | 866 |
| 870 size_t CPDFSDK_PageView::CountAnnots() const { | 867 size_t CPDFSDK_PageView::CountAnnots() const { |
| 871 return m_fxAnnotArray.size(); | 868 return m_fxAnnotArray.size(); |
| 872 } | 869 } |
| 873 | 870 |
| 874 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { | 871 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
| 875 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; | 872 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; |
| 876 } | 873 } |
| 877 | 874 |
| 878 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { | 875 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
| 879 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 876 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 880 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) | 877 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) |
| 881 return pAnnot; | 878 return pAnnot; |
| 882 } | 879 } |
| 883 return nullptr; | 880 return nullptr; |
| 884 } | 881 } |
| 882 |
| 885 #ifdef PDF_ENABLE_XFA | 883 #ifdef PDF_ENABLE_XFA |
| 886 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) { | 884 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) { |
| 887 if (!hWidget) | 885 if (!hWidget) |
| 888 return nullptr; | 886 return nullptr; |
| 889 | 887 |
| 890 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 888 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 891 if (pAnnot->GetXFAWidget() == hWidget) | 889 if (pAnnot->GetXFAWidget() == hWidget) |
| 892 return pAnnot; | 890 return pAnnot; |
| 893 } | 891 } |
| 894 return nullptr; | 892 return nullptr; |
| 895 } | 893 } |
| 896 #endif | 894 #endif // PDF_ENABLE_XFA |
| 897 | 895 |
| 898 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, | 896 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, |
| 899 FX_UINT nFlag) { | 897 FX_UINT nFlag) { |
| 900 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 898 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 901 ASSERT(pEnv); | 899 ASSERT(pEnv); |
| 902 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 900 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 903 if (!pFXAnnot) { | 901 if (!pFXAnnot) { |
| 904 KillFocusAnnot(nFlag); | 902 KillFocusAnnot(nFlag); |
| 905 return FALSE; | 903 return FALSE; |
| 906 } | 904 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 if (pFXAnnot == NULL) | 942 if (pFXAnnot == NULL) |
| 945 return FALSE; | 943 return FALSE; |
| 946 | 944 |
| 947 FX_BOOL bRet = | 945 FX_BOOL bRet = |
| 948 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point); | 946 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point); |
| 949 if (bRet) { | 947 if (bRet) { |
| 950 SetFocusAnnot(pFXAnnot); | 948 SetFocusAnnot(pFXAnnot); |
| 951 } | 949 } |
| 952 return TRUE; | 950 return TRUE; |
| 953 } | 951 } |
| 952 #endif // PDF_ENABLE_XFA |
| 954 | 953 |
| 955 #endif | |
| 956 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { | 954 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { |
| 957 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 955 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 958 ASSERT(pEnv); | 956 ASSERT(pEnv); |
| 959 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 957 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 960 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 958 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 961 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); | 959 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); |
| 962 FX_BOOL bRet = FALSE; | 960 FX_BOOL bRet = FALSE; |
| 963 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 961 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
| 964 // Last focus Annot gets a chance to handle the event. | 962 // Last focus Annot gets a chance to handle the event. |
| 965 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); | 963 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 } | 1031 } |
| 1034 | 1032 |
| 1035 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 1033 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 1036 return FALSE; | 1034 return FALSE; |
| 1037 } | 1035 } |
| 1038 | 1036 |
| 1039 void CPDFSDK_PageView::LoadFXAnnots() { | 1037 void CPDFSDK_PageView::LoadFXAnnots() { |
| 1040 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1038 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1041 #ifdef PDF_ENABLE_XFA | 1039 #ifdef PDF_ENABLE_XFA |
| 1042 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 1040 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 1043 #endif | 1041 #else |
| 1044 | |
| 1045 #ifndef PDF_ENABLE_XFA | |
| 1046 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 1042 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
| 1047 // Disable the default AP construction. | 1043 // Disable the default AP construction. |
| 1048 CPDF_InterForm::EnableUpdateAP(FALSE); | 1044 CPDF_InterForm::EnableUpdateAP(FALSE); |
| 1049 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); | 1045 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); |
| 1050 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 1046 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
| 1051 const size_t nCount = m_pAnnotList->Count(); | 1047 const size_t nCount = m_pAnnotList->Count(); |
| 1052 #endif | 1048 #endif // PDF_ENABLE_XFA |
| 1049 |
| 1053 SetLock(TRUE); | 1050 SetLock(TRUE); |
| 1054 #ifndef PDF_ENABLE_XFA | 1051 |
| 1055 for (size_t i = 0; i < nCount; ++i) { | 1052 #ifdef PDF_ENABLE_XFA |
| 1056 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | |
| 1057 CPDF_Document* pDoc = GetPDFDocument(); | |
| 1058 #else | |
| 1059 m_page->AddRef(); | 1053 m_page->AddRef(); |
| 1060 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 1054 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 1061 IXFA_PageView* pageView = NULL; | 1055 IXFA_PageView* pageView = NULL; |
| 1062 pageView = m_page->GetXFAPageView(); | 1056 pageView = m_page->GetXFAPageView(); |
| 1063 ASSERT(pageView != NULL); | 1057 ASSERT(pageView != NULL); |
| 1064 | 1058 |
| 1065 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( | 1059 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( |
| 1066 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | | 1060 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | |
| 1067 XFA_WIDGETFILTER_Viewable | | 1061 XFA_WIDGETFILTER_Viewable | |
| 1068 XFA_WIDGETFILTER_AllType); | 1062 XFA_WIDGETFILTER_AllType); |
| 1069 if (!pWidgetHander) { | 1063 if (!pWidgetHander) { |
| 1070 m_page->Release(); | 1064 m_page->Release(); |
| 1071 SetLock(FALSE); | 1065 SetLock(FALSE); |
| 1072 return; | 1066 return; |
| 1073 } | 1067 } |
| 1074 | 1068 |
| 1075 while (IXFA_Widget* pXFAAnnot = pWidgetHander->MoveToNext()) { | 1069 while (IXFA_Widget* pXFAAnnot = pWidgetHander->MoveToNext()) { |
| 1076 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); | 1070 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); |
| 1077 if (!pAnnot) | 1071 if (!pAnnot) |
| 1078 continue; | 1072 continue; |
| 1079 | 1073 |
| 1080 m_fxAnnotArray.push_back(pAnnot); | 1074 m_fxAnnotArray.push_back(pAnnot); |
| 1081 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1075 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 1082 } | 1076 } |
| 1083 #endif | |
| 1084 | |
| 1085 #ifndef PDF_ENABLE_XFA | |
| 1086 CheckUnSupportAnnot(pDoc, pPDFAnnot); | |
| 1087 #else | |
| 1088 pWidgetHander->Release(); | 1077 pWidgetHander->Release(); |
| 1089 } else { | 1078 } else { |
| 1090 CPDF_Page* pPage = m_page->GetPDFPage(); | 1079 CPDF_Page* pPage = m_page->GetPDFPage(); |
| 1091 ASSERT(pPage != NULL); | 1080 ASSERT(pPage != NULL); |
| 1092 #endif | |
| 1093 | |
| 1094 #ifndef PDF_ENABLE_XFA | |
| 1095 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | |
| 1096 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | |
| 1097 if (!pAnnot) | |
| 1098 continue; | |
| 1099 m_fxAnnotArray.push_back(pAnnot); | |
| 1100 #else | |
| 1101 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 1081 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
| 1102 // Disable the default AP construction. | 1082 // Disable the default AP construction. |
| 1103 CPDF_InterForm::EnableUpdateAP(FALSE); | 1083 CPDF_InterForm::EnableUpdateAP(FALSE); |
| 1104 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); | 1084 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); |
| 1105 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 1085 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
| 1106 | 1086 |
| 1107 const size_t nCount = m_pAnnotList->Count(); | 1087 const size_t nCount = m_pAnnotList->Count(); |
| 1108 for (size_t i = 0; i < nCount; ++i) { | 1088 for (size_t i = 0; i < nCount; ++i) { |
| 1109 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 1089 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 1110 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); | 1090 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); |
| 1111 | 1091 |
| 1112 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 1092 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| 1113 if (!pAnnot) | 1093 if (!pAnnot) |
| 1114 continue; | 1094 continue; |
| 1115 m_fxAnnotArray.push_back(pAnnot); | 1095 m_fxAnnotArray.push_back(pAnnot); |
| 1116 #endif | |
| 1117 | |
| 1118 #ifndef PDF_ENABLE_XFA | |
| 1119 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | |
| 1120 #else | |
| 1121 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1096 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 1122 } | 1097 } |
| 1123 #endif | |
| 1124 } | 1098 } |
| 1125 #ifdef PDF_ENABLE_XFA | |
| 1126 m_page->Release(); | 1099 m_page->Release(); |
| 1127 #endif | 1100 #else // PDF_ENABLE_XFA |
| 1101 for (size_t i = 0; i < nCount; ++i) { |
| 1102 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 1103 CPDF_Document* pDoc = GetPDFDocument(); |
| 1104 CheckUnSupportAnnot(pDoc, pPDFAnnot); |
| 1105 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 1106 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| 1107 if (!pAnnot) |
| 1108 continue; |
| 1109 m_fxAnnotArray.push_back(pAnnot); |
| 1110 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 1111 } |
| 1112 #endif // PDF_ENABLE_XFA |
| 1113 |
| 1128 SetLock(FALSE); | 1114 SetLock(FALSE); |
| 1129 } | 1115 } |
| 1130 | 1116 |
| 1131 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { | 1117 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { |
| 1132 for (int i = 0; i < rects.GetSize(); i++) { | 1118 for (int i = 0; i < rects.GetSize(); i++) { |
| 1133 CPDF_Rect rc = rects.GetAt(i); | 1119 CPDF_Rect rc = rects.GetAt(i); |
| 1134 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1120 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1135 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 1121 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
| 1136 } | 1122 } |
| 1137 } | 1123 } |
| 1138 | 1124 |
| 1139 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { | 1125 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
| 1140 CPDF_Rect rcWindow = pAnnot->GetRect(); | 1126 CPDF_Rect rcWindow = pAnnot->GetRect(); |
| 1141 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1127 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1142 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, | 1128 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, |
| 1143 rcWindow.bottom); | 1129 rcWindow.bottom); |
| 1144 } | 1130 } |
| 1145 | 1131 |
| 1146 int CPDFSDK_PageView::GetPageIndex() { | 1132 int CPDFSDK_PageView::GetPageIndex() { |
| 1147 if (m_page) { | 1133 if (m_page) { |
| 1148 #ifndef PDF_ENABLE_XFA | 1134 #ifdef PDF_ENABLE_XFA |
| 1135 CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict; |
| 1136 #else // PDF_ENABLE_XFA |
| 1149 CPDF_Dictionary* pDic = m_page->m_pFormDict; | 1137 CPDF_Dictionary* pDic = m_page->m_pFormDict; |
| 1150 #else | 1138 #endif // PDF_ENABLE_XFA |
| 1151 CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict; | |
| 1152 #endif | |
| 1153 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 1139 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 1154 if (pDoc && pDic) { | 1140 if (pDoc && pDic) { |
| 1155 return pDoc->GetPageIndex(pDic->GetObjNum()); | 1141 return pDoc->GetPageIndex(pDic->GetObjNum()); |
| 1156 } | 1142 } |
| 1157 } | 1143 } |
| 1158 return -1; | 1144 return -1; |
| 1159 } | 1145 } |
| 1160 | 1146 |
| 1161 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { | 1147 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { |
| 1162 if (!p) | 1148 if (!p) |
| 1163 return false; | 1149 return false; |
| 1164 | 1150 |
| 1165 const auto& annots = m_pAnnotList->All(); | 1151 const auto& annots = m_pAnnotList->All(); |
| 1166 return std::find(annots.begin(), annots.end(), p) != annots.end(); | 1152 return std::find(annots.begin(), annots.end(), p) != annots.end(); |
| 1167 } | 1153 } |
| 1168 | 1154 |
| 1169 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 1155 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
| 1170 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1156 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
| 1171 if (!pFocusAnnot) | 1157 if (!pFocusAnnot) |
| 1172 return nullptr; | 1158 return nullptr; |
| 1173 | 1159 |
| 1174 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1160 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 1175 if (pAnnot == pFocusAnnot) | 1161 if (pAnnot == pFocusAnnot) |
| 1176 return pAnnot; | 1162 return pAnnot; |
| 1177 } | 1163 } |
| 1178 return nullptr; | 1164 return nullptr; |
| 1179 } | 1165 } |
| OLD | NEW |