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 "../include/formfiller/FFL_FormFiller.h" | 7 #include "../include/formfiller/FFL_FormFiller.h" |
8 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "../include/fpdfxfa/fpdfxfa_util.h" | 9 #include "../include/fpdfxfa/fpdfxfa_util.h" |
10 #include "../include/fsdk_actionhandler.h" | 10 #include "../include/fsdk_actionhandler.h" |
11 #include "../include/fsdk_baseannot.h" | 11 #include "../include/fsdk_baseannot.h" |
12 #include "../include/fsdk_baseform.h" | 12 #include "../include/fsdk_baseform.h" |
13 #include "../include/fsdk_define.h" | 13 #include "../include/fsdk_define.h" |
14 #include "../include/fsdk_mgr.h" | 14 #include "../include/fsdk_mgr.h" |
15 #include "../include/javascript/IJavaScript.h" | 15 #include "../include/javascript/IJavaScript.h" |
16 #include "third_party/base/nonstd_unique_ptr.h" | 16 #include "third_party/base/nonstd_unique_ptr.h" |
17 | 17 |
18 //------------------------------------------------------------------------------
------ | |
19 //* CPDFSDK_Widget | |
20 //------------------------------------------------------------------------------
------ | |
21 | |
22 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) | 18 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) |
23 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 19 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
24 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 20 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
25 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 21 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
26 | 22 |
27 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 23 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, |
28 CPDFSDK_PageView* pPageView, | 24 CPDFSDK_PageView* pPageView, |
29 CPDFSDK_InterForm* pInterForm) | 25 CPDFSDK_InterForm* pInterForm) |
30 : CPDFSDK_BAAnnot(pAnnot, pPageView), | 26 : CPDFSDK_BAAnnot(pAnnot, pPageView), |
31 m_pInterForm(pInterForm), | 27 m_pInterForm(pInterForm), |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 pEdit->SetAlignmentV(1); | 1488 pEdit->SetAlignmentV(1); |
1493 | 1489 |
1494 FX_FLOAT fFontSize = GetFontSize(); | 1490 FX_FLOAT fFontSize = GetFontSize(); |
1495 if (IsFloatZero(fFontSize)) | 1491 if (IsFloatZero(fFontSize)) |
1496 pEdit->SetAutoFontSize(TRUE); | 1492 pEdit->SetAutoFontSize(TRUE); |
1497 else | 1493 else |
1498 pEdit->SetFontSize(fFontSize); | 1494 pEdit->SetFontSize(fFontSize); |
1499 | 1495 |
1500 pEdit->Initialize(); | 1496 pEdit->Initialize(); |
1501 | 1497 |
1502 if (sValue) | 1498 if (sValue) { |
1503 pEdit->SetText(sValue); | 1499 pEdit->SetText(sValue); |
1504 else { | 1500 } else { |
1505 int32_t nCurSel = pField->GetSelectedIndex(0); | 1501 int32_t nCurSel = pField->GetSelectedIndex(0); |
1506 | 1502 |
1507 if (nCurSel < 0) | 1503 if (nCurSel < 0) |
1508 pEdit->SetText(pField->GetValue().c_str()); | 1504 pEdit->SetText(pField->GetValue().c_str()); |
1509 else | 1505 else |
1510 pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str()); | 1506 pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str()); |
1511 } | 1507 } |
1512 | 1508 |
1513 CPDF_Rect rcContent = pEdit->GetContentRect(); | 1509 CPDF_Rect rcContent = pEdit->GetContentRect(); |
1514 | 1510 |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2204 if (nPageIndex >= 0) { | 2200 if (nPageIndex >= 0) { |
2205 pPage = m_pDocument->GetPageView(nPageIndex); | 2201 pPage = m_pDocument->GetPageView(nPageIndex); |
2206 } | 2202 } |
2207 } | 2203 } |
2208 | 2204 |
2209 if (!pPage) | 2205 if (!pPage) |
2210 return nullptr; | 2206 return nullptr; |
2211 return (CPDFSDK_Widget*)pPage->GetAnnotByDict(pControlDict); | 2207 return (CPDFSDK_Widget*)pPage->GetAnnotByDict(pControlDict); |
2212 } | 2208 } |
2213 | 2209 |
2214 void CPDFSDK_InterForm::GetWidgets(const CFX_WideString& sFieldName, | 2210 void CPDFSDK_InterForm::GetWidgets( |
2215 CFX_PtrArray& widgets) { | 2211 const CFX_WideString& sFieldName, |
2216 ASSERT(m_pInterForm != NULL); | 2212 std::vector<CPDFSDK_Widget*>* widgets) const { |
2217 | 2213 for (int i = 0, sz = m_pInterForm->CountFields(sFieldName); i < sz; ++i) { |
2218 for (int i = 0, sz = m_pInterForm->CountFields(sFieldName); i < sz; i++) { | |
2219 CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName); | 2214 CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName); |
2220 ASSERT(pFormField != NULL); | 2215 ASSERT(pFormField); |
2221 | |
2222 GetWidgets(pFormField, widgets); | 2216 GetWidgets(pFormField, widgets); |
2223 } | 2217 } |
2224 } | 2218 } |
2225 | 2219 |
2226 void CPDFSDK_InterForm::GetWidgets(CPDF_FormField* pField, | 2220 void CPDFSDK_InterForm::GetWidgets( |
2227 CFX_PtrArray& widgets) { | 2221 CPDF_FormField* pField, |
2228 ASSERT(pField != NULL); | 2222 std::vector<CPDFSDK_Widget*>* widgets) const { |
2229 | 2223 for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { |
2230 for (int i = 0, isz = pField->CountControls(); i < isz; i++) { | |
2231 CPDF_FormControl* pFormCtrl = pField->GetControl(i); | 2224 CPDF_FormControl* pFormCtrl = pField->GetControl(i); |
2232 ASSERT(pFormCtrl != NULL); | 2225 ASSERT(pFormCtrl); |
2233 | |
2234 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); | 2226 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); |
2235 | |
2236 if (pWidget) | 2227 if (pWidget) |
2237 widgets.Add(pWidget); | 2228 widgets->push_back(pWidget); |
2238 } | 2229 } |
2239 } | 2230 } |
2240 | 2231 |
2241 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( | 2232 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( |
2242 CPDF_Document* pDocument, | 2233 CPDF_Document* pDocument, |
2243 CPDF_Dictionary* pAnnotDict) const { | 2234 CPDF_Dictionary* pAnnotDict) const { |
2244 ASSERT(pDocument != NULL); | 2235 ASSERT(pDocument != NULL); |
2245 ASSERT(pAnnotDict != NULL); | 2236 ASSERT(pAnnotDict != NULL); |
2246 | 2237 |
2247 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { | 2238 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 } | 2568 } |
2578 } | 2569 } |
2579 } | 2570 } |
2580 | 2571 |
2581 /* ----------------------------- action ----------------------------- */ | 2572 /* ----------------------------- action ----------------------------- */ |
2582 | 2573 |
2583 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 2574 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
2584 ASSERT(action); | 2575 ASSERT(action); |
2585 | 2576 |
2586 CPDF_ActionFields af = action.GetWidgets(); | 2577 CPDF_ActionFields af = action.GetWidgets(); |
2587 CFX_PtrArray fieldObjects; | 2578 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
2588 af.GetAllFields(fieldObjects); | 2579 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
2589 CFX_PtrArray widgetArray; | |
2590 CFX_PtrArray fields; | |
2591 GetFieldFromObjects(fieldObjects, fields); | |
2592 | 2580 |
2593 FX_BOOL bHide = action.GetHideStatus(); | 2581 FX_BOOL bHide = action.GetHideStatus(); |
2594 | |
2595 FX_BOOL bChanged = FALSE; | 2582 FX_BOOL bChanged = FALSE; |
2596 | 2583 |
2597 for (int i = 0, sz = fields.GetSize(); i < sz; i++) { | 2584 for (CPDF_FormField* pField : fields) { |
2598 CPDF_FormField* pField = (CPDF_FormField*)fields[i]; | 2585 for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { |
2599 ASSERT(pField != NULL); | 2586 CPDF_FormControl* pControl = pField->GetControl(i); |
2600 | 2587 ASSERT(pControl); |
2601 for (int j = 0, jsz = pField->CountControls(); j < jsz; j++) { | |
2602 CPDF_FormControl* pControl = pField->GetControl(j); | |
2603 ASSERT(pControl != NULL); | |
2604 | 2588 |
2605 if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { | 2589 if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { |
2606 int nFlags = pWidget->GetFlags(); | 2590 int nFlags = pWidget->GetFlags(); |
2607 if (bHide) { | 2591 nFlags &= ~ANNOTFLAG_INVISIBLE; |
2608 nFlags &= (~ANNOTFLAG_INVISIBLE); | 2592 nFlags &= ~ANNOTFLAG_NOVIEW; |
2609 nFlags &= (~ANNOTFLAG_NOVIEW); | 2593 if (bHide) |
2610 nFlags |= (ANNOTFLAG_HIDDEN); | 2594 nFlags |= ANNOTFLAG_HIDDEN; |
2611 } else { | 2595 else |
2612 nFlags &= (~ANNOTFLAG_INVISIBLE); | 2596 nFlags &= ~ANNOTFLAG_HIDDEN; |
2613 nFlags &= (~ANNOTFLAG_HIDDEN); | |
2614 nFlags &= (~ANNOTFLAG_NOVIEW); | |
2615 } | |
2616 pWidget->SetFlags(nFlags); | 2597 pWidget->SetFlags(nFlags); |
2617 | 2598 pWidget->GetPageView()->UpdateView(pWidget); |
2618 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | |
2619 ASSERT(pPageView != NULL); | |
2620 | |
2621 pPageView->UpdateView(pWidget); | |
2622 | |
2623 bChanged = TRUE; | 2599 bChanged = TRUE; |
2624 } | 2600 } |
2625 } | 2601 } |
2626 } | 2602 } |
2627 | 2603 |
2628 return bChanged; | 2604 return bChanged; |
2629 } | 2605 } |
2630 | 2606 |
2631 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { | 2607 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { |
2632 ASSERT(m_pInterForm != NULL); | 2608 ASSERT(m_pInterForm != NULL); |
2633 CFX_WideString sDestination = action.GetFilePath(); | 2609 CFX_WideString sDestination = action.GetFilePath(); |
2634 if (sDestination.IsEmpty()) | 2610 if (sDestination.IsEmpty()) |
2635 return FALSE; | 2611 return FALSE; |
2636 | 2612 |
2637 CPDF_Dictionary* pActionDict = action.GetDict(); | 2613 CPDF_Dictionary* pActionDict = action.GetDict(); |
2638 if (pActionDict->KeyExist("Fields")) { | 2614 if (pActionDict->KeyExist("Fields")) { |
2639 CPDF_ActionFields af = action.GetWidgets(); | 2615 CPDF_ActionFields af = action.GetWidgets(); |
2640 FX_DWORD dwFlags = action.GetFlags(); | 2616 FX_DWORD dwFlags = action.GetFlags(); |
2641 CFX_PtrArray fieldObjects; | 2617 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
2642 af.GetAllFields(fieldObjects); | 2618 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
2643 | 2619 if (!fields.empty()) { |
2644 CFX_PtrArray fields; | 2620 bool bIncludeOrExclude = !(dwFlags & 0x01); |
2645 GetFieldFromObjects(fieldObjects, fields); | |
2646 if (fields.GetSize() != 0) { | |
2647 FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01); | |
2648 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) | 2621 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) |
2649 return FALSE; | 2622 return FALSE; |
2650 | 2623 |
2651 return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE); | 2624 return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE); |
2652 } | 2625 } |
2653 } | 2626 } |
2654 if (m_pInterForm->CheckRequiredFields()) | 2627 if (m_pInterForm->CheckRequiredFields(nullptr, true)) |
2655 return FALSE; | 2628 return FALSE; |
2656 | 2629 |
2657 return SubmitForm(sDestination, FALSE); | 2630 return SubmitForm(sDestination, FALSE); |
2658 } | 2631 } |
2659 | 2632 |
2660 FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, | 2633 FX_BOOL CPDFSDK_InterForm::SubmitFields( |
2661 const CFX_PtrArray& fields, | 2634 const CFX_WideString& csDestination, |
2662 FX_BOOL bIncludeOrExclude, | 2635 const std::vector<CPDF_FormField*>& fields, |
2663 FX_BOOL bUrlEncoded) { | 2636 FX_BOOL bIncludeOrExclude, |
| 2637 FX_BOOL bUrlEncoded) { |
2664 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2638 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2665 ASSERT(pEnv != NULL); | |
2666 | 2639 |
2667 CFX_ByteTextBuf textBuf; | 2640 CFX_ByteTextBuf textBuf; |
2668 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 2641 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); |
2669 | 2642 |
2670 uint8_t* pBuffer = textBuf.GetBuffer(); | 2643 uint8_t* pBuffer = textBuf.GetBuffer(); |
2671 FX_STRSIZE nBufSize = textBuf.GetLength(); | 2644 FX_STRSIZE nBufSize = textBuf.GetLength(); |
2672 | 2645 |
2673 if (bUrlEncoded) { | 2646 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) |
2674 if (!FDFToURLEncodedData(pBuffer, nBufSize)) | 2647 return FALSE; |
2675 return FALSE; | |
2676 } | |
2677 | 2648 |
2678 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); | 2649 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); |
2679 | |
2680 return TRUE; | 2650 return TRUE; |
2681 } | 2651 } |
2682 | 2652 |
2683 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, | 2653 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, |
2684 CFX_WideString csTxtFile) { | 2654 CFX_WideString csTxtFile) { |
2685 return TRUE; | 2655 return TRUE; |
2686 } | 2656 } |
2687 | 2657 |
2688 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, | 2658 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, |
2689 FX_STRSIZE& nBufSize) { | 2659 FX_STRSIZE& nBufSize) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 fdfEncodedData = fdfEncodedData << "&"; | 2691 fdfEncodedData = fdfEncodedData << "&"; |
2722 } | 2692 } |
2723 | 2693 |
2724 nBufSize = fdfEncodedData.GetLength(); | 2694 nBufSize = fdfEncodedData.GetLength(); |
2725 pBuf = FX_Alloc(uint8_t, nBufSize); | 2695 pBuf = FX_Alloc(uint8_t, nBufSize); |
2726 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 2696 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); |
2727 } | 2697 } |
2728 return TRUE; | 2698 return TRUE; |
2729 } | 2699 } |
2730 | 2700 |
2731 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, | 2701 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( |
2732 FX_BOOL bIncludeOrExclude, | 2702 const std::vector<CPDF_FormField*>& fields, |
2733 CFX_ByteTextBuf& textBuf) { | 2703 FX_BOOL bIncludeOrExclude, |
2734 ASSERT(m_pDocument != NULL); | 2704 CFX_ByteTextBuf& textBuf) { |
2735 ASSERT(m_pInterForm != NULL); | 2705 nonstd::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( |
2736 | 2706 m_pDocument->GetPath(), fields, bIncludeOrExclude)); |
2737 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( | 2707 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; |
2738 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); | |
2739 if (!pFDF) | |
2740 return FALSE; | |
2741 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | |
2742 delete pFDF; | |
2743 | |
2744 return bRet; | |
2745 } | 2708 } |
2746 | 2709 |
2747 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 2710 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, |
2748 FX_BOOL bSynchronizeElse) { | 2711 FX_BOOL bSynchronizeElse) { |
2749 ASSERT(pFormField != NULL); | 2712 ASSERT(pFormField != NULL); |
2750 | 2713 |
2751 int x = 0; | 2714 int x = 0; |
2752 if (m_FieldSynchronizeMap.Lookup(pFormField, x)) | 2715 if (m_FieldSynchronizeMap.Lookup(pFormField, x)) |
2753 return; | 2716 return; |
2754 | 2717 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2822 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 2785 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
2823 delete pFDF; | 2786 delete pFDF; |
2824 | 2787 |
2825 return bRet; | 2788 return bRet; |
2826 } | 2789 } |
2827 | 2790 |
2828 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { | 2791 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { |
2829 ASSERT(action); | 2792 ASSERT(action); |
2830 | 2793 |
2831 CPDF_Dictionary* pActionDict = action.GetDict(); | 2794 CPDF_Dictionary* pActionDict = action.GetDict(); |
2832 if (pActionDict->KeyExist("Fields")) { | 2795 if (!pActionDict->KeyExist("Fields")) |
2833 CPDF_ActionFields af = action.GetWidgets(); | 2796 return m_pInterForm->ResetForm(true); |
2834 FX_DWORD dwFlags = action.GetFlags(); | |
2835 | 2797 |
2836 CFX_PtrArray fieldObjects; | 2798 CPDF_ActionFields af = action.GetWidgets(); |
2837 af.GetAllFields(fieldObjects); | 2799 FX_DWORD dwFlags = action.GetFlags(); |
2838 CFX_PtrArray fields; | |
2839 GetFieldFromObjects(fieldObjects, fields); | |
2840 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE); | |
2841 } | |
2842 | 2800 |
2843 return m_pInterForm->ResetForm(TRUE); | 2801 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
| 2802 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
| 2803 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); |
2844 } | 2804 } |
2845 | 2805 |
2846 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { | 2806 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { |
2847 return FALSE; | 2807 return FALSE; |
2848 } | 2808 } |
2849 | 2809 |
2850 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, | 2810 std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( |
2851 CFX_PtrArray& fields) { | 2811 const std::vector<CPDF_Object*>& objects) const { |
2852 ASSERT(m_pInterForm != NULL); | 2812 std::vector<CPDF_FormField*> fields; |
2853 | 2813 for (CPDF_Object* pObject : objects) { |
2854 int iCount = objects.GetSize(); | 2814 if (pObject && pObject->IsString()) { |
2855 for (int i = 0; i < iCount; i++) { | |
2856 CPDF_Object* pObject = static_cast<CPDF_Object*>(objects[i]); | |
2857 if (!pObject) | |
2858 continue; | |
2859 | |
2860 if (pObject->IsString()) { | |
2861 CFX_WideString csName = pObject->GetUnicodeText(); | 2815 CFX_WideString csName = pObject->GetUnicodeText(); |
2862 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); | 2816 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); |
2863 if (pField) | 2817 if (pField) |
2864 fields.Add(pField); | 2818 fields.push_back(pField); |
2865 } else if (pObject->IsDictionary()) { | |
2866 if (m_pInterForm->IsValidFormField(pObject)) | |
2867 fields.Add(pObject); | |
2868 } | 2819 } |
2869 } | 2820 } |
| 2821 return fields; |
2870 } | 2822 } |
2871 | 2823 |
2872 /* ----------------------------- CPDF_FormNotify ----------------------------- | 2824 /* ----------------------------- CPDF_FormNotify ----------------------------- |
2873 */ | 2825 */ |
2874 | 2826 |
2875 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, | 2827 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, |
2876 CFX_WideString& csValue) { | 2828 CFX_WideString& csValue) { |
2877 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2829 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2878 int nType = pFormField->GetFieldType(); | 2830 int nType = pFormField->GetFieldType(); |
2879 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2831 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3223 break; | 3175 break; |
3224 } | 3176 } |
3225 } | 3177 } |
3226 } | 3178 } |
3227 | 3179 |
3228 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { | 3180 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
3229 CPDF_Rect rcAnnot; | 3181 CPDF_Rect rcAnnot; |
3230 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 3182 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
3231 return rcAnnot; | 3183 return rcAnnot; |
3232 } | 3184 } |
OLD | NEW |