OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "fpdfsdk/cpdfsdk_pageview.h" | 7 #include "fpdfsdk/cpdfsdk_pageview.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "core/fpdfapi/parser/cpdf_document.h" | 12 #include "core/fpdfapi/parser/cpdf_document.h" |
13 #include "core/fpdfapi/render/cpdf_renderoptions.h" | 13 #include "core/fpdfapi/render/cpdf_renderoptions.h" |
14 #include "core/fpdfdoc/cpdf_annotlist.h" | 14 #include "core/fpdfdoc/cpdf_annotlist.h" |
15 #include "core/fpdfdoc/cpdf_interform.h" | 15 #include "core/fpdfdoc/cpdf_interform.h" |
16 #include "fpdfsdk/cpdfsdk_annot.h" | 16 #include "fpdfsdk/cpdfsdk_annot.h" |
17 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" | 17 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" |
18 #include "fpdfsdk/cpdfsdk_annotiterator.h" | 18 #include "fpdfsdk/cpdfsdk_annotiteration.h" |
19 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 19 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
20 #include "fpdfsdk/cpdfsdk_interform.h" | 20 #include "fpdfsdk/cpdfsdk_interform.h" |
21 #include "third_party/base/ptr_util.h" | 21 #include "third_party/base/ptr_util.h" |
22 | 22 |
23 #ifdef PDF_ENABLE_XFA | 23 #ifdef PDF_ENABLE_XFA |
24 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" | 24 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
25 #include "xfa/fxfa/xfa_ffdocview.h" | 25 #include "xfa/fxfa/xfa_ffdocview.h" |
26 #include "xfa/fxfa/xfa_ffpageview.h" | 26 #include "xfa/fxfa/xfa_ffpageview.h" |
27 #include "xfa/fxfa/xfa_ffwidgethandler.h" | 27 #include "xfa/fxfa/xfa_ffwidgethandler.h" |
28 #include "xfa/fxfa/xfa_rendercontext.h" | 28 #include "xfa/fxfa/xfa_rendercontext.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (!annot) | 117 if (!annot) |
118 return; | 118 return; |
119 // Render the focus widget | 119 // Render the focus widget |
120 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, | 120 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, |
121 pUser2Device, false); | 121 pUser2Device, false); |
122 return; | 122 return; |
123 } | 123 } |
124 #endif // PDF_ENABLE_XFA | 124 #endif // PDF_ENABLE_XFA |
125 | 125 |
126 // for pdf/static xfa. | 126 // for pdf/static xfa. |
127 CPDFSDK_AnnotIterator annotIterator(this, true); | 127 CPDFSDK_AnnotIteration annotIteration(this, true); |
128 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 128 for (const auto& pSDKAnnot : annotIteration) { |
129 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 129 m_pFormFillEnv->GetAnnotHandlerMgr()->Annot_OnDraw( |
130 m_pFormFillEnv->GetAnnotHandlerMgr(); | 130 this, pSDKAnnot.Get(), pDevice, pUser2Device, pOptions->m_bDrawAnnots); |
131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, | |
132 pOptions->m_bDrawAnnots); | |
133 } | 131 } |
134 } | 132 } |
135 | 133 |
136 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 134 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
137 FX_FLOAT pageY) { | 135 FX_FLOAT pageY) { |
138 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); | 136 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); |
139 CPDFSDK_AnnotIterator annotIterator(this, false); | 137 CPDFSDK_AnnotIteration annotIteration(this, false); |
140 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 138 for (const auto& pSDKAnnot : annotIteration) { |
141 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 139 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get()); |
142 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) | 140 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) |
143 continue; | 141 continue; |
144 if (rc.Contains(pageX, pageY)) | 142 if (rc.Contains(pageX, pageY)) |
145 return pSDKAnnot; | 143 return pSDKAnnot.Get(); |
146 } | 144 } |
147 | |
148 return nullptr; | 145 return nullptr; |
149 } | 146 } |
150 | 147 |
151 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 148 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
152 FX_FLOAT pageY) { | 149 FX_FLOAT pageY) { |
153 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); | 150 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); |
154 CPDFSDK_AnnotIterator annotIterator(this, false); | 151 CPDFSDK_AnnotIteration annotIteration(this, false); |
155 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 152 for (const auto& pSDKAnnot : annotIteration) { |
156 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; | 153 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; |
157 #ifdef PDF_ENABLE_XFA | 154 #ifdef PDF_ENABLE_XFA |
158 bHitTest = bHitTest || | 155 bHitTest = bHitTest || |
159 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; | 156 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; |
160 #endif // PDF_ENABLE_XFA | 157 #endif // PDF_ENABLE_XFA |
161 if (bHitTest) { | 158 if (bHitTest) { |
162 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 159 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get()); |
163 CFX_FloatPoint point(pageX, pageY); | 160 CFX_FloatPoint point(pageX, pageY); |
164 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 161 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot.Get(), point)) |
165 return pSDKAnnot; | 162 return pSDKAnnot.Get(); |
166 } | 163 } |
167 } | 164 } |
168 | |
169 return nullptr; | 165 return nullptr; |
170 } | 166 } |
171 | 167 |
172 #ifdef PDF_ENABLE_XFA | 168 #ifdef PDF_ENABLE_XFA |
173 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { | 169 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { |
174 if (!pPDFAnnot) | 170 if (!pPDFAnnot) |
175 return nullptr; | 171 return nullptr; |
176 | 172 |
177 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); | 173 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); |
178 if (pSDKAnnot) | 174 if (pSDKAnnot) |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 493 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
498 CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); | 494 CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); |
499 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; | 495 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; |
500 } | 496 } |
501 | 497 |
502 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 498 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
503 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 499 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
504 CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); | 500 CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); |
505 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 501 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
506 } | 502 } |
OLD | NEW |