Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: fpdfsdk/src/fsdk_baseform.cpp

Issue 1399833002: Allow building of XFA branch without XFA (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Keep GN in sync. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fsdk_annothandler.cpp ('k') | fpdfsdk/src/fsdk_mgr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../third_party/base/nonstd_unique_ptr.h"
8 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
9 #include "../include/fpdfxfa/fpdfxfa_doc.h" 9 #include "../include/fpdfxfa/fpdfxfa_doc.h"
10 #include "../include/fpdfxfa/fpdfxfa_util.h" 10 #include "../include/fpdfxfa/fpdfxfa_util.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 pDocView->UpdateDocView(); 269 pDocView->UpdateDocView();
270 } 270 }
271 } 271 }
272 } 272 }
273 } 273 }
274 274
275 return FALSE; 275 return FALSE;
276 } 276 }
277 277
278 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { 278 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) {
279 #ifdef PDF_ENABLE_XFA
279 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 280 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
280 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 281 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
281 CPDF_FormField* pFormField = GetFormField(); 282 CPDF_FormField* pFormField = GetFormField();
282 ASSERT(pFormField != NULL); 283 ASSERT(pFormField != NULL);
283 284
284 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { 285 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
285 switch (GetFieldType()) { 286 switch (GetFieldType()) {
286 case FIELDTYPE_CHECKBOX: 287 case FIELDTYPE_CHECKBOX:
287 case FIELDTYPE_RADIOBUTTON: { 288 case FIELDTYPE_RADIOBUTTON: {
288 CPDF_FormControl* pFormCtrl = GetFormControl(); 289 CPDF_FormControl* pFormCtrl = GetFormControl();
(...skipping 29 matching lines...) Expand all
318 319
319 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); 320 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit);
320 break; 321 break;
321 } 322 }
322 323
323 if (bSynchronizeElse) 324 if (bSynchronizeElse)
324 pWidgetAcc->ProcessValueChanged(); 325 pWidgetAcc->ProcessValueChanged();
325 } 326 }
326 } 327 }
327 } 328 }
329 #endif // PDF_ENABLE_XFA
328 } 330 }
329 331
330 void CPDFSDK_Widget::SynchronizeXFAValue() { 332 void CPDFSDK_Widget::SynchronizeXFAValue() {
333 #ifdef PDF_ENABLE_XFA
331 ASSERT(m_pPageView != NULL); 334 ASSERT(m_pPageView != NULL);
332 335
333 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); 336 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
334 ASSERT(pSDKDoc != NULL); 337 ASSERT(pSDKDoc != NULL);
335 338
336 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); 339 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
337 ASSERT(pDoc != NULL); 340 ASSERT(pDoc != NULL);
338 341
339 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); 342 IXFA_DocView* pXFADocView = pDoc->GetXFADocView();
340 if (!pXFADocView) 343 if (!pXFADocView)
341 return; 344 return;
342 345
343 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 346 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
344 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 347 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
345 CPDF_FormField* pFormField = GetFormField(); 348 CPDF_FormField* pFormField = GetFormField();
346 ASSERT(pFormField != NULL); 349 ASSERT(pFormField != NULL);
347 350
348 CPDF_FormControl* pFormCtrl = GetFormControl(); 351 CPDF_FormControl* pFormCtrl = GetFormControl();
349 ASSERT(pFormCtrl != NULL); 352 ASSERT(pFormCtrl != NULL);
350 353
351 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, pFormField, 354 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, pFormField,
352 pFormCtrl); 355 pFormCtrl);
353 } 356 }
354 } 357 }
358 #endif // PDF_ENABLE_XFA
355 } 359 }
356 360
357 void CPDFSDK_Widget::SynchronizeXFAItems() { 361 void CPDFSDK_Widget::SynchronizeXFAItems() {
362 #ifdef PDF_ENABLE_XFA
358 ASSERT(m_pPageView != NULL); 363 ASSERT(m_pPageView != NULL);
359 364
360 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); 365 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
361 ASSERT(pSDKDoc != NULL); 366 ASSERT(pSDKDoc != NULL);
362 367
363 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); 368 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
364 ASSERT(pDoc != NULL); 369 ASSERT(pDoc != NULL);
365 370
366 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); 371 IXFA_DocView* pXFADocView = pDoc->GetXFADocView();
367 if (!pXFADocView) 372 if (!pXFADocView)
368 return; 373 return;
369 374
370 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 375 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
371 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 376 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
372 CPDF_FormField* pFormField = GetFormField(); 377 CPDF_FormField* pFormField = GetFormField();
373 ASSERT(pFormField != NULL); 378 ASSERT(pFormField != NULL);
374 379
375 SynchronizeXFAItems(pXFADocView, hWidget, pFormField, NULL); 380 SynchronizeXFAItems(pXFADocView, hWidget, pFormField, NULL);
376 } 381 }
377 } 382 }
383 #endif // PDF_ENABLE_XFA
378 } 384 }
379 385
380 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, 386 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView,
381 IXFA_Widget* hWidget, 387 IXFA_Widget* hWidget,
382 CPDF_FormField* pFormField, 388 CPDF_FormField* pFormField,
383 CPDF_FormControl* pFormControl) { 389 CPDF_FormControl* pFormControl) {
390 #ifdef PDF_ENABLE_XFA
384 ASSERT(pXFADocView != NULL); 391 ASSERT(pXFADocView != NULL);
385 ASSERT(hWidget != NULL); 392 ASSERT(hWidget != NULL);
386 393
387 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { 394 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) {
388 ASSERT(pFormField != NULL); 395 ASSERT(pFormField != NULL);
389 ASSERT(pFormControl != NULL); 396 ASSERT(pFormControl != NULL);
390 397
391 switch (pFormField->GetFieldType()) { 398 switch (pFormField->GetFieldType()) {
392 case FIELDTYPE_CHECKBOX: { 399 case FIELDTYPE_CHECKBOX: {
393 if (CXFA_WidgetAcc* pWidgetAcc = 400 if (CXFA_WidgetAcc* pWidgetAcc =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 449 }
443 } 450 }
444 451
445 CFX_WideString sValue; 452 CFX_WideString sValue;
446 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); 453 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display);
447 pFormField->SetValue(sValue, TRUE); 454 pFormField->SetValue(sValue, TRUE);
448 } 455 }
449 } break; 456 } break;
450 } 457 }
451 } 458 }
459 #endif // PDF_ENABLE_XFA
452 } 460 }
453 461
454 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, 462 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView,
455 IXFA_Widget* hWidget, 463 IXFA_Widget* hWidget,
456 CPDF_FormField* pFormField, 464 CPDF_FormField* pFormField,
457 CPDF_FormControl* pFormControl) { 465 CPDF_FormControl* pFormControl) {
466 #ifdef PDF_ENABLE_XFA
458 ASSERT(pXFADocView != NULL); 467 ASSERT(pXFADocView != NULL);
459 ASSERT(hWidget != NULL); 468 ASSERT(hWidget != NULL);
460 469
461 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { 470 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) {
462 ASSERT(pFormField != NULL); 471 ASSERT(pFormField != NULL);
463 472
464 switch (pFormField->GetFieldType()) { 473 switch (pFormField->GetFieldType()) {
465 case FIELDTYPE_LISTBOX: { 474 case FIELDTYPE_LISTBOX: {
466 pFormField->ClearSelection(FALSE); 475 pFormField->ClearSelection(FALSE);
467 pFormField->ClearOptions(TRUE); 476 pFormField->ClearOptions(TRUE);
(...skipping 21 matching lines...) Expand all
489 pWidgetAcc->GetChoiceListItem(swText, i); 498 pWidgetAcc->GetChoiceListItem(swText, i);
490 499
491 pFormField->InsertOption(swText, i, FALSE); 500 pFormField->InsertOption(swText, i, FALSE);
492 } 501 }
493 } 502 }
494 503
495 pFormField->SetValue(L"", TRUE); 504 pFormField->SetValue(L"", TRUE);
496 } break; 505 } break;
497 } 506 }
498 } 507 }
508 #endif // PDF_ENABLE_XFA
499 } 509 }
500 510
501 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( 511 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
502 CPDF_Annot::AppearanceMode mode) { 512 CPDF_Annot::AppearanceMode mode) {
503 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); 513 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
504 if (!pAP) 514 if (!pAP)
505 return FALSE; 515 return FALSE;
506 516
507 // Choose the right sub-ap 517 // Choose the right sub-ap
508 const FX_CHAR* ap_entry = "N"; 518 const FX_CHAR* ap_entry = "N";
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 675
666 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); 676 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance();
667 CFX_ByteString csFont = ""; 677 CFX_ByteString csFont = "";
668 FX_FLOAT fFontSize = 0.0f; 678 FX_FLOAT fFontSize = 0.0f;
669 pDa.GetFont(csFont, fFontSize); 679 pDa.GetFont(csFont, fFontSize);
670 680
671 return fFontSize; 681 return fFontSize;
672 } 682 }
673 683
674 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) { 684 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) {
685 #ifdef PDF_ENABLE_XFA
675 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 686 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
676 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 687 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
677 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { 688 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
678 if (nIndex < pWidgetAcc->CountSelectedItems()) 689 if (nIndex < pWidgetAcc->CountSelectedItems())
679 return pWidgetAcc->GetSelectedItem(nIndex); 690 return pWidgetAcc->GetSelectedItem(nIndex);
680 } 691 }
681 } 692 }
682 } 693 }
694 #endif // PDF_ENABLE_XFA
683 695
684 CPDF_FormField* pFormField = GetFormField(); 696 CPDF_FormField* pFormField = GetFormField();
685 ASSERT(pFormField != NULL);
686
687 return pFormField->GetSelectedIndex(nIndex); 697 return pFormField->GetSelectedIndex(nIndex);
688 } 698 }
689 699
690 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) { 700 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) {
701 #ifdef PDF_ENABLE_XFA
691 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 702 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
692 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 703 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
693 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { 704 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
694 CFX_WideString sValue; 705 CFX_WideString sValue;
695 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display 706 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display
696 : XFA_VALUEPICTURE_Edit); 707 : XFA_VALUEPICTURE_Edit);
697 return sValue; 708 return sValue;
698 } 709 }
699 } 710 }
700 } 711 }
712 #endif // PDF_ENABLE_XFA
701 713
702 CPDF_FormField* pFormField = GetFormField(); 714 CPDF_FormField* pFormField = GetFormField();
703 ASSERT(pFormField != NULL);
704
705 return pFormField->GetValue(); 715 return pFormField->GetValue();
706 } 716 }
707 717
708 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { 718 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const {
709 CPDF_FormField* pFormField = GetFormField(); 719 CPDF_FormField* pFormField = GetFormField();
710 ASSERT(pFormField != NULL); 720 ASSERT(pFormField != NULL);
711 721
712 return pFormField->GetDefaultValue(); 722 return pFormField->GetDefaultValue();
713 } 723 }
714 724
715 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { 725 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const {
716 CPDF_FormField* pFormField = GetFormField(); 726 CPDF_FormField* pFormField = GetFormField();
717 ASSERT(pFormField != NULL); 727 ASSERT(pFormField != NULL);
718 728
719 return pFormField->GetOptionLabel(nIndex); 729 return pFormField->GetOptionLabel(nIndex);
720 } 730 }
721 731
722 int CPDFSDK_Widget::CountOptions() const { 732 int CPDFSDK_Widget::CountOptions() const {
723 CPDF_FormField* pFormField = GetFormField(); 733 CPDF_FormField* pFormField = GetFormField();
724 ASSERT(pFormField != NULL); 734 ASSERT(pFormField != NULL);
725 735
726 return pFormField->CountOptions(); 736 return pFormField->CountOptions();
727 } 737 }
728 738
729 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) { 739 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) {
740 #ifdef PDF_ENABLE_XFA
730 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 741 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
731 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 742 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
732 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { 743 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
733 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) 744 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems())
734 return pWidgetAcc->GetItemState(nIndex); 745 return pWidgetAcc->GetItemState(nIndex);
735 746
736 return FALSE; 747 return FALSE;
737 } 748 }
738 } 749 }
739 } 750 }
751 #endif // PDF_ENABLE_XFA
740 752
741 CPDF_FormField* pFormField = GetFormField(); 753 CPDF_FormField* pFormField = GetFormField();
742 return pFormField->IsItemSelected(nIndex); 754 return pFormField->IsItemSelected(nIndex);
743 } 755 }
744 756
745 int CPDFSDK_Widget::GetTopVisibleIndex() const { 757 int CPDFSDK_Widget::GetTopVisibleIndex() const {
746 CPDF_FormField* pFormField = GetFormField(); 758 CPDF_FormField* pFormField = GetFormField();
747 return pFormField->GetTopVisibleIndex(); 759 return pFormField->GetTopVisibleIndex();
748 } 760 }
749 761
750 FX_BOOL CPDFSDK_Widget::IsChecked() { 762 FX_BOOL CPDFSDK_Widget::IsChecked() {
763 #ifdef PDF_ENABLE_XFA
751 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { 764 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
752 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { 765 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
753 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { 766 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
754 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; 767 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
755 return bChecked; 768 return bChecked;
756 } 769 }
757 } 770 }
758 } 771 }
772 #endif // PDF_ENABLE_XFA
759 773
760 CPDF_FormControl* pFormCtrl = GetFormControl(); 774 CPDF_FormControl* pFormCtrl = GetFormControl();
761 ASSERT(pFormCtrl != NULL);
762
763 return pFormCtrl->IsChecked(); 775 return pFormCtrl->IsChecked();
764 } 776 }
765 777
766 int CPDFSDK_Widget::GetAlignment() const { 778 int CPDFSDK_Widget::GetAlignment() const {
767 CPDF_FormControl* pFormCtrl = GetFormControl(); 779 CPDF_FormControl* pFormCtrl = GetFormControl();
768 ASSERT(pFormCtrl != NULL); 780 ASSERT(pFormCtrl != NULL);
769 781
770 return pFormCtrl->GetControlAlignment(); 782 return pFormCtrl->GetControlAlignment();
771 } 783 }
772 784
(...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after
3358 ASSERT(pAnnot != NULL); 3370 ASSERT(pAnnot != NULL);
3359 3371
3360 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); 3372 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
3361 ASSERT(pPDFAnnot != NULL); 3373 ASSERT(pPDFAnnot != NULL);
3362 3374
3363 CPDF_Rect rcAnnot; 3375 CPDF_Rect rcAnnot;
3364 pPDFAnnot->GetRect(rcAnnot); 3376 pPDFAnnot->GetRect(rcAnnot);
3365 3377
3366 return rcAnnot; 3378 return rcAnnot;
3367 } 3379 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_annothandler.cpp ('k') | fpdfsdk/src/fsdk_mgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698