blob: eb557f58305eb9ec2e9c5e94819213186d800c0e [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
Tom Sepez1ed8a212015-05-11 15:25:39 -070010#include "../../public/fpdf_formfill.h"
11#include "../../public/fpdf_fwlevent.h" // cross platform keycode and events define.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012#include "fsdk_common.h"
13#include "fsdk_define.h"
14#include "fx_systemhandler.h"
Bo Xufdc00a72014-10-28 23:03:33 -070015#include "fpdfxfa/fpdfxfa_doc.h"
16#include "fpdfxfa/fpdfxfa_page.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070017#include "fsdk_baseannot.h"
18#include "fsdk_baseform.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070019#include "fsdk_annothandler.h"
20#include "fsdk_actionhandler.h"
21
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022class CPDFSDK_Document;
23class CPDFSDK_PageView;
24class CPDFSDK_Annot;
25class CFFL_IFormFiller;
26class CPDFSDK_Widget;
27class IFX_SystemHandler;
28class CPDFSDK_ActionHandler;
29class CJS_RuntimeFactory;
30
31#include "javascript/IJavaScript.h"
32
Tom Sepezb1161362015-06-09 11:29:12 -070033class CPDFDoc_Environment final
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070034{
35public:
Bo Xufdc00a72014-10-28 23:03:33 -070036 CPDFDoc_Environment(CPDFXFA_Document * pDoc);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037 ~CPDFDoc_Environment();
38
Tom Sepez2f3dfef2015-03-02 15:35:26 -080039 int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040
Bo Xufdc00a72014-10-28 23:03:33 -070041 virtual void Release()
42 {
43 if (m_pInfo && m_pInfo->Release)
44 m_pInfo->Release(m_pInfo);
45 delete this;
46 }
Nico Weber5eb9f7b2014-07-18 09:14:35 -070047 void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048 {
Tom Sepezc6ab1722015-02-05 15:27:25 -080049 if (m_pInfo && m_pInfo->FFI_Invalidate)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070050 {
51 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom);
52 }
53 }
Nico Weber5eb9f7b2014-07-18 09:14:35 -070054 void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070055 {
Tom Sepezc6ab1722015-02-05 15:27:25 -080056 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070057 {
58 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom);
59 }
60 }
61
Nico Weber5eb9f7b2014-07-18 09:14:35 -070062 void FFI_SetCursor(int nCursorType)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070063 {
Tom Sepezc6ab1722015-02-05 15:27:25 -080064 if (m_pInfo && m_pInfo->FFI_SetCursor)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070065 {
66 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType);
67 }
68 }
69
Nico Weber5eb9f7b2014-07-18 09:14:35 -070070 int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071 {
Tom Sepezc6ab1722015-02-05 15:27:25 -080072 if (m_pInfo && m_pInfo->FFI_SetTimer)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073 {
74 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc);
75 }
76 return -1;
77 }
Tom Sepezc6ab1722015-02-05 15:27:25 -080078
Nico Weber5eb9f7b2014-07-18 09:14:35 -070079 void FFI_KillTimer(int nTimerID)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070080 {
Tom Sepezc6ab1722015-02-05 15:27:25 -080081 if (m_pInfo && m_pInfo->FFI_KillTimer)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070082 {
83 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID);
84 }
85 }
86 FX_SYSTEMTIME FFI_GetLocalTime()
87 {
88 FX_SYSTEMTIME fxtime;
89 if(m_pInfo && m_pInfo->FFI_GetLocalTime)
90 {
91 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo);
92 fxtime.wDay = systime.wDay;
93 fxtime.wDayOfWeek = systime.wDayOfWeek;
94 fxtime.wHour = systime.wHour;
95 fxtime.wMilliseconds = systime.wMilliseconds;
96 fxtime.wMinute = systime.wMinute;
97 fxtime.wMonth = systime.wMonth;
98 fxtime.wSecond = systime.wSecond;
99 fxtime.wYear = systime.wYear;
100 }
101 return fxtime;
102 }
103
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700104 void FFI_OnChange()
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700105 {
106 if(m_pInfo && m_pInfo->FFI_OnChange)
107 {
108 m_pInfo->FFI_OnChange(m_pInfo);
109 }
110 }
111
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700112 FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113 {
Tom Sepezc6ab1722015-02-05 15:27:25 -0800114
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0;
116 }
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700117 FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118 {
119
120 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0;
121 }
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700122 FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700123 {
124
125 return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
126 }
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700127 FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700128 {
129 return FALSE;
130 }
131
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700132 int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700133 {
134 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
135 {
136 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
137 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
138 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
139 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
140 int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon);
141 bsMsg.ReleaseBuffer();
142 bsTitle.ReleaseBuffer();
143 return ret;
144 }
145 return -1;
146 }
147
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700148 int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default, const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149 {
150 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response)
151 {
152 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode();
153 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode();
154 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode();
155 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode();
156 FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength());
157 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
158 FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength());
159 FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength());
Tom Sepezc6ab1722015-02-05 15:27:25 -0800160 int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle,
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700161 pDefault, pLabel, bPassword, response, length);
162 bsQuestion.ReleaseBuffer();
163 bsTitle.ReleaseBuffer();
164 bsDefault.ReleaseBuffer();
165 bsLabel.ReleaseBuffer();
166 return ret;
167 }
168 return -1;
169 }
170
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700171 void JS_appBeep(int nType)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700172 {
173 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep)
174 {
175 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
176 }
177 }
178
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700179 CFX_WideString JS_fieldBrowse()
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700180 {
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700181 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Field_browse)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700182 {
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700183 int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, NULL, 0);
184 if (nRequiredLen <= 0)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700185 return L"";
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700186
187 char* pbuff = new char[nRequiredLen];
188 if (!pbuff)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189 return L"";
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700190
191 memset(pbuff, 0, nRequiredLen);
192 int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, pbuff, nRequiredLen);
193 if (nActualLen <= 0 || nActualLen > nRequiredLen)
194 {
195 delete[] pbuff;
196 return L"";
197 }
198 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700199 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
200 delete[] pbuff;
201 return wsRet;
202 }
203 return L"";
204 }
205
206 CFX_WideString JS_docGetFilePath()
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700207 {
208 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_getFilePath)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700209 {
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700210 int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, NULL, 0);
211 if (nRequiredLen <= 0)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700212 return L"";
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700213
214 char* pbuff = new char[nRequiredLen];
215 if (!pbuff)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700216 return L"";
Tom Sepez0d3b5cc2014-07-30 13:03:52 -0700217
218 memset(pbuff, 0, nRequiredLen);
219 int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, pbuff, nRequiredLen);
220 if (nActualLen <= 0 || nActualLen > nRequiredLen)
221 {
222 delete[] pbuff;
223 return L"";
224 }
225 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700226 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
227 delete[] pbuff;
228 return wsRet;
229 }
230 return L"";
231 }
232
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700233 void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700234 {
235 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm)
236 {
237 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode();
238 FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength());
239 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination);
240 bsDestination.ReleaseBuffer();
241 }
242 }
243
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700244 void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,const FX_WCHAR* To, const FX_WCHAR* Subject, const FX_WCHAR* CC, const FX_WCHAR* BCC, const FX_WCHAR* Msg)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700245 {
246 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail)
247 {
248 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode();
249 CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode();
250 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode();
251 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode();
252 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode();
253 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
254 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
255 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength());
256 FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
257 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
258 m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject,
259 pCC, pBcc, pMsg);
260 bsTo.ReleaseBuffer();
261 bsCC.ReleaseBuffer();
262 bsBcc.ReleaseBuffer();
263 bsSubject.ReleaseBuffer();
264 bsMsg.ReleaseBuffer();
265 }
266 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700267
268 void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations)
269 {
270 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print)
271 {
272 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations);
273 }
274 }
275 void JS_docgotoPage(int nPageNum)
276 {
277 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage)
278 {
279 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum);
280 }
281 }
282
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700283 FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700284 {
285 if(m_pInfo && m_pInfo->FFI_GetPage)
286 {
287 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex);
288 }
289 return NULL;
290 }
291
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700292 FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700293 {
294 if(m_pInfo && m_pInfo->FFI_GetCurrentPage)
295 {
296 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document);
297 }
298 return NULL;
299 }
300
301 int FFI_GetRotation(FPDF_PAGE page)
302 {
303 if(m_pInfo && m_pInfo->FFI_GetRotation)
304 {
305 return m_pInfo->FFI_GetRotation(m_pInfo, page);
306 }
307 return 0;
308 }
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700309 void FFI_ExecuteNamedAction(const FX_CHAR* namedAction)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700310 {
311 if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction)
312 {
313 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction);
314 }
315 }
316 void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus)
317 {
318 if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus)
319 {
320 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus);
321 }
322 }
323
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700324 void FFI_DoURIAction(const FX_CHAR* bsURI)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700325 {
326 if(m_pInfo && m_pInfo->FFI_DoURIAction)
327 {
328 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI);
329 }
330 }
331
332 void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray)
333 {
334 if(m_pInfo && m_pInfo->FFI_DoGoToAction)
335 {
336 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray);
337 }
338 }
339
Bo Xufdc00a72014-10-28 23:03:33 -0700340 void FFI_DisplayCaret(FPDF_PAGE page, FPDF_BOOL bVisible, double left, double top, double right, double bottom)
341 {
342 if (m_pInfo && m_pInfo->FFI_DisplayCaret)
343 {
344 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, bottom);
345 }
346 }
347 int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document)
348 {
349 if (m_pInfo && m_pInfo->FFI_GetCurrentPageIndex)
350 {
351 m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document);
352 }
353 return -1;
354 }
355 int FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage)
356 {
357 if (m_pInfo && m_pInfo->FFI_SetCurrentPage)
358 {
359 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage);
360 }
361 return -1;
362 }
363
364 CFX_WideString FFI_GetAppName()
365 {
366 return CFX_WideString(L"Acrobat");
367
368 //if (m_pInfo && m_pInfo->FFI_GetAppName)
369 //{
370 // int nLen = m_pInfo->FFI_GetAppName(m_pInfo, NULL, 0);
371 // if(nLen <= 0)
372 // return L"";
373 // char* pbuff = new char[nLen];
374 // if(pbuff)
375 // memset(pbuff, 0, nLen);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800376 // else
Bo Xufdc00a72014-10-28 23:03:33 -0700377 // return L"";
378 // nLen = m_pInfo->FFI_GetAppName(m_pInfo, pbuff, nLen);
379 // CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen);
380 // CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
381 // delete[] pbuff;
382 // return wsRet;
383 //}
384
385 //return L"";
386 }
387
388 CFX_WideString FFI_GetPlatform()
389 {
390 if (m_pInfo && m_pInfo->FFI_GetPlatform)
391 {
392 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0);
393 if (nRequiredLen <= 0)
394 return L"";
395
396 char* pbuff = new char[nRequiredLen];
397 if (!pbuff)
398 return L"";
399
400 memset(pbuff, 0, nRequiredLen);
401 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen);
402 if (nActualLen <= 0 || nActualLen > nRequiredLen)
403 {
404 delete[] pbuff;
405 return L"";
406 }
407 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
408 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
409 delete[] pbuff;
410 return wsRet;
411 }
412 return L"";
413 }
414
Tom Sepezca3ac5e2015-06-10 17:38:11 -0700415 void FFI_GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL, FX_BOOL bAppend)
Bo Xufdc00a72014-10-28 23:03:33 -0700416 {
417 if (m_pInfo && m_pInfo->FFI_GotoURL)
418 {
419 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode();
420 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength());
421 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo);
422 bsTo.ReleaseBuffer();
423 }
424 }
425 void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL)
426 {
427 wsURL = CFX_WideString();
428 return;
429 //if (m_pInfo && m_pInfo->FFI_GetURL)
430 //{
431 // FPDF_WIDESTRING url = m_pInfo->FFI_GetURL(m_pInfo, document);
432 // CFX_WideString tmp;
433 // tmp.FromUTF16LE(url);
434 // wsURL = tmp;
435 //}
436 }
437
438 void FFI_AddDoRecord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget)
439 {
440 //if (m_pInfo && m_pInfo->FFI_AddDoRecord)
441 //{
442 // m_pInfo->FFI_AddDoRecord(m_pInfo, document, hWidget);
443 //}
444 }
445 void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag)
446 {
447 //if (m_pInfo && m_pInfo->FFI_PageEvent)
448 //{
449 // m_pInfo->FFI_PageEvent(m_pInfo, page, flag);
450 //}
451 }
452
453 void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect)
454 {
455 if (m_pInfo && m_pInfo->FFI_GetPageViewRect)
456 {
Tom Sepezc6ab1722015-02-05 15:27:25 -0800457 double left;
Bo Xufdc00a72014-10-28 23:03:33 -0700458 double top;
459 double right;
460 double bottom;
461 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom);
462
Bruce Dawson3f49aa32015-01-08 11:47:49 -0800463 dstRect.left = static_cast<float>(left);
464 dstRect.top = static_cast<float>(top < bottom ? bottom : top);
465 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom);
466 dstRect.right = static_cast<float>(right);
Bo Xufdc00a72014-10-28 23:03:33 -0700467 }
468 }
469
470
471 FX_BOOL FFI_PopupMenu(FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, CFX_PointF ptPopup, const CFX_PointF* pRectExclude)
472 {
473 if (m_pInfo && m_pInfo->FFI_PopupMenu)
474 {
475 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, ptPopup.y);
476 }
477 return FALSE;
478 }
Tom Sepezc6ab1722015-02-05 15:27:25 -0800479
Bo Xufdc00a72014-10-28 23:03:33 -0700480 void FFI_Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon)
481 {
482 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
483 {
484 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type, Icon);
485 }
486 }
487 void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC, FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg)
488 {
489 if(m_pInfo && m_pInfo->FFI_EmailTo)
490 {
491 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg);
492 }
493 }
494 void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo)
495 {
496 if(m_pInfo && m_pInfo->FFI_UploadTo)
497 {
498 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo);
499 }
500 }
501 FPDF_FILEHANDLER* FFI_OpenFile(int fileType, FPDF_WIDESTRING wsURL, const char* mode)
502 {
503 if(m_pInfo && m_pInfo->FFI_OpenFile)
504 {
505 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode);
506 }
507 return NULL;
508 }
509 CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler)
510 {
511#if 0
512 if (m_pInfo && m_pInfo->FFI_GetFilePath)
513 {
514 int nRequiredLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, NULL, 0);
515 if (nRequiredLen <= 0)
516 return L"";
517
518 char* pbuff = new char[nRequiredLen];
519 if (!pbuff)
520 return L"";
521
522 memset(pbuff, 0, nRequiredLen);
523 int nActualLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, pbuff, nRequiredLen);
524 if (nActualLen <= 0 || nActualLen > nRequiredLen)
525 {
526 delete[] pbuff;
527 return L"";
528 }
529 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
530 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
531 delete[] pbuff;
532 return wsRet;
533 }
534 return L"";
535#else
536 return L"";
537#endif
538 }
539 int FFI_GetDocumentCount()
540 {
541 //if (m_pInfo && m_pInfo->FFI_GetDocumentCount)
542 //{
543 //return m_pInfo->FFI_GetDocumentCount(m_pInfo);
544 //}
545 return 0;
546 }
547
548 int FFI_GetCurDocument()
549 {
550 //if (m_pInfo && m_pInfo->FFI_GetCurDocumentIndex)
551 //{
552 // return m_pInfo->FFI_GetCurDocumentIndex(m_pInfo);
553 //}
554 return 0;
555 }
556
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700557 IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url)
Bo Xufdc00a72014-10-28 23:03:33 -0700558 {
559 if (m_pInfo && m_pInfo->FFI_DownloadFromURL)
560 {
561 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode();
562 FPDF_WIDESTRING wsURL = (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength());
563
564 FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL);
565
566 CFPDF_FileStream* fileStream = FX_NEW CFPDF_FileStream(fileHandler);
567 return fileStream;
568 }
569 return NULL;
570 }
571
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700572 CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsContentType, const FX_WCHAR* wsEncode, const FX_WCHAR* wsHeader)
Bo Xufdc00a72014-10-28 23:03:33 -0700573 {
574 if (m_pInfo && m_pInfo->FFI_PostRequestURL)
575 {
576 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
577 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
578
579 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
580 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
581
582 CFX_ByteString bsContentType = CFX_WideString(wsContentType).UTF16LE_Encode();
583 FPDF_WIDESTRING contentType = (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength());
584
585 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
586 FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
587
588 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode();
589 FPDF_WIDESTRING header = (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength());
590
591 FPDF_BSTR respone;
592 FPDF_BStr_Init(&respone);
593 FPDF_BOOL bRet = m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, &respone);
594
595 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)respone.str, respone.len/sizeof(unsigned short));
596 FPDF_BStr_Clear(&respone);
597
598 return wsRet;
599 }
600 return L"";
601 }
602
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700603 FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsEncode)
Bo Xufdc00a72014-10-28 23:03:33 -0700604 {
605 if (m_pInfo && m_pInfo->FFI_PutRequestURL)
606 {
607 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
608 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
609
610 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
611 FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
612
613 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
614 FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
615
616 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode);
617 }
618 return FALSE;
619 }
620
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700621 FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, const FX_WCHAR* wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen)
Bo Xufdc00a72014-10-28 23:03:33 -0700622 {
623 /*CFX_ByteString bsTitle = CFX_WideString(wsTitle).UTF16LE_Encode();
624 FPDF_WIDESTRING title = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
625
626 CFX_ByteString bsFilter = CFX_WideString(wsFilter).UTF16LE_Encode();
627 FPDF_WIDESTRING filter = (FPDF_WIDESTRING)bsFilter.GetBuffer(bsFilter.GetLength());
628
629 CFX_ByteStringArray* strPathArr = FX_NEW CFX_ByteStringArray();
630 if (m_pInfo && m_pInfo->FFI_ShowFileDialog)
631 {
632 FPDF_BOOL bRet = m_pInfo->FFI_ShowFileDialog(m_pInfo, title, filter, bOpen, (FPDF_STRINGHANDLE)strPathArr);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800633 if (bRet)
Bo Xufdc00a72014-10-28 23:03:33 -0700634 {
635 int count = strPathArr->GetSize();
636 for (int i=0; i<count; i++)
637 {
638 CFX_ByteString bsPath = *strPathArr->GetDataPtr(i);
639 CFX_WideString wsPath = CFX_WideString::FromUTF16LE((unsigned short*)bsPath.GetBuffer(bsPath.GetLength()), bsPath.GetLength()/sizeof(unsigned short));
640 if (!wsPath.IsEmpty())
641 wsPathArr.Add(wsPath);
642 wsPath = L"";
643 }
644 return TRUE;
645 }
646
647 return FALSE;
648 }
649 */
650
651 return FALSE;
652 }
653 CFX_WideString FFI_GetLanguage()
654 {
655 if (m_pInfo && m_pInfo->FFI_GetLanguage)
656 {
657 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0);
658 if (nRequiredLen <= 0)
659 return L"";
660
661 char* pbuff = new char[nRequiredLen];
662 if (!pbuff)
663 return L"";
664
665 memset(pbuff, 0, nRequiredLen);
666 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen);
667 if (nActualLen <= 0 || nActualLen > nRequiredLen)
668 {
669 delete[] pbuff;
670 return L"";
671 }
672 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
673 CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
674 delete[] pbuff;
675 return wsRet;
676 }
677 return L"";
678 }
679
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700680 FX_BOOL IsJSInitiated();
681
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700682 void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;}
683 CPDFSDK_Document* GetCurrentDoc();
Bo Xufdc00a72014-10-28 23:03:33 -0700684 CPDFXFA_Document* GetPDFXFADocument() {return m_pDoc;}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700685
686 CFX_ByteString GetAppName() {return "";}
687
688 CFFL_IFormFiller* GetIFormFiller();
689 IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;}
690
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700691 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr();
692 IFXJS_Runtime* GetJSRuntime();
693 CPDFSDK_ActionHandler* GetActionHander();
Tom Sepez2f3dfef2015-03-02 15:35:26 -0800694 FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;}
695
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700696private:
697 CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr;
698 CPDFSDK_ActionHandler* m_pActionHandler;
699 IFXJS_Runtime* m_pJSRuntime;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700700 FPDF_FORMFILLINFO* m_pInfo;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700701 CPDFSDK_Document* m_pSDKDoc;
Bo Xufdc00a72014-10-28 23:03:33 -0700702 CPDFXFA_Document* m_pDoc;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700703
704 CFFL_IFormFiller* m_pIFormFiller;
705 IFX_SystemHandler* m_pSysHandler;
706
707public:
Bo Xufdc00a72014-10-28 23:03:33 -0700708 //CJS_RuntimeFactory* m_pJSRuntimeFactory;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700709};
710
711
712
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700713class CPDFSDK_InterForm;
714class CPDFSDK_Document
715{
716public:
Bo Xufdc00a72014-10-28 23:03:33 -0700717 CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700718 ~CPDFSDK_Document();
Tom Sepez2f3dfef2015-03-02 15:35:26 -0800719
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700720 CPDFSDK_InterForm* GetInterForm() ;
Bo Xufdc00a72014-10-28 23:03:33 -0700721 CPDFXFA_Document* GetDocument() {return m_pDoc;}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700722
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700723 void InitPageView();
Bo Xufdc00a72014-10-28 23:03:33 -0700724 int GetPageViewCount(){return m_pageMap.GetCount();}
725 void AddPageView(CPDFXFA_Page* pPDFXFAPage, CPDFSDK_PageView* pPageView);
726 CPDFSDK_PageView* GetPageView(CPDFXFA_Page* pPDFXFAPage, FX_BOOL ReNew = TRUE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700727 CPDFSDK_PageView* GetPageView(int nIndex);
728 CPDFSDK_PageView* GetCurrentView();
Bo Xufdc00a72014-10-28 23:03:33 -0700729 void ReMovePageView(CPDFXFA_Page* pPDFPage);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700730 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
731
Tom Sepez2f3dfef2015-03-02 15:35:26 -0800732 CPDFSDK_Annot* GetFocusAnnot();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700733
734 IFXJS_Runtime * GetJsRuntime();
Tom Sepezc6ab1722015-02-05 15:27:25 -0800735
Tom Sepez2f3dfef2015-03-02 15:35:26 -0800736 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700737 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0);
738
739 FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc);
740 FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
741 FX_BOOL DeletePages(int nStart, int nCount);
742 FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
743
744 void OnCloseDocument();
745
746 int GetPageCount() {return m_pDoc->GetPageCount();}
747 FX_BOOL GetPermissions(int nFlag);
748 FX_BOOL GetChangeMark() {return m_bChangeMask;}
749 void SetChangeMark() {m_bChangeMask = TRUE;}
750 void ClearChangeMark() {m_bChangeMask= FALSE;}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700751 CFX_WideString GetPath() ;
Bo Xufdc00a72014-10-28 23:03:33 -0700752 CPDFXFA_Page* GetPage(int nIndex);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700753 CPDFDoc_Environment * GetEnv() {return m_pEnv; }
754 void ProcJavascriptFun();
755 FX_BOOL ProcOpenAction();
756 CPDF_OCContext* GetOCContext();
757private:
Bo Xufdc00a72014-10-28 23:03:33 -0700758 CFX_MapPtrTemplate<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap;
759 CPDFXFA_Document* m_pDoc;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700760 CPDFSDK_InterForm* m_pInterForm;
761 CPDFSDK_Annot* m_pFocusAnnot;
762 CPDFDoc_Environment * m_pEnv;
763 CPDF_OCContext * m_pOccontent;
764 FX_BOOL m_bChangeMask;
765};
Tom Sepezb1161362015-06-09 11:29:12 -0700766class CPDFSDK_PageView final
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700767{
768public:
Bo Xufdc00a72014-10-28 23:03:33 -0700769 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700770 ~CPDFSDK_PageView();
Bo Xufdc00a72014-10-28 23:03:33 -0700771 void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions, FX_RECT* pClip = NULL) ;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700772 CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
773 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
774 CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
775 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
776 CPDFSDK_Annot* GetFocusAnnot() ;
777 void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);}
778 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);}
779 FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot);
780
781 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict);
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700782 CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700783 CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot);
Tom Sepezeed467d2015-06-02 10:35:27 -0700784 CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800785 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
786
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700787 int CountAnnots();
788 CPDFSDK_Annot* GetAnnot(int nIndex);
789 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict);
Tom Sepezeed467d2015-06-02 10:35:27 -0700790 CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget);
Bo Xufdc00a72014-10-28 23:03:33 -0700791 CPDFXFA_Page* GetPDFXFAPage(){return m_page;}
792 CPDF_Page* GetPDFPage();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700793 CPDF_Document* GetPDFDocument();
Tom Sepezc6ab1722015-02-05 15:27:25 -0800794 CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;}
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700795 FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag);
796 FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag);
Bo Xufdc00a72014-10-28 23:03:33 -0700797 FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_UINT nFlag);
798 FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_UINT nFlag);
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700799 FX_BOOL OnChar(int nChar, FX_UINT nFlag);
800 FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
801 FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700802
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700803 FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag);
804 FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag);
Tom Sepezd7e5cc72015-06-10 14:33:37 -0700805 FX_BOOL IsValidAnnot(void* p);
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700806 void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;}
807 void UpdateRects(CFX_RectArray& rects);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700808 void UpdateView(CPDFSDK_Annot* pAnnot);
809 CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; }
810
Nico Weber5eb9f7b2014-07-18 09:14:35 -0700811 int GetPageIndex();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700812 void LoadFXAnnots();
Bo Xufdc00a72014-10-28 23:03:33 -0700813 void SetValid(FX_BOOL bValid) {m_bValid = bValid;}
814 FX_BOOL IsValid() {return m_bValid;}
815 void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;}
816 FX_BOOL IsLocked() {return m_bLocked;}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700817private:
818 void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget);
Bo Xufdc00a72014-10-28 23:03:33 -0700819 CPDF_Matrix m_curMatrix;
820 CPDFXFA_Page* m_page;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700821 CPDF_AnnotList* m_pAnnotList;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700822 //CPDFSDK_Annot* m_pFocusAnnot;
823 CFX_PtrArray m_fxAnnotArray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700824 CPDFSDK_Document* m_pSDKDoc;
Bo Xufdc00a72014-10-28 23:03:33 -0700825 CPDFSDK_Annot* m_CaptureWidget;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700826 FX_BOOL m_bEnterWidget;
827 FX_BOOL m_bExitWidget;
828 FX_BOOL m_bOnWidget;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700829 FX_BOOL m_bValid;
Bo Xufdc00a72014-10-28 23:03:33 -0700830 FX_BOOL m_bLocked;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700831};
832
833
834template<class TYPE>
835class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE>
836{
Tom Sepezc6ab1722015-02-05 15:27:25 -0800837public:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700838 CGW_ArrayTemplate(){}
839 virtual ~CGW_ArrayTemplate(){}
Tom Sepezc6ab1722015-02-05 15:27:25 -0800840
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700841 typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800842
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700843 void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE)
844 {
845 int nSize = this->GetSize();
846 QuickSort(0, nSize -1, bAscent, pCompare);
847 }
Tom Sepezc6ab1722015-02-05 15:27:25 -0800848
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700849private:
850 void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare)
851 {
852 if (nStartPos >= nStopPos) return;
Tom Sepezc6ab1722015-02-05 15:27:25 -0800853
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700854 if ((nStopPos - nStartPos) == 1)
855 {
856 TYPE Value1 = this->GetAt(nStartPos);
857 TYPE Value2 = this->GetAt(nStopPos);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800858
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700859 int iGreate = (*pCompare)(Value1, Value2);
860 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
861 {
862 this->SetAt(nStartPos, Value2);
863 this->SetAt(nStopPos, Value1);
864 }
865 return;
866 }
Tom Sepezc6ab1722015-02-05 15:27:25 -0800867
Bo Xu9a52eb02014-06-24 11:37:49 -0700868 FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700869 FX_UINT i = nStartPos;
Tom Sepezc6ab1722015-02-05 15:27:25 -0800870
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700871 TYPE Value = this->GetAt(m);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800872
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700873 while (i < m)
874 {
875 TYPE temp = this->GetAt(i);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800876
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700877 int iGreate = (*pCompare)(temp, Value);
878 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0))
879 {
880 this->InsertAt(m+1, temp);
881 this->RemoveAt(i);
882 m--;
883 }
884 else
885 {
886 i++;
887 }
888 }
Tom Sepezc6ab1722015-02-05 15:27:25 -0800889
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700890 FX_UINT j = nStopPos;
Tom Sepezc6ab1722015-02-05 15:27:25 -0800891
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700892 while (j > m)
893 {
894 TYPE temp = this->GetAt(j);
Tom Sepezc6ab1722015-02-05 15:27:25 -0800895
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896 int iGreate = (*pCompare)(temp, Value);
897 if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0))
898 {
899 this->RemoveAt(j);
900 this->InsertAt(m, temp);
901 m++;
902 }
903 else
904 {
905 j--;
906 }
907 }
Tom Sepezc6ab1722015-02-05 15:27:25 -0800908
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700909 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare);
910 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare);
911 }
912};
913
Tom Sepez19922bb2015-05-28 13:23:12 -0700914#endif // FPDFSDK_INCLUDE_FSDK_MGR_H_