| 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_formfiller.h" | 21 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
| 22 #include "fpdfsdk/formfiller/cffl_listbox.h" | 22 #include "fpdfsdk/formfiller/cffl_listbox.h" |
| 23 #include "fpdfsdk/formfiller/cffl_pushbutton.h" | 23 #include "fpdfsdk/formfiller/cffl_pushbutton.h" |
| 24 #include "fpdfsdk/formfiller/cffl_radiobutton.h" | 24 #include "fpdfsdk/formfiller/cffl_radiobutton.h" |
| 25 #include "fpdfsdk/formfiller/cffl_textfield.h" | 25 #include "fpdfsdk/formfiller/cffl_textfield.h" |
| 26 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 26 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 27 | 27 |
| 28 #define FFL_MAXLISTBOXHEIGHT 140.0f | 28 #define FFL_MAXLISTBOXHEIGHT 140.0f |
| 29 | 29 |
| 30 CFFL_InteractiveFormFiller::CFFL_InteractiveFormFiller( | 30 CFFL_InteractiveFormFiller::CFFL_InteractiveFormFiller( |
| 31 CPDFSDK_FormFillEnvironment* pEnv) | 31 CPDFSDK_FormFillEnvironment* pFormFillEnv) |
| 32 : m_pEnv(pEnv), m_bNotifying(FALSE) {} | 32 : m_pFormFillEnv(pFormFillEnv), m_bNotifying(FALSE) {} |
| 33 | 33 |
| 34 CFFL_InteractiveFormFiller::~CFFL_InteractiveFormFiller() {} | 34 CFFL_InteractiveFormFiller::~CFFL_InteractiveFormFiller() {} |
| 35 | 35 |
| 36 FX_BOOL CFFL_InteractiveFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, | 36 FX_BOOL CFFL_InteractiveFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, |
| 37 CPDFSDK_Annot* pAnnot, | 37 CPDFSDK_Annot* pAnnot, |
| 38 CFX_FloatPoint point) { | 38 CFX_FloatPoint point) { |
| 39 CFX_FloatRect rc = pAnnot->GetRect(); | 39 CFX_FloatRect rc = pAnnot->GetRect(); |
| 40 return rc.Contains(point.x, point.y); | 40 return rc.Contains(point.x, point.y); |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 60 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 61 | 61 |
| 62 if (!IsVisible(pWidget)) | 62 if (!IsVisible(pWidget)) |
| 63 return; | 63 return; |
| 64 | 64 |
| 65 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { | 65 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) { |
| 66 if (pFormFiller->IsValid()) { | 66 if (pFormFiller->IsValid()) { |
| 67 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device); | 67 pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
| 68 pAnnot->GetPDFPage(); | 68 pAnnot->GetPDFPage(); |
| 69 | 69 |
| 70 CPDFSDK_Document* pDocument = m_pEnv->GetSDKDocument(); | 70 CPDFSDK_Document* pDocument = m_pFormFillEnv->GetSDKDocument(); |
| 71 if (pDocument->GetFocusAnnot() == pAnnot) { | 71 if (pDocument->GetFocusAnnot() == pAnnot) { |
| 72 CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView); | 72 CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView); |
| 73 if (!rcFocus.IsEmpty()) { | 73 if (!rcFocus.IsEmpty()) { |
| 74 CFX_PathData path; | 74 CFX_PathData path; |
| 75 path.SetPointCount(5); | 75 path.SetPointCount(5); |
| 76 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO); | 76 path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO); |
| 77 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO); | 77 path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO); |
| 78 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO); | 78 path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO); |
| 79 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO); | 79 path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO); |
| 80 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO); | 80 path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 if (!m_bNotifying) { | 130 if (!m_bNotifying) { |
| 131 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 131 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 132 if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) { | 132 if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) { |
| 133 m_bNotifying = TRUE; | 133 m_bNotifying = TRUE; |
| 134 | 134 |
| 135 int nValueAge = pWidget->GetValueAge(); | 135 int nValueAge = pWidget->GetValueAge(); |
| 136 pWidget->ClearAppModified(); | 136 pWidget->ClearAppModified(); |
| 137 ASSERT(pPageView); | 137 ASSERT(pPageView); |
| 138 | 138 |
| 139 PDFSDK_FieldAction fa; | 139 PDFSDK_FieldAction fa; |
| 140 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 140 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 141 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 141 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 142 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView); | 142 pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView); |
| 143 m_bNotifying = FALSE; | 143 m_bNotifying = FALSE; |
| 144 if (!(*pAnnot)) | 144 if (!(*pAnnot)) |
| 145 return; | 145 return; |
| 146 | 146 |
| 147 if (pWidget->IsAppModified()) { | 147 if (pWidget->IsAppModified()) { |
| 148 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 148 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 149 pFormFiller->ResetPDFWindow(pPageView, | 149 pFormFiller->ResetPDFWindow(pPageView, |
| 150 pWidget->GetValueAge() == nValueAge); | 150 pWidget->GetValueAge() == nValueAge); |
| 151 } | 151 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 164 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 164 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 165 if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) { | 165 if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) { |
| 166 m_bNotifying = TRUE; | 166 m_bNotifying = TRUE; |
| 167 pWidget->GetAppearanceAge(); | 167 pWidget->GetAppearanceAge(); |
| 168 | 168 |
| 169 int nValueAge = pWidget->GetValueAge(); | 169 int nValueAge = pWidget->GetValueAge(); |
| 170 pWidget->ClearAppModified(); | 170 pWidget->ClearAppModified(); |
| 171 ASSERT(pPageView); | 171 ASSERT(pPageView); |
| 172 | 172 |
| 173 PDFSDK_FieldAction fa; | 173 PDFSDK_FieldAction fa; |
| 174 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 174 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 175 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 175 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 176 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); | 176 pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView); |
| 177 m_bNotifying = FALSE; | 177 m_bNotifying = FALSE; |
| 178 if (!(*pAnnot)) | 178 if (!(*pAnnot)) |
| 179 return; | 179 return; |
| 180 | 180 |
| 181 if (pWidget->IsAppModified()) { | 181 if (pWidget->IsAppModified()) { |
| 182 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 182 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 183 pFormFiller->ResetPDFWindow(pPageView, | 183 pFormFiller->ResetPDFWindow(pPageView, |
| 184 nValueAge == pWidget->GetValueAge()); | 184 nValueAge == pWidget->GetValueAge()); |
| 185 } | 185 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 201 if (Annot_HitTest(pPageView, pAnnot->Get(), point) && | 201 if (Annot_HitTest(pPageView, pAnnot->Get(), point) && |
| 202 pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) { | 202 pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) { |
| 203 m_bNotifying = TRUE; | 203 m_bNotifying = TRUE; |
| 204 pWidget->GetAppearanceAge(); | 204 pWidget->GetAppearanceAge(); |
| 205 | 205 |
| 206 int nValueAge = pWidget->GetValueAge(); | 206 int nValueAge = pWidget->GetValueAge(); |
| 207 pWidget->ClearAppModified(); | 207 pWidget->ClearAppModified(); |
| 208 ASSERT(pPageView); | 208 ASSERT(pPageView); |
| 209 | 209 |
| 210 PDFSDK_FieldAction fa; | 210 PDFSDK_FieldAction fa; |
| 211 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlags); | 211 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlags); |
| 212 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlags); | 212 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlags); |
| 213 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); | 213 pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView); |
| 214 m_bNotifying = FALSE; | 214 m_bNotifying = FALSE; |
| 215 if (!(*pAnnot)) | 215 if (!(*pAnnot)) |
| 216 return TRUE; | 216 return TRUE; |
| 217 | 217 |
| 218 if (!IsValidAnnot(pPageView, pAnnot->Get())) | 218 if (!IsValidAnnot(pPageView, pAnnot->Get())) |
| 219 return TRUE; | 219 return TRUE; |
| 220 | 220 |
| 221 if (pWidget->IsAppModified()) { | 221 if (pWidget->IsAppModified()) { |
| 222 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 222 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 223 pFormFiller->ResetPDFWindow(pPageView, | 223 pFormFiller->ResetPDFWindow(pPageView, |
| 224 nValueAge == pWidget->GetValueAge()); | 224 nValueAge == pWidget->GetValueAge()); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE)) | 229 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot->Get(), FALSE)) |
| 230 return pFormFiller->OnLButtonDown(pPageView, pAnnot->Get(), nFlags, point); | 230 return pFormFiller->OnLButtonDown(pPageView, pAnnot->Get(), nFlags, point); |
| 231 | 231 |
| 232 return FALSE; | 232 return FALSE; |
| 233 } | 233 } |
| 234 | 234 |
| 235 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonUp( | 235 FX_BOOL CFFL_InteractiveFormFiller::OnLButtonUp( |
| 236 CPDFSDK_PageView* pPageView, | 236 CPDFSDK_PageView* pPageView, |
| 237 CPDFSDK_Annot::ObservedPtr* pAnnot, | 237 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 238 uint32_t nFlags, | 238 uint32_t nFlags, |
| 239 const CFX_FloatPoint& point) { | 239 const CFX_FloatPoint& point) { |
| 240 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); | 240 ASSERT((*pAnnot)->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); |
| 241 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 241 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 242 CPDFSDK_Document* pDocument = m_pEnv->GetSDKDocument(); | 242 CPDFSDK_Document* pDocument = m_pFormFillEnv->GetSDKDocument(); |
| 243 | 243 |
| 244 switch (pWidget->GetFieldType()) { | 244 switch (pWidget->GetFieldType()) { |
| 245 case FIELDTYPE_PUSHBUTTON: | 245 case FIELDTYPE_PUSHBUTTON: |
| 246 case FIELDTYPE_CHECKBOX: | 246 case FIELDTYPE_CHECKBOX: |
| 247 case FIELDTYPE_RADIOBUTTON: | 247 case FIELDTYPE_RADIOBUTTON: |
| 248 if (GetViewBBox(pPageView, pAnnot->Get()) | 248 if (GetViewBBox(pPageView, pAnnot->Get()) |
| 249 .Contains((int)point.x, (int)point.y)) | 249 .Contains((int)point.x, (int)point.y)) |
| 250 pDocument->SetFocusAnnot(pAnnot); | 250 pDocument->SetFocusAnnot(pAnnot); |
| 251 break; | 251 break; |
| 252 default: | 252 default: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 281 if (!m_bNotifying) { | 281 if (!m_bNotifying) { |
| 282 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 282 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 283 if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) { | 283 if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) { |
| 284 m_bNotifying = TRUE; | 284 m_bNotifying = TRUE; |
| 285 | 285 |
| 286 int nAge = pWidget->GetAppearanceAge(); | 286 int nAge = pWidget->GetAppearanceAge(); |
| 287 int nValueAge = pWidget->GetValueAge(); | 287 int nValueAge = pWidget->GetValueAge(); |
| 288 ASSERT(pPageView); | 288 ASSERT(pPageView); |
| 289 | 289 |
| 290 PDFSDK_FieldAction fa; | 290 PDFSDK_FieldAction fa; |
| 291 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 291 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 292 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 292 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 293 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); | 293 pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView); |
| 294 m_bNotifying = FALSE; | 294 m_bNotifying = FALSE; |
| 295 if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget)) { | 295 if (!(*pAnnot) || !IsValidAnnot(pPageView, pWidget)) { |
| 296 bExit = TRUE; | 296 bExit = TRUE; |
| 297 return; | 297 return; |
| 298 } | 298 } |
| 299 if (nAge != pWidget->GetAppearanceAge()) { | 299 if (nAge != pWidget->GetAppearanceAge()) { |
| 300 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { | 300 if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) { |
| 301 pFormFiller->ResetPDFWindow(pPageView, | 301 pFormFiller->ResetPDFWindow(pPageView, |
| 302 nValueAge == pWidget->GetValueAge()); | 302 nValueAge == pWidget->GetValueAge()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 pWidget->ClearAppModified(); | 406 pWidget->ClearAppModified(); |
| 407 | 407 |
| 408 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE); | 408 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE); |
| 409 if (!pFormFiller) | 409 if (!pFormFiller) |
| 410 return FALSE; | 410 return FALSE; |
| 411 | 411 |
| 412 CPDFSDK_PageView* pPageView = (*pAnnot)->GetPageView(); | 412 CPDFSDK_PageView* pPageView = (*pAnnot)->GetPageView(); |
| 413 ASSERT(pPageView); | 413 ASSERT(pPageView); |
| 414 | 414 |
| 415 PDFSDK_FieldAction fa; | 415 PDFSDK_FieldAction fa; |
| 416 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 416 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 417 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 417 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 418 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); | 418 pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa); |
| 419 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); | 419 pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView); |
| 420 m_bNotifying = FALSE; | 420 m_bNotifying = FALSE; |
| 421 if (!(*pAnnot)) | 421 if (!(*pAnnot)) |
| 422 return FALSE; | 422 return FALSE; |
| 423 | 423 |
| 424 if (pWidget->IsAppModified()) { | 424 if (pWidget->IsAppModified()) { |
| 425 if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, FALSE)) { | 425 if (CFFL_FormFiller* pFiller = GetFormFiller(pWidget, FALSE)) { |
| 426 pFiller->ResetPDFWindow(pPageView, | 426 pFiller->ResetPDFWindow(pPageView, |
| 427 nValueAge == pWidget->GetValueAge()); | 427 nValueAge == pWidget->GetValueAge()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 448 if (!m_bNotifying) { | 448 if (!m_bNotifying) { |
| 449 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 449 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 450 if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) { | 450 if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) { |
| 451 m_bNotifying = TRUE; | 451 m_bNotifying = TRUE; |
| 452 pWidget->ClearAppModified(); | 452 pWidget->ClearAppModified(); |
| 453 | 453 |
| 454 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | 454 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); |
| 455 ASSERT(pPageView); | 455 ASSERT(pPageView); |
| 456 | 456 |
| 457 PDFSDK_FieldAction fa; | 457 PDFSDK_FieldAction fa; |
| 458 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 458 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 459 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 459 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 460 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); | 460 pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa); |
| 461 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); | 461 pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView); |
| 462 m_bNotifying = FALSE; | 462 m_bNotifying = FALSE; |
| 463 if (!(*pAnnot)) | 463 if (!(*pAnnot)) |
| 464 return FALSE; | 464 return FALSE; |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 return TRUE; | 468 return TRUE; |
| 469 } | 469 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 497 return it->second.get(); | 497 return it->second.get(); |
| 498 | 498 |
| 499 if (!bRegister) | 499 if (!bRegister) |
| 500 return nullptr; | 500 return nullptr; |
| 501 | 501 |
| 502 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 502 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 503 int nFieldType = pWidget->GetFieldType(); | 503 int nFieldType = pWidget->GetFieldType(); |
| 504 CFFL_FormFiller* pFormFiller; | 504 CFFL_FormFiller* pFormFiller; |
| 505 switch (nFieldType) { | 505 switch (nFieldType) { |
| 506 case FIELDTYPE_PUSHBUTTON: | 506 case FIELDTYPE_PUSHBUTTON: |
| 507 pFormFiller = new CFFL_PushButton(m_pEnv, pWidget); | 507 pFormFiller = new CFFL_PushButton(m_pFormFillEnv, pWidget); |
| 508 break; | 508 break; |
| 509 case FIELDTYPE_CHECKBOX: | 509 case FIELDTYPE_CHECKBOX: |
| 510 pFormFiller = new CFFL_CheckBox(m_pEnv, pWidget); | 510 pFormFiller = new CFFL_CheckBox(m_pFormFillEnv, pWidget); |
| 511 break; | 511 break; |
| 512 case FIELDTYPE_RADIOBUTTON: | 512 case FIELDTYPE_RADIOBUTTON: |
| 513 pFormFiller = new CFFL_RadioButton(m_pEnv, pWidget); | 513 pFormFiller = new CFFL_RadioButton(m_pFormFillEnv, pWidget); |
| 514 break; | 514 break; |
| 515 case FIELDTYPE_TEXTFIELD: | 515 case FIELDTYPE_TEXTFIELD: |
| 516 pFormFiller = new CFFL_TextField(m_pEnv, pWidget); | 516 pFormFiller = new CFFL_TextField(m_pFormFillEnv, pWidget); |
| 517 break; | 517 break; |
| 518 case FIELDTYPE_LISTBOX: | 518 case FIELDTYPE_LISTBOX: |
| 519 pFormFiller = new CFFL_ListBox(m_pEnv, pWidget); | 519 pFormFiller = new CFFL_ListBox(m_pFormFillEnv, pWidget); |
| 520 break; | 520 break; |
| 521 case FIELDTYPE_COMBOBOX: | 521 case FIELDTYPE_COMBOBOX: |
| 522 pFormFiller = new CFFL_ComboBox(m_pEnv, pWidget); | 522 pFormFiller = new CFFL_ComboBox(m_pFormFillEnv, pWidget); |
| 523 break; | 523 break; |
| 524 case FIELDTYPE_UNKNOWN: | 524 case FIELDTYPE_UNKNOWN: |
| 525 default: | 525 default: |
| 526 pFormFiller = nullptr; | 526 pFormFiller = nullptr; |
| 527 break; | 527 break; |
| 528 } | 528 } |
| 529 | 529 |
| 530 if (!pFormFiller) | 530 if (!pFormFiller) |
| 531 return nullptr; | 531 return nullptr; |
| 532 | 532 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 FX_BOOL& bExit, | 628 FX_BOOL& bExit, |
| 629 uint32_t nFlag) { | 629 uint32_t nFlag) { |
| 630 if (!m_bNotifying) { | 630 if (!m_bNotifying) { |
| 631 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 631 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 632 if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { | 632 if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { |
| 633 ASSERT(pPageView); | 633 ASSERT(pPageView); |
| 634 m_bNotifying = TRUE; | 634 m_bNotifying = TRUE; |
| 635 pWidget->ClearAppModified(); | 635 pWidget->ClearAppModified(); |
| 636 | 636 |
| 637 PDFSDK_FieldAction fa; | 637 PDFSDK_FieldAction fa; |
| 638 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 638 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 639 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 639 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 640 fa.bWillCommit = TRUE; | 640 fa.bWillCommit = TRUE; |
| 641 fa.bKeyDown = TRUE; | 641 fa.bKeyDown = TRUE; |
| 642 fa.bRC = TRUE; | 642 fa.bRC = TRUE; |
| 643 | 643 |
| 644 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); | 644 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); |
| 645 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); | 645 pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa); |
| 646 pFormFiller->SaveState(pPageView); | 646 pFormFiller->SaveState(pPageView); |
| 647 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); | 647 pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView); |
| 648 if (!(*pAnnot)) | 648 if (!(*pAnnot)) |
| 649 return; | 649 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 660 FX_BOOL& bExit, | 660 FX_BOOL& bExit, |
| 661 uint32_t nFlag) { | 661 uint32_t nFlag) { |
| 662 if (!m_bNotifying) { | 662 if (!m_bNotifying) { |
| 663 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); | 663 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot->Get()); |
| 664 if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) { | 664 if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) { |
| 665 ASSERT(pPageView); | 665 ASSERT(pPageView); |
| 666 m_bNotifying = TRUE; | 666 m_bNotifying = TRUE; |
| 667 pWidget->ClearAppModified(); | 667 pWidget->ClearAppModified(); |
| 668 | 668 |
| 669 PDFSDK_FieldAction fa; | 669 PDFSDK_FieldAction fa; |
| 670 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 670 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 671 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 671 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 672 fa.bKeyDown = TRUE; | 672 fa.bKeyDown = TRUE; |
| 673 fa.bRC = TRUE; | 673 fa.bRC = TRUE; |
| 674 | 674 |
| 675 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); | 675 CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE); |
| 676 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); | 676 pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa); |
| 677 pFormFiller->SaveState(pPageView); | 677 pFormFiller->SaveState(pPageView); |
| 678 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); | 678 pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView); |
| 679 if (!(*pAnnot)) | 679 if (!(*pAnnot)) |
| 680 return; | 680 return; |
| 681 | 681 |
| 682 bRC = fa.bRC; | 682 bRC = fa.bRC; |
| 683 m_bNotifying = FALSE; | 683 m_bNotifying = FALSE; |
| 684 } | 684 } |
| 685 } | 685 } |
| 686 } | 686 } |
| 687 | 687 |
| 688 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, | 688 void CFFL_InteractiveFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, |
| 689 CPDFSDK_PageView* pPageView, | 689 CPDFSDK_PageView* pPageView, |
| 690 FX_BOOL& bExit, | 690 FX_BOOL& bExit, |
| 691 uint32_t nFlag) { | 691 uint32_t nFlag) { |
| 692 if (!m_bNotifying) { | 692 if (!m_bNotifying) { |
| 693 ASSERT(pWidget); | 693 ASSERT(pWidget); |
| 694 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 694 pPageView->GetFormFillEnv()->GetInterForm()->OnCalculate( |
| 695 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 695 pWidget->GetFormField()); |
| 696 pInterForm->OnCalculate(pWidget->GetFormField()); | |
| 697 m_bNotifying = FALSE; | 696 m_bNotifying = FALSE; |
| 698 } | 697 } |
| 699 } | 698 } |
| 700 | 699 |
| 701 void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Widget* pWidget, | 700 void CFFL_InteractiveFormFiller::OnFormat(CPDFSDK_Widget* pWidget, |
| 702 CPDFSDK_PageView* pPageView, | 701 CPDFSDK_PageView* pPageView, |
| 703 FX_BOOL& bExit, | 702 FX_BOOL& bExit, |
| 704 uint32_t nFlag) { | 703 uint32_t nFlag) { |
| 705 if (!m_bNotifying) { | 704 if (!m_bNotifying) { |
| 706 ASSERT(pWidget); | 705 ASSERT(pWidget); |
| 707 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 706 CPDFSDK_InterForm* pInterForm = pPageView->GetFormFillEnv()->GetInterForm(); |
| 708 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | |
| 709 | 707 |
| 710 FX_BOOL bFormatted = FALSE; | 708 FX_BOOL bFormatted = FALSE; |
| 711 CFX_WideString sValue = | 709 CFX_WideString sValue = |
| 712 pInterForm->OnFormat(pWidget->GetFormField(), bFormatted); | 710 pInterForm->OnFormat(pWidget->GetFormField(), bFormatted); |
| 713 | 711 |
| 714 if (bExit) | 712 if (bExit) |
| 715 return; | 713 return; |
| 716 | 714 |
| 717 if (bFormatted) { | 715 if (bFormatted) { |
| 718 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), &sValue, TRUE); | 716 pInterForm->ResetFieldAppearance(pWidget->GetFormField(), &sValue, TRUE); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 729 FX_BOOL& bReset, | 727 FX_BOOL& bReset, |
| 730 FX_BOOL& bExit, | 728 FX_BOOL& bExit, |
| 731 uint32_t nFlag) { | 729 uint32_t nFlag) { |
| 732 if (!m_bNotifying) { | 730 if (!m_bNotifying) { |
| 733 if (pWidget->HasXFAAAction(PDFSDK_XFA_Click)) { | 731 if (pWidget->HasXFAAAction(PDFSDK_XFA_Click)) { |
| 734 m_bNotifying = TRUE; | 732 m_bNotifying = TRUE; |
| 735 int nAge = pWidget->GetAppearanceAge(); | 733 int nAge = pWidget->GetAppearanceAge(); |
| 736 int nValueAge = pWidget->GetValueAge(); | 734 int nValueAge = pWidget->GetValueAge(); |
| 737 | 735 |
| 738 PDFSDK_FieldAction fa; | 736 PDFSDK_FieldAction fa; |
| 739 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 737 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 740 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 738 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 741 | 739 |
| 742 pWidget->OnXFAAAction(PDFSDK_XFA_Click, fa, pPageView); | 740 pWidget->OnXFAAAction(PDFSDK_XFA_Click, fa, pPageView); |
| 743 m_bNotifying = FALSE; | 741 m_bNotifying = FALSE; |
| 744 | 742 |
| 745 if (!IsValidAnnot(pPageView, pWidget)) { | 743 if (!IsValidAnnot(pPageView, pWidget)) { |
| 746 bExit = TRUE; | 744 bExit = TRUE; |
| 747 return; | 745 return; |
| 748 } | 746 } |
| 749 | 747 |
| 750 if (nAge != pWidget->GetAppearanceAge()) { | 748 if (nAge != pWidget->GetAppearanceAge()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 764 FX_BOOL& bReset, | 762 FX_BOOL& bReset, |
| 765 FX_BOOL& bExit, | 763 FX_BOOL& bExit, |
| 766 uint32_t nFlag) { | 764 uint32_t nFlag) { |
| 767 if (!m_bNotifying) { | 765 if (!m_bNotifying) { |
| 768 if (pWidget->HasXFAAAction(PDFSDK_XFA_Full)) { | 766 if (pWidget->HasXFAAAction(PDFSDK_XFA_Full)) { |
| 769 m_bNotifying = TRUE; | 767 m_bNotifying = TRUE; |
| 770 int nAge = pWidget->GetAppearanceAge(); | 768 int nAge = pWidget->GetAppearanceAge(); |
| 771 int nValueAge = pWidget->GetValueAge(); | 769 int nValueAge = pWidget->GetValueAge(); |
| 772 | 770 |
| 773 PDFSDK_FieldAction fa; | 771 PDFSDK_FieldAction fa; |
| 774 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 772 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 775 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 773 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 776 | 774 |
| 777 pWidget->OnXFAAAction(PDFSDK_XFA_Full, fa, pPageView); | 775 pWidget->OnXFAAAction(PDFSDK_XFA_Full, fa, pPageView); |
| 778 m_bNotifying = FALSE; | 776 m_bNotifying = FALSE; |
| 779 | 777 |
| 780 if (!IsValidAnnot(pPageView, pWidget)) { | 778 if (!IsValidAnnot(pPageView, pWidget)) { |
| 781 bExit = TRUE; | 779 bExit = TRUE; |
| 782 return; | 780 return; |
| 783 } | 781 } |
| 784 | 782 |
| 785 if (nAge != pWidget->GetAppearanceAge()) { | 783 if (nAge != pWidget->GetAppearanceAge()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 FX_BOOL& bReset, | 825 FX_BOOL& bReset, |
| 828 FX_BOOL& bExit, | 826 FX_BOOL& bExit, |
| 829 uint32_t nFlag) { | 827 uint32_t nFlag) { |
| 830 if (!m_bNotifying) { | 828 if (!m_bNotifying) { |
| 831 if (pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen)) { | 829 if (pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen)) { |
| 832 m_bNotifying = TRUE; | 830 m_bNotifying = TRUE; |
| 833 int nAge = pWidget->GetAppearanceAge(); | 831 int nAge = pWidget->GetAppearanceAge(); |
| 834 int nValueAge = pWidget->GetValueAge(); | 832 int nValueAge = pWidget->GetValueAge(); |
| 835 | 833 |
| 836 PDFSDK_FieldAction fa; | 834 PDFSDK_FieldAction fa; |
| 837 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 835 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 838 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 836 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 839 | 837 |
| 840 pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, fa, pPageView); | 838 pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, fa, pPageView); |
| 841 m_bNotifying = FALSE; | 839 m_bNotifying = FALSE; |
| 842 | 840 |
| 843 if (!IsValidAnnot(pPageView, pWidget)) { | 841 if (!IsValidAnnot(pPageView, pWidget)) { |
| 844 bExit = TRUE; | 842 bExit = TRUE; |
| 845 return; | 843 return; |
| 846 } | 844 } |
| 847 | 845 |
| 848 if (nAge != pWidget->GetAppearanceAge()) { | 846 if (nAge != pWidget->GetAppearanceAge()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 862 FX_BOOL& bReset, | 860 FX_BOOL& bReset, |
| 863 FX_BOOL& bExit, | 861 FX_BOOL& bExit, |
| 864 uint32_t nFlag) { | 862 uint32_t nFlag) { |
| 865 if (!m_bNotifying) { | 863 if (!m_bNotifying) { |
| 866 if (pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen)) { | 864 if (pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen)) { |
| 867 m_bNotifying = TRUE; | 865 m_bNotifying = TRUE; |
| 868 int nAge = pWidget->GetAppearanceAge(); | 866 int nAge = pWidget->GetAppearanceAge(); |
| 869 int nValueAge = pWidget->GetValueAge(); | 867 int nValueAge = pWidget->GetValueAge(); |
| 870 | 868 |
| 871 PDFSDK_FieldAction fa; | 869 PDFSDK_FieldAction fa; |
| 872 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 870 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 873 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 871 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 874 | 872 |
| 875 pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, fa, pPageView); | 873 pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, fa, pPageView); |
| 876 m_bNotifying = FALSE; | 874 m_bNotifying = FALSE; |
| 877 | 875 |
| 878 if (!IsValidAnnot(pPageView, pWidget)) { | 876 if (!IsValidAnnot(pPageView, pWidget)) { |
| 879 bExit = TRUE; | 877 bExit = TRUE; |
| 880 return; | 878 return; |
| 881 } | 879 } |
| 882 | 880 |
| 883 if (nAge != pWidget->GetAppearanceAge()) { | 881 if (nAge != pWidget->GetAppearanceAge()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 } | 923 } |
| 926 } | 924 } |
| 927 #endif // PDF_ENABLE_XFA | 925 #endif // PDF_ENABLE_XFA |
| 928 | 926 |
| 929 if (!m_bNotifying) { | 927 if (!m_bNotifying) { |
| 930 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { | 928 if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { |
| 931 m_bNotifying = TRUE; | 929 m_bNotifying = TRUE; |
| 932 int nAge = pData->pWidget->GetAppearanceAge(); | 930 int nAge = pData->pWidget->GetAppearanceAge(); |
| 933 int nValueAge = pData->pWidget->GetValueAge(); | 931 int nValueAge = pData->pWidget->GetValueAge(); |
| 934 | 932 |
| 935 CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument(); | 933 CPDFSDK_Document* pDocument = |
| 934 pData->pPageView->GetFormFillEnv()->GetSDKDocument(); |
| 936 | 935 |
| 937 PDFSDK_FieldAction fa; | 936 PDFSDK_FieldAction fa; |
| 938 fa.bModifier = m_pEnv->IsCTRLKeyDown(nFlag); | 937 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); |
| 939 fa.bShift = m_pEnv->IsSHIFTKeyDown(nFlag); | 938 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); |
| 940 fa.sChange = strChange; | 939 fa.sChange = strChange; |
| 941 fa.sChangeEx = strChangeEx; | 940 fa.sChangeEx = strChangeEx; |
| 942 fa.bKeyDown = bKeyDown; | 941 fa.bKeyDown = bKeyDown; |
| 943 fa.bWillCommit = FALSE; | 942 fa.bWillCommit = FALSE; |
| 944 fa.bRC = TRUE; | 943 fa.bRC = TRUE; |
| 945 fa.nSelStart = nSelStart; | 944 fa.nSelStart = nSelStart; |
| 946 fa.nSelEnd = nSelEnd; | 945 fa.nSelEnd = nSelEnd; |
| 947 | 946 |
| 948 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); | 947 pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); |
| 949 pFormFiller->SaveState(pData->pPageView); | 948 pFormFiller->SaveState(pData->pPageView); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 bExit = TRUE; | 981 bExit = TRUE; |
| 983 m_bNotifying = FALSE; | 982 m_bNotifying = FALSE; |
| 984 return; | 983 return; |
| 985 } | 984 } |
| 986 } | 985 } |
| 987 | 986 |
| 988 m_bNotifying = FALSE; | 987 m_bNotifying = FALSE; |
| 989 } | 988 } |
| 990 } | 989 } |
| 991 } | 990 } |
| OLD | NEW |