| OLD | NEW | 
|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 
| 6 | 6 | 
| 7 #include "fpdfsdk/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <memory> | 10 #include <memory> | 
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 656 #endif  // PDF_ENABLE_XFA | 656 #endif  // PDF_ENABLE_XFA | 
| 657   CPDF_FormField* pFormField = GetFormField(); | 657   CPDF_FormField* pFormField = GetFormField(); | 
| 658   return pFormField->IsItemSelected(nIndex); | 658   return pFormField->IsItemSelected(nIndex); | 
| 659 } | 659 } | 
| 660 | 660 | 
| 661 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 661 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 
| 662   CPDF_FormField* pFormField = GetFormField(); | 662   CPDF_FormField* pFormField = GetFormField(); | 
| 663   return pFormField->GetTopVisibleIndex(); | 663   return pFormField->GetTopVisibleIndex(); | 
| 664 } | 664 } | 
| 665 | 665 | 
| 666 FX_BOOL CPDFSDK_Widget::IsChecked() const { | 666 bool CPDFSDK_Widget::IsChecked() const { | 
| 667 #ifdef PDF_ENABLE_XFA | 667 #ifdef PDF_ENABLE_XFA | 
| 668   if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 668   if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 
| 669     if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 669     if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 
| 670       if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) | 670       if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) | 
| 671         return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | 671         return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | 
| 672     } | 672     } | 
| 673   } | 673   } | 
| 674 #endif  // PDF_ENABLE_XFA | 674 #endif  // PDF_ENABLE_XFA | 
| 675   CPDF_FormControl* pFormCtrl = GetFormControl(); | 675   CPDF_FormControl* pFormCtrl = GetFormControl(); | 
| 676   return pFormCtrl->IsChecked(); | 676   return pFormCtrl->IsChecked(); | 
| 677 } | 677 } | 
| 678 | 678 | 
| 679 int CPDFSDK_Widget::GetAlignment() const { | 679 int CPDFSDK_Widget::GetAlignment() const { | 
| 680   CPDF_FormControl* pFormCtrl = GetFormControl(); | 680   CPDF_FormControl* pFormCtrl = GetFormControl(); | 
| 681   return pFormCtrl->GetControlAlignment(); | 681   return pFormCtrl->GetControlAlignment(); | 
| 682 } | 682 } | 
| 683 | 683 | 
| 684 int CPDFSDK_Widget::GetMaxLen() const { | 684 int CPDFSDK_Widget::GetMaxLen() const { | 
| 685   CPDF_FormField* pFormField = GetFormField(); | 685   CPDF_FormField* pFormField = GetFormField(); | 
| 686   return pFormField->GetMaxLen(); | 686   return pFormField->GetMaxLen(); | 
| 687 } | 687 } | 
| 688 | 688 | 
| 689 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { | 689 void CPDFSDK_Widget::SetCheck(bool bChecked, bool bNotify) { | 
| 690   CPDF_FormControl* pFormCtrl = GetFormControl(); | 690   CPDF_FormControl* pFormCtrl = GetFormControl(); | 
| 691   CPDF_FormField* pFormField = pFormCtrl->GetField(); | 691   CPDF_FormField* pFormField = pFormCtrl->GetField(); | 
| 692   pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, | 692   pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, | 
| 693                            bNotify); | 693                            bNotify); | 
| 694 #ifdef PDF_ENABLE_XFA | 694 #ifdef PDF_ENABLE_XFA | 
| 695   if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) | 695   if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) | 
| 696     ResetAppearance(TRUE); | 696     ResetAppearance(TRUE); | 
| 697   if (!bNotify) | 697   if (!bNotify) | 
| 698     Synchronize(TRUE); | 698     Synchronize(TRUE); | 
| 699 #endif  // PDF_ENABLE_XFA | 699 #endif  // PDF_ENABLE_XFA | 
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2366 | 2366 | 
| 2367   FX_BOOL bHide = action.GetHideStatus(); | 2367   FX_BOOL bHide = action.GetHideStatus(); | 
| 2368   FX_BOOL bChanged = FALSE; | 2368   FX_BOOL bChanged = FALSE; | 
| 2369 | 2369 | 
| 2370   for (CPDF_FormField* pField : fields) { | 2370   for (CPDF_FormField* pField : fields) { | 
| 2371     for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { | 2371     for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { | 
| 2372       CPDF_FormControl* pControl = pField->GetControl(i); | 2372       CPDF_FormControl* pControl = pField->GetControl(i); | 
| 2373       ASSERT(pControl); | 2373       ASSERT(pControl); | 
| 2374 | 2374 | 
| 2375       if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { | 2375       if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { | 
| 2376         int nFlags = pWidget->GetFlags(); | 2376         FX_DWORD nFlags = pWidget->GetFlags(); | 
| 2377         nFlags &= ~ANNOTFLAG_INVISIBLE; | 2377         nFlags &= ~ANNOTFLAG_INVISIBLE; | 
| 2378         nFlags &= ~ANNOTFLAG_NOVIEW; | 2378         nFlags &= ~ANNOTFLAG_NOVIEW; | 
| 2379         if (bHide) | 2379         if (bHide) | 
| 2380           nFlags |= ANNOTFLAG_HIDDEN; | 2380           nFlags |= ANNOTFLAG_HIDDEN; | 
| 2381         else | 2381         else | 
| 2382           nFlags &= ~ANNOTFLAG_HIDDEN; | 2382           nFlags &= ~ANNOTFLAG_HIDDEN; | 
| 2383         pWidget->SetFlags(nFlags); | 2383         pWidget->SetFlags(nFlags); | 
| 2384         pWidget->GetPageView()->UpdateView(pWidget); | 2384         pWidget->GetPageView()->UpdateView(pWidget); | 
| 2385         bChanged = TRUE; | 2385         bChanged = TRUE; | 
| 2386       } | 2386       } | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 2399   if (pActionDict->KeyExist("Fields")) { | 2399   if (pActionDict->KeyExist("Fields")) { | 
| 2400     CPDF_ActionFields af(&action); | 2400     CPDF_ActionFields af(&action); | 
| 2401     FX_DWORD dwFlags = action.GetFlags(); | 2401     FX_DWORD dwFlags = action.GetFlags(); | 
| 2402     std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 2402     std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 
| 2403     std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 2403     std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 
| 2404     if (!fields.empty()) { | 2404     if (!fields.empty()) { | 
| 2405       bool bIncludeOrExclude = !(dwFlags & 0x01); | 2405       bool bIncludeOrExclude = !(dwFlags & 0x01); | 
| 2406       if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) | 2406       if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) | 
| 2407         return FALSE; | 2407         return FALSE; | 
| 2408 | 2408 | 
| 2409       return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE); | 2409       return SubmitFields(sDestination, fields, bIncludeOrExclude, false); | 
| 2410     } | 2410     } | 
| 2411   } | 2411   } | 
| 2412   if (m_pInterForm->CheckRequiredFields(nullptr, true)) | 2412   if (m_pInterForm->CheckRequiredFields(nullptr, true)) | 
| 2413     return FALSE; | 2413     return FALSE; | 
| 2414 | 2414 | 
| 2415   return SubmitForm(sDestination, FALSE); | 2415   return SubmitForm(sDestination, FALSE); | 
| 2416 } | 2416 } | 
| 2417 | 2417 | 
| 2418 FX_BOOL CPDFSDK_InterForm::SubmitFields( | 2418 FX_BOOL CPDFSDK_InterForm::SubmitFields( | 
| 2419     const CFX_WideString& csDestination, | 2419     const CFX_WideString& csDestination, | 
| 2420     const std::vector<CPDF_FormField*>& fields, | 2420     const std::vector<CPDF_FormField*>& fields, | 
| 2421     FX_BOOL bIncludeOrExclude, | 2421     bool bIncludeOrExclude, | 
| 2422     FX_BOOL bUrlEncoded) { | 2422     bool bUrlEncoded) { | 
| 2423   CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2423   CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 
| 2424 | 2424 | 
| 2425   CFX_ByteTextBuf textBuf; | 2425   CFX_ByteTextBuf textBuf; | 
| 2426   ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 2426   ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 
| 2427 | 2427 | 
| 2428   uint8_t* pBuffer = textBuf.GetBuffer(); | 2428   uint8_t* pBuffer = textBuf.GetBuffer(); | 
| 2429   FX_STRSIZE nBufSize = textBuf.GetLength(); | 2429   FX_STRSIZE nBufSize = textBuf.GetLength(); | 
| 2430 | 2430 | 
| 2431   if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 2431   if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 
| 2432     return FALSE; | 2432     return FALSE; | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2476 | 2476 | 
| 2477     nBufSize = fdfEncodedData.GetLength(); | 2477     nBufSize = fdfEncodedData.GetLength(); | 
| 2478     pBuf = FX_Alloc(uint8_t, nBufSize); | 2478     pBuf = FX_Alloc(uint8_t, nBufSize); | 
| 2479     FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 2479     FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 
| 2480   } | 2480   } | 
| 2481   return TRUE; | 2481   return TRUE; | 
| 2482 } | 2482 } | 
| 2483 | 2483 | 
| 2484 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( | 2484 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( | 
| 2485     const std::vector<CPDF_FormField*>& fields, | 2485     const std::vector<CPDF_FormField*>& fields, | 
| 2486     FX_BOOL bIncludeOrExclude, | 2486     bool bIncludeOrExclude, | 
| 2487     CFX_ByteTextBuf& textBuf) { | 2487     CFX_ByteTextBuf& textBuf) { | 
| 2488   std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( | 2488   std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( | 
| 2489       m_pDocument->GetPath(), fields, bIncludeOrExclude)); | 2489       m_pDocument->GetPath(), fields, bIncludeOrExclude)); | 
| 2490   return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 2490   return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 
| 2491 } | 2491 } | 
| 2492 | 2492 | 
| 2493 #ifdef PDF_ENABLE_XFA | 2493 #ifdef PDF_ENABLE_XFA | 
| 2494 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 2494 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 
| 2495                                          FX_BOOL bSynchronizeElse) { | 2495                                          FX_BOOL bSynchronizeElse) { | 
| 2496   int x = 0; | 2496   int x = 0; | 
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2863       break; | 2863       break; | 
| 2864     } | 2864     } | 
| 2865   } | 2865   } | 
| 2866 } | 2866 } | 
| 2867 | 2867 | 
| 2868 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2868 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 
| 2869   CFX_FloatRect rcAnnot; | 2869   CFX_FloatRect rcAnnot; | 
| 2870   pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2870   pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 
| 2871   return rcAnnot; | 2871   return rcAnnot; | 
| 2872 } | 2872 } | 
| OLD | NEW | 
|---|