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. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [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 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/javascript/JS_EventHandler.h" |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 8 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 9 | #include "fpdfsdk/javascript/Document.h" |
| 10 | #include "fpdfsdk/javascript/Field.h" |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 11 | #include "fpdfsdk/javascript/JS_Define.h" |
| 12 | #include "fpdfsdk/javascript/JS_Object.h" |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 13 | #include "fpdfsdk/javascript/JS_Value.h" |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 14 | #include "fpdfsdk/javascript/cjs_event_context.h" |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 15 | #include "fpdfsdk/javascript/cjs_runtime.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 16 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 17 | CJS_EventHandler::CJS_EventHandler(CJS_EventContext* pContext) |
| 18 | : m_pJSEventContext(pContext), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 19 | m_eEventType(JET_UNKNOWN), |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 20 | m_bValid(false), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 21 | m_pWideStrChange(nullptr), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 22 | m_nCommitKey(-1), |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 23 | m_bKeyDown(false), |
| 24 | m_bModifier(false), |
| 25 | m_bShift(false), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 26 | m_pISelEnd(nullptr), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 27 | m_nSelEndDu(0), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 28 | m_pISelStart(nullptr), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 29 | m_nSelStartDu(0), |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 30 | m_bWillCommit(false), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 31 | m_pValue(nullptr), |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 32 | m_bFieldFull(false), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 33 | m_pbRc(nullptr), |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 34 | m_bRcDu(false), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 35 | m_pTargetBookMark(nullptr), |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 36 | m_pTargetFormFillEnv(nullptr), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 37 | m_pTargetAnnot(nullptr) {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | |
| 39 | CJS_EventHandler::~CJS_EventHandler() {} |
| 40 | |
| 41 | void CJS_EventHandler::OnApp_Init() { |
| 42 | Initial(JET_APP_INIT); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 43 | } |
| 44 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 45 | void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 46 | const WideString& strTargetName) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 47 | Initial(JET_DOC_OPEN); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 48 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | m_strTargetName = strTargetName; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 50 | } |
| 51 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 52 | void CJS_EventHandler::OnDoc_WillPrint( |
| 53 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 54 | Initial(JET_DOC_WILLPRINT); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 55 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 56 | } |
| 57 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 58 | void CJS_EventHandler::OnDoc_DidPrint( |
| 59 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 60 | Initial(JET_DOC_DIDPRINT); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 61 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | } |
| 63 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 64 | void CJS_EventHandler::OnDoc_WillSave( |
| 65 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 66 | Initial(JET_DOC_WILLSAVE); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 67 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 68 | } |
| 69 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 70 | void CJS_EventHandler::OnDoc_DidSave( |
| 71 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | Initial(JET_DOC_DIDSAVE); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 73 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 74 | } |
| 75 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 76 | void CJS_EventHandler::OnDoc_WillClose( |
| 77 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 78 | Initial(JET_DOC_WILLCLOSE); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 79 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 80 | } |
| 81 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 82 | void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 83 | Initial(JET_PAGE_OPEN); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 84 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 85 | } |
| 86 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 87 | void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 88 | Initial(JET_PAGE_CLOSE); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 89 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 90 | } |
| 91 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 92 | void CJS_EventHandler::OnPage_InView( |
| 93 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 94 | Initial(JET_PAGE_INVIEW); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 95 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 96 | } |
| 97 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 98 | void CJS_EventHandler::OnPage_OutView( |
| 99 | CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 100 | Initial(JET_PAGE_OUTVIEW); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 101 | m_pTargetFormFillEnv.Reset(pFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 102 | } |
| 103 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 104 | void CJS_EventHandler::OnField_MouseEnter(bool bModifier, |
| 105 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 106 | CPDF_FormField* pTarget) { |
| 107 | Initial(JET_FIELD_MOUSEENTER); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 108 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 109 | m_bModifier = bModifier; |
| 110 | m_bShift = bShift; |
| 111 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 112 | m_strTargetName = pTarget->GetFullName(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 113 | } |
| 114 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 115 | void CJS_EventHandler::OnField_MouseExit(bool bModifier, |
| 116 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 117 | CPDF_FormField* pTarget) { |
| 118 | Initial(JET_FIELD_MOUSEEXIT); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 119 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 120 | m_bModifier = bModifier; |
| 121 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 122 | m_strTargetName = pTarget->GetFullName(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 123 | } |
| 124 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 125 | void CJS_EventHandler::OnField_MouseDown(bool bModifier, |
| 126 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 127 | CPDF_FormField* pTarget) { |
| 128 | Initial(JET_FIELD_MOUSEDOWN); |
| 129 | m_eEventType = JET_FIELD_MOUSEDOWN; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 130 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 131 | m_bModifier = bModifier; |
| 132 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 133 | m_strTargetName = pTarget->GetFullName(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 134 | } |
| 135 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 136 | void CJS_EventHandler::OnField_MouseUp(bool bModifier, |
| 137 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 138 | CPDF_FormField* pTarget) { |
| 139 | Initial(JET_FIELD_MOUSEUP); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 140 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 141 | m_bModifier = bModifier; |
| 142 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 143 | m_strTargetName = pTarget->GetFullName(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 144 | } |
| 145 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 146 | void CJS_EventHandler::OnField_Focus(bool bModifier, |
| 147 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 148 | CPDF_FormField* pTarget, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 149 | const WideString& Value) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 150 | Initial(JET_FIELD_FOCUS); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 151 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 152 | m_bModifier = bModifier; |
| 153 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 154 | m_strTargetName = pTarget->GetFullName(); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 155 | m_pValue = (WideString*)&Value; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 156 | } |
| 157 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 158 | void CJS_EventHandler::OnField_Blur(bool bModifier, |
| 159 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 160 | CPDF_FormField* pTarget, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 161 | const WideString& Value) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 162 | Initial(JET_FIELD_BLUR); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 163 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 164 | m_bModifier = bModifier; |
| 165 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 166 | m_strTargetName = pTarget->GetFullName(); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 167 | m_pValue = (WideString*)&Value; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 170 | void CJS_EventHandler::OnField_Keystroke(WideString& strChange, |
| 171 | const WideString& strChangeEx, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 172 | bool KeyDown, |
| 173 | bool bModifier, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 174 | int& nSelEnd, |
| 175 | int& nSelStart, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 176 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 177 | CPDF_FormField* pTarget, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 178 | WideString& Value, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 179 | bool bWillCommit, |
| 180 | bool bFieldFull, |
| 181 | bool& bRc) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 182 | Initial(JET_FIELD_KEYSTROKE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 183 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | m_nCommitKey = 0; |
| 185 | m_pWideStrChange = &strChange; |
| 186 | m_WideStrChangeEx = strChangeEx; |
| 187 | m_bKeyDown = KeyDown; |
| 188 | m_bModifier = bModifier; |
| 189 | m_pISelEnd = &nSelEnd; |
| 190 | m_pISelStart = &nSelStart; |
| 191 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 192 | m_strTargetName = pTarget->GetFullName(); |
| 193 | m_pValue = &Value; |
| 194 | m_bWillCommit = bWillCommit; |
| 195 | m_pbRc = &bRc; |
| 196 | m_bFieldFull = bFieldFull; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 199 | void CJS_EventHandler::OnField_Validate(WideString& strChange, |
| 200 | const WideString& strChangeEx, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 201 | bool bKeyDown, |
| 202 | bool bModifier, |
| 203 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 204 | CPDF_FormField* pTarget, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 205 | WideString& Value, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 206 | bool& bRc) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 207 | Initial(JET_FIELD_VALIDATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 208 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 209 | m_pWideStrChange = &strChange; |
| 210 | m_WideStrChangeEx = strChangeEx; |
| 211 | m_bKeyDown = bKeyDown; |
| 212 | m_bModifier = bModifier; |
| 213 | m_bShift = bShift; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 214 | m_strTargetName = pTarget->GetFullName(); |
| 215 | m_pValue = &Value; |
| 216 | m_pbRc = &bRc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 219 | void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource, |
| 220 | CPDF_FormField* pTarget, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 221 | WideString& Value, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 222 | bool& bRc) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 223 | Initial(JET_FIELD_CALCULATE); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 224 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 225 | if (pSource) |
| 226 | m_strSourceName = pSource->GetFullName(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 227 | m_strTargetName = pTarget->GetFullName(); |
| 228 | m_pValue = &Value; |
| 229 | m_pbRc = &bRc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Lei Zhang | 0aa0e73 | 2015-06-10 15:23:23 -0700 | [diff] [blame] | 232 | void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 233 | WideString& Value, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 234 | bool bWillCommit) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 235 | Initial(JET_FIELD_FORMAT); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 236 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 237 | m_nCommitKey = 0; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 238 | m_strTargetName = pTarget->GetFullName(); |
| 239 | m_pValue = &Value; |
| 240 | m_bWillCommit = bWillCommit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 241 | } |
| 242 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 243 | void CJS_EventHandler::OnScreen_Focus(bool bModifier, |
| 244 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 245 | CPDFSDK_Annot* pScreen) { |
| 246 | Initial(JET_SCREEN_FOCUS); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 247 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 248 | m_bModifier = bModifier; |
| 249 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 250 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 251 | } |
| 252 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 253 | void CJS_EventHandler::OnScreen_Blur(bool bModifier, |
| 254 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 255 | CPDFSDK_Annot* pScreen) { |
| 256 | Initial(JET_SCREEN_BLUR); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 257 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 258 | m_bModifier = bModifier; |
| 259 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 260 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 261 | } |
| 262 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 263 | void CJS_EventHandler::OnScreen_Open(bool bModifier, |
| 264 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 265 | CPDFSDK_Annot* pScreen) { |
| 266 | Initial(JET_SCREEN_OPEN); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 267 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 268 | m_bModifier = bModifier; |
| 269 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 270 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 271 | } |
| 272 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 273 | void CJS_EventHandler::OnScreen_Close(bool bModifier, |
| 274 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 275 | CPDFSDK_Annot* pScreen) { |
| 276 | Initial(JET_SCREEN_CLOSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 277 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 278 | m_bModifier = bModifier; |
| 279 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 280 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 281 | } |
| 282 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 283 | void CJS_EventHandler::OnScreen_MouseDown(bool bModifier, |
| 284 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 285 | CPDFSDK_Annot* pScreen) { |
| 286 | Initial(JET_SCREEN_MOUSEDOWN); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 287 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 288 | m_bModifier = bModifier; |
| 289 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 290 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 291 | } |
| 292 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 293 | void CJS_EventHandler::OnScreen_MouseUp(bool bModifier, |
| 294 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 295 | CPDFSDK_Annot* pScreen) { |
| 296 | Initial(JET_SCREEN_MOUSEUP); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 297 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 298 | m_bModifier = bModifier; |
| 299 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 300 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 301 | } |
| 302 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 303 | void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier, |
| 304 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 305 | CPDFSDK_Annot* pScreen) { |
| 306 | Initial(JET_SCREEN_MOUSEENTER); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 307 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 308 | m_bModifier = bModifier; |
| 309 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 310 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 311 | } |
| 312 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 313 | void CJS_EventHandler::OnScreen_MouseExit(bool bModifier, |
| 314 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 315 | CPDFSDK_Annot* pScreen) { |
| 316 | Initial(JET_SCREEN_MOUSEEXIT); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 317 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 318 | m_bModifier = bModifier; |
| 319 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 320 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 321 | } |
| 322 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 323 | void CJS_EventHandler::OnScreen_InView(bool bModifier, |
| 324 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 325 | CPDFSDK_Annot* pScreen) { |
| 326 | Initial(JET_SCREEN_INVIEW); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 327 | m_bModifier = bModifier; |
| 328 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 329 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 330 | } |
| 331 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 332 | void CJS_EventHandler::OnScreen_OutView(bool bModifier, |
| 333 | bool bShift, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 334 | CPDFSDK_Annot* pScreen) { |
| 335 | Initial(JET_SCREEN_OUTVIEW); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 336 | m_bModifier = bModifier; |
| 337 | m_bShift = bShift; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 338 | m_pTargetAnnot.Reset(pScreen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 339 | } |
| 340 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 341 | void CJS_EventHandler::OnLink_MouseUp( |
| 342 | CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 343 | Initial(JET_LINK_MOUSEUP); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 344 | m_pTargetFormFillEnv.Reset(pTargetFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 347 | void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { |
| 348 | Initial(JET_BOOKMARK_MOUSEUP); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 349 | m_pTargetBookMark = pBookMark; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 350 | } |
| 351 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 352 | void CJS_EventHandler::OnMenu_Exec( |
| 353 | CPDFSDK_FormFillEnvironment* pTargetFormFillEnv, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 354 | const WideString& strTargetName) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 355 | Initial(JET_MENU_EXEC); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 356 | m_pTargetFormFillEnv.Reset(pTargetFormFillEnv); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 357 | m_strTargetName = strTargetName; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 360 | void CJS_EventHandler::OnExternal_Exec() { |
| 361 | Initial(JET_EXTERNAL_EXEC); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 362 | } |
| 363 | |
dsinclair | 4526faf | 2016-10-11 10:54:49 -0700 | [diff] [blame] | 364 | void CJS_EventHandler::OnBatchExec( |
| 365 | CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 366 | Initial(JET_BATCH_EXEC); |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 367 | m_pTargetFormFillEnv.Reset(pTargetFormFillEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 370 | void CJS_EventHandler::OnConsole_Exec() { |
| 371 | Initial(JET_CONSOLE_EXEC); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 372 | } |
| 373 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 374 | void CJS_EventHandler::Initial(JS_EVENT_T type) { |
| 375 | m_eEventType = type; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 376 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 377 | m_strTargetName = L""; |
| 378 | m_strSourceName = L""; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 379 | m_pWideStrChange = nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 380 | m_WideStrChangeDu = L""; |
| 381 | m_WideStrChangeEx = L""; |
| 382 | m_nCommitKey = -1; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 383 | m_bKeyDown = false; |
| 384 | m_bModifier = false; |
| 385 | m_bShift = false; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 386 | m_pISelEnd = nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 387 | m_nSelEndDu = 0; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 388 | m_pISelStart = nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 389 | m_nSelStartDu = 0; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 390 | m_bWillCommit = false; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 391 | m_pValue = nullptr; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 392 | m_bFieldFull = false; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 393 | m_pbRc = nullptr; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 394 | m_bRcDu = false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 395 | |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 396 | m_pTargetBookMark = nullptr; |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 397 | m_pTargetFormFillEnv.Reset(); |
| 398 | m_pTargetAnnot.Reset(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 399 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 400 | m_bValid = true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 403 | void CJS_EventHandler::Destroy() { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 404 | m_bValid = false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 405 | } |
| 406 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 407 | bool CJS_EventHandler::IsValid() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 408 | return m_bValid; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 411 | WideString& CJS_EventHandler::Change() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 412 | if (m_pWideStrChange) { |
| 413 | return *m_pWideStrChange; |
| 414 | } |
| 415 | return m_WideStrChangeDu; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 418 | WideString CJS_EventHandler::ChangeEx() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 419 | return m_WideStrChangeEx; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 422 | int CJS_EventHandler::CommitKey() { |
| 423 | return m_nCommitKey; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 424 | } |
| 425 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 426 | bool CJS_EventHandler::FieldFull() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 427 | return m_bFieldFull; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 428 | } |
| 429 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 430 | bool CJS_EventHandler::KeyDown() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 431 | return m_bKeyDown; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 432 | } |
| 433 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 434 | bool CJS_EventHandler::Modifier() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 435 | return m_bModifier; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 436 | } |
| 437 | |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 438 | const wchar_t* CJS_EventHandler::Name() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 439 | switch (m_eEventType) { |
| 440 | case JET_APP_INIT: |
| 441 | return L"Init"; |
| 442 | case JET_BATCH_EXEC: |
| 443 | return L"Exec"; |
| 444 | case JET_BOOKMARK_MOUSEUP: |
| 445 | return L"Mouse Up"; |
| 446 | case JET_CONSOLE_EXEC: |
| 447 | return L"Exec"; |
| 448 | case JET_DOC_DIDPRINT: |
| 449 | return L"DidPrint"; |
| 450 | case JET_DOC_DIDSAVE: |
| 451 | return L"DidSave"; |
| 452 | case JET_DOC_OPEN: |
| 453 | return L"Open"; |
| 454 | case JET_DOC_WILLCLOSE: |
| 455 | return L"WillClose"; |
| 456 | case JET_DOC_WILLPRINT: |
| 457 | return L"WillPrint"; |
| 458 | case JET_DOC_WILLSAVE: |
| 459 | return L"WillSave"; |
| 460 | case JET_EXTERNAL_EXEC: |
| 461 | return L"Exec"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 462 | case JET_FIELD_FOCUS: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 463 | case JET_SCREEN_FOCUS: |
| 464 | return L"Focus"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 465 | case JET_FIELD_BLUR: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 466 | case JET_SCREEN_BLUR: |
| 467 | return L"Blur"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 468 | case JET_FIELD_MOUSEDOWN: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 469 | case JET_SCREEN_MOUSEDOWN: |
| 470 | return L"Mouse Down"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 471 | case JET_FIELD_MOUSEUP: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 472 | case JET_SCREEN_MOUSEUP: |
| 473 | return L"Mouse Up"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 474 | case JET_FIELD_MOUSEENTER: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 475 | case JET_SCREEN_MOUSEENTER: |
| 476 | return L"Mouse Enter"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 477 | case JET_FIELD_MOUSEEXIT: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 478 | case JET_SCREEN_MOUSEEXIT: |
| 479 | return L"Mouse Exit"; |
| 480 | case JET_FIELD_CALCULATE: |
| 481 | return L"Calculate"; |
| 482 | case JET_FIELD_FORMAT: |
| 483 | return L"Format"; |
| 484 | case JET_FIELD_KEYSTROKE: |
| 485 | return L"Keystroke"; |
| 486 | case JET_FIELD_VALIDATE: |
| 487 | return L"Validate"; |
| 488 | case JET_LINK_MOUSEUP: |
| 489 | return L"Mouse Up"; |
| 490 | case JET_MENU_EXEC: |
| 491 | return L"Exec"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 492 | case JET_PAGE_OPEN: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 493 | case JET_SCREEN_OPEN: |
| 494 | return L"Open"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 495 | case JET_PAGE_CLOSE: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 496 | case JET_SCREEN_CLOSE: |
| 497 | return L"Close"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 498 | case JET_SCREEN_INVIEW: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 499 | case JET_PAGE_INVIEW: |
| 500 | return L"InView"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 501 | case JET_PAGE_OUTVIEW: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 502 | case JET_SCREEN_OUTVIEW: |
| 503 | return L"OutView"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 504 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 505 | return L""; |
| 506 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 509 | const wchar_t* CJS_EventHandler::Type() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 510 | switch (m_eEventType) { |
| 511 | case JET_APP_INIT: |
| 512 | return L"App"; |
| 513 | case JET_BATCH_EXEC: |
| 514 | return L"Batch"; |
| 515 | case JET_BOOKMARK_MOUSEUP: |
| 516 | return L"BookMark"; |
| 517 | case JET_CONSOLE_EXEC: |
| 518 | return L"Console"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 519 | case JET_DOC_DIDPRINT: |
| 520 | case JET_DOC_DIDSAVE: |
| 521 | case JET_DOC_OPEN: |
| 522 | case JET_DOC_WILLCLOSE: |
| 523 | case JET_DOC_WILLPRINT: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 524 | case JET_DOC_WILLSAVE: |
| 525 | return L"Doc"; |
| 526 | case JET_EXTERNAL_EXEC: |
| 527 | return L"External"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 528 | case JET_FIELD_BLUR: |
| 529 | case JET_FIELD_FOCUS: |
| 530 | case JET_FIELD_MOUSEDOWN: |
| 531 | case JET_FIELD_MOUSEENTER: |
| 532 | case JET_FIELD_MOUSEEXIT: |
| 533 | case JET_FIELD_MOUSEUP: |
| 534 | case JET_FIELD_CALCULATE: |
| 535 | case JET_FIELD_FORMAT: |
| 536 | case JET_FIELD_KEYSTROKE: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 537 | case JET_FIELD_VALIDATE: |
| 538 | return L"Field"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 539 | case JET_SCREEN_FOCUS: |
| 540 | case JET_SCREEN_BLUR: |
| 541 | case JET_SCREEN_OPEN: |
| 542 | case JET_SCREEN_CLOSE: |
| 543 | case JET_SCREEN_MOUSEDOWN: |
| 544 | case JET_SCREEN_MOUSEUP: |
| 545 | case JET_SCREEN_MOUSEENTER: |
| 546 | case JET_SCREEN_MOUSEEXIT: |
| 547 | case JET_SCREEN_INVIEW: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 548 | case JET_SCREEN_OUTVIEW: |
| 549 | return L"Screen"; |
| 550 | case JET_LINK_MOUSEUP: |
| 551 | return L"Link"; |
| 552 | case JET_MENU_EXEC: |
| 553 | return L"Menu"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 554 | case JET_PAGE_OPEN: |
| 555 | case JET_PAGE_CLOSE: |
| 556 | case JET_PAGE_INVIEW: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 557 | case JET_PAGE_OUTVIEW: |
| 558 | return L"Page"; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 559 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 560 | return L""; |
| 561 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 562 | } |
| 563 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 564 | bool& CJS_EventHandler::Rc() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 565 | if (m_pbRc) { |
| 566 | return *m_pbRc; |
| 567 | } |
| 568 | return m_bRcDu; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 571 | int& CJS_EventHandler::SelEnd() { |
| 572 | if (m_pISelEnd) { |
| 573 | return *m_pISelEnd; |
| 574 | } |
| 575 | return m_nSelEndDu; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 576 | } |
| 577 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 578 | int& CJS_EventHandler::SelStart() { |
| 579 | if (m_pISelStart) { |
| 580 | return *m_pISelStart; |
| 581 | } |
| 582 | return m_nSelStartDu; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 583 | } |
| 584 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 585 | bool CJS_EventHandler::Shift() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 586 | return m_bShift; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 589 | Field* CJS_EventHandler::Source() { |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 590 | CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime(); |
tsepez | b469424 | 2016-08-15 16:44:55 -0700 | [diff] [blame] | 591 | v8::Local<v8::Object> pDocObj = |
| 592 | pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 593 | if (pDocObj.IsEmpty()) |
| 594 | return nullptr; |
Tom Sepez | cd56a7d | 2015-10-06 11:45:28 -0700 | [diff] [blame] | 595 | |
tsepez | b469424 | 2016-08-15 16:44:55 -0700 | [diff] [blame] | 596 | v8::Local<v8::Object> pFieldObj = |
| 597 | pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID); |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 598 | if (pFieldObj.IsEmpty()) |
| 599 | return nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 600 | |
Tom Sepez | d5a0e95 | 2015-09-17 15:40:06 -0700 | [diff] [blame] | 601 | CJS_Document* pJSDocument = |
tsepez | b469424 | 2016-08-15 16:44:55 -0700 | [diff] [blame] | 602 | static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj)); |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 603 | CJS_Field* pJSField = |
| 604 | static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj)); |
| 605 | |
| 606 | Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject()); |
dsinclair | 82e1767 | 2016-10-11 12:38:01 -0700 | [diff] [blame] | 607 | pDocument->SetFormFillEnv(m_pTargetFormFillEnv |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 608 | ? m_pTargetFormFillEnv.Get() |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 609 | : m_pJSEventContext->GetFormFillEnv()); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 610 | |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 611 | Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 612 | pField->AttachField(pDocument, m_strSourceName); |
| 613 | return pField; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 614 | } |
| 615 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 616 | Field* CJS_EventHandler::Target_Field() { |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 617 | CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime(); |
tsepez | b469424 | 2016-08-15 16:44:55 -0700 | [diff] [blame] | 618 | v8::Local<v8::Object> pDocObj = |
| 619 | pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 620 | if (pDocObj.IsEmpty()) |
| 621 | return nullptr; |
Tom Sepez | cd56a7d | 2015-10-06 11:45:28 -0700 | [diff] [blame] | 622 | |
tsepez | b469424 | 2016-08-15 16:44:55 -0700 | [diff] [blame] | 623 | v8::Local<v8::Object> pFieldObj = |
| 624 | pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID); |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 625 | if (pFieldObj.IsEmpty()) |
| 626 | return nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 627 | |
Tom Sepez | d5a0e95 | 2015-09-17 15:40:06 -0700 | [diff] [blame] | 628 | CJS_Document* pJSDocument = |
tsepez | b469424 | 2016-08-15 16:44:55 -0700 | [diff] [blame] | 629 | static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj)); |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 630 | CJS_Field* pJSField = |
| 631 | static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj)); |
| 632 | |
| 633 | Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject()); |
dsinclair | 82e1767 | 2016-10-11 12:38:01 -0700 | [diff] [blame] | 634 | pDocument->SetFormFillEnv(m_pTargetFormFillEnv |
Tom Sepez | 77f6d0f | 2017-02-23 12:14:10 -0800 | [diff] [blame] | 635 | ? m_pTargetFormFillEnv.Get() |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 636 | : m_pJSEventContext->GetFormFillEnv()); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 637 | |
Tom Sepez | c5a1472 | 2017-02-24 15:31:12 -0800 | [diff] [blame] | 638 | Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 639 | pField->AttachField(pDocument, m_strTargetName); |
| 640 | return pField; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 641 | } |
| 642 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 643 | WideString& CJS_EventHandler::Value() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 644 | return *m_pValue; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 645 | } |
| 646 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 647 | bool CJS_EventHandler::WillCommit() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 648 | return m_bWillCommit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 649 | } |
| 650 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 651 | WideString CJS_EventHandler::TargetName() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 652 | return m_strTargetName; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 653 | } |