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