Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: fpdfsdk/formfiller/cffl_iformfiller.cpp

Issue 2009253003: Clean up fx_ge.h and IWYU. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/cfx_systemhandler.cpp ('k') | fpdfsdk/fpdf_progressive.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "fpdfsdk/formfiller/cffl_checkbox.h" 12 #include "fpdfsdk/formfiller/cffl_checkbox.h"
12 #include "fpdfsdk/formfiller/cffl_combobox.h" 13 #include "fpdfsdk/formfiller/cffl_combobox.h"
13 #include "fpdfsdk/formfiller/cffl_formfiller.h" 14 #include "fpdfsdk/formfiller/cffl_formfiller.h"
14 #include "fpdfsdk/formfiller/cffl_listbox.h" 15 #include "fpdfsdk/formfiller/cffl_listbox.h"
15 #include "fpdfsdk/formfiller/cffl_pushbutton.h" 16 #include "fpdfsdk/formfiller/cffl_pushbutton.h"
16 #include "fpdfsdk/formfiller/cffl_radiobutton.h" 17 #include "fpdfsdk/formfiller/cffl_radiobutton.h"
17 #include "fpdfsdk/formfiller/cffl_textfield.h" 18 #include "fpdfsdk/formfiller/cffl_textfield.h"
18 #include "fpdfsdk/include/fsdk_mgr.h" 19 #include "fpdfsdk/include/fsdk_mgr.h"
19 #include "fpdfsdk/pdfwindow/PWL_Utils.h" 20 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
20 21
21 #define FFL_MAXLISTBOXHEIGHT 140.0f 22 #define FFL_MAXLISTBOXHEIGHT 140.0f
22 23
23 CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) 24 CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp)
24 : m_pApp(pApp), m_bNotifying(FALSE) {} 25 : m_pApp(pApp), m_bNotifying(FALSE) {}
25 26
26 CFFL_IFormFiller::~CFFL_IFormFiller() { 27 CFFL_IFormFiller::~CFFL_IFormFiller() {
27 for (auto& it : m_Maps) 28 for (auto& it : m_Maps)
28 delete it.second; 29 delete it.second;
29 m_Maps.clear(); 30 m_Maps.clear();
30 } 31 }
31 32
32 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, 33 FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,
33 CPDFSDK_Annot* pAnnot, 34 CPDFSDK_Annot* pAnnot,
34 CFX_FloatPoint point) { 35 CFX_FloatPoint point) {
35 CFX_FloatRect rc = pAnnot->GetRect(); 36 CFX_FloatRect rc = pAnnot->GetRect();
36 if (rc.Contains(point.x, point.y)) 37 return rc.Contains(point.x, point.y);
37 return TRUE;
38 return FALSE;
39 } 38 }
40 39
41 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, 40 FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView,
42 CPDFSDK_Annot* pAnnot) { 41 CPDFSDK_Annot* pAnnot) {
43 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) 42 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
44 return pFormFiller->GetViewBBox(pPageView, pAnnot); 43 return pFormFiller->GetViewBBox(pPageView, pAnnot);
45 44
46 ASSERT(pPageView); 45 ASSERT(pPageView);
47 46
48 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); 47 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
49 CFX_FloatRect rcAnnot; 48 CFX_FloatRect rcAnnot;
50 pPDFAnnot->GetRect(rcAnnot); 49 pPDFAnnot->GetRect(rcAnnot);
51 50
52 CFX_FloatRect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); 51 CFX_FloatRect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1);
53 return rcWin.GetOutterRect(); 52 return rcWin.GetOutterRect();
54 } 53 }
55 54
56 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, 55 void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView,
57 CPDFSDK_Annot* pAnnot, 56 CPDFSDK_Annot* pAnnot,
58 CFX_RenderDevice* pDevice, 57 CFX_RenderDevice* pDevice,
59 CFX_Matrix* pUser2Device, 58 CFX_Matrix* pUser2Device,
60 uint32_t dwFlags) { 59 uint32_t dwFlags) {
61 ASSERT(pPageView); 60 ASSERT(pPageView);
62 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 61 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
63 62
64 if (IsVisible(pWidget)) { 63 if (!IsVisible(pWidget))
65 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 64 return;
66 if (pFormFiller->IsValid()) {
67 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
68 pAnnot->GetPDFPage();
69 65
70 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument(); 66 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
71 if (pDocument->GetFocusAnnot() == pAnnot) { 67 if (pFormFiller->IsValid()) {
72 CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView); 68 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
73 if (!rcFocus.IsEmpty()) { 69 pAnnot->GetPDFPage();
74 CFX_PathData path;
75 path.SetPointCount(5);
76 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO);
77 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO);
78 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO);
79 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO);
80 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO);
81 70
82 CFX_GraphStateData gsd; 71 CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
83 gsd.SetDashCount(1); 72 if (pDocument->GetFocusAnnot() == pAnnot) {
84 gsd.m_DashArray[0] = 1.0f; 73 CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView);
85 gsd.m_DashPhase = 0; 74 if (!rcFocus.IsEmpty()) {
86 gsd.m_LineWidth = 1.0f; 75 CFX_PathData path;
87 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, 76 path.SetPointCount(5);
88 ArgbEncode(255, 0, 0, 0), FXFILL_ALTERNATE); 77 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO);
89 } 78 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO);
79 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO);
80 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO);
81 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO);
82
83 CFX_GraphStateData gsd;
84 gsd.SetDashCount(1);
85 gsd.m_DashArray[0] = 1.0f;
86 gsd.m_DashPhase = 0;
87 gsd.m_LineWidth = 1.0f;
88 pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
89 ArgbEncode(255, 0, 0, 0), FXFILL_ALTERNATE);
90 } 90 }
91 return;
92 } 91 }
92 return;
93 } 93 }
94 }
94 95
95 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) 96 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
96 pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device, 97 pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device,
97 dwFlags); 98 dwFlags);
98 else 99 } else {
99 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); 100 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
101 }
100 102
101 if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget)) 103 if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))
102 pWidget->DrawShadow(pDevice, pPageView); 104 pWidget->DrawShadow(pDevice, pPageView);
103 }
104 } 105 }
105 106
106 void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot) { 107 void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot) {
107 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 108 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
108 pFormFiller->OnCreate(pAnnot); 109 pFormFiller->OnCreate(pAnnot);
109 } 110 }
110 } 111 }
111 112
112 void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot) { 113 void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {
113 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { 114 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 bExit = TRUE; 1008 bExit = TRUE;
1008 m_bNotifying = FALSE; 1009 m_bNotifying = FALSE;
1009 return; 1010 return;
1010 } 1011 }
1011 } 1012 }
1012 1013
1013 m_bNotifying = FALSE; 1014 m_bNotifying = FALSE;
1014 } 1015 }
1015 } 1016 }
1016 } 1017 }
OLDNEW
« no previous file with comments | « fpdfsdk/cfx_systemhandler.cpp ('k') | fpdfsdk/fpdf_progressive.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698