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