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/formfiller/FormFiller.h"
8#include "../../include/formfiller/FFL_FormFiller.h"
9#include "../../include/formfiller/FFL_Notify.h"
10// #include "../../include/formfiller/FFL_ComboBox.h"
11// #include "../../include/formfiller/FFL_Module.h"
12
13/* -------------------------------- CFFL_Notify ------------------------------ */
14
15//#pragma warning(disable: 4800)
16
17CFFL_Notify::CFFL_Notify(CFFL_FormFiller * pFormFiller) :
18	m_pFormFiller(pFormFiller),
19	m_bDoActioning(FALSE),
20	m_nNotifyFlag(0)
21{
22	ASSERT(m_pFormFiller != NULL);
23}
24
25CFFL_Notify::~CFFL_Notify()
26{
27}
28
29void CFFL_Notify::BeforeNotify()
30{
31	m_nNotifyFlag ++;
32}
33
34
35void CFFL_Notify::AfterNotify()
36{
37	m_nNotifyFlag --;
38}
39
40FX_BOOL CFFL_Notify::OnMouseUp(FX_BOOL & bExit)
41{
42	BeforeNotify();
43	FX_BOOL bRet = FALSE;//DoAAction(CPDF_AAction::AActionType::ButtonUp, bExit);
44	AfterNotify();
45	return bRet;
46}
47
48FX_BOOL CFFL_Notify::OnMouseDown(FX_BOOL & bExit)
49{
50	BeforeNotify();
51	FX_BOOL bRet = FALSE;//DoAAction(CPDF_AAction::AActionType::ButtonDown, bExit);
52	AfterNotify();
53	return bRet;
54}
55
56FX_BOOL CFFL_Notify::OnMouseEnter(FX_BOOL & bExit)
57{
58	BeforeNotify();
59	FX_BOOL bRet = FALSE;//DoAAction(CPDF_AAction::AActionType::CursorEnter, bExit);
60	AfterNotify();
61	return bRet;
62}
63
64FX_BOOL CFFL_Notify::OnMouseExit(FX_BOOL & bExit)
65{
66	BeforeNotify();
67	FX_BOOL bRet = FALSE;//DoAAction(CPDF_AAction::AActionType::CursorExit, bExit);
68	AfterNotify();
69	return bRet;
70}
71
72FX_BOOL CFFL_Notify::OnSetFocus(FX_BOOL & bExit)
73{
74	BeforeNotify();
75	FX_BOOL bRet = FALSE;//DoAAction(CPDF_AAction::AActionType::GetFocus, bExit);
76	AfterNotify();
77	return bRet;
78}
79
80FX_BOOL CFFL_Notify::OnKillFocus(FX_BOOL & bExit)
81{
82	BeforeNotify();
83	FX_BOOL bRet = FALSE;//DoAAction(CPDF_AAction::AActionType::LoseFocus, bExit);
84	AfterNotify();
85	return bRet;
86}
87
88FX_BOOL CFFL_Notify::OnCalculate()
89{
90	return TRUE;
91}
92
93FX_BOOL CFFL_Notify::OnFormat(int iCommitKey)
94{
95	return TRUE;
96}
97
98FX_BOOL CFFL_Notify::OnKeyStroke(CPDF_FormField* pFormField, int nCommitKey, CFX_WideString& strValue, CFX_WideString& strChange,
99							   const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL bModifier,
100							   FX_BOOL bShift, FX_BOOL bWillCommit, FX_BOOL bFieldFull,
101							   int& nSelStart, int& nSelEnd, FX_BOOL& bRC)
102{
103	return TRUE;
104}
105
106FX_BOOL CFFL_Notify::OnValidate(CPDF_FormField* pFormField, CFX_WideString& strValue, CFX_WideString & strChange,
107									   const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL bModifier,
108									   FX_BOOL bShift, FX_BOOL & bRC)
109{
110	return TRUE;
111}
112
113FX_BOOL	CFFL_Notify::DoAAction(CPDF_AAction::AActionType eAAT, FX_BOOL & bExit)
114{
115	if (this->m_bDoActioning) return FALSE;
116
117	CPDF_Action action;
118	if (!FindAAction(eAAT,action)) return FALSE;
119
120	this->m_bDoActioning = TRUE;
121	ExecuteActionTree(eAAT,action,bExit);
122	this->m_bDoActioning = FALSE;
123	return TRUE;
124}
125
126FX_BOOL	CFFL_Notify::ExecuteActionTree(CPDF_AAction::AActionType eAAT,CPDF_Action & action, FX_BOOL& bExit)
127{
128	if (!ExecuteAction(eAAT,action,bExit)) return FALSE;
129	if (bExit) return TRUE;
130
131	for (FX_INT32 i=0,sz=action.GetSubActionsCount(); i<sz; i++)
132	{
133		CPDF_Action subaction = action.GetSubAction(i);
134		if (!ExecuteActionTree(eAAT,subaction,bExit)) return FALSE;
135		if (bExit) break;
136	}
137
138	return TRUE;
139}
140
141
142FX_BOOL	CFFL_Notify::FindAAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action)
143{
144	return FALSE;
145}
146
147FX_BOOL CFFL_Notify::FindAAction(CPDF_AAction aaction,CPDF_AAction::AActionType eAAT,CPDF_Action & action)
148{
149	CPDF_Action MyAction;
150
151	if (aaction.ActionExist(eAAT))
152	{
153		MyAction = aaction.GetAction(eAAT);
154	}
155	else
156		return FALSE;
157
158
159	if (MyAction.GetType() == CPDF_Action::Unknown)
160		return FALSE;
161
162	action = MyAction;
163
164	return TRUE;
165}
166
167FX_BOOL	CFFL_Notify::ExecuteAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action,FX_BOOL& bExit)
168{
169	return FALSE;
170}
171//#pragma warning(default: 4800)
172
173