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_annotiterator.h" |
19 #include "fpdfsdk/cpdfsdk_environment.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" |
29 #include "xfa/fxgraphics/cfx_graphics.h" | 29 #include "xfa/fxgraphics/cfx_graphics.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
58 } | 58 } |
59 | 59 |
60 CPDFSDK_PageView::~CPDFSDK_PageView() { | 60 CPDFSDK_PageView::~CPDFSDK_PageView() { |
61 #ifndef PDF_ENABLE_XFA | 61 #ifndef PDF_ENABLE_XFA |
62 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to | 62 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to |
63 // be freed, which will cause issues if we try to cleanup the pageview pointer | 63 // be freed, which will cause issues if we try to cleanup the pageview pointer |
64 // in |m_page|. So, reset the pageview pointer before doing anything else. | 64 // in |m_page|. So, reset the pageview pointer before doing anything else. |
65 m_page->SetView(nullptr); | 65 m_page->SetView(nullptr); |
66 #endif // PDF_ENABLE_XFA | 66 #endif // PDF_ENABLE_XFA |
67 | 67 |
68 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 68 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
Tom Sepez
2016/10/05 20:44:31
nit: can we call this method m_pSDKDoc->GetFormFil
dsinclair
2016/10/05 20:47:12
My plan is htat m_pSDKDoc will not exist in the fu
| |
69 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 69 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
70 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) | 70 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) |
71 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 71 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
72 | 72 |
73 m_SDKAnnotArray.clear(); | 73 m_SDKAnnotArray.clear(); |
74 m_pAnnotList.reset(); | 74 m_pAnnotList.reset(); |
75 | 75 |
76 #ifndef PDF_ENABLE_XFA | 76 #ifndef PDF_ENABLE_XFA |
77 if (m_bOwnsPage) | 77 if (m_bOwnsPage) |
78 delete m_page; | 78 delete m_page; |
79 #endif // PDF_ENABLE_XFA | 79 #endif // PDF_ENABLE_XFA |
80 } | 80 } |
81 | 81 |
82 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 82 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
83 CFX_Matrix* pUser2Device, | 83 CFX_Matrix* pUser2Device, |
84 #ifdef PDF_ENABLE_XFA | 84 #ifdef PDF_ENABLE_XFA |
85 CPDF_RenderOptions* pOptions, | 85 CPDF_RenderOptions* pOptions, |
86 const FX_RECT& pClip) { | 86 const FX_RECT& pClip) { |
87 #else | 87 #else |
88 CPDF_RenderOptions* pOptions) { | 88 CPDF_RenderOptions* pOptions) { |
89 #endif // PDF_ENABLE_XFA | 89 #endif // PDF_ENABLE_XFA |
90 m_curMatrix = *pUser2Device; | 90 m_curMatrix = *pUser2Device; |
91 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 91 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
92 | 92 |
93 #ifdef PDF_ENABLE_XFA | 93 #ifdef PDF_ENABLE_XFA |
94 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 94 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
95 if (!pPage) | 95 if (!pPage) |
96 return; | 96 return; |
97 | 97 |
98 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 98 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
99 CFX_Graphics gs; | 99 CFX_Graphics gs; |
100 gs.Create(pDevice); | 100 gs.Create(pDevice); |
101 CFX_RectF rectClip; | 101 CFX_RectF rectClip; |
(...skipping 26 matching lines...) Expand all Loading... | |
128 CPDFSDK_AnnotIterator annotIterator(this, true); | 128 CPDFSDK_AnnotIterator annotIterator(this, true); |
129 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 129 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
130 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 130 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, | 131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, |
132 pOptions->m_bDrawAnnots); | 132 pOptions->m_bDrawAnnots); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 136 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
137 FX_FLOAT pageY) { | 137 FX_FLOAT pageY) { |
138 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 138 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
139 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 139 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
140 CPDFSDK_AnnotIterator annotIterator(this, false); | 140 CPDFSDK_AnnotIterator annotIterator(this, false); |
141 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 141 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
142 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 142 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
143 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) | 143 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) |
144 continue; | 144 continue; |
145 if (rc.Contains(pageX, pageY)) | 145 if (rc.Contains(pageX, pageY)) |
146 return pSDKAnnot; | 146 return pSDKAnnot; |
147 } | 147 } |
148 | 148 |
149 return nullptr; | 149 return nullptr; |
150 } | 150 } |
151 | 151 |
152 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 152 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
153 FX_FLOAT pageY) { | 153 FX_FLOAT pageY) { |
154 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 154 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
155 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 155 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
156 CPDFSDK_AnnotIterator annotIterator(this, false); | 156 CPDFSDK_AnnotIterator annotIterator(this, false); |
157 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 157 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
158 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; | 158 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; |
159 #ifdef PDF_ENABLE_XFA | 159 #ifdef PDF_ENABLE_XFA |
160 bHitTest = bHitTest || | 160 bHitTest = bHitTest || |
161 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; | 161 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; |
162 #endif // PDF_ENABLE_XFA | 162 #endif // PDF_ENABLE_XFA |
163 if (bHitTest) { | 163 if (bHitTest) { |
164 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 164 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
165 CFX_FloatPoint point(pageX, pageY); | 165 CFX_FloatPoint point(pageX, pageY); |
166 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 166 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
167 return pSDKAnnot; | 167 return pSDKAnnot; |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 return nullptr; | 171 return nullptr; |
172 } | 172 } |
173 | 173 |
174 #ifdef PDF_ENABLE_XFA | 174 #ifdef PDF_ENABLE_XFA |
175 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { | 175 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { |
176 if (!pPDFAnnot) | 176 if (!pPDFAnnot) |
177 return nullptr; | 177 return nullptr; |
178 | 178 |
179 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); | 179 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); |
180 if (pSDKAnnot) | 180 if (pSDKAnnot) |
181 return pSDKAnnot; | 181 return pSDKAnnot; |
182 | 182 |
183 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 183 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
184 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 184 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
185 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 185 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
186 if (!pSDKAnnot) | 186 if (!pSDKAnnot) |
187 return nullptr; | 187 return nullptr; |
188 | 188 |
189 m_SDKAnnotArray.push_back(pSDKAnnot); | 189 m_SDKAnnotArray.push_back(pSDKAnnot); |
190 return pSDKAnnot; | 190 return pSDKAnnot; |
191 } | 191 } |
192 | 192 |
193 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 193 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
194 if (!pAnnot) | 194 if (!pAnnot) |
195 return FALSE; | 195 return FALSE; |
196 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 196 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
197 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && | 197 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && |
198 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) | 198 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) |
199 return FALSE; | 199 return FALSE; |
200 | 200 |
201 if (GetFocusAnnot() == pAnnot) | 201 if (GetFocusAnnot() == pAnnot) |
202 m_pSDKDoc->KillFocusAnnot(0); | 202 m_pSDKDoc->KillFocusAnnot(0); |
203 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 203 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
204 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 204 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
205 if (pAnnotHandler) | 205 if (pAnnotHandler) |
206 pAnnotHandler->ReleaseAnnot(pAnnot); | 206 pAnnotHandler->ReleaseAnnot(pAnnot); |
207 | 207 |
208 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); | 208 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); |
209 if (it != m_SDKAnnotArray.end()) | 209 if (it != m_SDKAnnotArray.end()) |
210 m_SDKAnnotArray.erase(it); | 210 m_SDKAnnotArray.erase(it); |
211 if (m_pCaptureWidget.Get() == pAnnot) | 211 if (m_pCaptureWidget.Get() == pAnnot) |
212 m_pCaptureWidget.Reset(); | 212 m_pCaptureWidget.Reset(); |
213 | 213 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 #endif // PDF_ENABLE_XFA | 256 #endif // PDF_ENABLE_XFA |
257 | 257 |
258 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, | 258 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, |
259 uint32_t nFlag) { | 259 uint32_t nFlag) { |
260 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 260 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
261 if (!pAnnot) { | 261 if (!pAnnot) { |
262 m_pSDKDoc->KillFocusAnnot(nFlag); | 262 m_pSDKDoc->KillFocusAnnot(nFlag); |
263 return FALSE; | 263 return FALSE; |
264 } | 264 } |
265 | 265 |
266 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 266 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
267 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 267 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
268 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) | 268 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) |
269 return FALSE; | 269 return FALSE; |
270 | 270 |
271 if (!pAnnot) | 271 if (!pAnnot) |
272 return FALSE; | 272 return FALSE; |
273 | 273 |
274 m_pSDKDoc->SetFocusAnnot(&pAnnot); | 274 m_pSDKDoc->SetFocusAnnot(&pAnnot); |
275 return TRUE; | 275 return TRUE; |
276 } | 276 } |
277 | 277 |
278 #ifdef PDF_ENABLE_XFA | 278 #ifdef PDF_ENABLE_XFA |
279 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, | 279 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, |
280 uint32_t nFlag) { | 280 uint32_t nFlag) { |
281 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 281 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
282 if (!pAnnot) | 282 if (!pAnnot) |
283 return FALSE; | 283 return FALSE; |
284 | 284 |
285 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 285 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
286 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 286 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
287 FX_BOOL ok = | 287 FX_BOOL ok = |
288 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); | 288 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); |
289 if (!pAnnot) | 289 if (!pAnnot) |
290 return FALSE; | 290 return FALSE; |
291 | 291 |
292 if (ok) | 292 if (ok) |
293 m_pSDKDoc->SetFocusAnnot(&pAnnot); | 293 m_pSDKDoc->SetFocusAnnot(&pAnnot); |
294 | 294 |
295 return TRUE; | 295 return TRUE; |
296 } | 296 } |
297 | 297 |
298 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, | 298 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, |
299 uint32_t nFlag) { | 299 uint32_t nFlag) { |
300 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 300 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
301 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 301 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
302 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 302 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
303 if (!pFXAnnot) | 303 if (!pFXAnnot) |
304 return FALSE; | 304 return FALSE; |
305 | 305 |
306 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) | 306 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) |
307 m_pSDKDoc->SetFocusAnnot(&pFXAnnot); | 307 m_pSDKDoc->SetFocusAnnot(&pFXAnnot); |
308 | 308 |
309 return TRUE; | 309 return TRUE; |
310 } | 310 } |
311 #endif // PDF_ENABLE_XFA | 311 #endif // PDF_ENABLE_XFA |
312 | 312 |
313 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, | 313 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, |
314 uint32_t nFlag) { | 314 uint32_t nFlag) { |
315 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 315 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
316 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 316 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
317 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 317 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
318 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); | 318 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); |
319 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 319 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
320 // Last focus Annot gets a chance to handle the event. | 320 // Last focus Annot gets a chance to handle the event. |
321 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) | 321 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) |
322 return TRUE; | 322 return TRUE; |
323 } | 323 } |
324 return pFXAnnot && | 324 return pFXAnnot && |
325 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); | 325 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); |
326 } | 326 } |
327 | 327 |
328 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { | 328 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { |
329 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 329 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
330 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 330 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
331 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); | 331 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); |
332 if (pFXAnnot) { | 332 if (pFXAnnot) { |
333 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { | 333 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { |
334 m_bExitWidget = TRUE; | 334 m_bExitWidget = TRUE; |
335 m_bEnterWidget = FALSE; | 335 m_bEnterWidget = FALSE; |
336 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); | 336 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); |
337 } | 337 } |
338 m_pCaptureWidget.Reset(pFXAnnot.Get()); | 338 m_pCaptureWidget.Reset(pFXAnnot.Get()); |
339 m_bOnWidget = TRUE; | 339 m_bOnWidget = TRUE; |
(...skipping 18 matching lines...) Expand all Loading... | |
358 } | 358 } |
359 | 359 |
360 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, | 360 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, |
361 double deltaY, | 361 double deltaY, |
362 const CFX_FloatPoint& point, | 362 const CFX_FloatPoint& point, |
363 int nFlag) { | 363 int nFlag) { |
364 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 364 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
365 if (!pAnnot) | 365 if (!pAnnot) |
366 return FALSE; | 366 return FALSE; |
367 | 367 |
368 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 368 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
369 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 369 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
370 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, | 370 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, |
371 point); | 371 point); |
372 } | 372 } |
373 | 373 |
374 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { | 374 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { |
375 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 375 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
376 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 376 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
377 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 377 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
378 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 378 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
379 } | 379 } |
380 | 380 |
381 return FALSE; | 381 return FALSE; |
382 } | 382 } |
383 | 383 |
384 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { | 384 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { |
385 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 385 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
386 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 386 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
387 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 387 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
388 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 388 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
389 } | 389 } |
390 return FALSE; | 390 return FALSE; |
391 } | 391 } |
392 | 392 |
393 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 393 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
394 return FALSE; | 394 return FALSE; |
395 } | 395 } |
396 | 396 |
397 void CPDFSDK_PageView::LoadFXAnnots() { | 397 void CPDFSDK_PageView::LoadFXAnnots() { |
398 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 398 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
399 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 399 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
400 | 400 |
401 SetLock(TRUE); | 401 SetLock(TRUE); |
402 | 402 |
403 #ifdef PDF_ENABLE_XFA | 403 #ifdef PDF_ENABLE_XFA |
404 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); | 404 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
405 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 405 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
406 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); | 406 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
407 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( | 407 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
408 pageView->CreateWidgetIterator( | 408 pageView->CreateWidgetIterator( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 if (!pAnnot) | 442 if (!pAnnot) |
443 continue; | 443 continue; |
444 m_SDKAnnotArray.push_back(pAnnot); | 444 m_SDKAnnotArray.push_back(pAnnot); |
445 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 445 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
446 } | 446 } |
447 | 447 |
448 SetLock(FALSE); | 448 SetLock(FALSE); |
449 } | 449 } |
450 | 450 |
451 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { | 451 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { |
452 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 452 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
453 for (const auto& rc : rects) | 453 for (const auto& rc : rects) |
454 pEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 454 pEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
455 } | 455 } |
456 | 456 |
457 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { | 457 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
458 CFX_FloatRect rcWindow = pAnnot->GetRect(); | 458 CFX_FloatRect rcWindow = pAnnot->GetRect(); |
459 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 459 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); |
460 pEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, | 460 pEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, |
461 rcWindow.bottom); | 461 rcWindow.bottom); |
462 } | 462 } |
463 | 463 |
464 int CPDFSDK_PageView::GetPageIndex() const { | 464 int CPDFSDK_PageView::GetPageIndex() const { |
465 if (!m_page) | 465 if (!m_page) |
466 return -1; | 466 return -1; |
467 | 467 |
468 #ifdef PDF_ENABLE_XFA | 468 #ifdef PDF_ENABLE_XFA |
469 int nDocType = m_page->GetDocument()->GetDocType(); | 469 int nDocType = m_page->GetDocument()->GetDocType(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 504 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
505 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 505 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
506 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; | 506 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; |
507 } | 507 } |
508 | 508 |
509 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 509 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
510 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 510 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
511 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 511 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
512 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 512 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
513 } | 513 } |
OLD | NEW |