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

Side by Side Diff: xfa/fxfa/parser/cxfa_widgetdata.cpp

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. Created 4 years, 8 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/parser/cxfa_validate.cpp ('k') | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp » ('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 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 break; 813 break;
814 } 814 }
815 } 815 }
816 SetSelectedItems(iSelArray, bNotify, bScriptModify, bSyncData); 816 SetSelectedItems(iSelArray, bNotify, bScriptModify, bSyncData);
817 } 817 }
818 } else { 818 } else {
819 if (bSelected) { 819 if (bSelected) {
820 if (iSel < 0) { 820 if (iSel < 0) {
821 CFX_WideString wsSaveText = wsSaveTextArray[nIndex]; 821 CFX_WideString wsSaveText = wsSaveTextArray[nIndex];
822 CFX_WideString wsFormatText(wsSaveText); 822 CFX_WideString wsFormatText(wsSaveText);
823 GetFormatDataValue(wsSaveText.AsWideStringC(), wsFormatText); 823 GetFormatDataValue(wsSaveText.AsStringC(), wsFormatText);
824 m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify, 824 m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify,
825 bSyncData); 825 bSyncData);
826 } 826 }
827 } else if (iSel >= 0) { 827 } else if (iSel >= 0) {
828 m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify, 828 m_pNode->SetContent(CFX_WideString(), CFX_WideString(), bNotify,
829 bScriptModify, bSyncData); 829 bScriptModify, bSyncData);
830 } 830 }
831 } 831 }
832 } 832 }
833 833
834 void CXFA_WidgetData::SetSelectedItems(CFX_Int32Array& iSelArray, 834 void CXFA_WidgetData::SetSelectedItems(CFX_Int32Array& iSelArray,
835 FX_BOOL bNotify, 835 FX_BOOL bNotify,
836 FX_BOOL bScriptModify, 836 FX_BOOL bScriptModify,
837 FX_BOOL bSyncData) { 837 FX_BOOL bSyncData) {
838 CFX_WideString wsValue; 838 CFX_WideString wsValue;
839 int32_t iSize = iSelArray.GetSize(); 839 int32_t iSize = iSelArray.GetSize();
840 if (iSize >= 1) { 840 if (iSize >= 1) {
841 CFX_WideStringArray wsSaveTextArray; 841 CFX_WideStringArray wsSaveTextArray;
842 GetChoiceListItems(wsSaveTextArray, TRUE); 842 GetChoiceListItems(wsSaveTextArray, TRUE);
843 CFX_WideString wsItemValue; 843 CFX_WideString wsItemValue;
844 for (int32_t i = 0; i < iSize; i++) { 844 for (int32_t i = 0; i < iSize; i++) {
845 wsItemValue = (iSize == 1) 845 wsItemValue = (iSize == 1)
846 ? wsSaveTextArray[iSelArray[i]] 846 ? wsSaveTextArray[iSelArray[i]]
847 : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n"); 847 : wsSaveTextArray[iSelArray[i]] + FX_WSTRC(L"\n");
848 wsValue += wsItemValue; 848 wsValue += wsItemValue;
849 } 849 }
850 } 850 }
851 CFX_WideString wsFormat(wsValue); 851 CFX_WideString wsFormat(wsValue);
852 if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) 852 if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect)
853 GetFormatDataValue(wsValue.AsWideStringC(), wsFormat); 853 GetFormatDataValue(wsValue.AsStringC(), wsFormat);
854 854
855 m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData); 855 m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData);
856 } 856 }
857 857
858 void CXFA_WidgetData::ClearAllSelections() { 858 void CXFA_WidgetData::ClearAllSelections() {
859 CXFA_Node* pBind = m_pNode->GetBindData(); 859 CXFA_Node* pBind = m_pNode->GetBindData();
860 if (pBind && GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { 860 if (pBind && GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
861 while (CXFA_Node* pChildNode = 861 while (CXFA_Node* pChildNode =
862 pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) { 862 pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) {
863 pBind->RemoveChild(pChildNode); 863 pBind->RemoveChild(pChildNode);
(...skipping 18 matching lines...) Expand all
882 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 882 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
883 if (pItemNode->GetClassID() != XFA_ELEMENT_Items) 883 if (pItemNode->GetClassID() != XFA_ELEMENT_Items)
884 continue; 884 continue;
885 885
886 listitems.Add(pItemNode); 886 listitems.Add(pItemNode);
887 iCount++; 887 iCount++;
888 } 888 }
889 if (iCount < 1) { 889 if (iCount < 1) {
890 CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); 890 CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items);
891 m_pNode->InsertChild(-1, pItems); 891 m_pNode->InsertChild(-1, pItems);
892 InsertListTextItem(pItems, wsLabel.AsWideStringC(), nIndex); 892 InsertListTextItem(pItems, wsLabel.AsStringC(), nIndex);
893 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); 893 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items);
894 m_pNode->InsertChild(-1, pSaveItems); 894 m_pNode->InsertChild(-1, pSaveItems);
895 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); 895 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE);
896 InsertListTextItem(pSaveItems, wsNewValue.AsWideStringC(), nIndex); 896 InsertListTextItem(pSaveItems, wsNewValue.AsStringC(), nIndex);
897 } else if (iCount > 1) { 897 } else if (iCount > 1) {
898 for (int32_t i = 0; i < 2; i++) { 898 for (int32_t i = 0; i < 2; i++) {
899 CXFA_Node* pNode = listitems[i]; 899 CXFA_Node* pNode = listitems[i];
900 FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save); 900 FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save);
901 if (bHasSave) 901 if (bHasSave)
902 InsertListTextItem(pNode, wsNewValue.AsWideStringC(), nIndex); 902 InsertListTextItem(pNode, wsNewValue.AsStringC(), nIndex);
903 else 903 else
904 InsertListTextItem(pNode, wsLabel.AsWideStringC(), nIndex); 904 InsertListTextItem(pNode, wsLabel.AsStringC(), nIndex);
905 } 905 }
906 } else { 906 } else {
907 CXFA_Node* pNode = listitems[0]; 907 CXFA_Node* pNode = listitems[0];
908 pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE); 908 pNode->SetBoolean(XFA_ATTRIBUTE_Save, FALSE);
909 pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible); 909 pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible);
910 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items); 910 CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items);
911 m_pNode->InsertChild(-1, pSaveItems); 911 m_pNode->InsertChild(-1, pSaveItems);
912 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE); 912 pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE);
913 pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden); 913 pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden);
914 listitems.RemoveAll(); 914 listitems.RemoveAll();
915 CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 915 CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
916 int32_t i = 0; 916 int32_t i = 0;
917 while (pListNode) { 917 while (pListNode) {
918 CFX_WideString wsOldValue; 918 CFX_WideString wsOldValue;
919 pListNode->TryContent(wsOldValue); 919 pListNode->TryContent(wsOldValue);
920 InsertListTextItem(pSaveItems, wsOldValue.AsWideStringC(), i); 920 InsertListTextItem(pSaveItems, wsOldValue.AsStringC(), i);
921 i++; 921 i++;
922 pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); 922 pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling);
923 } 923 }
924 InsertListTextItem(pNode, wsLabel.AsWideStringC(), nIndex); 924 InsertListTextItem(pNode, wsLabel.AsStringC(), nIndex);
925 InsertListTextItem(pSaveItems, wsNewValue.AsWideStringC(), nIndex); 925 InsertListTextItem(pSaveItems, wsNewValue.AsStringC(), nIndex);
926 } 926 }
927 if (!bNotify) 927 if (!bNotify)
928 return; 928 return;
929 929
930 m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent( 930 m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent(
931 this, XFA_WIDGETEVENT_ListItemAdded, (void*)(const FX_WCHAR*)wsLabel, 931 this, XFA_WIDGETEVENT_ListItemAdded, (void*)(const FX_WCHAR*)wsLabel,
932 (void*)(const FX_WCHAR*)wsValue, (void*)(uintptr_t)nIndex); 932 (void*)(const FX_WCHAR*)wsValue, (void*)(uintptr_t)nIndex);
933 } 933 }
934 934
935 void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue, 935 void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue,
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 return pLocale; 1474 return pLocale;
1475 1475
1476 FX_BOOL bLocale = FALSE; 1476 FX_BOOL bLocale = FALSE;
1477 CFX_WideString wsLocaleName; 1477 CFX_WideString wsLocaleName;
1478 bLocale = m_pNode->GetLocaleName(wsLocaleName); 1478 bLocale = m_pNode->GetLocaleName(wsLocaleName);
1479 if (bLocale) { 1479 if (bLocale) {
1480 if (wsLocaleName == FX_WSTRC(L"ambient")) { 1480 if (wsLocaleName == FX_WSTRC(L"ambient")) {
1481 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); 1481 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale();
1482 } else { 1482 } else {
1483 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName( 1483 pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(
1484 wsLocaleName.AsWideStringC()); 1484 wsLocaleName.AsStringC());
1485 } 1485 }
1486 } 1486 }
1487 return pLocale; 1487 return pLocale;
1488 } 1488 }
1489 1489
1490 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, 1490 FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
1491 XFA_VALUEPICTURE eValueType) { 1491 XFA_VALUEPICTURE eValueType) {
1492 wsValue = m_pNode->GetContent(); 1492 wsValue = m_pNode->GetContent();
1493 1493
1494 if (eValueType == XFA_VALUEPICTURE_Display) 1494 if (eValueType == XFA_VALUEPICTURE_Display)
1495 GetItemLabel(wsValue.AsWideStringC(), wsValue); 1495 GetItemLabel(wsValue.AsStringC(), wsValue);
1496 1496
1497 CFX_WideString wsPicture; 1497 CFX_WideString wsPicture;
1498 GetPictureContent(wsPicture, eValueType); 1498 GetPictureContent(wsPicture, eValueType);
1499 CXFA_Node* pNode = GetUIChild(); 1499 CXFA_Node* pNode = GetUIChild();
1500 if (!pNode) 1500 if (!pNode)
1501 return TRUE; 1501 return TRUE;
1502 1502
1503 XFA_ELEMENT uiType = GetUIChild()->GetClassID(); 1503 XFA_ELEMENT uiType = GetUIChild()->GetClassID();
1504 switch (uiType) { 1504 switch (uiType) {
1505 case XFA_ELEMENT_ChoiceList: { 1505 case XFA_ELEMENT_ChoiceList: {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 } 1731 }
1732 1732
1733 void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue, 1733 void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue,
1734 FX_BOOL bNotify) { 1734 FX_BOOL bNotify) {
1735 if (!m_pNode) 1735 if (!m_pNode)
1736 return; 1736 return;
1737 1737
1738 CFX_WideString wsFormatValue(wsValue); 1738 CFX_WideString wsFormatValue(wsValue);
1739 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData(); 1739 CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData();
1740 if (pContainerWidgetData) 1740 if (pContainerWidgetData)
1741 pContainerWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), 1741 pContainerWidgetData->GetFormatDataValue(wsValue.AsStringC(),
1742 wsFormatValue); 1742 wsFormatValue);
1743 1743
1744 m_pNode->SetContent(wsValue, wsFormatValue, bNotify); 1744 m_pNode->SetContent(wsValue, wsFormatValue, bNotify);
1745 } 1745 }
1746 1746
1747 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems, 1747 void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems,
1748 const CFX_WideStringC& wsText, 1748 const CFX_WideStringC& wsText,
1749 int32_t nIndex) { 1749 int32_t nIndex) {
1750 CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text); 1750 CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text);
1751 pItems->InsertChild(nIndex, pText); 1751 pItems->InsertChild(nIndex, pText);
(...skipping 21 matching lines...) Expand all
1773 FX_WCHAR wc = wsValue[i]; 1773 FX_WCHAR wc = wsValue[i];
1774 if (XFA_IsDigit(wc)) { 1774 if (XFA_IsDigit(wc)) {
1775 if (iLead >= 0) { 1775 if (iLead >= 0) {
1776 iLead_++; 1776 iLead_++;
1777 if (iLead_ > iLead) 1777 if (iLead_ > iLead)
1778 return L"0"; 1778 return L"0";
1779 } else if (iTread_ >= 0) { 1779 } else if (iTread_ >= 0) {
1780 iTread_++; 1780 iTread_++;
1781 if (iTread_ > iTread) { 1781 if (iTread_ > iTread) {
1782 if (iTread != -1) { 1782 if (iTread != -1) {
1783 CFX_Decimal wsDeci = CFX_Decimal(wsValue.AsWideStringC()); 1783 CFX_Decimal wsDeci = CFX_Decimal(wsValue.AsStringC());
1784 wsDeci.SetScale(iTread); 1784 wsDeci.SetScale(iTread);
1785 wsRet = wsDeci; 1785 wsRet = wsDeci;
1786 } 1786 }
1787 return wsRet; 1787 return wsRet;
1788 } 1788 }
1789 } 1789 }
1790 } else if (wc == L'.') { 1790 } else if (wc == L'.') {
1791 iTread_ = 0; 1791 iTread_ = 0;
1792 iLead = -1; 1792 iLead = -1;
1793 } 1793 }
1794 wsRet += wc; 1794 wsRet += wc;
1795 } 1795 }
1796 return wsRet; 1796 return wsRet;
1797 } 1797 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_validate.cpp ('k') | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698