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/formfiller/cffl_iformfiller.h" | 7 #include "fpdfsdk/formfiller/cffl_iformfiller.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
11 #include "core/fxge/include/fx_ge.h" | 11 #include "core/fxge/include/fx_ge.h" |
12 #include "fpdfsdk/formfiller/cffl_checkbox.h" | 12 #include "fpdfsdk/formfiller/cffl_checkbox.h" |
13 #include "fpdfsdk/formfiller/cffl_combobox.h" | 13 #include "fpdfsdk/formfiller/cffl_combobox.h" |
14 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 14 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
15 #include "fpdfsdk/formfiller/cffl_listbox.h" | 15 #include "fpdfsdk/formfiller/cffl_listbox.h" |
16 #include "fpdfsdk/formfiller/cffl_pushbutton.h" | 16 #include "fpdfsdk/formfiller/cffl_pushbutton.h" |
17 #include "fpdfsdk/formfiller/cffl_radiobutton.h" | 17 #include "fpdfsdk/formfiller/cffl_radiobutton.h" |
18 #include "fpdfsdk/formfiller/cffl_textfield.h" | 18 #include "fpdfsdk/formfiller/cffl_textfield.h" |
19 #include "fpdfsdk/include/fsdk_mgr.h" | 19 #include "fpdfsdk/include/fsdk_mgr.h" |
20 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 20 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
21 | 21 |
22 #define FFL_MAXLISTBOXHEIGHT 140.0f | 22 #define FFL_MAXLISTBOXHEIGHT 140.0f |
23 | 23 |
24 CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) | 24 CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) |
25 : m_pApp(pApp), m_bNotifying(FALSE) {} | 25 : m_pApp(pApp), m_bNotifying(FALSE) {} |
26 | 26 |
27 CFFL_IFormFiller::~CFFL_IFormFiller() { | 27 CFFL_IFormFiller::~CFFL_IFormFiller() {} |
28 for (auto& it : m_Maps) | |
29 delete it.second; | |
30 m_Maps.clear(); | |
31 } | |
32 | 28 |
33 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, | 29 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, |
34 CPDFSDK_Annot* pAnnot, | 30 CPDFSDK_Annot* pAnnot, |
35 CFX_FloatPoint point) { | 31 CFX_FloatPoint point) { |
36 CFX_FloatRect rc = pAnnot->GetRect(); | 32 CFX_FloatRect rc = pAnnot->GetRect(); |
37 return rc.Contains(point.x, point.y); | 33 return rc.Contains(point.x, point.y); |
38 } | 34 } |
39 | 35 |
40 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, | 36 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, |
41 CPDFSDK_Annot* pAnnot) { | 37 CPDFSDK_Annot* pAnnot) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 uint32_t dwPermissions = pDocument->GetUserPermissions(); | 500 uint32_t dwPermissions = pDocument->GetUserPermissions(); |
505 return (dwPermissions & FPDFPERM_FILL_FORM) || | 501 return (dwPermissions & FPDFPERM_FILL_FORM) || |
506 (dwPermissions & FPDFPERM_ANNOT_FORM) || | 502 (dwPermissions & FPDFPERM_ANNOT_FORM) || |
507 (dwPermissions & FPDFPERM_MODIFY); | 503 (dwPermissions & FPDFPERM_MODIFY); |
508 } | 504 } |
509 | 505 |
510 CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, | 506 CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, |
511 FX_BOOL bRegister) { | 507 FX_BOOL bRegister) { |
512 auto it = m_Maps.find(pAnnot); | 508 auto it = m_Maps.find(pAnnot); |
513 if (it != m_Maps.end()) | 509 if (it != m_Maps.end()) |
514 return it->second; | 510 return it->second.get(); |
515 | 511 |
516 if (!bRegister) | 512 if (!bRegister) |
517 return nullptr; | 513 return nullptr; |
518 | 514 |
519 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 515 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
520 int nFieldType = pWidget->GetFieldType(); | 516 int nFieldType = pWidget->GetFieldType(); |
521 CFFL_FormFiller* pFormFiller; | 517 CFFL_FormFiller* pFormFiller; |
522 switch (nFieldType) { | 518 switch (nFieldType) { |
523 case FIELDTYPE_PUSHBUTTON: | 519 case FIELDTYPE_PUSHBUTTON: |
524 pFormFiller = new CFFL_PushButton(m_pApp, pWidget); | 520 pFormFiller = new CFFL_PushButton(m_pApp, pWidget); |
(...skipping 15 matching lines...) Expand all Loading... |
540 break; | 536 break; |
541 case FIELDTYPE_UNKNOWN: | 537 case FIELDTYPE_UNKNOWN: |
542 default: | 538 default: |
543 pFormFiller = nullptr; | 539 pFormFiller = nullptr; |
544 break; | 540 break; |
545 } | 541 } |
546 | 542 |
547 if (!pFormFiller) | 543 if (!pFormFiller) |
548 return nullptr; | 544 return nullptr; |
549 | 545 |
550 m_Maps[pAnnot] = pFormFiller; | 546 m_Maps[pAnnot].reset(pFormFiller); |
551 return pFormFiller; | 547 return pFormFiller; |
552 } | 548 } |
553 | 549 |
554 void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot) { | 550 void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot) { |
555 if (pAnnot) { | 551 if (pAnnot) { |
556 UnRegisterFormFiller(pAnnot); | 552 UnRegisterFormFiller(pAnnot); |
557 } | 553 } |
558 } | 554 } |
559 | 555 |
560 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { | 556 void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { |
561 auto it = m_Maps.find(pAnnot); | 557 auto it = m_Maps.find(pAnnot); |
562 if (it == m_Maps.end()) | 558 if (it == m_Maps.end()) |
563 return; | 559 return; |
564 | 560 |
565 delete it->second; | |
566 m_Maps.erase(it); | 561 m_Maps.erase(it); |
567 } | 562 } |
568 | 563 |
569 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, | 564 void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, |
570 FX_FLOAT fPopupMin, | 565 FX_FLOAT fPopupMin, |
571 FX_FLOAT fPopupMax, | 566 FX_FLOAT fPopupMax, |
572 int32_t& nRet, | 567 int32_t& nRet, |
573 FX_FLOAT& fPopupRet) { | 568 FX_FLOAT& fPopupRet) { |
574 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 569 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
575 | 570 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 bExit = TRUE; | 998 bExit = TRUE; |
1004 m_bNotifying = FALSE; | 999 m_bNotifying = FALSE; |
1005 return; | 1000 return; |
1006 } | 1001 } |
1007 } | 1002 } |
1008 | 1003 |
1009 m_bNotifying = FALSE; | 1004 m_bNotifying = FALSE; |
1010 } | 1005 } |
1011 } | 1006 } |
1012 } | 1007 } |
OLD | NEW |