| OLD | NEW | 
|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 
| 6 | 6 | 
| 7 #include "fpdfsdk/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <map> | 10 #include <map> | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 34 | 34 | 
| 35 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 35 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 
| 36                                CPDFSDK_PageView* pPageView, | 36                                CPDFSDK_PageView* pPageView, | 
| 37                                CPDFSDK_InterForm* pInterForm) | 37                                CPDFSDK_InterForm* pInterForm) | 
| 38     : CPDFSDK_BAAnnot(pAnnot, pPageView), | 38     : CPDFSDK_BAAnnot(pAnnot, pPageView), | 
| 39       m_pInterForm(pInterForm), | 39       m_pInterForm(pInterForm), | 
| 40       m_nAppAge(0), | 40       m_nAppAge(0), | 
| 41       m_nValueAge(0) | 41       m_nValueAge(0) | 
| 42 #ifdef PDF_ENABLE_XFA | 42 #ifdef PDF_ENABLE_XFA | 
| 43       , | 43       , | 
| 44       m_hMixXFAWidget(NULL), | 44       m_hMixXFAWidget(nullptr), | 
| 45       m_pWidgetHandler(NULL) | 45       m_pWidgetHandler(nullptr) | 
| 46 #endif  // PDF_ENABLE_XFA | 46 #endif  // PDF_ENABLE_XFA | 
| 47 { | 47 { | 
| 48 } | 48 } | 
| 49 | 49 | 
| 50 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 50 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 
| 51 | 51 | 
| 52 #ifdef PDF_ENABLE_XFA | 52 #ifdef PDF_ENABLE_XFA | 
| 53 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { | 53 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { | 
| 54   CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 54   CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 
| 55   CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 55   CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 
| 56   if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 56   if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 
| 57     if (!m_hMixXFAWidget) { | 57     if (!m_hMixXFAWidget) { | 
| 58       if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 58       if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 
| 59         CFX_WideString sName; | 59         CFX_WideString sName; | 
| 60         if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 60         if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 
| 61           sName = GetAnnotName(); | 61           sName = GetAnnotName(); | 
| 62           if (sName.IsEmpty()) | 62           if (sName.IsEmpty()) | 
| 63             sName = GetName(); | 63             sName = GetName(); | 
| 64         } else { | 64         } else { | 
| 65           sName = GetName(); | 65           sName = GetName(); | 
| 66         } | 66         } | 
| 67 | 67 | 
| 68         if (!sName.IsEmpty()) | 68         if (!sName.IsEmpty()) | 
| 69           m_hMixXFAWidget = pDocView->GetWidgetByName(sName); | 69           m_hMixXFAWidget = pDocView->GetWidgetByName(sName); | 
| 70       } | 70       } | 
| 71     } | 71     } | 
| 72     return m_hMixXFAWidget; | 72     return m_hMixXFAWidget; | 
| 73   } | 73   } | 
| 74 | 74 | 
| 75   return NULL; | 75   return nullptr; | 
| 76 } | 76 } | 
| 77 | 77 | 
| 78 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { | 78 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { | 
| 79   CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 79   CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 
| 80   CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 80   CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 
| 81   if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 81   if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 
| 82     if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 82     if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 
| 83       CFX_WideString sName = GetName(); | 83       CFX_WideString sName = GetName(); | 
| 84       if (!sName.IsEmpty()) | 84       if (!sName.IsEmpty()) | 
| 85         return pDocView->GetWidgetByName(sName); | 85         return pDocView->GetWidgetByName(sName); | 
| 86     } | 86     } | 
| 87   } | 87   } | 
| 88 | 88 | 
| 89   return nullptr; | 89   return nullptr; | 
| 90 } | 90 } | 
| 91 | 91 | 
| 92 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { | 92 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { | 
| 93   CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 93   CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 
| 94   CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 94   CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 
| 95   if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 95   if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 
| 96     if (!m_pWidgetHandler) { | 96     if (!m_pWidgetHandler) { | 
| 97       if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 97       if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 
| 98         m_pWidgetHandler = pDocView->GetWidgetHandler(); | 98         m_pWidgetHandler = pDocView->GetWidgetHandler(); | 
| 99       } | 99       } | 
| 100     } | 100     } | 
| 101     return m_pWidgetHandler; | 101     return m_pWidgetHandler; | 
| 102   } | 102   } | 
| 103 | 103 | 
| 104   return NULL; | 104   return nullptr; | 
| 105 } | 105 } | 
| 106 | 106 | 
| 107 static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) { | 107 static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) { | 
| 108   XFA_EVENTTYPE eEventType = XFA_EVENT_Unknown; | 108   XFA_EVENTTYPE eEventType = XFA_EVENT_Unknown; | 
| 109 | 109 | 
| 110   switch (eXFAAAT) { | 110   switch (eXFAAAT) { | 
| 111     case PDFSDK_XFA_Click: | 111     case PDFSDK_XFA_Click: | 
| 112       eEventType = XFA_EVENT_Click; | 112       eEventType = XFA_EVENT_Click; | 
| 113       break; | 113       break; | 
| 114     case PDFSDK_XFA_Full: | 114     case PDFSDK_XFA_Full: | 
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 767 | 767 | 
| 768 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) { | 768 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) { | 
| 769   CPDF_FormField* pFormField = GetFormField(); | 769   CPDF_FormField* pFormField = GetFormField(); | 
| 770   ASSERT(pFormField); | 770   ASSERT(pFormField); | 
| 771   return m_pInterForm->OnFormat(pFormField, bFormated); | 771   return m_pInterForm->OnFormat(pFormField, bFormated); | 
| 772 } | 772 } | 
| 773 | 773 | 
| 774 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { | 774 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { | 
| 775   CPDF_FormField* pFormField = GetFormField(); | 775   CPDF_FormField* pFormField = GetFormField(); | 
| 776   ASSERT(pFormField); | 776   ASSERT(pFormField); | 
| 777   m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); | 777   m_pInterForm->ResetFieldAppearance(pFormField, nullptr, bValueChanged); | 
| 778 } | 778 } | 
| 779 | 779 | 
| 780 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, | 780 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, | 
| 781                                     const CFX_Matrix* pUser2Device, | 781                                     const CFX_Matrix* pUser2Device, | 
| 782                                     CPDF_Annot::AppearanceMode mode, | 782                                     CPDF_Annot::AppearanceMode mode, | 
| 783                                     const CPDF_RenderOptions* pOptions) { | 783                                     const CPDF_RenderOptions* pOptions) { | 
| 784   int nFieldType = GetFieldType(); | 784   int nFieldType = GetFieldType(); | 
| 785 | 785 | 
| 786   if ((nFieldType == FIELDTYPE_CHECKBOX || | 786   if ((nFieldType == FIELDTYPE_CHECKBOX || | 
| 787        nFieldType == FIELDTYPE_RADIOBUTTON) && | 787        nFieldType == FIELDTYPE_RADIOBUTTON) && | 
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 925   if (pControl->HasMKEntry("CA")) { | 925   if (pControl->HasMKEntry("CA")) { | 
| 926     csNormalCaption = pControl->GetNormalCaption(); | 926     csNormalCaption = pControl->GetNormalCaption(); | 
| 927   } | 927   } | 
| 928   if (pControl->HasMKEntry("RC")) { | 928   if (pControl->HasMKEntry("RC")) { | 
| 929     csRolloverCaption = pControl->GetRolloverCaption(); | 929     csRolloverCaption = pControl->GetRolloverCaption(); | 
| 930   } | 930   } | 
| 931   if (pControl->HasMKEntry("AC")) { | 931   if (pControl->HasMKEntry("AC")) { | 
| 932     csDownCaption = pControl->GetDownCaption(); | 932     csDownCaption = pControl->GetDownCaption(); | 
| 933   } | 933   } | 
| 934 | 934 | 
| 935   CPDF_Stream* pNormalIcon = NULL; | 935   CPDF_Stream* pNormalIcon = nullptr; | 
| 936   CPDF_Stream* pRolloverIcon = NULL; | 936   CPDF_Stream* pRolloverIcon = nullptr; | 
| 937   CPDF_Stream* pDownIcon = NULL; | 937   CPDF_Stream* pDownIcon = nullptr; | 
| 938 | 938 | 
| 939   if (pControl->HasMKEntry("I")) { | 939   if (pControl->HasMKEntry("I")) { | 
| 940     pNormalIcon = pControl->GetNormalIcon(); | 940     pNormalIcon = pControl->GetNormalIcon(); | 
| 941   } | 941   } | 
| 942   if (pControl->HasMKEntry("RI")) { | 942   if (pControl->HasMKEntry("RI")) { | 
| 943     pRolloverIcon = pControl->GetRolloverIcon(); | 943     pRolloverIcon = pControl->GetRolloverIcon(); | 
| 944   } | 944   } | 
| 945   if (pControl->HasMKEntry("IX")) { | 945   if (pControl->HasMKEntry("IX")) { | 
| 946     pDownIcon = pControl->GetDownIcon(); | 946     pDownIcon = pControl->GetDownIcon(); | 
| 947   } | 947   } | 
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1564   pEdit->Initialize(); | 1564   pEdit->Initialize(); | 
| 1565 | 1565 | 
| 1566   if (sValue) | 1566   if (sValue) | 
| 1567     pEdit->SetText(sValue); | 1567     pEdit->SetText(sValue); | 
| 1568   else | 1568   else | 
| 1569     pEdit->SetText(pField->GetValue().c_str()); | 1569     pEdit->SetText(pField->GetValue().c_str()); | 
| 1570 | 1570 | 
| 1571   CFX_FloatRect rcContent = pEdit->GetContentRect(); | 1571   CFX_FloatRect rcContent = pEdit->GetContentRect(); | 
| 1572 | 1572 | 
| 1573   CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream( | 1573   CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream( | 
| 1574       pEdit, CFX_FloatPoint(0.0f, 0.0f), NULL, !bCharArray, subWord); | 1574       pEdit, CFX_FloatPoint(0.0f, 0.0f), nullptr, !bCharArray, subWord); | 
| 1575 | 1575 | 
| 1576   if (sEdit.GetLength() > 0) { | 1576   if (sEdit.GetLength() > 0) { | 
| 1577     sBody << "/Tx BMC\n" | 1577     sBody << "/Tx BMC\n" | 
| 1578           << "q\n"; | 1578           << "q\n"; | 
| 1579     if (rcContent.Width() > rcClient.Width() || | 1579     if (rcContent.Width() > rcClient.Width() || | 
| 1580         rcContent.Height() > rcClient.Height()) { | 1580         rcContent.Height() > rcClient.Height()) { | 
| 1581       sBody << rcClient.left << " " << rcClient.bottom << " " | 1581       sBody << rcClient.left << " " << rcClient.bottom << " " | 
| 1582             << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; | 1582             << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; | 
| 1583     } | 1583     } | 
| 1584     CPWL_Color crText = GetTextPWLColor(); | 1584     CPWL_Color crText = GetTextPWLColor(); | 
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2480   uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 2480   uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 
| 2481   FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 2481   FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 
| 2482 | 2482 | 
| 2483   if (bUrlEncoded) { | 2483   if (bUrlEncoded) { | 
| 2484     if (!FDFToURLEncodedData(pBuffer, nBufSize)) | 2484     if (!FDFToURLEncodedData(pBuffer, nBufSize)) | 
| 2485       return FALSE; | 2485       return FALSE; | 
| 2486   } | 2486   } | 
| 2487 | 2487 | 
| 2488   pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 2488   pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 
| 2489 | 2489 | 
| 2490   if (bUrlEncoded) { | 2490   if (bUrlEncoded) | 
| 2491     FX_Free(pBuffer); | 2491     FX_Free(pBuffer); | 
| 2492     pBuffer = NULL; |  | 
| 2493   } |  | 
| 2494 | 2492 | 
| 2495   return TRUE; | 2493   return TRUE; | 
| 2496 } | 2494 } | 
| 2497 | 2495 | 
| 2498 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 2496 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 
| 2499   CFDF_Document* pFDF = | 2497   CFDF_Document* pFDF = | 
| 2500       m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC()); | 2498       m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC()); | 
| 2501   if (!pFDF) | 2499   if (!pFDF) | 
| 2502     return FALSE; | 2500     return FALSE; | 
| 2503 | 2501 | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2579 | 2577 | 
| 2580   if (!OnValidate(pField, csValue)) | 2578   if (!OnValidate(pField, csValue)) | 
| 2581     return -1; | 2579     return -1; | 
| 2582 | 2580 | 
| 2583   return 1; | 2581   return 1; | 
| 2584 } | 2582 } | 
| 2585 | 2583 | 
| 2586 void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { | 2584 void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { | 
| 2587   if (pField->GetFieldType() == FIELDTYPE_LISTBOX) { | 2585   if (pField->GetFieldType() == FIELDTYPE_LISTBOX) { | 
| 2588     OnCalculate(pField); | 2586     OnCalculate(pField); | 
| 2589     ResetFieldAppearance(pField, NULL, TRUE); | 2587     ResetFieldAppearance(pField, nullptr, TRUE); | 
| 2590     UpdateField(pField); | 2588     UpdateField(pField); | 
| 2591   } | 2589   } | 
| 2592 } | 2590 } | 
| 2593 | 2591 | 
| 2594 void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { | 2592 void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { | 
| 2595   int nType = pField->GetFieldType(); | 2593   int nType = pField->GetFieldType(); | 
| 2596   if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) { | 2594   if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) { | 
| 2597     OnCalculate(pField); | 2595     OnCalculate(pField); | 
| 2598     UpdateField(pField); | 2596     UpdateField(pField); | 
| 2599   } | 2597   } | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2806       break; | 2804       break; | 
| 2807     } | 2805     } | 
| 2808   } | 2806   } | 
| 2809 } | 2807 } | 
| 2810 | 2808 | 
| 2811 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2809 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 
| 2812   CFX_FloatRect rcAnnot; | 2810   CFX_FloatRect rcAnnot; | 
| 2813   pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2811   pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 
| 2814   return rcAnnot; | 2812   return rcAnnot; | 
| 2815 } | 2813 } | 
| OLD | NEW | 
|---|