Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: fpdfsdk/src/fsdk_mgr.cpp

Issue 1477583002: Inflict PDF_ENABLE_XFA ifdefs on XFA fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Remove fsdk_actionhandler.cpp Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fsdk_baseform.cpp ('k') | fpdfsdk/src/javascript/JS_Context.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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;
639 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 672 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
673 #ifdef PDF_ENABLE_XFA
640 CPDFXFA_Page* pPage = GetPDFXFAPage(); 674 CPDFXFA_Page* pPage = GetPDFXFAPage();
641 if (pPage == NULL) 675 if (pPage == NULL)
642 return; 676 return;
643 677
644 #ifdef PDF_ENABLE_XFA 678 #ifdef PDF_ENABLE_XFA
645 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { 679 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
646 CFX_Graphics gs; 680 CFX_Graphics gs;
647 gs.Create(pDevice); 681 gs.Create(pDevice);
648 CFX_RectF rectClip; 682 CFX_RectF rectClip;
649 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), 683 rectClip.Set(static_cast<FX_FLOAT>(pClip.left),
650 static_cast<FX_FLOAT>(pClip.top), 684 static_cast<FX_FLOAT>(pClip.top),
651 static_cast<FX_FLOAT>(pClip.Width()), 685 static_cast<FX_FLOAT>(pClip.Width()),
652 static_cast<FX_FLOAT>(pClip.Height())); 686 static_cast<FX_FLOAT>(pClip.Height()));
653 gs.SetClipRect(rectClip); 687 gs.SetClipRect(rectClip);
654 IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create(); 688 IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create();
655 if (!pRenderContext) 689 if (!pRenderContext)
656 return; 690 return;
657 CXFA_RenderOptions renderOptions; 691 CXFA_RenderOptions renderOptions;
658 renderOptions.m_bHighlight = TRUE; 692 renderOptions.m_bHighlight = TRUE;
659 pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device, 693 pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device,
660 renderOptions); 694 renderOptions);
661 pRenderContext->DoRender(); 695 pRenderContext->DoRender();
662 pRenderContext->StopRender(); 696 pRenderContext->StopRender();
663 pRenderContext->Release(); 697 pRenderContext->Release();
664 return; 698 return;
665 } 699 }
666 #endif // PDF_ENABLE_XFA 700 #endif // PDF_ENABLE_XFA
667 701
668 // for pdf/static xfa. 702 // for pdf/static xfa.
703 #endif
669 CPDFSDK_AnnotIterator annotIterator(this, true); 704 CPDFSDK_AnnotIterator annotIterator(this, true);
670 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 705 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
671 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 706 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
672 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); 707 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
673 } 708 }
674 } 709 }
675 710
676 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, 711 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
677 FX_FLOAT pageY) { 712 FX_FLOAT pageY) {
678 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { 713 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 745
711 return nullptr; 746 return nullptr;
712 } 747 }
713 748
714 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, 749 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
715 FX_FLOAT pageY) { 750 FX_FLOAT pageY) {
716 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 751 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
717 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); 752 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
718 CPDFSDK_AnnotIterator annotIterator(this, false); 753 CPDFSDK_AnnotIterator annotIterator(this, false);
719 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 754 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
755 #ifndef PDF_ENABLE_XFA
756 if (pSDKAnnot->GetType() == "Widget") {
757 #else
720 bool bHitTest = pSDKAnnot->GetType() == "Widget"; 758 bool bHitTest = pSDKAnnot->GetType() == "Widget";
721 bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME; 759 bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME;
722 if (bHitTest) { 760 if (bHitTest) {
761 #endif
723 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 762 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
724 CPDF_Point point(pageX, pageY); 763 CPDF_Point point(pageX, pageY);
725 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) 764 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
726 return pSDKAnnot; 765 return pSDKAnnot;
727 } 766 }
728 } 767 }
729 768
730 return nullptr; 769 return nullptr;
731 } 770 }
732 771
(...skipping 20 matching lines...) Expand all
753 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); 792 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr();
754 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); 793 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
755 if (!pSDKAnnot) 794 if (!pSDKAnnot)
756 return nullptr; 795 return nullptr;
757 796
758 m_fxAnnotArray.push_back(pSDKAnnot); 797 m_fxAnnotArray.push_back(pSDKAnnot);
759 pAnnotHandler->Annot_OnCreate(pSDKAnnot); 798 pAnnotHandler->Annot_OnCreate(pSDKAnnot);
760 return pSDKAnnot; 799 return pSDKAnnot;
761 } 800 }
762 801
802 #ifdef PDF_ENABLE_XFA
763 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) { 803 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) {
764 if (!pPDFAnnot) 804 if (!pPDFAnnot)
765 return nullptr; 805 return nullptr;
766 806
767 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); 807 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot);
768 if (pSDKAnnot) 808 if (pSDKAnnot)
769 return pSDKAnnot; 809 return pSDKAnnot;
770 810
771 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 811 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
772 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); 812 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr();
773 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); 813 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
774 if (!pSDKAnnot) 814 if (!pSDKAnnot)
775 return nullptr; 815 return nullptr;
776 816
777 m_fxAnnotArray.push_back(pSDKAnnot); 817 m_fxAnnotArray.push_back(pSDKAnnot);
778 return pSDKAnnot; 818 return pSDKAnnot;
779 } 819 }
780 820
821 #endif
781 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { 822 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) {
782 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; 823 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr;
783 } 824 }
784 825
785 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, 826 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,
786 CPDF_Dictionary* pDict) { 827 CPDF_Dictionary* pDict) {
787 return NULL; 828 return NULL;
788 } 829 }
789 830
790 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { 831 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
832 #ifndef PDF_ENABLE_XFA
833 return FALSE;
834 #else
791 if (!pAnnot) 835 if (!pAnnot)
792 return FALSE; 836 return FALSE;
793 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); 837 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
794 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && 838 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA &&
795 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) 839 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA))
796 return FALSE; 840 return FALSE;
797 841
798 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); 842 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot);
799 if (it != m_fxAnnotArray.end()) 843 if (it != m_fxAnnotArray.end())
800 m_fxAnnotArray.erase(it); 844 m_fxAnnotArray.erase(it);
801 if (m_CaptureWidget == pAnnot) 845 if (m_CaptureWidget == pAnnot)
802 m_CaptureWidget = nullptr; 846 m_CaptureWidget = nullptr;
803 847
804 return TRUE; 848 return TRUE;
849 #endif
805 } 850 }
806 851
807 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { 852 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() {
808 if (m_page) { 853 if (m_page) {
854 #ifndef PDF_ENABLE_XFA
855 return m_page->m_pDocument;
856 #else
809 return m_page->GetDocument()->GetPDFDoc(); 857 return m_page->GetDocument()->GetPDFDoc();
810 } 858 }
811 return NULL; 859 return NULL;
812 } 860 }
813 861
814 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { 862 CPDF_Page* CPDFSDK_PageView::GetPDFPage() {
815 if (m_page) { 863 if (m_page) {
816 return m_page->GetPDFPage(); 864 return m_page->GetPDFPage();
865 #endif
817 } 866 }
818 return NULL; 867 return NULL;
819 } 868 }
820 869
821 size_t CPDFSDK_PageView::CountAnnots() const { 870 size_t CPDFSDK_PageView::CountAnnots() const {
822 return m_fxAnnotArray.size(); 871 return m_fxAnnotArray.size();
823 } 872 }
824 873
825 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { 874 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) {
826 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; 875 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr;
827 } 876 }
828 877
829 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { 878 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) {
830 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 879 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
831 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) 880 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict)
832 return pAnnot; 881 return pAnnot;
833 } 882 }
834 return nullptr; 883 return nullptr;
835 } 884 }
885 #ifdef PDF_ENABLE_XFA
836 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) { 886 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) {
837 if (!hWidget) 887 if (!hWidget)
838 return nullptr; 888 return nullptr;
839 889
840 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 890 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
841 if (pAnnot->GetXFAWidget() == hWidget) 891 if (pAnnot->GetXFAWidget() == hWidget)
842 return pAnnot; 892 return pAnnot;
843 } 893 }
844 return nullptr; 894 return nullptr;
845 } 895 }
896 #endif
846 897
847 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, 898 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point,
848 FX_UINT nFlag) { 899 FX_UINT nFlag) {
849 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 900 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
850 ASSERT(pEnv); 901 ASSERT(pEnv);
851 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); 902 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
852 if (!pFXAnnot) { 903 if (!pFXAnnot) {
853 KillFocusAnnot(nFlag); 904 KillFocusAnnot(nFlag);
854 return FALSE; 905 return FALSE;
855 } 906 }
856 907
857 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 908 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
858 FX_BOOL bRet = 909 FX_BOOL bRet =
859 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); 910 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point);
860 if (bRet) 911 if (bRet)
861 SetFocusAnnot(pFXAnnot); 912 SetFocusAnnot(pFXAnnot);
862 return bRet; 913 return bRet;
863 } 914 }
864 915
916 #ifdef PDF_ENABLE_XFA
865 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CPDF_Point& point, 917 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CPDF_Point& point,
866 FX_UINT nFlag) { 918 FX_UINT nFlag) {
867 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 919 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
868 ASSERT(pEnv); 920 ASSERT(pEnv);
869 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 921 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
870 ASSERT(pAnnotHandlerMgr); 922 ASSERT(pAnnotHandlerMgr);
871 923
872 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); 924 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
873 925
874 if (pFXAnnot == NULL) 926 if (pFXAnnot == NULL)
(...skipping 18 matching lines...) Expand all
893 return FALSE; 945 return FALSE;
894 946
895 FX_BOOL bRet = 947 FX_BOOL bRet =
896 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point); 948 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point);
897 if (bRet) { 949 if (bRet) {
898 SetFocusAnnot(pFXAnnot); 950 SetFocusAnnot(pFXAnnot);
899 } 951 }
900 return TRUE; 952 return TRUE;
901 } 953 }
902 954
955 #endif
903 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { 956 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) {
904 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 957 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
905 ASSERT(pEnv); 958 ASSERT(pEnv);
906 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 959 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
907 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); 960 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
908 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); 961 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot();
909 FX_BOOL bRet = FALSE; 962 FX_BOOL bRet = FALSE;
910 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { 963 if (pFocusAnnot && pFocusAnnot != pFXAnnot) {
911 // Last focus Annot gets a chance to handle the event. 964 // Last focus Annot gets a chance to handle the event.
912 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); 965 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 1031 }
979 return FALSE; 1032 return FALSE;
980 } 1033 }
981 1034
982 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { 1035 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) {
983 return FALSE; 1036 return FALSE;
984 } 1037 }
985 1038
986 void CPDFSDK_PageView::LoadFXAnnots() { 1039 void CPDFSDK_PageView::LoadFXAnnots() {
987 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1040 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
1041 #ifdef PDF_ENABLE_XFA
988 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 1042 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
1043 #endif
989 1044
1045 #ifndef PDF_ENABLE_XFA
1046 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
1047 // Disable the default AP construction.
1048 CPDF_InterForm::EnableUpdateAP(FALSE);
1049 m_pAnnotList.reset(new CPDF_AnnotList(m_page));
1050 CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
1051 const size_t nCount = m_pAnnotList->Count();
1052 #endif
990 SetLock(TRUE); 1053 SetLock(TRUE);
1054 #ifndef PDF_ENABLE_XFA
1055 for (size_t i = 0; i < nCount; ++i) {
1056 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
1057 CPDF_Document* pDoc = GetPDFDocument();
1058 #else
991 m_page->AddRef(); 1059 m_page->AddRef();
992 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { 1060 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
993 IXFA_PageView* pageView = NULL; 1061 IXFA_PageView* pageView = NULL;
994 pageView = m_page->GetXFAPageView(); 1062 pageView = m_page->GetXFAPageView();
995 ASSERT(pageView != NULL); 1063 ASSERT(pageView != NULL);
996 1064
997 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( 1065 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator(
998 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | 1066 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible |
999 XFA_WIDGETFILTER_Viewable | 1067 XFA_WIDGETFILTER_Viewable |
1000 XFA_WIDGETFILTER_AllType); 1068 XFA_WIDGETFILTER_AllType);
1001 if (!pWidgetHander) { 1069 if (!pWidgetHander) {
1002 m_page->Release(); 1070 m_page->Release();
1003 SetLock(FALSE); 1071 SetLock(FALSE);
1004 return; 1072 return;
1005 } 1073 }
1006 1074
1007 while (IXFA_Widget* pXFAAnnot = pWidgetHander->MoveToNext()) { 1075 while (IXFA_Widget* pXFAAnnot = pWidgetHander->MoveToNext()) {
1008 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); 1076 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this);
1009 if (!pAnnot) 1077 if (!pAnnot)
1010 continue; 1078 continue;
1011 1079
1012 m_fxAnnotArray.push_back(pAnnot); 1080 m_fxAnnotArray.push_back(pAnnot);
1013 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); 1081 pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
1014 } 1082 }
1083 #endif
1015 1084
1085 #ifndef PDF_ENABLE_XFA
1086 CheckUnSupportAnnot(pDoc, pPDFAnnot);
1087 #else
1016 pWidgetHander->Release(); 1088 pWidgetHander->Release();
1017 } else { 1089 } else {
1018 CPDF_Page* pPage = m_page->GetPDFPage(); 1090 CPDF_Page* pPage = m_page->GetPDFPage();
1019 ASSERT(pPage != NULL); 1091 ASSERT(pPage != NULL);
1092 #endif
1020 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
1021 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); 1101 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
1022 // Disable the default AP construction. 1102 // Disable the default AP construction.
1023 CPDF_InterForm::EnableUpdateAP(FALSE); 1103 CPDF_InterForm::EnableUpdateAP(FALSE);
1024 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); 1104 m_pAnnotList.reset(new CPDF_AnnotList(pPage));
1025 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); 1105 CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
1026 1106
1027 const size_t nCount = m_pAnnotList->Count(); 1107 const size_t nCount = m_pAnnotList->Count();
1028 for (size_t i = 0; i < nCount; ++i) { 1108 for (size_t i = 0; i < nCount; ++i) {
1029 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); 1109 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
1030 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); 1110 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot);
1031 1111
1032 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); 1112 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
1033 if (!pAnnot) 1113 if (!pAnnot)
1034 continue; 1114 continue;
1035 m_fxAnnotArray.push_back(pAnnot); 1115 m_fxAnnotArray.push_back(pAnnot);
1116 #endif
1036 1117
1118 #ifndef PDF_ENABLE_XFA
1119 pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
1120 #else
1037 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); 1121 pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
1038 } 1122 }
1123 #endif
1039 } 1124 }
1125 #ifdef PDF_ENABLE_XFA
1040 m_page->Release(); 1126 m_page->Release();
1127 #endif
1041 SetLock(FALSE); 1128 SetLock(FALSE);
1042 } 1129 }
1043 1130
1044 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { 1131 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) {
1045 for (int i = 0; i < rects.GetSize(); i++) { 1132 for (int i = 0; i < rects.GetSize(); i++) {
1046 CPDF_Rect rc = rects.GetAt(i); 1133 CPDF_Rect rc = rects.GetAt(i);
1047 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1134 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
1048 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); 1135 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom);
1049 } 1136 }
1050 } 1137 }
1051 1138
1052 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { 1139 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) {
1053 CPDF_Rect rcWindow = pAnnot->GetRect(); 1140 CPDF_Rect rcWindow = pAnnot->GetRect();
1054 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1141 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
1055 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, 1142 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right,
1056 rcWindow.bottom); 1143 rcWindow.bottom);
1057 } 1144 }
1058 1145
1059 int CPDFSDK_PageView::GetPageIndex() { 1146 int CPDFSDK_PageView::GetPageIndex() {
1060 if (m_page) { 1147 if (m_page) {
1148 #ifndef PDF_ENABLE_XFA
1149 CPDF_Dictionary* pDic = m_page->m_pFormDict;
1150 #else
1061 CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict; 1151 CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict;
1152 #endif
1062 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 1153 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
1063 if (pDoc && pDic) { 1154 if (pDoc && pDic) {
1064 return pDoc->GetPageIndex(pDic->GetObjNum()); 1155 return pDoc->GetPageIndex(pDic->GetObjNum());
1065 } 1156 }
1066 } 1157 }
1067 return -1; 1158 return -1;
1068 } 1159 }
1069 1160
1070 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { 1161 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
1071 if (!p) 1162 if (!p)
1072 return false; 1163 return false;
1073 1164
1074 const auto& annots = m_pAnnotList->All(); 1165 const auto& annots = m_pAnnotList->All();
1075 return std::find(annots.begin(), annots.end(), p) != annots.end(); 1166 return std::find(annots.begin(), annots.end(), p) != annots.end();
1076 } 1167 }
1077 1168
1078 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { 1169 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
1079 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); 1170 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
1080 if (!pFocusAnnot) 1171 if (!pFocusAnnot)
1081 return nullptr; 1172 return nullptr;
1082 1173
1083 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 1174 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
1084 if (pAnnot == pFocusAnnot) 1175 if (pAnnot == pFocusAnnot)
1085 return pAnnot; 1176 return pAnnot;
1086 } 1177 }
1087 return nullptr; 1178 return nullptr;
1088 } 1179 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_baseform.cpp ('k') | fpdfsdk/src/javascript/JS_Context.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698