OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/include/fxfa/xfa_ffwidgethandler.h" | 7 #include "xfa/include/fxfa/xfa_ffwidgethandler.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "xfa/fxfa/app/xfa_ffchoicelist.h" | 11 #include "xfa/fxfa/app/xfa_ffchoicelist.h" |
12 #include "xfa/fxfa/app/xfa_fffield.h" | 12 #include "xfa/fxfa/app/xfa_fffield.h" |
13 #include "xfa/fxfa/app/xfa_ffwidget.h" | |
14 #include "xfa/fxfa/app/xfa_fwladapter.h" | 13 #include "xfa/fxfa/app/xfa_fwladapter.h" |
15 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 14 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
16 #include "xfa/fxfa/parser/xfa_parser.h" | 15 #include "xfa/fxfa/parser/xfa_parser.h" |
17 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 16 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
18 #include "xfa/include/fxfa/xfa_ffdoc.h" | 17 #include "xfa/include/fxfa/xfa_ffdoc.h" |
19 #include "xfa/include/fxfa/xfa_ffdocview.h" | 18 #include "xfa/include/fxfa/xfa_ffdocview.h" |
| 19 #include "xfa/include/fxfa/xfa_ffwidget.h" |
20 | 20 |
21 CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) | 21 CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) |
22 : m_pDocView(pDocView) {} | 22 : m_pDocView(pDocView) {} |
23 | 23 |
24 CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} | 24 CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} |
25 | 25 |
26 CXFA_FFPageView* CXFA_FFWidgetHandler::GetPageView(CXFA_FFWidget* hWidget) { | |
27 return hWidget->GetPageView(); | |
28 } | |
29 void CXFA_FFWidgetHandler::GetRect(CXFA_FFWidget* hWidget, CFX_RectF& rt) { | |
30 hWidget->GetWidgetRect(rt); | |
31 } | |
32 uint32_t CXFA_FFWidgetHandler::GetStatus(CXFA_FFWidget* hWidget) { | |
33 return hWidget->GetStatus(); | |
34 } | |
35 FX_BOOL CXFA_FFWidgetHandler::GetBBox(CXFA_FFWidget* hWidget, | |
36 CFX_RectF& rtBox, | |
37 uint32_t dwStatus, | |
38 FX_BOOL bDrawFocus) { | |
39 return hWidget->GetBBox(rtBox, dwStatus, bDrawFocus); | |
40 } | |
41 CXFA_WidgetAcc* CXFA_FFWidgetHandler::GetDataAcc(CXFA_FFWidget* hWidget) { | |
42 return hWidget->GetDataAcc(); | |
43 } | |
44 void CXFA_FFWidgetHandler::GetName(CXFA_FFWidget* hWidget, | |
45 CFX_WideString& wsName, | |
46 int32_t iNameType) { | |
47 hWidget->GetDataAcc()->GetName(wsName, iNameType); | |
48 } | |
49 FX_BOOL CXFA_FFWidgetHandler::GetToolTip(CXFA_FFWidget* hWidget, | |
50 CFX_WideString& wsToolTip) { | |
51 return hWidget->GetToolTip(wsToolTip); | |
52 } | |
53 void CXFA_FFWidgetHandler::SetPrivateData(CXFA_FFWidget* hWidget, | |
54 void* module_id, | |
55 void* pData, | |
56 PD_CALLBACK_FREEDATA callback) { | |
57 hWidget->SetPrivateData(module_id, pData, callback); | |
58 } | |
59 void* CXFA_FFWidgetHandler::GetPrivateData(CXFA_FFWidget* hWidget, | |
60 void* module_id) { | |
61 return hWidget->GetPrivateData(module_id); | |
62 } | |
63 FX_BOOL CXFA_FFWidgetHandler::OnMouseEnter(CXFA_FFWidget* hWidget) { | 26 FX_BOOL CXFA_FFWidgetHandler::OnMouseEnter(CXFA_FFWidget* hWidget) { |
64 m_pDocView->LockUpdate(); | 27 m_pDocView->LockUpdate(); |
65 FX_BOOL bRet = hWidget->OnMouseEnter(); | 28 FX_BOOL bRet = hWidget->OnMouseEnter(); |
66 m_pDocView->UnlockUpdate(); | 29 m_pDocView->UnlockUpdate(); |
67 m_pDocView->UpdateDocView(); | 30 m_pDocView->UpdateDocView(); |
68 return bRet; | 31 return bRet; |
69 } | 32 } |
| 33 |
70 FX_BOOL CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { | 34 FX_BOOL CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { |
71 m_pDocView->LockUpdate(); | 35 m_pDocView->LockUpdate(); |
72 FX_BOOL bRet = hWidget->OnMouseExit(); | 36 FX_BOOL bRet = hWidget->OnMouseExit(); |
73 m_pDocView->UnlockUpdate(); | 37 m_pDocView->UnlockUpdate(); |
74 m_pDocView->UpdateDocView(); | 38 m_pDocView->UpdateDocView(); |
75 return bRet; | 39 return bRet; |
76 } | 40 } |
| 41 |
77 FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, | 42 FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, |
78 uint32_t dwFlags, | 43 uint32_t dwFlags, |
79 FX_FLOAT fx, | 44 FX_FLOAT fx, |
80 FX_FLOAT fy) { | 45 FX_FLOAT fy) { |
81 m_pDocView->LockUpdate(); | 46 m_pDocView->LockUpdate(); |
82 hWidget->Rotate2Normal(fx, fy); | 47 hWidget->Rotate2Normal(fx, fy); |
83 FX_BOOL bRet = hWidget->OnLButtonDown(dwFlags, fx, fy); | 48 FX_BOOL bRet = hWidget->OnLButtonDown(dwFlags, fx, fy); |
84 if (bRet && m_pDocView->SetFocus(hWidget)) { | 49 if (bRet && m_pDocView->SetFocus(hWidget)) { |
85 ((CXFA_FFDoc*)m_pDocView->GetDoc()) | 50 ((CXFA_FFDoc*)m_pDocView->GetDoc()) |
86 ->GetDocProvider() | 51 ->GetDocProvider() |
87 ->SetFocusWidget(m_pDocView->GetDoc(), (CXFA_FFWidget*)hWidget); | 52 ->SetFocusWidget(m_pDocView->GetDoc(), (CXFA_FFWidget*)hWidget); |
88 } | 53 } |
89 m_pDocView->UnlockUpdate(); | 54 m_pDocView->UnlockUpdate(); |
90 m_pDocView->UpdateDocView(); | 55 m_pDocView->UpdateDocView(); |
91 return bRet; | 56 return bRet; |
92 } | 57 } |
| 58 |
93 FX_BOOL CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, | 59 FX_BOOL CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, |
94 uint32_t dwFlags, | 60 uint32_t dwFlags, |
95 FX_FLOAT fx, | 61 FX_FLOAT fx, |
96 FX_FLOAT fy) { | 62 FX_FLOAT fy) { |
97 m_pDocView->LockUpdate(); | 63 m_pDocView->LockUpdate(); |
98 hWidget->Rotate2Normal(fx, fy); | 64 hWidget->Rotate2Normal(fx, fy); |
99 m_pDocView->m_bLayoutEvent = TRUE; | 65 m_pDocView->m_bLayoutEvent = TRUE; |
100 FX_BOOL bRet = hWidget->OnLButtonUp(dwFlags, fx, fy); | 66 FX_BOOL bRet = hWidget->OnLButtonUp(dwFlags, fx, fy); |
101 m_pDocView->UnlockUpdate(); | 67 m_pDocView->UnlockUpdate(); |
102 m_pDocView->UpdateDocView(); | 68 m_pDocView->UpdateDocView(); |
103 return bRet; | 69 return bRet; |
104 } | 70 } |
| 71 |
105 FX_BOOL CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, | 72 FX_BOOL CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, |
106 uint32_t dwFlags, | 73 uint32_t dwFlags, |
107 FX_FLOAT fx, | 74 FX_FLOAT fx, |
108 FX_FLOAT fy) { | 75 FX_FLOAT fy) { |
109 hWidget->Rotate2Normal(fx, fy); | 76 hWidget->Rotate2Normal(fx, fy); |
110 FX_BOOL bRet = hWidget->OnLButtonDblClk(dwFlags, fx, fy); | 77 FX_BOOL bRet = hWidget->OnLButtonDblClk(dwFlags, fx, fy); |
111 m_pDocView->RunInvalidate(); | 78 m_pDocView->RunInvalidate(); |
112 return bRet; | 79 return bRet; |
113 } | 80 } |
| 81 |
114 FX_BOOL CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, | 82 FX_BOOL CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, |
115 uint32_t dwFlags, | 83 uint32_t dwFlags, |
116 FX_FLOAT fx, | 84 FX_FLOAT fx, |
117 FX_FLOAT fy) { | 85 FX_FLOAT fy) { |
118 hWidget->Rotate2Normal(fx, fy); | 86 hWidget->Rotate2Normal(fx, fy); |
119 FX_BOOL bRet = hWidget->OnMouseMove(dwFlags, fx, fy); | 87 FX_BOOL bRet = hWidget->OnMouseMove(dwFlags, fx, fy); |
120 m_pDocView->RunInvalidate(); | 88 m_pDocView->RunInvalidate(); |
121 return bRet; | 89 return bRet; |
122 } | 90 } |
| 91 |
123 FX_BOOL CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, | 92 FX_BOOL CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, |
124 uint32_t dwFlags, | 93 uint32_t dwFlags, |
125 int16_t zDelta, | 94 int16_t zDelta, |
126 FX_FLOAT fx, | 95 FX_FLOAT fx, |
127 FX_FLOAT fy) { | 96 FX_FLOAT fy) { |
128 hWidget->Rotate2Normal(fx, fy); | 97 hWidget->Rotate2Normal(fx, fy); |
129 FX_BOOL bRet = hWidget->OnMouseWheel(dwFlags, zDelta, fx, fy); | 98 FX_BOOL bRet = hWidget->OnMouseWheel(dwFlags, zDelta, fx, fy); |
130 m_pDocView->RunInvalidate(); | 99 m_pDocView->RunInvalidate(); |
131 return bRet; | 100 return bRet; |
132 } | 101 } |
| 102 |
133 FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, | 103 FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, |
134 uint32_t dwFlags, | 104 uint32_t dwFlags, |
135 FX_FLOAT fx, | 105 FX_FLOAT fx, |
136 FX_FLOAT fy) { | 106 FX_FLOAT fy) { |
137 hWidget->Rotate2Normal(fx, fy); | 107 hWidget->Rotate2Normal(fx, fy); |
138 FX_BOOL bRet = hWidget->OnRButtonDown(dwFlags, fx, fy); | 108 FX_BOOL bRet = hWidget->OnRButtonDown(dwFlags, fx, fy); |
139 if (bRet && m_pDocView->SetFocus(hWidget)) { | 109 if (bRet && m_pDocView->SetFocus(hWidget)) { |
140 ((CXFA_FFDoc*)m_pDocView->GetDoc()) | 110 ((CXFA_FFDoc*)m_pDocView->GetDoc()) |
141 ->GetDocProvider() | 111 ->GetDocProvider() |
142 ->SetFocusWidget(m_pDocView->GetDoc(), (CXFA_FFWidget*)hWidget); | 112 ->SetFocusWidget(m_pDocView->GetDoc(), (CXFA_FFWidget*)hWidget); |
143 } | 113 } |
144 m_pDocView->RunInvalidate(); | 114 m_pDocView->RunInvalidate(); |
145 return bRet; | 115 return bRet; |
146 } | 116 } |
| 117 |
147 FX_BOOL CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, | 118 FX_BOOL CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, |
148 uint32_t dwFlags, | 119 uint32_t dwFlags, |
149 FX_FLOAT fx, | 120 FX_FLOAT fx, |
150 FX_FLOAT fy) { | 121 FX_FLOAT fy) { |
151 hWidget->Rotate2Normal(fx, fy); | 122 hWidget->Rotate2Normal(fx, fy); |
152 FX_BOOL bRet = hWidget->OnRButtonUp(dwFlags, fx, fy); | 123 FX_BOOL bRet = hWidget->OnRButtonUp(dwFlags, fx, fy); |
153 m_pDocView->RunInvalidate(); | 124 m_pDocView->RunInvalidate(); |
154 return bRet; | 125 return bRet; |
155 } | 126 } |
| 127 |
156 FX_BOOL CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, | 128 FX_BOOL CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, |
157 uint32_t dwFlags, | 129 uint32_t dwFlags, |
158 FX_FLOAT fx, | 130 FX_FLOAT fx, |
159 FX_FLOAT fy) { | 131 FX_FLOAT fy) { |
160 hWidget->Rotate2Normal(fx, fy); | 132 hWidget->Rotate2Normal(fx, fy); |
161 FX_BOOL bRet = hWidget->OnRButtonDblClk(dwFlags, fx, fy); | 133 FX_BOOL bRet = hWidget->OnRButtonDblClk(dwFlags, fx, fy); |
162 m_pDocView->RunInvalidate(); | 134 m_pDocView->RunInvalidate(); |
163 return bRet; | 135 return bRet; |
164 } | 136 } |
| 137 |
165 FX_BOOL CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget, | 138 FX_BOOL CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget, |
166 uint32_t dwKeyCode, | 139 uint32_t dwKeyCode, |
167 uint32_t dwFlags) { | 140 uint32_t dwFlags) { |
168 FX_BOOL bRet = hWidget->OnKeyDown(dwKeyCode, dwFlags); | 141 FX_BOOL bRet = hWidget->OnKeyDown(dwKeyCode, dwFlags); |
169 m_pDocView->RunInvalidate(); | 142 m_pDocView->RunInvalidate(); |
170 m_pDocView->UpdateDocView(); | 143 m_pDocView->UpdateDocView(); |
171 return bRet; | 144 return bRet; |
172 } | 145 } |
| 146 |
173 FX_BOOL CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget, | 147 FX_BOOL CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget, |
174 uint32_t dwKeyCode, | 148 uint32_t dwKeyCode, |
175 uint32_t dwFlags) { | 149 uint32_t dwFlags) { |
176 FX_BOOL bRet = hWidget->OnKeyUp(dwKeyCode, dwFlags); | 150 FX_BOOL bRet = hWidget->OnKeyUp(dwKeyCode, dwFlags); |
177 m_pDocView->RunInvalidate(); | 151 m_pDocView->RunInvalidate(); |
178 return bRet; | 152 return bRet; |
179 } | 153 } |
| 154 |
180 FX_BOOL CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, | 155 FX_BOOL CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, |
181 uint32_t dwChar, | 156 uint32_t dwChar, |
182 uint32_t dwFlags) { | 157 uint32_t dwFlags) { |
183 FX_BOOL bRet = hWidget->OnChar(dwChar, dwFlags); | 158 FX_BOOL bRet = hWidget->OnChar(dwChar, dwFlags); |
184 m_pDocView->RunInvalidate(); | 159 m_pDocView->RunInvalidate(); |
185 return bRet; | 160 return bRet; |
186 } | 161 } |
| 162 |
187 uint32_t CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, | 163 uint32_t CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, |
188 FX_FLOAT fx, | 164 FX_FLOAT fx, |
189 FX_FLOAT fy) { | 165 FX_FLOAT fy) { |
190 if (!(hWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) | 166 if (!(hWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) |
191 return FWL_WGTHITTEST_Unknown; | 167 return FWL_WGTHITTEST_Unknown; |
192 | 168 |
193 hWidget->Rotate2Normal(fx, fy); | 169 hWidget->Rotate2Normal(fx, fy); |
194 return hWidget->OnHitTest(fx, fy); | 170 return hWidget->OnHitTest(fx, fy); |
195 } | 171 } |
| 172 |
196 FX_BOOL CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget, | 173 FX_BOOL CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget, |
197 FX_FLOAT fx, | 174 FX_FLOAT fx, |
198 FX_FLOAT fy) { | 175 FX_FLOAT fy) { |
199 hWidget->Rotate2Normal(fx, fy); | 176 hWidget->Rotate2Normal(fx, fy); |
200 return hWidget->OnSetCursor(fx, fy); | 177 return hWidget->OnSetCursor(fx, fy); |
201 } | 178 } |
| 179 |
202 void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, | 180 void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, |
203 CFX_Graphics* pGS, | 181 CFX_Graphics* pGS, |
204 CFX_Matrix* pMatrix, | 182 CFX_Matrix* pMatrix, |
205 FX_BOOL bHighlight) { | 183 FX_BOOL bHighlight) { |
206 hWidget->RenderWidget(pGS, pMatrix, | 184 hWidget->RenderWidget(pGS, pMatrix, |
207 bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0); | 185 bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0); |
208 } | 186 } |
| 187 |
209 FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, | 188 FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, |
210 XFA_EVENTTYPE eEventType) { | 189 XFA_EVENTTYPE eEventType) { |
211 if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) { | 190 if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) |
212 return FALSE; | 191 return FALSE; |
213 } | 192 if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) |
214 if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { | |
215 return FALSE; | 193 return FALSE; |
216 } | 194 |
217 switch (eEventType) { | 195 switch (eEventType) { |
218 case XFA_EVENT_Calculate: { | 196 case XFA_EVENT_Calculate: { |
219 CXFA_Calculate calc = pWidgetAcc->GetCalculate(); | 197 CXFA_Calculate calc = pWidgetAcc->GetCalculate(); |
220 if (!calc) { | 198 if (!calc) |
221 return FALSE; | 199 return FALSE; |
222 } | 200 if (calc.GetScript()) |
223 if (calc.GetScript()) { | |
224 return TRUE; | 201 return TRUE; |
225 } | |
226 return FALSE; | 202 return FALSE; |
227 } | 203 } |
228 case XFA_EVENT_Validate: { | 204 case XFA_EVENT_Validate: { |
229 CXFA_Validate val = pWidgetAcc->GetValidate(); | 205 CXFA_Validate val = pWidgetAcc->GetValidate(); |
230 if (!val) { | 206 if (!val) |
231 return FALSE; | 207 return FALSE; |
232 } | 208 if (val.GetScript()) |
233 if (val.GetScript()) { | |
234 return TRUE; | 209 return TRUE; |
235 } | |
236 return FALSE; | 210 return FALSE; |
237 } | 211 } |
238 default: | 212 default: |
239 break; | 213 break; |
240 } | 214 } |
241 CXFA_NodeArray eventArray; | 215 CXFA_NodeArray eventArray; |
242 return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], | 216 return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], |
243 eventArray); | 217 eventArray); |
244 } | 218 } |
| 219 |
245 int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, | 220 int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, |
246 CXFA_EventParam* pParam) { | 221 CXFA_EventParam* pParam) { |
247 if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { | 222 if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) |
248 return XFA_EVENTERROR_NotExist; | 223 return XFA_EVENTERROR_NotExist; |
249 } | 224 if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) |
250 if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) { | |
251 return XFA_EVENTERROR_NotExist; | 225 return XFA_EVENTERROR_NotExist; |
252 } | 226 |
253 switch (pParam->m_eType) { | 227 switch (pParam->m_eType) { |
254 case XFA_EVENT_Calculate: | 228 case XFA_EVENT_Calculate: |
255 return pWidgetAcc->ProcessCalculate(); | 229 return pWidgetAcc->ProcessCalculate(); |
256 case XFA_EVENT_Validate: | 230 case XFA_EVENT_Validate: |
257 if (((CXFA_FFDoc*)m_pDocView->GetDoc()) | 231 if (((CXFA_FFDoc*)m_pDocView->GetDoc()) |
258 ->GetDocProvider() | 232 ->GetDocProvider() |
259 ->IsValidationsEnabled(m_pDocView->GetDoc())) { | 233 ->IsValidationsEnabled(m_pDocView->GetDoc())) { |
260 return pWidgetAcc->ProcessValidate(); | 234 return pWidgetAcc->ProcessValidate(); |
261 } | 235 } |
262 return XFA_EVENTERROR_Disabled; | 236 return XFA_EVENTERROR_Disabled; |
263 case XFA_EVENT_InitCalculate: { | 237 case XFA_EVENT_InitCalculate: { |
264 CXFA_Calculate calc = pWidgetAcc->GetCalculate(); | 238 CXFA_Calculate calc = pWidgetAcc->GetCalculate(); |
265 if (!calc) { | 239 if (!calc) |
266 return XFA_EVENTERROR_NotExist; | 240 return XFA_EVENTERROR_NotExist; |
267 } | 241 if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) |
268 if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | |
269 return XFA_EVENTERROR_Disabled; | 242 return XFA_EVENTERROR_Disabled; |
270 } | 243 |
271 CXFA_Script script = calc.GetScript(); | 244 CXFA_Script script = calc.GetScript(); |
272 return pWidgetAcc->ExecuteScript(script, pParam); | 245 return pWidgetAcc->ExecuteScript(script, pParam); |
273 } | 246 } |
274 default: | 247 default: |
275 break; | 248 break; |
276 } | 249 } |
277 int32_t iRet = | 250 int32_t iRet = |
278 pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); | 251 pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); |
279 return iRet; | 252 return iRet; |
280 } | 253 } |
| 254 |
281 CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, | 255 CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, |
282 XFA_WIDGETTYPE eType, | 256 XFA_WIDGETTYPE eType, |
283 CXFA_FFWidget* hBefore) { | 257 CXFA_FFWidget* hBefore) { |
284 CXFA_Node* pParentFormItem = | 258 CXFA_Node* pParentFormItem = |
285 hParent ? hParent->GetDataAcc()->GetNode() : nullptr; | 259 hParent ? hParent->GetDataAcc()->GetNode() : nullptr; |
286 CXFA_Node* pBeforeFormItem = | 260 CXFA_Node* pBeforeFormItem = |
287 hBefore ? hBefore->GetDataAcc()->GetNode() : nullptr; | 261 hBefore ? hBefore->GetDataAcc()->GetNode() : nullptr; |
288 CXFA_Node* pNewFormItem = | 262 CXFA_Node* pNewFormItem = |
289 CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); | 263 CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); |
290 if (pNewFormItem == NULL) { | 264 if (!pNewFormItem) |
291 return NULL; | 265 return nullptr; |
292 } | 266 |
293 pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized); | 267 pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized); |
294 pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized); | 268 pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized); |
295 m_pDocView->RunLayout(); | 269 m_pDocView->RunLayout(); |
296 CXFA_LayoutItem* pLayout = | 270 CXFA_LayoutItem* pLayout = |
297 m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); | 271 m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); |
298 return (CXFA_FFWidget*)pLayout; | 272 return (CXFA_FFWidget*)pLayout; |
299 } | 273 } |
| 274 |
300 CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( | 275 CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( |
301 XFA_WIDGETTYPE eType, | 276 XFA_WIDGETTYPE eType, |
302 CXFA_Node* pParent, | 277 CXFA_Node* pParent, |
303 CXFA_Node* pBefore) const { | 278 CXFA_Node* pBefore) const { |
304 switch (eType) { | 279 switch (eType) { |
305 case XFA_WIDGETTYPE_Barcode: | 280 case XFA_WIDGETTYPE_Barcode: |
306 return NULL; | 281 return nullptr; |
307 case XFA_WIDGETTYPE_PushButton: | 282 case XFA_WIDGETTYPE_PushButton: |
308 return CreatePushButton(pParent, pBefore); | 283 return CreatePushButton(pParent, pBefore); |
309 case XFA_WIDGETTYPE_CheckButton: | 284 case XFA_WIDGETTYPE_CheckButton: |
310 return CreateCheckButton(pParent, pBefore); | 285 return CreateCheckButton(pParent, pBefore); |
311 case XFA_WIDGETTYPE_ExcludeGroup: | 286 case XFA_WIDGETTYPE_ExcludeGroup: |
312 return CreateExclGroup(pParent, pBefore); | 287 return CreateExclGroup(pParent, pBefore); |
313 case XFA_WIDGETTYPE_RadioButton: | 288 case XFA_WIDGETTYPE_RadioButton: |
314 return CreateRadioButton(pParent, pBefore); | 289 return CreateRadioButton(pParent, pBefore); |
315 case XFA_WIDGETTYPE_Arc: | 290 case XFA_WIDGETTYPE_Arc: |
316 return CreateArc(pParent, pBefore); | 291 return CreateArc(pParent, pBefore); |
(...skipping 19 matching lines...) Expand all Loading... |
336 return CreateDropdownList(pParent, pBefore); | 311 return CreateDropdownList(pParent, pBefore); |
337 case XFA_WIDGETTYPE_ListBox: | 312 case XFA_WIDGETTYPE_ListBox: |
338 return CreateListBox(pParent, pBefore); | 313 return CreateListBox(pParent, pBefore); |
339 case XFA_WIDGETTYPE_ImageField: | 314 case XFA_WIDGETTYPE_ImageField: |
340 return CreateImageField(pParent, pBefore); | 315 return CreateImageField(pParent, pBefore); |
341 case XFA_WIDGETTYPE_PasswordEdit: | 316 case XFA_WIDGETTYPE_PasswordEdit: |
342 return CreatePasswordEdit(pParent, pBefore); | 317 return CreatePasswordEdit(pParent, pBefore); |
343 case XFA_WIDGETTYPE_Subform: | 318 case XFA_WIDGETTYPE_Subform: |
344 return CreateSubform(pParent, pBefore); | 319 return CreateSubform(pParent, pBefore); |
345 default: | 320 default: |
346 break; | 321 return nullptr; |
347 } | 322 } |
348 return NULL; | |
349 } | 323 } |
| 324 |
350 CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, | 325 CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, |
351 CXFA_Node* pBefore) const { | 326 CXFA_Node* pBefore) const { |
352 CXFA_Node* pField = CreateField(XFA_ELEMENT_Button, pParent, pBefore); | 327 CXFA_Node* pField = CreateField(XFA_ELEMENT_Button, pParent, pBefore); |
353 CXFA_Node* pCaption = CreateCopyNode(XFA_ELEMENT_Caption, pField); | 328 CXFA_Node* pCaption = CreateCopyNode(XFA_ELEMENT_Caption, pField); |
354 CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pCaption); | 329 CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pCaption); |
355 CXFA_Node* pText = CreateCopyNode(XFA_ELEMENT_Text, pValue); | 330 CXFA_Node* pText = CreateCopyNode(XFA_ELEMENT_Text, pValue); |
356 pText->SetContent(FX_WSTRC(L"Button"), FX_WSTRC(L"Button"), FALSE); | 331 pText->SetContent(FX_WSTRC(L"Button"), FX_WSTRC(L"Button"), FALSE); |
| 332 |
357 CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption); | 333 CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption); |
358 pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE); | 334 pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE); |
359 pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE); | 335 pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE); |
360 CreateFontNode(pCaption); | 336 CreateFontNode(pCaption); |
| 337 |
361 CXFA_Node* pBorder = CreateCopyNode(XFA_ELEMENT_Border, pField); | 338 CXFA_Node* pBorder = CreateCopyNode(XFA_ELEMENT_Border, pField); |
362 pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE); | 339 pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE); |
| 340 |
363 CXFA_Node* pEdge = CreateCopyNode(XFA_ELEMENT_Edge, pBorder); | 341 CXFA_Node* pEdge = CreateCopyNode(XFA_ELEMENT_Edge, pBorder); |
364 pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE); | 342 pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE); |
| 343 |
365 CXFA_Node* pFill = CreateCopyNode(XFA_ELEMENT_Fill, pBorder); | 344 CXFA_Node* pFill = CreateCopyNode(XFA_ELEMENT_Fill, pBorder); |
366 CXFA_Node* pColor = CreateCopyNode(XFA_ELEMENT_Color, pFill); | 345 CXFA_Node* pColor = CreateCopyNode(XFA_ELEMENT_Color, pFill); |
367 pColor->SetCData(XFA_ATTRIBUTE_Value, FX_WSTRC(L"212, 208, 200"), FALSE); | 346 pColor->SetCData(XFA_ATTRIBUTE_Value, FX_WSTRC(L"212, 208, 200"), FALSE); |
| 347 |
368 CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); | 348 CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); |
369 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); | 349 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); |
| 350 |
370 return pField; | 351 return pField; |
371 } | 352 } |
| 353 |
372 CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, | 354 CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, |
373 CXFA_Node* pBefore) const { | 355 CXFA_Node* pBefore) const { |
374 CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); | 356 return CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); |
375 return pField; | |
376 } | 357 } |
| 358 |
377 CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, | 359 CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, |
378 CXFA_Node* pBefore) const { | 360 CXFA_Node* pBefore) const { |
379 return CreateFormItem(XFA_ELEMENT_ExclGroup, pParent, pBefore); | 361 return CreateFormItem(XFA_ELEMENT_ExclGroup, pParent, pBefore); |
380 } | 362 } |
| 363 |
381 CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, | 364 CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, |
382 CXFA_Node* pBefore) const { | 365 CXFA_Node* pBefore) const { |
383 CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); | 366 CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); |
384 CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_ELEMENT_Ui); | 367 CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_ELEMENT_Ui); |
385 CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_ELEMENT_CheckButton); | 368 CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_ELEMENT_CheckButton); |
386 pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); | 369 pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); |
387 return pField; | 370 return pField; |
388 } | 371 } |
| 372 |
389 CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, | 373 CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, |
390 CXFA_Node* pBefore) const { | 374 CXFA_Node* pBefore) const { |
391 CXFA_Node* pField = CreateField(XFA_ELEMENT_DateTimeEdit, pParent, pBefore); | 375 CXFA_Node* pField = CreateField(XFA_ELEMENT_DateTimeEdit, pParent, pBefore); |
392 CreateValueNode(XFA_ELEMENT_Date, pField); | 376 CreateValueNode(XFA_ELEMENT_Date, pField); |
393 return pField; | 377 return pField; |
394 } | 378 } |
| 379 |
395 CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, | 380 CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, |
396 CXFA_Node* pBefore) const { | 381 CXFA_Node* pBefore) const { |
397 CXFA_Node* pField = CreateNumericField(pParent, pBefore); | 382 CXFA_Node* pField = CreateNumericField(pParent, pBefore); |
398 CreateValueNode(XFA_ELEMENT_Decimal, pField); | 383 CreateValueNode(XFA_ELEMENT_Decimal, pField); |
399 return pField; | 384 return pField; |
400 } | 385 } |
| 386 |
401 CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, | 387 CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, |
402 CXFA_Node* pBefore) const { | 388 CXFA_Node* pBefore) const { |
403 CXFA_Node* pField = CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); | 389 return CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); |
404 return pField; | |
405 } | 390 } |
| 391 |
406 CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, | 392 CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, |
407 CXFA_Node* pBefore) const { | 393 CXFA_Node* pBefore) const { |
408 CXFA_Node* pField = CreateField(XFA_ELEMENT_Signature, pParent, pBefore); | 394 return CreateField(XFA_ELEMENT_Signature, pParent, pBefore); |
409 return pField; | |
410 } | 395 } |
| 396 |
411 CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, | 397 CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, |
412 CXFA_Node* pBefore) const { | 398 CXFA_Node* pBefore) const { |
413 CXFA_Node* pField = CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); | 399 return CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); |
414 return pField; | |
415 } | 400 } |
| 401 |
416 CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, | 402 CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, |
417 CXFA_Node* pBefore) const { | 403 CXFA_Node* pBefore) const { |
418 CXFA_Node* pField = CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); | 404 return CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); |
419 return pField; | |
420 } | 405 } |
| 406 |
421 CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, | 407 CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, |
422 CXFA_Node* pBefore) const { | 408 CXFA_Node* pBefore) const { |
423 CXFA_Node* pField = CreateDropdownList(pParent, pBefore); | 409 CXFA_Node* pField = CreateDropdownList(pParent, pBefore); |
424 CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); | 410 CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); |
425 CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); | 411 CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); |
426 pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); | 412 pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); |
427 pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); | 413 pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); |
428 return pField; | 414 return pField; |
429 } | 415 } |
| 416 |
430 CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, | 417 CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, |
431 CXFA_Node* pBefore) const { | 418 CXFA_Node* pBefore) const { |
432 CXFA_Node* pField = CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); | 419 return CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); |
433 return pField; | |
434 } | 420 } |
| 421 |
435 CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, | 422 CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, |
436 CXFA_Node* pBefore) const { | 423 CXFA_Node* pBefore) const { |
437 CXFA_Node* pField = CreateField(XFA_ELEMENT_PasswordEdit, pParent, pBefore); | 424 CXFA_Node* pField = CreateField(XFA_ELEMENT_PasswordEdit, pParent, pBefore); |
438 CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); | 425 CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); |
439 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE); | 426 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE); |
440 return pField; | 427 return pField; |
441 } | 428 } |
| 429 |
442 CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, | 430 CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, |
443 CXFA_Node* pParent, | 431 CXFA_Node* pParent, |
444 CXFA_Node* pBefore) const { | 432 CXFA_Node* pBefore) const { |
445 CXFA_Node* pField = CreateFormItem(XFA_ELEMENT_Field, pParent, pBefore); | 433 CXFA_Node* pField = CreateFormItem(XFA_ELEMENT_Field, pParent, pBefore); |
446 CreateCopyNode(eElement, CreateCopyNode(XFA_ELEMENT_Ui, pField)); | 434 CreateCopyNode(eElement, CreateCopyNode(XFA_ELEMENT_Ui, pField)); |
447 CreateFontNode(pField); | 435 CreateFontNode(pField); |
448 return pField; | 436 return pField; |
449 } | 437 } |
| 438 |
450 CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, | 439 CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, |
451 CXFA_Node* pBefore) const { | 440 CXFA_Node* pBefore) const { |
452 return CreateDraw(XFA_ELEMENT_Arc, pParent, pBefore); | 441 return CreateDraw(XFA_ELEMENT_Arc, pParent, pBefore); |
453 } | 442 } |
| 443 |
454 CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, | 444 CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, |
455 CXFA_Node* pBefore) const { | 445 CXFA_Node* pBefore) const { |
456 return CreateDraw(XFA_ELEMENT_Rectangle, pParent, pBefore); | 446 return CreateDraw(XFA_ELEMENT_Rectangle, pParent, pBefore); |
457 } | 447 } |
| 448 |
458 CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, | 449 CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, |
459 CXFA_Node* pBefore) const { | 450 CXFA_Node* pBefore) const { |
460 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Image, pParent, pBefore); | 451 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Image, pParent, pBefore); |
461 CreateCopyNode(XFA_ELEMENT_ImageEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); | 452 CreateCopyNode(XFA_ELEMENT_ImageEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); |
462 return pField; | 453 return pField; |
463 } | 454 } |
| 455 |
464 CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, | 456 CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, |
465 CXFA_Node* pBefore) const { | 457 CXFA_Node* pBefore) const { |
466 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); | 458 return CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); |
467 return pField; | |
468 } | 459 } |
| 460 |
469 CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, | 461 CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, |
470 CXFA_Node* pBefore) const { | 462 CXFA_Node* pBefore) const { |
471 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Text, pParent, pBefore); | 463 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Text, pParent, pBefore); |
472 CreateCopyNode(XFA_ELEMENT_TextEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); | 464 CreateCopyNode(XFA_ELEMENT_TextEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); |
473 CreateFontNode(pField); | 465 CreateFontNode(pField); |
474 return pField; | 466 return pField; |
475 } | 467 } |
| 468 |
476 CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, | 469 CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, |
477 CXFA_Node* pParent, | 470 CXFA_Node* pParent, |
478 CXFA_Node* pBefore) const { | 471 CXFA_Node* pBefore) const { |
479 CXFA_Node* pDraw = CreateFormItem(XFA_ELEMENT_Draw, pParent, pBefore); | 472 CXFA_Node* pDraw = CreateFormItem(XFA_ELEMENT_Draw, pParent, pBefore); |
480 CreateValueNode(eElement, pDraw); | 473 CreateValueNode(eElement, pDraw); |
481 return pDraw; | 474 return pDraw; |
482 } | 475 } |
| 476 |
483 CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, | 477 CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, |
484 CXFA_Node* pBefore) const { | 478 CXFA_Node* pBefore) const { |
485 CXFA_Node* pSubform = CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); | 479 return CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); |
486 return pSubform; | |
487 } | 480 } |
| 481 |
488 CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, | 482 CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, |
489 CXFA_Node* pParent, | 483 CXFA_Node* pParent, |
490 CXFA_Node* pBefore) const { | 484 CXFA_Node* pBefore) const { |
491 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; | 485 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; |
492 CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(FALSE); | 486 CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(FALSE); |
493 if (pParent) | 487 if (pParent) |
494 pParent->InsertChild(pNewFormItem, pBefore); | 488 pParent->InsertChild(pNewFormItem, pBefore); |
495 return pNewFormItem; | 489 return pNewFormItem; |
496 } | 490 } |
| 491 |
497 CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, | 492 CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, |
498 CXFA_Node* pParent, | 493 CXFA_Node* pParent, |
499 CXFA_Node* pBefore) const { | 494 CXFA_Node* pBefore) const { |
500 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; | 495 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; |
501 CXFA_Node* pNewNode = | 496 CXFA_Node* pNewNode = |
502 CreateTemplateNode(eElement, pTemplateParent, | 497 CreateTemplateNode(eElement, pTemplateParent, |
503 pBefore ? pBefore->GetTemplateNode() : NULL) | 498 pBefore ? pBefore->GetTemplateNode() : NULL) |
504 ->Clone(FALSE); | 499 ->Clone(FALSE); |
505 if (pParent) | 500 if (pParent) |
506 pParent->InsertChild(pNewNode, pBefore); | 501 pParent->InsertChild(pNewNode, pBefore); |
507 return pNewNode; | 502 return pNewNode; |
508 } | 503 } |
| 504 |
509 CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, | 505 CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, |
510 CXFA_Node* pParent, | 506 CXFA_Node* pParent, |
511 CXFA_Node* pBefore) const { | 507 CXFA_Node* pBefore) const { |
512 CXFA_Document* pXFADoc = GetXFADoc(); | 508 CXFA_Document* pXFADoc = GetXFADoc(); |
513 CXFA_Node* pNewTemplateNode = pXFADoc->GetParser()->GetFactory()->CreateNode( | 509 CXFA_Node* pNewTemplateNode = pXFADoc->GetParser()->GetFactory()->CreateNode( |
514 XFA_XDPPACKET_Template, eElement); | 510 XFA_XDPPACKET_Template, eElement); |
515 if (pParent) | 511 if (pParent) |
516 pParent->InsertChild(pNewTemplateNode, pBefore); | 512 pParent->InsertChild(pNewTemplateNode, pBefore); |
517 return pNewTemplateNode; | 513 return pNewTemplateNode; |
518 } | 514 } |
| 515 |
519 CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const { | 516 CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const { |
520 CXFA_Node* pFont = CreateCopyNode(XFA_ELEMENT_Font, pParent); | 517 CXFA_Node* pFont = CreateCopyNode(XFA_ELEMENT_Font, pParent); |
521 pFont->SetCData(XFA_ATTRIBUTE_Typeface, FX_WSTRC(L"Myriad Pro"), FALSE); | 518 pFont->SetCData(XFA_ATTRIBUTE_Typeface, FX_WSTRC(L"Myriad Pro"), FALSE); |
522 return pFont; | 519 return pFont; |
523 } | 520 } |
| 521 |
524 CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, | 522 CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, |
525 uint32_t dwFlags, | 523 uint32_t dwFlags, |
526 FX_FLOAT fInsets[4]) const { | 524 FX_FLOAT fInsets[4]) const { |
527 CXFA_Node* pMargin = CreateCopyNode(XFA_ELEMENT_Margin, pParent); | 525 CXFA_Node* pMargin = CreateCopyNode(XFA_ELEMENT_Margin, pParent); |
528 if (dwFlags & 0x01) { | 526 if (dwFlags & 0x01) |
529 pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, | 527 pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, |
530 CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE); | 528 CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE); |
531 } | 529 if (dwFlags & 0x02) |
532 if (dwFlags & 0x02) { | |
533 pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, | 530 pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, |
534 CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE); | 531 CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE); |
535 } | 532 if (dwFlags & 0x04) |
536 if (dwFlags & 0x04) { | |
537 pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, | 533 pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, |
538 CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE); | 534 CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE); |
539 } | 535 if (dwFlags & 0x08) |
540 if (dwFlags & 0x08) { | |
541 pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, | 536 pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, |
542 CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE); | 537 CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE); |
543 } | |
544 return pMargin; | 538 return pMargin; |
545 } | 539 } |
| 540 |
546 CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_ELEMENT eValue, | 541 CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_ELEMENT eValue, |
547 CXFA_Node* pParent) const { | 542 CXFA_Node* pParent) const { |
548 CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pParent); | 543 CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pParent); |
549 CreateCopyNode(eValue, pValue); | 544 CreateCopyNode(eValue, pValue); |
550 return pValue; | 545 return pValue; |
551 } | 546 } |
| 547 |
552 CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { | 548 CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { |
553 return GetXFADoc()->GetParser()->GetFactory(); | 549 return GetXFADoc()->GetParser()->GetFactory(); |
554 } | 550 } |
| 551 |
555 CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { | 552 CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { |
556 return ((CXFA_FFDoc*)(m_pDocView->GetDoc()))->GetXFADoc(); | 553 return ((CXFA_FFDoc*)(m_pDocView->GetDoc()))->GetXFADoc(); |
557 } | 554 } |
558 | 555 |
559 CXFA_FFMenuHandler::CXFA_FFMenuHandler() {} | |
560 | |
561 CXFA_FFMenuHandler::~CXFA_FFMenuHandler() {} | |
562 | |
563 FX_BOOL CXFA_FFMenuHandler::CanCopy(CXFA_FFWidget* hWidget) { | |
564 return hWidget->CanCopy(); | |
565 } | |
566 FX_BOOL CXFA_FFMenuHandler::CanCut(CXFA_FFWidget* hWidget) { | |
567 return hWidget->CanCut(); | |
568 } | |
569 FX_BOOL CXFA_FFMenuHandler::CanPaste(CXFA_FFWidget* hWidget) { | |
570 return hWidget->CanPaste(); | |
571 } | |
572 FX_BOOL CXFA_FFMenuHandler::CanSelectAll(CXFA_FFWidget* hWidget) { | |
573 return hWidget->CanSelectAll(); | |
574 } | |
575 FX_BOOL CXFA_FFMenuHandler::CanDelete(CXFA_FFWidget* hWidget) { | |
576 return hWidget->CanDelete(); | |
577 } | |
578 FX_BOOL CXFA_FFMenuHandler::CanDeSelect(CXFA_FFWidget* hWidget) { | |
579 return hWidget->CanDeSelect(); | |
580 } | |
581 FX_BOOL CXFA_FFMenuHandler::Copy(CXFA_FFWidget* hWidget, | |
582 CFX_WideString& wsText) { | |
583 return hWidget->Copy(wsText); | |
584 } | |
585 FX_BOOL CXFA_FFMenuHandler::Cut(CXFA_FFWidget* hWidget, | |
586 CFX_WideString& wsText) { | |
587 return hWidget->Cut(wsText); | |
588 } | |
589 FX_BOOL CXFA_FFMenuHandler::Paste(CXFA_FFWidget* hWidget, | |
590 const CFX_WideString& wsText) { | |
591 return hWidget->Paste(wsText); | |
592 } | |
593 FX_BOOL CXFA_FFMenuHandler::SelectAll(CXFA_FFWidget* hWidget) { | |
594 return hWidget->SelectAll(); | |
595 } | |
596 FX_BOOL CXFA_FFMenuHandler::Delete(CXFA_FFWidget* hWidget) { | |
597 return hWidget->Delete(); | |
598 } | |
599 FX_BOOL CXFA_FFMenuHandler::DeSelect(CXFA_FFWidget* hWidget) { | |
600 return hWidget->DeSelect(); | |
601 } | |
602 FX_BOOL CXFA_FFMenuHandler::CanUndo(CXFA_FFWidget* hWidget) { | |
603 return hWidget->CanUndo(); | |
604 } | |
605 FX_BOOL CXFA_FFMenuHandler::CanRedo(CXFA_FFWidget* hWidget) { | |
606 return hWidget->CanRedo(); | |
607 } | |
608 FX_BOOL CXFA_FFMenuHandler::Undo(CXFA_FFWidget* hWidget) { | |
609 return hWidget->Undo(); | |
610 } | |
611 FX_BOOL CXFA_FFMenuHandler::Redo(CXFA_FFWidget* hWidget) { | |
612 return hWidget->Redo(); | |
613 } | |
614 FX_BOOL CXFA_FFMenuHandler::GetSuggestWords( | |
615 CXFA_FFWidget* hWidget, | |
616 CFX_PointF pointf, | |
617 std::vector<CFX_ByteString>& sSuggest) { | |
618 return hWidget->GetSuggestWords(pointf, sSuggest); | |
619 } | |
620 FX_BOOL CXFA_FFMenuHandler::ReplaceSpellCheckWord( | |
621 CXFA_FFWidget* hWidget, | |
622 CFX_PointF pointf, | |
623 const CFX_ByteStringC& bsReplace) { | |
624 return hWidget->ReplaceSpellCheckWord(pointf, bsReplace); | |
625 } | |
OLD | NEW |