Chromium Code Reviews| 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 #include "../include/fpdfxfa/fpdfxfa_app.h" | 18 #include "../include/fpdfxfa/fpdfxfa_app.h" |
| 18 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 19 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 19 #include "../include/fpdfxfa/fpdfxfa_page.h" | 20 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| 20 #include "../include/fpdfxfa/fpdfxfa_util.h" | 21 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 21 | 22 |
| 23 #endif | |
| 22 #if _FX_OS_ == _FX_ANDROID_ | 24 #if _FX_OS_ == _FX_ANDROID_ |
| 23 #include "time.h" | 25 #include "time.h" |
| 24 #else | 26 #else |
| 25 #include <ctime> | 27 #include <ctime> |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 28 class CFX_SystemHandler : public IFX_SystemHandler { | 30 class CFX_SystemHandler : public IFX_SystemHandler { |
| 29 public: | 31 public: |
| 30 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) | 32 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) |
| 31 : m_pEnv(pEnv), m_nCharSet(-1) {} | 33 : m_pEnv(pEnv), m_nCharSet(-1) {} |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 return m_pEnv->FFI_GetLocalTime(); | 207 return m_pEnv->FFI_GetLocalTime(); |
| 206 } | 208 } |
| 207 | 209 |
| 208 CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc, | 210 CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc, |
| 209 FPDF_FORMFILLINFO* pFFinfo) | 211 FPDF_FORMFILLINFO* pFFinfo) |
| 210 : m_pInfo(pFFinfo), m_pSDKDoc(NULL), m_pUnderlyingDoc(pDoc) { | 212 : m_pInfo(pFFinfo), m_pSDKDoc(NULL), m_pUnderlyingDoc(pDoc) { |
| 211 m_pSysHandler.reset(new CFX_SystemHandler(this)); | 213 m_pSysHandler.reset(new CFX_SystemHandler(this)); |
| 212 } | 214 } |
| 213 | 215 |
| 214 CPDFDoc_Environment::~CPDFDoc_Environment() { | 216 CPDFDoc_Environment::~CPDFDoc_Environment() { |
| 217 #ifdef PDF_ENABLE_XFA | |
| 215 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 218 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
| 216 if (pProvider->m_pEnvList.GetSize() == 0) | 219 if (pProvider->m_pEnvList.GetSize() == 0) |
| 217 pProvider->SetJavaScriptInitialized(FALSE); | 220 pProvider->SetJavaScriptInitialized(FALSE); |
| 221 #endif | |
| 218 } | 222 } |
| 219 | 223 |
| 220 int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, | 224 int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, |
| 221 const FX_WCHAR* Title, | 225 const FX_WCHAR* Title, |
| 222 FX_UINT Type, | 226 FX_UINT Type, |
| 223 FX_UINT Icon) { | 227 FX_UINT Icon) { |
| 224 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) { |
| 225 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); | 229 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| 226 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); | 230 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| 227 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); | 231 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 return TRUE; | 535 return TRUE; |
| 532 | 536 |
| 533 if (m_pFocusAnnot) { | 537 if (m_pFocusAnnot) { |
| 534 if (!KillFocusAnnot(nFlag)) | 538 if (!KillFocusAnnot(nFlag)) |
| 535 return FALSE; | 539 return FALSE; |
| 536 } | 540 } |
| 537 | 541 |
| 538 if (!pAnnot) | 542 if (!pAnnot) |
| 539 return FALSE; | 543 return FALSE; |
| 540 | 544 |
| 545 #ifdef PDF_ENABLE_XFA | |
| 541 CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; | 546 CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; |
| 547 #endif | |
| 542 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 548 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 543 if (pPageView && pPageView->IsValid()) { | 549 if (pPageView && pPageView->IsValid()) { |
| 544 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); | 550 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); |
| 545 if (!m_pFocusAnnot) { | 551 if (!m_pFocusAnnot) { |
| 552 #ifdef PDF_ENABLE_XFA | |
| 546 if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) | 553 if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) |
| 547 return FALSE; | 554 return FALSE; |
| 548 | 555 |
| 556 #endif | |
| 549 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) | 557 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) |
| 550 return FALSE; | 558 return FALSE; |
| 551 if (!m_pFocusAnnot) { | 559 if (!m_pFocusAnnot) { |
| 552 m_pFocusAnnot = pAnnot; | 560 m_pFocusAnnot = pAnnot; |
| 553 return TRUE; | 561 return TRUE; |
| 554 } | 562 } |
| 555 } | 563 } |
| 556 } | 564 } |
| 557 return FALSE; | 565 return FALSE; |
| 558 } | 566 } |
| 559 | 567 |
| 560 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { | 568 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { |
| 561 if (m_pFocusAnnot) { | 569 if (m_pFocusAnnot) { |
| 562 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); | 570 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); |
| 563 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; | 571 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; |
| 564 m_pFocusAnnot = nullptr; | 572 m_pFocusAnnot = nullptr; |
| 573 #ifdef PDF_ENABLE_XFA | |
| 565 | 574 |
| 566 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) | 575 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) |
| 567 return FALSE; | 576 return FALSE; |
| 568 | 577 |
| 578 #endif | |
| 569 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { | 579 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { |
| 570 if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { | 580 if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { |
| 571 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; | 581 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; |
| 572 int nFieldType = pWidget->GetFieldType(); | 582 int nFieldType = pWidget->GetFieldType(); |
| 573 if (FIELDTYPE_TEXTFIELD == nFieldType || | 583 if (FIELDTYPE_TEXTFIELD == nFieldType || |
| 574 FIELDTYPE_COMBOBOX == nFieldType) { | 584 FIELDTYPE_COMBOBOX == nFieldType) { |
| 575 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); | 585 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); |
| 576 } | 586 } |
| 577 } | 587 } |
| 578 | 588 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 605 | 615 |
| 606 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, | 616 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, |
| 607 UnderlyingPageType* page) | 617 UnderlyingPageType* page) |
| 608 : m_page(page), | 618 : m_page(page), |
| 609 m_pSDKDoc(pSDKDoc), | 619 m_pSDKDoc(pSDKDoc), |
| 610 m_CaptureWidget(nullptr), | 620 m_CaptureWidget(nullptr), |
| 611 m_bEnterWidget(FALSE), | 621 m_bEnterWidget(FALSE), |
| 612 m_bExitWidget(FALSE), | 622 m_bExitWidget(FALSE), |
| 613 m_bOnWidget(FALSE), | 623 m_bOnWidget(FALSE), |
| 614 m_bValid(FALSE), | 624 m_bValid(FALSE), |
| 625 #ifndef PDF_ENABLE_XFA | |
| 626 m_bLocked(FALSE), | |
| 627 m_bTakeOverPage(FALSE) { | |
| 628 #else | |
| 615 m_bLocked(FALSE) { | 629 m_bLocked(FALSE) { |
| 630 #endif | |
| 616 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 631 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
| 617 if (pInterForm) { | 632 if (pInterForm) { |
| 618 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 633 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 634 #ifndef PDF_ENABLE_XFA | |
| 635 pPDFInterForm->FixPageFields(page); | |
| 636 #else | |
| 619 if (page->GetPDFPage()) | 637 if (page->GetPDFPage()) |
| 620 pPDFInterForm->FixPageFields(page->GetPDFPage()); | 638 pPDFInterForm->FixPageFields(page->GetPDFPage()); |
| 639 #endif | |
| 621 } | 640 } |
| 641 #ifndef PDF_ENABLE_XFA | |
| 642 m_page->SetPrivateData((void*)m_page, (void*)this, nullptr); | |
| 643 #endif | |
| 622 } | 644 } |
| 623 | 645 |
| 624 CPDFSDK_PageView::~CPDFSDK_PageView() { | 646 CPDFSDK_PageView::~CPDFSDK_PageView() { |
| 625 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 647 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 626 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 648 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 627 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) | 649 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
| 628 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 650 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
| 629 m_fxAnnotArray.clear(); | 651 m_fxAnnotArray.clear(); |
| 630 | 652 |
| 631 m_pAnnotList.reset(); | 653 m_pAnnotList.reset(); |
| 654 #ifndef PDF_ENABLE_XFA | |
| 655 | |
| 656 m_page->RemovePrivateData((void*)m_page); | |
| 657 if (m_bTakeOverPage) { | |
| 658 delete m_page; | |
| 659 } | |
| 660 #endif | |
| 632 } | 661 } |
| 633 | 662 |
| 634 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 663 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 635 CPDF_Matrix* pUser2Device, | 664 CPDF_Matrix* pUser2Device, |
| 665 #ifndef PDF_ENABLE_XFA | |
| 666 CPDF_RenderOptions* pOptions) { | |
| 667 #else | |
| 636 CPDF_RenderOptions* pOptions, | 668 CPDF_RenderOptions* pOptions, |
| 637 const FX_RECT& pClip) { | 669 const FX_RECT& pClip) { |
| 670 #endif | |
| 638 m_curMatrix = *pUser2Device; | 671 m_curMatrix = *pUser2Device; |
| 672 #ifdef PDF_ENABLE_XFA | |
| 639 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 673 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 640 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 674 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
| 641 | 675 |
| 642 if (pPage == NULL) | 676 if (pPage == NULL) |
| 643 return; | 677 return; |
| 678 #endif | |
| 644 | 679 |
| 680 #ifndef PDF_ENABLE_XFA | |
| 681 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | |
|
Lei Zhang
2015/11/25 00:34:31
Dup of line 673.
Tom Sepez
2015/11/25 21:45:30
Strange. Wonder if there was some whitespace diff
| |
| 682 #else | |
| 645 #ifdef PDF_ENABLE_XFA | 683 #ifdef PDF_ENABLE_XFA |
| 646 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { | 684 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { |
| 647 CFX_Graphics gs; | 685 CFX_Graphics gs; |
| 648 gs.Create(pDevice); | 686 gs.Create(pDevice); |
| 649 CFX_RectF rectClip; | 687 CFX_RectF rectClip; |
| 650 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), | 688 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), |
| 651 static_cast<FX_FLOAT>(pClip.top), | 689 static_cast<FX_FLOAT>(pClip.top), |
| 652 static_cast<FX_FLOAT>(pClip.Width()), | 690 static_cast<FX_FLOAT>(pClip.Width()), |
| 653 static_cast<FX_FLOAT>(pClip.Height())); | 691 static_cast<FX_FLOAT>(pClip.Height())); |
| 654 gs.SetClipRect(rectClip); | 692 gs.SetClipRect(rectClip); |
| 655 IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create(); | 693 IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create(); |
| 656 if (!pRenderContext) | 694 if (!pRenderContext) |
| 657 return; | 695 return; |
| 658 CXFA_RenderOptions renderOptions; | 696 CXFA_RenderOptions renderOptions; |
| 659 renderOptions.m_bHighlight = TRUE; | 697 renderOptions.m_bHighlight = TRUE; |
| 660 pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device, | 698 pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device, |
| 661 renderOptions); | 699 renderOptions); |
| 662 pRenderContext->DoRender(); | 700 pRenderContext->DoRender(); |
| 663 pRenderContext->StopRender(); | 701 pRenderContext->StopRender(); |
| 664 pRenderContext->Release(); | 702 pRenderContext->Release(); |
| 665 return; | 703 return; |
| 666 } | 704 } |
| 667 #endif // PDF_ENABLE_XFA | 705 #endif // PDF_ENABLE_XFA |
| 668 | 706 |
| 669 // for pdf/static xfa. | 707 // for pdf/static xfa. |
| 708 #endif | |
| 670 CPDFSDK_AnnotIterator annotIterator(this, true); | 709 CPDFSDK_AnnotIterator annotIterator(this, true); |
| 671 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 710 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 672 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 711 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 673 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 712 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
| 674 } | 713 } |
| 675 } | 714 } |
| 676 | 715 |
| 677 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 716 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| 678 FX_FLOAT pageY) { | 717 FX_FLOAT pageY) { |
| 679 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { | 718 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 | 750 |
| 712 return nullptr; | 751 return nullptr; |
| 713 } | 752 } |
| 714 | 753 |
| 715 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 754 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
| 716 FX_FLOAT pageY) { | 755 FX_FLOAT pageY) { |
| 717 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 756 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 718 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 757 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
| 719 CPDFSDK_AnnotIterator annotIterator(this, false); | 758 CPDFSDK_AnnotIterator annotIterator(this, false); |
| 720 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 759 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 760 #ifndef PDF_ENABLE_XFA | |
| 761 if (pSDKAnnot->GetType() == "Widget") { | |
|
Lei Zhang
2015/11/25 00:34:31
Maybe:
bool bHitTest = pSDKAnnot->GetType() == "W
Tom Sepez
2015/11/25 21:45:30
Done. Will use
bHitTest = bHitTest || pSDKAnnot
| |
| 762 #else | |
| 721 if (pSDKAnnot->GetType() == "Widget" || | 763 if (pSDKAnnot->GetType() == "Widget" || |
| 722 pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME) { | 764 pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME) { |
| 765 #endif | |
| 723 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 766 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 724 CPDF_Point point(pageX, pageY); | 767 CPDF_Point point(pageX, pageY); |
| 725 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 768 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
| 726 return pSDKAnnot; | 769 return pSDKAnnot; |
| 727 } | 770 } |
| 728 } | 771 } |
| 729 | 772 |
| 730 return nullptr; | 773 return nullptr; |
| 731 } | 774 } |
| 732 | 775 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 753 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 796 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
| 754 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 797 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
| 755 if (!pSDKAnnot) | 798 if (!pSDKAnnot) |
| 756 return nullptr; | 799 return nullptr; |
| 757 | 800 |
| 758 m_fxAnnotArray.push_back(pSDKAnnot); | 801 m_fxAnnotArray.push_back(pSDKAnnot); |
| 759 pAnnotHandler->Annot_OnCreate(pSDKAnnot); | 802 pAnnotHandler->Annot_OnCreate(pSDKAnnot); |
| 760 return pSDKAnnot; | 803 return pSDKAnnot; |
| 761 } | 804 } |
| 762 | 805 |
| 806 #ifdef PDF_ENABLE_XFA | |
| 763 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) { | 807 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) { |
| 764 if (!pPDFAnnot) | 808 if (!pPDFAnnot) |
| 765 return nullptr; | 809 return nullptr; |
| 766 | 810 |
| 767 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); | 811 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); |
| 768 if (pSDKAnnot) | 812 if (pSDKAnnot) |
| 769 return pSDKAnnot; | 813 return pSDKAnnot; |
| 770 | 814 |
| 771 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 815 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 772 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 816 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
| 773 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 817 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
| 774 if (!pSDKAnnot) | 818 if (!pSDKAnnot) |
| 775 return nullptr; | 819 return nullptr; |
| 776 | 820 |
| 777 m_fxAnnotArray.push_back(pSDKAnnot); | 821 m_fxAnnotArray.push_back(pSDKAnnot); |
| 778 return pSDKAnnot; | 822 return pSDKAnnot; |
| 779 } | 823 } |
| 780 | 824 |
| 825 #endif | |
| 781 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { | 826 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { |
| 782 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; | 827 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; |
| 783 } | 828 } |
| 784 | 829 |
| 785 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, | 830 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, |
| 786 CPDF_Dictionary* pDict) { | 831 CPDF_Dictionary* pDict) { |
| 787 return NULL; | 832 return NULL; |
| 788 } | 833 } |
| 789 | 834 |
| 790 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 835 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
| 836 #ifndef PDF_ENABLE_XFA | |
| 837 return FALSE; | |
| 838 #else | |
| 791 if (!pAnnot) | 839 if (!pAnnot) |
| 792 return FALSE; | 840 return FALSE; |
| 793 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 841 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
| 794 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && | 842 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && |
| 795 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNIMIC_XFA)) | 843 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNIMIC_XFA)) |
| 796 return FALSE; | 844 return FALSE; |
| 797 | 845 |
| 798 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); | 846 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); |
| 799 if (it != m_fxAnnotArray.end()) | 847 if (it != m_fxAnnotArray.end()) |
| 800 m_fxAnnotArray.erase(it); | 848 m_fxAnnotArray.erase(it); |
| 801 if (m_CaptureWidget == pAnnot) | 849 if (m_CaptureWidget == pAnnot) |
| 802 m_CaptureWidget = nullptr; | 850 m_CaptureWidget = nullptr; |
| 803 | 851 |
| 804 return TRUE; | 852 return TRUE; |
| 853 #endif | |
| 805 } | 854 } |
| 806 | 855 |
| 807 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { | 856 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
| 808 if (m_page) { | 857 if (m_page) { |
| 858 #ifndef PDF_ENABLE_XFA | |
| 859 return m_page->m_pDocument; | |
| 860 #else | |
| 809 return m_page->GetDocument()->GetPDFDoc(); | 861 return m_page->GetDocument()->GetPDFDoc(); |
| 810 } | 862 } |
| 811 return NULL; | 863 return NULL; |
| 812 } | 864 } |
| 813 | 865 |
| 814 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { | 866 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { |
| 815 if (m_page) { | 867 if (m_page) { |
| 816 return m_page->GetPDFPage(); | 868 return m_page->GetPDFPage(); |
| 869 #endif | |
|
Lei Zhang
2015/11/25 00:34:31
Weird automatic change.
Tom Sepez
2015/11/25 21:45:30
Removed whitespace on xfa side. Maybe it gets sma
| |
| 817 } | 870 } |
| 871 #ifdef PDF_ENABLE_XFA | |
| 818 | 872 |
| 873 #endif | |
| 819 return NULL; | 874 return NULL; |
| 820 } | 875 } |
| 821 | 876 |
| 822 size_t CPDFSDK_PageView::CountAnnots() const { | 877 size_t CPDFSDK_PageView::CountAnnots() const { |
| 823 return m_fxAnnotArray.size(); | 878 return m_fxAnnotArray.size(); |
| 824 } | 879 } |
| 825 | 880 |
| 826 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { | 881 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
| 827 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; | 882 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; |
| 828 } | 883 } |
| 829 | 884 |
| 830 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { | 885 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
| 831 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 886 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 832 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) | 887 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) |
| 833 return pAnnot; | 888 return pAnnot; |
| 834 } | 889 } |
| 835 return nullptr; | 890 return nullptr; |
| 836 } | 891 } |
| 892 #ifdef PDF_ENABLE_XFA | |
| 837 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) { | 893 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) { |
| 838 if (!hWidget) | 894 if (!hWidget) |
| 839 return nullptr; | 895 return nullptr; |
| 840 | 896 |
| 841 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 897 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 842 if (pAnnot->GetXFAWidget() == hWidget) | 898 if (pAnnot->GetXFAWidget() == hWidget) |
| 843 return pAnnot; | 899 return pAnnot; |
| 844 } | 900 } |
| 845 return nullptr; | 901 return nullptr; |
| 846 } | 902 } |
| 903 #endif | |
| 847 | 904 |
| 848 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, | 905 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, |
| 849 FX_UINT nFlag) { | 906 FX_UINT nFlag) { |
| 850 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 907 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 851 ASSERT(pEnv); | 908 ASSERT(pEnv); |
| 852 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 909 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 853 if (!pFXAnnot) { | 910 if (!pFXAnnot) { |
| 854 KillFocusAnnot(nFlag); | 911 KillFocusAnnot(nFlag); |
| 855 return FALSE; | 912 return FALSE; |
| 856 } | 913 } |
| 857 | 914 |
| 858 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 915 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 859 FX_BOOL bRet = | 916 FX_BOOL bRet = |
| 860 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); | 917 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); |
| 861 if (bRet) | 918 if (bRet) |
| 862 SetFocusAnnot(pFXAnnot); | 919 SetFocusAnnot(pFXAnnot); |
| 863 return bRet; | 920 return bRet; |
| 864 } | 921 } |
| 865 | 922 |
| 923 #ifdef PDF_ENABLE_XFA | |
| 866 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CPDF_Point& point, | 924 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CPDF_Point& point, |
| 867 FX_UINT nFlag) { | 925 FX_UINT nFlag) { |
| 868 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 926 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 869 ASSERT(pEnv); | 927 ASSERT(pEnv); |
| 870 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 928 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 871 ASSERT(pAnnotHandlerMgr); | 929 ASSERT(pAnnotHandlerMgr); |
| 872 | 930 |
| 873 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 931 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 874 | 932 |
| 875 if (pFXAnnot == NULL) | 933 if (pFXAnnot == NULL) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 894 return FALSE; | 952 return FALSE; |
| 895 | 953 |
| 896 FX_BOOL bRet = | 954 FX_BOOL bRet = |
| 897 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point); | 955 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point); |
| 898 if (bRet) { | 956 if (bRet) { |
| 899 SetFocusAnnot(pFXAnnot); | 957 SetFocusAnnot(pFXAnnot); |
| 900 } | 958 } |
| 901 return TRUE; | 959 return TRUE; |
| 902 } | 960 } |
| 903 | 961 |
| 962 #endif | |
| 904 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { | 963 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { |
| 905 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 964 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 906 ASSERT(pEnv); | 965 ASSERT(pEnv); |
| 907 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 966 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 908 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 967 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 909 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); | 968 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); |
| 910 FX_BOOL bRet = FALSE; | 969 FX_BOOL bRet = FALSE; |
| 911 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 970 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
| 912 // Last focus Annot gets a chance to handle the event. | 971 // Last focus Annot gets a chance to handle the event. |
| 913 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); | 972 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 979 } | 1038 } |
| 980 return FALSE; | 1039 return FALSE; |
| 981 } | 1040 } |
| 982 | 1041 |
| 983 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 1042 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 984 return FALSE; | 1043 return FALSE; |
| 985 } | 1044 } |
| 986 | 1045 |
| 987 void CPDFSDK_PageView::LoadFXAnnots() { | 1046 void CPDFSDK_PageView::LoadFXAnnots() { |
| 988 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1047 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1048 #ifdef PDF_ENABLE_XFA | |
| 989 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 1049 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 1050 #endif | |
| 990 | 1051 |
| 1052 #ifndef PDF_ENABLE_XFA | |
| 1053 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | |
| 1054 // Disable the default AP construction. | |
| 1055 CPDF_InterForm::EnableUpdateAP(FALSE); | |
| 1056 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); | |
| 1057 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | |
| 1058 const size_t nCount = m_pAnnotList->Count(); | |
| 1059 #endif | |
| 991 SetLock(TRUE); | 1060 SetLock(TRUE); |
| 1061 #ifndef PDF_ENABLE_XFA | |
| 1062 for (size_t i = 0; i < nCount; ++i) { | |
| 1063 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | |
| 1064 CPDF_Document* pDoc = GetPDFDocument(); | |
| 1065 #else | |
| 992 m_page->AddRef(); | 1066 m_page->AddRef(); |
| 993 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { | 1067 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { |
| 994 IXFA_PageView* pageView = NULL; | 1068 IXFA_PageView* pageView = NULL; |
| 995 pageView = m_page->GetXFAPageView(); | 1069 pageView = m_page->GetXFAPageView(); |
| 996 ASSERT(pageView != NULL); | 1070 ASSERT(pageView != NULL); |
| 997 | 1071 |
| 998 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( | 1072 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( |
| 999 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | | 1073 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | |
| 1000 XFA_WIDGETFILTER_Viewable | | 1074 XFA_WIDGETFILTER_Viewable | |
| 1001 XFA_WIDGETFILTER_AllType); | 1075 XFA_WIDGETFILTER_AllType); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1017 pWidgetHander->Release(); | 1091 pWidgetHander->Release(); |
| 1018 } else { | 1092 } else { |
| 1019 CPDF_Page* pPage = m_page->GetPDFPage(); | 1093 CPDF_Page* pPage = m_page->GetPDFPage(); |
| 1020 ASSERT(pPage != NULL); | 1094 ASSERT(pPage != NULL); |
| 1021 | 1095 |
| 1022 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 1096 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
| 1023 // Disable the default AP construction. | 1097 // Disable the default AP construction. |
| 1024 CPDF_InterForm::EnableUpdateAP(FALSE); | 1098 CPDF_InterForm::EnableUpdateAP(FALSE); |
| 1025 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); | 1099 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); |
| 1026 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 1100 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
| 1101 #endif | |
| 1027 | 1102 |
| 1103 #ifndef PDF_ENABLE_XFA | |
|
Lei Zhang
2015/11/25 00:34:31
The body of this function probably should be prope
Tom Sepez
2015/11/25 21:45:30
Ok manual.
| |
| 1104 CheckUnSupportAnnot(pDoc, pPDFAnnot); | |
| 1105 #else | |
| 1028 const size_t nCount = m_pAnnotList->Count(); | 1106 const size_t nCount = m_pAnnotList->Count(); |
| 1029 for (size_t i = 0; i < nCount; ++i) { | 1107 for (size_t i = 0; i < nCount; ++i) { |
| 1030 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 1108 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 1031 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); | 1109 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); |
| 1110 #endif | |
| 1032 | 1111 |
| 1112 #ifndef PDF_ENABLE_XFA | |
| 1113 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | |
| 1114 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | |
| 1115 if (!pAnnot) | |
| 1116 continue; | |
| 1117 m_fxAnnotArray.push_back(pAnnot); | |
| 1118 #else | |
| 1033 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 1119 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| 1034 if (!pAnnot) | 1120 if (!pAnnot) |
| 1035 continue; | 1121 continue; |
| 1036 m_fxAnnotArray.push_back(pAnnot); | 1122 m_fxAnnotArray.push_back(pAnnot); |
| 1123 #endif | |
| 1037 | 1124 |
| 1125 #ifndef PDF_ENABLE_XFA | |
| 1126 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | |
| 1127 #else | |
| 1038 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1128 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 1039 } | 1129 } |
| 1130 #endif | |
| 1040 } | 1131 } |
| 1132 #ifdef PDF_ENABLE_XFA | |
| 1041 m_page->Release(); | 1133 m_page->Release(); |
| 1134 #endif | |
| 1042 SetLock(FALSE); | 1135 SetLock(FALSE); |
| 1043 } | 1136 } |
| 1044 | 1137 |
| 1045 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { | 1138 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { |
| 1046 for (int i = 0; i < rects.GetSize(); i++) { | 1139 for (int i = 0; i < rects.GetSize(); i++) { |
| 1047 CPDF_Rect rc = rects.GetAt(i); | 1140 CPDF_Rect rc = rects.GetAt(i); |
| 1048 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1141 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1049 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 1142 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
| 1050 } | 1143 } |
| 1051 } | 1144 } |
| 1052 | 1145 |
| 1053 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { | 1146 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
| 1054 CPDF_Rect rcWindow = pAnnot->GetRect(); | 1147 CPDF_Rect rcWindow = pAnnot->GetRect(); |
| 1055 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1148 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1056 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, | 1149 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, |
| 1057 rcWindow.bottom); | 1150 rcWindow.bottom); |
| 1058 } | 1151 } |
| 1059 | 1152 |
| 1060 int CPDFSDK_PageView::GetPageIndex() { | 1153 int CPDFSDK_PageView::GetPageIndex() { |
| 1061 if (m_page) { | 1154 if (m_page) { |
| 1155 #ifndef PDF_ENABLE_XFA | |
| 1156 CPDF_Dictionary* pDic = m_page->m_pFormDict; | |
| 1157 #else | |
| 1062 CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict; | 1158 CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict; |
| 1159 #endif | |
| 1063 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 1160 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 1064 if (pDoc && pDic) { | 1161 if (pDoc && pDic) { |
| 1065 return pDoc->GetPageIndex(pDic->GetObjNum()); | 1162 return pDoc->GetPageIndex(pDic->GetObjNum()); |
| 1066 } | 1163 } |
| 1067 } | 1164 } |
| 1068 return -1; | 1165 return -1; |
| 1069 } | 1166 } |
| 1070 | 1167 |
| 1071 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { | 1168 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { |
| 1072 if (!p) | 1169 if (!p) |
| 1073 return false; | 1170 return false; |
| 1074 | 1171 |
| 1075 const auto& annots = m_pAnnotList->All(); | 1172 const auto& annots = m_pAnnotList->All(); |
| 1076 return std::find(annots.begin(), annots.end(), p) != annots.end(); | 1173 return std::find(annots.begin(), annots.end(), p) != annots.end(); |
| 1077 } | 1174 } |
| 1078 | 1175 |
| 1079 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 1176 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
| 1080 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1177 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
| 1081 if (!pFocusAnnot) | 1178 if (!pFocusAnnot) |
| 1082 return nullptr; | 1179 return nullptr; |
| 1083 | 1180 |
| 1084 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1181 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 1085 if (pAnnot == pFocusAnnot) | 1182 if (pAnnot == pFocusAnnot) |
| 1086 return pAnnot; | 1183 return pAnnot; |
| 1087 } | 1184 } |
| 1088 return nullptr; | 1185 return nullptr; |
| 1089 } | 1186 } |
| OLD | NEW |