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/include/cpdfsdk_pageview.h" | 7 #include "fpdfsdk/include/cpdfsdk_pageview.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
10 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" | 10 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" |
11 #include "core/fpdfdoc/include/cpdf_annotlist.h" | 11 #include "core/fpdfdoc/include/cpdf_annotlist.h" |
12 #include "core/fpdfdoc/include/cpdf_interform.h" | 12 #include "core/fpdfdoc/include/cpdf_interform.h" |
13 #include "fpdfsdk/include/cpdfdoc_environment.h" | |
14 #include "fpdfsdk/include/cpdfsdk_annot.h" | 13 #include "fpdfsdk/include/cpdfsdk_annot.h" |
15 #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" | 14 #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" |
16 #include "fpdfsdk/include/cpdfsdk_annotiterator.h" | 15 #include "fpdfsdk/include/cpdfsdk_annotiterator.h" |
| 16 #include "fpdfsdk/include/cpdfsdk_environment.h" |
17 #include "fpdfsdk/include/cpdfsdk_interform.h" | 17 #include "fpdfsdk/include/cpdfsdk_interform.h" |
18 | 18 |
19 #ifdef PDF_ENABLE_XFA | 19 #ifdef PDF_ENABLE_XFA |
20 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" | 20 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
21 #include "xfa/fxfa/include/xfa_ffdocview.h" | 21 #include "xfa/fxfa/include/xfa_ffdocview.h" |
22 #include "xfa/fxfa/include/xfa_ffpageview.h" | 22 #include "xfa/fxfa/include/xfa_ffpageview.h" |
23 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" | 23 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" |
24 #include "xfa/fxfa/include/xfa_rendercontext.h" | 24 #include "xfa/fxfa/include/xfa_rendercontext.h" |
25 #include "xfa/fxgraphics/include/cfx_graphics.h" | 25 #include "xfa/fxgraphics/include/cfx_graphics.h" |
26 #endif // PDF_ENABLE_XFA | 26 #endif // PDF_ENABLE_XFA |
(...skipping 27 matching lines...) Expand all Loading... |
54 } | 54 } |
55 | 55 |
56 CPDFSDK_PageView::~CPDFSDK_PageView() { | 56 CPDFSDK_PageView::~CPDFSDK_PageView() { |
57 #ifndef PDF_ENABLE_XFA | 57 #ifndef PDF_ENABLE_XFA |
58 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to | 58 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to |
59 // be freed, which will cause issues if we try to cleanup the pageview pointer | 59 // be freed, which will cause issues if we try to cleanup the pageview pointer |
60 // in |m_page|. So, reset the pageview pointer before doing anything else. | 60 // in |m_page|. So, reset the pageview pointer before doing anything else. |
61 m_page->SetView(nullptr); | 61 m_page->SetView(nullptr); |
62 #endif // PDF_ENABLE_XFA | 62 #endif // PDF_ENABLE_XFA |
63 | 63 |
64 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 64 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
65 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 65 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
66 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) | 66 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
67 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 67 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
68 | 68 |
69 m_fxAnnotArray.clear(); | 69 m_fxAnnotArray.clear(); |
70 m_pAnnotList.reset(); | 70 m_pAnnotList.reset(); |
71 | 71 |
72 #ifndef PDF_ENABLE_XFA | 72 #ifndef PDF_ENABLE_XFA |
73 if (m_bOwnsPage) | 73 if (m_bOwnsPage) |
74 delete m_page; | 74 delete m_page; |
75 #endif // PDF_ENABLE_XFA | 75 #endif // PDF_ENABLE_XFA |
76 } | 76 } |
77 | 77 |
78 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 78 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
79 CFX_Matrix* pUser2Device, | 79 CFX_Matrix* pUser2Device, |
80 #ifdef PDF_ENABLE_XFA | 80 #ifdef PDF_ENABLE_XFA |
81 CPDF_RenderOptions* pOptions, | 81 CPDF_RenderOptions* pOptions, |
82 const FX_RECT& pClip) { | 82 const FX_RECT& pClip) { |
83 #else | 83 #else |
84 CPDF_RenderOptions* pOptions) { | 84 CPDF_RenderOptions* pOptions) { |
85 #endif // PDF_ENABLE_XFA | 85 #endif // PDF_ENABLE_XFA |
86 m_curMatrix = *pUser2Device; | 86 m_curMatrix = *pUser2Device; |
87 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 87 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
88 | 88 |
89 #ifdef PDF_ENABLE_XFA | 89 #ifdef PDF_ENABLE_XFA |
90 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 90 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
91 if (!pPage) | 91 if (!pPage) |
92 return; | 92 return; |
93 | 93 |
94 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 94 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
95 CFX_Graphics gs; | 95 CFX_Graphics gs; |
96 gs.Create(pDevice); | 96 gs.Create(pDevice); |
97 CFX_RectF rectClip; | 97 CFX_RectF rectClip; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 CFX_FloatRect annotRect = pAnnot->GetRect(); | 146 CFX_FloatRect annotRect = pAnnot->GetRect(); |
147 if (annotRect.Contains(pageX, pageY)) | 147 if (annotRect.Contains(pageX, pageY)) |
148 return pAnnot.get(); | 148 return pAnnot.get(); |
149 } | 149 } |
150 } | 150 } |
151 return nullptr; | 151 return nullptr; |
152 } | 152 } |
153 | 153 |
154 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 154 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
155 FX_FLOAT pageY) { | 155 FX_FLOAT pageY) { |
156 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 156 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
157 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 157 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
158 CPDFSDK_AnnotIterator annotIterator(this, false); | 158 CPDFSDK_AnnotIterator annotIterator(this, false); |
159 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 159 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
160 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 160 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
161 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) | 161 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) |
162 continue; | 162 continue; |
163 if (rc.Contains(pageX, pageY)) | 163 if (rc.Contains(pageX, pageY)) |
164 return pSDKAnnot; | 164 return pSDKAnnot; |
165 } | 165 } |
166 | 166 |
167 return nullptr; | 167 return nullptr; |
168 } | 168 } |
169 | 169 |
170 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 170 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
171 FX_FLOAT pageY) { | 171 FX_FLOAT pageY) { |
172 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 172 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
173 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 173 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
174 CPDFSDK_AnnotIterator annotIterator(this, false); | 174 CPDFSDK_AnnotIterator annotIterator(this, false); |
175 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 175 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
176 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; | 176 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; |
177 #ifdef PDF_ENABLE_XFA | 177 #ifdef PDF_ENABLE_XFA |
178 bHitTest = bHitTest || | 178 bHitTest = bHitTest || |
179 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; | 179 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; |
180 #endif // PDF_ENABLE_XFA | 180 #endif // PDF_ENABLE_XFA |
181 if (bHitTest) { | 181 if (bHitTest) { |
182 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 182 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
183 CFX_FloatPoint point(pageX, pageY); | 183 CFX_FloatPoint point(pageX, pageY); |
184 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 184 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
185 return pSDKAnnot; | 185 return pSDKAnnot; |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 return nullptr; | 189 return nullptr; |
190 } | 190 } |
191 | 191 |
192 void CPDFSDK_PageView::KillFocusAnnotIfNeeded() { | 192 void CPDFSDK_PageView::KillFocusAnnotIfNeeded() { |
193 // if there is a focused annot on the page, we should kill the focus first. | 193 // if there is a focused annot on the page, we should kill the focus first. |
194 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { | 194 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { |
195 if (pdfium::ContainsValue(m_fxAnnotArray, focusedAnnot)) | 195 if (pdfium::ContainsValue(m_fxAnnotArray, focusedAnnot)) |
196 KillFocusAnnot(); | 196 KillFocusAnnot(); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { | 200 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { |
201 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 201 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
202 ASSERT(pEnv); | 202 ASSERT(pEnv); |
203 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 203 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
204 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 204 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
205 if (!pSDKAnnot) | 205 if (!pSDKAnnot) |
206 return nullptr; | 206 return nullptr; |
207 | 207 |
208 m_fxAnnotArray.push_back(pSDKAnnot); | 208 m_fxAnnotArray.push_back(pSDKAnnot); |
209 pAnnotHandler->Annot_OnCreate(pSDKAnnot); | 209 pAnnotHandler->Annot_OnCreate(pSDKAnnot); |
210 return pSDKAnnot; | 210 return pSDKAnnot; |
211 } | 211 } |
212 | 212 |
213 #ifdef PDF_ENABLE_XFA | 213 #ifdef PDF_ENABLE_XFA |
214 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { | 214 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { |
215 if (!pPDFAnnot) | 215 if (!pPDFAnnot) |
216 return nullptr; | 216 return nullptr; |
217 | 217 |
218 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); | 218 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); |
219 if (pSDKAnnot) | 219 if (pSDKAnnot) |
220 return pSDKAnnot; | 220 return pSDKAnnot; |
221 | 221 |
222 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 222 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
223 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 223 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
224 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 224 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
225 if (!pSDKAnnot) | 225 if (!pSDKAnnot) |
226 return nullptr; | 226 return nullptr; |
227 | 227 |
228 m_fxAnnotArray.push_back(pSDKAnnot); | 228 m_fxAnnotArray.push_back(pSDKAnnot); |
229 return pSDKAnnot; | 229 return pSDKAnnot; |
230 } | 230 } |
231 #endif // PDF_ENABLE_XFA | 231 #endif // PDF_ENABLE_XFA |
232 | 232 |
(...skipping 11 matching lines...) Expand all Loading... |
244 #ifdef PDF_ENABLE_XFA | 244 #ifdef PDF_ENABLE_XFA |
245 if (!pAnnot) | 245 if (!pAnnot) |
246 return FALSE; | 246 return FALSE; |
247 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 247 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
248 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && | 248 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && |
249 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) | 249 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) |
250 return FALSE; | 250 return FALSE; |
251 | 251 |
252 if (GetFocusAnnot() == pAnnot) | 252 if (GetFocusAnnot() == pAnnot) |
253 KillFocusAnnot(); | 253 KillFocusAnnot(); |
254 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 254 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
255 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 255 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
256 if (pAnnotHandler) | 256 if (pAnnotHandler) |
257 pAnnotHandler->ReleaseAnnot(pAnnot); | 257 pAnnotHandler->ReleaseAnnot(pAnnot); |
258 | 258 |
259 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); | 259 auto it = std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), pAnnot); |
260 if (it != m_fxAnnotArray.end()) | 260 if (it != m_fxAnnotArray.end()) |
261 m_fxAnnotArray.erase(it); | 261 m_fxAnnotArray.erase(it); |
262 if (m_CaptureWidget == pAnnot) | 262 if (m_CaptureWidget == pAnnot) |
263 m_CaptureWidget = nullptr; | 263 m_CaptureWidget = nullptr; |
264 | 264 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 311 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
312 if (pAnnot->GetXFAWidget() == hWidget) | 312 if (pAnnot->GetXFAWidget() == hWidget) |
313 return pAnnot; | 313 return pAnnot; |
314 } | 314 } |
315 return nullptr; | 315 return nullptr; |
316 } | 316 } |
317 #endif // PDF_ENABLE_XFA | 317 #endif // PDF_ENABLE_XFA |
318 | 318 |
319 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, | 319 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, |
320 FX_UINT nFlag) { | 320 FX_UINT nFlag) { |
321 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 321 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
322 ASSERT(pEnv); | 322 ASSERT(pEnv); |
323 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 323 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
324 if (!pFXAnnot) { | 324 if (!pFXAnnot) { |
325 KillFocusAnnot(nFlag); | 325 KillFocusAnnot(nFlag); |
326 return FALSE; | 326 return FALSE; |
327 } | 327 } |
328 | 328 |
329 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 329 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
330 FX_BOOL bRet = | 330 FX_BOOL bRet = |
331 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); | 331 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); |
332 if (bRet) | 332 if (bRet) |
333 SetFocusAnnot(pFXAnnot); | 333 SetFocusAnnot(pFXAnnot); |
334 return bRet; | 334 return bRet; |
335 } | 335 } |
336 | 336 |
337 #ifdef PDF_ENABLE_XFA | 337 #ifdef PDF_ENABLE_XFA |
338 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, | 338 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, |
339 FX_UINT nFlag) { | 339 FX_UINT nFlag) { |
340 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 340 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
341 ASSERT(pEnv); | 341 ASSERT(pEnv); |
342 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 342 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
343 ASSERT(pAnnotHandlerMgr); | 343 ASSERT(pAnnotHandlerMgr); |
344 | 344 |
345 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 345 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
346 | 346 |
347 if (!pFXAnnot) | 347 if (!pFXAnnot) |
348 return FALSE; | 348 return FALSE; |
349 | 349 |
350 if (pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag, point)) | 350 if (pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag, point)) |
351 SetFocusAnnot(pFXAnnot); | 351 SetFocusAnnot(pFXAnnot); |
352 | 352 |
353 return TRUE; | 353 return TRUE; |
354 } | 354 } |
355 | 355 |
356 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, | 356 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, |
357 FX_UINT nFlag) { | 357 FX_UINT nFlag) { |
358 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 358 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
359 ASSERT(pEnv); | 359 ASSERT(pEnv); |
360 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 360 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
361 | 361 |
362 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 362 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
363 | 363 |
364 if (!pFXAnnot) | 364 if (!pFXAnnot) |
365 return FALSE; | 365 return FALSE; |
366 | 366 |
367 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point)) | 367 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point)) |
368 SetFocusAnnot(pFXAnnot); | 368 SetFocusAnnot(pFXAnnot); |
369 | 369 |
370 return TRUE; | 370 return TRUE; |
371 } | 371 } |
372 #endif // PDF_ENABLE_XFA | 372 #endif // PDF_ENABLE_XFA |
373 | 373 |
374 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, | 374 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, |
375 FX_UINT nFlag) { | 375 FX_UINT nFlag) { |
376 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 376 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
377 ASSERT(pEnv); | 377 ASSERT(pEnv); |
378 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 378 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
379 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 379 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
380 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); | 380 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); |
381 FX_BOOL bRet = FALSE; | 381 FX_BOOL bRet = FALSE; |
382 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 382 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
383 // Last focus Annot gets a chance to handle the event. | 383 // Last focus Annot gets a chance to handle the event. |
384 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); | 384 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); |
385 } | 385 } |
386 if (pFXAnnot && !bRet) | 386 if (pFXAnnot && !bRet) |
387 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag, point); | 387 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag, point); |
388 return bRet; | 388 return bRet; |
389 } | 389 } |
390 | 390 |
391 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { | 391 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { |
392 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 392 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
393 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 393 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
394 if (CPDFSDK_Annot* pFXAnnot = GetFXAnnotAtPoint(point.x, point.y)) { | 394 if (CPDFSDK_Annot* pFXAnnot = GetFXAnnotAtPoint(point.x, point.y)) { |
395 if (m_CaptureWidget && m_CaptureWidget != pFXAnnot) { | 395 if (m_CaptureWidget && m_CaptureWidget != pFXAnnot) { |
396 m_bExitWidget = TRUE; | 396 m_bExitWidget = TRUE; |
397 m_bEnterWidget = FALSE; | 397 m_bEnterWidget = FALSE; |
398 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); | 398 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); |
399 } | 399 } |
400 m_CaptureWidget = pFXAnnot; | 400 m_CaptureWidget = pFXAnnot; |
401 m_bOnWidget = TRUE; | 401 m_bOnWidget = TRUE; |
402 if (!m_bEnterWidget) { | 402 if (!m_bEnterWidget) { |
(...skipping 14 matching lines...) Expand all Loading... |
417 } | 417 } |
418 } | 418 } |
419 return FALSE; | 419 return FALSE; |
420 } | 420 } |
421 | 421 |
422 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, | 422 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, |
423 double deltaY, | 423 double deltaY, |
424 const CFX_FloatPoint& point, | 424 const CFX_FloatPoint& point, |
425 int nFlag) { | 425 int nFlag) { |
426 if (CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) { | 426 if (CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) { |
427 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 427 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
428 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 428 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
429 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, | 429 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, |
430 (int)deltaY, point); | 430 (int)deltaY, point); |
431 } | 431 } |
432 return FALSE; | 432 return FALSE; |
433 } | 433 } |
434 | 434 |
435 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) { | 435 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) { |
436 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 436 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
437 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 437 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
438 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 438 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
439 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 439 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
440 } | 440 } |
441 | 441 |
442 return FALSE; | 442 return FALSE; |
443 } | 443 } |
444 | 444 |
445 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { | 445 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { |
446 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 446 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
447 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 447 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
448 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 448 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
449 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 449 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
450 } | 450 } |
451 return FALSE; | 451 return FALSE; |
452 } | 452 } |
453 | 453 |
454 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 454 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
455 return FALSE; | 455 return FALSE; |
456 } | 456 } |
457 | 457 |
458 void CPDFSDK_PageView::LoadFXAnnots() { | 458 void CPDFSDK_PageView::LoadFXAnnots() { |
459 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 459 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
460 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 460 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
461 | 461 |
462 SetLock(TRUE); | 462 SetLock(TRUE); |
463 | 463 |
464 #ifdef PDF_ENABLE_XFA | 464 #ifdef PDF_ENABLE_XFA |
465 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); | 465 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
466 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 466 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
467 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); | 467 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
468 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( | 468 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
469 pageView->CreateWidgetIterator( | 469 pageView->CreateWidgetIterator( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 m_pSDKDoc->SetFocusAnnot(nullptr); | 515 m_pSDKDoc->SetFocusAnnot(nullptr); |
516 m_CaptureWidget = nullptr; | 516 m_CaptureWidget = nullptr; |
517 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) | 517 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
518 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr()->ReleaseAnnot(pAnnot); | 518 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr()->ReleaseAnnot(pAnnot); |
519 m_fxAnnotArray.clear(); | 519 m_fxAnnotArray.clear(); |
520 m_pAnnotList.reset(); | 520 m_pAnnotList.reset(); |
521 SetLock(FALSE); | 521 SetLock(FALSE); |
522 } | 522 } |
523 | 523 |
524 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { | 524 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { |
525 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 525 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
526 for (const auto& rc : rects) | 526 for (const auto& rc : rects) |
527 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 527 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
528 } | 528 } |
529 | 529 |
530 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { | 530 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
531 CFX_FloatRect rcWindow = pAnnot->GetRect(); | 531 CFX_FloatRect rcWindow = pAnnot->GetRect(); |
532 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 532 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
533 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, | 533 pEnv->FFI_Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, |
534 rcWindow.bottom); | 534 rcWindow.bottom); |
535 } | 535 } |
536 | 536 |
537 int CPDFSDK_PageView::GetPageIndex() const { | 537 int CPDFSDK_PageView::GetPageIndex() const { |
538 if (!m_page) | 538 if (!m_page) |
539 return -1; | 539 return -1; |
540 | 540 |
541 #ifdef PDF_ENABLE_XFA | 541 #ifdef PDF_ENABLE_XFA |
542 int nDocType = m_page->GetDocument()->GetDocType(); | 542 int nDocType = m_page->GetDocument()->GetDocType(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 return pAnnot; | 578 return pAnnot; |
579 } | 579 } |
580 return nullptr; | 580 return nullptr; |
581 } | 581 } |
582 | 582 |
583 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 583 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
584 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 584 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
585 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 585 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
586 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 586 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
587 } | 587 } |
OLD | NEW |