blob: 042ba3811df98cefab7834d0e9e54a4c03f4cb02 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Tom Sepezc6ab1722015-02-05 15:27:25 -08004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez19922bb2015-05-28 13:23:12 -07007#ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_
8#define FPDFSDK_INCLUDE_FSDK_MGR_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Lei Zhang606346f2015-06-19 18:11:07 -070010#include <map>
Lei Zhangaa8bf7e2015-12-24 19:13:32 -080011#include <memory>
Lei Zhang606346f2015-06-19 18:11:07 -070012
Lei Zhanga688a042015-11-09 13:57:49 -080013#include "core/include/fpdftext/fpdf_text.h"
Lei Zhang8241df72015-11-06 14:38:48 -080014#include "fsdk_actionhandler.h"
15#include "fsdk_annothandler.h"
16#include "fsdk_baseannot.h"
17#include "fsdk_baseform.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070018#include "fsdk_common.h"
19#include "fsdk_define.h"
20#include "fx_systemhandler.h"
Lei Zhange5b0bd12015-06-19 17:15:41 -070021#include "javascript/IJavaScript.h"
Lei Zhangb4e7f302015-11-06 15:52:32 -080022#include "public/fpdf_formfill.h"
23#include "public/fpdf_fwlevent.h" // cross platform keycode and events define.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070024
Tom Sepez40e9ff32015-11-30 12:39:54 -080025#ifdef PDF_ENABLE_XFA
Lei Zhang875b9c92016-01-08 13:51:10 -080026#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
27#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
Tom Sepez40e9ff32015-11-30 12:39:54 -080028#endif // PDF_ENABLE_XFA
29
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070030class CFFL_IFormFiller;
Tom Sepezdcbc02f2015-07-17 09:16:17 -070031class CPDFSDK_ActionHandler;
32class CPDFSDK_Annot;
33class CPDFSDK_Document;
34class CPDFSDK_InterForm;
35class CPDFSDK_PageView;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070036class CPDFSDK_Widget;
37class IFX_SystemHandler;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070038
Nico Weber9d8ec5a2015-08-04 13:00:21 -070039class CPDFDoc_Environment final {
40 public:
Tom Sepez50d12ad2015-11-24 09:50:51 -080041 CPDFDoc_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo);
Tom Sepezdfbf8e72015-10-14 14:17:26 -070042 ~CPDFDoc_Environment();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070043
Tom Sepez51da0932015-11-25 16:05:49 -080044#ifdef PDF_ENABLE_XFA
Tom Sepezdfbf8e72015-10-14 14:17:26 -070045 void Release() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070046 if (m_pInfo && m_pInfo->Release)
47 m_pInfo->Release(m_pInfo);
48 delete this;
49 }
Tom Sepez40e9ff32015-11-30 12:39:54 -080050#endif // PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -070051
52 void FFI_Invalidate(FPDF_PAGE page,
53 double left,
54 double top,
55 double right,
56 double bottom) {
57 if (m_pInfo && m_pInfo->FFI_Invalidate)
58 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom);
59 }
60
61 void FFI_OutputSelectedRect(FPDF_PAGE page,
62 double left,
63 double top,
64 double right,
65 double bottom) {
66 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect)
67 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom);
68 }
69
70 void FFI_SetCursor(int nCursorType) {
71 if (m_pInfo && m_pInfo->FFI_SetCursor)
72 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType);
73 }
74
75 int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) {
76 if (m_pInfo && m_pInfo->FFI_SetTimer)
77 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
78 return -1;
79 }
80
81 void FFI_KillTimer(int nTimerID) {
82 if (m_pInfo && m_pInfo->FFI_KillTimer)
83 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
84 }
85
Tom Sepez468e5892015-10-13 15:49:36 -070086 FX_SYSTEMTIME FFI_GetLocalTime() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087 FX_SYSTEMTIME fxtime;
88 if (m_pInfo && m_pInfo->FFI_GetLocalTime) {
89 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo);
90 fxtime.wDay = systime.wDay;
91 fxtime.wDayOfWeek = systime.wDayOfWeek;
92 fxtime.wHour = systime.wHour;
93 fxtime.wMilliseconds = systime.wMilliseconds;
94 fxtime.wMinute = systime.wMinute;
95 fxtime.wMonth = systime.wMonth;
96 fxtime.wSecond = systime.wSecond;
97 fxtime.wYear = systime.wYear;
Tom Sepezdcbc02f2015-07-17 09:16:17 -070098 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -070099 return fxtime;
100 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700101
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102 void FFI_OnChange() {
103 if (m_pInfo && m_pInfo->FFI_OnChange)
104 m_pInfo->FFI_OnChange(m_pInfo);
105 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700106
Tom Sepez468e5892015-10-13 15:49:36 -0700107 FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0;
109 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110
Tom Sepez468e5892015-10-13 15:49:36 -0700111 FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0;
113 }
Tom Sepezc6ab1722015-02-05 15:27:25 -0800114
Tom Sepez468e5892015-10-13 15:49:36 -0700115 FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
117 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118
Tom Sepez468e5892015-10-13 15:49:36 -0700119 FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) const { return FALSE; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700120
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 int JS_appAlert(const FX_WCHAR* Msg,
122 const FX_WCHAR* Title,
123 FX_UINT Type,
124 FX_UINT Icon);
125 int JS_appResponse(const FX_WCHAR* Question,
126 const FX_WCHAR* Title,
127 const FX_WCHAR* Default,
128 const FX_WCHAR* cLabel,
129 FPDF_BOOL bPassword,
130 void* response,
131 int length);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800132
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 void JS_appBeep(int nType) {
134 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep)
135 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
136 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700137
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700138 CFX_WideString JS_fieldBrowse();
139 CFX_WideString JS_docGetFilePath();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700141 void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL);
142 void JS_docmailForm(void* mailData,
143 int length,
144 FPDF_BOOL bUI,
145 const FX_WCHAR* To,
146 const FX_WCHAR* Subject,
147 const FX_WCHAR* CC,
148 const FX_WCHAR* BCC,
149 const FX_WCHAR* Msg);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700151 void JS_docprint(FPDF_BOOL bUI,
152 int nStart,
153 int nEnd,
154 FPDF_BOOL bSilent,
155 FPDF_BOOL bShrinkToFit,
156 FPDF_BOOL bPrintAsImage,
157 FPDF_BOOL bReverse,
158 FPDF_BOOL bAnnotations) {
159 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print)
160 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart,
161 nEnd, bSilent, bShrinkToFit,
162 bPrintAsImage, bReverse, bAnnotations);
163 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700164
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700165 void JS_docgotoPage(int nPageNum) {
166 if (m_pInfo && m_pInfo->m_pJsPlatform &&
167 m_pInfo->m_pJsPlatform->Doc_gotoPage)
168 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum);
169 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700170
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700171 FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex) {
172 if (m_pInfo && m_pInfo->FFI_GetPage)
173 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex);
174 return NULL;
175 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700176
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700177 FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) {
178 if (m_pInfo && m_pInfo->FFI_GetCurrentPage)
179 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document);
180 return NULL;
181 }
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700182
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700183 int FFI_GetRotation(FPDF_PAGE page) {
184 if (m_pInfo && m_pInfo->FFI_GetRotation)
185 return m_pInfo->FFI_GetRotation(m_pInfo, page);
186 return 0;
187 }
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700188
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189 void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) {
190 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
191 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction);
192 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700194 void FFI_OnSetFieldInputFocus(void* field,
195 FPDF_WIDESTRING focusText,
196 FPDF_DWORD nTextLen,
197 FX_BOOL bFocus) {
198 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus)
199 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus);
200 }
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700201
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700202 void FFI_DoURIAction(const FX_CHAR* bsURI) {
203 if (m_pInfo && m_pInfo->FFI_DoURIAction)
204 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI);
205 }
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700206
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700207 void FFI_DoGoToAction(int nPageIndex,
208 int zoomMode,
209 float* fPosArray,
210 int sizeOfArray) {
211 if (m_pInfo && m_pInfo->FFI_DoGoToAction)
212 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray,
213 sizeOfArray);
214 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700215
Tom Sepez51da0932015-11-25 16:05:49 -0800216#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700217 void FFI_DisplayCaret(FPDF_PAGE page,
218 FPDF_BOOL bVisible,
219 double left,
220 double top,
221 double right,
222 double bottom) {
223 if (m_pInfo && m_pInfo->FFI_DisplayCaret)
224 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right,
225 bottom);
226 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700227
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700228 int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) {
Jun Fang01fe5882015-11-25 11:05:58 +0800229 if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) {
230 return -1;
231 }
232 return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700233 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700234
Jun Fang01fe5882015-11-25 11:05:58 +0800235 void FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700236 if (m_pInfo && m_pInfo->FFI_SetCurrentPage)
237 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700238 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700239
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700240 CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700241
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700242 CFX_WideString FFI_GetPlatform() {
243 if (m_pInfo && m_pInfo->FFI_GetPlatform) {
244 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0);
245 if (nRequiredLen <= 0)
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700246 return L"";
Bo Xufdc00a72014-10-28 23:03:33 -0700247
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700248 char* pbuff = new char[nRequiredLen];
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700249 memset(pbuff, 0, nRequiredLen);
250 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen);
251 if (nActualLen <= 0 || nActualLen > nRequiredLen) {
252 delete[] pbuff;
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700253 return L"";
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700254 }
255 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
256 CFX_WideString wsRet = CFX_WideString::FromUTF16LE(
257 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()),
258 bsRet.GetLength() / sizeof(unsigned short));
259 delete[] pbuff;
260 return wsRet;
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700261 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700262 return L"";
263 }
Bo Xufdc00a72014-10-28 23:03:33 -0700264
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265 void FFI_GotoURL(FPDF_DOCUMENT document,
266 const CFX_WideStringC& wsURL,
267 FX_BOOL bAppend) {
268 if (m_pInfo && m_pInfo->FFI_GotoURL) {
269 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode();
270 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength());
271 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo);
272 bsTo.ReleaseBuffer();
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700273 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700274 }
Bo Xufdc00a72014-10-28 23:03:33 -0700275
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700276 void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) {
277 wsURL = CFX_WideString();
278 }
279
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280 void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag) {}
281
282 void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) {
283 if (m_pInfo && m_pInfo->FFI_GetPageViewRect) {
284 double left;
285 double top;
286 double right;
287 double bottom;
288 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom);
289
290 dstRect.left = static_cast<float>(left);
291 dstRect.top = static_cast<float>(top < bottom ? bottom : top);
292 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom);
293 dstRect.right = static_cast<float>(right);
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700294 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700295 }
Bo Xufdc00a72014-10-28 23:03:33 -0700296
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700297 FX_BOOL FFI_PopupMenu(FPDF_PAGE page,
298 FPDF_WIDGET hWidget,
299 int menuFlag,
300 CFX_PointF ptPopup,
301 const CFX_PointF* pRectExclude) {
302 if (m_pInfo && m_pInfo->FFI_PopupMenu)
303 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x,
304 ptPopup.y);
305 return FALSE;
306 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700307
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700308 void FFI_Alert(FPDF_WIDESTRING Msg,
309 FPDF_WIDESTRING Title,
310 int Type,
311 int Icon) {
312 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
313 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title,
314 Type, Icon);
315 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700316
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700317 void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler,
318 FPDF_WIDESTRING pTo,
319 FPDF_WIDESTRING pSubject,
320 FPDF_WIDESTRING pCC,
321 FPDF_WIDESTRING pBcc,
322 FPDF_WIDESTRING pMsg) {
323 if (m_pInfo && m_pInfo->FFI_EmailTo)
324 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc,
325 pMsg);
326 }
327
328 void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler,
329 int fileFlag,
330 FPDF_WIDESTRING uploadTo) {
331 if (m_pInfo && m_pInfo->FFI_UploadTo)
332 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo);
333 }
334
335 FPDF_FILEHANDLER* FFI_OpenFile(int fileType,
336 FPDF_WIDESTRING wsURL,
337 const char* mode) {
338 if (m_pInfo && m_pInfo->FFI_OpenFile)
339 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode);
340 return NULL;
341 }
342
343 CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) const {
344 return L"";
345 }
346
347 int FFI_GetDocumentCount() const { return 0; }
348 int FFI_GetCurDocument() const { return 0; }
349
350 IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url) {
351 if (m_pInfo && m_pInfo->FFI_DownloadFromURL) {
352 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode();
353 FPDF_WIDESTRING wsURL =
354 (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength());
355
356 FPDF_LPFILEHANDLER fileHandler =
357 m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL);
358
Lei Zhangdb5256f2015-10-02 10:11:43 -0700359 return new CFPDF_FileStream(fileHandler);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700360 }
361 return NULL;
362 }
363
364 CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL,
365 const FX_WCHAR* wsData,
366 const FX_WCHAR* wsContentType,
367 const FX_WCHAR* wsEncode,
368 const FX_WCHAR* wsHeader) {
369 if (m_pInfo && m_pInfo->FFI_PostRequestURL) {
370 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
371 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
372
373 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
374 FPDF_WIDESTRING data =
375 (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
376
377 CFX_ByteString bsContentType =
378 CFX_WideString(wsContentType).UTF16LE_Encode();
379 FPDF_WIDESTRING contentType =
380 (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength());
381
382 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
383 FPDF_WIDESTRING encode =
384 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
385
386 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode();
387 FPDF_WIDESTRING header =
388 (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength());
389
390 FPDF_BSTR respone;
391 FPDF_BStr_Init(&respone);
392 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode,
393 header, &respone);
394
395 CFX_WideString wsRet = CFX_WideString::FromUTF16LE(
396 (unsigned short*)respone.str, respone.len / sizeof(unsigned short));
397 FPDF_BStr_Clear(&respone);
398
399 return wsRet;
400 }
401 return L"";
402 }
403
404 FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL,
405 const FX_WCHAR* wsData,
406 const FX_WCHAR* wsEncode) {
407 if (m_pInfo && m_pInfo->FFI_PutRequestURL) {
408 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
409 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
410
411 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
412 FPDF_WIDESTRING data =
413 (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
414
415 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
416 FPDF_WIDESTRING encode =
417 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
418
419 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode);
420 }
421 return FALSE;
422 }
423
424 FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle,
425 const FX_WCHAR* wsFilter,
426 CFX_WideStringArray& wsPathArr,
427 FX_BOOL bOpen) {
428 return FALSE;
429 }
430
431 CFX_WideString FFI_GetLanguage() {
432 if (m_pInfo && m_pInfo->FFI_GetLanguage) {
433 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0);
434 if (nRequiredLen <= 0)
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700435 return L"";
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700436
437 char* pbuff = new char[nRequiredLen];
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438 memset(pbuff, 0, nRequiredLen);
439 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen);
440 if (nActualLen <= 0 || nActualLen > nRequiredLen) {
441 delete[] pbuff;
442 return L"";
443 }
444 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
445 CFX_WideString wsRet = CFX_WideString::FromUTF16LE(
446 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()),
447 bsRet.GetLength() / sizeof(unsigned short));
448 delete[] pbuff;
449 return wsRet;
Tom Sepezdcbc02f2015-07-17 09:16:17 -0700450 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700451 return L"";
452 }
Tom Sepez40e9ff32015-11-30 12:39:54 -0800453#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700454
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700455 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; }
456 void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; }
457 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; }
Tom Sepez50d12ad2015-11-24 09:50:51 -0800458 UnderlyingDocumentType* GetUnderlyingDocument() const {
459 return m_pUnderlyingDoc;
460 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700461 CFX_ByteString GetAppName() const { return ""; }
Oliver Chang24752492015-10-30 16:08:20 -0700462 IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700463 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700464
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700465 CFFL_IFormFiller* GetIFormFiller(); // Creates if not present.
466 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present.
Tom Sepezba038bc2015-10-08 12:03:00 -0700467 IJS_Runtime* GetJSRuntime(); // Creates if not present.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700468 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present.
Tom Sepez2f3dfef2015-03-02 15:35:26 -0800469
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700470 private:
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800471 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr;
472 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler;
473 std::unique_ptr<IJS_Runtime> m_pJSRuntime;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700474 FPDF_FORMFILLINFO* const m_pInfo;
475 CPDFSDK_Document* m_pSDKDoc;
Tom Sepez50d12ad2015-11-24 09:50:51 -0800476 UnderlyingDocumentType* const m_pUnderlyingDoc;
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800477 std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller;
478 std::unique_ptr<IFX_SystemHandler> m_pSysHandler;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700479};
480
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700481class CPDFSDK_Document {
482 public:
Tom Sepezfe351db2016-01-29 16:26:27 -0800483 static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle);
484
Tom Sepez50d12ad2015-11-24 09:50:51 -0800485 CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700486 ~CPDFSDK_Document();
Tom Sepez2f3dfef2015-03-02 15:35:26 -0800487
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700488 CPDFSDK_InterForm* GetInterForm();
Tom Sepez50d12ad2015-11-24 09:50:51 -0800489
Tom Sepez5259ef32015-11-24 10:21:01 -0800490 // Gets the document object for the next layer down; for master this is
491 // a CPDF_Document, but for XFA it is a CPDFXFA_Document.
Tom Sepez50d12ad2015-11-24 09:50:51 -0800492 UnderlyingDocumentType* GetUnderlyingDocument() const {
Tom Sepez40e9ff32015-11-30 12:39:54 -0800493#ifdef PDF_ENABLE_XFA
Tom Sepez50d12ad2015-11-24 09:50:51 -0800494 return GetXFADocument();
Tom Sepez40e9ff32015-11-30 12:39:54 -0800495#else // PDF_ENABLE_XFA
496 return GetPDFDocument();
497#endif // PDF_ENABLE_XFA
Tom Sepez50d12ad2015-11-24 09:50:51 -0800498 }
Tom Sepez5259ef32015-11-24 10:21:01 -0800499
500 // Gets the CPDF_Document, either directly in master, or from the
501 // CPDFXFA_Document for XFA.
Tom Sepezbf59a072015-10-21 14:07:23 -0700502 CPDF_Document* GetPDFDocument() const {
Tom Sepez40e9ff32015-11-30 12:39:54 -0800503#ifdef PDF_ENABLE_XFA
Tom Sepezbf59a072015-10-21 14:07:23 -0700504 return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr;
Tom Sepez40e9ff32015-11-30 12:39:54 -0800505#else // PDF_ENABLE_XFA
506 return m_pDoc;
507#endif // PDF_ENABLE_XFA
Tom Sepezbf59a072015-10-21 14:07:23 -0700508 }
Tom Sepez5259ef32015-11-24 10:21:01 -0800509
Tom Sepez40e9ff32015-11-30 12:39:54 -0800510#ifdef PDF_ENABLE_XFA
Tom Sepez5259ef32015-11-24 10:21:01 -0800511 // Gets the XFA document directly (XFA-only).
Tom Sepez50d12ad2015-11-24 09:50:51 -0800512 CPDFXFA_Document* GetXFADocument() const { return m_pDoc; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700513
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700514 int GetPageViewCount() const { return m_pageMap.size(); }
Tom Sepez40e9ff32015-11-30 12:39:54 -0800515#endif // PDF_ENABLE_XFA
516
Tom Sepez540c4362015-11-24 13:33:57 -0800517 CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700518 FX_BOOL ReNew = TRUE);
519 CPDFSDK_PageView* GetPageView(int nIndex);
520 CPDFSDK_PageView* GetCurrentView();
Tom Sepez540c4362015-11-24 13:33:57 -0800521 void RemovePageView(UnderlyingPageType* pPage);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700522 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700523
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700524 CPDFSDK_Annot* GetFocusAnnot();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700525
Tom Sepezba038bc2015-10-08 12:03:00 -0700526 IJS_Runtime* GetJsRuntime();
Tom Sepezc6ab1722015-02-05 15:27:25 -0800527
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700528 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
529 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700530
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700531 FX_BOOL ExtractPages(const CFX_WordArray& arrExtraPages,
532 CPDF_Document* pDstDoc);
533 FX_BOOL InsertPages(int nInsertAt,
534 const CPDF_Document* pSrcDoc,
535 const CFX_WordArray& arrSrcPages);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700536 FX_BOOL ReplacePages(int nPage,
537 const CPDF_Document* pSrcDoc,
538 const CFX_WordArray& arrSrcPages);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700539
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700540 void OnCloseDocument();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700541
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700542 int GetPageCount() { return m_pDoc->GetPageCount(); }
543 FX_BOOL GetPermissions(int nFlag);
544 FX_BOOL GetChangeMark() { return m_bChangeMask; }
545 void SetChangeMark() { m_bChangeMask = TRUE; }
546 void ClearChangeMark() { m_bChangeMask = FALSE; }
547 CFX_WideString GetPath();
Tom Sepez540c4362015-11-24 13:33:57 -0800548 UnderlyingPageType* GetPage(int nIndex);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700549 CPDFDoc_Environment* GetEnv() { return m_pEnv; }
550 void ProcJavascriptFun();
551 FX_BOOL ProcOpenAction();
552 CPDF_OCContext* GetOCContext();
553
554 private:
Tom Sepez540c4362015-11-24 13:33:57 -0800555 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap;
Tom Sepez50d12ad2015-11-24 09:50:51 -0800556 UnderlyingDocumentType* m_pDoc;
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800557 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700558 CPDFSDK_Annot* m_pFocusAnnot;
559 CPDFDoc_Environment* m_pEnv;
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800560 std::unique_ptr<CPDF_OCContext> m_pOccontent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700561 FX_BOOL m_bChangeMask;
Oliver Chang972b78d2015-10-30 12:59:29 -0700562 FX_BOOL m_bBeingDestroyed;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700563};
Tom Sepezb9cc7a02016-02-01 13:42:30 -0800564
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700565class CPDFSDK_PageView final {
566 public:
Tom Sepez540c4362015-11-24 13:33:57 -0800567 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700568 ~CPDFSDK_PageView();
Tom Sepez40e9ff32015-11-30 12:39:54 -0800569
570#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700571 void PageView_OnDraw(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -0800572 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700573 CPDF_RenderOptions* pOptions,
Lei Zhangf0e2e1b2015-11-02 13:27:54 -0800574 const FX_RECT& pClip);
Tom Sepez40e9ff32015-11-30 12:39:54 -0800575#else // PDF_ENABLE_XFA
576 void PageView_OnDraw(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -0800577 CFX_Matrix* pUser2Device,
Tom Sepez40e9ff32015-11-30 12:39:54 -0800578 CPDF_RenderOptions* pOptions);
579#endif // PDF_ENABLE_XFA
580
Lei Zhang1b700c32015-10-30 23:55:35 -0700581 const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700582 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
Lei Zhang1b700c32015-10-30 23:55:35 -0700583 const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700584 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
585 CPDFSDK_Annot* GetFocusAnnot();
586 void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) {
587 m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);
588 }
589 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {
590 return m_pSDKDoc->KillFocusAnnot(nFlag);
591 }
Oliver Chang972b78d2015-10-30 12:59:29 -0700592 void KillFocusAnnotIfNeeded();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700593 FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700594
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700595 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict);
596 CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict);
597 CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot);
Tom Sepez40e9ff32015-11-30 12:39:54 -0800598
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700599 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
Lei Zhang50218532015-10-30 14:03:43 -0700600 size_t CountAnnots() const;
Lei Zhangbf60b292015-10-26 12:14:35 -0700601 CPDFSDK_Annot* GetAnnot(size_t nIndex);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700602 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict);
Tom Sepez40e9ff32015-11-30 12:39:54 -0800603
604#ifdef PDF_ENABLE_XFA
605 CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700606 CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget);
607 CPDFXFA_Page* GetPDFXFAPage() { return m_page; }
608 CPDF_Page* GetPDFPage();
Tom Sepez40e9ff32015-11-30 12:39:54 -0800609#else
610 CPDF_Page* GetPDFPage() { return m_page; }
611#endif // PDF_ENABLE_XFA
612
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700613 CPDF_Document* GetPDFDocument();
614 CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; }
615 FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_UINT nFlag);
616 FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag);
Tom Sepez51da0932015-11-25 16:05:49 -0800617#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700618 FX_BOOL OnRButtonDown(const CPDF_Point& point, FX_UINT nFlag);
619 FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_UINT nFlag);
Tom Sepez40e9ff32015-11-30 12:39:54 -0800620#endif // PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700621 FX_BOOL OnChar(int nChar, FX_UINT nFlag);
622 FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
623 FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700624
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700625 FX_BOOL OnMouseMove(const CPDF_Point& point, int nFlag);
626 FX_BOOL OnMouseWheel(double deltaX,
627 double deltaY,
628 const CPDF_Point& point,
629 int nFlag);
Lei Zhang1b700c32015-10-30 23:55:35 -0700630 bool IsValidAnnot(const CPDF_Annot* p) const;
Tom Sepez60d909e2015-12-10 15:34:55 -0800631 void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700632 void UpdateRects(CFX_RectArray& rects);
633 void UpdateView(CPDFSDK_Annot* pAnnot);
Lei Zhangbf60b292015-10-26 12:14:35 -0700634 const std::vector<CPDFSDK_Annot*>& GetAnnotList() const {
635 return m_fxAnnotArray;
636 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700637
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700638 int GetPageIndex();
639 void LoadFXAnnots();
Jun Fang75239542016-01-20 08:04:47 +0800640 void ClearFXAnnots();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700641 void SetValid(FX_BOOL bValid) { m_bValid = bValid; }
642 FX_BOOL IsValid() { return m_bValid; }
643 void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; }
644 FX_BOOL IsLocked() { return m_bLocked; }
Tom Sepez51da0932015-11-25 16:05:49 -0800645#ifndef PDF_ENABLE_XFA
646 void TakeOverPage() { m_bTakeOverPage = TRUE; }
Tom Sepez40e9ff32015-11-30 12:39:54 -0800647#endif // PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700648
649 private:
650 void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice,
651 CPDFSDK_Widget* pWidget);
Lei Zhangbf60b292015-10-26 12:14:35 -0700652
Tom Sepez60d909e2015-12-10 15:34:55 -0800653 CFX_Matrix m_curMatrix;
Tom Sepez540c4362015-11-24 13:33:57 -0800654 UnderlyingPageType* m_page;
Lei Zhangaa8bf7e2015-12-24 19:13:32 -0800655 std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
Lei Zhangbf60b292015-10-26 12:14:35 -0700656 std::vector<CPDFSDK_Annot*> m_fxAnnotArray;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700657 CPDFSDK_Document* m_pSDKDoc;
Tom Sepez40e9ff32015-11-30 12:39:54 -0800658#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700659 CPDFSDK_Annot* m_CaptureWidget;
Tom Sepez40e9ff32015-11-30 12:39:54 -0800660#else // PDF_ENABLE_XFA
661 CPDFSDK_Widget* m_CaptureWidget;
662 FX_BOOL m_bTakeOverPage;
663#endif // PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700664 FX_BOOL m_bEnterWidget;
665 FX_BOOL m_bExitWidget;
666 FX_BOOL m_bOnWidget;
667 FX_BOOL m_bValid;
668 FX_BOOL m_bLocked;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700669};
670
Tom Sepez19922bb2015-05-28 13:23:12 -0700671#endif // FPDFSDK_INCLUDE_FSDK_MGR_H_