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