| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdfsdk_widget.h" | 7 #include "fpdfsdk/cpdfsdk_widget.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 11 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
| 12 #include "core/fpdfapi/parser/cpdf_document.h" | 12 #include "core/fpdfapi/parser/cpdf_document.h" |
| 13 #include "core/fpdfapi/parser/cpdf_stream.h" | 13 #include "core/fpdfapi/parser/cpdf_stream.h" |
| 14 #include "core/fpdfdoc/cpdf_defaultappearance.h" | 14 #include "core/fpdfdoc/cpdf_defaultappearance.h" |
| 15 #include "core/fpdfdoc/cpdf_formcontrol.h" | 15 #include "core/fpdfdoc/cpdf_formcontrol.h" |
| 16 #include "core/fpdfdoc/cpdf_formfield.h" | 16 #include "core/fpdfdoc/cpdf_formfield.h" |
| 17 #include "core/fpdfdoc/cpdf_iconfit.h" | 17 #include "core/fpdfdoc/cpdf_iconfit.h" |
| 18 #include "core/fpdfdoc/cpdf_interform.h" | 18 #include "core/fpdfdoc/cpdf_interform.h" |
| 19 #include "core/fxge/cfx_graphstatedata.h" | 19 #include "core/fxge/cfx_graphstatedata.h" |
| 20 #include "core/fxge/cfx_pathdata.h" | 20 #include "core/fxge/cfx_pathdata.h" |
| 21 #include "core/fxge/cfx_renderdevice.h" | 21 #include "core/fxge/cfx_renderdevice.h" |
| 22 #include "fpdfsdk/cpdfsdk_document.h" | |
| 23 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 22 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 24 #include "fpdfsdk/cpdfsdk_interform.h" | 23 #include "fpdfsdk/cpdfsdk_interform.h" |
| 25 #include "fpdfsdk/cpdfsdk_pageview.h" | 24 #include "fpdfsdk/cpdfsdk_pageview.h" |
| 26 #include "fpdfsdk/formfiller/cba_fontmap.h" | 25 #include "fpdfsdk/formfiller/cba_fontmap.h" |
| 27 #include "fpdfsdk/fsdk_actionhandler.h" | 26 #include "fpdfsdk/fsdk_actionhandler.h" |
| 28 #include "fpdfsdk/fsdk_define.h" | 27 #include "fpdfsdk/fsdk_define.h" |
| 29 #include "fpdfsdk/fxedit/fxet_edit.h" | 28 #include "fpdfsdk/fxedit/fxet_edit.h" |
| 30 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 29 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 31 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 30 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 32 | 31 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 m_hMixXFAWidget(nullptr), | 61 m_hMixXFAWidget(nullptr), |
| 63 m_pWidgetHandler(nullptr) | 62 m_pWidgetHandler(nullptr) |
| 64 #endif // PDF_ENABLE_XFA | 63 #endif // PDF_ENABLE_XFA |
| 65 { | 64 { |
| 66 } | 65 } |
| 67 | 66 |
| 68 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 67 CPDFSDK_Widget::~CPDFSDK_Widget() {} |
| 69 | 68 |
| 70 #ifdef PDF_ENABLE_XFA | 69 #ifdef PDF_ENABLE_XFA |
| 71 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { | 70 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { |
| 72 CPDFXFA_Document* pDoc = | 71 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 73 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 74 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 72 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 75 if (!m_hMixXFAWidget) { | 73 if (!m_hMixXFAWidget) { |
| 76 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 74 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 77 CFX_WideString sName; | 75 CFX_WideString sName; |
| 78 if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 76 if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
| 79 sName = GetAnnotName(); | 77 sName = GetAnnotName(); |
| 80 if (sName.IsEmpty()) | 78 if (sName.IsEmpty()) |
| 81 sName = GetName(); | 79 sName = GetName(); |
| 82 } else { | 80 } else { |
| 83 sName = GetName(); | 81 sName = GetName(); |
| 84 } | 82 } |
| 85 | 83 |
| 86 if (!sName.IsEmpty()) | 84 if (!sName.IsEmpty()) |
| 87 m_hMixXFAWidget = pDocView->GetWidgetByName(sName, nullptr); | 85 m_hMixXFAWidget = pDocView->GetWidgetByName(sName, nullptr); |
| 88 } | 86 } |
| 89 } | 87 } |
| 90 return m_hMixXFAWidget; | 88 return m_hMixXFAWidget; |
| 91 } | 89 } |
| 92 | 90 |
| 93 return nullptr; | 91 return nullptr; |
| 94 } | 92 } |
| 95 | 93 |
| 96 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { | 94 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { |
| 97 CPDFXFA_Document* pDoc = | 95 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 98 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 99 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 96 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 100 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 97 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
| 101 CFX_WideString sName = GetName(); | 98 CFX_WideString sName = GetName(); |
| 102 if (!sName.IsEmpty()) | 99 if (!sName.IsEmpty()) |
| 103 return pDocView->GetWidgetByName(sName, nullptr); | 100 return pDocView->GetWidgetByName(sName, nullptr); |
| 104 } | 101 } |
| 105 } | 102 } |
| 106 | 103 |
| 107 return nullptr; | 104 return nullptr; |
| 108 } | 105 } |
| 109 | 106 |
| 110 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { | 107 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { |
| 111 CPDFXFA_Document* pDoc = | 108 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 112 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 113 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 109 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 114 if (!m_pWidgetHandler) { | 110 if (!m_pWidgetHandler) { |
| 115 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) | 111 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) |
| 116 m_pWidgetHandler = pDocView->GetWidgetHandler(); | 112 m_pWidgetHandler = pDocView->GetWidgetHandler(); |
| 117 } | 113 } |
| 118 return m_pWidgetHandler; | 114 return m_pWidgetHandler; |
| 119 } | 115 } |
| 120 | 116 |
| 121 return nullptr; | 117 return nullptr; |
| 122 } | 118 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 212 } |
| 217 } | 213 } |
| 218 | 214 |
| 219 pAcc = hWidget->GetDataAcc(); | 215 pAcc = hWidget->GetDataAcc(); |
| 220 return pXFAWidgetHandler->HasEvent(pAcc, eEventType); | 216 return pXFAWidgetHandler->HasEvent(pAcc, eEventType); |
| 221 } | 217 } |
| 222 | 218 |
| 223 FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, | 219 FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, |
| 224 PDFSDK_FieldAction& data, | 220 PDFSDK_FieldAction& data, |
| 225 CPDFSDK_PageView* pPageView) { | 221 CPDFSDK_PageView* pPageView) { |
| 226 CPDFXFA_Document* pDoc = | 222 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 227 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 228 | 223 |
| 229 CXFA_FFWidget* hWidget = GetMixXFAWidget(); | 224 CXFA_FFWidget* hWidget = GetMixXFAWidget(); |
| 230 if (!hWidget) | 225 if (!hWidget) |
| 231 return FALSE; | 226 return FALSE; |
| 232 | 227 |
| 233 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); | 228 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); |
| 234 if (eEventType == XFA_EVENT_Unknown) | 229 if (eEventType == XFA_EVENT_Unknown) |
| 235 return FALSE; | 230 return FALSE; |
| 236 | 231 |
| 237 CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler(); | 232 CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); | 315 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); |
| 321 break; | 316 break; |
| 322 } | 317 } |
| 323 } | 318 } |
| 324 | 319 |
| 325 if (bSynchronizeElse) | 320 if (bSynchronizeElse) |
| 326 pWidgetAcc->ProcessValueChanged(); | 321 pWidgetAcc->ProcessValueChanged(); |
| 327 } | 322 } |
| 328 | 323 |
| 329 void CPDFSDK_Widget::SynchronizeXFAValue() { | 324 void CPDFSDK_Widget::SynchronizeXFAValue() { |
| 330 CPDFXFA_Document* pDoc = | 325 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 331 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 332 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); | 326 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); |
| 333 if (!pXFADocView) | 327 if (!pXFADocView) |
| 334 return; | 328 return; |
| 335 | 329 |
| 336 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 330 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 337 if (GetXFAWidgetHandler()) { | 331 if (GetXFAWidgetHandler()) { |
| 338 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), | 332 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), |
| 339 GetFormControl()); | 333 GetFormControl()); |
| 340 } | 334 } |
| 341 } | 335 } |
| 342 } | 336 } |
| 343 | 337 |
| 344 void CPDFSDK_Widget::SynchronizeXFAItems() { | 338 void CPDFSDK_Widget::SynchronizeXFAItems() { |
| 345 CPDFXFA_Document* pDoc = | 339 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 346 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 347 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); | 340 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); |
| 348 if (!pXFADocView) | 341 if (!pXFADocView) |
| 349 return; | 342 return; |
| 350 | 343 |
| 351 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 344 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 352 if (GetXFAWidgetHandler()) | 345 if (GetXFAWidgetHandler()) |
| 353 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); | 346 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); |
| 354 } | 347 } |
| 355 } | 348 } |
| 356 | 349 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 return TRUE; | 495 return TRUE; |
| 503 } | 496 } |
| 504 | 497 |
| 505 int CPDFSDK_Widget::GetFieldType() const { | 498 int CPDFSDK_Widget::GetFieldType() const { |
| 506 CPDF_FormField* pField = GetFormField(); | 499 CPDF_FormField* pField = GetFormField(); |
| 507 return pField ? pField->GetFieldType() : FIELDTYPE_UNKNOWN; | 500 return pField ? pField->GetFieldType() : FIELDTYPE_UNKNOWN; |
| 508 } | 501 } |
| 509 | 502 |
| 510 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { | 503 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { |
| 511 #ifdef PDF_ENABLE_XFA | 504 #ifdef PDF_ENABLE_XFA |
| 512 CPDFXFA_Document* pDoc = | 505 CPDFXFA_Document* pDoc = m_pPageView->GetFormFillEnv()->GetXFADocument(); |
| 513 m_pPageView->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 514 int nDocType = pDoc->GetDocType(); | 506 int nDocType = pDoc->GetDocType(); |
| 515 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) | 507 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) |
| 516 return TRUE; | 508 return TRUE; |
| 517 #endif // PDF_ENABLE_XFA | 509 #endif // PDF_ENABLE_XFA |
| 518 return CPDFSDK_BAAnnot::IsAppearanceValid(); | 510 return CPDFSDK_BAAnnot::IsAppearanceValid(); |
| 519 } | 511 } |
| 520 | 512 |
| 521 int CPDFSDK_Widget::GetLayoutOrder() const { | 513 int CPDFSDK_Widget::GetLayoutOrder() const { |
| 522 return 2; | 514 return 2; |
| 523 } | 515 } |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) | 1819 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) |
| 1828 pAPDict->RemoveFor(sAPType); | 1820 pAPDict->RemoveFor(sAPType); |
| 1829 } | 1821 } |
| 1830 | 1822 |
| 1831 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1823 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
| 1832 PDFSDK_FieldAction& data, | 1824 PDFSDK_FieldAction& data, |
| 1833 CPDFSDK_PageView* pPageView) { | 1825 CPDFSDK_PageView* pPageView) { |
| 1834 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv(); | 1826 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv(); |
| 1835 | 1827 |
| 1836 #ifdef PDF_ENABLE_XFA | 1828 #ifdef PDF_ENABLE_XFA |
| 1837 CPDFXFA_Document* pDoc = pFormFillEnv->GetSDKDocument()->GetXFADocument(); | 1829 CPDFXFA_Document* pDoc = pFormFillEnv->GetXFADocument(); |
| 1838 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 1830 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
| 1839 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); | 1831 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); |
| 1840 | 1832 |
| 1841 if (eEventType != XFA_EVENT_Unknown) { | 1833 if (eEventType != XFA_EVENT_Unknown) { |
| 1842 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 1834 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
| 1843 CXFA_EventParam param; | 1835 CXFA_EventParam param; |
| 1844 param.m_eType = eEventType; | 1836 param.m_eType = eEventType; |
| 1845 param.m_wsChange = data.sChange; | 1837 param.m_wsChange = data.sChange; |
| 1846 param.m_iCommitKey = data.nCommitKey; | 1838 param.m_iCommitKey = data.nCommitKey; |
| 1847 param.m_bShift = data.bShift; | 1839 param.m_bShift = data.bShift; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 return FALSE; | 1923 return FALSE; |
| 1932 | 1924 |
| 1933 if (!IsVisible()) | 1925 if (!IsVisible()) |
| 1934 return FALSE; | 1926 return FALSE; |
| 1935 | 1927 |
| 1936 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1928 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 1937 return FALSE; | 1929 return FALSE; |
| 1938 | 1930 |
| 1939 return TRUE; | 1931 return TRUE; |
| 1940 } | 1932 } |
| OLD | NEW |