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 | |
Tom Sepez | 1ed8a21 | 2015-05-11 15:25:39 -0700 | [diff] [blame] | 10 | #include "../../public/fpdf_formfill.h" |
| 11 | #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] | 12 | #include "fsdk_common.h" |
| 13 | #include "fsdk_define.h" |
| 14 | #include "fx_systemhandler.h" |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 15 | #include "fpdfxfa/fpdfxfa_doc.h" |
| 16 | #include "fpdfxfa/fpdfxfa_page.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 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_annothandler.h" |
| 20 | #include "fsdk_actionhandler.h" |
| 21 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | class CPDFSDK_Document; |
| 23 | class CPDFSDK_PageView; |
| 24 | class CPDFSDK_Annot; |
| 25 | class CFFL_IFormFiller; |
| 26 | class CPDFSDK_Widget; |
| 27 | class IFX_SystemHandler; |
| 28 | class CPDFSDK_ActionHandler; |
| 29 | class CJS_RuntimeFactory; |
| 30 | |
| 31 | #include "javascript/IJavaScript.h" |
| 32 | |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 33 | class CPDFDoc_Environment final |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 34 | { |
| 35 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 36 | CPDFDoc_Environment(CPDFXFA_Document * pDoc); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | ~CPDFDoc_Environment(); |
| 38 | |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 39 | int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 40 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 41 | virtual void Release() |
| 42 | { |
| 43 | if (m_pInfo && m_pInfo->Release) |
| 44 | m_pInfo->Release(m_pInfo); |
| 45 | delete this; |
| 46 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 47 | void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 48 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 49 | if (m_pInfo && m_pInfo->FFI_Invalidate) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 50 | { |
| 51 | m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); |
| 52 | } |
| 53 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 54 | void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 55 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 56 | if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 57 | { |
| 58 | m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); |
| 59 | } |
| 60 | } |
| 61 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 62 | void FFI_SetCursor(int nCursorType) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 63 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 64 | if (m_pInfo && m_pInfo->FFI_SetCursor) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 65 | { |
| 66 | m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); |
| 67 | } |
| 68 | } |
| 69 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 70 | int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 71 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 72 | if (m_pInfo && m_pInfo->FFI_SetTimer) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 73 | { |
| 74 | return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); |
| 75 | } |
| 76 | return -1; |
| 77 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 78 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 79 | void FFI_KillTimer(int nTimerID) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 80 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 81 | if (m_pInfo && m_pInfo->FFI_KillTimer) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 82 | { |
| 83 | m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); |
| 84 | } |
| 85 | } |
| 86 | FX_SYSTEMTIME FFI_GetLocalTime() |
| 87 | { |
| 88 | FX_SYSTEMTIME fxtime; |
| 89 | if(m_pInfo && m_pInfo->FFI_GetLocalTime) |
| 90 | { |
| 91 | FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); |
| 92 | fxtime.wDay = systime.wDay; |
| 93 | fxtime.wDayOfWeek = systime.wDayOfWeek; |
| 94 | fxtime.wHour = systime.wHour; |
| 95 | fxtime.wMilliseconds = systime.wMilliseconds; |
| 96 | fxtime.wMinute = systime.wMinute; |
| 97 | fxtime.wMonth = systime.wMonth; |
| 98 | fxtime.wSecond = systime.wSecond; |
| 99 | fxtime.wYear = systime.wYear; |
| 100 | } |
| 101 | return fxtime; |
| 102 | } |
| 103 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 104 | void FFI_OnChange() |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 105 | { |
| 106 | if(m_pInfo && m_pInfo->FFI_OnChange) |
| 107 | { |
| 108 | m_pInfo->FFI_OnChange(m_pInfo); |
| 109 | } |
| 110 | } |
| 111 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 112 | FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 113 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 114 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 115 | return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; |
| 116 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 117 | FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 118 | { |
| 119 | |
| 120 | return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; |
| 121 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 122 | FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 123 | { |
| 124 | |
| 125 | return (nFlag & FWL_EVENTFLAG_AltKey) != 0; |
| 126 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 127 | FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 128 | { |
| 129 | return FALSE; |
| 130 | } |
| 131 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 132 | int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 133 | { |
| 134 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| 135 | { |
| 136 | CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| 137 | CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| 138 | FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| 139 | FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| 140 | int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon); |
| 141 | bsMsg.ReleaseBuffer(); |
| 142 | bsTitle.ReleaseBuffer(); |
| 143 | return ret; |
| 144 | } |
| 145 | return -1; |
| 146 | } |
| 147 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 148 | int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default, const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 149 | { |
| 150 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response) |
| 151 | { |
| 152 | CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); |
| 153 | CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| 154 | CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); |
| 155 | CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); |
| 156 | FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength()); |
| 157 | FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| 158 | FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength()); |
| 159 | FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength()); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 160 | int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle, |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 161 | pDefault, pLabel, bPassword, response, length); |
| 162 | bsQuestion.ReleaseBuffer(); |
| 163 | bsTitle.ReleaseBuffer(); |
| 164 | bsDefault.ReleaseBuffer(); |
| 165 | bsLabel.ReleaseBuffer(); |
| 166 | return ret; |
| 167 | } |
| 168 | return -1; |
| 169 | } |
| 170 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 171 | void JS_appBeep(int nType) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 172 | { |
| 173 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep) |
| 174 | { |
| 175 | m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); |
| 176 | } |
| 177 | } |
| 178 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 179 | CFX_WideString JS_fieldBrowse() |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 180 | { |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 181 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Field_browse) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 182 | { |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 183 | int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, NULL, 0); |
| 184 | if (nRequiredLen <= 0) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 185 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 186 | |
| 187 | char* pbuff = new char[nRequiredLen]; |
| 188 | if (!pbuff) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 189 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 190 | |
| 191 | memset(pbuff, 0, nRequiredLen); |
| 192 | int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, pbuff, nRequiredLen); |
| 193 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 194 | { |
| 195 | delete[] pbuff; |
| 196 | return L""; |
| 197 | } |
| 198 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 199 | CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 200 | delete[] pbuff; |
| 201 | return wsRet; |
| 202 | } |
| 203 | return L""; |
| 204 | } |
| 205 | |
| 206 | CFX_WideString JS_docGetFilePath() |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 207 | { |
| 208 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_getFilePath) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 209 | { |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 210 | int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, NULL, 0); |
| 211 | if (nRequiredLen <= 0) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 212 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 213 | |
| 214 | char* pbuff = new char[nRequiredLen]; |
| 215 | if (!pbuff) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 216 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 217 | |
| 218 | memset(pbuff, 0, nRequiredLen); |
| 219 | int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, pbuff, nRequiredLen); |
| 220 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 221 | { |
| 222 | delete[] pbuff; |
| 223 | return L""; |
| 224 | } |
| 225 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 226 | CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 227 | delete[] pbuff; |
| 228 | return wsRet; |
| 229 | } |
| 230 | return L""; |
| 231 | } |
| 232 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 233 | void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 234 | { |
| 235 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm) |
| 236 | { |
| 237 | CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); |
| 238 | FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength()); |
| 239 | m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination); |
| 240 | bsDestination.ReleaseBuffer(); |
| 241 | } |
| 242 | } |
| 243 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 244 | void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,const FX_WCHAR* To, const FX_WCHAR* Subject, const FX_WCHAR* CC, const FX_WCHAR* BCC, const FX_WCHAR* Msg) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 245 | { |
| 246 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail) |
| 247 | { |
| 248 | CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); |
| 249 | CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode(); |
| 250 | CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); |
| 251 | CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); |
| 252 | CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| 253 | FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
| 254 | FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
| 255 | FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
| 256 | FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
| 257 | FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| 258 | m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject, |
| 259 | pCC, pBcc, pMsg); |
| 260 | bsTo.ReleaseBuffer(); |
| 261 | bsCC.ReleaseBuffer(); |
| 262 | bsBcc.ReleaseBuffer(); |
| 263 | bsSubject.ReleaseBuffer(); |
| 264 | bsMsg.ReleaseBuffer(); |
| 265 | } |
| 266 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 267 | |
| 268 | void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations) |
| 269 | { |
| 270 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print) |
| 271 | { |
| 272 | m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); |
| 273 | } |
| 274 | } |
| 275 | void JS_docgotoPage(int nPageNum) |
| 276 | { |
| 277 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage) |
| 278 | { |
| 279 | m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); |
| 280 | } |
| 281 | } |
| 282 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 283 | FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 284 | { |
| 285 | if(m_pInfo && m_pInfo->FFI_GetPage) |
| 286 | { |
| 287 | return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); |
| 288 | } |
| 289 | return NULL; |
| 290 | } |
| 291 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 292 | FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 293 | { |
| 294 | if(m_pInfo && m_pInfo->FFI_GetCurrentPage) |
| 295 | { |
| 296 | return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); |
| 297 | } |
| 298 | return NULL; |
| 299 | } |
| 300 | |
| 301 | int FFI_GetRotation(FPDF_PAGE page) |
| 302 | { |
| 303 | if(m_pInfo && m_pInfo->FFI_GetRotation) |
| 304 | { |
| 305 | return m_pInfo->FFI_GetRotation(m_pInfo, page); |
| 306 | } |
| 307 | return 0; |
| 308 | } |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 309 | void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 310 | { |
| 311 | if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction) |
| 312 | { |
| 313 | m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); |
| 314 | } |
| 315 | } |
| 316 | void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus) |
| 317 | { |
| 318 | if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus) |
| 319 | { |
| 320 | m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); |
| 321 | } |
| 322 | } |
| 323 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 324 | void FFI_DoURIAction(const FX_CHAR* bsURI) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 325 | { |
| 326 | if(m_pInfo && m_pInfo->FFI_DoURIAction) |
| 327 | { |
| 328 | m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray) |
| 333 | { |
| 334 | if(m_pInfo && m_pInfo->FFI_DoGoToAction) |
| 335 | { |
| 336 | m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray); |
| 337 | } |
| 338 | } |
| 339 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 340 | void FFI_DisplayCaret(FPDF_PAGE page, FPDF_BOOL bVisible, double left, double top, double right, double bottom) |
| 341 | { |
| 342 | if (m_pInfo && m_pInfo->FFI_DisplayCaret) |
| 343 | { |
| 344 | m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, bottom); |
| 345 | } |
| 346 | } |
| 347 | int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) |
| 348 | { |
| 349 | if (m_pInfo && m_pInfo->FFI_GetCurrentPageIndex) |
| 350 | { |
| 351 | m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); |
| 352 | } |
| 353 | return -1; |
| 354 | } |
| 355 | int FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) |
| 356 | { |
| 357 | if (m_pInfo && m_pInfo->FFI_SetCurrentPage) |
| 358 | { |
| 359 | m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); |
| 360 | } |
| 361 | return -1; |
| 362 | } |
| 363 | |
| 364 | CFX_WideString FFI_GetAppName() |
| 365 | { |
| 366 | return CFX_WideString(L"Acrobat"); |
| 367 | |
| 368 | //if (m_pInfo && m_pInfo->FFI_GetAppName) |
| 369 | //{ |
| 370 | // int nLen = m_pInfo->FFI_GetAppName(m_pInfo, NULL, 0); |
| 371 | // if(nLen <= 0) |
| 372 | // return L""; |
| 373 | // char* pbuff = new char[nLen]; |
| 374 | // if(pbuff) |
| 375 | // memset(pbuff, 0, nLen); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 376 | // else |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 377 | // return L""; |
| 378 | // nLen = m_pInfo->FFI_GetAppName(m_pInfo, pbuff, nLen); |
| 379 | // CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); |
| 380 | // CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 381 | // delete[] pbuff; |
| 382 | // return wsRet; |
| 383 | //} |
| 384 | |
| 385 | //return L""; |
| 386 | } |
| 387 | |
| 388 | CFX_WideString FFI_GetPlatform() |
| 389 | { |
| 390 | if (m_pInfo && m_pInfo->FFI_GetPlatform) |
| 391 | { |
| 392 | int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0); |
| 393 | if (nRequiredLen <= 0) |
| 394 | return L""; |
| 395 | |
| 396 | char* pbuff = new char[nRequiredLen]; |
| 397 | if (!pbuff) |
| 398 | return L""; |
| 399 | |
| 400 | memset(pbuff, 0, nRequiredLen); |
| 401 | int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); |
| 402 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 403 | { |
| 404 | delete[] pbuff; |
| 405 | return L""; |
| 406 | } |
| 407 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 408 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short)); |
| 409 | delete[] pbuff; |
| 410 | return wsRet; |
| 411 | } |
| 412 | return L""; |
| 413 | } |
| 414 | |
Tom Sepez | ca3ac5e | 2015-06-10 17:38:11 -0700 | [diff] [blame^] | 415 | void FFI_GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL, FX_BOOL bAppend) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 416 | { |
| 417 | if (m_pInfo && m_pInfo->FFI_GotoURL) |
| 418 | { |
| 419 | CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 420 | FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); |
| 421 | m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); |
| 422 | bsTo.ReleaseBuffer(); |
| 423 | } |
| 424 | } |
| 425 | void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) |
| 426 | { |
| 427 | wsURL = CFX_WideString(); |
| 428 | return; |
| 429 | //if (m_pInfo && m_pInfo->FFI_GetURL) |
| 430 | //{ |
| 431 | // FPDF_WIDESTRING url = m_pInfo->FFI_GetURL(m_pInfo, document); |
| 432 | // CFX_WideString tmp; |
| 433 | // tmp.FromUTF16LE(url); |
| 434 | // wsURL = tmp; |
| 435 | //} |
| 436 | } |
| 437 | |
| 438 | void FFI_AddDoRecord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) |
| 439 | { |
| 440 | //if (m_pInfo && m_pInfo->FFI_AddDoRecord) |
| 441 | //{ |
| 442 | // m_pInfo->FFI_AddDoRecord(m_pInfo, document, hWidget); |
| 443 | //} |
| 444 | } |
| 445 | void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag) |
| 446 | { |
| 447 | //if (m_pInfo && m_pInfo->FFI_PageEvent) |
| 448 | //{ |
| 449 | // m_pInfo->FFI_PageEvent(m_pInfo, page, flag); |
| 450 | //} |
| 451 | } |
| 452 | |
| 453 | void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) |
| 454 | { |
| 455 | if (m_pInfo && m_pInfo->FFI_GetPageViewRect) |
| 456 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 457 | double left; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 458 | double top; |
| 459 | double right; |
| 460 | double bottom; |
| 461 | m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); |
| 462 | |
Bruce Dawson | 3f49aa3 | 2015-01-08 11:47:49 -0800 | [diff] [blame] | 463 | dstRect.left = static_cast<float>(left); |
| 464 | dstRect.top = static_cast<float>(top < bottom ? bottom : top); |
| 465 | dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); |
| 466 | dstRect.right = static_cast<float>(right); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 467 | } |
| 468 | } |
| 469 | |
| 470 | |
| 471 | FX_BOOL FFI_PopupMenu(FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, CFX_PointF ptPopup, const CFX_PointF* pRectExclude) |
| 472 | { |
| 473 | if (m_pInfo && m_pInfo->FFI_PopupMenu) |
| 474 | { |
| 475 | return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, ptPopup.y); |
| 476 | } |
| 477 | return FALSE; |
| 478 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 479 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 480 | void FFI_Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon) |
| 481 | { |
| 482 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| 483 | { |
| 484 | m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type, Icon); |
| 485 | } |
| 486 | } |
| 487 | void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC, FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg) |
| 488 | { |
| 489 | if(m_pInfo && m_pInfo->FFI_EmailTo) |
| 490 | { |
| 491 | m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
| 492 | } |
| 493 | } |
| 494 | void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo) |
| 495 | { |
| 496 | if(m_pInfo && m_pInfo->FFI_UploadTo) |
| 497 | { |
| 498 | m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); |
| 499 | } |
| 500 | } |
| 501 | FPDF_FILEHANDLER* FFI_OpenFile(int fileType, FPDF_WIDESTRING wsURL, const char* mode) |
| 502 | { |
| 503 | if(m_pInfo && m_pInfo->FFI_OpenFile) |
| 504 | { |
| 505 | return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); |
| 506 | } |
| 507 | return NULL; |
| 508 | } |
| 509 | CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) |
| 510 | { |
| 511 | #if 0 |
| 512 | if (m_pInfo && m_pInfo->FFI_GetFilePath) |
| 513 | { |
| 514 | int nRequiredLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, NULL, 0); |
| 515 | if (nRequiredLen <= 0) |
| 516 | return L""; |
| 517 | |
| 518 | char* pbuff = new char[nRequiredLen]; |
| 519 | if (!pbuff) |
| 520 | return L""; |
| 521 | |
| 522 | memset(pbuff, 0, nRequiredLen); |
| 523 | int nActualLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, pbuff, nRequiredLen); |
| 524 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 525 | { |
| 526 | delete[] pbuff; |
| 527 | return L""; |
| 528 | } |
| 529 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 530 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short)); |
| 531 | delete[] pbuff; |
| 532 | return wsRet; |
| 533 | } |
| 534 | return L""; |
| 535 | #else |
| 536 | return L""; |
| 537 | #endif |
| 538 | } |
| 539 | int FFI_GetDocumentCount() |
| 540 | { |
| 541 | //if (m_pInfo && m_pInfo->FFI_GetDocumentCount) |
| 542 | //{ |
| 543 | //return m_pInfo->FFI_GetDocumentCount(m_pInfo); |
| 544 | //} |
| 545 | return 0; |
| 546 | } |
| 547 | |
| 548 | int FFI_GetCurDocument() |
| 549 | { |
| 550 | //if (m_pInfo && m_pInfo->FFI_GetCurDocumentIndex) |
| 551 | //{ |
| 552 | // return m_pInfo->FFI_GetCurDocumentIndex(m_pInfo); |
| 553 | //} |
| 554 | return 0; |
| 555 | } |
| 556 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 557 | IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 558 | { |
| 559 | if (m_pInfo && m_pInfo->FFI_DownloadFromURL) |
| 560 | { |
| 561 | CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); |
| 562 | FPDF_WIDESTRING wsURL = (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); |
| 563 | |
| 564 | FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); |
| 565 | |
| 566 | CFPDF_FileStream* fileStream = FX_NEW CFPDF_FileStream(fileHandler); |
| 567 | return fileStream; |
| 568 | } |
| 569 | return NULL; |
| 570 | } |
| 571 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 572 | CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsContentType, const FX_WCHAR* wsEncode, const FX_WCHAR* wsHeader) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 573 | { |
| 574 | if (m_pInfo && m_pInfo->FFI_PostRequestURL) |
| 575 | { |
| 576 | CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 577 | FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 578 | |
| 579 | CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 580 | FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 581 | |
| 582 | CFX_ByteString bsContentType = CFX_WideString(wsContentType).UTF16LE_Encode(); |
| 583 | FPDF_WIDESTRING contentType = (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength()); |
| 584 | |
| 585 | CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 586 | FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 587 | |
| 588 | CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode(); |
| 589 | FPDF_WIDESTRING header = (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength()); |
| 590 | |
| 591 | FPDF_BSTR respone; |
| 592 | FPDF_BStr_Init(&respone); |
| 593 | FPDF_BOOL bRet = m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, &respone); |
| 594 | |
| 595 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)respone.str, respone.len/sizeof(unsigned short)); |
| 596 | FPDF_BStr_Clear(&respone); |
| 597 | |
| 598 | return wsRet; |
| 599 | } |
| 600 | return L""; |
| 601 | } |
| 602 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 603 | FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsEncode) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 604 | { |
| 605 | if (m_pInfo && m_pInfo->FFI_PutRequestURL) |
| 606 | { |
| 607 | CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 608 | FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 609 | |
| 610 | CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 611 | FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 612 | |
| 613 | CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 614 | FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 615 | |
| 616 | return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); |
| 617 | } |
| 618 | return FALSE; |
| 619 | } |
| 620 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 621 | FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, const FX_WCHAR* wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 622 | { |
| 623 | /*CFX_ByteString bsTitle = CFX_WideString(wsTitle).UTF16LE_Encode(); |
| 624 | FPDF_WIDESTRING title = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| 625 | |
| 626 | CFX_ByteString bsFilter = CFX_WideString(wsFilter).UTF16LE_Encode(); |
| 627 | FPDF_WIDESTRING filter = (FPDF_WIDESTRING)bsFilter.GetBuffer(bsFilter.GetLength()); |
| 628 | |
| 629 | CFX_ByteStringArray* strPathArr = FX_NEW CFX_ByteStringArray(); |
| 630 | if (m_pInfo && m_pInfo->FFI_ShowFileDialog) |
| 631 | { |
| 632 | FPDF_BOOL bRet = m_pInfo->FFI_ShowFileDialog(m_pInfo, title, filter, bOpen, (FPDF_STRINGHANDLE)strPathArr); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 633 | if (bRet) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 634 | { |
| 635 | int count = strPathArr->GetSize(); |
| 636 | for (int i=0; i<count; i++) |
| 637 | { |
| 638 | CFX_ByteString bsPath = *strPathArr->GetDataPtr(i); |
| 639 | CFX_WideString wsPath = CFX_WideString::FromUTF16LE((unsigned short*)bsPath.GetBuffer(bsPath.GetLength()), bsPath.GetLength()/sizeof(unsigned short)); |
| 640 | if (!wsPath.IsEmpty()) |
| 641 | wsPathArr.Add(wsPath); |
| 642 | wsPath = L""; |
| 643 | } |
| 644 | return TRUE; |
| 645 | } |
| 646 | |
| 647 | return FALSE; |
| 648 | } |
| 649 | */ |
| 650 | |
| 651 | return FALSE; |
| 652 | } |
| 653 | CFX_WideString FFI_GetLanguage() |
| 654 | { |
| 655 | if (m_pInfo && m_pInfo->FFI_GetLanguage) |
| 656 | { |
| 657 | int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0); |
| 658 | if (nRequiredLen <= 0) |
| 659 | return L""; |
| 660 | |
| 661 | char* pbuff = new char[nRequiredLen]; |
| 662 | if (!pbuff) |
| 663 | return L""; |
| 664 | |
| 665 | memset(pbuff, 0, nRequiredLen); |
| 666 | int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); |
| 667 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 668 | { |
| 669 | delete[] pbuff; |
| 670 | return L""; |
| 671 | } |
| 672 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 673 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short)); |
| 674 | delete[] pbuff; |
| 675 | return wsRet; |
| 676 | } |
| 677 | return L""; |
| 678 | } |
| 679 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 680 | FX_BOOL IsJSInitiated(); |
| 681 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 682 | void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;} |
| 683 | CPDFSDK_Document* GetCurrentDoc(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 684 | CPDFXFA_Document* GetPDFXFADocument() {return m_pDoc;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 685 | |
| 686 | CFX_ByteString GetAppName() {return "";} |
| 687 | |
| 688 | CFFL_IFormFiller* GetIFormFiller(); |
| 689 | IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;} |
| 690 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 691 | CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); |
| 692 | IFXJS_Runtime* GetJSRuntime(); |
| 693 | CPDFSDK_ActionHandler* GetActionHander(); |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 694 | FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;} |
| 695 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 696 | private: |
| 697 | CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; |
| 698 | CPDFSDK_ActionHandler* m_pActionHandler; |
| 699 | IFXJS_Runtime* m_pJSRuntime; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 700 | FPDF_FORMFILLINFO* m_pInfo; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 701 | CPDFSDK_Document* m_pSDKDoc; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 702 | CPDFXFA_Document* m_pDoc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 703 | |
| 704 | CFFL_IFormFiller* m_pIFormFiller; |
| 705 | IFX_SystemHandler* m_pSysHandler; |
| 706 | |
| 707 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 708 | //CJS_RuntimeFactory* m_pJSRuntimeFactory; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 709 | }; |
| 710 | |
| 711 | |
| 712 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 713 | class CPDFSDK_InterForm; |
| 714 | class CPDFSDK_Document |
| 715 | { |
| 716 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 717 | CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 718 | ~CPDFSDK_Document(); |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 719 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 720 | CPDFSDK_InterForm* GetInterForm() ; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 721 | CPDFXFA_Document* GetDocument() {return m_pDoc;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 722 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 723 | void InitPageView(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 724 | int GetPageViewCount(){return m_pageMap.GetCount();} |
| 725 | void AddPageView(CPDFXFA_Page* pPDFXFAPage, CPDFSDK_PageView* pPageView); |
| 726 | CPDFSDK_PageView* GetPageView(CPDFXFA_Page* pPDFXFAPage, FX_BOOL ReNew = TRUE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 727 | CPDFSDK_PageView* GetPageView(int nIndex); |
| 728 | CPDFSDK_PageView* GetCurrentView(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 729 | void ReMovePageView(CPDFXFA_Page* pPDFPage); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 730 | void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); |
| 731 | |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 732 | CPDFSDK_Annot* GetFocusAnnot(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 733 | |
| 734 | IFXJS_Runtime * GetJsRuntime(); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 735 | |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 736 | FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 737 | FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); |
| 738 | |
| 739 | FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc); |
| 740 | FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); |
| 741 | FX_BOOL DeletePages(int nStart, int nCount); |
| 742 | FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); |
| 743 | |
| 744 | void OnCloseDocument(); |
| 745 | |
| 746 | int GetPageCount() {return m_pDoc->GetPageCount();} |
| 747 | FX_BOOL GetPermissions(int nFlag); |
| 748 | FX_BOOL GetChangeMark() {return m_bChangeMask;} |
| 749 | void SetChangeMark() {m_bChangeMask = TRUE;} |
| 750 | void ClearChangeMark() {m_bChangeMask= FALSE;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 751 | CFX_WideString GetPath() ; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 752 | CPDFXFA_Page* GetPage(int nIndex); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 753 | CPDFDoc_Environment * GetEnv() {return m_pEnv; } |
| 754 | void ProcJavascriptFun(); |
| 755 | FX_BOOL ProcOpenAction(); |
| 756 | CPDF_OCContext* GetOCContext(); |
| 757 | private: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 758 | CFX_MapPtrTemplate<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap; |
| 759 | CPDFXFA_Document* m_pDoc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 760 | CPDFSDK_InterForm* m_pInterForm; |
| 761 | CPDFSDK_Annot* m_pFocusAnnot; |
| 762 | CPDFDoc_Environment * m_pEnv; |
| 763 | CPDF_OCContext * m_pOccontent; |
| 764 | FX_BOOL m_bChangeMask; |
| 765 | }; |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 766 | class CPDFSDK_PageView final |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 767 | { |
| 768 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 769 | CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 770 | ~CPDFSDK_PageView(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 771 | void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions, FX_RECT* pClip = NULL) ; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 772 | CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 773 | CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 774 | CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 775 | CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 776 | CPDFSDK_Annot* GetFocusAnnot() ; |
| 777 | void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);} |
| 778 | FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);} |
| 779 | FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); |
| 780 | |
| 781 | CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 782 | CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 783 | CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot); |
Tom Sepez | eed467d | 2015-06-02 10:35:27 -0700 | [diff] [blame] | 784 | CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 785 | FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); |
| 786 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 787 | int CountAnnots(); |
| 788 | CPDFSDK_Annot* GetAnnot(int nIndex); |
| 789 | CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict); |
Tom Sepez | eed467d | 2015-06-02 10:35:27 -0700 | [diff] [blame] | 790 | CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 791 | CPDFXFA_Page* GetPDFXFAPage(){return m_page;} |
| 792 | CPDF_Page* GetPDFPage(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 793 | CPDF_Document* GetPDFDocument(); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 794 | CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;} |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 795 | FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag); |
| 796 | FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 797 | FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_UINT nFlag); |
| 798 | FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_UINT nFlag); |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 799 | FX_BOOL OnChar(int nChar, FX_UINT nFlag); |
| 800 | FX_BOOL OnKeyDown(int nKeyCode, int nFlag); |
| 801 | FX_BOOL OnKeyUp(int nKeyCode, int nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 802 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 803 | FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag); |
| 804 | FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 805 | FX_BOOL IsValidAnnot(void* p); |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 806 | void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;} |
| 807 | void UpdateRects(CFX_RectArray& rects); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 808 | void UpdateView(CPDFSDK_Annot* pAnnot); |
| 809 | CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; } |
| 810 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 811 | int GetPageIndex(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 812 | void LoadFXAnnots(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 813 | void SetValid(FX_BOOL bValid) {m_bValid = bValid;} |
| 814 | FX_BOOL IsValid() {return m_bValid;} |
| 815 | void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;} |
| 816 | FX_BOOL IsLocked() {return m_bLocked;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 817 | private: |
| 818 | void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 819 | CPDF_Matrix m_curMatrix; |
| 820 | CPDFXFA_Page* m_page; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 821 | CPDF_AnnotList* m_pAnnotList; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 822 | //CPDFSDK_Annot* m_pFocusAnnot; |
| 823 | CFX_PtrArray m_fxAnnotArray; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 824 | CPDFSDK_Document* m_pSDKDoc; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 825 | CPDFSDK_Annot* m_CaptureWidget; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 826 | FX_BOOL m_bEnterWidget; |
| 827 | FX_BOOL m_bExitWidget; |
| 828 | FX_BOOL m_bOnWidget; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 829 | FX_BOOL m_bValid; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 830 | FX_BOOL m_bLocked; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 831 | }; |
| 832 | |
| 833 | |
| 834 | template<class TYPE> |
| 835 | class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> |
| 836 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 837 | public: |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 838 | CGW_ArrayTemplate(){} |
| 839 | virtual ~CGW_ArrayTemplate(){} |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 840 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 841 | typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 842 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 843 | void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) |
| 844 | { |
| 845 | int nSize = this->GetSize(); |
| 846 | QuickSort(0, nSize -1, bAscent, pCompare); |
| 847 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 848 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 849 | private: |
| 850 | void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare) |
| 851 | { |
| 852 | if (nStartPos >= nStopPos) return; |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 853 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 854 | if ((nStopPos - nStartPos) == 1) |
| 855 | { |
| 856 | TYPE Value1 = this->GetAt(nStartPos); |
| 857 | TYPE Value2 = this->GetAt(nStopPos); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 858 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 859 | int iGreate = (*pCompare)(Value1, Value2); |
| 860 | if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) |
| 861 | { |
| 862 | this->SetAt(nStartPos, Value2); |
| 863 | this->SetAt(nStopPos, Value1); |
| 864 | } |
| 865 | return; |
| 866 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 867 | |
Bo Xu | 9a52eb0 | 2014-06-24 11:37:49 -0700 | [diff] [blame] | 868 | FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 869 | FX_UINT i = nStartPos; |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 870 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 871 | TYPE Value = this->GetAt(m); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 872 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 873 | while (i < m) |
| 874 | { |
| 875 | TYPE temp = this->GetAt(i); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 876 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 877 | int iGreate = (*pCompare)(temp, Value); |
| 878 | if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) |
| 879 | { |
| 880 | this->InsertAt(m+1, temp); |
| 881 | this->RemoveAt(i); |
| 882 | m--; |
| 883 | } |
| 884 | else |
| 885 | { |
| 886 | i++; |
| 887 | } |
| 888 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 889 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 890 | FX_UINT j = nStopPos; |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 891 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 892 | while (j > m) |
| 893 | { |
| 894 | TYPE temp = this->GetAt(j); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 895 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 896 | int iGreate = (*pCompare)(temp, Value); |
| 897 | if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) |
| 898 | { |
| 899 | this->RemoveAt(j); |
| 900 | this->InsertAt(m, temp); |
| 901 | m++; |
| 902 | } |
| 903 | else |
| 904 | { |
| 905 | j--; |
| 906 | } |
| 907 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 908 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 909 | if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); |
| 910 | if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); |
| 911 | } |
| 912 | }; |
| 913 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 914 | #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ |