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