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 "../../public/fpdf_ext.h" | 7 #include "../../public/fpdf_ext.h" |
8 #include "../../third_party/base/nonstd_unique_ptr.h" | 8 #include "../../third_party/base/nonstd_unique_ptr.h" |
9 #include "../include/formfiller/FFL_FormFiller.h" | 9 #include "../include/formfiller/FFL_FormFiller.h" |
10 #include "../include/fsdk_define.h" | 10 #include "../include/fsdk_define.h" |
11 #include "../include/fsdk_mgr.h" | 11 #include "../include/fsdk_mgr.h" |
12 #include "../include/javascript/IJavaScript.h" | 12 #include "../include/javascript/IJavaScript.h" |
13 | 13 |
14 #if _FX_OS_ == _FX_ANDROID_ | 14 #if _FX_OS_ == _FX_ANDROID_ |
15 #include "time.h" | 15 #include "time.h" |
16 #else | 16 #else |
17 #include <ctime> | 17 #include <ctime> |
18 #endif | 18 #endif |
19 | 19 |
20 class CFX_SystemHandler : public IFX_SystemHandler { | 20 class CFX_SystemHandler : public IFX_SystemHandler { |
21 public: | 21 public: |
22 CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} | 22 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) |
23 : m_pEnv(pEnv), m_nCharSet(-1) {} | |
23 ~CFX_SystemHandler() override {} | 24 ~CFX_SystemHandler() override {} |
24 | 25 |
25 public: | 26 public: |
26 // IFX_SystemHandler | 27 // IFX_SystemHandler |
27 void InvalidateRect(FX_HWND hWnd, FX_RECT rect) override; | 28 void InvalidateRect(FX_HWND hWnd, FX_RECT rect) override; |
28 void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) override; | 29 void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) override; |
29 FX_BOOL IsSelectionImplemented() override; | 30 FX_BOOL IsSelectionImplemented() override; |
30 CFX_WideString GetClipboardText(FX_HWND hWnd) override { return L""; } | 31 CFX_WideString GetClipboardText(FX_HWND hWnd) override { return L""; } |
31 FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) override { | 32 FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) override { |
32 return FALSE; | 33 return FALSE; |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 return m_pEnv->JS_docGetFilePath(); | 604 return m_pEnv->JS_docGetFilePath(); |
604 } | 605 } |
605 | 606 |
606 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDF_Page* page) | 607 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDF_Page* page) |
607 : m_page(page), m_pSDKDoc(pSDKDoc) { | 608 : m_page(page), m_pSDKDoc(pSDKDoc) { |
608 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 609 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
609 if (pInterForm) { | 610 if (pInterForm) { |
610 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 611 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
611 pPDFInterForm->FixPageFields(page); | 612 pPDFInterForm->FixPageFields(page); |
612 } | 613 } |
613 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); | 614 m_page->SetPrivateData((void*)m_page, (void*)this, nullptr); |
614 m_fxAnnotArray.RemoveAll(); | |
615 | 615 |
616 m_bEnterWidget = FALSE; | 616 m_bEnterWidget = FALSE; |
Tom Sepez
2015/10/21 19:32:59
Can we make these part of the initialization list,
Lei Zhang
2015/10/22 06:56:22
Done.
| |
617 m_bExitWidget = FALSE; | 617 m_bExitWidget = FALSE; |
618 m_bOnWidget = FALSE; | 618 m_bOnWidget = FALSE; |
619 m_CaptureWidget = NULL; | 619 m_CaptureWidget = nullptr; |
620 m_bValid = FALSE; | 620 m_bValid = FALSE; |
621 m_bLocked = FALSE; | 621 m_bLocked = FALSE; |
622 m_bTakeOverPage = FALSE; | 622 m_bTakeOverPage = FALSE; |
623 } | 623 } |
624 | 624 |
625 CPDFSDK_PageView::~CPDFSDK_PageView() { | 625 CPDFSDK_PageView::~CPDFSDK_PageView() { |
626 // if there is a focused annot on the page, we should kill the focus first. | 626 // if there is a focused annot on the page, we should kill the focus first. |
627 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { | 627 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { |
628 for (int i = 0, count = m_fxAnnotArray.GetSize(); i < count; i++) { | 628 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
Tom Sepez
2015/10/21 19:32:59
find() of some sort?
Lei Zhang
2015/10/22 06:56:22
Done.
| |
629 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
630 if (pAnnot == focusedAnnot) { | 629 if (pAnnot == focusedAnnot) { |
631 KillFocusAnnot(); | 630 KillFocusAnnot(); |
632 break; | 631 break; |
633 } | 632 } |
634 } | 633 } |
635 } | 634 } |
636 | 635 |
637 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 636 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
638 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 637 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
639 ASSERT(pAnnotHandlerMgr); | 638 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
640 for (int i = 0, count = m_fxAnnotArray.GetSize(); i < count; i++) { | |
641 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
642 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 639 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
643 } | 640 m_fxAnnotArray.clear(); |
644 m_fxAnnotArray.RemoveAll(); | |
645 | 641 |
646 delete m_pAnnotList; | 642 m_pAnnotList.reset(); |
647 m_pAnnotList = NULL; | |
648 | 643 |
649 m_page->RemovePrivateData((void*)m_page); | 644 m_page->RemovePrivateData((void*)m_page); |
650 if (m_bTakeOverPage) { | 645 if (m_bTakeOverPage) { |
651 delete m_page; | 646 delete m_page; |
652 } | 647 } |
653 } | 648 } |
654 | 649 |
655 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 650 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
656 CPDF_Matrix* pUser2Device, | 651 CPDF_Matrix* pUser2Device, |
657 CPDF_RenderOptions* pOptions) { | 652 CPDF_RenderOptions* pOptions) { |
658 m_curMatrix = *pUser2Device; | 653 m_curMatrix = *pUser2Device; |
659 | 654 |
660 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 655 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
661 CPDFSDK_AnnotIterator annotIterator(this, TRUE); | 656 CPDFSDK_AnnotIterator annotIterator(this, true); |
662 int index = -1; | 657 size_t index = 0; |
663 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) { | 658 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(&index)) { |
664 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 659 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
665 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 660 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
666 } | 661 } |
667 } | 662 } |
668 | 663 |
669 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 664 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
670 FX_FLOAT pageY) { | 665 FX_FLOAT pageY) { |
671 int nCount = m_pAnnotList->Count(); | 666 int nCount = CountAnnots(); |
672 for (int i = 0; i < nCount; i++) { | 667 for (int i = 0; i < nCount; i++) { |
673 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 668 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
674 CFX_FloatRect annotRect; | 669 CFX_FloatRect annotRect; |
675 pAnnot->GetRect(annotRect); | 670 pAnnot->GetRect(annotRect); |
676 if (annotRect.Contains(pageX, pageY)) | 671 if (annotRect.Contains(pageX, pageY)) |
677 return pAnnot; | 672 return pAnnot; |
678 } | 673 } |
679 return NULL; | 674 return nullptr; |
680 } | 675 } |
681 | 676 |
682 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, | 677 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
683 FX_FLOAT pageY) { | 678 FX_FLOAT pageY) { |
684 int nCount = m_pAnnotList->Count(); | 679 int nCount = CountAnnots(); |
685 for (int i = 0; i < nCount; i++) { | 680 for (int i = 0; i < nCount; ++i) { |
686 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 681 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
687 if (pAnnot->GetSubType() == "Widget") { | 682 if (pAnnot->GetSubType() == "Widget") { |
688 CFX_FloatRect annotRect; | 683 CFX_FloatRect annotRect; |
689 pAnnot->GetRect(annotRect); | 684 pAnnot->GetRect(annotRect); |
690 if (annotRect.Contains(pageX, pageY)) | 685 if (annotRect.Contains(pageX, pageY)) |
691 return pAnnot; | 686 return pAnnot; |
692 } | 687 } |
693 } | 688 } |
694 return NULL; | 689 return nullptr; |
695 } | 690 } |
696 | 691 |
697 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 692 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
698 FX_FLOAT pageY) { | 693 FX_FLOAT pageY) { |
699 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 694 CPDFSDK_AnnotIterator annotIterator(this, false); |
700 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 695 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
701 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 696 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
702 CPDFSDK_Annot* pSDKAnnot = NULL; | 697 CPDFSDK_Annot* pSDKAnnot = NULL; |
703 int index = -1; | 698 size_t index = 0; |
704 while ((pSDKAnnot = annotIterator.Next(index))) { | 699 while ((pSDKAnnot = annotIterator.Next(&index))) { |
705 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 700 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
706 if (rc.Contains(pageX, pageY)) | 701 if (rc.Contains(pageX, pageY)) |
707 return pSDKAnnot; | 702 return pSDKAnnot; |
708 } | 703 } |
709 | 704 |
710 return NULL; | 705 return NULL; |
711 } | 706 } |
712 | 707 |
713 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 708 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
714 FX_FLOAT pageY) { | 709 FX_FLOAT pageY) { |
715 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 710 CPDFSDK_AnnotIterator annotIterator(this, false); |
716 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 711 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
717 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 712 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
718 CPDFSDK_Annot* pSDKAnnot = NULL; | 713 CPDFSDK_Annot* pSDKAnnot = NULL; |
719 int index = -1; | 714 size_t index = 0; |
720 while ((pSDKAnnot = annotIterator.Next(index))) { | 715 while ((pSDKAnnot = annotIterator.Next(&index))) { |
721 if (pSDKAnnot->GetType() == "Widget") { | 716 if (pSDKAnnot->GetType() == "Widget") { |
722 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 717 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
723 CPDF_Point point(pageX, pageY); | 718 CPDF_Point point(pageX, pageY); |
724 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 719 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
725 return pSDKAnnot; | 720 return pSDKAnnot; |
726 } | 721 } |
727 } | 722 } |
728 | 723 |
729 return NULL; | 724 return NULL; |
730 } | 725 } |
731 | 726 |
732 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { | 727 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { |
733 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); | 728 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); |
734 if (pAnnotDic) | 729 if (pAnnotDic) |
735 return pAnnotDic->KeyExist("AS"); | 730 return pAnnotDic->KeyExist("AS"); |
736 return FALSE; | 731 return FALSE; |
737 } | 732 } |
738 | 733 |
739 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { | 734 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { |
740 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 735 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
741 ASSERT(pEnv); | 736 ASSERT(pEnv); |
742 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 737 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
738 if (!pAnnotHandler) | |
739 return nullptr; | |
743 | 740 |
744 CPDFSDK_Annot* pSDKAnnot = NULL; | 741 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
742 if (!pSDKAnnot) | |
743 return nullptr; | |
745 | 744 |
746 if (pAnnotHandler) { | 745 m_fxAnnotArray.push_back(pSDKAnnot); |
747 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 746 pAnnotHandler->Annot_OnCreate(pSDKAnnot); |
748 } | |
749 if (!pSDKAnnot) | |
750 return NULL; | |
751 | |
752 m_fxAnnotArray.Add(pSDKAnnot); | |
753 | |
754 if (pAnnotHandler) { | |
755 pAnnotHandler->Annot_OnCreate(pSDKAnnot); | |
756 } | |
757 | |
758 return pSDKAnnot; | 747 return pSDKAnnot; |
759 } | 748 } |
760 | 749 |
761 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { | 750 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { |
762 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; | 751 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; |
763 } | 752 } |
764 | 753 |
765 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, | 754 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, |
766 CPDF_Dictionary* pDict) { | 755 CPDF_Dictionary* pDict) { |
767 return NULL; | 756 return NULL; |
768 } | 757 } |
769 | 758 |
770 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 759 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
771 return FALSE; | 760 return FALSE; |
772 } | 761 } |
773 | 762 |
774 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { | 763 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
775 if (m_page) { | 764 if (m_page) { |
776 return m_page->m_pDocument; | 765 return m_page->m_pDocument; |
777 } | 766 } |
778 return NULL; | 767 return NULL; |
779 } | 768 } |
780 | 769 |
781 int CPDFSDK_PageView::CountAnnots() { | 770 int CPDFSDK_PageView::CountAnnots() const { |
782 return m_pAnnotList->Count(); | 771 return m_pAnnotList->Count(); |
783 } | 772 } |
784 | 773 |
785 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(int nIndex) { | 774 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
786 int nCount = m_fxAnnotArray.GetSize(); | 775 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; |
787 if (nIndex < 0 || nIndex >= nCount) { | |
788 return NULL; | |
789 } | |
790 | |
791 return (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(nIndex); | |
792 } | 776 } |
793 | 777 |
794 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { | 778 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
795 int nCount = m_fxAnnotArray.GetSize(); | 779 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
796 for (int i = 0; i < nCount; i++) { | 780 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) |
797 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
798 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) | |
799 return pAnnot; | 781 return pAnnot; |
800 } | 782 } |
801 return NULL; | 783 return nullptr; |
802 } | 784 } |
803 | 785 |
804 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, | 786 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, |
805 FX_UINT nFlag) { | 787 FX_UINT nFlag) { |
806 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 788 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
807 ASSERT(pEnv); | 789 ASSERT(pEnv); |
808 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 790 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
809 if (!pFXAnnot) { | 791 if (!pFXAnnot) { |
810 KillFocusAnnot(nFlag); | 792 KillFocusAnnot(nFlag); |
811 } else { | 793 } else { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
911 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 893 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
912 return FALSE; | 894 return FALSE; |
913 } | 895 } |
914 | 896 |
915 void CPDFSDK_PageView::LoadFXAnnots() { | 897 void CPDFSDK_PageView::LoadFXAnnots() { |
916 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 898 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
917 | 899 |
918 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 900 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
919 // Disable the default AP construction. | 901 // Disable the default AP construction. |
920 CPDF_InterForm::EnableUpdateAP(FALSE); | 902 CPDF_InterForm::EnableUpdateAP(FALSE); |
921 m_pAnnotList = new CPDF_AnnotList(m_page); | 903 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); |
922 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 904 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
923 int nCount = m_pAnnotList->Count(); | 905 int nCount = CountAnnots(); |
924 SetLock(TRUE); | 906 SetLock(TRUE); |
925 for (int i = 0; i < nCount; i++) { | 907 for (int i = 0; i < nCount; ++i) { |
926 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 908 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
927 CPDF_Document* pDoc = GetPDFDocument(); | 909 CPDF_Document* pDoc = GetPDFDocument(); |
928 | 910 |
929 CheckUnSupportAnnot(pDoc, pPDFAnnot); | 911 CheckUnSupportAnnot(pDoc, pPDFAnnot); |
930 | 912 |
931 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 913 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
932 ASSERT(pAnnotHandlerMgr != NULL); | 914 ASSERT(pAnnotHandlerMgr != NULL); |
933 | 915 |
934 if (pAnnotHandlerMgr) { | 916 if (pAnnotHandlerMgr) { |
935 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 917 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
936 if (!pAnnot) | 918 if (!pAnnot) |
937 continue; | 919 continue; |
938 m_fxAnnotArray.Add(pAnnot); | 920 m_fxAnnotArray.push_back(pAnnot); |
939 | 921 |
940 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 922 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
941 } | 923 } |
942 } | 924 } |
943 SetLock(FALSE); | 925 SetLock(FALSE); |
944 } | 926 } |
945 | 927 |
946 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { | 928 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { |
947 for (int i = 0; i < rects.GetSize(); i++) { | 929 for (int i = 0; i < rects.GetSize(); i++) { |
948 CPDF_Rect rc = rects.GetAt(i); | 930 CPDF_Rect rc = rects.GetAt(i); |
(...skipping 13 matching lines...) Expand all Loading... | |
962 if (m_page) { | 944 if (m_page) { |
963 CPDF_Dictionary* pDic = m_page->m_pFormDict; | 945 CPDF_Dictionary* pDic = m_page->m_pFormDict; |
964 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); | 946 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); |
965 if (pDoc && pDic) { | 947 if (pDoc && pDic) { |
966 return pDoc->GetPageIndex(pDic->GetObjNum()); | 948 return pDoc->GetPageIndex(pDic->GetObjNum()); |
967 } | 949 } |
968 } | 950 } |
969 return -1; | 951 return -1; |
970 } | 952 } |
971 | 953 |
972 FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) { | 954 FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) const { |
Tom Sepez
2015/10/21 19:32:59
Why does this take a void?
Lei Zhang
2015/10/22 06:56:22
Dunno, fixed.
| |
973 if (p == NULL) | 955 if (!p) |
974 return FALSE; | 956 return FALSE; |
975 int iCount = m_pAnnotList->Count(); | 957 |
976 for (int i = 0; i < iCount; i++) { | 958 int nCount = CountAnnots(); |
959 for (int i = 0; i < nCount; ++i) { | |
977 if (m_pAnnotList->GetAt(i) == p) | 960 if (m_pAnnotList->GetAt(i) == p) |
978 return TRUE; | 961 return TRUE; |
979 } | 962 } |
980 return FALSE; | 963 return FALSE; |
981 } | 964 } |
982 | 965 |
983 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 966 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
984 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 967 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
985 if (!pFocusAnnot) | 968 if (!pFocusAnnot) |
986 return NULL; | 969 return nullptr; |
987 | 970 |
988 for (int i = 0; i < m_fxAnnotArray.GetSize(); i++) { | 971 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
989 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
990 if (pAnnot == pFocusAnnot) | 972 if (pAnnot == pFocusAnnot) |
991 return pAnnot; | 973 return pAnnot; |
992 } | 974 } |
993 return NULL; | 975 return nullptr; |
994 } | 976 } |
OLD | NEW |