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 | 7b5bc26 | 2015-03-05 16:44:22 -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 | |
| 7 | #include "../include/fsdk_define.h" |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 8 | #include "../include/fpdfxfa/fpdfxfa_doc.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | #include "../include/fsdk_mgr.h" |
| 10 | #include "../include/fsdk_actionhandler.h" |
| 11 | #include "../include/javascript/IJavaScript.h" |
| 12 | |
| 13 | /* -------------------------- CBA_ActionHandler -------------------------- */ |
| 14 | |
Tom Sepez | 2c28619 | 2015-06-18 12:47:11 -0700 | [diff] [blame] | 15 | CPDFSDK_ActionHandler::CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi) |
| 16 | : m_pFormActionHandler(new CPDFSDK_FormActionHandler), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 17 | m_pMediaActionHandler(NULL) {} |
| 18 | |
| 19 | void CPDFSDK_ActionHandler::SetMediaActionHandler( |
| 20 | CPDFSDK_MediaActionHandler* pHandler) { |
| 21 | ASSERT(pHandler != NULL); |
| 22 | ASSERT(m_pMediaActionHandler == NULL); |
| 23 | m_pMediaActionHandler = pHandler; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 26 | // document open |
| 27 | FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, |
| 28 | CPDFSDK_Document* pDocument) { |
| 29 | CFX_PtrList list; |
| 30 | return ExecuteDocumentOpenAction(action, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | // document open |
| 34 | FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( |
| 35 | const CPDF_Action& JsAction, |
| 36 | CFX_WideString csJSName, |
| 37 | CPDFSDK_Document* pDocument) { |
| 38 | if (JsAction.GetType() == CPDF_Action::JavaScript) { |
| 39 | CFX_WideString swJS = JsAction.GetJavaScript(); |
| 40 | if (!swJS.IsEmpty()) { |
| 41 | RunDocumentOpenJavaScript(pDocument, csJSName, swJS); |
| 42 | return TRUE; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript( |
| 50 | const CPDF_Action& JsAction, |
| 51 | CPDF_AAction::AActionType type, |
| 52 | CPDFSDK_Document* pDocument, |
| 53 | CPDF_FormField* pFormField, |
| 54 | PDFSDK_FieldAction& data) { |
| 55 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 56 | ASSERT(pEnv); |
| 57 | if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript) { |
| 58 | CFX_WideString swJS = JsAction.GetJavaScript(); |
| 59 | if (!swJS.IsEmpty()) { |
| 60 | RunFieldJavaScript(pDocument, pFormField, type, data, swJS); |
| 61 | return TRUE; |
| 62 | } |
| 63 | } |
| 64 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 67 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Page( |
| 68 | const CPDF_Action& action, |
| 69 | enum CPDF_AAction::AActionType eType, |
| 70 | CPDFSDK_Document* pDocument) { |
| 71 | CFX_PtrList list; |
| 72 | return ExecuteDocumentPageAction(action, eType, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 75 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Document( |
| 76 | const CPDF_Action& action, |
| 77 | enum CPDF_AAction::AActionType eType, |
| 78 | CPDFSDK_Document* pDocument) { |
| 79 | CFX_PtrList list; |
| 80 | return ExecuteDocumentPageAction(action, eType, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 83 | FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark, |
| 84 | const CPDF_Action& action, |
| 85 | CPDF_AAction::AActionType type, |
| 86 | CPDFSDK_Document* pDocument) { |
| 87 | CFX_PtrList list; |
| 88 | return ExecuteBookMark(action, pDocument, pBookMark, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 91 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, |
| 92 | CPDF_AAction::AActionType type, |
| 93 | CPDFSDK_Document* pDocument, |
| 94 | CPDFSDK_Annot* pScreen) { |
| 95 | CFX_PtrList list; |
| 96 | return ExecuteScreenAction(action, type, pDocument, pScreen, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 99 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action, |
| 100 | CPDFSDK_Document* pDocument) { |
| 101 | CFX_PtrList list; |
| 102 | return ExecuteLinkAction(action, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 105 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, |
| 106 | CPDF_AAction::AActionType type, |
| 107 | CPDFSDK_Document* pDocument, |
| 108 | CPDF_FormField* pFormField, |
| 109 | PDFSDK_FieldAction& data) { |
| 110 | CFX_PtrList list; |
| 111 | return ExecuteFieldAction(action, type, pDocument, pFormField, data, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 114 | FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( |
| 115 | const CPDF_Action& action, |
| 116 | CPDFSDK_Document* pDocument, |
| 117 | CFX_PtrList& list) { |
| 118 | CPDF_Dictionary* pDict = action.GetDict(); |
| 119 | if (list.Find(pDict)) |
| 120 | return FALSE; |
| 121 | |
| 122 | list.AddTail(pDict); |
| 123 | |
| 124 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 125 | ASSERT(pEnv); |
| 126 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 127 | if (pEnv->IsJSInitiated()) { |
| 128 | CFX_WideString swJS = action.GetJavaScript(); |
| 129 | if (!swJS.IsEmpty()) { |
| 130 | RunDocumentOpenJavaScript(pDocument, L"", swJS); |
| 131 | } |
| 132 | } |
| 133 | } else { |
| 134 | DoAction_NoJs(action, pDocument); |
| 135 | } |
| 136 | |
| 137 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 138 | CPDF_Action subaction = action.GetSubAction(i); |
| 139 | if (!ExecuteDocumentOpenAction(subaction, pDocument, list)) |
| 140 | return FALSE; |
| 141 | } |
| 142 | |
| 143 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 146 | FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action, |
| 147 | CPDFSDK_Document* pDocument, |
| 148 | CFX_PtrList& list) { |
| 149 | ASSERT(pDocument != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 150 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 151 | CPDF_Dictionary* pDict = action.GetDict(); |
| 152 | if (list.Find(pDict)) |
| 153 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 154 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 155 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 156 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 157 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 158 | ASSERT(pEnv); |
| 159 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 160 | if (pEnv->IsJSInitiated()) { |
| 161 | CFX_WideString swJS = action.GetJavaScript(); |
| 162 | if (!swJS.IsEmpty()) { |
| 163 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? |
| 164 | ASSERT(pRuntime != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 165 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 166 | pRuntime->SetReaderDocument(pDocument); |
| 167 | |
| 168 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 169 | ASSERT(pContext != NULL); |
| 170 | |
| 171 | pContext->OnLink_MouseUp(pDocument); |
| 172 | |
| 173 | CFX_WideString csInfo; |
| 174 | FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
| 175 | if (!bRet) { |
| 176 | // FIXME: return error. |
| 177 | } |
| 178 | |
| 179 | pRuntime->ReleaseContext(pContext); |
| 180 | } |
| 181 | } |
| 182 | } else { |
| 183 | DoAction_NoJs(action, pDocument); |
| 184 | } |
| 185 | |
| 186 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 187 | CPDF_Action subaction = action.GetSubAction(i); |
| 188 | if (!ExecuteLinkAction(subaction, pDocument, list)) |
| 189 | return FALSE; |
| 190 | } |
| 191 | |
| 192 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 195 | FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( |
| 196 | const CPDF_Action& action, |
| 197 | CPDF_AAction::AActionType type, |
| 198 | CPDFSDK_Document* pDocument, |
| 199 | CFX_PtrList& list) { |
| 200 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 201 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 202 | CPDF_Dictionary* pDict = action.GetDict(); |
| 203 | if (list.Find(pDict)) |
| 204 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 205 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 206 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 207 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 209 | ASSERT(pEnv); |
| 210 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 211 | if (pEnv->IsJSInitiated()) { |
| 212 | CFX_WideString swJS = action.GetJavaScript(); |
| 213 | if (!swJS.IsEmpty()) { |
| 214 | RunDocumentPageJavaScript(pDocument, type, swJS); |
| 215 | } |
| 216 | } |
| 217 | } else { |
| 218 | DoAction_NoJs(action, pDocument); |
| 219 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 220 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | if (!IsValidDocView(pDocument)) |
| 222 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 223 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 224 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 225 | CPDF_Action subaction = action.GetSubAction(i); |
| 226 | if (!ExecuteDocumentPageAction(subaction, type, pDocument, list)) |
| 227 | return FALSE; |
| 228 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 229 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 230 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 233 | FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, |
| 234 | CPDF_Dictionary* pFieldDict) { |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 235 | ASSERT(pDocument != NULL); |
| 236 | ASSERT(pFieldDict != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 237 | |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 238 | CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
| 239 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 240 | |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 241 | CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 242 | ASSERT(pPDFInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 243 | |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 244 | return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 247 | FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( |
| 248 | const CPDF_Action& action, |
| 249 | CPDF_AAction::AActionType type, |
| 250 | CPDFSDK_Document* pDocument, |
| 251 | CPDF_FormField* pFormField, |
| 252 | PDFSDK_FieldAction& data, |
| 253 | CFX_PtrList& list) { |
| 254 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 255 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 256 | CPDF_Dictionary* pDict = action.GetDict(); |
| 257 | if (list.Find(pDict)) |
| 258 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 259 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 260 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 261 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 262 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 263 | ASSERT(pEnv); |
| 264 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 265 | if (pEnv->IsJSInitiated()) { |
| 266 | CFX_WideString swJS = action.GetJavaScript(); |
| 267 | if (!swJS.IsEmpty()) { |
| 268 | RunFieldJavaScript(pDocument, pFormField, type, data, swJS); |
| 269 | if (!IsValidField(pDocument, pFormField->GetFieldDict())) |
| 270 | return FALSE; |
| 271 | } |
| 272 | } |
| 273 | } else { |
| 274 | DoAction_NoJs(action, pDocument); |
| 275 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 276 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 277 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 278 | CPDF_Action subaction = action.GetSubAction(i); |
| 279 | if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list)) |
| 280 | return FALSE; |
| 281 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 282 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 283 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 286 | FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( |
| 287 | const CPDF_Action& action, |
| 288 | CPDF_AAction::AActionType type, |
| 289 | CPDFSDK_Document* pDocument, |
| 290 | CPDFSDK_Annot* pScreen, |
| 291 | CFX_PtrList& list) { |
| 292 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 293 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 294 | CPDF_Dictionary* pDict = action.GetDict(); |
| 295 | if (list.Find(pDict)) |
| 296 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 297 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 298 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 299 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 300 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 301 | ASSERT(pEnv); |
| 302 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 303 | if (pEnv->IsJSInitiated()) { |
| 304 | CFX_WideString swJS = action.GetJavaScript(); |
| 305 | if (!swJS.IsEmpty()) { |
| 306 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 307 | ASSERT(pRuntime != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 308 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 309 | pRuntime->SetReaderDocument(pDocument); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 310 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 311 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 312 | ASSERT(pContext != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 313 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 314 | // switch (type) |
| 315 | // { |
| 316 | // case CPDF_AAction::CursorEnter: |
| 317 | // pContext->OnScreen_MouseEnter(IsCTRLpressed(), |
| 318 | // IsSHIFTpressed(), pScreen); |
| 319 | // break; |
| 320 | // case CPDF_AAction::CursorExit: |
| 321 | // pContext->OnScreen_MouseExit(IsCTRLpressed(), |
| 322 | // IsSHIFTpressed(), pScreen); |
| 323 | // break; |
| 324 | // case CPDF_AAction::ButtonDown: |
| 325 | // pContext->OnScreen_MouseDown(IsCTRLpressed(), |
| 326 | // IsSHIFTpressed(), pScreen); |
| 327 | // break; |
| 328 | // case CPDF_AAction::ButtonUp: |
| 329 | // pContext->OnScreen_MouseUp(IsCTRLpressed(), |
| 330 | // IsSHIFTpressed(), pScreen); |
| 331 | // break; |
| 332 | // case CPDF_AAction::GetFocus: |
| 333 | // pContext->OnScreen_Focus(IsCTRLpressed(), |
| 334 | // IsSHIFTpressed(), pScreen); |
| 335 | // break; |
| 336 | // case CPDF_AAction::LoseFocus: |
| 337 | // pContext->OnScreen_Blur(IsCTRLpressed(), |
| 338 | // IsSHIFTpressed(), pScreen); |
| 339 | // break; |
| 340 | // case CPDF_AAction::PageOpen: |
| 341 | // pContext->OnScreen_Open(IsCTRLpressed(), |
| 342 | // IsSHIFTpressed(), pScreen); |
| 343 | // break; |
| 344 | // case CPDF_AAction::PageClose: |
| 345 | // pContext->OnScreen_Close(IsCTRLpressed(), |
| 346 | // IsSHIFTpressed(), pScreen); |
| 347 | // break; |
| 348 | // case CPDF_AAction::PageVisible: |
| 349 | // pContext->OnScreen_InView(IsCTRLpressed(), |
| 350 | // IsSHIFTpressed(), pScreen); |
| 351 | // break; |
| 352 | // case CPDF_AAction::PageInvisible: |
| 353 | // pContext->OnScreen_OutView(IsCTRLpressed(), |
| 354 | // IsSHIFTpressed(), pScreen); |
| 355 | // break; |
| 356 | // default: |
| 357 | // ASSERT(FALSE); |
| 358 | // break; |
| 359 | // } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 360 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 361 | CFX_WideString csInfo; |
| 362 | FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
| 363 | if (!bRet) { |
| 364 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), |
| 365 | // csInfo); |
| 366 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 367 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 368 | pRuntime->ReleaseContext(pContext); |
| 369 | } |
| 370 | } |
| 371 | } else { |
| 372 | DoAction_NoJs(action, pDocument); |
| 373 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 374 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 375 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 376 | CPDF_Action subaction = action.GetSubAction(i); |
| 377 | if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, list)) |
| 378 | return FALSE; |
| 379 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 380 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 381 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 384 | FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, |
| 385 | CPDFSDK_Document* pDocument, |
| 386 | CPDF_Bookmark* pBookmark, |
| 387 | CFX_PtrList& list) { |
| 388 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 389 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 390 | CPDF_Dictionary* pDict = action.GetDict(); |
| 391 | if (list.Find(pDict)) |
| 392 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 393 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 394 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 395 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 396 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 397 | ASSERT(pEnv); |
| 398 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 399 | if (pEnv->IsJSInitiated()) { |
| 400 | CFX_WideString swJS = action.GetJavaScript(); |
| 401 | if (!swJS.IsEmpty()) { |
| 402 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 403 | ASSERT(pRuntime != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 404 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 405 | pRuntime->SetReaderDocument(pDocument); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 406 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 407 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 408 | ASSERT(pContext != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 409 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 410 | pContext->OnBookmark_MouseUp(pBookmark); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 411 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 412 | CFX_WideString csInfo; |
| 413 | FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
| 414 | if (!bRet) { |
| 415 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), |
| 416 | // csInfo); |
| 417 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 418 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 419 | pRuntime->ReleaseContext(pContext); |
| 420 | } |
| 421 | } |
| 422 | } else { |
| 423 | DoAction_NoJs(action, pDocument); |
| 424 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 425 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 426 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 427 | CPDF_Action subaction = action.GetSubAction(i); |
| 428 | if (!ExecuteBookMark(subaction, pDocument, pBookmark, list)) |
| 429 | return FALSE; |
| 430 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 431 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 432 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 435 | void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, |
| 436 | CPDFSDK_Document* pDocument) { |
| 437 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 438 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 439 | switch (action.GetType()) { |
| 440 | case CPDF_Action::GoTo: |
| 441 | DoAction_GoTo(pDocument, action); |
| 442 | break; |
| 443 | case CPDF_Action::GoToR: |
| 444 | DoAction_GoToR(pDocument, action); |
| 445 | break; |
| 446 | case CPDF_Action::GoToE: |
| 447 | break; |
| 448 | case CPDF_Action::Launch: |
| 449 | DoAction_Launch(pDocument, action); |
| 450 | break; |
| 451 | case CPDF_Action::Thread: |
| 452 | break; |
| 453 | case CPDF_Action::URI: |
| 454 | DoAction_URI(pDocument, action); |
| 455 | break; |
| 456 | case CPDF_Action::Sound: |
| 457 | if (m_pMediaActionHandler) { |
| 458 | m_pMediaActionHandler->DoAction_Sound(action, pDocument); |
| 459 | } |
| 460 | break; |
| 461 | case CPDF_Action::Movie: |
| 462 | if (m_pMediaActionHandler) { |
| 463 | m_pMediaActionHandler->DoAction_Movie(action, pDocument); |
| 464 | } |
| 465 | break; |
| 466 | case CPDF_Action::Hide: |
| 467 | if (m_pFormActionHandler) { |
| 468 | m_pFormActionHandler->DoAction_Hide(action, pDocument); |
| 469 | } |
| 470 | break; |
| 471 | case CPDF_Action::Named: |
| 472 | DoAction_Named(pDocument, action); |
| 473 | break; |
| 474 | case CPDF_Action::SubmitForm: |
| 475 | if (m_pFormActionHandler) { |
| 476 | m_pFormActionHandler->DoAction_SubmitForm(action, pDocument); |
| 477 | } |
| 478 | break; |
| 479 | case CPDF_Action::ResetForm: |
| 480 | if (m_pFormActionHandler) { |
| 481 | m_pFormActionHandler->DoAction_ResetForm(action, pDocument); |
| 482 | } |
| 483 | break; |
| 484 | case CPDF_Action::ImportData: |
| 485 | if (m_pFormActionHandler) { |
| 486 | m_pFormActionHandler->DoAction_ImportData(action, pDocument); |
| 487 | } |
| 488 | break; |
| 489 | case CPDF_Action::JavaScript: |
| 490 | ASSERT(FALSE); |
| 491 | break; |
| 492 | case CPDF_Action::SetOCGState: |
| 493 | DoAction_SetOCGState(pDocument, action); |
| 494 | break; |
| 495 | case CPDF_Action::Rendition: |
| 496 | if (m_pMediaActionHandler) { |
| 497 | m_pMediaActionHandler->DoAction_Rendition(action, pDocument); |
| 498 | } |
| 499 | break; |
| 500 | case CPDF_Action::Trans: |
| 501 | break; |
| 502 | case CPDF_Action::GoTo3DView: |
| 503 | break; |
| 504 | default: |
| 505 | break; |
| 506 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 509 | FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) { |
| 510 | ASSERT(pDocument != NULL); |
| 511 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 514 | void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 515 | const CPDF_Action& action) { |
| 516 | ASSERT(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 517 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 518 | CPDF_Document* pPDFDocument = pDocument->GetDocument()->GetPDFDoc(); |
| 519 | ASSERT(pPDFDocument != NULL); |
| 520 | CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
| 521 | ASSERT(pApp != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 522 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 523 | CPDF_Dest MyDest = action.GetDest(pPDFDocument); |
| 524 | int nPageIndex = MyDest.GetPageIndex(pPDFDocument); |
| 525 | int nFitType = MyDest.GetZoomMode(); |
| 526 | const CPDF_Array* pMyArray = (CPDF_Array*)MyDest.GetObject(); |
| 527 | float* pPosAry = NULL; |
| 528 | int sizeOfAry = 0; |
| 529 | if (pMyArray != NULL) { |
| 530 | pPosAry = new float[pMyArray->GetCount()]; |
| 531 | int j = 0; |
| 532 | for (int i = 2; i < (int)pMyArray->GetCount(); i++) { |
| 533 | pPosAry[j++] = pMyArray->GetFloat(i); |
| 534 | } |
| 535 | sizeOfAry = j; |
| 536 | } |
| 537 | pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); |
| 538 | if (pPosAry) |
| 539 | delete[] pPosAry; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 540 | } |
| 541 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 542 | void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, |
| 543 | const CPDF_Action& action) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 544 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 545 | void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, |
| 546 | const CPDF_Action& action) {} |
| 547 | |
| 548 | void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, |
| 549 | const CPDF_Action& action) { |
| 550 | ASSERT(action); |
| 551 | |
| 552 | CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
| 553 | ASSERT(pApp != NULL); |
| 554 | |
| 555 | CFX_ByteString sURI = action.GetURI(pDocument->GetDocument()->GetPDFDoc()); |
| 556 | pApp->FFI_DoURIAction(sURI.c_str()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 559 | void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, |
| 560 | const CPDF_Action& action) { |
| 561 | ASSERT(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 562 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 563 | CFX_ByteString csName = action.GetNamedAction(); |
| 564 | pDocument->GetEnv()->FFI_ExecuteNamedAction(csName); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 567 | void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument, |
| 568 | const CPDF_Action& action) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 569 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 570 | void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, |
| 571 | CPDF_FormField* pFormField, |
| 572 | CPDF_AAction::AActionType type, |
| 573 | PDFSDK_FieldAction& data, |
| 574 | const CFX_WideString& script) { |
| 575 | ASSERT(type != CPDF_AAction::Calculate); |
| 576 | ASSERT(type != CPDF_AAction::Format); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 577 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 578 | ASSERT(pDocument != NULL); |
| 579 | |
| 580 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 581 | ASSERT(pRuntime != NULL); |
| 582 | |
| 583 | pRuntime->SetReaderDocument(pDocument); |
| 584 | |
| 585 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 586 | ASSERT(pContext != NULL); |
| 587 | |
| 588 | switch (type) { |
| 589 | case CPDF_AAction::CursorEnter: |
| 590 | pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); |
| 591 | break; |
| 592 | case CPDF_AAction::CursorExit: |
| 593 | pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); |
| 594 | break; |
| 595 | case CPDF_AAction::ButtonDown: |
| 596 | pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField); |
| 597 | break; |
| 598 | case CPDF_AAction::ButtonUp: |
| 599 | pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField); |
| 600 | break; |
| 601 | case CPDF_AAction::GetFocus: |
| 602 | pContext->OnField_Focus(data.bModifier, data.bShift, pFormField, |
| 603 | data.sValue); |
| 604 | break; |
| 605 | case CPDF_AAction::LoseFocus: |
| 606 | pContext->OnField_Blur(data.bModifier, data.bShift, pFormField, |
| 607 | data.sValue); |
| 608 | break; |
| 609 | case CPDF_AAction::KeyStroke: |
| 610 | pContext->OnField_Keystroke(data.sChange, data.sChangeEx, data.bKeyDown, |
| 611 | data.bModifier, data.nSelEnd, data.nSelStart, |
| 612 | data.bShift, pFormField, data.sValue, |
| 613 | data.bWillCommit, data.bFieldFull, data.bRC); |
| 614 | break; |
| 615 | case CPDF_AAction::Validate: |
| 616 | pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, |
| 617 | data.bModifier, data.bShift, pFormField, |
| 618 | data.sValue, data.bRC); |
| 619 | break; |
| 620 | default: |
| 621 | ASSERT(FALSE); |
| 622 | break; |
| 623 | } |
| 624 | |
| 625 | CFX_WideString csInfo; |
| 626 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 627 | if (!bRet) { |
| 628 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 629 | } |
| 630 | |
| 631 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 632 | } |
| 633 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 634 | void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( |
| 635 | CPDFSDK_Document* pDocument, |
| 636 | const CFX_WideString& sScriptName, |
| 637 | const CFX_WideString& script) { |
| 638 | ASSERT(pDocument != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 639 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 640 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 641 | ASSERT(pRuntime != NULL); |
| 642 | |
| 643 | pRuntime->SetReaderDocument(pDocument); |
| 644 | |
| 645 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 646 | ASSERT(pContext != NULL); |
| 647 | |
| 648 | pContext->OnDoc_Open(pDocument, sScriptName); |
| 649 | |
| 650 | CFX_WideString csInfo; |
| 651 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 652 | if (!bRet) { |
| 653 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 654 | } |
| 655 | |
| 656 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 657 | } |
| 658 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 659 | void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( |
| 660 | CPDFSDK_Document* pDocument, |
| 661 | CPDF_AAction::AActionType type, |
| 662 | const CFX_WideString& script) { |
| 663 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 664 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 665 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 666 | ASSERT(pRuntime != NULL); |
| 667 | |
| 668 | pRuntime->SetReaderDocument(pDocument); |
| 669 | |
| 670 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 671 | ASSERT(pContext != NULL); |
| 672 | |
| 673 | switch (type) { |
| 674 | case CPDF_AAction::OpenPage: |
| 675 | pContext->OnPage_Open(pDocument); |
| 676 | break; |
| 677 | case CPDF_AAction::ClosePage: |
| 678 | pContext->OnPage_Close(pDocument); |
| 679 | break; |
| 680 | case CPDF_AAction::CloseDocument: |
| 681 | pContext->OnDoc_WillClose(pDocument); |
| 682 | break; |
| 683 | case CPDF_AAction::SaveDocument: |
| 684 | pContext->OnDoc_WillSave(pDocument); |
| 685 | break; |
| 686 | case CPDF_AAction::DocumentSaved: |
| 687 | pContext->OnDoc_DidSave(pDocument); |
| 688 | break; |
| 689 | case CPDF_AAction::PrintDocument: |
| 690 | pContext->OnDoc_WillPrint(pDocument); |
| 691 | break; |
| 692 | case CPDF_AAction::DocumentPrinted: |
| 693 | pContext->OnDoc_DidPrint(pDocument); |
| 694 | break; |
| 695 | case CPDF_AAction::PageVisible: |
| 696 | pContext->OnPage_InView(pDocument); |
| 697 | break; |
| 698 | case CPDF_AAction::PageInvisible: |
| 699 | pContext->OnPage_OutView(pDocument); |
| 700 | break; |
| 701 | default: |
| 702 | ASSERT(FALSE); |
| 703 | break; |
| 704 | } |
| 705 | |
| 706 | CFX_WideString csInfo; |
| 707 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 708 | if (!bRet) { |
| 709 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 710 | } |
| 711 | |
| 712 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 715 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, |
| 716 | CPDFSDK_Document* pDocument) { |
| 717 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 718 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 719 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 720 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 721 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 722 | if (pInterForm->DoAction_Hide(action)) { |
| 723 | pDocument->SetChangeMark(); |
| 724 | return TRUE; |
| 725 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 726 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 727 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 728 | } |
| 729 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 730 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm( |
| 731 | const CPDF_Action& action, |
| 732 | CPDFSDK_Document* pDocument) { |
| 733 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 734 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 735 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 736 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 737 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 738 | return pInterForm->DoAction_SubmitForm(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 739 | } |
| 740 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 741 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm( |
| 742 | const CPDF_Action& action, |
| 743 | CPDFSDK_Document* pDocument) { |
| 744 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 745 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 746 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 747 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 748 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 749 | if (pInterForm->DoAction_ResetForm(action)) { |
| 750 | return TRUE; |
| 751 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 752 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 753 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 756 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData( |
| 757 | const CPDF_Action& action, |
| 758 | CPDFSDK_Document* pDocument) { |
| 759 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 760 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 761 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 762 | ASSERT(pInterForm != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 763 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 764 | if (pInterForm->DoAction_ImportData(action)) { |
| 765 | pDocument->SetChangeMark(); |
| 766 | return TRUE; |
| 767 | } |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 768 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 769 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 770 | } |
| 771 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 772 | FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Rendition( |
| 773 | const CPDF_Action& action, |
| 774 | CPDFSDK_Document* pDocument) { |
| 775 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 776 | } |
| 777 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 778 | FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Sound( |
| 779 | const CPDF_Action& action, |
| 780 | CPDFSDK_Document* pDocument) { |
| 781 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 782 | } |
| 783 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 784 | FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Movie( |
| 785 | const CPDF_Action& action, |
| 786 | CPDFSDK_Document* pDocument) { |
| 787 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 788 | } |