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

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

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks Created 4 years, 6 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/fxfa/app/xfa_ffwidgetacc.cpp ('k') | xfa/fxfa/include/fxfa_basic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fxfa/include/xfa_ffwidgethandler.h" 7 #include "xfa/fxfa/include/xfa_ffwidgethandler.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 CFX_Matrix* pMatrix, 180 CFX_Matrix* pMatrix,
181 FX_BOOL bHighlight) { 181 FX_BOOL bHighlight) {
182 hWidget->RenderWidget(pGS, pMatrix, 182 hWidget->RenderWidget(pGS, pMatrix,
183 bHighlight ? XFA_WidgetStatus_Highlight : 0); 183 bHighlight ? XFA_WidgetStatus_Highlight : 0);
184 } 184 }
185 185
186 FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, 186 FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc,
187 XFA_EVENTTYPE eEventType) { 187 XFA_EVENTTYPE eEventType) {
188 if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown) 188 if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown)
189 return FALSE; 189 return FALSE;
190 if (pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) 190 if (pWidgetAcc->GetClassID() == XFA_Element::Draw)
191 return FALSE; 191 return FALSE;
192 192
193 switch (eEventType) { 193 switch (eEventType) {
194 case XFA_EVENT_Calculate: { 194 case XFA_EVENT_Calculate: {
195 CXFA_Calculate calc = pWidgetAcc->GetCalculate(); 195 CXFA_Calculate calc = pWidgetAcc->GetCalculate();
196 if (!calc) 196 if (!calc)
197 return FALSE; 197 return FALSE;
198 if (calc.GetScript()) 198 if (calc.GetScript())
199 return TRUE; 199 return TRUE;
200 return FALSE; 200 return FALSE;
(...skipping 11 matching lines...) Expand all
212 } 212 }
213 CXFA_NodeArray eventArray; 213 CXFA_NodeArray eventArray;
214 return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], 214 return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType],
215 eventArray); 215 eventArray);
216 } 216 }
217 217
218 int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, 218 int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc,
219 CXFA_EventParam* pParam) { 219 CXFA_EventParam* pParam) {
220 if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) 220 if (!pParam || pParam->m_eType == XFA_EVENT_Unknown)
221 return XFA_EVENTERROR_NotExist; 221 return XFA_EVENTERROR_NotExist;
222 if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) 222 if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_Element::Draw)
223 return XFA_EVENTERROR_NotExist; 223 return XFA_EVENTERROR_NotExist;
224 224
225 switch (pParam->m_eType) { 225 switch (pParam->m_eType) {
226 case XFA_EVENT_Calculate: 226 case XFA_EVENT_Calculate:
227 return pWidgetAcc->ProcessCalculate(); 227 return pWidgetAcc->ProcessCalculate();
228 case XFA_EVENT_Validate: 228 case XFA_EVENT_Validate:
229 if (m_pDocView->GetDoc()->GetDocProvider()->IsValidationsEnabled( 229 if (m_pDocView->GetDoc()->GetDocProvider()->IsValidationsEnabled(
230 m_pDocView->GetDoc())) { 230 m_pDocView->GetDoc())) {
231 return pWidgetAcc->ProcessValidate(); 231 return pWidgetAcc->ProcessValidate();
232 } 232 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return CreatePasswordEdit(pParent, pBefore); 314 return CreatePasswordEdit(pParent, pBefore);
315 case XFA_WIDGETTYPE_Subform: 315 case XFA_WIDGETTYPE_Subform:
316 return CreateSubform(pParent, pBefore); 316 return CreateSubform(pParent, pBefore);
317 default: 317 default:
318 return nullptr; 318 return nullptr;
319 } 319 }
320 } 320 }
321 321
322 CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, 322 CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent,
323 CXFA_Node* pBefore) const { 323 CXFA_Node* pBefore) const {
324 CXFA_Node* pField = CreateField(XFA_ELEMENT_Button, pParent, pBefore); 324 CXFA_Node* pField = CreateField(XFA_Element::Button, pParent, pBefore);
325 CXFA_Node* pCaption = CreateCopyNode(XFA_ELEMENT_Caption, pField); 325 CXFA_Node* pCaption = CreateCopyNode(XFA_Element::Caption, pField);
326 CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pCaption); 326 CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pCaption);
327 CXFA_Node* pText = CreateCopyNode(XFA_ELEMENT_Text, pValue); 327 CXFA_Node* pText = CreateCopyNode(XFA_Element::Text, pValue);
328 pText->SetContent(L"Button", L"Button", FALSE); 328 pText->SetContent(L"Button", L"Button", FALSE);
329 329
330 CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption); 330 CXFA_Node* pPara = CreateCopyNode(XFA_Element::Para, pCaption);
331 pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE); 331 pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE);
332 pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE); 332 pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, FALSE);
333 CreateFontNode(pCaption); 333 CreateFontNode(pCaption);
334 334
335 CXFA_Node* pBorder = CreateCopyNode(XFA_ELEMENT_Border, pField); 335 CXFA_Node* pBorder = CreateCopyNode(XFA_Element::Border, pField);
336 pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE); 336 pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, FALSE);
337 337
338 CXFA_Node* pEdge = CreateCopyNode(XFA_ELEMENT_Edge, pBorder); 338 CXFA_Node* pEdge = CreateCopyNode(XFA_Element::Edge, pBorder);
339 pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE); 339 pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, FALSE);
340 340
341 CXFA_Node* pFill = CreateCopyNode(XFA_ELEMENT_Fill, pBorder); 341 CXFA_Node* pFill = CreateCopyNode(XFA_Element::Fill, pBorder);
342 CXFA_Node* pColor = CreateCopyNode(XFA_ELEMENT_Color, pFill); 342 CXFA_Node* pColor = CreateCopyNode(XFA_Element::Color, pFill);
343 pColor->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", FALSE); 343 pColor->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", FALSE);
344 344
345 CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); 345 CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField);
346 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); 346 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None);
347 347
348 return pField; 348 return pField;
349 } 349 }
350 350
351 CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, 351 CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent,
352 CXFA_Node* pBefore) const { 352 CXFA_Node* pBefore) const {
353 return CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); 353 return CreateField(XFA_Element::CheckButton, pParent, pBefore);
354 } 354 }
355 355
356 CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, 356 CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent,
357 CXFA_Node* pBefore) const { 357 CXFA_Node* pBefore) const {
358 return CreateFormItem(XFA_ELEMENT_ExclGroup, pParent, pBefore); 358 return CreateFormItem(XFA_Element::ExclGroup, pParent, pBefore);
359 } 359 }
360 360
361 CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, 361 CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent,
362 CXFA_Node* pBefore) const { 362 CXFA_Node* pBefore) const {
363 CXFA_Node* pField = CreateField(XFA_ELEMENT_CheckButton, pParent, pBefore); 363 CXFA_Node* pField = CreateField(XFA_Element::CheckButton, pParent, pBefore);
364 CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_ELEMENT_Ui); 364 CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_Element::Ui);
365 CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_ELEMENT_CheckButton); 365 CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_Element::CheckButton);
366 pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); 366 pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round);
367 return pField; 367 return pField;
368 } 368 }
369 369
370 CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, 370 CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent,
371 CXFA_Node* pBefore) const { 371 CXFA_Node* pBefore) const {
372 CXFA_Node* pField = CreateField(XFA_ELEMENT_DateTimeEdit, pParent, pBefore); 372 CXFA_Node* pField = CreateField(XFA_Element::DateTimeEdit, pParent, pBefore);
373 CreateValueNode(XFA_ELEMENT_Date, pField); 373 CreateValueNode(XFA_Element::Date, pField);
374 return pField; 374 return pField;
375 } 375 }
376 376
377 CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, 377 CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent,
378 CXFA_Node* pBefore) const { 378 CXFA_Node* pBefore) const {
379 CXFA_Node* pField = CreateNumericField(pParent, pBefore); 379 CXFA_Node* pField = CreateNumericField(pParent, pBefore);
380 CreateValueNode(XFA_ELEMENT_Decimal, pField); 380 CreateValueNode(XFA_Element::Decimal, pField);
381 return pField; 381 return pField;
382 } 382 }
383 383
384 CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, 384 CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent,
385 CXFA_Node* pBefore) const { 385 CXFA_Node* pBefore) const {
386 return CreateField(XFA_ELEMENT_NumericEdit, pParent, pBefore); 386 return CreateField(XFA_Element::NumericEdit, pParent, pBefore);
387 } 387 }
388 388
389 CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, 389 CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent,
390 CXFA_Node* pBefore) const { 390 CXFA_Node* pBefore) const {
391 return CreateField(XFA_ELEMENT_Signature, pParent, pBefore); 391 return CreateField(XFA_Element::Signature, pParent, pBefore);
392 } 392 }
393 393
394 CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, 394 CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent,
395 CXFA_Node* pBefore) const { 395 CXFA_Node* pBefore) const {
396 return CreateField(XFA_ELEMENT_TextEdit, pParent, pBefore); 396 return CreateField(XFA_Element::TextEdit, pParent, pBefore);
397 } 397 }
398 398
399 CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, 399 CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent,
400 CXFA_Node* pBefore) const { 400 CXFA_Node* pBefore) const {
401 return CreateField(XFA_ELEMENT_ChoiceList, pParent, pBefore); 401 return CreateField(XFA_Element::ChoiceList, pParent, pBefore);
402 } 402 }
403 403
404 CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, 404 CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent,
405 CXFA_Node* pBefore) const { 405 CXFA_Node* pBefore) const {
406 CXFA_Node* pField = CreateDropdownList(pParent, pBefore); 406 CXFA_Node* pField = CreateDropdownList(pParent, pBefore);
407 CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); 407 CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild);
408 CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); 408 CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild);
409 pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); 409 pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always);
410 pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); 410 pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit);
411 return pField; 411 return pField;
412 } 412 }
413 413
414 CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, 414 CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent,
415 CXFA_Node* pBefore) const { 415 CXFA_Node* pBefore) const {
416 return CreateField(XFA_ELEMENT_ImageEdit, pParent, pBefore); 416 return CreateField(XFA_Element::ImageEdit, pParent, pBefore);
417 } 417 }
418 418
419 CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, 419 CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent,
420 CXFA_Node* pBefore) const { 420 CXFA_Node* pBefore) const {
421 CXFA_Node* pField = CreateField(XFA_ELEMENT_PasswordEdit, pParent, pBefore); 421 CXFA_Node* pField = CreateField(XFA_Element::PasswordEdit, pParent, pBefore);
422 CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField); 422 CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField);
423 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE); 423 pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, FALSE);
424 return pField; 424 return pField;
425 } 425 }
426 426
427 CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_ELEMENT eElement, 427 CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_Element eElement,
428 CXFA_Node* pParent, 428 CXFA_Node* pParent,
429 CXFA_Node* pBefore) const { 429 CXFA_Node* pBefore) const {
430 CXFA_Node* pField = CreateFormItem(XFA_ELEMENT_Field, pParent, pBefore); 430 CXFA_Node* pField = CreateFormItem(XFA_Element::Field, pParent, pBefore);
431 CreateCopyNode(eElement, CreateCopyNode(XFA_ELEMENT_Ui, pField)); 431 CreateCopyNode(eElement, CreateCopyNode(XFA_Element::Ui, pField));
432 CreateFontNode(pField); 432 CreateFontNode(pField);
433 return pField; 433 return pField;
434 } 434 }
435 435
436 CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, 436 CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent,
437 CXFA_Node* pBefore) const { 437 CXFA_Node* pBefore) const {
438 return CreateDraw(XFA_ELEMENT_Arc, pParent, pBefore); 438 return CreateDraw(XFA_Element::Arc, pParent, pBefore);
439 } 439 }
440 440
441 CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, 441 CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent,
442 CXFA_Node* pBefore) const { 442 CXFA_Node* pBefore) const {
443 return CreateDraw(XFA_ELEMENT_Rectangle, pParent, pBefore); 443 return CreateDraw(XFA_Element::Rectangle, pParent, pBefore);
444 } 444 }
445 445
446 CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, 446 CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent,
447 CXFA_Node* pBefore) const { 447 CXFA_Node* pBefore) const {
448 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Image, pParent, pBefore); 448 CXFA_Node* pField = CreateDraw(XFA_Element::Image, pParent, pBefore);
449 CreateCopyNode(XFA_ELEMENT_ImageEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); 449 CreateCopyNode(XFA_Element::ImageEdit,
450 CreateCopyNode(XFA_Element::Ui, pField));
450 return pField; 451 return pField;
451 } 452 }
452 453
453 CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, 454 CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent,
454 CXFA_Node* pBefore) const { 455 CXFA_Node* pBefore) const {
455 return CreateDraw(XFA_ELEMENT_Line, pParent, pBefore); 456 return CreateDraw(XFA_Element::Line, pParent, pBefore);
456 } 457 }
457 458
458 CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, 459 CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent,
459 CXFA_Node* pBefore) const { 460 CXFA_Node* pBefore) const {
460 CXFA_Node* pField = CreateDraw(XFA_ELEMENT_Text, pParent, pBefore); 461 CXFA_Node* pField = CreateDraw(XFA_Element::Text, pParent, pBefore);
461 CreateCopyNode(XFA_ELEMENT_TextEdit, CreateCopyNode(XFA_ELEMENT_Ui, pField)); 462 CreateCopyNode(XFA_Element::TextEdit,
463 CreateCopyNode(XFA_Element::Ui, pField));
462 CreateFontNode(pField); 464 CreateFontNode(pField);
463 return pField; 465 return pField;
464 } 466 }
465 467
466 CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_ELEMENT eElement, 468 CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_Element eElement,
467 CXFA_Node* pParent, 469 CXFA_Node* pParent,
468 CXFA_Node* pBefore) const { 470 CXFA_Node* pBefore) const {
469 CXFA_Node* pDraw = CreateFormItem(XFA_ELEMENT_Draw, pParent, pBefore); 471 CXFA_Node* pDraw = CreateFormItem(XFA_Element::Draw, pParent, pBefore);
470 CreateValueNode(eElement, pDraw); 472 CreateValueNode(eElement, pDraw);
471 return pDraw; 473 return pDraw;
472 } 474 }
473 475
474 CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, 476 CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent,
475 CXFA_Node* pBefore) const { 477 CXFA_Node* pBefore) const {
476 return CreateFormItem(XFA_ELEMENT_Subform, pParent, pBefore); 478 return CreateFormItem(XFA_Element::Subform, pParent, pBefore);
477 } 479 }
478 480
479 CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_ELEMENT eElement, 481 CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement,
480 CXFA_Node* pParent, 482 CXFA_Node* pParent,
481 CXFA_Node* pBefore) const { 483 CXFA_Node* pBefore) const {
482 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; 484 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL;
483 CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(FALSE); 485 CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(FALSE);
484 if (pParent) 486 if (pParent)
485 pParent->InsertChild(pNewFormItem, pBefore); 487 pParent->InsertChild(pNewFormItem, pBefore);
486 return pNewFormItem; 488 return pNewFormItem;
487 } 489 }
488 490
489 CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_ELEMENT eElement, 491 CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_Element eElement,
490 CXFA_Node* pParent, 492 CXFA_Node* pParent,
491 CXFA_Node* pBefore) const { 493 CXFA_Node* pBefore) const {
492 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL; 494 CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : NULL;
493 CXFA_Node* pNewNode = 495 CXFA_Node* pNewNode =
494 CreateTemplateNode(eElement, pTemplateParent, 496 CreateTemplateNode(eElement, pTemplateParent,
495 pBefore ? pBefore->GetTemplateNode() : NULL) 497 pBefore ? pBefore->GetTemplateNode() : NULL)
496 ->Clone(FALSE); 498 ->Clone(FALSE);
497 if (pParent) 499 if (pParent)
498 pParent->InsertChild(pNewNode, pBefore); 500 pParent->InsertChild(pNewNode, pBefore);
499 return pNewNode; 501 return pNewNode;
500 } 502 }
501 503
502 CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement, 504 CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_Element eElement,
503 CXFA_Node* pParent, 505 CXFA_Node* pParent,
504 CXFA_Node* pBefore) const { 506 CXFA_Node* pBefore) const {
505 CXFA_Document* pXFADoc = GetXFADoc(); 507 CXFA_Document* pXFADoc = GetXFADoc();
506 CXFA_Node* pNewTemplateNode = pXFADoc->GetParser()->GetFactory()->CreateNode( 508 CXFA_Node* pNewTemplateNode = pXFADoc->GetParser()->GetFactory()->CreateNode(
507 XFA_XDPPACKET_Template, eElement); 509 XFA_XDPPACKET_Template, eElement);
508 if (pParent) 510 if (pParent)
509 pParent->InsertChild(pNewTemplateNode, pBefore); 511 pParent->InsertChild(pNewTemplateNode, pBefore);
510 return pNewTemplateNode; 512 return pNewTemplateNode;
511 } 513 }
512 514
513 CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const { 515 CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const {
514 CXFA_Node* pFont = CreateCopyNode(XFA_ELEMENT_Font, pParent); 516 CXFA_Node* pFont = CreateCopyNode(XFA_Element::Font, pParent);
515 pFont->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", FALSE); 517 pFont->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", FALSE);
516 return pFont; 518 return pFont;
517 } 519 }
518 520
519 CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, 521 CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent,
520 uint32_t dwFlags, 522 uint32_t dwFlags,
521 FX_FLOAT fInsets[4]) const { 523 FX_FLOAT fInsets[4]) const {
522 CXFA_Node* pMargin = CreateCopyNode(XFA_ELEMENT_Margin, pParent); 524 CXFA_Node* pMargin = CreateCopyNode(XFA_Element::Margin, pParent);
523 if (dwFlags & 0x01) 525 if (dwFlags & 0x01)
524 pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, 526 pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset,
525 CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE); 527 CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), FALSE);
526 if (dwFlags & 0x02) 528 if (dwFlags & 0x02)
527 pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, 529 pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset,
528 CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE); 530 CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), FALSE);
529 if (dwFlags & 0x04) 531 if (dwFlags & 0x04)
530 pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, 532 pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset,
531 CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE); 533 CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), FALSE);
532 if (dwFlags & 0x08) 534 if (dwFlags & 0x08)
533 pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, 535 pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset,
534 CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE); 536 CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), FALSE);
535 return pMargin; 537 return pMargin;
536 } 538 }
537 539
538 CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_ELEMENT eValue, 540 CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_Element eValue,
539 CXFA_Node* pParent) const { 541 CXFA_Node* pParent) const {
540 CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pParent); 542 CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pParent);
541 CreateCopyNode(eValue, pValue); 543 CreateCopyNode(eValue, pValue);
542 return pValue; 544 return pValue;
543 } 545 }
544 546
545 CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { 547 CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const {
546 return GetXFADoc()->GetParser()->GetFactory(); 548 return GetXFADoc()->GetParser()->GetFactory();
547 } 549 }
548 550
549 CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { 551 CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const {
550 return m_pDocView->GetDoc()->GetXFADoc(); 552 return m_pDocView->GetDoc()->GetXFADoc();
551 } 553 }
552 554
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffwidgetacc.cpp ('k') | xfa/fxfa/include/fxfa_basic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698