John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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 Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_ |
| 8 | #define FPDFSDK_INCLUDE_FSDK_MGR_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 10 | #include <map> |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 11 | #include <memory> |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 12 | |
Lei Zhang | a688a04 | 2015-11-09 13:57:49 -0800 | [diff] [blame] | 13 | #include "core/include/fpdftext/fpdf_text.h" |
Lei Zhang | 8241df7 | 2015-11-06 14:38:48 -0800 | [diff] [blame] | 14 | #include "fsdk_actionhandler.h" |
| 15 | #include "fsdk_annothandler.h" |
| 16 | #include "fsdk_baseannot.h" |
| 17 | #include "fsdk_baseform.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | #include "fsdk_common.h" |
| 19 | #include "fsdk_define.h" |
| 20 | #include "fx_systemhandler.h" |
Lei Zhang | e5b0bd1 | 2015-06-19 17:15:41 -0700 | [diff] [blame] | 21 | #include "javascript/IJavaScript.h" |
Lei Zhang | b4e7f30 | 2015-11-06 15:52:32 -0800 | [diff] [blame] | 22 | #include "public/fpdf_formfill.h" |
| 23 | #include "public/fpdf_fwlevent.h" // cross platform keycode and events define. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 25 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 875b9c9 | 2016-01-08 13:51:10 -0800 | [diff] [blame] | 26 | #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
| 27 | #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 28 | #endif // PDF_ENABLE_XFA |
| 29 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 30 | class CFFL_IFormFiller; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 31 | class CPDFSDK_ActionHandler; |
| 32 | class CPDFSDK_Annot; |
| 33 | class CPDFSDK_Document; |
| 34 | class CPDFSDK_InterForm; |
| 35 | class CPDFSDK_PageView; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | class CPDFSDK_Widget; |
| 37 | class IFX_SystemHandler; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 38 | |
Tom Sepez | 5702859 | 2016-02-01 15:49:11 -0800 | [diff] [blame] | 39 | // NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken |
| 40 | // since modifying the result would impact |bsUTF16LE|. |
| 41 | FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE); |
| 42 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 43 | class CPDFDoc_Environment final { |
| 44 | public: |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 45 | CPDFDoc_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo); |
Tom Sepez | dfbf8e7 | 2015-10-14 14:17:26 -0700 | [diff] [blame] | 46 | ~CPDFDoc_Environment(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 47 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 48 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | dfbf8e7 | 2015-10-14 14:17:26 -0700 | [diff] [blame] | 49 | void Release() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 50 | if (m_pInfo && m_pInfo->Release) |
| 51 | m_pInfo->Release(m_pInfo); |
| 52 | delete this; |
| 53 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 54 | #endif // PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 55 | |
| 56 | void FFI_Invalidate(FPDF_PAGE page, |
| 57 | double left, |
| 58 | double top, |
| 59 | double right, |
| 60 | double bottom) { |
| 61 | if (m_pInfo && m_pInfo->FFI_Invalidate) |
| 62 | m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); |
| 63 | } |
| 64 | |
| 65 | void FFI_OutputSelectedRect(FPDF_PAGE page, |
| 66 | double left, |
| 67 | double top, |
| 68 | double right, |
| 69 | double bottom) { |
| 70 | if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) |
| 71 | m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); |
| 72 | } |
| 73 | |
| 74 | void FFI_SetCursor(int nCursorType) { |
| 75 | if (m_pInfo && m_pInfo->FFI_SetCursor) |
| 76 | m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); |
| 77 | } |
| 78 | |
| 79 | int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) { |
| 80 | if (m_pInfo && m_pInfo->FFI_SetTimer) |
| 81 | return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); |
| 82 | return -1; |
| 83 | } |
| 84 | |
| 85 | void FFI_KillTimer(int nTimerID) { |
| 86 | if (m_pInfo && m_pInfo->FFI_KillTimer) |
| 87 | m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); |
| 88 | } |
| 89 | |
Tom Sepez | 468e589 | 2015-10-13 15:49:36 -0700 | [diff] [blame] | 90 | FX_SYSTEMTIME FFI_GetLocalTime() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 91 | FX_SYSTEMTIME fxtime; |
| 92 | if (m_pInfo && m_pInfo->FFI_GetLocalTime) { |
| 93 | FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); |
| 94 | fxtime.wDay = systime.wDay; |
| 95 | fxtime.wDayOfWeek = systime.wDayOfWeek; |
| 96 | fxtime.wHour = systime.wHour; |
| 97 | fxtime.wMilliseconds = systime.wMilliseconds; |
| 98 | fxtime.wMinute = systime.wMinute; |
| 99 | fxtime.wMonth = systime.wMonth; |
| 100 | fxtime.wSecond = systime.wSecond; |
| 101 | fxtime.wYear = systime.wYear; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 102 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 103 | return fxtime; |
| 104 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 105 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 106 | void FFI_OnChange() { |
| 107 | if (m_pInfo && m_pInfo->FFI_OnChange) |
| 108 | m_pInfo->FFI_OnChange(m_pInfo); |
| 109 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 110 | |
Tom Sepez | 468e589 | 2015-10-13 15:49:36 -0700 | [diff] [blame] | 111 | FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 112 | return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; |
| 113 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 114 | |
Tom Sepez | 468e589 | 2015-10-13 15:49:36 -0700 | [diff] [blame] | 115 | FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; |
| 117 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 118 | |
Tom Sepez | 468e589 | 2015-10-13 15:49:36 -0700 | [diff] [blame] | 119 | FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 120 | return (nFlag & FWL_EVENTFLAG_AltKey) != 0; |
| 121 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 122 | |
Tom Sepez | 468e589 | 2015-10-13 15:49:36 -0700 | [diff] [blame] | 123 | FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) const { return FALSE; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 124 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 125 | FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex) { |
| 126 | if (m_pInfo && m_pInfo->FFI_GetPage) |
| 127 | return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); |
| 128 | return NULL; |
| 129 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 130 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 131 | FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) { |
| 132 | if (m_pInfo && m_pInfo->FFI_GetCurrentPage) |
| 133 | return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); |
| 134 | return NULL; |
| 135 | } |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 136 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 137 | int FFI_GetRotation(FPDF_PAGE page) { |
| 138 | if (m_pInfo && m_pInfo->FFI_GetRotation) |
| 139 | return m_pInfo->FFI_GetRotation(m_pInfo, page); |
| 140 | return 0; |
| 141 | } |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 142 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 143 | void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) { |
| 144 | if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) |
| 145 | m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); |
| 146 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 147 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 148 | void FFI_OnSetFieldInputFocus(void* field, |
| 149 | FPDF_WIDESTRING focusText, |
| 150 | FPDF_DWORD nTextLen, |
| 151 | FX_BOOL bFocus) { |
| 152 | if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) |
| 153 | m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); |
| 154 | } |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 155 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 156 | void FFI_DoURIAction(const FX_CHAR* bsURI) { |
| 157 | if (m_pInfo && m_pInfo->FFI_DoURIAction) |
| 158 | m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); |
| 159 | } |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 160 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 161 | void FFI_DoGoToAction(int nPageIndex, |
| 162 | int zoomMode, |
| 163 | float* fPosArray, |
| 164 | int sizeOfArray) { |
| 165 | if (m_pInfo && m_pInfo->FFI_DoGoToAction) |
| 166 | m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, |
| 167 | sizeOfArray); |
| 168 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 169 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 170 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | void FFI_DisplayCaret(FPDF_PAGE page, |
| 172 | FPDF_BOOL bVisible, |
| 173 | double left, |
| 174 | double top, |
| 175 | double right, |
| 176 | double bottom) { |
| 177 | if (m_pInfo && m_pInfo->FFI_DisplayCaret) |
| 178 | m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, |
| 179 | bottom); |
| 180 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 181 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 182 | int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) { |
Jun Fang | 01fe588 | 2015-11-25 11:05:58 +0800 | [diff] [blame] | 183 | if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) { |
| 184 | return -1; |
| 185 | } |
| 186 | return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 187 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 188 | |
Jun Fang | 01fe588 | 2015-11-25 11:05:58 +0800 | [diff] [blame] | 189 | void FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 190 | if (m_pInfo && m_pInfo->FFI_SetCurrentPage) |
| 191 | m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 192 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 193 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 194 | CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 195 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 196 | CFX_WideString FFI_GetPlatform() { |
| 197 | if (m_pInfo && m_pInfo->FFI_GetPlatform) { |
| 198 | int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0); |
| 199 | if (nRequiredLen <= 0) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 200 | return L""; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 201 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 202 | char* pbuff = new char[nRequiredLen]; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 203 | memset(pbuff, 0, nRequiredLen); |
| 204 | int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); |
| 205 | if (nActualLen <= 0 || nActualLen > nRequiredLen) { |
| 206 | delete[] pbuff; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 207 | return L""; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | } |
| 209 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 210 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
| 211 | (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), |
| 212 | bsRet.GetLength() / sizeof(unsigned short)); |
| 213 | delete[] pbuff; |
| 214 | return wsRet; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 215 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 216 | return L""; |
| 217 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 218 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 219 | void FFI_GotoURL(FPDF_DOCUMENT document, |
| 220 | const CFX_WideStringC& wsURL, |
| 221 | FX_BOOL bAppend) { |
| 222 | if (m_pInfo && m_pInfo->FFI_GotoURL) { |
| 223 | CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 224 | FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); |
| 225 | m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); |
| 226 | bsTo.ReleaseBuffer(); |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 227 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 228 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 229 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 230 | void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) { |
| 231 | wsURL = CFX_WideString(); |
| 232 | } |
| 233 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 234 | void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag) {} |
| 235 | |
| 236 | void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { |
| 237 | if (m_pInfo && m_pInfo->FFI_GetPageViewRect) { |
| 238 | double left; |
| 239 | double top; |
| 240 | double right; |
| 241 | double bottom; |
| 242 | m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); |
| 243 | |
| 244 | dstRect.left = static_cast<float>(left); |
| 245 | dstRect.top = static_cast<float>(top < bottom ? bottom : top); |
| 246 | dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); |
| 247 | dstRect.right = static_cast<float>(right); |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 248 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 250 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 251 | FX_BOOL FFI_PopupMenu(FPDF_PAGE page, |
| 252 | FPDF_WIDGET hWidget, |
| 253 | int menuFlag, |
| 254 | CFX_PointF ptPopup, |
| 255 | const CFX_PointF* pRectExclude) { |
| 256 | if (m_pInfo && m_pInfo->FFI_PopupMenu) |
| 257 | return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, |
| 258 | ptPopup.y); |
| 259 | return FALSE; |
| 260 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 261 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 262 | void FFI_Alert(FPDF_WIDESTRING Msg, |
| 263 | FPDF_WIDESTRING Title, |
| 264 | int Type, |
| 265 | int Icon) { |
| 266 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| 267 | m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, |
| 268 | Type, Icon); |
| 269 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 270 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 271 | void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, |
| 272 | FPDF_WIDESTRING pTo, |
| 273 | FPDF_WIDESTRING pSubject, |
| 274 | FPDF_WIDESTRING pCC, |
| 275 | FPDF_WIDESTRING pBcc, |
| 276 | FPDF_WIDESTRING pMsg) { |
| 277 | if (m_pInfo && m_pInfo->FFI_EmailTo) |
| 278 | m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, |
| 279 | pMsg); |
| 280 | } |
| 281 | |
| 282 | void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, |
| 283 | int fileFlag, |
| 284 | FPDF_WIDESTRING uploadTo) { |
| 285 | if (m_pInfo && m_pInfo->FFI_UploadTo) |
| 286 | m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); |
| 287 | } |
| 288 | |
| 289 | FPDF_FILEHANDLER* FFI_OpenFile(int fileType, |
| 290 | FPDF_WIDESTRING wsURL, |
| 291 | const char* mode) { |
| 292 | if (m_pInfo && m_pInfo->FFI_OpenFile) |
| 293 | return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); |
| 294 | return NULL; |
| 295 | } |
| 296 | |
| 297 | CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) const { |
| 298 | return L""; |
| 299 | } |
| 300 | |
| 301 | int FFI_GetDocumentCount() const { return 0; } |
| 302 | int FFI_GetCurDocument() const { return 0; } |
| 303 | |
| 304 | IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url) { |
| 305 | if (m_pInfo && m_pInfo->FFI_DownloadFromURL) { |
| 306 | CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); |
| 307 | FPDF_WIDESTRING wsURL = |
| 308 | (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); |
| 309 | |
| 310 | FPDF_LPFILEHANDLER fileHandler = |
| 311 | m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); |
| 312 | |
Lei Zhang | db5256f | 2015-10-02 10:11:43 -0700 | [diff] [blame] | 313 | return new CFPDF_FileStream(fileHandler); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 314 | } |
| 315 | return NULL; |
| 316 | } |
| 317 | |
| 318 | CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, |
| 319 | const FX_WCHAR* wsData, |
| 320 | const FX_WCHAR* wsContentType, |
| 321 | const FX_WCHAR* wsEncode, |
| 322 | const FX_WCHAR* wsHeader) { |
| 323 | if (m_pInfo && m_pInfo->FFI_PostRequestURL) { |
| 324 | CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 325 | FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 326 | |
| 327 | CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 328 | FPDF_WIDESTRING data = |
| 329 | (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 330 | |
| 331 | CFX_ByteString bsContentType = |
| 332 | CFX_WideString(wsContentType).UTF16LE_Encode(); |
| 333 | FPDF_WIDESTRING contentType = |
| 334 | (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength()); |
| 335 | |
| 336 | CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 337 | FPDF_WIDESTRING encode = |
| 338 | (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 339 | |
| 340 | CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode(); |
| 341 | FPDF_WIDESTRING header = |
| 342 | (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength()); |
| 343 | |
| 344 | FPDF_BSTR respone; |
| 345 | FPDF_BStr_Init(&respone); |
| 346 | m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, |
| 347 | header, &respone); |
| 348 | |
| 349 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
| 350 | (unsigned short*)respone.str, respone.len / sizeof(unsigned short)); |
| 351 | FPDF_BStr_Clear(&respone); |
| 352 | |
| 353 | return wsRet; |
| 354 | } |
| 355 | return L""; |
| 356 | } |
| 357 | |
| 358 | FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, |
| 359 | const FX_WCHAR* wsData, |
| 360 | const FX_WCHAR* wsEncode) { |
| 361 | if (m_pInfo && m_pInfo->FFI_PutRequestURL) { |
| 362 | CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 363 | FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 364 | |
| 365 | CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 366 | FPDF_WIDESTRING data = |
| 367 | (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 368 | |
| 369 | CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 370 | FPDF_WIDESTRING encode = |
| 371 | (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 372 | |
| 373 | return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); |
| 374 | } |
| 375 | return FALSE; |
| 376 | } |
| 377 | |
| 378 | FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, |
| 379 | const FX_WCHAR* wsFilter, |
| 380 | CFX_WideStringArray& wsPathArr, |
| 381 | FX_BOOL bOpen) { |
| 382 | return FALSE; |
| 383 | } |
| 384 | |
| 385 | CFX_WideString FFI_GetLanguage() { |
| 386 | if (m_pInfo && m_pInfo->FFI_GetLanguage) { |
| 387 | int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0); |
| 388 | if (nRequiredLen <= 0) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 389 | return L""; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 390 | |
| 391 | char* pbuff = new char[nRequiredLen]; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 392 | memset(pbuff, 0, nRequiredLen); |
| 393 | int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); |
| 394 | if (nActualLen <= 0 || nActualLen > nRequiredLen) { |
| 395 | delete[] pbuff; |
| 396 | return L""; |
| 397 | } |
| 398 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 399 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
| 400 | (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), |
| 401 | bsRet.GetLength() / sizeof(unsigned short)); |
| 402 | delete[] pbuff; |
| 403 | return wsRet; |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 404 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 405 | return L""; |
| 406 | } |
Jun Fang | c30d5bf | 2016-02-02 18:12:23 -0800 | [diff] [blame] | 407 | void FFI_PageEvent(int iPageIndex, int iEventType) const { |
| 408 | // Todo: call a call-back function when it's implemented |
| 409 | // in applicaiton's side. |
| 410 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 411 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 412 | |
Tom Sepez | 5702859 | 2016-02-01 15:49:11 -0800 | [diff] [blame] | 413 | int JS_appAlert(const FX_WCHAR* Msg, |
| 414 | const FX_WCHAR* Title, |
| 415 | FX_UINT Type, |
| 416 | FX_UINT Icon); |
| 417 | int JS_appResponse(const FX_WCHAR* Question, |
| 418 | const FX_WCHAR* Title, |
| 419 | const FX_WCHAR* Default, |
| 420 | const FX_WCHAR* cLabel, |
| 421 | FPDF_BOOL bPassword, |
| 422 | void* response, |
| 423 | int length); |
| 424 | void JS_appBeep(int nType); |
| 425 | CFX_WideString JS_fieldBrowse(); |
| 426 | CFX_WideString JS_docGetFilePath(); |
| 427 | void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL); |
| 428 | void JS_docmailForm(void* mailData, |
| 429 | int length, |
| 430 | FPDF_BOOL bUI, |
| 431 | const FX_WCHAR* To, |
| 432 | const FX_WCHAR* Subject, |
| 433 | const FX_WCHAR* CC, |
| 434 | const FX_WCHAR* BCC, |
| 435 | const FX_WCHAR* Msg); |
| 436 | void JS_docprint(FPDF_BOOL bUI, |
| 437 | int nStart, |
| 438 | int nEnd, |
| 439 | FPDF_BOOL bSilent, |
| 440 | FPDF_BOOL bShrinkToFit, |
| 441 | FPDF_BOOL bPrintAsImage, |
| 442 | FPDF_BOOL bReverse, |
| 443 | FPDF_BOOL bAnnotations); |
| 444 | void JS_docgotoPage(int nPageNum); |
| 445 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 446 | FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } |
| 447 | void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } |
| 448 | CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 449 | UnderlyingDocumentType* GetUnderlyingDocument() const { |
| 450 | return m_pUnderlyingDoc; |
| 451 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 452 | CFX_ByteString GetAppName() const { return ""; } |
Oliver Chang | 2475249 | 2015-10-30 16:08:20 -0700 | [diff] [blame] | 453 | IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 454 | FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 455 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 456 | CFFL_IFormFiller* GetIFormFiller(); // Creates if not present. |
| 457 | CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 458 | IJS_Runtime* GetJSRuntime(); // Creates if not present. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 459 | CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 460 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 461 | private: |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 462 | std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; |
| 463 | std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; |
| 464 | std::unique_ptr<IJS_Runtime> m_pJSRuntime; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 465 | FPDF_FORMFILLINFO* const m_pInfo; |
| 466 | CPDFSDK_Document* m_pSDKDoc; |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 467 | UnderlyingDocumentType* const m_pUnderlyingDoc; |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 468 | std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller; |
| 469 | std::unique_ptr<IFX_SystemHandler> m_pSysHandler; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 470 | }; |
| 471 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 472 | class CPDFSDK_Document { |
| 473 | public: |
Tom Sepez | fe351db | 2016-01-29 16:26:27 -0800 | [diff] [blame] | 474 | static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle); |
| 475 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 476 | CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 477 | ~CPDFSDK_Document(); |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 478 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 479 | CPDFSDK_InterForm* GetInterForm(); |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 480 | |
Tom Sepez | 5259ef3 | 2015-11-24 10:21:01 -0800 | [diff] [blame] | 481 | // Gets the document object for the next layer down; for master this is |
| 482 | // a CPDF_Document, but for XFA it is a CPDFXFA_Document. |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 483 | UnderlyingDocumentType* GetUnderlyingDocument() const { |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 484 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 485 | return GetXFADocument(); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 486 | #else // PDF_ENABLE_XFA |
| 487 | return GetPDFDocument(); |
| 488 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 489 | } |
Tom Sepez | 5259ef3 | 2015-11-24 10:21:01 -0800 | [diff] [blame] | 490 | |
| 491 | // Gets the CPDF_Document, either directly in master, or from the |
| 492 | // CPDFXFA_Document for XFA. |
Tom Sepez | bf59a07 | 2015-10-21 14:07:23 -0700 | [diff] [blame] | 493 | CPDF_Document* GetPDFDocument() const { |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 494 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | bf59a07 | 2015-10-21 14:07:23 -0700 | [diff] [blame] | 495 | return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 496 | #else // PDF_ENABLE_XFA |
| 497 | return m_pDoc; |
| 498 | #endif // PDF_ENABLE_XFA |
Tom Sepez | bf59a07 | 2015-10-21 14:07:23 -0700 | [diff] [blame] | 499 | } |
Tom Sepez | 5259ef3 | 2015-11-24 10:21:01 -0800 | [diff] [blame] | 500 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 501 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 5259ef3 | 2015-11-24 10:21:01 -0800 | [diff] [blame] | 502 | // Gets the XFA document directly (XFA-only). |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 503 | CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 504 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 505 | int GetPageViewCount() const { return m_pageMap.size(); } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 506 | #endif // PDF_ENABLE_XFA |
| 507 | |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 508 | CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 509 | FX_BOOL ReNew = TRUE); |
| 510 | CPDFSDK_PageView* GetPageView(int nIndex); |
| 511 | CPDFSDK_PageView* GetCurrentView(); |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 512 | void RemovePageView(UnderlyingPageType* pPage); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 513 | void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 514 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 515 | CPDFSDK_Annot* GetFocusAnnot(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 516 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 517 | IJS_Runtime* GetJsRuntime(); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 518 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 519 | FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); |
| 520 | FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 521 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 522 | FX_BOOL ExtractPages(const CFX_WordArray& arrExtraPages, |
| 523 | CPDF_Document* pDstDoc); |
| 524 | FX_BOOL InsertPages(int nInsertAt, |
| 525 | const CPDF_Document* pSrcDoc, |
| 526 | const CFX_WordArray& arrSrcPages); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 527 | FX_BOOL ReplacePages(int nPage, |
| 528 | const CPDF_Document* pSrcDoc, |
| 529 | const CFX_WordArray& arrSrcPages); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 530 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 531 | void OnCloseDocument(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 532 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 533 | int GetPageCount() { return m_pDoc->GetPageCount(); } |
| 534 | FX_BOOL GetPermissions(int nFlag); |
| 535 | FX_BOOL GetChangeMark() { return m_bChangeMask; } |
| 536 | void SetChangeMark() { m_bChangeMask = TRUE; } |
| 537 | void ClearChangeMark() { m_bChangeMask = FALSE; } |
| 538 | CFX_WideString GetPath(); |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 539 | UnderlyingPageType* GetPage(int nIndex); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 540 | CPDFDoc_Environment* GetEnv() { return m_pEnv; } |
| 541 | void ProcJavascriptFun(); |
| 542 | FX_BOOL ProcOpenAction(); |
| 543 | CPDF_OCContext* GetOCContext(); |
| 544 | |
| 545 | private: |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 546 | std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 547 | UnderlyingDocumentType* m_pDoc; |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 548 | std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 549 | CPDFSDK_Annot* m_pFocusAnnot; |
| 550 | CPDFDoc_Environment* m_pEnv; |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 551 | std::unique_ptr<CPDF_OCContext> m_pOccontent; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 552 | FX_BOOL m_bChangeMask; |
Oliver Chang | 972b78d | 2015-10-30 12:59:29 -0700 | [diff] [blame] | 553 | FX_BOOL m_bBeingDestroyed; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 554 | }; |
Tom Sepez | b9cc7a0 | 2016-02-01 13:42:30 -0800 | [diff] [blame] | 555 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 556 | class CPDFSDK_PageView final { |
| 557 | public: |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 558 | CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 559 | ~CPDFSDK_PageView(); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 560 | |
| 561 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 562 | void PageView_OnDraw(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 563 | CFX_Matrix* pUser2Device, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 564 | CPDF_RenderOptions* pOptions, |
Lei Zhang | f0e2e1b | 2015-11-02 13:27:54 -0800 | [diff] [blame] | 565 | const FX_RECT& pClip); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 566 | #else // PDF_ENABLE_XFA |
| 567 | void PageView_OnDraw(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 568 | CFX_Matrix* pUser2Device, |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 569 | CPDF_RenderOptions* pOptions); |
| 570 | #endif // PDF_ENABLE_XFA |
| 571 | |
Lei Zhang | 1b700c3 | 2015-10-30 23:55:35 -0700 | [diff] [blame] | 572 | const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 573 | CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
Lei Zhang | 1b700c3 | 2015-10-30 23:55:35 -0700 | [diff] [blame] | 574 | const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 575 | CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 576 | CPDFSDK_Annot* GetFocusAnnot(); |
| 577 | void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) { |
| 578 | m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag); |
| 579 | } |
| 580 | FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) { |
| 581 | return m_pSDKDoc->KillFocusAnnot(nFlag); |
| 582 | } |
Oliver Chang | 972b78d | 2015-10-30 12:59:29 -0700 | [diff] [blame] | 583 | void KillFocusAnnotIfNeeded(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 584 | FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 585 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 586 | CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); |
| 587 | CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); |
| 588 | CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 589 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 590 | FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); |
Lei Zhang | 5021853 | 2015-10-30 14:03:43 -0700 | [diff] [blame] | 591 | size_t CountAnnots() const; |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 592 | CPDFSDK_Annot* GetAnnot(size_t nIndex); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 593 | CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 594 | |
| 595 | #ifdef PDF_ENABLE_XFA |
| 596 | CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 597 | CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget); |
| 598 | CPDFXFA_Page* GetPDFXFAPage() { return m_page; } |
| 599 | CPDF_Page* GetPDFPage(); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 600 | #else |
| 601 | CPDF_Page* GetPDFPage() { return m_page; } |
| 602 | #endif // PDF_ENABLE_XFA |
| 603 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 604 | CPDF_Document* GetPDFDocument(); |
| 605 | CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } |
| 606 | FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_UINT nFlag); |
| 607 | FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag); |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 608 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 609 | FX_BOOL OnRButtonDown(const CPDF_Point& point, FX_UINT nFlag); |
| 610 | FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_UINT nFlag); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 611 | #endif // PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 612 | FX_BOOL OnChar(int nChar, FX_UINT nFlag); |
| 613 | FX_BOOL OnKeyDown(int nKeyCode, int nFlag); |
| 614 | FX_BOOL OnKeyUp(int nKeyCode, int nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 615 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 616 | FX_BOOL OnMouseMove(const CPDF_Point& point, int nFlag); |
| 617 | FX_BOOL OnMouseWheel(double deltaX, |
| 618 | double deltaY, |
| 619 | const CPDF_Point& point, |
| 620 | int nFlag); |
Lei Zhang | 1b700c3 | 2015-10-30 23:55:35 -0700 | [diff] [blame] | 621 | bool IsValidAnnot(const CPDF_Annot* p) const; |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 622 | void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 623 | void UpdateRects(CFX_RectArray& rects); |
| 624 | void UpdateView(CPDFSDK_Annot* pAnnot); |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 625 | const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { |
| 626 | return m_fxAnnotArray; |
| 627 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 628 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 629 | int GetPageIndex(); |
| 630 | void LoadFXAnnots(); |
Jun Fang | 7523954 | 2016-01-20 08:04:47 +0800 | [diff] [blame] | 631 | void ClearFXAnnots(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 632 | void SetValid(FX_BOOL bValid) { m_bValid = bValid; } |
| 633 | FX_BOOL IsValid() { return m_bValid; } |
| 634 | void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; } |
| 635 | FX_BOOL IsLocked() { return m_bLocked; } |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 636 | #ifndef PDF_ENABLE_XFA |
| 637 | void TakeOverPage() { m_bTakeOverPage = TRUE; } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 638 | #endif // PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 639 | |
| 640 | private: |
| 641 | void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, |
| 642 | CPDFSDK_Widget* pWidget); |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 643 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 644 | CFX_Matrix m_curMatrix; |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 645 | UnderlyingPageType* m_page; |
Lei Zhang | aa8bf7e | 2015-12-24 19:13:32 -0800 | [diff] [blame] | 646 | std::unique_ptr<CPDF_AnnotList> m_pAnnotList; |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 647 | std::vector<CPDFSDK_Annot*> m_fxAnnotArray; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 648 | CPDFSDK_Document* m_pSDKDoc; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 649 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 650 | CPDFSDK_Annot* m_CaptureWidget; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 651 | #else // PDF_ENABLE_XFA |
| 652 | CPDFSDK_Widget* m_CaptureWidget; |
| 653 | FX_BOOL m_bTakeOverPage; |
| 654 | #endif // PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 655 | FX_BOOL m_bEnterWidget; |
| 656 | FX_BOOL m_bExitWidget; |
| 657 | FX_BOOL m_bOnWidget; |
| 658 | FX_BOOL m_bValid; |
| 659 | FX_BOOL m_bLocked; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 660 | }; |
| 661 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 662 | #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ |