| 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/formfiller/FFL_FormFiller.h" | 7 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 8 #include "fpdfsdk/include/fsdk_actionhandler.h" | 8 #include "fpdfsdk/include/fsdk_actionhandler.h" |
| 9 #include "fpdfsdk/include/fsdk_baseannot.h" | 9 #include "fpdfsdk/include/fsdk_baseannot.h" |
| 10 #include "fpdfsdk/include/fsdk_baseform.h" | 10 #include "fpdfsdk/include/fsdk_baseform.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 case FIELDTYPE_RADIOBUTTON: | 486 case FIELDTYPE_RADIOBUTTON: |
| 487 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { | 487 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { |
| 488 return pSubDict->GetStream(GetAppState()) != NULL; | 488 return pSubDict->GetStream(GetAppState()) != NULL; |
| 489 } | 489 } |
| 490 return FALSE; | 490 return FALSE; |
| 491 } | 491 } |
| 492 return TRUE; | 492 return TRUE; |
| 493 } | 493 } |
| 494 | 494 |
| 495 int CPDFSDK_Widget::GetFieldType() const { | 495 int CPDFSDK_Widget::GetFieldType() const { |
| 496 CPDF_FormField* pField = GetFormField(); | 496 return GetFormField()->GetFieldType(); |
| 497 ASSERT(pField != NULL); | |
| 498 | |
| 499 return pField->GetFieldType(); | |
| 500 } | 497 } |
| 501 | 498 |
| 502 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { | 499 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { |
| 503 #ifdef PDF_ENABLE_XFA | 500 #ifdef PDF_ENABLE_XFA |
| 504 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 501 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
| 505 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 502 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 506 int nDocType = pDoc->GetDocType(); | 503 int nDocType = pDoc->GetDocType(); |
| 507 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) | 504 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) |
| 508 return TRUE; | 505 return TRUE; |
| 509 #endif // PDF_ENABLE_XFA | 506 #endif // PDF_ENABLE_XFA |
| 510 return CPDFSDK_BAAnnot::IsAppearanceValid(); | 507 return CPDFSDK_BAAnnot::IsAppearanceValid(); |
| 511 } | 508 } |
| 512 | 509 |
| 513 int CPDFSDK_Widget::GetFieldFlags() const { | 510 int CPDFSDK_Widget::GetFieldFlags() const { |
| 514 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 511 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
| 515 ASSERT(pPDFInterForm != NULL); | |
| 516 | |
| 517 CPDF_FormControl* pFormControl = | 512 CPDF_FormControl* pFormControl = |
| 518 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); | 513 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); |
| 519 CPDF_FormField* pFormField = pFormControl->GetField(); | 514 CPDF_FormField* pFormField = pFormControl->GetField(); |
| 520 return pFormField->GetFieldFlags(); | 515 return pFormField->GetFieldFlags(); |
| 521 } | 516 } |
| 522 | 517 |
| 523 CFX_ByteString CPDFSDK_Widget::GetSubType() const { | 518 CFX_ByteString CPDFSDK_Widget::GetSubType() const { |
| 524 int nType = GetFieldType(); | 519 int nType = GetFieldType(); |
| 525 | 520 |
| 526 if (nType == FIELDTYPE_SIGNATURE) | 521 if (nType == FIELDTYPE_SIGNATURE) |
| 527 return BFFT_SIGNATURE; | 522 return BFFT_SIGNATURE; |
| 528 return CPDFSDK_Annot::GetSubType(); | 523 return CPDFSDK_Annot::GetSubType(); |
| 529 } | 524 } |
| 530 | 525 |
| 531 CPDF_FormField* CPDFSDK_Widget::GetFormField() const { | 526 CPDF_FormField* CPDFSDK_Widget::GetFormField() const { |
| 532 return GetFormControl()->GetField(); | 527 return GetFormControl()->GetField(); |
| 533 } | 528 } |
| 534 | 529 |
| 535 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { | 530 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { |
| 536 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 531 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
| 537 return pPDFInterForm->GetControlByDict(GetAnnotDict()); | 532 return pPDFInterForm->GetControlByDict(GetAnnotDict()); |
| 538 } | 533 } |
| 539 | 534 |
| 540 CPDF_FormControl* CPDFSDK_Widget::GetFormControl( | 535 CPDF_FormControl* CPDFSDK_Widget::GetFormControl( |
| 541 CPDF_InterForm* pInterForm, | 536 CPDF_InterForm* pInterForm, |
| 542 const CPDF_Dictionary* pAnnotDict) { | 537 const CPDF_Dictionary* pAnnotDict) { |
| 543 ASSERT(pAnnotDict != NULL); | 538 ASSERT(pAnnotDict); |
| 544 return pInterForm->GetControlByDict(pAnnotDict); | 539 return pInterForm->GetControlByDict(pAnnotDict); |
| 545 } | 540 } |
| 546 | 541 |
| 547 int CPDFSDK_Widget::GetRotate() const { | 542 int CPDFSDK_Widget::GetRotate() const { |
| 548 CPDF_FormControl* pCtrl = GetFormControl(); | 543 CPDF_FormControl* pCtrl = GetFormControl(); |
| 549 return pCtrl->GetRotation() % 360; | 544 return pCtrl->GetRotation() % 360; |
| 550 } | 545 } |
| 551 | 546 |
| 552 #ifdef PDF_ENABLE_XFA | 547 #ifdef PDF_ENABLE_XFA |
| 553 CFX_WideString CPDFSDK_Widget::GetName() const { | 548 CFX_WideString CPDFSDK_Widget::GetName() const { |
| 554 CPDF_FormField* pFormField = GetFormField(); | 549 CPDF_FormField* pFormField = GetFormField(); |
| 555 return pFormField->GetFullName(); | 550 return pFormField->GetFullName(); |
| 556 } | 551 } |
| 557 #endif // PDF_ENABLE_XFA | 552 #endif // PDF_ENABLE_XFA |
| 558 | 553 |
| 559 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { | 554 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { |
| 560 CPDF_FormControl* pFormCtrl = GetFormControl(); | 555 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 561 ASSERT(pFormCtrl != NULL); | |
| 562 | |
| 563 int iColorType = 0; | 556 int iColorType = 0; |
| 564 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 557 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); |
| 565 | 558 |
| 566 return iColorType != COLORTYPE_TRANSPARENT; | 559 return iColorType != COLORTYPE_TRANSPARENT; |
| 567 } | 560 } |
| 568 | 561 |
| 569 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { | 562 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { |
| 570 CPDF_FormControl* pFormCtrl = GetFormControl(); | 563 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 571 ASSERT(pFormCtrl != NULL); | |
| 572 | |
| 573 int iColorType = 0; | 564 int iColorType = 0; |
| 574 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); | 565 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); |
| 575 | 566 |
| 576 return iColorType != COLORTYPE_TRANSPARENT; | 567 return iColorType != COLORTYPE_TRANSPARENT; |
| 577 } | 568 } |
| 578 | 569 |
| 579 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { | 570 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { |
| 580 CPDF_FormControl* pFormCtrl = GetFormControl(); | 571 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 581 ASSERT(pFormCtrl != NULL); | |
| 582 | |
| 583 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 572 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
| 584 if (da.HasColor()) { | 573 if (da.HasColor()) { |
| 585 FX_ARGB argb; | 574 FX_ARGB argb; |
| 586 int iColorType = COLORTYPE_TRANSPARENT; | 575 int iColorType = COLORTYPE_TRANSPARENT; |
| 587 da.GetColor(argb, iColorType); | 576 da.GetColor(argb, iColorType); |
| 588 color = FX_ARGBTOCOLORREF(argb); | 577 color = FX_ARGBTOCOLORREF(argb); |
| 589 | 578 |
| 590 return iColorType != COLORTYPE_TRANSPARENT; | 579 return iColorType != COLORTYPE_TRANSPARENT; |
| 591 } | 580 } |
| 592 | 581 |
| 593 return FALSE; | 582 return FALSE; |
| 594 } | 583 } |
| 595 | 584 |
| 596 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { | 585 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { |
| 597 CPDF_FormControl* pFormCtrl = GetFormControl(); | 586 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 598 ASSERT(pFormCtrl != NULL); | |
| 599 | |
| 600 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 587 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
| 601 CFX_ByteString csFont = ""; | 588 CFX_ByteString csFont = ""; |
| 602 FX_FLOAT fFontSize = 0.0f; | 589 FX_FLOAT fFontSize = 0.0f; |
| 603 pDa.GetFont(csFont, fFontSize); | 590 pDa.GetFont(csFont, fFontSize); |
| 604 | 591 |
| 605 return fFontSize; | 592 return fFontSize; |
| 606 } | 593 } |
| 607 | 594 |
| 608 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { | 595 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
| 609 #ifdef PDF_ENABLE_XFA | 596 #ifdef PDF_ENABLE_XFA |
| (...skipping 24 matching lines...) Expand all Loading... |
| 634 } | 621 } |
| 635 #else | 622 #else |
| 636 CFX_WideString CPDFSDK_Widget::GetValue() const { | 623 CFX_WideString CPDFSDK_Widget::GetValue() const { |
| 637 #endif // PDF_ENABLE_XFA | 624 #endif // PDF_ENABLE_XFA |
| 638 CPDF_FormField* pFormField = GetFormField(); | 625 CPDF_FormField* pFormField = GetFormField(); |
| 639 return pFormField->GetValue(); | 626 return pFormField->GetValue(); |
| 640 } | 627 } |
| 641 | 628 |
| 642 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { | 629 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { |
| 643 CPDF_FormField* pFormField = GetFormField(); | 630 CPDF_FormField* pFormField = GetFormField(); |
| 644 ASSERT(pFormField != NULL); | |
| 645 | |
| 646 return pFormField->GetDefaultValue(); | 631 return pFormField->GetDefaultValue(); |
| 647 } | 632 } |
| 648 | 633 |
| 649 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { | 634 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { |
| 650 CPDF_FormField* pFormField = GetFormField(); | 635 CPDF_FormField* pFormField = GetFormField(); |
| 651 ASSERT(pFormField != NULL); | |
| 652 | |
| 653 return pFormField->GetOptionLabel(nIndex); | 636 return pFormField->GetOptionLabel(nIndex); |
| 654 } | 637 } |
| 655 | 638 |
| 656 int CPDFSDK_Widget::CountOptions() const { | 639 int CPDFSDK_Widget::CountOptions() const { |
| 657 CPDF_FormField* pFormField = GetFormField(); | 640 CPDF_FormField* pFormField = GetFormField(); |
| 658 ASSERT(pFormField != NULL); | |
| 659 | |
| 660 return pFormField->CountOptions(); | 641 return pFormField->CountOptions(); |
| 661 } | 642 } |
| 662 | 643 |
| 663 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { | 644 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
| 664 #ifdef PDF_ENABLE_XFA | 645 #ifdef PDF_ENABLE_XFA |
| 665 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 646 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
| 666 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 647 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
| 667 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 648 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
| 668 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 649 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
| 669 return pWidgetAcc->GetItemState(nIndex); | 650 return pWidgetAcc->GetItemState(nIndex); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 692 } | 673 } |
| 693 } | 674 } |
| 694 } | 675 } |
| 695 #endif // PDF_ENABLE_XFA | 676 #endif // PDF_ENABLE_XFA |
| 696 CPDF_FormControl* pFormCtrl = GetFormControl(); | 677 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 697 return pFormCtrl->IsChecked(); | 678 return pFormCtrl->IsChecked(); |
| 698 } | 679 } |
| 699 | 680 |
| 700 int CPDFSDK_Widget::GetAlignment() const { | 681 int CPDFSDK_Widget::GetAlignment() const { |
| 701 CPDF_FormControl* pFormCtrl = GetFormControl(); | 682 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 702 ASSERT(pFormCtrl != NULL); | |
| 703 | |
| 704 return pFormCtrl->GetControlAlignment(); | 683 return pFormCtrl->GetControlAlignment(); |
| 705 } | 684 } |
| 706 | 685 |
| 707 int CPDFSDK_Widget::GetMaxLen() const { | 686 int CPDFSDK_Widget::GetMaxLen() const { |
| 708 CPDF_FormField* pFormField = GetFormField(); | 687 CPDF_FormField* pFormField = GetFormField(); |
| 709 ASSERT(pFormField != NULL); | |
| 710 | |
| 711 return pFormField->GetMaxLen(); | 688 return pFormField->GetMaxLen(); |
| 712 } | 689 } |
| 713 | 690 |
| 714 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { | 691 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { |
| 715 CPDF_FormControl* pFormCtrl = GetFormControl(); | 692 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 716 CPDF_FormField* pFormField = pFormCtrl->GetField(); | 693 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
| 717 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, | 694 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, |
| 718 bNotify); | 695 bNotify); |
| 719 #ifdef PDF_ENABLE_XFA | 696 #ifdef PDF_ENABLE_XFA |
| 720 if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) | 697 if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 ResetAppearance_ComboBox(sValue); | 790 ResetAppearance_ComboBox(sValue); |
| 814 break; | 791 break; |
| 815 case FIELDTYPE_LISTBOX: | 792 case FIELDTYPE_LISTBOX: |
| 816 ResetAppearance_ListBox(); | 793 ResetAppearance_ListBox(); |
| 817 break; | 794 break; |
| 818 case FIELDTYPE_TEXTFIELD: | 795 case FIELDTYPE_TEXTFIELD: |
| 819 ResetAppearance_TextField(sValue); | 796 ResetAppearance_TextField(sValue); |
| 820 break; | 797 break; |
| 821 } | 798 } |
| 822 | 799 |
| 823 ASSERT(m_pAnnot != NULL); | |
| 824 m_pAnnot->ClearCachedAP(); | 800 m_pAnnot->ClearCachedAP(); |
| 825 } | 801 } |
| 826 | 802 |
| 827 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) { | 803 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) { |
| 828 CPDF_FormField* pFormField = GetFormField(); | 804 CPDF_FormField* pFormField = GetFormField(); |
| 829 ASSERT(pFormField != NULL); | 805 ASSERT(pFormField); |
| 830 return m_pInterForm->OnFormat(pFormField, bFormated); | 806 return m_pInterForm->OnFormat(pFormField, bFormated); |
| 831 } | 807 } |
| 832 | 808 |
| 833 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { | 809 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { |
| 834 CPDF_FormField* pFormField = GetFormField(); | 810 CPDF_FormField* pFormField = GetFormField(); |
| 835 ASSERT(pFormField != NULL); | 811 ASSERT(pFormField); |
| 836 | |
| 837 ASSERT(m_pInterForm != NULL); | |
| 838 | |
| 839 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); | 812 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); |
| 840 } | 813 } |
| 841 | 814 |
| 842 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, | 815 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, |
| 843 const CFX_Matrix* pUser2Device, | 816 const CFX_Matrix* pUser2Device, |
| 844 CPDF_Annot::AppearanceMode mode, | 817 CPDF_Annot::AppearanceMode mode, |
| 845 const CPDF_RenderOptions* pOptions) { | 818 const CPDF_RenderOptions* pOptions) { |
| 846 int nFieldType = GetFieldType(); | 819 int nFieldType = GetFieldType(); |
| 847 | 820 |
| 848 if ((nFieldType == FIELDTYPE_CHECKBOX || | 821 if ((nFieldType == FIELDTYPE_CHECKBOX || |
| (...skipping 12 matching lines...) Expand all Loading... |
| 861 | 834 |
| 862 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, | 835 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, |
| 863 FXFILL_ALTERNATE); | 836 FXFILL_ALTERNATE); |
| 864 } else { | 837 } else { |
| 865 CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); | 838 CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); |
| 866 } | 839 } |
| 867 } | 840 } |
| 868 | 841 |
| 869 void CPDFSDK_Widget::UpdateField() { | 842 void CPDFSDK_Widget::UpdateField() { |
| 870 CPDF_FormField* pFormField = GetFormField(); | 843 CPDF_FormField* pFormField = GetFormField(); |
| 871 ASSERT(pFormField != NULL); | 844 ASSERT(pFormField); |
| 872 | |
| 873 ASSERT(m_pInterForm != NULL); | |
| 874 m_pInterForm->UpdateField(pFormField); | 845 m_pInterForm->UpdateField(pFormField); |
| 875 } | 846 } |
| 876 | 847 |
| 877 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, | 848 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, |
| 878 CPDFSDK_PageView* pPageView) { | 849 CPDFSDK_PageView* pPageView) { |
| 879 ASSERT(m_pInterForm != NULL); | |
| 880 | |
| 881 int nFieldType = GetFieldType(); | 850 int nFieldType = GetFieldType(); |
| 882 if (m_pInterForm->IsNeedHighLight(nFieldType)) { | 851 if (m_pInterForm->IsNeedHighLight(nFieldType)) { |
| 883 CPDF_Rect rc = GetRect(); | 852 CPDF_Rect rc = GetRect(); |
| 884 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); | 853 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
| 885 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); | 854 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); |
| 886 | 855 |
| 887 CFX_FloatRect rcDevice; | 856 CFX_FloatRect rcDevice; |
| 888 ASSERT(m_pInterForm->GetDocument()); | 857 ASSERT(m_pInterForm->GetDocument()); |
| 889 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); | 858 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
| 890 if (!pEnv) | 859 if (!pEnv) |
| 891 return; | 860 return; |
| 892 CFX_Matrix page2device; | 861 CFX_Matrix page2device; |
| 893 pPageView->GetCurrentMatrix(page2device); | 862 pPageView->GetCurrentMatrix(page2device); |
| 894 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), | 863 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), |
| 895 rcDevice.left, rcDevice.bottom); | 864 rcDevice.left, rcDevice.bottom); |
| 896 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), | 865 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), |
| 897 rcDevice.right, rcDevice.top); | 866 rcDevice.right, rcDevice.top); |
| 898 | 867 |
| 899 rcDevice.Normalize(); | 868 rcDevice.Normalize(); |
| 900 | 869 |
| 901 FX_ARGB argb = ArgbEncode((int)alpha, color); | 870 FX_ARGB argb = ArgbEncode((int)alpha, color); |
| 902 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, | 871 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, |
| 903 (int)rcDevice.bottom); | 872 (int)rcDevice.bottom); |
| 904 pDevice->FillRect(&rcDev, argb); | 873 pDevice->FillRect(&rcDev, argb); |
| 905 } | 874 } |
| 906 } | 875 } |
| 907 | 876 |
| 908 void CPDFSDK_Widget::ResetAppearance_PushButton() { | 877 void CPDFSDK_Widget::ResetAppearance_PushButton() { |
| 909 CPDF_FormControl* pControl = GetFormControl(); | 878 CPDF_FormControl* pControl = GetFormControl(); |
| 910 ASSERT(pControl != NULL); | |
| 911 | |
| 912 CPDF_Rect rcWindow = GetRotatedRect(); | 879 CPDF_Rect rcWindow = GetRotatedRect(); |
| 913 | |
| 914 int32_t nLayout = 0; | 880 int32_t nLayout = 0; |
| 915 | |
| 916 switch (pControl->GetTextPosition()) { | 881 switch (pControl->GetTextPosition()) { |
| 917 case TEXTPOS_ICON: | 882 case TEXTPOS_ICON: |
| 918 nLayout = PPBL_ICON; | 883 nLayout = PPBL_ICON; |
| 919 break; | 884 break; |
| 920 case TEXTPOS_BELOW: | 885 case TEXTPOS_BELOW: |
| 921 nLayout = PPBL_ICONTOPLABELBOTTOM; | 886 nLayout = PPBL_ICONTOPLABELBOTTOM; |
| 922 break; | 887 break; |
| 923 case TEXTPOS_ABOVE: | 888 case TEXTPOS_ABOVE: |
| 924 nLayout = PPBL_LABELTOPICONBOTTOM; | 889 nLayout = PPBL_LABELTOPICONBOTTOM; |
| 925 break; | 890 break; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 if (pDownIcon) { | 1005 if (pDownIcon) { |
| 1041 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { | 1006 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { |
| 1042 if (pImageDict->GetString("Name").IsEmpty()) | 1007 if (pImageDict->GetString("Name").IsEmpty()) |
| 1043 pImageDict->SetAtString("Name", "ImgC"); | 1008 pImageDict->SetAtString("Name", "ImgC"); |
| 1044 } | 1009 } |
| 1045 } | 1010 } |
| 1046 | 1011 |
| 1047 CPDF_IconFit iconFit = pControl->GetIconFit(); | 1012 CPDF_IconFit iconFit = pControl->GetIconFit(); |
| 1048 | 1013 |
| 1049 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1014 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1050 ASSERT(pDoc != NULL); | |
| 1051 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1015 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1052 | 1016 |
| 1053 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 1017 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
| 1054 FontMap.Initial(); | 1018 FontMap.Initial(); |
| 1055 | 1019 |
| 1056 FontMap.SetAPType("N"); | 1020 FontMap.SetAPType("N"); |
| 1057 | 1021 |
| 1058 CFX_ByteString csAP = | 1022 CFX_ByteString csAP = |
| 1059 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + | 1023 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
| 1060 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 1024 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 if (pDownIcon) | 1086 if (pDownIcon) |
| 1123 AddImageToAppearance("D", pDownIcon); | 1087 AddImageToAppearance("D", pDownIcon); |
| 1124 } else { | 1088 } else { |
| 1125 RemoveAppearance("D"); | 1089 RemoveAppearance("D"); |
| 1126 RemoveAppearance("R"); | 1090 RemoveAppearance("R"); |
| 1127 } | 1091 } |
| 1128 } | 1092 } |
| 1129 | 1093 |
| 1130 void CPDFSDK_Widget::ResetAppearance_CheckBox() { | 1094 void CPDFSDK_Widget::ResetAppearance_CheckBox() { |
| 1131 CPDF_FormControl* pControl = GetFormControl(); | 1095 CPDF_FormControl* pControl = GetFormControl(); |
| 1132 ASSERT(pControl != NULL); | |
| 1133 | |
| 1134 CPWL_Color crBackground, crBorder, crText; | 1096 CPWL_Color crBackground, crBorder, crText; |
| 1135 | |
| 1136 int iColorType; | 1097 int iColorType; |
| 1137 FX_FLOAT fc[4]; | 1098 FX_FLOAT fc[4]; |
| 1138 | 1099 |
| 1139 pControl->GetOriginalBackgroundColor(iColorType, fc); | 1100 pControl->GetOriginalBackgroundColor(iColorType, fc); |
| 1140 if (iColorType > 0) | 1101 if (iColorType > 0) |
| 1141 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1102 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1142 | 1103 |
| 1143 pControl->GetOriginalBorderColor(iColorType, fc); | 1104 pControl->GetOriginalBorderColor(iColorType, fc); |
| 1144 if (iColorType > 0) | 1105 if (iColorType > 0) |
| 1145 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1106 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 pControl->GetCheckedAPState()); | 1212 pControl->GetCheckedAPState()); |
| 1252 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 1213 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
| 1253 | 1214 |
| 1254 CFX_ByteString csAS = GetAppState(); | 1215 CFX_ByteString csAS = GetAppState(); |
| 1255 if (csAS.IsEmpty()) | 1216 if (csAS.IsEmpty()) |
| 1256 SetAppState("Off"); | 1217 SetAppState("Off"); |
| 1257 } | 1218 } |
| 1258 | 1219 |
| 1259 void CPDFSDK_Widget::ResetAppearance_RadioButton() { | 1220 void CPDFSDK_Widget::ResetAppearance_RadioButton() { |
| 1260 CPDF_FormControl* pControl = GetFormControl(); | 1221 CPDF_FormControl* pControl = GetFormControl(); |
| 1261 ASSERT(pControl != NULL); | |
| 1262 | |
| 1263 CPWL_Color crBackground, crBorder, crText; | 1222 CPWL_Color crBackground, crBorder, crText; |
| 1264 | |
| 1265 int iColorType; | 1223 int iColorType; |
| 1266 FX_FLOAT fc[4]; | 1224 FX_FLOAT fc[4]; |
| 1267 | 1225 |
| 1268 pControl->GetOriginalBackgroundColor(iColorType, fc); | 1226 pControl->GetOriginalBackgroundColor(iColorType, fc); |
| 1269 if (iColorType > 0) | 1227 if (iColorType > 0) |
| 1270 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1228 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1271 | 1229 |
| 1272 pControl->GetOriginalBorderColor(iColorType, fc); | 1230 pControl->GetOriginalBorderColor(iColorType, fc); |
| 1273 if (iColorType > 0) | 1231 if (iColorType > 0) |
| 1274 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1232 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 pControl->GetCheckedAPState()); | 1375 pControl->GetCheckedAPState()); |
| 1418 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 1376 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
| 1419 | 1377 |
| 1420 CFX_ByteString csAS = GetAppState(); | 1378 CFX_ByteString csAS = GetAppState(); |
| 1421 if (csAS.IsEmpty()) | 1379 if (csAS.IsEmpty()) |
| 1422 SetAppState("Off"); | 1380 SetAppState("Off"); |
| 1423 } | 1381 } |
| 1424 | 1382 |
| 1425 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) { | 1383 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) { |
| 1426 CPDF_FormControl* pControl = GetFormControl(); | 1384 CPDF_FormControl* pControl = GetFormControl(); |
| 1427 ASSERT(pControl != NULL); | |
| 1428 CPDF_FormField* pField = pControl->GetField(); | 1385 CPDF_FormField* pField = pControl->GetField(); |
| 1429 ASSERT(pField != NULL); | |
| 1430 | |
| 1431 CFX_ByteTextBuf sBody, sLines; | 1386 CFX_ByteTextBuf sBody, sLines; |
| 1432 | 1387 |
| 1433 CPDF_Rect rcClient = GetClientRect(); | 1388 CPDF_Rect rcClient = GetClientRect(); |
| 1434 CPDF_Rect rcButton = rcClient; | 1389 CPDF_Rect rcButton = rcClient; |
| 1435 rcButton.left = rcButton.right - 13; | 1390 rcButton.left = rcButton.right - 13; |
| 1436 rcButton.Normalize(); | 1391 rcButton.Normalize(); |
| 1437 | 1392 |
| 1438 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1393 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
| 1439 pEdit->EnableRefresh(FALSE); | 1394 pEdit->EnableRefresh(FALSE); |
| 1440 | 1395 |
| 1441 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1396 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1442 ASSERT(pDoc != NULL); | |
| 1443 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1397 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1444 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 1398 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
| 1445 FontMap.Initial(); | 1399 FontMap.Initial(); |
| 1446 pEdit->SetFontMap(&FontMap); | 1400 pEdit->SetFontMap(&FontMap); |
| 1447 | 1401 |
| 1448 CPDF_Rect rcEdit = rcClient; | 1402 CPDF_Rect rcEdit = rcClient; |
| 1449 rcEdit.right = rcButton.left; | 1403 rcEdit.right = rcButton.left; |
| 1450 rcEdit.Normalize(); | 1404 rcEdit.Normalize(); |
| 1451 | 1405 |
| 1452 pEdit->SetPlateRect(rcEdit); | 1406 pEdit->SetPlateRect(rcEdit); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); | 1450 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); |
| 1497 | 1451 |
| 1498 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + | 1452 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
| 1499 sLines.GetByteString() + sBody.GetByteString(); | 1453 sLines.GetByteString() + sBody.GetByteString(); |
| 1500 | 1454 |
| 1501 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1455 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
| 1502 } | 1456 } |
| 1503 | 1457 |
| 1504 void CPDFSDK_Widget::ResetAppearance_ListBox() { | 1458 void CPDFSDK_Widget::ResetAppearance_ListBox() { |
| 1505 CPDF_FormControl* pControl = GetFormControl(); | 1459 CPDF_FormControl* pControl = GetFormControl(); |
| 1506 ASSERT(pControl != NULL); | |
| 1507 CPDF_FormField* pField = pControl->GetField(); | 1460 CPDF_FormField* pField = pControl->GetField(); |
| 1508 ASSERT(pField != NULL); | |
| 1509 | |
| 1510 CPDF_Rect rcClient = GetClientRect(); | 1461 CPDF_Rect rcClient = GetClientRect(); |
| 1511 | |
| 1512 CFX_ByteTextBuf sBody, sLines; | 1462 CFX_ByteTextBuf sBody, sLines; |
| 1513 | 1463 |
| 1514 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1464 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
| 1515 pEdit->EnableRefresh(FALSE); | 1465 pEdit->EnableRefresh(FALSE); |
| 1516 | 1466 |
| 1517 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1467 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1518 ASSERT(pDoc != NULL); | |
| 1519 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1468 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1520 | 1469 |
| 1521 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 1470 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
| 1522 FontMap.Initial(); | 1471 FontMap.Initial(); |
| 1523 pEdit->SetFontMap(&FontMap); | 1472 pEdit->SetFontMap(&FontMap); |
| 1524 | 1473 |
| 1525 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); | 1474 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
| 1526 | 1475 |
| 1527 FX_FLOAT fFontSize = GetFontSize(); | 1476 FX_FLOAT fFontSize = GetFontSize(); |
| 1528 | 1477 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 } | 1539 } |
| 1591 | 1540 |
| 1592 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + | 1541 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
| 1593 sLines.GetByteString() + sBody.GetByteString(); | 1542 sLines.GetByteString() + sBody.GetByteString(); |
| 1594 | 1543 |
| 1595 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1544 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
| 1596 } | 1545 } |
| 1597 | 1546 |
| 1598 void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { | 1547 void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { |
| 1599 CPDF_FormControl* pControl = GetFormControl(); | 1548 CPDF_FormControl* pControl = GetFormControl(); |
| 1600 ASSERT(pControl != NULL); | |
| 1601 CPDF_FormField* pField = pControl->GetField(); | 1549 CPDF_FormField* pField = pControl->GetField(); |
| 1602 ASSERT(pField != NULL); | |
| 1603 | |
| 1604 CFX_ByteTextBuf sBody, sLines; | 1550 CFX_ByteTextBuf sBody, sLines; |
| 1605 | 1551 |
| 1606 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1552 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
| 1607 pEdit->EnableRefresh(FALSE); | 1553 pEdit->EnableRefresh(FALSE); |
| 1608 | 1554 |
| 1609 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1555 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1610 ASSERT(pDoc != NULL); | |
| 1611 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1556 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1612 | 1557 |
| 1613 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 1558 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
| 1614 FontMap.Initial(); | 1559 FontMap.Initial(); |
| 1615 pEdit->SetFontMap(&FontMap); | 1560 pEdit->SetFontMap(&FontMap); |
| 1616 | 1561 |
| 1617 CPDF_Rect rcClient = GetClientRect(); | 1562 CPDF_Rect rcClient = GetClientRect(); |
| 1618 pEdit->SetPlateRect(rcClient); | 1563 pEdit->SetPlateRect(rcClient); |
| 1619 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1564 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
| 1620 | 1565 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 } | 1772 } |
| 1828 | 1773 |
| 1829 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 1774 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
| 1830 crLeftTop, crRightBottom, nBorderStyle, | 1775 crLeftTop, crRightBottom, nBorderStyle, |
| 1831 dsBorder); | 1776 dsBorder); |
| 1832 } | 1777 } |
| 1833 | 1778 |
| 1834 CFX_Matrix CPDFSDK_Widget::GetMatrix() const { | 1779 CFX_Matrix CPDFSDK_Widget::GetMatrix() const { |
| 1835 CFX_Matrix mt; | 1780 CFX_Matrix mt; |
| 1836 CPDF_FormControl* pControl = GetFormControl(); | 1781 CPDF_FormControl* pControl = GetFormControl(); |
| 1837 ASSERT(pControl != NULL); | |
| 1838 | |
| 1839 CPDF_Rect rcAnnot = GetRect(); | 1782 CPDF_Rect rcAnnot = GetRect(); |
| 1840 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; | 1783 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; |
| 1841 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; | 1784 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; |
| 1842 | 1785 |
| 1843 switch (abs(pControl->GetRotation() % 360)) { | 1786 switch (abs(pControl->GetRotation() % 360)) { |
| 1844 case 0: | 1787 case 0: |
| 1845 default: | 1788 default: |
| 1846 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); | 1789 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); |
| 1847 break; | 1790 break; |
| 1848 case 90: | 1791 case 90: |
| 1849 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0); | 1792 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0); |
| 1850 break; | 1793 break; |
| 1851 case 180: | 1794 case 180: |
| 1852 mt = CFX_Matrix(-1, 0, 0, -1, fWidth, fHeight); | 1795 mt = CFX_Matrix(-1, 0, 0, -1, fWidth, fHeight); |
| 1853 break; | 1796 break; |
| 1854 case 270: | 1797 case 270: |
| 1855 mt = CFX_Matrix(0, -1, 1, 0, 0, fHeight); | 1798 mt = CFX_Matrix(0, -1, 1, 0, 0, fHeight); |
| 1856 break; | 1799 break; |
| 1857 } | 1800 } |
| 1858 | 1801 |
| 1859 return mt; | 1802 return mt; |
| 1860 } | 1803 } |
| 1861 | 1804 |
| 1862 CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const { | 1805 CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const { |
| 1863 CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0); | 1806 CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0); |
| 1864 | 1807 |
| 1865 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1808 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 1866 ASSERT(pFormCtrl != NULL); | |
| 1867 | |
| 1868 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 1809 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
| 1869 if (da.HasColor()) { | 1810 if (da.HasColor()) { |
| 1870 int32_t iColorType; | 1811 int32_t iColorType; |
| 1871 FX_FLOAT fc[4]; | 1812 FX_FLOAT fc[4]; |
| 1872 da.GetColor(iColorType, fc); | 1813 da.GetColor(iColorType, fc); |
| 1873 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1814 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1874 } | 1815 } |
| 1875 | 1816 |
| 1876 return crText; | 1817 return crText; |
| 1877 } | 1818 } |
| 1878 | 1819 |
| 1879 CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const { | 1820 CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const { |
| 1880 CPWL_Color crBorder; | 1821 CPWL_Color crBorder; |
| 1881 | 1822 |
| 1882 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1823 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 1883 ASSERT(pFormCtrl != NULL); | |
| 1884 | |
| 1885 int32_t iColorType; | 1824 int32_t iColorType; |
| 1886 FX_FLOAT fc[4]; | 1825 FX_FLOAT fc[4]; |
| 1887 pFormCtrl->GetOriginalBorderColor(iColorType, fc); | 1826 pFormCtrl->GetOriginalBorderColor(iColorType, fc); |
| 1888 if (iColorType > 0) | 1827 if (iColorType > 0) |
| 1889 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1828 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1890 | 1829 |
| 1891 return crBorder; | 1830 return crBorder; |
| 1892 } | 1831 } |
| 1893 | 1832 |
| 1894 CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const { | 1833 CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const { |
| 1895 CPWL_Color crFill; | 1834 CPWL_Color crFill; |
| 1896 | 1835 |
| 1897 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1836 CPDF_FormControl* pFormCtrl = GetFormControl(); |
| 1898 ASSERT(pFormCtrl != NULL); | |
| 1899 | |
| 1900 int32_t iColorType; | 1837 int32_t iColorType; |
| 1901 FX_FLOAT fc[4]; | 1838 FX_FLOAT fc[4]; |
| 1902 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); | 1839 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); |
| 1903 if (iColorType > 0) | 1840 if (iColorType > 0) |
| 1904 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1841 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1905 | 1842 |
| 1906 return crFill; | 1843 return crFill; |
| 1907 } | 1844 } |
| 1908 | 1845 |
| 1909 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1846 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
| 1910 CPDF_Stream* pImage) { | 1847 CPDF_Stream* pImage) { |
| 1911 ASSERT(pImage != NULL); | |
| 1912 | |
| 1913 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 1848 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 1914 ASSERT(pDoc != NULL); | 1849 ASSERT(pDoc); |
| 1915 | 1850 |
| 1916 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 1851 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
| 1917 ASSERT(pAPDict != NULL); | |
| 1918 | |
| 1919 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); | 1852 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); |
| 1920 ASSERT(pStream != NULL); | |
| 1921 | |
| 1922 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1853 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| 1923 ASSERT(pStreamDict != NULL); | |
| 1924 | |
| 1925 CFX_ByteString sImageAlias = "IMG"; | 1854 CFX_ByteString sImageAlias = "IMG"; |
| 1926 | 1855 |
| 1927 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { | 1856 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { |
| 1928 sImageAlias = pImageDict->GetString("Name"); | 1857 sImageAlias = pImageDict->GetString("Name"); |
| 1929 if (sImageAlias.IsEmpty()) | 1858 if (sImageAlias.IsEmpty()) |
| 1930 sImageAlias = "IMG"; | 1859 sImageAlias = "IMG"; |
| 1931 } | 1860 } |
| 1932 | 1861 |
| 1933 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 1862 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
| 1934 if (!pStreamResList) { | 1863 if (!pStreamResList) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 } | 1958 } |
| 2030 default: | 1959 default: |
| 2031 break; | 1960 break; |
| 2032 } | 1961 } |
| 2033 | 1962 |
| 2034 return CPDF_Action(); | 1963 return CPDF_Action(); |
| 2035 } | 1964 } |
| 2036 | 1965 |
| 2037 CFX_WideString CPDFSDK_Widget::GetAlternateName() const { | 1966 CFX_WideString CPDFSDK_Widget::GetAlternateName() const { |
| 2038 CPDF_FormField* pFormField = GetFormField(); | 1967 CPDF_FormField* pFormField = GetFormField(); |
| 2039 ASSERT(pFormField != NULL); | |
| 2040 | |
| 2041 return pFormField->GetAlternateName(); | 1968 return pFormField->GetAlternateName(); |
| 2042 } | 1969 } |
| 2043 | 1970 |
| 2044 int32_t CPDFSDK_Widget::GetAppearanceAge() const { | 1971 int32_t CPDFSDK_Widget::GetAppearanceAge() const { |
| 2045 return m_nAppAge; | 1972 return m_nAppAge; |
| 2046 } | 1973 } |
| 2047 | 1974 |
| 2048 int32_t CPDFSDK_Widget::GetValueAge() const { | 1975 int32_t CPDFSDK_Widget::GetValueAge() const { |
| 2049 return m_nValueAge; | 1976 return m_nValueAge; |
| 2050 } | 1977 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 ASSERT(pFormCtrl); | 2117 ASSERT(pFormCtrl); |
| 2191 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); | 2118 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); |
| 2192 if (pWidget) | 2119 if (pWidget) |
| 2193 widgets->push_back(pWidget); | 2120 widgets->push_back(pWidget); |
| 2194 } | 2121 } |
| 2195 } | 2122 } |
| 2196 | 2123 |
| 2197 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( | 2124 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( |
| 2198 CPDF_Document* pDocument, | 2125 CPDF_Document* pDocument, |
| 2199 CPDF_Dictionary* pAnnotDict) const { | 2126 CPDF_Dictionary* pAnnotDict) const { |
| 2200 ASSERT(pDocument != NULL); | 2127 ASSERT(pAnnotDict); |
| 2201 ASSERT(pAnnotDict != NULL); | |
| 2202 | 2128 |
| 2203 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { | 2129 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { |
| 2204 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { | 2130 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { |
| 2205 if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) { | 2131 if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) { |
| 2206 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { | 2132 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { |
| 2207 CPDF_Object* pDict = pAnnots->GetElementValue(j); | 2133 CPDF_Object* pDict = pAnnots->GetElementValue(j); |
| 2208 if (pAnnotDict == pDict) { | 2134 if (pAnnotDict == pDict) { |
| 2209 return i; | 2135 return i; |
| 2210 } | 2136 } |
| 2211 } | 2137 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 } | 2245 } |
| 2320 | 2246 |
| 2321 delete pBmp; | 2247 delete pBmp; |
| 2322 } | 2248 } |
| 2323 | 2249 |
| 2324 return pRetStream; | 2250 return pRetStream; |
| 2325 } | 2251 } |
| 2326 #endif // _WIN32 | 2252 #endif // _WIN32 |
| 2327 | 2253 |
| 2328 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { | 2254 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { |
| 2329 ASSERT(m_pDocument != NULL); | |
| 2330 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2255 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2331 ASSERT(pEnv); | 2256 ASSERT(pEnv); |
| 2332 if (!pEnv->IsJSInitiated()) | 2257 if (!pEnv->IsJSInitiated()) |
| 2333 return; | 2258 return; |
| 2334 | 2259 |
| 2335 if (m_bBusy) | 2260 if (m_bBusy) |
| 2336 return; | 2261 return; |
| 2337 | 2262 |
| 2338 m_bBusy = TRUE; | 2263 m_bBusy = TRUE; |
| 2339 | 2264 |
| 2340 if (IsCalculateEnabled()) { | 2265 if (IsCalculateEnabled()) { |
| 2341 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 2266 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
| 2342 ASSERT(pRuntime != NULL); | |
| 2343 | |
| 2344 pRuntime->SetReaderDocument(m_pDocument); | 2267 pRuntime->SetReaderDocument(m_pDocument); |
| 2345 | 2268 |
| 2346 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 2269 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
| 2347 for (int i = 0; i < nSize; i++) { | 2270 for (int i = 0; i < nSize; i++) { |
| 2348 if (CPDF_FormField* pField = | 2271 if (CPDF_FormField* pField = |
| 2349 m_pInterForm->GetFieldInCalculationOrder(i)) { | 2272 m_pInterForm->GetFieldInCalculationOrder(i)) { |
| 2350 int nType = pField->GetFieldType(); | 2273 int nType = pField->GetFieldType(); |
| 2351 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2274 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
| 2352 CPDF_AAction aAction = pField->GetAdditionalAction(); | 2275 CPDF_AAction aAction = pField->GetAdditionalAction(); |
| 2353 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { | 2276 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { |
| 2354 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); | 2277 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
| 2355 if (action) { | 2278 if (action) { |
| 2356 CFX_WideString csJS = action.GetJavaScript(); | 2279 CFX_WideString csJS = action.GetJavaScript(); |
| 2357 if (!csJS.IsEmpty()) { | 2280 if (!csJS.IsEmpty()) { |
| 2358 IJS_Context* pContext = pRuntime->NewContext(); | 2281 IJS_Context* pContext = pRuntime->NewContext(); |
| 2359 ASSERT(pContext != NULL); | |
| 2360 | |
| 2361 CFX_WideString sOldValue = pField->GetValue(); | 2282 CFX_WideString sOldValue = pField->GetValue(); |
| 2362 CFX_WideString sValue = sOldValue; | 2283 CFX_WideString sValue = sOldValue; |
| 2363 FX_BOOL bRC = TRUE; | 2284 FX_BOOL bRC = TRUE; |
| 2364 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); | 2285 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
| 2365 | 2286 |
| 2366 CFX_WideString sInfo; | 2287 CFX_WideString sInfo; |
| 2367 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); | 2288 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); |
| 2368 pRuntime->ReleaseContext(pContext); | 2289 pRuntime->ReleaseContext(pContext); |
| 2369 | 2290 |
| 2370 if (bRet) { | 2291 if (bRet) { |
| 2371 if (bRC) { | 2292 if (bRC) { |
| 2372 if (sValue.Compare(sOldValue) != 0) | 2293 if (sValue.Compare(sOldValue) != 0) |
| 2373 pField->SetValue(sValue, TRUE); | 2294 pField->SetValue(sValue, TRUE); |
| 2374 } | 2295 } |
| 2375 } | 2296 } |
| 2376 } | 2297 } |
| 2377 } | 2298 } |
| 2378 } | 2299 } |
| 2379 } | 2300 } |
| 2380 } | 2301 } |
| 2381 } | 2302 } |
| 2382 } | 2303 } |
| 2383 | 2304 |
| 2384 m_bBusy = FALSE; | 2305 m_bBusy = FALSE; |
| 2385 } | 2306 } |
| 2386 | 2307 |
| 2387 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, | 2308 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, |
| 2388 FX_BOOL& bFormated) { | 2309 FX_BOOL& bFormated) { |
| 2389 ASSERT(m_pDocument != NULL); | |
| 2390 ASSERT(pFormField != NULL); | |
| 2391 | |
| 2392 CFX_WideString sValue = pFormField->GetValue(); | 2310 CFX_WideString sValue = pFormField->GetValue(); |
| 2393 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2311 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2394 ASSERT(pEnv); | 2312 ASSERT(pEnv); |
| 2395 if (!pEnv->IsJSInitiated()) { | 2313 if (!pEnv->IsJSInitiated()) { |
| 2396 bFormated = FALSE; | 2314 bFormated = FALSE; |
| 2397 return sValue; | 2315 return sValue; |
| 2398 } | 2316 } |
| 2399 | 2317 |
| 2400 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 2318 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
| 2401 ASSERT(pRuntime != NULL); | |
| 2402 | |
| 2403 pRuntime->SetReaderDocument(m_pDocument); | 2319 pRuntime->SetReaderDocument(m_pDocument); |
| 2404 | 2320 |
| 2405 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { | 2321 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { |
| 2406 if (pFormField->CountSelectedItems() > 0) { | 2322 if (pFormField->CountSelectedItems() > 0) { |
| 2407 int index = pFormField->GetSelectedIndex(0); | 2323 int index = pFormField->GetSelectedIndex(0); |
| 2408 if (index >= 0) | 2324 if (index >= 0) |
| 2409 sValue = pFormField->GetOptionLabel(index); | 2325 sValue = pFormField->GetOptionLabel(index); |
| 2410 } | 2326 } |
| 2411 } | 2327 } |
| 2412 | 2328 |
| 2413 bFormated = FALSE; | 2329 bFormated = FALSE; |
| 2414 | 2330 |
| 2415 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2331 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
| 2416 if (aAction && aAction.ActionExist(CPDF_AAction::Format)) { | 2332 if (aAction && aAction.ActionExist(CPDF_AAction::Format)) { |
| 2417 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); | 2333 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); |
| 2418 if (action) { | 2334 if (action) { |
| 2419 CFX_WideString script = action.GetJavaScript(); | 2335 CFX_WideString script = action.GetJavaScript(); |
| 2420 if (!script.IsEmpty()) { | 2336 if (!script.IsEmpty()) { |
| 2421 CFX_WideString Value = sValue; | 2337 CFX_WideString Value = sValue; |
| 2422 | 2338 |
| 2423 IJS_Context* pContext = pRuntime->NewContext(); | 2339 IJS_Context* pContext = pRuntime->NewContext(); |
| 2424 ASSERT(pContext != NULL); | |
| 2425 | |
| 2426 pContext->OnField_Format(pFormField, Value, TRUE); | 2340 pContext->OnField_Format(pFormField, Value, TRUE); |
| 2427 | 2341 |
| 2428 CFX_WideString sInfo; | 2342 CFX_WideString sInfo; |
| 2429 FX_BOOL bRet = pContext->RunScript(script, &sInfo); | 2343 FX_BOOL bRet = pContext->RunScript(script, &sInfo); |
| 2430 pRuntime->ReleaseContext(pContext); | 2344 pRuntime->ReleaseContext(pContext); |
| 2431 | 2345 |
| 2432 if (bRet) { | 2346 if (bRet) { |
| 2433 sValue = Value; | 2347 sValue = Value; |
| 2434 bFormated = TRUE; | 2348 bFormated = TRUE; |
| 2435 } | 2349 } |
| 2436 } | 2350 } |
| 2437 } | 2351 } |
| 2438 } | 2352 } |
| 2439 | 2353 |
| 2440 return sValue; | 2354 return sValue; |
| 2441 } | 2355 } |
| 2442 | 2356 |
| 2443 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, | 2357 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, |
| 2444 const FX_WCHAR* sValue, | 2358 const FX_WCHAR* sValue, |
| 2445 FX_BOOL bValueChanged) { | 2359 FX_BOOL bValueChanged) { |
| 2446 ASSERT(pFormField != NULL); | |
| 2447 | |
| 2448 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2360 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 2449 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2361 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
| 2450 ASSERT(pFormCtrl != NULL); | 2362 ASSERT(pFormCtrl); |
| 2451 | |
| 2452 ASSERT(m_pInterForm != NULL); | |
| 2453 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2363 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
| 2454 pWidget->ResetAppearance(sValue, bValueChanged); | 2364 pWidget->ResetAppearance(sValue, bValueChanged); |
| 2455 } | 2365 } |
| 2456 } | 2366 } |
| 2457 | 2367 |
| 2458 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { | 2368 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { |
| 2459 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2369 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 2460 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2370 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
| 2461 ASSERT(pFormCtrl != NULL); | 2371 ASSERT(pFormCtrl); |
| 2462 | 2372 |
| 2463 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { | 2373 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
| 2464 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2374 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2465 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); | 2375 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); |
| 2466 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 2376 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
| 2467 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); | 2377 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); |
| 2468 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); | 2378 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); |
| 2469 | 2379 |
| 2470 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, | 2380 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, |
| 2471 rcBBox.bottom); | 2381 rcBBox.bottom); |
| 2472 } | 2382 } |
| 2473 } | 2383 } |
| 2474 } | 2384 } |
| 2475 | 2385 |
| 2476 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, | 2386 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
| 2477 CFX_WideString& csValue, | 2387 CFX_WideString& csValue, |
| 2478 FX_BOOL& bRC) { | 2388 FX_BOOL& bRC) { |
| 2479 ASSERT(pFormField != NULL); | |
| 2480 | |
| 2481 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2389 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
| 2482 if (aAction && aAction.ActionExist(CPDF_AAction::KeyStroke)) { | 2390 if (aAction && aAction.ActionExist(CPDF_AAction::KeyStroke)) { |
| 2483 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 2391 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
| 2484 if (action) { | 2392 if (action) { |
| 2485 ASSERT(m_pDocument != NULL); | |
| 2486 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2393 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2487 ASSERT(pEnv != NULL); | |
| 2488 | |
| 2489 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 2394 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
| 2490 ASSERT(pActionHandler != NULL); | |
| 2491 | |
| 2492 PDFSDK_FieldAction fa; | 2395 PDFSDK_FieldAction fa; |
| 2493 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 2396 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
| 2494 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 2397 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
| 2495 fa.sValue = csValue; | 2398 fa.sValue = csValue; |
| 2496 | 2399 |
| 2497 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, | 2400 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, |
| 2498 m_pDocument, pFormField, fa); | 2401 m_pDocument, pFormField, fa); |
| 2499 bRC = fa.bRC; | 2402 bRC = fa.bRC; |
| 2500 } | 2403 } |
| 2501 } | 2404 } |
| 2502 } | 2405 } |
| 2503 | 2406 |
| 2504 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, | 2407 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
| 2505 CFX_WideString& csValue, | 2408 CFX_WideString& csValue, |
| 2506 FX_BOOL& bRC) { | 2409 FX_BOOL& bRC) { |
| 2507 ASSERT(pFormField != NULL); | |
| 2508 | |
| 2509 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2410 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
| 2510 if (aAction && aAction.ActionExist(CPDF_AAction::Validate)) { | 2411 if (aAction && aAction.ActionExist(CPDF_AAction::Validate)) { |
| 2511 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 2412 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
| 2512 if (action) { | 2413 if (action) { |
| 2513 ASSERT(m_pDocument != NULL); | |
| 2514 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2414 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2515 ASSERT(pEnv != NULL); | |
| 2516 | |
| 2517 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 2415 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
| 2518 ASSERT(pActionHandler != NULL); | |
| 2519 | |
| 2520 PDFSDK_FieldAction fa; | 2416 PDFSDK_FieldAction fa; |
| 2521 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 2417 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
| 2522 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 2418 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
| 2523 fa.sValue = csValue; | 2419 fa.sValue = csValue; |
| 2524 | 2420 |
| 2525 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, | 2421 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, |
| 2526 m_pDocument, pFormField, fa); | 2422 m_pDocument, pFormField, fa); |
| 2527 bRC = fa.bRC; | 2423 bRC = fa.bRC; |
| 2528 } | 2424 } |
| 2529 } | 2425 } |
| 2530 } | 2426 } |
| 2531 | 2427 |
| 2532 /* ----------------------------- action ----------------------------- */ | |
| 2533 | |
| 2534 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 2428 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
| 2535 ASSERT(action); | 2429 ASSERT(action); |
| 2536 | 2430 |
| 2537 CPDF_ActionFields af = action.GetWidgets(); | 2431 CPDF_ActionFields af = action.GetWidgets(); |
| 2538 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 2432 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
| 2539 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 2433 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
| 2540 | 2434 |
| 2541 FX_BOOL bHide = action.GetHideStatus(); | 2435 FX_BOOL bHide = action.GetHideStatus(); |
| 2542 FX_BOOL bChanged = FALSE; | 2436 FX_BOOL bChanged = FALSE; |
| 2543 | 2437 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2558 pWidget->GetPageView()->UpdateView(pWidget); | 2452 pWidget->GetPageView()->UpdateView(pWidget); |
| 2559 bChanged = TRUE; | 2453 bChanged = TRUE; |
| 2560 } | 2454 } |
| 2561 } | 2455 } |
| 2562 } | 2456 } |
| 2563 | 2457 |
| 2564 return bChanged; | 2458 return bChanged; |
| 2565 } | 2459 } |
| 2566 | 2460 |
| 2567 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { | 2461 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { |
| 2568 ASSERT(m_pInterForm != NULL); | |
| 2569 CFX_WideString sDestination = action.GetFilePath(); | 2462 CFX_WideString sDestination = action.GetFilePath(); |
| 2570 if (sDestination.IsEmpty()) | 2463 if (sDestination.IsEmpty()) |
| 2571 return FALSE; | 2464 return FALSE; |
| 2572 | 2465 |
| 2573 CPDF_Dictionary* pActionDict = action.GetDict(); | 2466 CPDF_Dictionary* pActionDict = action.GetDict(); |
| 2574 if (pActionDict->KeyExist("Fields")) { | 2467 if (pActionDict->KeyExist("Fields")) { |
| 2575 CPDF_ActionFields af = action.GetWidgets(); | 2468 CPDF_ActionFields af = action.GetWidgets(); |
| 2576 FX_DWORD dwFlags = action.GetFlags(); | 2469 FX_DWORD dwFlags = action.GetFlags(); |
| 2577 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 2470 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
| 2578 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 2471 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2692 const CFX_WideString& sFileExt) { | 2585 const CFX_WideString& sFileExt) { |
| 2693 CFX_WideString sFileName; | 2586 CFX_WideString sFileName; |
| 2694 return L""; | 2587 return L""; |
| 2695 } | 2588 } |
| 2696 | 2589 |
| 2697 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, | 2590 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
| 2698 FX_BOOL bUrlEncoded) { | 2591 FX_BOOL bUrlEncoded) { |
| 2699 if (sDestination.IsEmpty()) | 2592 if (sDestination.IsEmpty()) |
| 2700 return FALSE; | 2593 return FALSE; |
| 2701 | 2594 |
| 2595 if (!m_pDocument || !m_pInterForm) |
| 2596 return FALSE; |
| 2597 |
| 2702 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2598 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 2703 ASSERT(pEnv != NULL); | |
| 2704 | |
| 2705 if (!m_pDocument) | |
| 2706 return FALSE; | |
| 2707 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); | 2599 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); |
| 2708 | |
| 2709 if (!m_pInterForm) | |
| 2710 return FALSE; | |
| 2711 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); | 2600 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); |
| 2712 if (!pFDFDoc) | 2601 if (!pFDFDoc) |
| 2713 return FALSE; | 2602 return FALSE; |
| 2714 | 2603 |
| 2715 CFX_ByteTextBuf FdfBuffer; | 2604 CFX_ByteTextBuf FdfBuffer; |
| 2716 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 2605 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); |
| 2717 delete pFDFDoc; | 2606 delete pFDFDoc; |
| 2718 if (!bRet) | 2607 if (!bRet) |
| 2719 return FALSE; | 2608 return FALSE; |
| 2720 | 2609 |
| 2721 uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 2610 uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
| 2722 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 2611 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
| 2723 | 2612 |
| 2724 if (bUrlEncoded) { | 2613 if (bUrlEncoded) { |
| 2725 if (!FDFToURLEncodedData(pBuffer, nBufSize)) | 2614 if (!FDFToURLEncodedData(pBuffer, nBufSize)) |
| 2726 return FALSE; | 2615 return FALSE; |
| 2727 } | 2616 } |
| 2728 | 2617 |
| 2729 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 2618 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
| 2730 | 2619 |
| 2731 if (bUrlEncoded) { | 2620 if (bUrlEncoded) { |
| 2732 FX_Free(pBuffer); | 2621 FX_Free(pBuffer); |
| 2733 pBuffer = NULL; | 2622 pBuffer = NULL; |
| 2734 } | 2623 } |
| 2735 | 2624 |
| 2736 return TRUE; | 2625 return TRUE; |
| 2737 } | 2626 } |
| 2738 | 2627 |
| 2739 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 2628 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { |
| 2740 ASSERT(m_pInterForm != NULL); | |
| 2741 ASSERT(m_pDocument != NULL); | |
| 2742 | |
| 2743 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); | 2629 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); |
| 2744 if (!pFDF) | 2630 if (!pFDF) |
| 2745 return FALSE; | 2631 return FALSE; |
| 2746 | 2632 |
| 2747 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 2633 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
| 2748 delete pFDF; | 2634 delete pFDF; |
| 2749 | 2635 |
| 2750 return bRet; | 2636 return bRet; |
| 2751 } | 2637 } |
| 2752 | 2638 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2776 if (pObject && pObject->IsString()) { | 2662 if (pObject && pObject->IsString()) { |
| 2777 CFX_WideString csName = pObject->GetUnicodeText(); | 2663 CFX_WideString csName = pObject->GetUnicodeText(); |
| 2778 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); | 2664 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); |
| 2779 if (pField) | 2665 if (pField) |
| 2780 fields.push_back(pField); | 2666 fields.push_back(pField); |
| 2781 } | 2667 } |
| 2782 } | 2668 } |
| 2783 return fields; | 2669 return fields; |
| 2784 } | 2670 } |
| 2785 | 2671 |
| 2786 /* ----------------------------- CPDF_FormNotify ----------------------------- | |
| 2787 */ | |
| 2788 | |
| 2789 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, | 2672 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, |
| 2790 CFX_WideString& csValue) { | 2673 CFX_WideString& csValue) { |
| 2791 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2674 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
| 2792 int nType = pFormField->GetFieldType(); | 2675 int nType = pFormField->GetFieldType(); |
| 2793 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2676 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
| 2794 FX_BOOL bRC = TRUE; | 2677 FX_BOOL bRC = TRUE; |
| 2795 OnKeyStrokeCommit(pFormField, csValue, bRC); | 2678 OnKeyStrokeCommit(pFormField, csValue, bRC); |
| 2796 if (bRC) { | 2679 if (bRC) { |
| 2797 OnValidate(pFormField, csValue, bRC); | 2680 OnValidate(pFormField, csValue, bRC); |
| 2798 return bRC ? 1 : -1; | 2681 return bRC ? 1 : -1; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2919 | 2802 |
| 2920 /* ------------------------- CBA_AnnotIterator ------------------------- */ | 2803 /* ------------------------- CBA_AnnotIterator ------------------------- */ |
| 2921 | 2804 |
| 2922 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, | 2805 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, |
| 2923 const CFX_ByteString& sType, | 2806 const CFX_ByteString& sType, |
| 2924 const CFX_ByteString& sSubType) | 2807 const CFX_ByteString& sSubType) |
| 2925 : m_pPageView(pPageView), | 2808 : m_pPageView(pPageView), |
| 2926 m_sType(sType), | 2809 m_sType(sType), |
| 2927 m_sSubType(sSubType), | 2810 m_sSubType(sSubType), |
| 2928 m_nTabs(BAI_STRUCTURE) { | 2811 m_nTabs(BAI_STRUCTURE) { |
| 2929 ASSERT(m_pPageView != NULL); | |
| 2930 | |
| 2931 CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); | 2812 CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); |
| 2932 ASSERT(pPDFPage != NULL); | |
| 2933 ASSERT(pPDFPage->m_pFormDict != NULL); | |
| 2934 | |
| 2935 CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs"); | 2813 CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs"); |
| 2936 | 2814 |
| 2937 if (sTabs == "R") { | 2815 if (sTabs == "R") { |
| 2938 m_nTabs = BAI_ROW; | 2816 m_nTabs = BAI_ROW; |
| 2939 } else if (sTabs == "C") { | 2817 } else if (sTabs == "C") { |
| 2940 m_nTabs = BAI_COLUMN; | 2818 m_nTabs = BAI_COLUMN; |
| 2941 } else { | 2819 } else { |
| 2942 m_nTabs = BAI_STRUCTURE; | 2820 m_nTabs = BAI_STRUCTURE; |
| 2943 } | 2821 } |
| 2944 | 2822 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); | 2865 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); |
| 2988 | 2866 |
| 2989 if (rcAnnot1.left < rcAnnot2.left) | 2867 if (rcAnnot1.left < rcAnnot2.left) |
| 2990 return -1; | 2868 return -1; |
| 2991 if (rcAnnot1.left > rcAnnot2.left) | 2869 if (rcAnnot1.left > rcAnnot2.left) |
| 2992 return 1; | 2870 return 1; |
| 2993 return 0; | 2871 return 0; |
| 2994 } | 2872 } |
| 2995 | 2873 |
| 2996 int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { | 2874 int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
| 2997 ASSERT(p1 != NULL); | 2875 ASSERT(p1); |
| 2998 ASSERT(p2 != NULL); | 2876 ASSERT(p2); |
| 2999 | 2877 |
| 3000 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); | 2878 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); |
| 3001 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); | 2879 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); |
| 3002 | 2880 |
| 3003 if (rcAnnot1.top < rcAnnot2.top) | 2881 if (rcAnnot1.top < rcAnnot2.top) |
| 3004 return -1; | 2882 return -1; |
| 3005 if (rcAnnot1.top > rcAnnot2.top) | 2883 if (rcAnnot1.top > rcAnnot2.top) |
| 3006 return 1; | 2884 return 1; |
| 3007 return 0; | 2885 return 0; |
| 3008 } | 2886 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 break; | 3018 break; |
| 3141 } | 3019 } |
| 3142 } | 3020 } |
| 3143 } | 3021 } |
| 3144 | 3022 |
| 3145 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { | 3023 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
| 3146 CPDF_Rect rcAnnot; | 3024 CPDF_Rect rcAnnot; |
| 3147 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 3025 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
| 3148 return rcAnnot; | 3026 return rcAnnot; |
| 3149 } | 3027 } |
| OLD | NEW |