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