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