summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cjs_eventhandler.cpp97
-rw-r--r--fxjs/cjs_eventhandler.h42
-rw-r--r--fxjs/cjs_publicmethods_embeddertest.cpp10
3 files changed, 70 insertions, 79 deletions
diff --git a/fxjs/cjs_eventhandler.cpp b/fxjs/cjs_eventhandler.cpp
index 933970954a..5b20ce769b 100644
--- a/fxjs/cjs_eventhandler.cpp
+++ b/fxjs/cjs_eventhandler.cpp
@@ -15,96 +15,77 @@
#include "fxjs/cjs_runtime.h"
CJS_EventHandler::CJS_EventHandler(CJS_EventContext* pContext)
- : m_pJSEventContext(pContext),
- m_eEventType(JET_UNKNOWN),
- m_bValid(false),
- m_pWideStrChange(nullptr),
- m_nCommitKey(-1),
- m_bKeyDown(false),
- m_bModifier(false),
- m_bShift(false),
- m_pISelEnd(nullptr),
- m_nSelEndDu(0),
- m_pISelStart(nullptr),
- m_nSelStartDu(0),
- m_bWillCommit(false),
- m_pValue(nullptr),
- m_bFieldFull(false),
- m_pbRc(nullptr),
- m_bRcDu(false),
- m_pTargetBookMark(nullptr),
- m_pTargetFormFillEnv(nullptr),
- m_pTargetAnnot(nullptr) {}
+ : m_pJSEventContext(pContext) {}
CJS_EventHandler::~CJS_EventHandler() {}
void CJS_EventHandler::OnApp_Init() {
- Initial(JET_APP_INIT);
+ Initialize(JET_APP_INIT);
}
void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const WideString& strTargetName) {
- Initial(JET_DOC_OPEN);
+ Initialize(JET_DOC_OPEN);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
m_strTargetName = strTargetName;
}
void CJS_EventHandler::OnDoc_WillPrint(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_DOC_WILLPRINT);
+ Initialize(JET_DOC_WILLPRINT);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_DidPrint(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_DOC_DIDPRINT);
+ Initialize(JET_DOC_DIDPRINT);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_WillSave(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_DOC_WILLSAVE);
+ Initialize(JET_DOC_WILLSAVE);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_DidSave(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_DOC_DIDSAVE);
+ Initialize(JET_DOC_DIDSAVE);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_WillClose(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_DOC_WILLCLOSE);
+ Initialize(JET_DOC_WILLCLOSE);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_PAGE_OPEN);
+ Initialize(JET_PAGE_OPEN);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_PAGE_CLOSE);
+ Initialize(JET_PAGE_CLOSE);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_InView(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_PAGE_INVIEW);
+ Initialize(JET_PAGE_INVIEW);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_OutView(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- Initial(JET_PAGE_OUTVIEW);
+ Initialize(JET_PAGE_OUTVIEW);
m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnField_MouseEnter(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) {
- Initial(JET_FIELD_MOUSEENTER);
+ Initialize(JET_FIELD_MOUSEENTER);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -115,7 +96,7 @@ void CJS_EventHandler::OnField_MouseEnter(bool bModifier,
void CJS_EventHandler::OnField_MouseExit(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) {
- Initial(JET_FIELD_MOUSEEXIT);
+ Initialize(JET_FIELD_MOUSEEXIT);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -125,7 +106,7 @@ void CJS_EventHandler::OnField_MouseExit(bool bModifier,
void CJS_EventHandler::OnField_MouseDown(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) {
- Initial(JET_FIELD_MOUSEDOWN);
+ Initialize(JET_FIELD_MOUSEDOWN);
m_eEventType = JET_FIELD_MOUSEDOWN;
m_bModifier = bModifier;
@@ -136,7 +117,7 @@ void CJS_EventHandler::OnField_MouseDown(bool bModifier,
void CJS_EventHandler::OnField_MouseUp(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) {
- Initial(JET_FIELD_MOUSEUP);
+ Initialize(JET_FIELD_MOUSEUP);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -147,7 +128,7 @@ void CJS_EventHandler::OnField_Focus(bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
const WideString& Value) {
- Initial(JET_FIELD_FOCUS);
+ Initialize(JET_FIELD_FOCUS);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -159,7 +140,7 @@ void CJS_EventHandler::OnField_Blur(bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
const WideString& Value) {
- Initial(JET_FIELD_BLUR);
+ Initialize(JET_FIELD_BLUR);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -179,7 +160,7 @@ void CJS_EventHandler::OnField_Keystroke(WideString& strChange,
bool bWillCommit,
bool bFieldFull,
bool& bRc) {
- Initial(JET_FIELD_KEYSTROKE);
+ Initialize(JET_FIELD_KEYSTROKE);
m_nCommitKey = 0;
m_pWideStrChange = &strChange;
@@ -204,7 +185,7 @@ void CJS_EventHandler::OnField_Validate(WideString& strChange,
CPDF_FormField* pTarget,
WideString& Value,
bool& bRc) {
- Initial(JET_FIELD_VALIDATE);
+ Initialize(JET_FIELD_VALIDATE);
m_pWideStrChange = &strChange;
m_WideStrChangeEx = strChangeEx;
@@ -220,7 +201,7 @@ void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource,
CPDF_FormField* pTarget,
WideString& Value,
bool& bRc) {
- Initial(JET_FIELD_CALCULATE);
+ Initialize(JET_FIELD_CALCULATE);
if (pSource)
m_strSourceName = pSource->GetFullName();
@@ -232,7 +213,7 @@ void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource,
void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget,
WideString& Value,
bool bWillCommit) {
- Initial(JET_FIELD_FORMAT);
+ Initialize(JET_FIELD_FORMAT);
m_nCommitKey = 0;
m_strTargetName = pTarget->GetFullName();
@@ -243,7 +224,7 @@ void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget,
void CJS_EventHandler::OnScreen_Focus(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_FOCUS);
+ Initialize(JET_SCREEN_FOCUS);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -253,7 +234,7 @@ void CJS_EventHandler::OnScreen_Focus(bool bModifier,
void CJS_EventHandler::OnScreen_Blur(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_BLUR);
+ Initialize(JET_SCREEN_BLUR);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -263,7 +244,7 @@ void CJS_EventHandler::OnScreen_Blur(bool bModifier,
void CJS_EventHandler::OnScreen_Open(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_OPEN);
+ Initialize(JET_SCREEN_OPEN);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -273,7 +254,7 @@ void CJS_EventHandler::OnScreen_Open(bool bModifier,
void CJS_EventHandler::OnScreen_Close(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_CLOSE);
+ Initialize(JET_SCREEN_CLOSE);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -283,7 +264,7 @@ void CJS_EventHandler::OnScreen_Close(bool bModifier,
void CJS_EventHandler::OnScreen_MouseDown(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_MOUSEDOWN);
+ Initialize(JET_SCREEN_MOUSEDOWN);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -293,7 +274,7 @@ void CJS_EventHandler::OnScreen_MouseDown(bool bModifier,
void CJS_EventHandler::OnScreen_MouseUp(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_MOUSEUP);
+ Initialize(JET_SCREEN_MOUSEUP);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -303,7 +284,7 @@ void CJS_EventHandler::OnScreen_MouseUp(bool bModifier,
void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_MOUSEENTER);
+ Initialize(JET_SCREEN_MOUSEENTER);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -313,7 +294,7 @@ void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier,
void CJS_EventHandler::OnScreen_MouseExit(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_MOUSEEXIT);
+ Initialize(JET_SCREEN_MOUSEEXIT);
m_bModifier = bModifier;
m_bShift = bShift;
@@ -323,7 +304,7 @@ void CJS_EventHandler::OnScreen_MouseExit(bool bModifier,
void CJS_EventHandler::OnScreen_InView(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_INVIEW);
+ Initialize(JET_SCREEN_INVIEW);
m_bModifier = bModifier;
m_bShift = bShift;
m_pTargetAnnot.Reset(pScreen);
@@ -332,7 +313,7 @@ void CJS_EventHandler::OnScreen_InView(bool bModifier,
void CJS_EventHandler::OnScreen_OutView(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
- Initial(JET_SCREEN_OUTVIEW);
+ Initialize(JET_SCREEN_OUTVIEW);
m_bModifier = bModifier;
m_bShift = bShift;
m_pTargetAnnot.Reset(pScreen);
@@ -340,38 +321,38 @@ void CJS_EventHandler::OnScreen_OutView(bool bModifier,
void CJS_EventHandler::OnLink_MouseUp(
CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
- Initial(JET_LINK_MOUSEUP);
+ Initialize(JET_LINK_MOUSEUP);
m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
}
void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
- Initial(JET_BOOKMARK_MOUSEUP);
+ Initialize(JET_BOOKMARK_MOUSEUP);
m_pTargetBookMark = pBookMark;
}
void CJS_EventHandler::OnMenu_Exec(
CPDFSDK_FormFillEnvironment* pTargetFormFillEnv,
const WideString& strTargetName) {
- Initial(JET_MENU_EXEC);
+ Initialize(JET_MENU_EXEC);
m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
m_strTargetName = strTargetName;
}
void CJS_EventHandler::OnExternal_Exec() {
- Initial(JET_EXTERNAL_EXEC);
+ Initialize(JET_EXTERNAL_EXEC);
}
void CJS_EventHandler::OnBatchExec(
CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
- Initial(JET_BATCH_EXEC);
+ Initialize(JET_BATCH_EXEC);
m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
}
void CJS_EventHandler::OnConsole_Exec() {
- Initial(JET_CONSOLE_EXEC);
+ Initialize(JET_CONSOLE_EXEC);
}
-void CJS_EventHandler::Initial(JS_EVENT_T type) {
+void CJS_EventHandler::Initialize(JS_EVENT_T type) {
m_eEventType = type;
m_strTargetName = L"";
diff --git a/fxjs/cjs_eventhandler.h b/fxjs/cjs_eventhandler.h
index 4087355405..aa02895924 100644
--- a/fxjs/cjs_eventhandler.h
+++ b/fxjs/cjs_eventhandler.h
@@ -140,7 +140,6 @@ class CJS_EventHandler {
void OnConsole_Exec();
void OnExternal_Exec();
- void Initial(JS_EVENT_T type);
void Destroy();
bool IsValid() const;
@@ -166,28 +165,39 @@ class CJS_EventHandler {
JS_EVENT_T EventType() const { return m_eEventType; }
+ void SetRCForTest(bool* pRC) { m_pbRc = pRC; }
+
+ void SetStrChangeForTest(WideString* pStrChange) {
+ m_pWideStrChange = pStrChange;
+ }
+
+ void ResetWillCommitForTest() { m_bWillCommit = false; }
+
+ UnownedPtr<WideString> m_pValue;
+
+ private:
+ void Initialize(JS_EVENT_T type);
UnownedPtr<CJS_EventContext> const m_pJSEventContext;
- JS_EVENT_T m_eEventType;
- bool m_bValid;
+ JS_EVENT_T m_eEventType = JET_UNKNOWN;
+ bool m_bValid = false;
WideString m_strTargetName;
WideString m_strSourceName;
UnownedPtr<WideString> m_pWideStrChange;
WideString m_WideStrChangeDu;
WideString m_WideStrChangeEx;
- int m_nCommitKey;
- bool m_bKeyDown;
- bool m_bModifier;
- bool m_bShift;
- int* m_pISelEnd;
- int m_nSelEndDu;
- int* m_pISelStart;
- int m_nSelStartDu;
- bool m_bWillCommit;
- UnownedPtr<WideString> m_pValue;
- bool m_bFieldFull;
- bool* m_pbRc;
- bool m_bRcDu;
+ int m_nCommitKey = -1;
+ bool m_bKeyDown = false;
+ bool m_bModifier = false;
+ bool m_bShift = false;
+ int* m_pISelEnd = nullptr;
+ int m_nSelEndDu = 0;
+ int* m_pISelStart = nullptr;
+ int m_nSelStartDu = 0;
+ bool m_bWillCommit = false;
+ bool m_bFieldFull = false;
+ bool* m_pbRc = nullptr;
+ bool m_bRcDu = false;
UnownedPtr<CPDF_Bookmark> m_pTargetBookMark;
CPDFSDK_FormFillEnvironment::ObservedPtr m_pTargetFormFillEnv;
diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp
index 9413aa6a46..38604555ae 100644
--- a/fxjs/cjs_publicmethods_embeddertest.cpp
+++ b/fxjs/cjs_publicmethods_embeddertest.cpp
@@ -224,10 +224,10 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFNumber_Keystroke) {
WideString change = L"";
handler->m_pValue = &result;
- handler->m_pbRc = &valid;
- handler->m_pWideStrChange = &change;
+ handler->SetRCForTest(&valid);
+ handler->SetStrChangeForTest(&change);
- handler->m_bWillCommit = 0;
+ handler->ResetWillCommitForTest();
handler->SetSelStart(0);
handler->SetSelEnd(0);
@@ -245,6 +245,6 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFNumber_Keystroke) {
// Keep the *SAN bots happy. One of these is an UnownedPtr, another seems to
// used during destruction. Clear them all to be safe and consistent.
handler->m_pValue = nullptr;
- handler->m_pbRc = nullptr;
- handler->m_pWideStrChange = nullptr;
+ handler->SetRCForTest(nullptr);
+ handler->SetStrChangeForTest(nullptr);
}