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/javascript/Field.h" | 7 #include "fpdfsdk/javascript/Field.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 14 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
15 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 15 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
17 #include "core/fpdfdoc/include/cpdf_interform.h" | 17 #include "core/fpdfdoc/include/cpdf_interform.h" |
18 #include "fpdfsdk/include/cpdfdoc_environment.h" | |
19 #include "fpdfsdk/include/cpdfsdk_document.h" | 18 #include "fpdfsdk/include/cpdfsdk_document.h" |
| 19 #include "fpdfsdk/include/cpdfsdk_environment.h" |
20 #include "fpdfsdk/include/cpdfsdk_interform.h" | 20 #include "fpdfsdk/include/cpdfsdk_interform.h" |
21 #include "fpdfsdk/include/cpdfsdk_pageview.h" | 21 #include "fpdfsdk/include/cpdfsdk_pageview.h" |
22 #include "fpdfsdk/include/cpdfsdk_widget.h" | 22 #include "fpdfsdk/include/cpdfsdk_widget.h" |
23 #include "fpdfsdk/javascript/Document.h" | 23 #include "fpdfsdk/javascript/Document.h" |
24 #include "fpdfsdk/javascript/Icon.h" | 24 #include "fpdfsdk/javascript/Icon.h" |
25 #include "fpdfsdk/javascript/JS_Define.h" | 25 #include "fpdfsdk/javascript/JS_Define.h" |
26 #include "fpdfsdk/javascript/JS_EventHandler.h" | 26 #include "fpdfsdk/javascript/JS_EventHandler.h" |
27 #include "fpdfsdk/javascript/JS_Object.h" | 27 #include "fpdfsdk/javascript/JS_Object.h" |
28 #include "fpdfsdk/javascript/JS_Value.h" | 28 #include "fpdfsdk/javascript/JS_Value.h" |
29 #include "fpdfsdk/javascript/PublicMethods.h" | 29 #include "fpdfsdk/javascript/PublicMethods.h" |
(...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 | 2828 |
2829 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, | 2829 FX_BOOL Field::browseForFileToSubmit(IJS_Context* cc, |
2830 const std::vector<CJS_Value>& params, | 2830 const std::vector<CJS_Value>& params, |
2831 CJS_Value& vRet, | 2831 CJS_Value& vRet, |
2832 CFX_WideString& sError) { | 2832 CFX_WideString& sError) { |
2833 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2833 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2834 if (FieldArray.empty()) | 2834 if (FieldArray.empty()) |
2835 return FALSE; | 2835 return FALSE; |
2836 | 2836 |
2837 CPDF_FormField* pFormField = FieldArray[0]; | 2837 CPDF_FormField* pFormField = FieldArray[0]; |
2838 CPDFDoc_Environment* pApp = m_pDocument->GetEnv(); | 2838 CPDFSDK_Environment* pApp = m_pDocument->GetEnv(); |
2839 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && | 2839 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && |
2840 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { | 2840 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { |
2841 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); | 2841 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); |
2842 if (!wsFileName.IsEmpty()) { | 2842 if (!wsFileName.IsEmpty()) { |
2843 pFormField->SetValue(wsFileName); | 2843 pFormField->SetValue(wsFileName); |
2844 UpdateFormField(m_pDocument.Get(), pFormField, TRUE, TRUE, TRUE); | 2844 UpdateFormField(m_pDocument.Get(), pFormField, TRUE, TRUE, TRUE); |
2845 } | 2845 } |
2846 return TRUE; | 2846 return TRUE; |
2847 } | 2847 } |
2848 return FALSE; | 2848 return FALSE; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 CPDF_FormField* pFormField = FieldArray[0]; | 3195 CPDF_FormField* pFormField = FieldArray[0]; |
3196 int32_t nCount = pFormField->CountControls(); | 3196 int32_t nCount = pFormField->CountControls(); |
3197 if (nCount < 1) | 3197 if (nCount < 1) |
3198 return FALSE; | 3198 return FALSE; |
3199 | 3199 |
3200 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 3200 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
3201 CPDFSDK_Widget* pWidget = nullptr; | 3201 CPDFSDK_Widget* pWidget = nullptr; |
3202 if (nCount == 1) { | 3202 if (nCount == 1) { |
3203 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); | 3203 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); |
3204 } else { | 3204 } else { |
3205 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 3205 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); |
3206 UnderlyingPageType* pPage = UnderlyingFromFPDFPage( | 3206 UnderlyingPageType* pPage = UnderlyingFromFPDFPage( |
3207 pEnv->FFI_GetCurrentPage(m_pDocument->GetUnderlyingDocument())); | 3207 pEnv->FFI_GetCurrentPage(m_pDocument->GetUnderlyingDocument())); |
3208 if (!pPage) | 3208 if (!pPage) |
3209 return FALSE; | 3209 return FALSE; |
3210 if (CPDFSDK_PageView* pCurPageView = | 3210 if (CPDFSDK_PageView* pCurPageView = |
3211 m_pDocument->GetPageView(pPage, true)) { | 3211 m_pDocument->GetPageView(pPage, true)) { |
3212 for (int32_t i = 0; i < nCount; i++) { | 3212 for (int32_t i = 0; i < nCount; i++) { |
3213 if (CPDFSDK_Widget* pTempWidget = | 3213 if (CPDFSDK_Widget* pTempWidget = |
3214 pInterForm->GetWidget(pFormField->GetControl(i), false)) { | 3214 pInterForm->GetWidget(pFormField->GetControl(i), false)) { |
3215 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { | 3215 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3491 } | 3491 } |
3492 } | 3492 } |
3493 | 3493 |
3494 void Field::AddField(CPDFSDK_Document* pDocument, | 3494 void Field::AddField(CPDFSDK_Document* pDocument, |
3495 int nPageIndex, | 3495 int nPageIndex, |
3496 int nFieldType, | 3496 int nFieldType, |
3497 const CFX_WideString& sName, | 3497 const CFX_WideString& sName, |
3498 const CFX_FloatRect& rcCoords) { | 3498 const CFX_FloatRect& rcCoords) { |
3499 // Not supported. | 3499 // Not supported. |
3500 } | 3500 } |
OLD | NEW |