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 "fpdfsdk/include/formfiller/FFL_IFormFiller.h" | 7 #include "fpdfsdk/include/formfiller/FFL_IFormFiller.h" |
8 | 8 |
9 #include "fpdfsdk/include/formfiller/FFL_CheckBox.h" | 9 #include "fpdfsdk/include/formfiller/FFL_CheckBox.h" |
10 #include "fpdfsdk/include/formfiller/FFL_ComboBox.h" | 10 #include "fpdfsdk/include/formfiller/FFL_ComboBox.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 : m_pApp(pApp), m_bNotifying(FALSE) {} | 22 : m_pApp(pApp), m_bNotifying(FALSE) {} |
23 | 23 |
24 CFFL_IFormFiller::~CFFL_IFormFiller() { | 24 CFFL_IFormFiller::~CFFL_IFormFiller() { |
25 for (auto& it : m_Maps) | 25 for (auto& it : m_Maps) |
26 delete it.second; | 26 delete it.second; |
27 m_Maps.clear(); | 27 m_Maps.clear(); |
28 } | 28 } |
29 | 29 |
30 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, | 30 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, |
31 CPDFSDK_Annot* pAnnot, | 31 CPDFSDK_Annot* pAnnot, |
32 CPDF_Point point) { | 32 CFX_FloatPoint point) { |
33 CPDF_Rect rc = pAnnot->GetRect(); | 33 CFX_FloatRect rc = pAnnot->GetRect(); |
34 if (rc.Contains(point.x, point.y)) | 34 if (rc.Contains(point.x, point.y)) |
35 return TRUE; | 35 return TRUE; |
36 return FALSE; | 36 return FALSE; |
37 } | 37 } |
38 | 38 |
39 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, | 39 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, |
40 CPDFSDK_Annot* pAnnot) { | 40 CPDFSDK_Annot* pAnnot) { |
41 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 41 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) |
42 return pFormFiller->GetViewBBox(pPageView, pAnnot); | 42 return pFormFiller->GetViewBBox(pPageView, pAnnot); |
43 | 43 |
44 ASSERT(pPageView); | 44 ASSERT(pPageView); |
45 | 45 |
46 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 46 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
47 CPDF_Rect rcAnnot; | 47 CFX_FloatRect rcAnnot; |
48 pPDFAnnot->GetRect(rcAnnot); | 48 pPDFAnnot->GetRect(rcAnnot); |
49 | 49 |
50 CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); | 50 CFX_FloatRect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); |
51 return rcWin.GetOutterRect(); | 51 return rcWin.GetOutterRect(); |
52 } | 52 } |
53 | 53 |
54 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, | 54 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, |
55 CPDFSDK_Annot* pAnnot, | 55 CPDFSDK_Annot* pAnnot, |
56 CFX_RenderDevice* pDevice, | 56 CFX_RenderDevice* pDevice, |
57 CFX_Matrix* pUser2Device, | 57 CFX_Matrix* pUser2Device, |
58 FX_DWORD dwFlags) { | 58 FX_DWORD dwFlags) { |
59 ASSERT(pPageView); | 59 ASSERT(pPageView); |
60 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 60 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
61 | 61 |
62 if (IsVisible(pWidget)) { | 62 if (IsVisible(pWidget)) { |
63 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 63 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
64 if (pFormFiller->IsValid()) { | 64 if (pFormFiller->IsValid()) { |
65 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 65 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
66 pAnnot->GetPDFPage(); | 66 pAnnot->GetPDFPage(); |
67 | 67 |
68 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); | 68 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); |
69 if (pDocument->GetFocusAnnot() == pAnnot) { | 69 if (pDocument->GetFocusAnnot() == pAnnot) { |
70 CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView); | 70 CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView); |
71 if (!rcFocus.IsEmpty()) { | 71 if (!rcFocus.IsEmpty()) { |
72 CFX_PathData path; | 72 CFX_PathData path; |
73 path.SetPointCount(5); | 73 path.SetPointCount(5); |
74 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO); | 74 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO); |
75 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO); | 75 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO); |
76 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO); | 76 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO); |
77 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO); | 77 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO); |
78 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO); | 78 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO); |
79 | 79 |
80 CFX_GraphStateData gsd; | 80 CFX_GraphStateData gsd; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 191 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
192 pFormFiller->OnMouseExit(pPageView, pAnnot); | 192 pFormFiller->OnMouseExit(pPageView, pAnnot); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, | 196 FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, |
197 CPDFSDK_Annot* pAnnot, | 197 CPDFSDK_Annot* pAnnot, |
198 FX_UINT nFlags, | 198 FX_UINT nFlags, |
199 const CPDF_Point& point) { | 199 const CFX_FloatPoint& point) { |
200 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 200 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
201 | 201 |
202 if (!m_bNotifying) { | 202 if (!m_bNotifying) { |
203 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 203 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
204 if (Annot_HitTest(pPageView, pAnnot, point) && | 204 if (Annot_HitTest(pPageView, pAnnot, point) && |
205 pWidget->GetAAction(CPDF_AAction::ButtonDown)) { | 205 pWidget->GetAAction(CPDF_AAction::ButtonDown)) { |
206 m_bNotifying = TRUE; | 206 m_bNotifying = TRUE; |
207 pWidget->GetAppearanceAge(); | 207 pWidget->GetAppearanceAge(); |
208 int nValueAge = pWidget->GetValueAge(); | 208 int nValueAge = pWidget->GetValueAge(); |
209 pWidget->ClearAppModified(); | 209 pWidget->ClearAppModified(); |
(...skipping 21 matching lines...) Expand all Loading... |
231 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 231 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
232 return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); | 232 return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
233 } | 233 } |
234 | 234 |
235 return FALSE; | 235 return FALSE; |
236 } | 236 } |
237 | 237 |
238 FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, | 238 FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, |
239 CPDFSDK_Annot* pAnnot, | 239 CPDFSDK_Annot* pAnnot, |
240 FX_UINT nFlags, | 240 FX_UINT nFlags, |
241 const CPDF_Point& point) { | 241 const CFX_FloatPoint& point) { |
242 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 242 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
243 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 243 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
244 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); | 244 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); |
245 | 245 |
246 switch (pWidget->GetFieldType()) { | 246 switch (pWidget->GetFieldType()) { |
247 case FIELDTYPE_PUSHBUTTON: | 247 case FIELDTYPE_PUSHBUTTON: |
248 case FIELDTYPE_CHECKBOX: | 248 case FIELDTYPE_CHECKBOX: |
249 case FIELDTYPE_RADIOBUTTON: | 249 case FIELDTYPE_RADIOBUTTON: |
250 if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y)) | 250 if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y)) |
251 pDocument->SetFocusAnnot(pAnnot); | 251 pDocument->SetFocusAnnot(pAnnot); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 bReset = TRUE; | 312 bReset = TRUE; |
313 } | 313 } |
314 } | 314 } |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 318 FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
319 CPDFSDK_Annot* pAnnot, | 319 CPDFSDK_Annot* pAnnot, |
320 FX_UINT nFlags, | 320 FX_UINT nFlags, |
321 const CPDF_Point& point) { | 321 const CFX_FloatPoint& point) { |
322 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 322 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
323 | 323 |
324 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 324 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
325 return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); | 325 return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
326 } | 326 } |
327 | 327 |
328 return FALSE; | 328 return FALSE; |
329 } | 329 } |
330 | 330 |
331 FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, | 331 FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, |
332 CPDFSDK_Annot* pAnnot, | 332 CPDFSDK_Annot* pAnnot, |
333 FX_UINT nFlags, | 333 FX_UINT nFlags, |
334 const CPDF_Point& point) { | 334 const CFX_FloatPoint& point) { |
335 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 335 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
336 | 336 |
337 // change cursor | 337 // change cursor |
338 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { | 338 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) { |
339 return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); | 339 return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); |
340 } | 340 } |
341 | 341 |
342 return FALSE; | 342 return FALSE; |
343 } | 343 } |
344 | 344 |
345 FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, | 345 FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, |
346 CPDFSDK_Annot* pAnnot, | 346 CPDFSDK_Annot* pAnnot, |
347 FX_UINT nFlags, | 347 FX_UINT nFlags, |
348 short zDelta, | 348 short zDelta, |
349 const CPDF_Point& point) { | 349 const CFX_FloatPoint& point) { |
350 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 350 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
351 | 351 |
352 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 352 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
353 return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point); | 353 return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point); |
354 } | 354 } |
355 | 355 |
356 return FALSE; | 356 return FALSE; |
357 } | 357 } |
358 | 358 |
359 FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, | 359 FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, |
360 CPDFSDK_Annot* pAnnot, | 360 CPDFSDK_Annot* pAnnot, |
361 FX_UINT nFlags, | 361 FX_UINT nFlags, |
362 const CPDF_Point& point) { | 362 const CFX_FloatPoint& point) { |
363 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 363 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
364 | 364 |
365 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 365 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
366 return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); | 366 return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
367 } | 367 } |
368 | 368 |
369 return FALSE; | 369 return FALSE; |
370 } | 370 } |
371 | 371 |
372 FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, | 372 FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, |
373 CPDFSDK_Annot* pAnnot, | 373 CPDFSDK_Annot* pAnnot, |
374 FX_UINT nFlags, | 374 FX_UINT nFlags, |
375 const CPDF_Point& point) { | 375 const CFX_FloatPoint& point) { |
376 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 376 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
377 | 377 |
378 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 378 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
379 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); | 379 return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
380 } | 380 } |
381 | 381 |
382 return FALSE; | 382 return FALSE; |
383 } | 383 } |
384 | 384 |
385 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 385 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 m_Maps.erase(it); | 563 m_Maps.erase(it); |
564 } | 564 } |
565 | 565 |
566 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, | 566 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, |
567 FX_FLOAT fPopupMin, | 567 FX_FLOAT fPopupMin, |
568 FX_FLOAT fPopupMax, | 568 FX_FLOAT fPopupMax, |
569 int32_t& nRet, | 569 int32_t& nRet, |
570 FX_FLOAT& fPopupRet) { | 570 FX_FLOAT& fPopupRet) { |
571 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 571 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
572 | 572 |
573 CPDF_Rect rcPageView(0, 0, 0, 0); | 573 CFX_FloatRect rcPageView(0, 0, 0, 0); |
574 rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth(); | 574 rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth(); |
575 rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight(); | 575 rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight(); |
576 rcPageView.Normalize(); | 576 rcPageView.Normalize(); |
577 | 577 |
578 CPDF_Rect rcAnnot = pData->pWidget->GetRect(); | 578 CFX_FloatRect rcAnnot = pData->pWidget->GetRect(); |
579 | 579 |
580 FX_FLOAT fTop = 0.0f; | 580 FX_FLOAT fTop = 0.0f; |
581 FX_FLOAT fBottom = 0.0f; | 581 FX_FLOAT fBottom = 0.0f; |
582 | 582 |
583 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pData->pWidget; | 583 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pData->pWidget; |
584 switch (pWidget->GetRotate() / 90) { | 584 switch (pWidget->GetRotate() / 90) { |
585 default: | 585 default: |
586 case 0: | 586 case 0: |
587 fTop = rcPageView.top - rcAnnot.top; | 587 fTop = rcPageView.top - rcAnnot.top; |
588 fBottom = rcAnnot.bottom - rcPageView.bottom; | 588 fBottom = rcAnnot.bottom - rcPageView.bottom; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 bExit = TRUE; | 1005 bExit = TRUE; |
1006 m_bNotifying = FALSE; | 1006 m_bNotifying = FALSE; |
1007 return; | 1007 return; |
1008 } | 1008 } |
1009 } | 1009 } |
1010 | 1010 |
1011 m_bNotifying = FALSE; | 1011 m_bNotifying = FALSE; |
1012 } | 1012 } |
1013 } | 1013 } |
1014 } | 1014 } |
OLD | NEW |