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

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

Issue 2045883004: Remove more FXJSE c-method wrappers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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/fm2js/xfa_fm2jscontext.cpp ('k') | xfa/fxfa/parser/xfa_script_hostpseudomodel.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 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/parser/xfa_object.h" 7 #include "xfa/fxfa/parser/xfa_object.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); 97 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
98 ASSERT(pAppProvider); 98 ASSERT(pAppProvider);
99 CFX_WideString wsFormat; 99 CFX_WideString wsFormat;
100 pAppProvider->LoadString(iStringID, wsFormat); 100 pAppProvider->LoadString(iStringID, wsFormat);
101 CFX_WideString wsMessage; 101 CFX_WideString wsMessage;
102 va_list arg_ptr; 102 va_list arg_ptr;
103 va_start(arg_ptr, iStringID); 103 va_start(arg_ptr, iStringID);
104 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 104 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
105 va_end(arg_ptr); 105 va_end(arg_ptr);
106 FXJSE_ThrowMessage( 106 FXJSE_ThrowMessage(
107 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 107 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
108 } 108 }
109 109
110 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, 110 CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
111 uint16_t ePacket, 111 uint16_t ePacket,
112 XFA_ELEMENT eElement) 112 XFA_ELEMENT eElement)
113 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), 113 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)),
114 m_pNext(nullptr), 114 m_pNext(nullptr),
115 m_pChild(nullptr), 115 m_pChild(nullptr),
116 m_pLastChild(nullptr), 116 m_pLastChild(nullptr),
117 m_pParent(nullptr), 117 m_pParent(nullptr),
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 XFA_ATTRIBUTE eAttribute) { 738 XFA_ATTRIBUTE eAttribute) {
739 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); 739 CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
740 if (!pScriptContext) 740 if (!pScriptContext)
741 return; 741 return;
742 if (bSetting) { 742 if (bSetting) {
743 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); 743 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
744 ASSERT(pAppProvider); 744 ASSERT(pAppProvider);
745 CFX_WideString wsMessage; 745 CFX_WideString wsMessage;
746 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); 746 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage);
747 FXJSE_ThrowMessage( 747 FXJSE_ThrowMessage(
748 "",
749 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 748 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
750 } else { 749 } else {
751 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); 750 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this);
752 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); 751 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
753 } 752 }
754 } 753 }
755 754
756 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, 755 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue,
757 FX_BOOL bSetting, 756 FX_BOOL bSetting,
758 XFA_ATTRIBUTE eAttribute) { 757 XFA_ATTRIBUTE eAttribute) {
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 return; 1612 return;
1614 } else if (classID == XFA_ELEMENT_Draw) { 1613 } else if (classID == XFA_ELEMENT_Draw) {
1615 Script_Draw_DefaultValue(pValue, bSetting, eAttribute); 1614 Script_Draw_DefaultValue(pValue, bSetting, eAttribute);
1616 return; 1615 return;
1617 } else if (classID == XFA_ELEMENT_Boolean) { 1616 } else if (classID == XFA_ELEMENT_Boolean) {
1618 Script_Boolean_Value(pValue, bSetting, eAttribute); 1617 Script_Boolean_Value(pValue, bSetting, eAttribute);
1619 return; 1618 return;
1620 } 1619 }
1621 if (bSetting) { 1620 if (bSetting) {
1622 CFX_ByteString newValue; 1621 CFX_ByteString newValue;
1623 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) 1622 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
1624 pValue->ToString(newValue); 1623 pValue->ToString(newValue);
1625 1624
1626 CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC()); 1625 CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC());
1627 CFX_WideString wsFormatValue(wsNewValue); 1626 CFX_WideString wsFormatValue(wsNewValue);
1628 CXFA_WidgetData* pContainerWidgetData = nullptr; 1627 CXFA_WidgetData* pContainerWidgetData = nullptr;
1629 if (GetPacketID() == XFA_XDPPACKET_Datasets) { 1628 if (GetPacketID() == XFA_XDPPACKET_Datasets) {
1630 CXFA_NodeArray formNodes; 1629 CXFA_NodeArray formNodes;
1631 GetBindItems(formNodes); 1630 GetBindItems(formNodes);
1632 CFX_WideString wsPicture; 1631 CFX_WideString wsPicture;
1633 for (int32_t i = 0; i < formNodes.GetSize(); i++) { 1632 for (int32_t i = 0; i < formNodes.GetSize(); i++) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 } else { 1680 } else {
1682 pValue->SetString( 1681 pValue->SetString(
1683 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 1682 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
1684 } 1683 }
1685 } 1684 }
1686 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, 1685 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue,
1687 FX_BOOL bSetting, 1686 FX_BOOL bSetting,
1688 XFA_ATTRIBUTE eAttribute) { 1687 XFA_ATTRIBUTE eAttribute) {
1689 if (bSetting) { 1688 if (bSetting) {
1690 CFX_ByteString newValue; 1689 CFX_ByteString newValue;
1691 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) 1690 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
1692 pValue->ToString(newValue); 1691 pValue->ToString(newValue);
1693 1692
1694 int32_t iValue = FXSYS_atoi(newValue.c_str()); 1693 int32_t iValue = FXSYS_atoi(newValue.c_str());
1695 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1"); 1694 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1");
1696 CFX_WideString wsFormatValue(wsNewValue); 1695 CFX_WideString wsFormatValue(wsNewValue);
1697 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); 1696 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
1698 if (pContainerWidgetData) { 1697 if (pContainerWidgetData) {
1699 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); 1698 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
1700 } 1699 }
1701 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); 1700 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 pValue->SetNull(); 1888 pValue->SetNull();
1890 } 1889 }
1891 } else { 1890 } else {
1892 ThrowException(XFA_IDS_INVAlID_PROP_SET); 1891 ThrowException(XFA_IDS_INVAlID_PROP_SET);
1893 } 1892 }
1894 } 1893 }
1895 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, 1894 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
1896 FX_BOOL bSetting, 1895 FX_BOOL bSetting,
1897 XFA_ATTRIBUTE eAttribute) { 1896 XFA_ATTRIBUTE eAttribute) {
1898 if (bSetting) { 1897 if (bSetting) {
1899 if (FXJSE_Value_IsUTF8String(pValue)) { 1898 if (pValue && pValue->IsString()) {
1900 CXFA_WidgetData* pWidgetData = GetWidgetData(); 1899 CXFA_WidgetData* pWidgetData = GetWidgetData();
1901 ASSERT(pWidgetData); 1900 ASSERT(pWidgetData);
1902 XFA_ELEMENT uiType = pWidgetData->GetUIType(); 1901 XFA_ELEMENT uiType = pWidgetData->GetUIType();
1903 if (uiType == XFA_ELEMENT_Text) { 1902 if (uiType == XFA_ELEMENT_Text) {
1904 CFX_ByteString newValue; 1903 CFX_ByteString newValue;
1905 pValue->ToString(newValue); 1904 pValue->ToString(newValue);
1906 CFX_WideString wsNewValue = 1905 CFX_WideString wsNewValue =
1907 CFX_WideString::FromUTF8(newValue.AsStringC()); 1906 CFX_WideString::FromUTF8(newValue.AsStringC());
1908 CFX_WideString wsFormatValue(wsNewValue); 1907 CFX_WideString wsFormatValue(wsNewValue);
1909 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); 1908 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
1910 } else if (uiType != XFA_ELEMENT_Image) {
1911 } 1909 }
1912 } 1910 }
1913 } else { 1911 } else {
1914 CFX_WideString content = GetScriptContent(TRUE); 1912 CFX_WideString content = GetScriptContent(TRUE);
1915 if (content.IsEmpty()) { 1913 if (content.IsEmpty()) {
1916 pValue->SetNull(); 1914 pValue->SetNull();
1917 } else { 1915 } else {
1918 pValue->SetString( 1916 pValue->SetString(
1919 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); 1917 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
1920 } 1918 }
1921 } 1919 }
1922 } 1920 }
1923 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, 1921 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue,
1924 FX_BOOL bSetting, 1922 FX_BOOL bSetting,
1925 XFA_ATTRIBUTE eAttribute) { 1923 XFA_ATTRIBUTE eAttribute) {
1926 CXFA_WidgetData* pWidgetData = GetWidgetData(); 1924 CXFA_WidgetData* pWidgetData = GetWidgetData();
1927 if (!pWidgetData) { 1925 if (!pWidgetData) {
1928 return; 1926 return;
1929 } 1927 }
1930 if (bSetting) { 1928 if (bSetting) {
1931 if (FXJSE_Value_IsNull(pValue)) { 1929 if (pValue && pValue->IsNull()) {
1932 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; 1930 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
1933 pWidgetData->m_bIsNull = TRUE; 1931 pWidgetData->m_bIsNull = TRUE;
1934 } else { 1932 } else {
1935 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; 1933 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
1936 pWidgetData->m_bIsNull = FALSE; 1934 pWidgetData->m_bIsNull = FALSE;
1937 } 1935 }
1938 CFX_ByteString newValue; 1936 CFX_ByteString newValue;
1939 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) 1937 if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
1940 pValue->ToString(newValue); 1938 pValue->ToString(newValue);
1941 1939
1942 CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC()); 1940 CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC());
1943 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); 1941 CXFA_Node* pUIChild = pWidgetData->GetUIChild();
1944 if (pUIChild->GetClassID() == XFA_ELEMENT_NumericEdit) { 1942 if (pUIChild->GetClassID() == XFA_ELEMENT_NumericEdit) {
1945 int32_t iLeadDigits = 0; 1943 int32_t iLeadDigits = 0;
1946 int32_t iFracDigits = 0; 1944 int32_t iFracDigits = 0;
1947 pWidgetData->GetLeadDigits(iLeadDigits); 1945 pWidgetData->GetLeadDigits(iLeadDigits);
1948 pWidgetData->GetFracDigits(iFracDigits); 1946 pWidgetData->GetFracDigits(iFracDigits);
1949 wsNewText = 1947 wsNewText =
(...skipping 3330 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); 5278 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode);
5281 } 5279 }
5282 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { 5280 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
5283 return m_pAttachNode->RemoveChild(pNode); 5281 return m_pAttachNode->RemoveChild(pNode);
5284 } 5282 }
5285 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { 5283 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) {
5286 return m_pAttachNode->GetChild( 5284 return m_pAttachNode->GetChild(
5287 iIndex, XFA_ELEMENT_UNKNOWN, 5285 iIndex, XFA_ELEMENT_UNKNOWN,
5288 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); 5286 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform);
5289 } 5287 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.cpp ('k') | xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698