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

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

Issue 1421583005: Revert "Fix incorrect CPDFSDK_PageView::CountAnnots()." (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 1 month 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/include/fsdk_mgr.h ('k') | no next file » | 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 "../../public/fpdf_ext.h" 9 #include "../../public/fpdf_ext.h"
10 #include "../../third_party/base/nonstd_unique_ptr.h" 10 #include "../../third_party/base/nonstd_unique_ptr.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 657 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
658 CPDFSDK_AnnotIterator annotIterator(this, true); 658 CPDFSDK_AnnotIterator annotIterator(this, true);
659 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 659 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
660 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 660 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
661 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); 661 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
662 } 662 }
663 } 663 }
664 664
665 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, 665 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
666 FX_FLOAT pageY) { 666 FX_FLOAT pageY) {
667 for (size_t i = 0; i < CountAnnots(); ++i) { 667 int nCount = CountAnnots();
668 for (int i = 0; i < nCount; i++) {
668 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); 669 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
669 CFX_FloatRect annotRect; 670 CFX_FloatRect annotRect;
670 pAnnot->GetRect(annotRect); 671 pAnnot->GetRect(annotRect);
671 if (annotRect.Contains(pageX, pageY)) 672 if (annotRect.Contains(pageX, pageY))
672 return pAnnot; 673 return pAnnot;
673 } 674 }
674 return nullptr; 675 return nullptr;
675 } 676 }
676 677
677 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, 678 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
678 FX_FLOAT pageY) { 679 FX_FLOAT pageY) {
679 for (size_t i = 0; i < CountAnnots(); ++i) { 680 int nCount = CountAnnots();
681 for (int i = 0; i < nCount; ++i) {
680 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); 682 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
681 if (pAnnot->GetSubType() == "Widget") { 683 if (pAnnot->GetSubType() == "Widget") {
682 CFX_FloatRect annotRect; 684 CFX_FloatRect annotRect;
683 pAnnot->GetRect(annotRect); 685 pAnnot->GetRect(annotRect);
684 if (annotRect.Contains(pageX, pageY)) 686 if (annotRect.Contains(pageX, pageY))
685 return pAnnot; 687 return pAnnot;
686 } 688 }
687 } 689 }
688 return nullptr; 690 return nullptr;
689 } 691 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 return FALSE; 757 return FALSE;
756 } 758 }
757 759
758 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { 760 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() {
759 if (m_page) { 761 if (m_page) {
760 return m_page->m_pDocument; 762 return m_page->m_pDocument;
761 } 763 }
762 return NULL; 764 return NULL;
763 } 765 }
764 766
765 size_t CPDFSDK_PageView::CountAnnots() const { 767 int CPDFSDK_PageView::CountAnnots() const {
766 return m_fxAnnotArray.size(); 768 return m_pAnnotList->Count();
767 } 769 }
768 770
769 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { 771 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) {
770 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; 772 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr;
771 } 773 }
772 774
773 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { 775 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) {
774 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 776 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
775 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) 777 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict)
776 return pAnnot; 778 return pAnnot;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 892 }
891 893
892 void CPDFSDK_PageView::LoadFXAnnots() { 894 void CPDFSDK_PageView::LoadFXAnnots() {
893 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 895 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
894 896
895 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); 897 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
896 // Disable the default AP construction. 898 // Disable the default AP construction.
897 CPDF_InterForm::EnableUpdateAP(FALSE); 899 CPDF_InterForm::EnableUpdateAP(FALSE);
898 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); 900 m_pAnnotList.reset(new CPDF_AnnotList(m_page));
899 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); 901 CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
902 int nCount = CountAnnots();
900 SetLock(TRUE); 903 SetLock(TRUE);
901 for (size_t i = 0; i < CountAnnots(); ++i) { 904 for (int i = 0; i < nCount; ++i) {
902 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); 905 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
903 CPDF_Document* pDoc = GetPDFDocument(); 906 CPDF_Document* pDoc = GetPDFDocument();
904 907
905 CheckUnSupportAnnot(pDoc, pPDFAnnot); 908 CheckUnSupportAnnot(pDoc, pPDFAnnot);
906 909
907 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); 910 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
908 ASSERT(pAnnotHandlerMgr != NULL); 911 ASSERT(pAnnotHandlerMgr != NULL);
909 912
910 if (pAnnotHandlerMgr) { 913 if (pAnnotHandlerMgr) {
911 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); 914 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
(...skipping 30 matching lines...) Expand all
942 return pDoc->GetPageIndex(pDic->GetObjNum()); 945 return pDoc->GetPageIndex(pDic->GetObjNum());
943 } 946 }
944 } 947 }
945 return -1; 948 return -1;
946 } 949 }
947 950
948 FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { 951 FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const {
949 if (!p) 952 if (!p)
950 return FALSE; 953 return FALSE;
951 954
952 for (size_t i = 0; i < CountAnnots(); ++i) { 955 int nCount = CountAnnots();
956 for (int i = 0; i < nCount; ++i) {
953 if (m_pAnnotList->GetAt(i) == p) 957 if (m_pAnnotList->GetAt(i) == p)
954 return TRUE; 958 return TRUE;
955 } 959 }
956 return FALSE; 960 return FALSE;
957 } 961 }
958 962
959 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { 963 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
960 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); 964 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
961 if (!pFocusAnnot) 965 if (!pFocusAnnot)
962 return nullptr; 966 return nullptr;
963 967
964 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 968 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
965 if (pAnnot == pFocusAnnot) 969 if (pAnnot == pFocusAnnot)
966 return pAnnot; 970 return pAnnot;
967 } 971 }
968 return nullptr; 972 return nullptr;
969 } 973 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_mgr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698