OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/parser/cxfa_widgetdata.h" | 7 #include "xfa/fxfa/parser/cxfa_widgetdata.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fxbarcode/include/BC_Library.h" | 10 #include "xfa/fxbarcode/include/BC_Library.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 return TRUE; | 70 return TRUE; |
71 } | 71 } |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode) | 75 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode) |
76 : CXFA_Data(pNode), | 76 : CXFA_Data(pNode), |
77 m_bIsNull(TRUE), | 77 m_bIsNull(TRUE), |
78 m_bPreNull(TRUE), | 78 m_bPreNull(TRUE), |
79 m_pUiChildNode(NULL), | 79 m_pUiChildNode(nullptr), |
80 m_eUIType(XFA_Element::Unknown) {} | 80 m_eUIType(XFA_Element::Unknown) {} |
81 | 81 |
82 CXFA_Node* CXFA_WidgetData::GetUIChild() { | 82 CXFA_Node* CXFA_WidgetData::GetUIChild() { |
83 if (m_eUIType == XFA_Element::Unknown) | 83 if (m_eUIType == XFA_Element::Unknown) |
84 m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType); | 84 m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType); |
85 | 85 |
86 return m_pUiChildNode; | 86 return m_pUiChildNode; |
87 } | 87 } |
88 | 88 |
89 XFA_Element CXFA_WidgetData::GetUIType() { | 89 XFA_Element CXFA_WidgetData::GetUIType() { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 434 } |
435 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | 435 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); |
436 } | 436 } |
437 SyncValue(wsContent, bNotify); | 437 SyncValue(wsContent, bNotify); |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 CXFA_Node* CXFA_WidgetData::GetExclGroupNode() { | 441 CXFA_Node* CXFA_WidgetData::GetExclGroupNode() { |
442 CXFA_Node* pExcl = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_Parent)); | 442 CXFA_Node* pExcl = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_Parent)); |
443 if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup) | 443 if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup) |
444 return NULL; | 444 return nullptr; |
445 return pExcl; | 445 return pExcl; |
446 } | 446 } |
447 | 447 |
448 CXFA_Node* CXFA_WidgetData::GetSelectedMember() { | 448 CXFA_Node* CXFA_WidgetData::GetSelectedMember() { |
449 CXFA_Node* pSelectedMember = NULL; | 449 CXFA_Node* pSelectedMember = nullptr; |
450 CFX_WideString wsState = GetRawValue(); | 450 CFX_WideString wsState = GetRawValue(); |
451 if (wsState.IsEmpty()) | 451 if (wsState.IsEmpty()) |
452 return pSelectedMember; | 452 return pSelectedMember; |
453 | 453 |
454 for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); | 454 for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); |
455 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 455 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
456 CXFA_WidgetData widgetData(pNode); | 456 CXFA_WidgetData widgetData(pNode); |
457 if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { | 457 if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { |
458 pSelectedMember = pNode; | 458 pSelectedMember = pNode; |
459 break; | 459 break; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 509 } |
510 if (m_pNode) { | 510 if (m_pNode) { |
511 m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, | 511 m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify, |
512 bSyncData); | 512 bSyncData); |
513 } | 513 } |
514 } | 514 } |
515 | 515 |
516 CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { | 516 CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() { |
517 CXFA_Node* pExcl = GetNode(); | 517 CXFA_Node* pExcl = GetNode(); |
518 if (!pExcl) | 518 if (!pExcl) |
519 return NULL; | 519 return nullptr; |
520 | 520 |
521 CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild); | 521 CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild); |
522 while (pNode) { | 522 while (pNode) { |
523 if (pNode->GetElementType() == XFA_Element::Field) | 523 if (pNode->GetElementType() == XFA_Element::Field) |
524 return pNode; | 524 return pNode; |
525 | 525 |
526 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 526 pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
527 } | 527 } |
528 return NULL; | 528 return nullptr; |
529 } | 529 } |
530 CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) { | 530 CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) { |
531 if (!pNode) | 531 if (!pNode) |
532 return NULL; | 532 return nullptr; |
533 | 533 |
534 CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 534 CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
535 while (pNodeField) { | 535 while (pNodeField) { |
536 if (pNodeField->GetElementType() == XFA_Element::Field) | 536 if (pNodeField->GetElementType() == XFA_Element::Field) |
537 return pNodeField; | 537 return pNodeField; |
538 | 538 |
539 pNodeField = pNodeField->GetNodeItem(XFA_NODEITEM_NextSibling); | 539 pNodeField = pNodeField->GetNodeItem(XFA_NODEITEM_NextSibling); |
540 } | 540 } |
541 return NULL; | 541 return nullptr; |
542 } | 542 } |
543 | 543 |
544 int32_t CXFA_WidgetData::GetChoiceListCommitOn() { | 544 int32_t CXFA_WidgetData::GetChoiceListCommitOn() { |
545 CXFA_Node* pUIChild = GetUIChild(); | 545 CXFA_Node* pUIChild = GetUIChild(); |
546 if (pUIChild) | 546 if (pUIChild) |
547 return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn); | 547 return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn); |
548 return XFA_GetAttributeDefaultValue_Enum( | 548 return XFA_GetAttributeDefaultValue_Enum( |
549 XFA_Element::ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form); | 549 XFA_Element::ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form); |
550 } | 550 } |
551 | 551 |
(...skipping 14 matching lines...) Expand all Loading... |
566 } | 566 } |
567 | 567 |
568 FX_BOOL CXFA_WidgetData::IsListBox() { | 568 FX_BOOL CXFA_WidgetData::IsListBox() { |
569 int32_t iOpenMode = GetChoiceListOpen(); | 569 int32_t iOpenMode = GetChoiceListOpen(); |
570 return (iOpenMode == XFA_ATTRIBUTEENUM_Always || | 570 return (iOpenMode == XFA_ATTRIBUTEENUM_Always || |
571 iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect); | 571 iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect); |
572 } | 572 } |
573 | 573 |
574 int32_t CXFA_WidgetData::CountChoiceListItems(FX_BOOL bSaveValue) { | 574 int32_t CXFA_WidgetData::CountChoiceListItems(FX_BOOL bSaveValue) { |
575 CXFA_NodeArray pItems; | 575 CXFA_NodeArray pItems; |
576 CXFA_Node* pItem = NULL; | 576 CXFA_Node* pItem = nullptr; |
577 int32_t iCount = 0; | 577 int32_t iCount = 0; |
578 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 578 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
579 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 579 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
580 if (pNode->GetElementType() != XFA_Element::Items) | 580 if (pNode->GetElementType() != XFA_Element::Items) |
581 continue; | 581 continue; |
582 | 582 |
583 iCount++; | 583 iCount++; |
584 pItems.Add(pNode); | 584 pItems.Add(pNode); |
585 if (iCount == 2) | 585 if (iCount == 2) |
586 break; | 586 break; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 pItem->TryContent(wsText); | 632 pItem->TryContent(wsText); |
633 return TRUE; | 633 return TRUE; |
634 } | 634 } |
635 } | 635 } |
636 return FALSE; | 636 return FALSE; |
637 } | 637 } |
638 | 638 |
639 void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, | 639 void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray, |
640 FX_BOOL bSaveValue) { | 640 FX_BOOL bSaveValue) { |
641 CXFA_NodeArray pItems; | 641 CXFA_NodeArray pItems; |
642 CXFA_Node* pItem = NULL; | 642 CXFA_Node* pItem = nullptr; |
643 int32_t iCount = 0; | 643 int32_t iCount = 0; |
644 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 644 CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
645 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 645 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
646 if (pNode->GetElementType() != XFA_Element::Items) | 646 if (pNode->GetElementType() != XFA_Element::Items) |
647 continue; | 647 continue; |
648 | 648 |
649 iCount++; | 649 iCount++; |
650 pItems.Add(pNode); | 650 pItems.Add(pNode); |
651 if (iCount == 2) | 651 if (iCount == 2) |
652 break; | 652 break; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 continue; | 936 continue; |
937 | 937 |
938 iCount++; | 938 iCount++; |
939 listitems.Add(pItems); | 939 listitems.Add(pItems); |
940 } | 940 } |
941 if (iCount <= 1) { | 941 if (iCount <= 1) { |
942 wsLabel = wsValue; | 942 wsLabel = wsValue; |
943 } else { | 943 } else { |
944 CXFA_Node* pLabelItems = listitems[0]; | 944 CXFA_Node* pLabelItems = listitems[0]; |
945 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); | 945 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); |
946 CXFA_Node* pSaveItems = NULL; | 946 CXFA_Node* pSaveItems = nullptr; |
947 if (bSave) { | 947 if (bSave) { |
948 pSaveItems = pLabelItems; | 948 pSaveItems = pLabelItems; |
949 pLabelItems = listitems[1]; | 949 pLabelItems = listitems[1]; |
950 } else { | 950 } else { |
951 pSaveItems = listitems[1]; | 951 pSaveItems = listitems[1]; |
952 } | 952 } |
953 iCount = 0; | 953 iCount = 0; |
954 int32_t iSearch = -1; | 954 int32_t iSearch = -1; |
955 CFX_WideString wsContent; | 955 CFX_WideString wsContent; |
956 CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); | 956 CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); |
(...skipping 25 matching lines...) Expand all Loading... |
982 continue; | 982 continue; |
983 | 983 |
984 iCount++; | 984 iCount++; |
985 listitems.Add(pItems); | 985 listitems.Add(pItems); |
986 } | 986 } |
987 if (iCount <= 1) { | 987 if (iCount <= 1) { |
988 wsValue = wsLabel; | 988 wsValue = wsLabel; |
989 } else { | 989 } else { |
990 CXFA_Node* pLabelItems = listitems[0]; | 990 CXFA_Node* pLabelItems = listitems[0]; |
991 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); | 991 FX_BOOL bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save); |
992 CXFA_Node* pSaveItems = NULL; | 992 CXFA_Node* pSaveItems = nullptr; |
993 if (bSave) { | 993 if (bSave) { |
994 pSaveItems = pLabelItems; | 994 pSaveItems = pLabelItems; |
995 pLabelItems = listitems[1]; | 995 pLabelItems = listitems[1]; |
996 } else { | 996 } else { |
997 pSaveItems = listitems[1]; | 997 pSaveItems = listitems[1]; |
998 } | 998 } |
999 iCount = 0; | 999 iCount = 0; |
1000 int32_t iSearch = -1; | 1000 int32_t iSearch = -1; |
1001 CFX_WideString wsContent; | 1001 CFX_WideString wsContent; |
1002 CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); | 1002 CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 } | 1455 } |
1456 break; | 1456 break; |
1457 } | 1457 } |
1458 default: | 1458 default: |
1459 break; | 1459 break; |
1460 } | 1460 } |
1461 return FALSE; | 1461 return FALSE; |
1462 } | 1462 } |
1463 | 1463 |
1464 IFX_Locale* CXFA_WidgetData::GetLocal() { | 1464 IFX_Locale* CXFA_WidgetData::GetLocal() { |
1465 IFX_Locale* pLocale = NULL; | |
1466 if (!m_pNode) | 1465 if (!m_pNode) |
1467 return pLocale; | 1466 return nullptr; |
1468 | 1467 |
1469 FX_BOOL bLocale = FALSE; | |
1470 CFX_WideString wsLocaleName; | 1468 CFX_WideString wsLocaleName; |
1471 bLocale = m_pNode->GetLocaleName(wsLocaleName); | 1469 if (!m_pNode->GetLocaleName(wsLocaleName)) |
1472 if (bLocale) { | 1470 return nullptr; |
1473 if (wsLocaleName == FX_WSTRC(L"ambient")) { | 1471 if (wsLocaleName == FX_WSTRC(L"ambient")) |
1474 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); | 1472 return m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); |
1475 } else { | 1473 return m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); |
1476 pLocale = | |
1477 m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); | |
1478 } | |
1479 } | |
1480 return pLocale; | |
1481 } | 1474 } |
1482 | 1475 |
1483 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, | 1476 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, |
1484 XFA_VALUEPICTURE eValueType) { | 1477 XFA_VALUEPICTURE eValueType) { |
1485 wsValue = m_pNode->GetContent(); | 1478 wsValue = m_pNode->GetContent(); |
1486 | 1479 |
1487 if (eValueType == XFA_VALUEPICTURE_Display) | 1480 if (eValueType == XFA_VALUEPICTURE_Display) |
1488 GetItemLabel(wsValue.AsStringC(), wsValue); | 1481 GetItemLabel(wsValue.AsStringC(), wsValue); |
1489 | 1482 |
1490 CFX_WideString wsPicture; | 1483 CFX_WideString wsPicture; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 } | 1770 } |
1778 } | 1771 } |
1779 } else if (wc == L'.') { | 1772 } else if (wc == L'.') { |
1780 iTread_ = 0; | 1773 iTread_ = 0; |
1781 iLead = -1; | 1774 iLead = -1; |
1782 } | 1775 } |
1783 wsRet += wc; | 1776 wsRet += wc; |
1784 } | 1777 } |
1785 return wsRet; | 1778 return wsRet; |
1786 } | 1779 } |
OLD | NEW |