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