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_interactiveformfiller.h" | 7 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" |
8 | 8 |
9 #include "core/fpdfapi/page/cpdf_page.h" | 9 #include "core/fpdfapi/page/cpdf_page.h" |
10 #include "core/fpdfapi/parser/cpdf_document.h" | 10 #include "core/fpdfapi/parser/cpdf_document.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "fpdfsdk/formfiller/cffl_listbox.h" | 21 #include "fpdfsdk/formfiller/cffl_listbox.h" |
22 #include "fpdfsdk/formfiller/cffl_pushbutton.h" | 22 #include "fpdfsdk/formfiller/cffl_pushbutton.h" |
23 #include "fpdfsdk/formfiller/cffl_radiobutton.h" | 23 #include "fpdfsdk/formfiller/cffl_radiobutton.h" |
24 #include "fpdfsdk/formfiller/cffl_textfield.h" | 24 #include "fpdfsdk/formfiller/cffl_textfield.h" |
25 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 25 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
26 | 26 |
27 #define FFL_MAXLISTBOXHEIGHT 140.0f | 27 #define FFL_MAXLISTBOXHEIGHT 140.0f |
28 | 28 |
29 CFFL_InteractiveFormFiller::CFFL_InteractiveFormFiller( | 29 CFFL_InteractiveFormFiller::CFFL_InteractiveFormFiller( |
30 CPDFSDK_FormFillEnvironment* pFormFillEnv) | 30 CPDFSDK_FormFillEnvironment* pFormFillEnv) |
31 : m_pFormFillEnv(pFormFillEnv), m_bNotifying(FALSE) {} | 31 : m_pFormFillEnv(pFormFillEnv), m_bNotifying(false) {} |
32 | 32 |
33 CFFL_InteractiveFormFiller::~CFFL_InteractiveFormFiller() {} | 33 CFFL_InteractiveFormFiller::~CFFL_InteractiveFormFiller() {} |
34 | 34 |
35 FX_BOOL CFFL_InteractiveFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, | 35 bool CFFL_InteractiveFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, |
36 CPDFSDK_Annot* pAnnot, | 36 CPDFSDK_Annot* pAnnot, |
37 CFX_FloatPoint point) { | 37 CFX_FloatPoint point) { |
38 CFX_FloatRect rc = pAnnot->GetRect(); | 38 CFX_FloatRect rc = pAnnot->GetRect(); |
39 return rc.Contains(point.x, point.y); | 39 return rc.Contains(point.x, point.y); |
40 } | 40 } |
41 | 41 |
42 FX_RECT CFFL_InteractiveFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, | 42 FX_RECT CFFL_InteractiveFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, |
43 CPDFSDK_Annot* pAnnot) { | 43 CPDFSDK_Annot* pAnnot) { |
44 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 44 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, false)) |
45 return pFormFiller->GetViewBBox(pPageView, pAnnot); | 45 return pFormFiller->GetViewBBox(pPageView, pAnnot); |
46 | 46 |
47 ASSERT(pPageView); | 47 ASSERT(pPageView); |
48 | 48 |
49 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 49 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
50 CFX_FloatRect rcWin = CPWL_Utils::InflateRect(pPDFAnnot->GetRect(), 1); | 50 CFX_FloatRect rcWin = CPWL_Utils::InflateRect(pPDFAnnot->GetRect(), 1); |
51 return rcWin.GetOuterRect(); | 51 return rcWin.GetOuterRect(); |
52 } | 52 } |
53 | 53 |
54 void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView, | 54 void CFFL_InteractiveFormFiller::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 ASSERT(pPageView); | 58 ASSERT(pPageView); |
59 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 59 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
60 | 60 |
61 if (!IsVisible(pWidget)) | 61 if (!IsVisible(pWidget)) |
62 return; | 62 return; |
63 | 63 |
64 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 64 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, false)) { |
65 if (pFormFiller->IsValid()) { | 65 if (pFormFiller->IsValid()) { |
66 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device); | 66 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
67 pAnnot->GetPDFPage(); | 67 pAnnot->GetPDFPage(); |
68 | 68 |
69 if (m_pFormFillEnv->GetFocusAnnot() == pAnnot) { | 69 if (m_pFormFillEnv->GetFocusAnnot() == pAnnot) { |
70 CFX_FloatRect 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; |
81 gsd.SetDashCount(1); | 81 gsd.SetDashCount(1); |
82 gsd.m_DashArray[0] = 1.0f; | 82 gsd.m_DashArray[0] = 1.0f; |
83 gsd.m_DashPhase = 0; | 83 gsd.m_DashPhase = 0; |
84 gsd.m_LineWidth = 1.0f; | 84 gsd.m_LineWidth = 1.0f; |
85 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, | 85 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, |
86 ArgbEncode(255, 0, 0, 0), FXFILL_ALTERNATE); | 86 ArgbEncode(255, 0, 0, 0), FXFILL_ALTERNATE); |
87 } | 87 } |
88 } | 88 } |
89 return; | 89 return; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 93 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, false)) { |
94 pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device); | 94 pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device); |
95 } else { | 95 } else { |
96 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 96 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
97 } | 97 } |
98 | 98 |
99 if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget)) | 99 if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget)) |
100 pWidget->DrawShadow(pDevice, pPageView); | 100 pWidget->DrawShadow(pDevice, pPageView); |
101 } | 101 } |
102 | 102 |
103 void CFFL_InteractiveFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) { | 103 void CFFL_InteractiveFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) { |
104 UnRegisterFormFiller(pAnnot); | 104 UnRegisterFormFiller(pAnnot); |
105 } | 105 } |
106 | 106 |
107 void CFFL_InteractiveFormFiller::OnMouseEnter( | 107 void CFFL_InteractiveFormFiller::OnMouseEnter( |
108 CPDFSDK_PageView* pPageView, | 108 CPDFSDK_PageView* pPageView, |
109 CPDFSDK_Annot::ObservedPtr* pAnnot, | 109 CPDFSDK_Annot::ObservedPtr* pAnnot, |
110 uint32_t nFlag) { | 110 uint32_t nFlag) { |
111 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 111 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
112 if (!m_bNotifying) { | 112 if (!m_bNotifying) { |
113 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 113 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
114 if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) { | 114 if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) { |
115 m_bNotifying = TRUE; | 115 m_bNotifying = true; |
116 | 116 |
117 int nValueAge = pWidget->GetValueAge(); | 117 int nValueAge = pWidget->GetValueAge(); |
118 pWidget->ClearAppModified(); | 118 pWidget->ClearAppModified(); |
119 ASSERT(pPageView); | 119 ASSERT(pPageView); |
120 | 120 |
121 PDFSDK_FieldAction fa; | 121 PDFSDK_FieldAction fa; |
122 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 122 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
123 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 123 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
124 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView); | 124 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView); |
125 m_bNotifying = FALSE; | 125 m_bNotifying = false; |
126 if (!(*pAnnot)) | 126 if (!(*pAnnot)) |
127 return; | 127 return; |
128 | 128 |
129 if (pWidget->IsAppModified()) { | 129 if (pWidget->IsAppModified()) { |
130 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 130 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
131 pFormFiller->ResetPDFWindow(pPageView, | 131 pFormFiller->ResetPDFWindow(pPageView, |
132 pWidget->GetValueAge() == nValueAge); | 132 pWidget->GetValueAge() == nValueAge); |
133 } | 133 } |
134 } | 134 } |
135 } | 135 } |
136 } | 136 } |
137 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), TRUE)) | 137 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), true)) |
138 pFormFiller->OnMouseEnter(pPageView, pAnnot->Get()); | 138 pFormFiller->OnMouseEnter(pPageView, pAnnot->Get()); |
139 } | 139 } |
140 | 140 |
141 void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, | 141 void CFFL_InteractiveFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, |
142 CPDFSDK_Annot::ObservedPtr* pAnnot, | 142 CPDFSDK_Annot::ObservedPtr* pAnnot, |
143 uint32_t nFlag) { | 143 uint32_t nFlag) { |
144 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 144 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
145 if (!m_bNotifying) { | 145 if (!m_bNotifying) { |
146 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 146 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
147 if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) { | 147 if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) { |
148 m_bNotifying = TRUE; | 148 m_bNotifying = true; |
149 pWidget->GetAppearanceAge(); | 149 pWidget->GetAppearanceAge(); |
150 | 150 |
151 int nValueAge = pWidget->GetValueAge(); | 151 int nValueAge = pWidget->GetValueAge(); |
152 pWidget->ClearAppModified(); | 152 pWidget->ClearAppModified(); |
153 ASSERT(pPageView); | 153 ASSERT(pPageView); |
154 | 154 |
155 PDFSDK_FieldAction fa; | 155 PDFSDK_FieldAction fa; |
156 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 156 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
157 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 157 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
158 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); | 158 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); |
159 m_bNotifying = FALSE; | 159 m_bNotifying = false; |
160 if (!(*pAnnot)) | 160 if (!(*pAnnot)) |
161 return; | 161 return; |
162 | 162 |
163 if (pWidget->IsAppModified()) { | 163 if (pWidget->IsAppModified()) { |
164 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 164 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
165 pFormFiller->ResetPDFWindow(pPageView, | 165 pFormFiller->ResetPDFWindow(pPageView, |
166 nValueAge == pWidget->GetValueAge()); | 166 nValueAge == pWidget->GetValueAge()); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 } | 170 } |
171 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE)) | 171 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false)) |
172 pFormFiller->OnMouseExit(pPageView, pAnnot->Get()); | 172 pFormFiller->OnMouseExit(pPageView, pAnnot->Get()); |
173 } | 173 } |
174 | 174 |
175 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonDown( | 175 bool CFFL_InteractiveFormFiller::OnLButtonDown( |
176 CPDFSDK_PageView* pPageView, | 176 CPDFSDK_PageView* pPageView, |
177 CPDFSDK_Annot::ObservedPtr* pAnnot, | 177 CPDFSDK_Annot::ObservedPtr* pAnnot, |
178 uint32_t nFlags, | 178 uint32_t nFlags, |
179 const CFX_FloatPoint& point) { | 179 const CFX_FloatPoint& point) { |
180 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 180 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
181 if (!m_bNotifying) { | 181 if (!m_bNotifying) { |
182 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 182 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
183 if (Annot_HitTest(pPageView, pAnnot->Get(), point) && | 183 if (Annot_HitTest(pPageView, pAnnot->Get(), point) && |
184 pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) { | 184 pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) { |
185 m_bNotifying = TRUE; | 185 m_bNotifying = true; |
186 pWidget->GetAppearanceAge(); | 186 pWidget->GetAppearanceAge(); |
187 | 187 |
188 int nValueAge = pWidget->GetValueAge(); | 188 int nValueAge = pWidget->GetValueAge(); |
189 pWidget->ClearAppModified(); | 189 pWidget->ClearAppModified(); |
190 ASSERT(pPageView); | 190 ASSERT(pPageView); |
191 | 191 |
192 PDFSDK_FieldAction fa; | 192 PDFSDK_FieldAction fa; |
193 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlags); | 193 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlags); |
194 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlags); | 194 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlags); |
195 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); | 195 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); |
196 m_bNotifying = FALSE; | 196 m_bNotifying = false; |
197 if (!(*pAnnot)) | 197 if (!(*pAnnot)) |
198 return TRUE; | 198 return true; |
199 | 199 |
200 if (!IsValidAnnot(pPageView, pAnnot->Get())) | 200 if (!IsValidAnnot(pPageView, pAnnot->Get())) |
201 return TRUE; | 201 return true; |
202 | 202 |
203 if (pWidget->IsAppModified()) { | 203 if (pWidget->IsAppModified()) { |
204 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 204 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
205 pFormFiller->ResetPDFWindow(pPageView, | 205 pFormFiller->ResetPDFWindow(pPageView, |
206 nValueAge == pWidget->GetValueAge()); | 206 nValueAge == pWidget->GetValueAge()); |
207 } | 207 } |
208 } | 208 } |
209 } | 209 } |
210 } | 210 } |
211 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE)) | 211 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false)) |
212 return pFormFiller->OnLButtonDown(pPageView, pAnnot->Get(), nFlags, point); | 212 return pFormFiller->OnLButtonDown(pPageView, pAnnot->Get(), nFlags, point); |
213 | 213 |
214 return FALSE; | 214 return false; |
215 } | 215 } |
216 | 216 |
217 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonUp( | 217 bool CFFL_InteractiveFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, |
218 CPDFSDK_PageView* pPageView, | 218 CPDFSDK_Annot::ObservedPtr* pAnnot, |
219 CPDFSDK_Annot::ObservedPtr* pAnnot, | 219 uint32_t nFlags, |
220 uint32_t nFlags, | 220 const CFX_FloatPoint& point) { |
221 const CFX_FloatPoint& point) { | |
222 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 221 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
223 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 222 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
224 | 223 |
225 switch (pWidget->GetFieldType()) { | 224 switch (pWidget->GetFieldType()) { |
226 case FIELDTYPE_PUSHBUTTON: | 225 case FIELDTYPE_PUSHBUTTON: |
227 case FIELDTYPE_CHECKBOX: | 226 case FIELDTYPE_CHECKBOX: |
228 case FIELDTYPE_RADIOBUTTON: | 227 case FIELDTYPE_RADIOBUTTON: |
229 if (GetViewBBox(pPageView, pAnnot->Get()) | 228 if (GetViewBBox(pPageView, pAnnot->Get()) |
230 .Contains((int)point.x, (int)point.y)) | 229 .Contains((int)point.x, (int)point.y)) |
231 m_pFormFillEnv->SetFocusAnnot(pAnnot); | 230 m_pFormFillEnv->SetFocusAnnot(pAnnot); |
232 break; | 231 break; |
233 default: | 232 default: |
234 m_pFormFillEnv->SetFocusAnnot(pAnnot); | 233 m_pFormFillEnv->SetFocusAnnot(pAnnot); |
235 break; | 234 break; |
236 } | 235 } |
237 | 236 |
238 FX_BOOL bRet = FALSE; | 237 bool bRet = false; |
239 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE)) | 238 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false)) |
240 bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot->Get(), nFlags, point); | 239 bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot->Get(), nFlags, point); |
241 | 240 |
242 if (m_pFormFillEnv->GetFocusAnnot() == pAnnot->Get()) { | 241 if (m_pFormFillEnv->GetFocusAnnot() == pAnnot->Get()) { |
243 FX_BOOL bExit = FALSE; | 242 bool bExit = false; |
244 FX_BOOL bReset = FALSE; | 243 bool bReset = false; |
245 OnButtonUp(pAnnot, pPageView, bReset, bExit, nFlags); | 244 OnButtonUp(pAnnot, pPageView, bReset, bExit, nFlags); |
246 if (!pAnnot || bExit) | 245 if (!pAnnot || bExit) |
247 return TRUE; | 246 return true; |
248 #ifdef PDF_ENABLE_XFA | 247 #ifdef PDF_ENABLE_XFA |
249 OnClick(pWidget, pPageView, bReset, bExit, nFlags); | 248 OnClick(pWidget, pPageView, bReset, bExit, nFlags); |
250 if (!pAnnot || bExit) | 249 if (!pAnnot || bExit) |
251 return TRUE; | 250 return true; |
252 #endif // PDF_ENABLE_XFA | 251 #endif // PDF_ENABLE_XFA |
253 } | 252 } |
254 return bRet; | 253 return bRet; |
255 } | 254 } |
256 | 255 |
257 void CFFL_InteractiveFormFiller::OnButtonUp(CPDFSDK_Annot::ObservedPtr* pAnnot, | 256 void CFFL_InteractiveFormFiller::OnButtonUp(CPDFSDK_Annot::ObservedPtr* pAnnot, |
258 CPDFSDK_PageView* pPageView, | 257 CPDFSDK_PageView* pPageView, |
259 FX_BOOL& bReset, | 258 bool& bReset, |
260 FX_BOOL& bExit, | 259 bool& bExit, |
261 uint32_t nFlag) { | 260 uint32_t nFlag) { |
262 if (!m_bNotifying) { | 261 if (!m_bNotifying) { |
263 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 262 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
264 if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) { | 263 if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) { |
265 m_bNotifying = TRUE; | 264 m_bNotifying = true; |
266 | 265 |
267 int nAge = pWidget->GetAppearanceAge(); | 266 int nAge = pWidget->GetAppearanceAge(); |
268 int nValueAge = pWidget->GetValueAge(); | 267 int nValueAge = pWidget->GetValueAge(); |
269 ASSERT(pPageView); | 268 ASSERT(pPageView); |
270 | 269 |
271 PDFSDK_FieldAction fa; | 270 PDFSDK_FieldAction fa; |
272 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 271 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
273 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 272 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
274 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); | 273 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); |
275 m_bNotifying = FALSE; | 274 m_bNotifying = false; |
276 if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget)) { | 275 if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget)) { |
277 bExit = TRUE; | 276 bExit = true; |
278 return; | 277 return; |
279 } | 278 } |
280 if (nAge != pWidget->GetAppearanceAge()) { | 279 if (nAge != pWidget->GetAppearanceAge()) { |
281 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 280 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
282 pFormFiller->ResetPDFWindow(pPageView, | 281 pFormFiller->ResetPDFWindow(pPageView, |
283 nValueAge == pWidget->GetValueAge()); | 282 nValueAge == pWidget->GetValueAge()); |
284 } | 283 } |
285 bReset = TRUE; | 284 bReset = true; |
286 } | 285 } |
287 } | 286 } |
288 } | 287 } |
289 } | 288 } |
290 | 289 |
291 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonDblClk( | 290 bool CFFL_InteractiveFormFiller::OnLButtonDblClk( |
292 CPDFSDK_PageView* pPageView, | 291 CPDFSDK_PageView* pPageView, |
293 CPDFSDK_Annot::ObservedPtr* pAnnot, | 292 CPDFSDK_Annot::ObservedPtr* pAnnot, |
294 uint32_t nFlags, | 293 uint32_t nFlags, |
295 const CFX_FloatPoint& point) { | 294 const CFX_FloatPoint& point) { |
296 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 295 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
297 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE); | 296 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false); |
298 return pFormFiller && | 297 return pFormFiller && |
299 pFormFiller->OnLButtonDblClk(pPageView, pAnnot->Get(), nFlags, point); | 298 pFormFiller->OnLButtonDblClk(pPageView, pAnnot->Get(), nFlags, point); |
300 } | 299 } |
301 | 300 |
302 FX_BOOL CFFL_InteractiveFormFiller::OnMouseMove( | 301 bool CFFL_InteractiveFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, |
303 CPDFSDK_PageView* pPageView, | 302 CPDFSDK_Annot::ObservedPtr* pAnnot, |
304 CPDFSDK_Annot::ObservedPtr* pAnnot, | 303 uint32_t nFlags, |
305 uint32_t nFlags, | 304 const CFX_FloatPoint& point) { |
306 const CFX_FloatPoint& point) { | |
307 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 305 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
308 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), TRUE); | 306 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), true); |
309 return pFormFiller && | 307 return pFormFiller && |
310 pFormFiller->OnMouseMove(pPageView, pAnnot->Get(), nFlags, point); | 308 pFormFiller->OnMouseMove(pPageView, pAnnot->Get(), nFlags, point); |
311 } | 309 } |
312 | 310 |
313 FX_BOOL CFFL_InteractiveFormFiller::OnMouseWheel( | 311 bool CFFL_InteractiveFormFiller::OnMouseWheel( |
314 CPDFSDK_PageView* pPageView, | 312 CPDFSDK_PageView* pPageView, |
315 CPDFSDK_Annot::ObservedPtr* pAnnot, | 313 CPDFSDK_Annot::ObservedPtr* pAnnot, |
316 uint32_t nFlags, | 314 uint32_t nFlags, |
317 short zDelta, | 315 short zDelta, |
318 const CFX_FloatPoint& point) { | 316 const CFX_FloatPoint& point) { |
319 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 317 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
320 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE); | 318 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false); |
321 return pFormFiller && | 319 return pFormFiller && |
322 pFormFiller->OnMouseWheel(pPageView, pAnnot->Get(), nFlags, zDelta, | 320 pFormFiller->OnMouseWheel(pPageView, pAnnot->Get(), nFlags, zDelta, |
323 point); | 321 point); |
324 } | 322 } |
325 | 323 |
326 FX_BOOL CFFL_InteractiveFormFiller::OnRButtonDown( | 324 bool CFFL_InteractiveFormFiller::OnRButtonDown( |
327 CPDFSDK_PageView* pPageView, | 325 CPDFSDK_PageView* pPageView, |
328 CPDFSDK_Annot::ObservedPtr* pAnnot, | 326 CPDFSDK_Annot::ObservedPtr* pAnnot, |
329 uint32_t nFlags, | 327 uint32_t nFlags, |
330 const CFX_FloatPoint& point) { | 328 const CFX_FloatPoint& point) { |
331 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 329 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
332 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE); | 330 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false); |
333 return pFormFiller && | 331 return pFormFiller && |
334 pFormFiller->OnRButtonDown(pPageView, pAnnot->Get(), nFlags, point); | 332 pFormFiller->OnRButtonDown(pPageView, pAnnot->Get(), nFlags, point); |
335 } | 333 } |
336 | 334 |
337 FX_BOOL CFFL_InteractiveFormFiller::OnRButtonUp( | 335 bool CFFL_InteractiveFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, |
338 CPDFSDK_PageView* pPageView, | 336 CPDFSDK_Annot::ObservedPtr* pAnnot, |
339 CPDFSDK_Annot::ObservedPtr* pAnnot, | 337 uint32_t nFlags, |
340 uint32_t nFlags, | 338 const CFX_FloatPoint& point) { |
341 const CFX_FloatPoint& point) { | |
342 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 339 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
343 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE); | 340 CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false); |
344 return pFormFiller && | 341 return pFormFiller && |
345 pFormFiller->OnRButtonUp(pPageView, pAnnot->Get(), nFlags, point); | 342 pFormFiller->OnRButtonUp(pPageView, pAnnot->Get(), nFlags, point); |
346 } | 343 } |
347 | 344 |
348 FX_BOOL CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 345 bool CFFL_InteractiveFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
349 uint32_t nKeyCode, | 346 uint32_t nKeyCode, |
350 uint32_t nFlags) { | 347 uint32_t nFlags) { |
351 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 348 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
352 | 349 |
353 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 350 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, false)) { |
354 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); | 351 return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags); |
355 } | 352 } |
356 | 353 |
357 return FALSE; | 354 return false; |
358 } | 355 } |
359 | 356 |
360 FX_BOOL CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot, | 357 bool CFFL_InteractiveFormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
361 uint32_t nChar, | 358 uint32_t nChar, |
362 uint32_t nFlags) { | 359 uint32_t nFlags) { |
363 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 360 ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
364 if (nChar == FWL_VKEY_Tab) | 361 if (nChar == FWL_VKEY_Tab) |
365 return TRUE; | 362 return true; |
366 | 363 |
367 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) | 364 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, false)) |
368 return pFormFiller->OnChar(pAnnot, nChar, nFlags); | 365 return pFormFiller->OnChar(pAnnot, nChar, nFlags); |
369 | 366 |
370 return FALSE; | 367 return false; |
371 } | 368 } |
372 | 369 |
373 FX_BOOL CFFL_InteractiveFormFiller::OnSetFocus( | 370 bool CFFL_InteractiveFormFiller::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
374 CPDFSDK_Annot::ObservedPtr* pAnnot, | 371 uint32_t nFlag) { |
375 uint32_t nFlag) { | |
376 if (!(*pAnnot)) | 372 if (!(*pAnnot)) |
377 return FALSE; | 373 return false; |
378 | 374 |
379 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 375 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
380 if (!m_bNotifying) { | 376 if (!m_bNotifying) { |
381 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 377 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
382 if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) { | 378 if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) { |
383 m_bNotifying = TRUE; | 379 m_bNotifying = true; |
384 pWidget->GetAppearanceAge(); | 380 pWidget->GetAppearanceAge(); |
385 | 381 |
386 int nValueAge = pWidget->GetValueAge(); | 382 int nValueAge = pWidget->GetValueAge(); |
387 pWidget->ClearAppModified(); | 383 pWidget->ClearAppModified(); |
388 | 384 |
389 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE); | 385 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, true); |
390 if (!pFormFiller) | 386 if (!pFormFiller) |
391 return FALSE; | 387 return false; |
392 | 388 |
393 CPDFSDK_PageView* pPageView = (*pAnnot)->GetPageView(); | 389 CPDFSDK_PageView* pPageView = (*pAnnot)->GetPageView(); |
394 ASSERT(pPageView); | 390 ASSERT(pPageView); |
395 | 391 |
396 PDFSDK_FieldAction fa; | 392 PDFSDK_FieldAction fa; |
397 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 393 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
398 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 394 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
399 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); | 395 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); |
400 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); | 396 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); |
401 m_bNotifying = FALSE; | 397 m_bNotifying = false; |
402 if (!(*pAnnot)) | 398 if (!(*pAnnot)) |
403 return FALSE; | 399 return false; |
404 | 400 |
405 if (pWidget->IsAppModified()) { | 401 if (pWidget->IsAppModified()) { |
406 if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, FALSE)) { | 402 if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, false)) { |
407 pFiller->ResetPDFWindow(pPageView, | 403 pFiller->ResetPDFWindow(pPageView, |
408 nValueAge == pWidget->GetValueAge()); | 404 nValueAge == pWidget->GetValueAge()); |
409 } | 405 } |
410 } | 406 } |
411 } | 407 } |
412 } | 408 } |
413 | 409 |
414 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), TRUE)) | 410 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), true)) |
415 pFormFiller->SetFocusForAnnot(pAnnot->Get(), nFlag); | 411 pFormFiller->SetFocusForAnnot(pAnnot->Get(), nFlag); |
416 | 412 |
417 return TRUE; | 413 return true; |
418 } | 414 } |
419 | 415 |
420 FX_BOOL CFFL_InteractiveFormFiller::OnKillFocus( | 416 bool CFFL_InteractiveFormFiller::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
421 CPDFSDK_Annot::ObservedPtr* pAnnot, | 417 uint32_t nFlag) { |
422 uint32_t nFlag) { | |
423 if (!(*pAnnot)) | 418 if (!(*pAnnot)) |
424 return FALSE; | 419 return false; |
425 | 420 |
426 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 421 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
427 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE)) { | 422 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), false)) { |
428 pFormFiller->KillFocusForAnnot(pAnnot->Get(), nFlag); | 423 pFormFiller->KillFocusForAnnot(pAnnot->Get(), nFlag); |
429 if (!m_bNotifying) { | 424 if (!m_bNotifying) { |
430 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 425 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
431 if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) { | 426 if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) { |
432 m_bNotifying = TRUE; | 427 m_bNotifying = true; |
433 pWidget->ClearAppModified(); | 428 pWidget->ClearAppModified(); |
434 | 429 |
435 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | 430 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); |
436 ASSERT(pPageView); | 431 ASSERT(pPageView); |
437 | 432 |
438 PDFSDK_FieldAction fa; | 433 PDFSDK_FieldAction fa; |
439 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 434 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
440 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 435 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
441 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); | 436 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); |
442 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); | 437 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); |
443 m_bNotifying = FALSE; | 438 m_bNotifying = false; |
444 if (!(*pAnnot)) | 439 if (!(*pAnnot)) |
445 return FALSE; | 440 return false; |
446 } | 441 } |
447 } | 442 } |
448 } | 443 } |
449 return TRUE; | 444 return true; |
450 } | 445 } |
451 | 446 |
452 FX_BOOL CFFL_InteractiveFormFiller::IsVisible(CPDFSDK_Widget* pWidget) { | 447 bool CFFL_InteractiveFormFiller::IsVisible(CPDFSDK_Widget* pWidget) { |
453 return pWidget->IsVisible(); | 448 return pWidget->IsVisible(); |
454 } | 449 } |
455 | 450 |
456 FX_BOOL CFFL_InteractiveFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) { | 451 bool CFFL_InteractiveFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) { |
457 int nFieldFlags = pWidget->GetFieldFlags(); | 452 int nFieldFlags = pWidget->GetFieldFlags(); |
458 return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY; | 453 return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY; |
459 } | 454 } |
460 | 455 |
461 FX_BOOL CFFL_InteractiveFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) { | 456 bool CFFL_InteractiveFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) { |
462 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 457 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
463 return TRUE; | 458 return true; |
464 | 459 |
465 CPDF_Page* pPage = pWidget->GetPDFPage(); | 460 CPDF_Page* pPage = pWidget->GetPDFPage(); |
466 CPDF_Document* pDocument = pPage->m_pDocument; | 461 CPDF_Document* pDocument = pPage->m_pDocument; |
467 uint32_t dwPermissions = pDocument->GetUserPermissions(); | 462 uint32_t dwPermissions = pDocument->GetUserPermissions(); |
468 return (dwPermissions & FPDFPERM_FILL_FORM) || | 463 return (dwPermissions & FPDFPERM_FILL_FORM) || |
469 (dwPermissions & FPDFPERM_ANNOT_FORM) || | 464 (dwPermissions & FPDFPERM_ANNOT_FORM) || |
470 (dwPermissions & FPDFPERM_MODIFY); | 465 (dwPermissions & FPDFPERM_MODIFY); |
471 } | 466 } |
472 | 467 |
473 CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller( | 468 CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller( |
474 CPDFSDK_Annot* pAnnot, | 469 CPDFSDK_Annot* pAnnot, |
475 FX_BOOL bRegister) { | 470 bool bRegister) { |
476 auto it = m_Maps.find(pAnnot); | 471 auto it = m_Maps.find(pAnnot); |
477 if (it != m_Maps.end()) | 472 if (it != m_Maps.end()) |
478 return it->second.get(); | 473 return it->second.get(); |
479 | 474 |
480 if (!bRegister) | 475 if (!bRegister) |
481 return nullptr; | 476 return nullptr; |
482 | 477 |
483 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 478 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
484 int nFieldType = pWidget->GetFieldType(); | 479 int nFieldType = pWidget->GetFieldType(); |
485 CFFL_FormFiller* pFormFiller; | 480 CFFL_FormFiller* pFormFiller; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 fTop = rcAnnot.bottom - rcPageView.bottom; | 555 fTop = rcAnnot.bottom - rcPageView.bottom; |
561 fBottom = rcPageView.top - rcAnnot.top; | 556 fBottom = rcPageView.top - rcAnnot.top; |
562 break; | 557 break; |
563 case 3: | 558 case 3: |
564 fTop = rcPageView.right - rcAnnot.right; | 559 fTop = rcPageView.right - rcAnnot.right; |
565 fBottom = rcAnnot.left - rcPageView.left; | 560 fBottom = rcAnnot.left - rcPageView.left; |
566 break; | 561 break; |
567 } | 562 } |
568 | 563 |
569 FX_FLOAT fFactHeight = 0; | 564 FX_FLOAT fFactHeight = 0; |
570 FX_BOOL bBottom = TRUE; | 565 bool bBottom = true; |
571 FX_FLOAT fMaxListBoxHeight = 0; | 566 FX_FLOAT fMaxListBoxHeight = 0; |
572 if (fPopupMax > FFL_MAXLISTBOXHEIGHT) { | 567 if (fPopupMax > FFL_MAXLISTBOXHEIGHT) { |
573 if (fPopupMin > FFL_MAXLISTBOXHEIGHT) { | 568 if (fPopupMin > FFL_MAXLISTBOXHEIGHT) { |
574 fMaxListBoxHeight = fPopupMin; | 569 fMaxListBoxHeight = fPopupMin; |
575 } else { | 570 } else { |
576 fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT; | 571 fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT; |
577 } | 572 } |
578 } else { | 573 } else { |
579 fMaxListBoxHeight = fPopupMax; | 574 fMaxListBoxHeight = fPopupMax; |
580 } | 575 } |
581 | 576 |
582 if (fBottom > fMaxListBoxHeight) { | 577 if (fBottom > fMaxListBoxHeight) { |
583 fFactHeight = fMaxListBoxHeight; | 578 fFactHeight = fMaxListBoxHeight; |
584 bBottom = TRUE; | 579 bBottom = true; |
585 } else { | 580 } else { |
586 if (fTop > fMaxListBoxHeight) { | 581 if (fTop > fMaxListBoxHeight) { |
587 fFactHeight = fMaxListBoxHeight; | 582 fFactHeight = fMaxListBoxHeight; |
588 bBottom = FALSE; | 583 bBottom = false; |
589 } else { | 584 } else { |
590 if (fTop > fBottom) { | 585 if (fTop > fBottom) { |
591 fFactHeight = fTop; | 586 fFactHeight = fTop; |
592 bBottom = FALSE; | 587 bBottom = false; |
593 } else { | 588 } else { |
594 fFactHeight = fBottom; | 589 fFactHeight = fBottom; |
595 bBottom = TRUE; | 590 bBottom = true; |
596 } | 591 } |
597 } | 592 } |
598 } | 593 } |
599 | 594 |
600 nRet = bBottom ? 0 : 1; | 595 nRet = bBottom ? 0 : 1; |
601 fPopupRet = fFactHeight; | 596 fPopupRet = fFactHeight; |
602 } | 597 } |
603 | 598 |
604 void CFFL_InteractiveFormFiller::OnKeyStrokeCommit( | 599 void CFFL_InteractiveFormFiller::OnKeyStrokeCommit( |
605 CPDFSDK_Annot::ObservedPtr* pAnnot, | 600 CPDFSDK_Annot::ObservedPtr* pAnnot, |
606 CPDFSDK_PageView* pPageView, | 601 CPDFSDK_PageView* pPageView, |
607 FX_BOOL& bRC, | 602 bool& bRC, |
608 FX_BOOL& bExit, | 603 bool& bExit, |
609 uint32_t nFlag) { | 604 uint32_t nFlag) { |
610 if (!m_bNotifying) { | 605 if (!m_bNotifying) { |
611 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 606 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
612 if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { | 607 if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { |
613 ASSERT(pPageView); | 608 ASSERT(pPageView); |
614 m_bNotifying = TRUE; | 609 m_bNotifying = true; |
615 pWidget->ClearAppModified(); | 610 pWidget->ClearAppModified(); |
616 | 611 |
617 PDFSDK_FieldAction fa; | 612 PDFSDK_FieldAction fa; |
618 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 613 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
619 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 614 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
620 fa.bWillCommit = TRUE; | 615 fa.bWillCommit = true; |
621 fa.bKeyDown = TRUE; | 616 fa.bKeyDown = true; |
622 fa.bRC = TRUE; | 617 fa.bRC = true; |
623 | 618 |
624 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); | 619 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false); |
625 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); | 620 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); |
626 pFormFiller->SaveState(pPageView); | 621 pFormFiller->SaveState(pPageView); |
627 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); | 622 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); |
628 if (!(*pAnnot)) | 623 if (!(*pAnnot)) |
629 return; | 624 return; |
630 | 625 |
631 bRC = fa.bRC; | 626 bRC = fa.bRC; |
632 m_bNotifying = FALSE; | 627 m_bNotifying = false; |
633 } | 628 } |
634 } | 629 } |
635 } | 630 } |
636 | 631 |
637 void CFFL_InteractiveFormFiller::OnValidate(CPDFSDK_Annot::ObservedPtr* pAnnot, | 632 void CFFL_InteractiveFormFiller::OnValidate(CPDFSDK_Annot::ObservedPtr* pAnnot, |
638 CPDFSDK_PageView* pPageView, | 633 CPDFSDK_PageView* pPageView, |
639 FX_BOOL& bRC, | 634 bool& bRC, |
640 FX_BOOL& bExit, | 635 bool& bExit, |
641 uint32_t nFlag) { | 636 uint32_t nFlag) { |
642 if (!m_bNotifying) { | 637 if (!m_bNotifying) { |
643 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 638 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
644 if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) { | 639 if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) { |
645 ASSERT(pPageView); | 640 ASSERT(pPageView); |
646 m_bNotifying = TRUE; | 641 m_bNotifying = true; |
647 pWidget->ClearAppModified(); | 642 pWidget->ClearAppModified(); |
648 | 643 |
649 PDFSDK_FieldAction fa; | 644 PDFSDK_FieldAction fa; |
650 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 645 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
651 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 646 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
652 fa.bKeyDown = TRUE; | 647 fa.bKeyDown = true; |
653 fa.bRC = TRUE; | 648 fa.bRC = true; |
654 | 649 |
655 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); | 650 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false); |
656 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); | 651 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); |
657 pFormFiller->SaveState(pPageView); | 652 pFormFiller->SaveState(pPageView); |
658 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); | 653 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); |
659 if (!(*pAnnot)) | 654 if (!(*pAnnot)) |
660 return; | 655 return; |
661 | 656 |
662 bRC = fa.bRC; | 657 bRC = fa.bRC; |
663 m_bNotifying = FALSE; | 658 m_bNotifying = false; |
664 } | 659 } |
665 } | 660 } |
666 } | 661 } |
667 | 662 |
668 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, | 663 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, |
669 CPDFSDK_PageView* pPageView, | 664 CPDFSDK_PageView* pPageView, |
670 FX_BOOL& bExit, | 665 bool& bExit, |
671 uint32_t nFlag) { | 666 uint32_t nFlag) { |
672 if (!m_bNotifying) { | 667 if (!m_bNotifying) { |
673 ASSERT(pWidget); | 668 ASSERT(pWidget); |
674 CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); | 669 CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); |
675 pInterForm->OnCalculate(pWidget->GetFormField()); | 670 pInterForm->OnCalculate(pWidget->GetFormField()); |
676 m_bNotifying = FALSE; | 671 m_bNotifying = false; |
677 } | 672 } |
678 } | 673 } |
679 | 674 |
680 void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Widget* pWidget, | 675 void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Widget* pWidget, |
681 CPDFSDK_PageView* pPageView, | 676 CPDFSDK_PageView* pPageView, |
682 FX_BOOL& bExit, | 677 bool& bExit, |
683 uint32_t nFlag) { | 678 uint32_t nFlag) { |
684 if (!m_bNotifying) { | 679 if (!m_bNotifying) { |
685 ASSERT(pWidget); | 680 ASSERT(pWidget); |
686 CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); | 681 CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); |
687 | 682 |
688 FX_BOOL bFormatted = FALSE; | 683 bool bFormatted = false; |
689 CFX_WideString sValue = | 684 CFX_WideString sValue = |
690 pInterForm->OnFormat(pWidget->GetFormField(), bFormatted); | 685 pInterForm->OnFormat(pWidget->GetFormField(), bFormatted); |
691 | 686 |
692 if (bExit) | 687 if (bExit) |
693 return; | 688 return; |
694 | 689 |
695 if (bFormatted) { | 690 if (bFormatted) { |
696 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), &sValue, TRUE); | 691 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), &sValue, true); |
697 pInterForm->UpdateField(pWidget->GetFormField()); | 692 pInterForm->UpdateField(pWidget->GetFormField()); |
698 } | 693 } |
699 | 694 |
700 m_bNotifying = FALSE; | 695 m_bNotifying = false; |
701 } | 696 } |
702 } | 697 } |
703 | 698 |
704 #ifdef PDF_ENABLE_XFA | 699 #ifdef PDF_ENABLE_XFA |
705 void CFFL_InteractiveFormFiller::OnClick(CPDFSDK_Widget* pWidget, | 700 void CFFL_InteractiveFormFiller::OnClick(CPDFSDK_Widget* pWidget, |
706 CPDFSDK_PageView* pPageView, | 701 CPDFSDK_PageView* pPageView, |
707 FX_BOOL& bReset, | 702 bool& bReset, |
708 FX_BOOL& bExit, | 703 bool& bExit, |
709 uint32_t nFlag) { | 704 uint32_t nFlag) { |
710 if (!m_bNotifying) { | 705 if (!m_bNotifying) { |
711 if (pWidget->HasXFAAAction(PDFSDK_XFA_Click)) { | 706 if (pWidget->HasXFAAAction(PDFSDK_XFA_Click)) { |
712 m_bNotifying = TRUE; | 707 m_bNotifying = true; |
713 int nAge = pWidget->GetAppearanceAge(); | 708 int nAge = pWidget->GetAppearanceAge(); |
714 int nValueAge = pWidget->GetValueAge(); | 709 int nValueAge = pWidget->GetValueAge(); |
715 | 710 |
716 PDFSDK_FieldAction fa; | 711 PDFSDK_FieldAction fa; |
717 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 712 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
718 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 713 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
719 | 714 |
720 pWidget->OnXFAAAction(PDFSDK_XFA_Click, fa, pPageView); | 715 pWidget->OnXFAAAction(PDFSDK_XFA_Click, fa, pPageView); |
721 m_bNotifying = FALSE; | 716 m_bNotifying = false; |
722 | 717 |
723 if (!IsValidAnnot(pPageView, pWidget)) { | 718 if (!IsValidAnnot(pPageView, pWidget)) { |
724 bExit = TRUE; | 719 bExit = true; |
725 return; | 720 return; |
726 } | 721 } |
727 | 722 |
728 if (nAge != pWidget->GetAppearanceAge()) { | 723 if (nAge != pWidget->GetAppearanceAge()) { |
729 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 724 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
730 pFormFiller->ResetPDFWindow(pPageView, | 725 pFormFiller->ResetPDFWindow(pPageView, |
731 nValueAge == pWidget->GetValueAge()); | 726 nValueAge == pWidget->GetValueAge()); |
732 } | 727 } |
733 | 728 |
734 bReset = TRUE; | 729 bReset = true; |
735 } | 730 } |
736 } | 731 } |
737 } | 732 } |
738 } | 733 } |
739 | 734 |
740 void CFFL_InteractiveFormFiller::OnFull(CPDFSDK_Widget* pWidget, | 735 void CFFL_InteractiveFormFiller::OnFull(CPDFSDK_Widget* pWidget, |
741 CPDFSDK_PageView* pPageView, | 736 CPDFSDK_PageView* pPageView, |
742 FX_BOOL& bReset, | 737 bool& bReset, |
743 FX_BOOL& bExit, | 738 bool& bExit, |
744 uint32_t nFlag) { | 739 uint32_t nFlag) { |
745 if (!m_bNotifying) { | 740 if (!m_bNotifying) { |
746 if (pWidget->HasXFAAAction(PDFSDK_XFA_Full)) { | 741 if (pWidget->HasXFAAAction(PDFSDK_XFA_Full)) { |
747 m_bNotifying = TRUE; | 742 m_bNotifying = true; |
748 int nAge = pWidget->GetAppearanceAge(); | 743 int nAge = pWidget->GetAppearanceAge(); |
749 int nValueAge = pWidget->GetValueAge(); | 744 int nValueAge = pWidget->GetValueAge(); |
750 | 745 |
751 PDFSDK_FieldAction fa; | 746 PDFSDK_FieldAction fa; |
752 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 747 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
753 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 748 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
754 | 749 |
755 pWidget->OnXFAAAction(PDFSDK_XFA_Full, fa, pPageView); | 750 pWidget->OnXFAAAction(PDFSDK_XFA_Full, fa, pPageView); |
756 m_bNotifying = FALSE; | 751 m_bNotifying = false; |
757 | 752 |
758 if (!IsValidAnnot(pPageView, pWidget)) { | 753 if (!IsValidAnnot(pPageView, pWidget)) { |
759 bExit = TRUE; | 754 bExit = true; |
760 return; | 755 return; |
761 } | 756 } |
762 | 757 |
763 if (nAge != pWidget->GetAppearanceAge()) { | 758 if (nAge != pWidget->GetAppearanceAge()) { |
764 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 759 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
765 pFormFiller->ResetPDFWindow(pPageView, | 760 pFormFiller->ResetPDFWindow(pPageView, |
766 nValueAge == pWidget->GetValueAge()); | 761 nValueAge == pWidget->GetValueAge()); |
767 } | 762 } |
768 | 763 |
769 bReset = TRUE; | 764 bReset = true; |
770 } | 765 } |
771 } | 766 } |
772 } | 767 } |
773 } | 768 } |
774 | 769 |
775 void CFFL_InteractiveFormFiller::OnPopupPreOpen(void* pPrivateData, | 770 void CFFL_InteractiveFormFiller::OnPopupPreOpen(void* pPrivateData, |
776 FX_BOOL& bExit, | 771 bool& bExit, |
777 uint32_t nFlag) { | 772 uint32_t nFlag) { |
778 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 773 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
779 ASSERT(pData); | 774 ASSERT(pData); |
780 ASSERT(pData->pWidget); | 775 ASSERT(pData->pWidget); |
781 | 776 |
782 FX_BOOL bTempReset = FALSE; | 777 bool bTempReset = false; |
783 FX_BOOL bTempExit = FALSE; | 778 bool bTempExit = false; |
784 OnPreOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag); | 779 OnPreOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag); |
785 if (bTempReset || bTempExit) | 780 if (bTempReset || bTempExit) |
786 bExit = TRUE; | 781 bExit = true; |
787 } | 782 } |
788 | 783 |
789 void CFFL_InteractiveFormFiller::OnPopupPostOpen(void* pPrivateData, | 784 void CFFL_InteractiveFormFiller::OnPopupPostOpen(void* pPrivateData, |
790 FX_BOOL& bExit, | 785 bool& bExit, |
791 uint32_t nFlag) { | 786 uint32_t nFlag) { |
792 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 787 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
793 ASSERT(pData); | 788 ASSERT(pData); |
794 ASSERT(pData->pWidget); | 789 ASSERT(pData->pWidget); |
795 | 790 |
796 FX_BOOL bTempReset = FALSE; | 791 bool bTempReset = false; |
797 FX_BOOL bTempExit = FALSE; | 792 bool bTempExit = false; |
798 OnPostOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag); | 793 OnPostOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag); |
799 if (bTempReset || bTempExit) | 794 if (bTempReset || bTempExit) |
800 bExit = TRUE; | 795 bExit = true; |
801 } | 796 } |
802 | 797 |
803 void CFFL_InteractiveFormFiller::OnPreOpen(CPDFSDK_Widget* pWidget, | 798 void CFFL_InteractiveFormFiller::OnPreOpen(CPDFSDK_Widget* pWidget, |
804 CPDFSDK_PageView* pPageView, | 799 CPDFSDK_PageView* pPageView, |
805 FX_BOOL& bReset, | 800 bool& bReset, |
806 FX_BOOL& bExit, | 801 bool& bExit, |
807 uint32_t nFlag) { | 802 uint32_t nFlag) { |
808 if (!m_bNotifying) { | 803 if (!m_bNotifying) { |
809 if (pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen)) { | 804 if (pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen)) { |
810 m_bNotifying = TRUE; | 805 m_bNotifying = true; |
811 int nAge = pWidget->GetAppearanceAge(); | 806 int nAge = pWidget->GetAppearanceAge(); |
812 int nValueAge = pWidget->GetValueAge(); | 807 int nValueAge = pWidget->GetValueAge(); |
813 | 808 |
814 PDFSDK_FieldAction fa; | 809 PDFSDK_FieldAction fa; |
815 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 810 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
816 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 811 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
817 | 812 |
818 pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, fa, pPageView); | 813 pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, fa, pPageView); |
819 m_bNotifying = FALSE; | 814 m_bNotifying = false; |
820 | 815 |
821 if (!IsValidAnnot(pPageView, pWidget)) { | 816 if (!IsValidAnnot(pPageView, pWidget)) { |
822 bExit = TRUE; | 817 bExit = true; |
823 return; | 818 return; |
824 } | 819 } |
825 | 820 |
826 if (nAge != pWidget->GetAppearanceAge()) { | 821 if (nAge != pWidget->GetAppearanceAge()) { |
827 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 822 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
828 pFormFiller->ResetPDFWindow(pPageView, | 823 pFormFiller->ResetPDFWindow(pPageView, |
829 nValueAge == pWidget->GetValueAge()); | 824 nValueAge == pWidget->GetValueAge()); |
830 } | 825 } |
831 | 826 |
832 bReset = TRUE; | 827 bReset = true; |
833 } | 828 } |
834 } | 829 } |
835 } | 830 } |
836 } | 831 } |
837 | 832 |
838 void CFFL_InteractiveFormFiller::OnPostOpen(CPDFSDK_Widget* pWidget, | 833 void CFFL_InteractiveFormFiller::OnPostOpen(CPDFSDK_Widget* pWidget, |
839 CPDFSDK_PageView* pPageView, | 834 CPDFSDK_PageView* pPageView, |
840 FX_BOOL& bReset, | 835 bool& bReset, |
841 FX_BOOL& bExit, | 836 bool& bExit, |
842 uint32_t nFlag) { | 837 uint32_t nFlag) { |
843 if (!m_bNotifying) { | 838 if (!m_bNotifying) { |
844 if (pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen)) { | 839 if (pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen)) { |
845 m_bNotifying = TRUE; | 840 m_bNotifying = true; |
846 int nAge = pWidget->GetAppearanceAge(); | 841 int nAge = pWidget->GetAppearanceAge(); |
847 int nValueAge = pWidget->GetValueAge(); | 842 int nValueAge = pWidget->GetValueAge(); |
848 | 843 |
849 PDFSDK_FieldAction fa; | 844 PDFSDK_FieldAction fa; |
850 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 845 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
851 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 846 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
852 | 847 |
853 pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, fa, pPageView); | 848 pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, fa, pPageView); |
854 m_bNotifying = FALSE; | 849 m_bNotifying = false; |
855 | 850 |
856 if (!IsValidAnnot(pPageView, pWidget)) { | 851 if (!IsValidAnnot(pPageView, pWidget)) { |
857 bExit = TRUE; | 852 bExit = true; |
858 return; | 853 return; |
859 } | 854 } |
860 | 855 |
861 if (nAge != pWidget->GetAppearanceAge()) { | 856 if (nAge != pWidget->GetAppearanceAge()) { |
862 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 857 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, false)) { |
863 pFormFiller->ResetPDFWindow(pPageView, | 858 pFormFiller->ResetPDFWindow(pPageView, |
864 nValueAge == pWidget->GetValueAge()); | 859 nValueAge == pWidget->GetValueAge()); |
865 } | 860 } |
866 | 861 |
867 bReset = TRUE; | 862 bReset = true; |
868 } | 863 } |
869 } | 864 } |
870 } | 865 } |
871 } | 866 } |
872 #endif // PDF_ENABLE_XFA | 867 #endif // PDF_ENABLE_XFA |
873 | 868 |
874 FX_BOOL CFFL_InteractiveFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, | 869 bool CFFL_InteractiveFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, |
875 CPDFSDK_Annot* pAnnot) { | 870 CPDFSDK_Annot* pAnnot) { |
876 return pPageView && pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); | 871 return pPageView && pPageView->IsValidAnnot(pAnnot->GetPDFAnnot()); |
877 } | 872 } |
878 | 873 |
879 void CFFL_InteractiveFormFiller::OnBeforeKeyStroke( | 874 void CFFL_InteractiveFormFiller::OnBeforeKeyStroke( |
880 void* pPrivateData, | 875 void* pPrivateData, |
881 CFX_WideString& strChange, | 876 CFX_WideString& strChange, |
882 const CFX_WideString& strChangeEx, | 877 const CFX_WideString& strChangeEx, |
883 int nSelStart, | 878 int nSelStart, |
884 int nSelEnd, | 879 int nSelEnd, |
885 FX_BOOL bKeyDown, | 880 bool bKeyDown, |
886 FX_BOOL& bRC, | 881 bool& bRC, |
887 FX_BOOL& bExit, | 882 bool& bExit, |
888 uint32_t nFlag) { | 883 uint32_t nFlag) { |
889 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; | 884 CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; |
890 ASSERT(pData->pWidget); | 885 ASSERT(pData->pWidget); |
891 | 886 |
892 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); | 887 CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, false); |
893 | 888 |
894 #ifdef PDF_ENABLE_XFA | 889 #ifdef PDF_ENABLE_XFA |
895 if (pFormFiller->IsFieldFull(pData->pPageView)) { | 890 if (pFormFiller->IsFieldFull(pData->pPageView)) { |
896 FX_BOOL bFullExit = FALSE; | 891 bool bFullExit = false; |
897 FX_BOOL bFullReset = FALSE; | 892 bool bFullReset = false; |
898 OnFull(pData->pWidget, pData->pPageView, bFullReset, bFullExit, nFlag); | 893 OnFull(pData->pWidget, pData->pPageView, bFullReset, bFullExit, nFlag); |
899 | 894 |
900 if (bFullReset || bFullExit) { | 895 if (bFullReset || bFullExit) { |
901 bExit = TRUE; | 896 bExit = true; |
902 return; | 897 return; |
903 } | 898 } |
904 } | 899 } |
905 #endif // PDF_ENABLE_XFA | 900 #endif // PDF_ENABLE_XFA |
906 | 901 |
907 if (!m_bNotifying) { | 902 if (!m_bNotifying) { |
908 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { | 903 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { |
909 m_bNotifying = TRUE; | 904 m_bNotifying = true; |
910 int nAge = pData->pWidget->GetAppearanceAge(); | 905 int nAge = pData->pWidget->GetAppearanceAge(); |
911 int nValueAge = pData->pWidget->GetValueAge(); | 906 int nValueAge = pData->pWidget->GetValueAge(); |
912 | 907 |
913 CPDFSDK_FormFillEnvironment* pFormFillEnv = | 908 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
914 pData->pPageView->GetFormFillEnv(); | 909 pData->pPageView->GetFormFillEnv(); |
915 | 910 |
916 PDFSDK_FieldAction fa; | 911 PDFSDK_FieldAction fa; |
917 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); | 912 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
918 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); | 913 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
919 fa.sChange = strChange; | 914 fa.sChange = strChange; |
920 fa.sChangeEx = strChangeEx; | 915 fa.sChangeEx = strChangeEx; |
921 fa.bKeyDown = bKeyDown; | 916 fa.bKeyDown = bKeyDown; |
922 fa.bWillCommit = FALSE; | 917 fa.bWillCommit = false; |
923 fa.bRC = TRUE; | 918 fa.bRC = true; |
924 fa.nSelStart = nSelStart; | 919 fa.nSelStart = nSelStart; |
925 fa.nSelEnd = nSelEnd; | 920 fa.nSelEnd = nSelEnd; |
926 | 921 |
927 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); | 922 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); |
928 pFormFiller->SaveState(pData->pPageView); | 923 pFormFiller->SaveState(pData->pPageView); |
929 | 924 |
930 CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget); | 925 CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget); |
931 if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, | 926 if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, |
932 pData->pPageView)) { | 927 pData->pPageView)) { |
933 if (!pObserved || !IsValidAnnot(pData->pPageView, pData->pWidget)) { | 928 if (!pObserved || !IsValidAnnot(pData->pPageView, pData->pWidget)) { |
934 bExit = TRUE; | 929 bExit = true; |
935 m_bNotifying = FALSE; | 930 m_bNotifying = false; |
936 return; | 931 return; |
937 } | 932 } |
938 | 933 |
939 if (nAge != pData->pWidget->GetAppearanceAge()) { | 934 if (nAge != pData->pWidget->GetAppearanceAge()) { |
940 CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( | 935 CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( |
941 pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); | 936 pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); |
942 pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 937 pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
943 bExit = TRUE; | 938 bExit = true; |
944 } | 939 } |
945 | 940 |
946 if (fa.bRC) { | 941 if (fa.bRC) { |
947 pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, | 942 pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, |
948 fa); | 943 fa); |
949 bRC = FALSE; | 944 bRC = false; |
950 } else { | 945 } else { |
951 pFormFiller->RestoreState(pData->pPageView); | 946 pFormFiller->RestoreState(pData->pPageView); |
952 bRC = FALSE; | 947 bRC = false; |
953 } | 948 } |
954 | 949 |
955 if (pFormFillEnv->GetFocusAnnot() != pData->pWidget) { | 950 if (pFormFillEnv->GetFocusAnnot() != pData->pWidget) { |
956 pFormFiller->CommitData(pData->pPageView, nFlag); | 951 pFormFiller->CommitData(pData->pPageView, nFlag); |
957 bExit = TRUE; | 952 bExit = true; |
958 } | 953 } |
959 } else { | 954 } else { |
960 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { | 955 if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { |
961 bExit = TRUE; | 956 bExit = true; |
962 m_bNotifying = FALSE; | 957 m_bNotifying = false; |
963 return; | 958 return; |
964 } | 959 } |
965 } | 960 } |
966 | 961 |
967 m_bNotifying = FALSE; | 962 m_bNotifying = false; |
968 } | 963 } |
969 } | 964 } |
970 } | 965 } |
OLD | NEW |