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