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 "../../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 21 matching lines...) Expand all Loading... |
32 m_pInterForm(pInterForm), | 32 m_pInterForm(pInterForm), |
33 m_nAppAge(0), | 33 m_nAppAge(0), |
34 m_nValueAge(0), | 34 m_nValueAge(0), |
35 m_hMixXFAWidget(NULL), | 35 m_hMixXFAWidget(NULL), |
36 m_pWidgetHandler(NULL) { | 36 m_pWidgetHandler(NULL) { |
37 ASSERT(m_pInterForm != NULL); | 37 ASSERT(m_pInterForm != NULL); |
38 } | 38 } |
39 | 39 |
40 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 40 CPDFSDK_Widget::~CPDFSDK_Widget() {} |
41 | 41 |
42 IXFA_Widget* CPDFSDK_Widget::GetMixXFAWidget() { | 42 IXFA_Widget* CPDFSDK_Widget::GetMixXFAWidget() const { |
43 ASSERT(m_pPageView != NULL); | |
44 | |
45 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 43 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
46 ASSERT(pSDKDoc != NULL); | |
47 | |
48 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); | 44 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); |
49 ASSERT(pDoc != NULL); | |
50 | |
51 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 45 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
52 if (!m_hMixXFAWidget) { | 46 if (!m_hMixXFAWidget) { |
53 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 47 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { |
54 CFX_WideString sName; | 48 CFX_WideString sName; |
55 if (this->GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 49 if (this->GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
56 sName = this->GetAnnotName(); | 50 sName = this->GetAnnotName(); |
57 if (sName.IsEmpty()) | 51 if (sName.IsEmpty()) |
58 sName = GetName(); | 52 sName = GetName(); |
59 } else | 53 } else |
60 sName = GetName(); | 54 sName = GetName(); |
(...skipping 22 matching lines...) Expand all Loading... |
83 CFX_WideString sName = GetName(); | 77 CFX_WideString sName = GetName(); |
84 | 78 |
85 if (!sName.IsEmpty()) | 79 if (!sName.IsEmpty()) |
86 return pDocView->GetWidgetByName(sName); | 80 return pDocView->GetWidgetByName(sName); |
87 } | 81 } |
88 } | 82 } |
89 | 83 |
90 return NULL; | 84 return NULL; |
91 } | 85 } |
92 | 86 |
93 IXFA_WidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() { | 87 IXFA_WidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { |
94 ASSERT(m_pPageView != NULL); | |
95 | |
96 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 88 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
97 ASSERT(pSDKDoc != NULL); | |
98 | |
99 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); | 89 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); |
100 ASSERT(pDoc != NULL); | |
101 | |
102 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 90 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
103 if (!m_pWidgetHandler) { | 91 if (!m_pWidgetHandler) { |
104 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 92 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { |
105 m_pWidgetHandler = pDocView->GetWidgetHandler(); | 93 m_pWidgetHandler = pDocView->GetWidgetHandler(); |
106 } | 94 } |
107 } | 95 } |
108 return m_pWidgetHandler; | 96 return m_pWidgetHandler; |
109 } | 97 } |
110 | 98 |
111 return NULL; | 99 return NULL; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 324 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
337 ASSERT(pSDKDoc != NULL); | 325 ASSERT(pSDKDoc != NULL); |
338 | 326 |
339 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); | 327 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); |
340 ASSERT(pDoc != NULL); | 328 ASSERT(pDoc != NULL); |
341 | 329 |
342 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); | 330 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); |
343 if (!pXFADocView) | 331 if (!pXFADocView) |
344 return; | 332 return; |
345 | 333 |
346 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 334 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
347 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 335 if (GetXFAWidgetHandler()) { |
348 CPDF_FormField* pFormField = GetFormField(); | 336 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), |
349 ASSERT(pFormField != NULL); | 337 GetFormControl()); |
350 | |
351 CPDF_FormControl* pFormCtrl = GetFormControl(); | |
352 ASSERT(pFormCtrl != NULL); | |
353 | |
354 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, pFormField, | |
355 pFormCtrl); | |
356 } | 338 } |
357 } | 339 } |
358 #endif // PDF_ENABLE_XFA | 340 #endif // PDF_ENABLE_XFA |
359 } | 341 } |
360 | 342 |
361 void CPDFSDK_Widget::SynchronizeXFAItems() { | 343 void CPDFSDK_Widget::SynchronizeXFAItems() { |
362 #ifdef PDF_ENABLE_XFA | 344 #ifdef PDF_ENABLE_XFA |
363 ASSERT(m_pPageView != NULL); | 345 ASSERT(m_pPageView != NULL); |
364 | 346 |
365 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 347 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
366 ASSERT(pSDKDoc != NULL); | 348 ASSERT(pSDKDoc != NULL); |
367 | 349 |
368 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); | 350 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); |
369 ASSERT(pDoc != NULL); | 351 ASSERT(pDoc != NULL); |
370 | 352 |
371 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); | 353 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); |
372 if (!pXFADocView) | 354 if (!pXFADocView) |
373 return; | 355 return; |
374 | 356 |
375 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 357 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
376 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 358 if (GetXFAWidgetHandler()) |
377 CPDF_FormField* pFormField = GetFormField(); | 359 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); |
378 ASSERT(pFormField != NULL); | |
379 | |
380 SynchronizeXFAItems(pXFADocView, hWidget, pFormField, NULL); | |
381 } | |
382 } | 360 } |
383 #endif // PDF_ENABLE_XFA | 361 #endif // PDF_ENABLE_XFA |
384 } | 362 } |
385 | 363 |
386 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, | 364 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, |
387 IXFA_Widget* hWidget, | 365 IXFA_Widget* hWidget, |
388 CPDF_FormField* pFormField, | 366 CPDF_FormField* pFormField, |
389 CPDF_FormControl* pFormControl) { | 367 CPDF_FormControl* pFormControl) { |
390 #ifdef PDF_ENABLE_XFA | 368 #ifdef PDF_ENABLE_XFA |
391 ASSERT(pXFADocView != NULL); | 369 ASSERT(pXFADocView != NULL); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 return pControl; | 593 return pControl; |
616 } | 594 } |
617 | 595 |
618 int CPDFSDK_Widget::GetRotate() const { | 596 int CPDFSDK_Widget::GetRotate() const { |
619 CPDF_FormControl* pCtrl = GetFormControl(); | 597 CPDF_FormControl* pCtrl = GetFormControl(); |
620 ASSERT(pCtrl != NULL); | 598 ASSERT(pCtrl != NULL); |
621 | 599 |
622 return pCtrl->GetRotation() % 360; | 600 return pCtrl->GetRotation() % 360; |
623 } | 601 } |
624 | 602 |
625 CFX_WideString CPDFSDK_Widget::GetName() { | 603 CFX_WideString CPDFSDK_Widget::GetName() const { |
626 ASSERT(m_pInterForm != NULL); | |
627 | |
628 CPDF_FormField* pFormField = GetFormField(); | 604 CPDF_FormField* pFormField = GetFormField(); |
629 ASSERT(pFormField != NULL); | |
630 | |
631 return pFormField->GetFullName(); | 605 return pFormField->GetFullName(); |
632 } | 606 } |
633 | 607 |
634 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { | 608 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { |
635 CPDF_FormControl* pFormCtrl = GetFormControl(); | 609 CPDF_FormControl* pFormCtrl = GetFormControl(); |
636 ASSERT(pFormCtrl != NULL); | 610 ASSERT(pFormCtrl != NULL); |
637 | 611 |
638 int iColorType = 0; | 612 int iColorType = 0; |
639 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 613 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); |
640 | 614 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 ASSERT(pFormCtrl != NULL); | 647 ASSERT(pFormCtrl != NULL); |
674 | 648 |
675 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 649 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
676 CFX_ByteString csFont = ""; | 650 CFX_ByteString csFont = ""; |
677 FX_FLOAT fFontSize = 0.0f; | 651 FX_FLOAT fFontSize = 0.0f; |
678 pDa.GetFont(csFont, fFontSize); | 652 pDa.GetFont(csFont, fFontSize); |
679 | 653 |
680 return fFontSize; | 654 return fFontSize; |
681 } | 655 } |
682 | 656 |
683 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) { | 657 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
684 #ifdef PDF_ENABLE_XFA | 658 #ifdef PDF_ENABLE_XFA |
685 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 659 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
686 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 660 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
687 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 661 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
688 if (nIndex < pWidgetAcc->CountSelectedItems()) | 662 if (nIndex < pWidgetAcc->CountSelectedItems()) |
689 return pWidgetAcc->GetSelectedItem(nIndex); | 663 return pWidgetAcc->GetSelectedItem(nIndex); |
690 } | 664 } |
691 } | 665 } |
692 } | 666 } |
693 #endif // PDF_ENABLE_XFA | 667 #endif // PDF_ENABLE_XFA |
694 | 668 |
695 CPDF_FormField* pFormField = GetFormField(); | 669 CPDF_FormField* pFormField = GetFormField(); |
696 return pFormField->GetSelectedIndex(nIndex); | 670 return pFormField->GetSelectedIndex(nIndex); |
697 } | 671 } |
698 | 672 |
699 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) { | 673 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { |
700 #ifdef PDF_ENABLE_XFA | 674 #ifdef PDF_ENABLE_XFA |
701 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 675 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
702 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 676 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
703 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 677 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
704 CFX_WideString sValue; | 678 CFX_WideString sValue; |
705 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display | 679 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display |
706 : XFA_VALUEPICTURE_Edit); | 680 : XFA_VALUEPICTURE_Edit); |
707 return sValue; | 681 return sValue; |
708 } | 682 } |
709 } | 683 } |
(...skipping 18 matching lines...) Expand all Loading... |
728 return pFormField->GetOptionLabel(nIndex); | 702 return pFormField->GetOptionLabel(nIndex); |
729 } | 703 } |
730 | 704 |
731 int CPDFSDK_Widget::CountOptions() const { | 705 int CPDFSDK_Widget::CountOptions() const { |
732 CPDF_FormField* pFormField = GetFormField(); | 706 CPDF_FormField* pFormField = GetFormField(); |
733 ASSERT(pFormField != NULL); | 707 ASSERT(pFormField != NULL); |
734 | 708 |
735 return pFormField->CountOptions(); | 709 return pFormField->CountOptions(); |
736 } | 710 } |
737 | 711 |
738 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) { | 712 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
739 #ifdef PDF_ENABLE_XFA | 713 #ifdef PDF_ENABLE_XFA |
740 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 714 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
741 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 715 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
742 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 716 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
743 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 717 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
744 return pWidgetAcc->GetItemState(nIndex); | 718 return pWidgetAcc->GetItemState(nIndex); |
745 | 719 |
746 return FALSE; | 720 return FALSE; |
747 } | 721 } |
748 } | 722 } |
749 } | 723 } |
750 #endif // PDF_ENABLE_XFA | 724 #endif // PDF_ENABLE_XFA |
751 | 725 |
752 CPDF_FormField* pFormField = GetFormField(); | 726 CPDF_FormField* pFormField = GetFormField(); |
753 return pFormField->IsItemSelected(nIndex); | 727 return pFormField->IsItemSelected(nIndex); |
754 } | 728 } |
755 | 729 |
756 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 730 int CPDFSDK_Widget::GetTopVisibleIndex() const { |
757 CPDF_FormField* pFormField = GetFormField(); | 731 CPDF_FormField* pFormField = GetFormField(); |
758 return pFormField->GetTopVisibleIndex(); | 732 return pFormField->GetTopVisibleIndex(); |
759 } | 733 } |
760 | 734 |
761 FX_BOOL CPDFSDK_Widget::IsChecked() { | 735 FX_BOOL CPDFSDK_Widget::IsChecked() const { |
762 #ifdef PDF_ENABLE_XFA | 736 #ifdef PDF_ENABLE_XFA |
763 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 737 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
764 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 738 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
765 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 739 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
766 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | 740 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; |
767 return bChecked; | 741 return bChecked; |
768 } | 742 } |
769 } | 743 } |
770 } | 744 } |
771 #endif // PDF_ENABLE_XFA | 745 #endif // PDF_ENABLE_XFA |
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3352 ASSERT(pAnnot != NULL); | 3326 ASSERT(pAnnot != NULL); |
3353 | 3327 |
3354 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 3328 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
3355 ASSERT(pPDFAnnot != NULL); | 3329 ASSERT(pPDFAnnot != NULL); |
3356 | 3330 |
3357 CPDF_Rect rcAnnot; | 3331 CPDF_Rect rcAnnot; |
3358 pPDFAnnot->GetRect(rcAnnot); | 3332 pPDFAnnot->GetRect(rcAnnot); |
3359 | 3333 |
3360 return rcAnnot; | 3334 return rcAnnot; |
3361 } | 3335 } |
OLD | NEW |