| 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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 881        pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 881        pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 
| 882     if (pItemNode->GetClassID() != XFA_ELEMENT_Items) | 882     if (pItemNode->GetClassID() != XFA_ELEMENT_Items) | 
| 883       continue; | 883       continue; | 
| 884 | 884 | 
| 885     listitems.Add(pItemNode); | 885     listitems.Add(pItemNode); | 
| 886     iCount++; | 886     iCount++; | 
| 887   } | 887   } | 
| 888   if (iCount < 1) { | 888   if (iCount < 1) { | 
| 889     CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | 889     CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | 
| 890     m_pNode->InsertChild(-1, pItems); | 890     m_pNode->InsertChild(-1, pItems); | 
| 891     InsertListTextItem(pItems, wsLabel.AsStringC(), nIndex); | 891     InsertListTextItem(pItems, wsLabel, nIndex); | 
| 892     CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | 892     CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | 
| 893     m_pNode->InsertChild(-1, pSaveItems); | 893     m_pNode->InsertChild(-1, pSaveItems); | 
| 894     pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); | 894     pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); | 
| 895     InsertListTextItem(pSaveItems, wsNewValue.AsStringC(), nIndex); | 895     InsertListTextItem(pSaveItems, wsNewValue, nIndex); | 
| 896   } else if (iCount > 1) { | 896   } else if (iCount > 1) { | 
| 897     for (int32_t i = 0; i < 2; i++) { | 897     for (int32_t i = 0; i < 2; i++) { | 
| 898       CXFA_Node* pNode = listitems[i]; | 898       CXFA_Node* pNode = listitems[i]; | 
| 899       FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save); | 899       FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save); | 
| 900       if (bHasSave) | 900       if (bHasSave) | 
| 901         InsertListTextItem(pNode, wsNewValue.AsStringC(), nIndex); | 901         InsertListTextItem(pNode, wsNewValue, nIndex); | 
| 902       else | 902       else | 
| 903         InsertListTextItem(pNode, wsLabel.AsStringC(), nIndex); | 903         InsertListTextItem(pNode, wsLabel, nIndex); | 
| 904     } | 904     } | 
| 905   } else { | 905   } else { | 
| 906     CXFA_Node* pNode = listitems[0]; | 906     CXFA_Node* pNode = listitems[0]; | 
| 907     pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); | 907     pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); | 
| 908     pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); | 908     pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); | 
| 909     CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | 909     CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); | 
| 910     m_pNode->InsertChild(-1, pSaveItems); | 910     m_pNode->InsertChild(-1, pSaveItems); | 
| 911     pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); | 911     pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); | 
| 912     pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); | 912     pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); | 
| 913     listitems.RemoveAll(); | 913     listitems.RemoveAll(); | 
| 914     CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 914     CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 
| 915     int32_t i = 0; | 915     int32_t i = 0; | 
| 916     while (pListNode) { | 916     while (pListNode) { | 
| 917       CFX_WideString wsOldValue; | 917       CFX_WideString wsOldValue; | 
| 918       pListNode->TryContent(wsOldValue); | 918       pListNode->TryContent(wsOldValue); | 
| 919       InsertListTextItem(pSaveItems, wsOldValue.AsStringC(), i); | 919       InsertListTextItem(pSaveItems, wsOldValue, i); | 
| 920       i++; | 920       i++; | 
| 921       pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 921       pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 
| 922     } | 922     } | 
| 923     InsertListTextItem(pNode, wsLabel.AsStringC(), nIndex); | 923     InsertListTextItem(pNode, wsLabel, nIndex); | 
| 924     InsertListTextItem(pSaveItems, wsNewValue.AsStringC(), nIndex); | 924     InsertListTextItem(pSaveItems, wsNewValue, nIndex); | 
| 925   } | 925   } | 
| 926   if (!bNotify) | 926   if (!bNotify) | 
| 927     return; | 927     return; | 
| 928 | 928 | 
| 929   m_pNode->GetDocument()->GetNotify()->OnWidgetListItemAdded( | 929   m_pNode->GetDocument()->GetNotify()->OnWidgetListItemAdded( | 
| 930       this, wsLabel.c_str(), wsValue.c_str(), nIndex); | 930       this, wsLabel.c_str(), wsValue.c_str(), nIndex); | 
| 931 } | 931 } | 
| 932 | 932 | 
| 933 void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue, | 933 void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue, | 
| 934                                    CFX_WideString& wsLabel) { | 934                                    CFX_WideString& wsLabel) { | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1067   CXFA_Node* pUIChild = GetUIChild(); | 1067   CXFA_Node* pUIChild = GetUIChild(); | 
| 1068   if (!pUIChild) | 1068   if (!pUIChild) | 
| 1069     return -1; | 1069     return -1; | 
| 1070   if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) | 1070   if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) | 
| 1071     return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); | 1071     return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells); | 
| 1072   return -1; | 1072   return -1; | 
| 1073 } | 1073 } | 
| 1074 | 1074 | 
| 1075 CFX_WideString CXFA_WidgetData::GetBarcodeType() { | 1075 CFX_WideString CXFA_WidgetData::GetBarcodeType() { | 
| 1076   CXFA_Node* pUIChild = GetUIChild(); | 1076   CXFA_Node* pUIChild = GetUIChild(); | 
| 1077   return pUIChild ? pUIChild->GetCData(XFA_ATTRIBUTE_Type) : NULL; | 1077   return pUIChild ? CFX_WideString(pUIChild->GetCData(XFA_ATTRIBUTE_Type)) | 
|  | 1078                   : nullptr; | 
| 1078 } | 1079 } | 
| 1079 | 1080 | 
| 1080 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { | 1081 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { | 
| 1081   CXFA_Node* pUIChild = GetUIChild(); | 1082   CXFA_Node* pUIChild = GetUIChild(); | 
| 1082   CFX_WideString wsCharEncoding; | 1083   CFX_WideString wsCharEncoding; | 
| 1083   if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { | 1084   if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) { | 
| 1084     if (wsCharEncoding.CompareNoCase(L"UTF-16")) { | 1085     if (wsCharEncoding.CompareNoCase(L"UTF-16")) { | 
| 1085       val = CHAR_ENCODING_UNICODE; | 1086       val = CHAR_ENCODING_UNICODE; | 
| 1086       return TRUE; | 1087       return TRUE; | 
| 1087     } else if (wsCharEncoding.CompareNoCase(L"UTF-8")) { | 1088     } | 
|  | 1089     if (wsCharEncoding.CompareNoCase(L"UTF-8")) { | 
| 1088       val = CHAR_ENCODING_UTF8; | 1090       val = CHAR_ENCODING_UTF8; | 
| 1089       return TRUE; | 1091       return TRUE; | 
| 1090     } | 1092     } | 
| 1091   } | 1093   } | 
| 1092   return FALSE; | 1094   return FALSE; | 
| 1093 } | 1095 } | 
| 1094 | 1096 | 
| 1095 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) { | 1097 FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) { | 
| 1096   CXFA_Node* pUIChild = GetUIChild(); | 1098   CXFA_Node* pUIChild = GetUIChild(); | 
| 1097   XFA_ATTRIBUTEENUM eChecksum; | 1099   XFA_ATTRIBUTEENUM eChecksum; | 
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1468   if (!m_pNode) | 1470   if (!m_pNode) | 
| 1469     return pLocale; | 1471     return pLocale; | 
| 1470 | 1472 | 
| 1471   FX_BOOL bLocale = FALSE; | 1473   FX_BOOL bLocale = FALSE; | 
| 1472   CFX_WideString wsLocaleName; | 1474   CFX_WideString wsLocaleName; | 
| 1473   bLocale = m_pNode->GetLocaleName(wsLocaleName); | 1475   bLocale = m_pNode->GetLocaleName(wsLocaleName); | 
| 1474   if (bLocale) { | 1476   if (bLocale) { | 
| 1475     if (wsLocaleName == FX_WSTRC(L"ambient")) { | 1477     if (wsLocaleName == FX_WSTRC(L"ambient")) { | 
| 1476       pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); | 1478       pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); | 
| 1477     } else { | 1479     } else { | 
| 1478       pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName( | 1480       pLocale = | 
| 1479           wsLocaleName.AsStringC()); | 1481           m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); | 
| 1480     } | 1482     } | 
| 1481   } | 1483   } | 
| 1482   return pLocale; | 1484   return pLocale; | 
| 1483 } | 1485 } | 
| 1484 | 1486 | 
| 1485 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, | 1487 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, | 
| 1486                                   XFA_VALUEPICTURE eValueType) { | 1488                                   XFA_VALUEPICTURE eValueType) { | 
| 1487   wsValue = m_pNode->GetContent(); | 1489   wsValue = m_pNode->GetContent(); | 
| 1488 | 1490 | 
| 1489   if (eValueType == XFA_VALUEPICTURE_Display) | 1491   if (eValueType == XFA_VALUEPICTURE_Display) | 
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1732 | 1734 | 
| 1733   CFX_WideString wsFormatValue(wsValue); | 1735   CFX_WideString wsFormatValue(wsValue); | 
| 1734   CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); | 1736   CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); | 
| 1735   if (pContainerWidgetData) | 1737   if (pContainerWidgetData) | 
| 1736     pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); | 1738     pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue); | 
| 1737 | 1739 | 
| 1738   m_pNode->SetContent(wsValue, wsFormatValue, bNotify); | 1740   m_pNode->SetContent(wsValue, wsFormatValue, bNotify); | 
| 1739 } | 1741 } | 
| 1740 | 1742 | 
| 1741 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, | 1743 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, | 
| 1742                                          const CFX_WideStringC& wsText, | 1744                                          const CFX_WideString& wsText, | 
| 1743                                          int32_t nIndex) { | 1745                                          int32_t nIndex) { | 
| 1744   CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); | 1746   CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); | 
| 1745   pItems->InsertChild(nIndex, pText); | 1747   pItems->InsertChild(nIndex, pText); | 
| 1746   pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); | 1748   pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE); | 
| 1747 } | 1749 } | 
| 1748 | 1750 | 
| 1749 CFX_WideString CXFA_WidgetData::NumericLimit(const CFX_WideString& wsValue, | 1751 CFX_WideString CXFA_WidgetData::NumericLimit(const CFX_WideString& wsValue, | 
| 1750                                              int32_t iLead, | 1752                                              int32_t iLead, | 
| 1751                                              int32_t iTread) const { | 1753                                              int32_t iTread) const { | 
| 1752   if ((iLead == -1) && (iTread == -1)) | 1754   if ((iLead == -1) && (iTread == -1)) | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 1782         } | 1784         } | 
| 1783       } | 1785       } | 
| 1784     } else if (wc == L'.') { | 1786     } else if (wc == L'.') { | 
| 1785       iTread_ = 0; | 1787       iTread_ = 0; | 
| 1786       iLead = -1; | 1788       iLead = -1; | 
| 1787     } | 1789     } | 
| 1788     wsRet += wc; | 1790     wsRet += wc; | 
| 1789   } | 1791   } | 
| 1790   return wsRet; | 1792   return wsRet; | 
| 1791 } | 1793 } | 
| OLD | NEW | 
|---|