OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdfsdk_environment.h" | 7 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" | 11 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" |
12 #include "fpdfsdk/cpdfsdk_document.h" | 12 #include "fpdfsdk/cpdfsdk_document.h" |
13 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" | 13 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" |
14 #include "fpdfsdk/fsdk_actionhandler.h" | 14 #include "fpdfsdk/fsdk_actionhandler.h" |
15 #include "fpdfsdk/javascript/ijs_runtime.h" | 15 #include "fpdfsdk/javascript/ijs_runtime.h" |
16 #include "third_party/base/ptr_util.h" | 16 #include "third_party/base/ptr_util.h" |
17 | 17 |
18 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
19 #include "fpdfsdk/fpdfxfa/cpdfxfa_app.h" | 19 #include "fpdfsdk/fpdfxfa/cpdfxfa_app.h" |
20 #endif // PDF_ENABLE_XFA | 20 #endif // PDF_ENABLE_XFA |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken | 24 // NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken |
25 // since modifying the result would impact |bsUTF16LE|. | 25 // since modifying the result would impact |bsUTF16LE|. |
26 FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) { | 26 FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) { |
27 return reinterpret_cast<FPDF_WIDESTRING>( | 27 return reinterpret_cast<FPDF_WIDESTRING>( |
28 bsUTF16LE->GetBuffer(bsUTF16LE->GetLength())); | 28 bsUTF16LE->GetBuffer(bsUTF16LE->GetLength())); |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 CPDFSDK_Environment::CPDFSDK_Environment(UnderlyingDocumentType* pDoc, | 33 CPDFSDK_FormfillEnvironment::CPDFSDK_FormfillEnvironment( |
34 FPDF_FORMFILLINFO* pFFinfo) | 34 UnderlyingDocumentType* pDoc, |
| 35 FPDF_FORMFILLINFO* pFFinfo) |
35 : m_pInfo(pFFinfo), | 36 : m_pInfo(pFFinfo), |
36 m_pSDKDoc(new CPDFSDK_Document(pDoc, this)), | 37 m_pSDKDoc(new CPDFSDK_Document(pDoc, this)), |
37 m_pUnderlyingDoc(pDoc), | 38 m_pUnderlyingDoc(pDoc), |
38 m_pSysHandler(new CFX_SystemHandler(this)) {} | 39 m_pSysHandler(new CFX_SystemHandler(this)) {} |
39 | 40 |
40 CPDFSDK_Environment::~CPDFSDK_Environment() { | 41 CPDFSDK_FormfillEnvironment::~CPDFSDK_FormfillEnvironment() { |
41 #ifdef PDF_ENABLE_XFA | 42 #ifdef PDF_ENABLE_XFA |
42 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); | 43 CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); |
43 if (pProvider->m_pEnvList.GetSize() == 0) | 44 if (pProvider->m_pEnvList.GetSize() == 0) |
44 pProvider->SetJavaScriptInitialized(FALSE); | 45 pProvider->SetJavaScriptInitialized(FALSE); |
45 #endif // PDF_ENABLE_XFA | 46 #endif // PDF_ENABLE_XFA |
46 if (m_pInfo && m_pInfo->Release) | 47 if (m_pInfo && m_pInfo->Release) |
47 m_pInfo->Release(m_pInfo); | 48 m_pInfo->Release(m_pInfo); |
48 } | 49 } |
49 | 50 |
50 int CPDFSDK_Environment::JS_appAlert(const FX_WCHAR* Msg, | 51 int CPDFSDK_FormfillEnvironment::JS_appAlert(const FX_WCHAR* Msg, |
51 const FX_WCHAR* Title, | 52 const FX_WCHAR* Title, |
52 uint32_t Type, | 53 uint32_t Type, |
53 uint32_t Icon) { | 54 uint32_t Icon) { |
54 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 55 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
55 !m_pInfo->m_pJsPlatform->app_alert) { | 56 !m_pInfo->m_pJsPlatform->app_alert) { |
56 return -1; | 57 return -1; |
57 } | 58 } |
58 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); | 59 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
59 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); | 60 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
60 return m_pInfo->m_pJsPlatform->app_alert( | 61 return m_pInfo->m_pJsPlatform->app_alert( |
61 m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsMsg), | 62 m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsMsg), |
62 AsFPDFWideString(&bsTitle), Type, Icon); | 63 AsFPDFWideString(&bsTitle), Type, Icon); |
63 } | 64 } |
64 | 65 |
65 int CPDFSDK_Environment::JS_appResponse(const FX_WCHAR* Question, | 66 int CPDFSDK_FormfillEnvironment::JS_appResponse(const FX_WCHAR* Question, |
66 const FX_WCHAR* Title, | 67 const FX_WCHAR* Title, |
67 const FX_WCHAR* Default, | 68 const FX_WCHAR* Default, |
68 const FX_WCHAR* cLabel, | 69 const FX_WCHAR* cLabel, |
69 FPDF_BOOL bPassword, | 70 FPDF_BOOL bPassword, |
70 void* response, | 71 void* response, |
71 int length) { | 72 int length) { |
72 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 73 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
73 !m_pInfo->m_pJsPlatform->app_response) { | 74 !m_pInfo->m_pJsPlatform->app_response) { |
74 return -1; | 75 return -1; |
75 } | 76 } |
76 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); | 77 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); |
77 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); | 78 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
78 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); | 79 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); |
79 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); | 80 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); |
80 return m_pInfo->m_pJsPlatform->app_response( | 81 return m_pInfo->m_pJsPlatform->app_response( |
81 m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsQuestion), | 82 m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsQuestion), |
82 AsFPDFWideString(&bsTitle), AsFPDFWideString(&bsDefault), | 83 AsFPDFWideString(&bsTitle), AsFPDFWideString(&bsDefault), |
83 AsFPDFWideString(&bsLabel), bPassword, response, length); | 84 AsFPDFWideString(&bsLabel), bPassword, response, length); |
84 } | 85 } |
85 | 86 |
86 void CPDFSDK_Environment::JS_appBeep(int nType) { | 87 void CPDFSDK_FormfillEnvironment::JS_appBeep(int nType) { |
87 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 88 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
88 !m_pInfo->m_pJsPlatform->app_beep) { | 89 !m_pInfo->m_pJsPlatform->app_beep) { |
89 return; | 90 return; |
90 } | 91 } |
91 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); | 92 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); |
92 } | 93 } |
93 | 94 |
94 CFX_WideString CPDFSDK_Environment::JS_fieldBrowse() { | 95 CFX_WideString CPDFSDK_FormfillEnvironment::JS_fieldBrowse() { |
95 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 96 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
96 !m_pInfo->m_pJsPlatform->Field_browse) { | 97 !m_pInfo->m_pJsPlatform->Field_browse) { |
97 return CFX_WideString(); | 98 return CFX_WideString(); |
98 } | 99 } |
99 const int nRequiredLen = | 100 const int nRequiredLen = |
100 m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0); | 101 m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0); |
101 if (nRequiredLen <= 0) | 102 if (nRequiredLen <= 0) |
102 return CFX_WideString(); | 103 return CFX_WideString(); |
103 | 104 |
104 std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); | 105 std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); |
105 memset(pBuff.get(), 0, nRequiredLen); | 106 memset(pBuff.get(), 0, nRequiredLen); |
106 const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( | 107 const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( |
107 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); | 108 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); |
108 if (nActualLen <= 0 || nActualLen > nRequiredLen) | 109 if (nActualLen <= 0 || nActualLen > nRequiredLen) |
109 return CFX_WideString(); | 110 return CFX_WideString(); |
110 | 111 |
111 return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); | 112 return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); |
112 } | 113 } |
113 | 114 |
114 CFX_WideString CPDFSDK_Environment::JS_docGetFilePath() { | 115 CFX_WideString CPDFSDK_FormfillEnvironment::JS_docGetFilePath() { |
115 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 116 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
116 !m_pInfo->m_pJsPlatform->Doc_getFilePath) { | 117 !m_pInfo->m_pJsPlatform->Doc_getFilePath) { |
117 return CFX_WideString(); | 118 return CFX_WideString(); |
118 } | 119 } |
119 const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( | 120 const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( |
120 m_pInfo->m_pJsPlatform, nullptr, 0); | 121 m_pInfo->m_pJsPlatform, nullptr, 0); |
121 if (nRequiredLen <= 0) | 122 if (nRequiredLen <= 0) |
122 return CFX_WideString(); | 123 return CFX_WideString(); |
123 | 124 |
124 std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); | 125 std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); |
125 memset(pBuff.get(), 0, nRequiredLen); | 126 memset(pBuff.get(), 0, nRequiredLen); |
126 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( | 127 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( |
127 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); | 128 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); |
128 if (nActualLen <= 0 || nActualLen > nRequiredLen) | 129 if (nActualLen <= 0 || nActualLen > nRequiredLen) |
129 return CFX_WideString(); | 130 return CFX_WideString(); |
130 | 131 |
131 return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); | 132 return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); |
132 } | 133 } |
133 | 134 |
134 void CPDFSDK_Environment::JS_docSubmitForm(void* formData, | 135 void CPDFSDK_FormfillEnvironment::JS_docSubmitForm(void* formData, |
135 int length, | 136 int length, |
136 const FX_WCHAR* URL) { | 137 const FX_WCHAR* URL) { |
137 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 138 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
138 !m_pInfo->m_pJsPlatform->Doc_submitForm) { | 139 !m_pInfo->m_pJsPlatform->Doc_submitForm) { |
139 return; | 140 return; |
140 } | 141 } |
141 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); | 142 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); |
142 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, | 143 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, |
143 length, | 144 length, |
144 AsFPDFWideString(&bsDestination)); | 145 AsFPDFWideString(&bsDestination)); |
145 } | 146 } |
146 | 147 |
147 void CPDFSDK_Environment::JS_docmailForm(void* mailData, | 148 void CPDFSDK_FormfillEnvironment::JS_docmailForm(void* mailData, |
148 int length, | 149 int length, |
149 FPDF_BOOL bUI, | 150 FPDF_BOOL bUI, |
150 const FX_WCHAR* To, | 151 const FX_WCHAR* To, |
151 const FX_WCHAR* Subject, | 152 const FX_WCHAR* Subject, |
152 const FX_WCHAR* CC, | 153 const FX_WCHAR* CC, |
153 const FX_WCHAR* BCC, | 154 const FX_WCHAR* BCC, |
154 const FX_WCHAR* Msg) { | 155 const FX_WCHAR* Msg) { |
155 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 156 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
156 !m_pInfo->m_pJsPlatform->Doc_mail) { | 157 !m_pInfo->m_pJsPlatform->Doc_mail) { |
157 return; | 158 return; |
158 } | 159 } |
159 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); | 160 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); |
160 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); | 161 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); |
161 CFX_ByteString bsCC = CFX_WideString(CC).UTF16LE_Encode(); | 162 CFX_ByteString bsCC = CFX_WideString(CC).UTF16LE_Encode(); |
162 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); | 163 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); |
163 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); | 164 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
164 m_pInfo->m_pJsPlatform->Doc_mail( | 165 m_pInfo->m_pJsPlatform->Doc_mail( |
165 m_pInfo->m_pJsPlatform, mailData, length, bUI, AsFPDFWideString(&bsTo), | 166 m_pInfo->m_pJsPlatform, mailData, length, bUI, AsFPDFWideString(&bsTo), |
166 AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC), | 167 AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC), |
167 AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg)); | 168 AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg)); |
168 } | 169 } |
169 | 170 |
170 void CPDFSDK_Environment::JS_docprint(FPDF_BOOL bUI, | 171 void CPDFSDK_FormfillEnvironment::JS_docprint(FPDF_BOOL bUI, |
171 int nStart, | 172 int nStart, |
172 int nEnd, | 173 int nEnd, |
173 FPDF_BOOL bSilent, | 174 FPDF_BOOL bSilent, |
174 FPDF_BOOL bShrinkToFit, | 175 FPDF_BOOL bShrinkToFit, |
175 FPDF_BOOL bPrintAsImage, | 176 FPDF_BOOL bPrintAsImage, |
176 FPDF_BOOL bReverse, | 177 FPDF_BOOL bReverse, |
177 FPDF_BOOL bAnnotations) { | 178 FPDF_BOOL bAnnotations) { |
178 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 179 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
179 !m_pInfo->m_pJsPlatform->Doc_print) { | 180 !m_pInfo->m_pJsPlatform->Doc_print) { |
180 return; | 181 return; |
181 } | 182 } |
182 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, | 183 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, |
183 bSilent, bShrinkToFit, bPrintAsImage, | 184 bSilent, bShrinkToFit, bPrintAsImage, |
184 bReverse, bAnnotations); | 185 bReverse, bAnnotations); |
185 } | 186 } |
186 | 187 |
187 void CPDFSDK_Environment::JS_docgotoPage(int nPageNum) { | 188 void CPDFSDK_FormfillEnvironment::JS_docgotoPage(int nPageNum) { |
188 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 189 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
189 !m_pInfo->m_pJsPlatform->Doc_gotoPage) { | 190 !m_pInfo->m_pJsPlatform->Doc_gotoPage) { |
190 return; | 191 return; |
191 } | 192 } |
192 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); | 193 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); |
193 } | 194 } |
194 | 195 |
195 IJS_Runtime* CPDFSDK_Environment::GetJSRuntime() { | 196 IJS_Runtime* CPDFSDK_FormfillEnvironment::GetJSRuntime() { |
196 if (!IsJSInitiated()) | 197 if (!IsJSInitiated()) |
197 return nullptr; | 198 return nullptr; |
198 if (!m_pJSRuntime) | 199 if (!m_pJSRuntime) |
199 m_pJSRuntime.reset(IJS_Runtime::Create(this)); | 200 m_pJSRuntime.reset(IJS_Runtime::Create(this)); |
200 return m_pJSRuntime.get(); | 201 return m_pJSRuntime.get(); |
201 } | 202 } |
202 | 203 |
203 CPDFSDK_AnnotHandlerMgr* CPDFSDK_Environment::GetAnnotHandlerMgr() { | 204 CPDFSDK_AnnotHandlerMgr* CPDFSDK_FormfillEnvironment::GetAnnotHandlerMgr() { |
204 if (!m_pAnnotHandlerMgr) | 205 if (!m_pAnnotHandlerMgr) |
205 m_pAnnotHandlerMgr = pdfium::MakeUnique<CPDFSDK_AnnotHandlerMgr>(this); | 206 m_pAnnotHandlerMgr = pdfium::MakeUnique<CPDFSDK_AnnotHandlerMgr>(this); |
206 return m_pAnnotHandlerMgr.get(); | 207 return m_pAnnotHandlerMgr.get(); |
207 } | 208 } |
208 | 209 |
209 CPDFSDK_ActionHandler* CPDFSDK_Environment::GetActionHander() { | 210 CPDFSDK_ActionHandler* CPDFSDK_FormfillEnvironment::GetActionHander() { |
210 if (!m_pActionHandler) | 211 if (!m_pActionHandler) |
211 m_pActionHandler = pdfium::MakeUnique<CPDFSDK_ActionHandler>(); | 212 m_pActionHandler = pdfium::MakeUnique<CPDFSDK_ActionHandler>(); |
212 return m_pActionHandler.get(); | 213 return m_pActionHandler.get(); |
213 } | 214 } |
214 | 215 |
215 CFFL_InteractiveFormFiller* CPDFSDK_Environment::GetInteractiveFormFiller() { | 216 CFFL_InteractiveFormFiller* |
| 217 CPDFSDK_FormfillEnvironment::GetInteractiveFormFiller() { |
216 if (!m_pFormFiller) | 218 if (!m_pFormFiller) |
217 m_pFormFiller = pdfium::MakeUnique<CFFL_InteractiveFormFiller>(this); | 219 m_pFormFiller = pdfium::MakeUnique<CFFL_InteractiveFormFiller>(this); |
218 return m_pFormFiller.get(); | 220 return m_pFormFiller.get(); |
219 } | 221 } |
220 | 222 |
221 void CPDFSDK_Environment::Invalidate(FPDF_PAGE page, | 223 void CPDFSDK_FormfillEnvironment::Invalidate(FPDF_PAGE page, |
222 double left, | 224 double left, |
223 double top, | 225 double top, |
224 double right, | 226 double right, |
225 double bottom) { | 227 double bottom) { |
226 if (m_pInfo && m_pInfo->FFI_Invalidate) | 228 if (m_pInfo && m_pInfo->FFI_Invalidate) |
227 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); | 229 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); |
228 } | 230 } |
229 | 231 |
230 void CPDFSDK_Environment::OutputSelectedRect(FPDF_PAGE page, | 232 void CPDFSDK_FormfillEnvironment::OutputSelectedRect(FPDF_PAGE page, |
231 double left, | 233 double left, |
232 double top, | 234 double top, |
233 double right, | 235 double right, |
234 double bottom) { | 236 double bottom) { |
235 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) | 237 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) |
236 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); | 238 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); |
237 } | 239 } |
238 | 240 |
239 void CPDFSDK_Environment::SetCursor(int nCursorType) { | 241 void CPDFSDK_FormfillEnvironment::SetCursor(int nCursorType) { |
240 if (m_pInfo && m_pInfo->FFI_SetCursor) | 242 if (m_pInfo && m_pInfo->FFI_SetCursor) |
241 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); | 243 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); |
242 } | 244 } |
243 | 245 |
244 int CPDFSDK_Environment::SetTimer(int uElapse, TimerCallback lpTimerFunc) { | 246 int CPDFSDK_FormfillEnvironment::SetTimer(int uElapse, |
| 247 TimerCallback lpTimerFunc) { |
245 if (m_pInfo && m_pInfo->FFI_SetTimer) | 248 if (m_pInfo && m_pInfo->FFI_SetTimer) |
246 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); | 249 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); |
247 return -1; | 250 return -1; |
248 } | 251 } |
249 | 252 |
250 void CPDFSDK_Environment::KillTimer(int nTimerID) { | 253 void CPDFSDK_FormfillEnvironment::KillTimer(int nTimerID) { |
251 if (m_pInfo && m_pInfo->FFI_KillTimer) | 254 if (m_pInfo && m_pInfo->FFI_KillTimer) |
252 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); | 255 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); |
253 } | 256 } |
254 | 257 |
255 FX_SYSTEMTIME CPDFSDK_Environment::GetLocalTime() const { | 258 FX_SYSTEMTIME CPDFSDK_FormfillEnvironment::GetLocalTime() const { |
256 FX_SYSTEMTIME fxtime; | 259 FX_SYSTEMTIME fxtime; |
257 if (!m_pInfo || !m_pInfo->FFI_GetLocalTime) | 260 if (!m_pInfo || !m_pInfo->FFI_GetLocalTime) |
258 return fxtime; | 261 return fxtime; |
259 | 262 |
260 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); | 263 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); |
261 fxtime.wDay = systime.wDay; | 264 fxtime.wDay = systime.wDay; |
262 fxtime.wDayOfWeek = systime.wDayOfWeek; | 265 fxtime.wDayOfWeek = systime.wDayOfWeek; |
263 fxtime.wHour = systime.wHour; | 266 fxtime.wHour = systime.wHour; |
264 fxtime.wMilliseconds = systime.wMilliseconds; | 267 fxtime.wMilliseconds = systime.wMilliseconds; |
265 fxtime.wMinute = systime.wMinute; | 268 fxtime.wMinute = systime.wMinute; |
266 fxtime.wMonth = systime.wMonth; | 269 fxtime.wMonth = systime.wMonth; |
267 fxtime.wSecond = systime.wSecond; | 270 fxtime.wSecond = systime.wSecond; |
268 fxtime.wYear = systime.wYear; | 271 fxtime.wYear = systime.wYear; |
269 return fxtime; | 272 return fxtime; |
270 } | 273 } |
271 | 274 |
272 void CPDFSDK_Environment::OnChange() { | 275 void CPDFSDK_FormfillEnvironment::OnChange() { |
273 if (m_pInfo && m_pInfo->FFI_OnChange) | 276 if (m_pInfo && m_pInfo->FFI_OnChange) |
274 m_pInfo->FFI_OnChange(m_pInfo); | 277 m_pInfo->FFI_OnChange(m_pInfo); |
275 } | 278 } |
276 | 279 |
277 FX_BOOL CPDFSDK_Environment::IsSHIFTKeyDown(uint32_t nFlag) const { | 280 FX_BOOL CPDFSDK_FormfillEnvironment::IsSHIFTKeyDown(uint32_t nFlag) const { |
278 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; | 281 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; |
279 } | 282 } |
280 | 283 |
281 FX_BOOL CPDFSDK_Environment::IsCTRLKeyDown(uint32_t nFlag) const { | 284 FX_BOOL CPDFSDK_FormfillEnvironment::IsCTRLKeyDown(uint32_t nFlag) const { |
282 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; | 285 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; |
283 } | 286 } |
284 | 287 |
285 FX_BOOL CPDFSDK_Environment::IsALTKeyDown(uint32_t nFlag) const { | 288 FX_BOOL CPDFSDK_FormfillEnvironment::IsALTKeyDown(uint32_t nFlag) const { |
286 return (nFlag & FWL_EVENTFLAG_AltKey) != 0; | 289 return (nFlag & FWL_EVENTFLAG_AltKey) != 0; |
287 } | 290 } |
288 | 291 |
289 FPDF_PAGE CPDFSDK_Environment::GetPage(FPDF_DOCUMENT document, int nPageIndex) { | 292 FPDF_PAGE CPDFSDK_FormfillEnvironment::GetPage(FPDF_DOCUMENT document, |
| 293 int nPageIndex) { |
290 if (m_pInfo && m_pInfo->FFI_GetPage) | 294 if (m_pInfo && m_pInfo->FFI_GetPage) |
291 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); | 295 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); |
292 return nullptr; | 296 return nullptr; |
293 } | 297 } |
294 | 298 |
295 FPDF_PAGE CPDFSDK_Environment::GetCurrentPage(FPDF_DOCUMENT document) { | 299 FPDF_PAGE CPDFSDK_FormfillEnvironment::GetCurrentPage(FPDF_DOCUMENT document) { |
296 if (m_pInfo && m_pInfo->FFI_GetCurrentPage) | 300 if (m_pInfo && m_pInfo->FFI_GetCurrentPage) |
297 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); | 301 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); |
298 return nullptr; | 302 return nullptr; |
299 } | 303 } |
300 | 304 |
301 void CPDFSDK_Environment::ExecuteNamedAction(const FX_CHAR* namedAction) { | 305 void CPDFSDK_FormfillEnvironment::ExecuteNamedAction( |
| 306 const FX_CHAR* namedAction) { |
302 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) | 307 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) |
303 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); | 308 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); |
304 } | 309 } |
305 | 310 |
306 void CPDFSDK_Environment::OnSetFieldInputFocus(FPDF_WIDESTRING focusText, | 311 void CPDFSDK_FormfillEnvironment::OnSetFieldInputFocus( |
307 FPDF_DWORD nTextLen, | 312 FPDF_WIDESTRING focusText, |
308 FX_BOOL bFocus) { | 313 FPDF_DWORD nTextLen, |
| 314 FX_BOOL bFocus) { |
309 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) | 315 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) |
310 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); | 316 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); |
311 } | 317 } |
312 | 318 |
313 void CPDFSDK_Environment::DoURIAction(const FX_CHAR* bsURI) { | 319 void CPDFSDK_FormfillEnvironment::DoURIAction(const FX_CHAR* bsURI) { |
314 if (m_pInfo && m_pInfo->FFI_DoURIAction) | 320 if (m_pInfo && m_pInfo->FFI_DoURIAction) |
315 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); | 321 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); |
316 } | 322 } |
317 | 323 |
318 void CPDFSDK_Environment::DoGoToAction(int nPageIndex, | 324 void CPDFSDK_FormfillEnvironment::DoGoToAction(int nPageIndex, |
319 int zoomMode, | 325 int zoomMode, |
320 float* fPosArray, | 326 float* fPosArray, |
321 int sizeOfArray) { | 327 int sizeOfArray) { |
322 if (m_pInfo && m_pInfo->FFI_DoGoToAction) { | 328 if (m_pInfo && m_pInfo->FFI_DoGoToAction) { |
323 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, | 329 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, |
324 sizeOfArray); | 330 sizeOfArray); |
325 } | 331 } |
326 } | 332 } |
327 | 333 |
328 #ifdef PDF_ENABLE_XFA | 334 #ifdef PDF_ENABLE_XFA |
329 void CPDFSDK_Environment::DisplayCaret(FPDF_PAGE page, | 335 void CPDFSDK_FormfillEnvironment::DisplayCaret(FPDF_PAGE page, |
330 FPDF_BOOL bVisible, | 336 FPDF_BOOL bVisible, |
331 double left, | 337 double left, |
332 double top, | 338 double top, |
333 double right, | 339 double right, |
334 double bottom) { | 340 double bottom) { |
335 if (m_pInfo && m_pInfo->FFI_DisplayCaret) { | 341 if (m_pInfo && m_pInfo->FFI_DisplayCaret) { |
336 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, | 342 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, |
337 bottom); | 343 bottom); |
338 } | 344 } |
339 } | 345 } |
340 | 346 |
341 int CPDFSDK_Environment::GetCurrentPageIndex(FPDF_DOCUMENT document) { | 347 int CPDFSDK_FormfillEnvironment::GetCurrentPageIndex(FPDF_DOCUMENT document) { |
342 if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) | 348 if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) |
343 return -1; | 349 return -1; |
344 return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); | 350 return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); |
345 } | 351 } |
346 | 352 |
347 void CPDFSDK_Environment::SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { | 353 void CPDFSDK_FormfillEnvironment::SetCurrentPage(FPDF_DOCUMENT document, |
| 354 int iCurPage) { |
348 if (m_pInfo && m_pInfo->FFI_SetCurrentPage) | 355 if (m_pInfo && m_pInfo->FFI_SetCurrentPage) |
349 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); | 356 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); |
350 } | 357 } |
351 | 358 |
352 CFX_WideString CPDFSDK_Environment::GetPlatform() { | 359 CFX_WideString CPDFSDK_FormfillEnvironment::GetPlatform() { |
353 if (!m_pInfo || !m_pInfo->FFI_GetPlatform) | 360 if (!m_pInfo || !m_pInfo->FFI_GetPlatform) |
354 return L""; | 361 return L""; |
355 | 362 |
356 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0); | 363 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0); |
357 if (nRequiredLen <= 0) | 364 if (nRequiredLen <= 0) |
358 return L""; | 365 return L""; |
359 | 366 |
360 char* pbuff = new char[nRequiredLen]; | 367 char* pbuff = new char[nRequiredLen]; |
361 memset(pbuff, 0, nRequiredLen); | 368 memset(pbuff, 0, nRequiredLen); |
362 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); | 369 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); |
363 if (nActualLen <= 0 || nActualLen > nRequiredLen) { | 370 if (nActualLen <= 0 || nActualLen > nRequiredLen) { |
364 delete[] pbuff; | 371 delete[] pbuff; |
365 return L""; | 372 return L""; |
366 } | 373 } |
367 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); | 374 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
368 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( | 375 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
369 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), | 376 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), |
370 bsRet.GetLength() / sizeof(unsigned short)); | 377 bsRet.GetLength() / sizeof(unsigned short)); |
371 delete[] pbuff; | 378 delete[] pbuff; |
372 return wsRet; | 379 return wsRet; |
373 } | 380 } |
374 | 381 |
375 void CPDFSDK_Environment::GotoURL(FPDF_DOCUMENT document, | 382 void CPDFSDK_FormfillEnvironment::GotoURL(FPDF_DOCUMENT document, |
376 const CFX_WideStringC& wsURL) { | 383 const CFX_WideStringC& wsURL) { |
377 if (!m_pInfo || !m_pInfo->FFI_GotoURL) | 384 if (!m_pInfo || !m_pInfo->FFI_GotoURL) |
378 return; | 385 return; |
379 | 386 |
380 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); | 387 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); |
381 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); | 388 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); |
382 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); | 389 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); |
383 bsTo.ReleaseBuffer(); | 390 bsTo.ReleaseBuffer(); |
384 } | 391 } |
385 | 392 |
386 void CPDFSDK_Environment::GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { | 393 void CPDFSDK_FormfillEnvironment::GetPageViewRect(FPDF_PAGE page, |
| 394 FS_RECTF& dstRect) { |
387 if (!m_pInfo || !m_pInfo->FFI_GetPageViewRect) | 395 if (!m_pInfo || !m_pInfo->FFI_GetPageViewRect) |
388 return; | 396 return; |
389 | 397 |
390 double left; | 398 double left; |
391 double top; | 399 double top; |
392 double right; | 400 double right; |
393 double bottom; | 401 double bottom; |
394 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); | 402 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); |
395 | 403 |
396 dstRect.left = static_cast<float>(left); | 404 dstRect.left = static_cast<float>(left); |
397 dstRect.top = static_cast<float>(top < bottom ? bottom : top); | 405 dstRect.top = static_cast<float>(top < bottom ? bottom : top); |
398 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); | 406 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); |
399 dstRect.right = static_cast<float>(right); | 407 dstRect.right = static_cast<float>(right); |
400 } | 408 } |
401 | 409 |
402 FX_BOOL CPDFSDK_Environment::PopupMenu(FPDF_PAGE page, | 410 FX_BOOL CPDFSDK_FormfillEnvironment::PopupMenu(FPDF_PAGE page, |
403 FPDF_WIDGET hWidget, | 411 FPDF_WIDGET hWidget, |
404 int menuFlag, | 412 int menuFlag, |
405 CFX_PointF pt) { | 413 CFX_PointF pt) { |
406 if (!m_pInfo || !m_pInfo->FFI_PopupMenu) | 414 if (!m_pInfo || !m_pInfo->FFI_PopupMenu) |
407 return FALSE; | 415 return FALSE; |
408 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, pt.x, pt.y); | 416 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, pt.x, pt.y); |
409 } | 417 } |
410 | 418 |
411 void CPDFSDK_Environment::Alert(FPDF_WIDESTRING Msg, | 419 void CPDFSDK_FormfillEnvironment::Alert(FPDF_WIDESTRING Msg, |
412 FPDF_WIDESTRING Title, | 420 FPDF_WIDESTRING Title, |
413 int Type, | 421 int Type, |
414 int Icon) { | 422 int Icon) { |
415 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) { | 423 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) { |
416 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type, | 424 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type, |
417 Icon); | 425 Icon); |
418 } | 426 } |
419 } | 427 } |
420 | 428 |
421 void CPDFSDK_Environment::EmailTo(FPDF_FILEHANDLER* fileHandler, | 429 void CPDFSDK_FormfillEnvironment::EmailTo(FPDF_FILEHANDLER* fileHandler, |
422 FPDF_WIDESTRING pTo, | 430 FPDF_WIDESTRING pTo, |
423 FPDF_WIDESTRING pSubject, | 431 FPDF_WIDESTRING pSubject, |
424 FPDF_WIDESTRING pCC, | 432 FPDF_WIDESTRING pCC, |
425 FPDF_WIDESTRING pBcc, | 433 FPDF_WIDESTRING pBcc, |
426 FPDF_WIDESTRING pMsg) { | 434 FPDF_WIDESTRING pMsg) { |
427 if (m_pInfo && m_pInfo->FFI_EmailTo) | 435 if (m_pInfo && m_pInfo->FFI_EmailTo) |
428 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg); | 436 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
429 } | 437 } |
430 | 438 |
431 void CPDFSDK_Environment::UploadTo(FPDF_FILEHANDLER* fileHandler, | 439 void CPDFSDK_FormfillEnvironment::UploadTo(FPDF_FILEHANDLER* fileHandler, |
432 int fileFlag, | 440 int fileFlag, |
433 FPDF_WIDESTRING uploadTo) { | 441 FPDF_WIDESTRING uploadTo) { |
434 if (m_pInfo && m_pInfo->FFI_UploadTo) | 442 if (m_pInfo && m_pInfo->FFI_UploadTo) |
435 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); | 443 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); |
436 } | 444 } |
437 | 445 |
438 FPDF_FILEHANDLER* CPDFSDK_Environment::OpenFile(int fileType, | 446 FPDF_FILEHANDLER* CPDFSDK_FormfillEnvironment::OpenFile(int fileType, |
439 FPDF_WIDESTRING wsURL, | 447 FPDF_WIDESTRING wsURL, |
440 const char* mode) { | 448 const char* mode) { |
441 if (m_pInfo && m_pInfo->FFI_OpenFile) | 449 if (m_pInfo && m_pInfo->FFI_OpenFile) |
442 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); | 450 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); |
443 return nullptr; | 451 return nullptr; |
444 } | 452 } |
445 | 453 |
446 IFX_FileRead* CPDFSDK_Environment::DownloadFromURL(const FX_WCHAR* url) { | 454 IFX_FileRead* CPDFSDK_FormfillEnvironment::DownloadFromURL( |
| 455 const FX_WCHAR* url) { |
447 if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) | 456 if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) |
448 return nullptr; | 457 return nullptr; |
449 | 458 |
450 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); | 459 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); |
451 FPDF_WIDESTRING wsURL = | 460 FPDF_WIDESTRING wsURL = |
452 (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); | 461 (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); |
453 | 462 |
454 FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); | 463 FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); |
455 | 464 |
456 return new CFPDF_FileStream(fileHandler); | 465 return new CFPDF_FileStream(fileHandler); |
457 } | 466 } |
458 | 467 |
459 CFX_WideString CPDFSDK_Environment::PostRequestURL( | 468 CFX_WideString CPDFSDK_FormfillEnvironment::PostRequestURL( |
460 const FX_WCHAR* wsURL, | 469 const FX_WCHAR* wsURL, |
461 const FX_WCHAR* wsData, | 470 const FX_WCHAR* wsData, |
462 const FX_WCHAR* wsContentType, | 471 const FX_WCHAR* wsContentType, |
463 const FX_WCHAR* wsEncode, | 472 const FX_WCHAR* wsEncode, |
464 const FX_WCHAR* wsHeader) { | 473 const FX_WCHAR* wsHeader) { |
465 if (!m_pInfo || !m_pInfo->FFI_PostRequestURL) | 474 if (!m_pInfo || !m_pInfo->FFI_PostRequestURL) |
466 return L""; | 475 return L""; |
467 | 476 |
468 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); | 477 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
469 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); | 478 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
(...skipping 18 matching lines...) Expand all Loading... |
488 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, | 497 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, |
489 &response); | 498 &response); |
490 | 499 |
491 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( | 500 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
492 (FPDF_WIDESTRING)response.str, response.len / sizeof(FPDF_WIDESTRING)); | 501 (FPDF_WIDESTRING)response.str, response.len / sizeof(FPDF_WIDESTRING)); |
493 FPDF_BStr_Clear(&response); | 502 FPDF_BStr_Clear(&response); |
494 | 503 |
495 return wsRet; | 504 return wsRet; |
496 } | 505 } |
497 | 506 |
498 FPDF_BOOL CPDFSDK_Environment::PutRequestURL(const FX_WCHAR* wsURL, | 507 FPDF_BOOL CPDFSDK_FormfillEnvironment::PutRequestURL(const FX_WCHAR* wsURL, |
499 const FX_WCHAR* wsData, | 508 const FX_WCHAR* wsData, |
500 const FX_WCHAR* wsEncode) { | 509 const FX_WCHAR* wsEncode) { |
501 if (!m_pInfo || !m_pInfo->FFI_PutRequestURL) | 510 if (!m_pInfo || !m_pInfo->FFI_PutRequestURL) |
502 return FALSE; | 511 return FALSE; |
503 | 512 |
504 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); | 513 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
505 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); | 514 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
506 | 515 |
507 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); | 516 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
508 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); | 517 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
509 | 518 |
510 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); | 519 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
511 FPDF_WIDESTRING encode = | 520 FPDF_WIDESTRING encode = |
512 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); | 521 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
513 | 522 |
514 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); | 523 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); |
515 } | 524 } |
516 | 525 |
517 CFX_WideString CPDFSDK_Environment::GetLanguage() { | 526 CFX_WideString CPDFSDK_FormfillEnvironment::GetLanguage() { |
518 if (!m_pInfo || !m_pInfo->FFI_GetLanguage) | 527 if (!m_pInfo || !m_pInfo->FFI_GetLanguage) |
519 return L""; | 528 return L""; |
520 | 529 |
521 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0); | 530 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0); |
522 if (nRequiredLen <= 0) | 531 if (nRequiredLen <= 0) |
523 return L""; | 532 return L""; |
524 | 533 |
525 char* pbuff = new char[nRequiredLen]; | 534 char* pbuff = new char[nRequiredLen]; |
526 memset(pbuff, 0, nRequiredLen); | 535 memset(pbuff, 0, nRequiredLen); |
527 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); | 536 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); |
528 if (nActualLen <= 0 || nActualLen > nRequiredLen) { | 537 if (nActualLen <= 0 || nActualLen > nRequiredLen) { |
529 delete[] pbuff; | 538 delete[] pbuff; |
530 return L""; | 539 return L""; |
531 } | 540 } |
532 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); | 541 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
533 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( | 542 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
534 (FPDF_WIDESTRING)bsRet.GetBuffer(bsRet.GetLength()), | 543 (FPDF_WIDESTRING)bsRet.GetBuffer(bsRet.GetLength()), |
535 bsRet.GetLength() / sizeof(FPDF_WIDESTRING)); | 544 bsRet.GetLength() / sizeof(FPDF_WIDESTRING)); |
536 delete[] pbuff; | 545 delete[] pbuff; |
537 return wsRet; | 546 return wsRet; |
538 } | 547 } |
539 | 548 |
540 void CPDFSDK_Environment::PageEvent(int iPageCount, | 549 void CPDFSDK_FormfillEnvironment::PageEvent(int iPageCount, |
541 uint32_t dwEventType) const { | 550 uint32_t dwEventType) const { |
542 if (m_pInfo && m_pInfo->FFI_PageEvent) | 551 if (m_pInfo && m_pInfo->FFI_PageEvent) |
543 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); | 552 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); |
544 } | 553 } |
545 #endif // PDF_ENABLE_XFA | 554 #endif // PDF_ENABLE_XFA |
OLD | NEW |