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 "../../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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // for pdf/static xfa. | 718 // for pdf/static xfa. |
719 CPDFSDK_AnnotIterator annotIterator(this, true); | 719 CPDFSDK_AnnotIterator annotIterator(this, true); |
720 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 720 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
721 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 721 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
722 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 722 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
723 } | 723 } |
724 } | 724 } |
725 | 725 |
726 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 726 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
727 FX_FLOAT pageY) { | 727 FX_FLOAT pageY) { |
728 int nCount = CountAnnots(); | 728 const int nCount = m_pAnnotList->Count(); |
729 for (int i = 0; i < nCount; i++) { | 729 for (int i = 0; i < nCount; ++i) { |
730 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 730 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
731 CFX_FloatRect annotRect; | 731 CFX_FloatRect annotRect; |
732 pAnnot->GetRect(annotRect); | 732 pAnnot->GetRect(annotRect); |
733 if (annotRect.Contains(pageX, pageY)) | 733 if (annotRect.Contains(pageX, pageY)) |
734 return pAnnot; | 734 return pAnnot; |
735 } | 735 } |
736 return nullptr; | 736 return nullptr; |
737 } | 737 } |
738 | 738 |
739 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, | 739 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
740 FX_FLOAT pageY) { | 740 FX_FLOAT pageY) { |
741 int nCount = CountAnnots(); | 741 const int nCount = m_pAnnotList->Count(); |
742 for (int i = 0; i < nCount; ++i) { | 742 for (int i = 0; i < nCount; ++i) { |
743 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 743 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
744 if (pAnnot->GetSubType() == "Widget") { | 744 if (pAnnot->GetSubType() == "Widget") { |
745 CFX_FloatRect annotRect; | 745 CFX_FloatRect annotRect; |
746 pAnnot->GetRect(annotRect); | 746 pAnnot->GetRect(annotRect); |
747 if (annotRect.Contains(pageX, pageY)) | 747 if (annotRect.Contains(pageX, pageY)) |
748 return pAnnot; | 748 return pAnnot; |
749 } | 749 } |
750 } | 750 } |
751 return nullptr; | 751 return nullptr; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 } | 870 } |
871 | 871 |
872 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { | 872 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { |
873 if (m_page) { | 873 if (m_page) { |
874 return m_page->GetPDFPage(); | 874 return m_page->GetPDFPage(); |
875 } | 875 } |
876 | 876 |
877 return NULL; | 877 return NULL; |
878 } | 878 } |
879 | 879 |
880 int CPDFSDK_PageView::CountAnnots() const { | 880 size_t CPDFSDK_PageView::CountAnnots() const { |
881 return m_pAnnotList->Count(); | 881 return m_fxAnnotArray.size(); |
882 } | 882 } |
883 | 883 |
884 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { | 884 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
885 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; | 885 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; |
886 } | 886 } |
887 | 887 |
888 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { | 888 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
889 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 889 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
890 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) | 890 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) |
891 return pAnnot; | 891 return pAnnot; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 } else { | 1087 } else { |
1088 CPDF_Page* pPage = m_page->GetPDFPage(); | 1088 CPDF_Page* pPage = m_page->GetPDFPage(); |
1089 ASSERT(pPage != NULL); | 1089 ASSERT(pPage != NULL); |
1090 | 1090 |
1091 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 1091 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
1092 // Disable the default AP construction. | 1092 // Disable the default AP construction. |
1093 CPDF_InterForm::EnableUpdateAP(FALSE); | 1093 CPDF_InterForm::EnableUpdateAP(FALSE); |
1094 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); | 1094 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); |
1095 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 1095 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
1096 | 1096 |
1097 int nCount = m_pAnnotList->Count(); | 1097 const int nCount = m_pAnnotList->Count(); |
1098 for (int i = 0; i < nCount; i++) { | 1098 for (int i = 0; i < nCount; i++) { |
1099 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 1099 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
1100 CPDF_Document* pDoc = GetPDFDocument(); | 1100 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); |
1101 | |
1102 CheckUnSupportAnnot(pDoc, pPDFAnnot); | |
1103 | 1101 |
1104 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 1102 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
1105 if (!pAnnot) | 1103 if (!pAnnot) |
1106 continue; | 1104 continue; |
1107 m_fxAnnotArray.push_back(pAnnot); | 1105 m_fxAnnotArray.push_back(pAnnot); |
1108 | 1106 |
1109 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1107 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
1110 } | 1108 } |
1111 } | 1109 } |
1112 m_page->Release(); | 1110 m_page->Release(); |
(...skipping 23 matching lines...) Expand all Loading... |
1136 return pDoc->GetPDFDoc()->GetPageIndex(pDic->GetObjNum()); | 1134 return pDoc->GetPDFDoc()->GetPageIndex(pDic->GetObjNum()); |
1137 } | 1135 } |
1138 } | 1136 } |
1139 return -1; | 1137 return -1; |
1140 } | 1138 } |
1141 | 1139 |
1142 FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { | 1140 FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { |
1143 if (!p) | 1141 if (!p) |
1144 return FALSE; | 1142 return FALSE; |
1145 | 1143 |
1146 int nCount = CountAnnots(); | 1144 const int nCount = m_pAnnotList->Count(); |
1147 for (int i = 0; i < nCount; ++i) { | 1145 for (int i = 0; i < nCount; ++i) { |
1148 if (m_pAnnotList->GetAt(i) == p) | 1146 if (m_pAnnotList->GetAt(i) == p) |
1149 return TRUE; | 1147 return TRUE; |
1150 } | 1148 } |
1151 return FALSE; | 1149 return FALSE; |
1152 } | 1150 } |
1153 | 1151 |
1154 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 1152 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
1155 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1153 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
1156 if (!pFocusAnnot) | 1154 if (!pFocusAnnot) |
1157 return nullptr; | 1155 return nullptr; |
1158 | 1156 |
1159 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1157 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
1160 if (pAnnot == pFocusAnnot) | 1158 if (pAnnot == pFocusAnnot) |
1161 return pAnnot; | 1159 return pAnnot; |
1162 } | 1160 } |
1163 return nullptr; | 1161 return nullptr; |
1164 } | 1162 } |
OLD | NEW |