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