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/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 return FALSE; | 256 return FALSE; |
257 } | 257 } |
258 | 258 |
259 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { | 259 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { |
260 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 260 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
261 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 261 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
262 CPDF_FormField* pFormField = GetFormField(); | 262 CPDF_FormField* pFormField = GetFormField(); |
263 ASSERT(pFormField != NULL); | |
264 | |
265 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 263 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
266 switch (GetFieldType()) { | 264 switch (GetFieldType()) { |
267 case FIELDTYPE_CHECKBOX: | 265 case FIELDTYPE_CHECKBOX: |
268 case FIELDTYPE_RADIOBUTTON: { | 266 case FIELDTYPE_RADIOBUTTON: { |
269 CPDF_FormControl* pFormCtrl = GetFormControl(); | 267 CPDF_FormControl* pFormCtrl = GetFormControl(); |
270 ASSERT(pFormCtrl != NULL); | |
271 | |
272 XFA_CHECKSTATE eCheckState = | 268 XFA_CHECKSTATE eCheckState = |
273 pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; | 269 pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; |
274 pWidgetAcc->SetCheckState(eCheckState); | 270 pWidgetAcc->SetCheckState(eCheckState); |
275 } break; | 271 } break; |
276 case FIELDTYPE_TEXTFIELD: | 272 case FIELDTYPE_TEXTFIELD: |
277 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); | 273 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); |
278 break; | 274 break; |
279 case FIELDTYPE_LISTBOX: { | 275 case FIELDTYPE_LISTBOX: { |
280 pWidgetAcc->ClearAllSelections(); | 276 pWidgetAcc->ClearAllSelections(); |
281 | 277 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 329 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
334 if (GetXFAWidgetHandler()) | 330 if (GetXFAWidgetHandler()) |
335 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); | 331 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); |
336 } | 332 } |
337 } | 333 } |
338 | 334 |
339 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, | 335 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, |
340 IXFA_Widget* hWidget, | 336 IXFA_Widget* hWidget, |
341 CPDF_FormField* pFormField, | 337 CPDF_FormField* pFormField, |
342 CPDF_FormControl* pFormControl) { | 338 CPDF_FormControl* pFormControl) { |
343 ASSERT(pXFADocView != NULL); | 339 ASSERT(hWidget); |
344 ASSERT(hWidget != NULL); | |
345 | 340 |
346 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { | 341 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { |
347 ASSERT(pFormField != NULL); | 342 ASSERT(pFormControl); |
348 ASSERT(pFormControl != NULL); | |
349 | 343 |
350 switch (pFormField->GetFieldType()) { | 344 switch (pFormField->GetFieldType()) { |
351 case FIELDTYPE_CHECKBOX: { | 345 case FIELDTYPE_CHECKBOX: { |
352 if (CXFA_WidgetAcc* pWidgetAcc = | 346 if (CXFA_WidgetAcc* pWidgetAcc = |
353 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 347 pXFAWidgetHandler->GetDataAcc(hWidget)) { |
354 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | 348 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; |
355 | 349 |
356 pFormField->CheckControl(pFormField->GetControlIndex(pFormControl), | 350 pFormField->CheckControl(pFormField->GetControlIndex(pFormControl), |
357 bChecked, TRUE); | 351 bChecked, TRUE); |
358 } | 352 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 401 } |
408 } break; | 402 } break; |
409 } | 403 } |
410 } | 404 } |
411 } | 405 } |
412 | 406 |
413 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, | 407 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, |
414 IXFA_Widget* hWidget, | 408 IXFA_Widget* hWidget, |
415 CPDF_FormField* pFormField, | 409 CPDF_FormField* pFormField, |
416 CPDF_FormControl* pFormControl) { | 410 CPDF_FormControl* pFormControl) { |
417 ASSERT(pXFADocView != NULL); | 411 ASSERT(hWidget); |
418 ASSERT(hWidget != NULL); | |
419 | 412 |
420 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { | 413 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { |
421 ASSERT(pFormField != NULL); | |
422 | |
423 switch (pFormField->GetFieldType()) { | 414 switch (pFormField->GetFieldType()) { |
424 case FIELDTYPE_LISTBOX: { | 415 case FIELDTYPE_LISTBOX: { |
425 pFormField->ClearSelection(FALSE); | 416 pFormField->ClearSelection(FALSE); |
426 pFormField->ClearOptions(TRUE); | 417 pFormField->ClearOptions(TRUE); |
427 | 418 |
428 if (CXFA_WidgetAcc* pWidgetAcc = | 419 if (CXFA_WidgetAcc* pWidgetAcc = |
429 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 420 pXFAWidgetHandler->GetDataAcc(hWidget)) { |
430 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; | 421 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; |
431 i++) { | 422 i++) { |
432 CFX_WideString swText; | 423 CFX_WideString swText; |
(...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 FX_BOOL bIncludeOrExclude, | 2484 FX_BOOL bIncludeOrExclude, |
2494 CFX_ByteTextBuf& textBuf) { | 2485 CFX_ByteTextBuf& textBuf) { |
2495 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( | 2486 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( |
2496 m_pDocument->GetPath(), fields, bIncludeOrExclude)); | 2487 m_pDocument->GetPath(), fields, bIncludeOrExclude)); |
2497 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 2488 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; |
2498 } | 2489 } |
2499 | 2490 |
2500 #ifdef PDF_ENABLE_XFA | 2491 #ifdef PDF_ENABLE_XFA |
2501 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 2492 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, |
2502 FX_BOOL bSynchronizeElse) { | 2493 FX_BOOL bSynchronizeElse) { |
2503 ASSERT(pFormField != NULL); | |
2504 | |
2505 int x = 0; | 2494 int x = 0; |
2506 if (m_FieldSynchronizeMap.Lookup(pFormField, x)) | 2495 if (m_FieldSynchronizeMap.Lookup(pFormField, x)) |
2507 return; | 2496 return; |
2508 | 2497 |
2509 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2498 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2510 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2499 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2511 ASSERT(pFormCtrl != NULL); | 2500 ASSERT(pFormCtrl); |
2512 | 2501 ASSERT(m_pInterForm); |
2513 ASSERT(m_pInterForm != NULL); | |
2514 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { | 2502 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
2515 pWidget->Synchronize(bSynchronizeElse); | 2503 pWidget->Synchronize(bSynchronizeElse); |
2516 } | 2504 } |
2517 } | 2505 } |
2518 } | 2506 } |
2519 #endif // PDF_ENABLE_XFA | 2507 #endif // PDF_ENABLE_XFA |
2520 | 2508 |
2521 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 2509 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
2522 const CFX_WideString& sFileExt) { | 2510 const CFX_WideString& sFileExt) { |
2523 CFX_WideString sFileName; | 2511 CFX_WideString sFileName; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2873 break; | 2861 break; |
2874 } | 2862 } |
2875 } | 2863 } |
2876 } | 2864 } |
2877 | 2865 |
2878 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2866 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
2879 CPDF_Rect rcAnnot; | 2867 CPDF_Rect rcAnnot; |
2880 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2868 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2881 return rcAnnot; | 2869 return rcAnnot; |
2882 } | 2870 } |
OLD | NEW |