Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Side by Side Diff: xfa/src/fxfa/app/xfa_ffwidgethandler.cpp

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

Powered by Google App Engine
This is Rietveld 408576698