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); |
Lei Zhang | da180e9 | 2015-08-14 22:22:13 -0700 | [diff] [blame^] | 538 | delete[] pPosAry; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 539 | } |
| 540 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 541 | void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, |
| 542 | const CPDF_Action& action) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 543 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 544 | void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, |
| 545 | const CPDF_Action& action) {} |
| 546 | |
| 547 | void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, |
| 548 | const CPDF_Action& action) { |
| 549 | ASSERT(action); |
| 550 | |
| 551 | CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
| 552 | ASSERT(pApp != NULL); |
| 553 | |
| 554 | CFX_ByteString sURI = action.GetURI(pDocument->GetDocument()->GetPDFDoc()); |
| 555 | pApp->FFI_DoURIAction(sURI.c_str()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 558 | void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, |
| 559 | const CPDF_Action& action) { |
| 560 | ASSERT(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 561 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 562 | CFX_ByteString csName = action.GetNamedAction(); |
| 563 | pDocument->GetEnv()->FFI_ExecuteNamedAction(csName); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 564 | } |
| 565 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 566 | void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument, |
| 567 | const CPDF_Action& action) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 568 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 569 | void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, |
| 570 | CPDF_FormField* pFormField, |
| 571 | CPDF_AAction::AActionType type, |
| 572 | PDFSDK_FieldAction& data, |
| 573 | const CFX_WideString& script) { |
| 574 | ASSERT(type != CPDF_AAction::Calculate); |
| 575 | ASSERT(type != CPDF_AAction::Format); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 576 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 577 | ASSERT(pDocument != NULL); |
| 578 | |
| 579 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 580 | ASSERT(pRuntime != NULL); |
| 581 | |
| 582 | pRuntime->SetReaderDocument(pDocument); |
| 583 | |
| 584 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 585 | ASSERT(pContext != NULL); |
| 586 | |
| 587 | switch (type) { |
| 588 | case CPDF_AAction::CursorEnter: |
| 589 | pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); |
| 590 | break; |
| 591 | case CPDF_AAction::CursorExit: |
| 592 | pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); |
| 593 | break; |
| 594 | case CPDF_AAction::ButtonDown: |
| 595 | pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField); |
| 596 | break; |
| 597 | case CPDF_AAction::ButtonUp: |
| 598 | pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField); |
| 599 | break; |
| 600 | case CPDF_AAction::GetFocus: |
| 601 | pContext->OnField_Focus(data.bModifier, data.bShift, pFormField, |
| 602 | data.sValue); |
| 603 | break; |
| 604 | case CPDF_AAction::LoseFocus: |
| 605 | pContext->OnField_Blur(data.bModifier, data.bShift, pFormField, |
| 606 | data.sValue); |
| 607 | break; |
| 608 | case CPDF_AAction::KeyStroke: |
| 609 | pContext->OnField_Keystroke(data.sChange, data.sChangeEx, data.bKeyDown, |
| 610 | data.bModifier, data.nSelEnd, data.nSelStart, |
| 611 | data.bShift, pFormField, data.sValue, |
| 612 | data.bWillCommit, data.bFieldFull, data.bRC); |
| 613 | break; |
| 614 | case CPDF_AAction::Validate: |
| 615 | pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, |
| 616 | data.bModifier, data.bShift, pFormField, |
| 617 | data.sValue, data.bRC); |
| 618 | break; |
| 619 | default: |
| 620 | ASSERT(FALSE); |
| 621 | break; |
| 622 | } |
| 623 | |
| 624 | CFX_WideString csInfo; |
| 625 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 626 | if (!bRet) { |
| 627 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 628 | } |
| 629 | |
| 630 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 631 | } |
| 632 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 633 | void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( |
| 634 | CPDFSDK_Document* pDocument, |
| 635 | const CFX_WideString& sScriptName, |
| 636 | const CFX_WideString& script) { |
| 637 | ASSERT(pDocument != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 638 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 639 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 640 | ASSERT(pRuntime != NULL); |
| 641 | |
| 642 | pRuntime->SetReaderDocument(pDocument); |
| 643 | |
| 644 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 645 | ASSERT(pContext != NULL); |
| 646 | |
| 647 | pContext->OnDoc_Open(pDocument, sScriptName); |
| 648 | |
| 649 | CFX_WideString csInfo; |
| 650 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 651 | if (!bRet) { |
| 652 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 653 | } |
| 654 | |
| 655 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 656 | } |
| 657 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 658 | void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( |
| 659 | CPDFSDK_Document* pDocument, |
| 660 | CPDF_AAction::AActionType type, |
| 661 | const CFX_WideString& script) { |
| 662 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 663 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 664 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 665 | ASSERT(pRuntime != NULL); |
| 666 | |
| 667 | pRuntime->SetReaderDocument(pDocument); |
| 668 | |
| 669 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 670 | ASSERT(pContext != NULL); |
| 671 | |
| 672 | switch (type) { |
| 673 | case CPDF_AAction::OpenPage: |
| 674 | pContext->OnPage_Open(pDocument); |
| 675 | break; |
| 676 | case CPDF_AAction::ClosePage: |
| 677 | pContext->OnPage_Close(pDocument); |
| 678 | break; |
| 679 | case CPDF_AAction::CloseDocument: |
| 680 | pContext->OnDoc_WillClose(pDocument); |
| 681 | break; |
| 682 | case CPDF_AAction::SaveDocument: |
| 683 | pContext->OnDoc_WillSave(pDocument); |
| 684 | break; |
| 685 | case CPDF_AAction::DocumentSaved: |
| 686 | pContext->OnDoc_DidSave(pDocument); |
| 687 | break; |
| 688 | case CPDF_AAction::PrintDocument: |
| 689 | pContext->OnDoc_WillPrint(pDocument); |
| 690 | break; |
| 691 | case CPDF_AAction::DocumentPrinted: |
| 692 | pContext->OnDoc_DidPrint(pDocument); |
| 693 | break; |
| 694 | case CPDF_AAction::PageVisible: |
| 695 | pContext->OnPage_InView(pDocument); |
| 696 | break; |
| 697 | case CPDF_AAction::PageInvisible: |
| 698 | pContext->OnPage_OutView(pDocument); |
| 699 | break; |
| 700 | default: |
| 701 | ASSERT(FALSE); |
| 702 | break; |
| 703 | } |
| 704 | |
| 705 | CFX_WideString csInfo; |
| 706 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 707 | if (!bRet) { |
| 708 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 709 | } |
| 710 | |
| 711 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 712 | } |
| 713 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 714 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, |
| 715 | CPDFSDK_Document* pDocument) { |
| 716 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 717 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 718 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 719 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 720 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 721 | if (pInterForm->DoAction_Hide(action)) { |
| 722 | pDocument->SetChangeMark(); |
| 723 | return TRUE; |
| 724 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 725 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 726 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 727 | } |
| 728 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 729 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm( |
| 730 | const CPDF_Action& action, |
| 731 | CPDFSDK_Document* pDocument) { |
| 732 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 733 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 734 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 735 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 736 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 737 | return pInterForm->DoAction_SubmitForm(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 738 | } |
| 739 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 740 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm( |
| 741 | const CPDF_Action& action, |
| 742 | CPDFSDK_Document* pDocument) { |
| 743 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 744 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 745 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 746 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 747 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 748 | if (pInterForm->DoAction_ResetForm(action)) { |
| 749 | return TRUE; |
| 750 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 751 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 752 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 753 | } |
| 754 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 755 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData( |
| 756 | const CPDF_Action& action, |
| 757 | CPDFSDK_Document* pDocument) { |
| 758 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 759 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 760 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 761 | ASSERT(pInterForm != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 762 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 763 | if (pInterForm->DoAction_ImportData(action)) { |
| 764 | pDocument->SetChangeMark(); |
| 765 | return TRUE; |
| 766 | } |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 767 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 768 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 769 | } |
| 770 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 771 | FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Rendition( |
| 772 | const CPDF_Action& action, |
| 773 | CPDFSDK_Document* pDocument) { |
| 774 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 775 | } |
| 776 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 777 | FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Sound( |
| 778 | const CPDF_Action& action, |
| 779 | CPDFSDK_Document* pDocument) { |
| 780 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 781 | } |
| 782 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 783 | FX_BOOL CPDFSDK_MediaActionHandler::DoAction_Movie( |
| 784 | const CPDF_Action& action, |
| 785 | CPDFSDK_Document* pDocument) { |
| 786 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 787 | } |