OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, | 55 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, |
56 XFA_ObjectType objectType, | 56 XFA_ObjectType objectType, |
57 XFA_Element elementType) | 57 XFA_Element elementType) |
58 : m_pDocument(pDocument), | 58 : m_pDocument(pDocument), |
59 m_objectType(objectType), | 59 m_objectType(objectType), |
60 m_elementType(elementType) {} | 60 m_elementType(elementType) {} |
61 | 61 |
62 CXFA_Object::~CXFA_Object() {} | 62 CXFA_Object::~CXFA_Object() {} |
63 | 63 |
64 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { | 64 CFX_WideStringC CXFA_Object::GetClassName() const { |
65 wsName = XFA_GetElementByID(GetElementType())->pName; | 65 return XFA_GetElementByID(GetElementType())->pName; |
66 } | 66 } |
67 | 67 |
68 uint32_t CXFA_Object::GetClassHashCode() const { | 68 uint32_t CXFA_Object::GetClassHashCode() const { |
69 return XFA_GetElementByID(GetElementType())->uHash; | 69 return XFA_GetElementByID(GetElementType())->uHash; |
70 } | 70 } |
71 | 71 |
72 XFA_Element CXFA_Object::GetElementType() const { | 72 XFA_Element CXFA_Object::GetElementType() const { |
73 return m_elementType; | 73 return m_elementType; |
74 } | 74 } |
75 | 75 |
76 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, | 76 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, |
77 FX_BOOL bSetting, | 77 FX_BOOL bSetting, |
78 XFA_ATTRIBUTE eAttribute) { | 78 XFA_ATTRIBUTE eAttribute) { |
79 if (!bSetting) { | 79 if (!bSetting) { |
80 CFX_WideStringC className; | 80 CFX_WideStringC className = GetClassName(); |
81 GetClassName(className); | |
82 pValue->SetString( | 81 pValue->SetString( |
83 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); | 82 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); |
84 } else { | 83 } else { |
85 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 84 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
86 } | 85 } |
87 } | 86 } |
88 | 87 |
89 void CXFA_Object::ThrowException(int32_t iStringID, ...) { | 88 void CXFA_Object::ThrowException(int32_t iStringID, ...) { |
90 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 89 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
91 ASSERT(pAppProvider); | 90 ASSERT(pAppProvider); |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 743 } |
745 } | 744 } |
746 | 745 |
747 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, | 746 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, |
748 FX_BOOL bSetting, | 747 FX_BOOL bSetting, |
749 XFA_ATTRIBUTE eAttribute) { | 748 XFA_ATTRIBUTE eAttribute) { |
750 if (bSetting) { | 749 if (bSetting) { |
751 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 750 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
752 } else { | 751 } else { |
753 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; | 752 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; |
754 CFX_WideStringC wsName; | 753 CFX_WideString wsExpression = |
755 GetClassName(wsName); | 754 FX_WSTRC(L"#") + GetClassName() + FX_WSTRC(L"[*]"); |
756 CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); | |
757 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); | 755 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); |
758 } | 756 } |
759 } | 757 } |
760 | 758 |
761 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, | 759 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, |
762 FX_BOOL bSetting, | 760 FX_BOOL bSetting, |
763 XFA_ATTRIBUTE eAttribute) { | 761 XFA_ATTRIBUTE eAttribute) { |
764 if (bSetting) { | 762 if (bSetting) { |
765 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 763 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
766 } else { | 764 } else { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); | 956 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); |
959 if (!wsContentType.IsEmpty()) { | 957 if (!wsContentType.IsEmpty()) { |
960 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, | 958 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, |
961 CFX_WideString(wsContentType)); | 959 CFX_WideString(wsContentType)); |
962 } | 960 } |
963 CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); | 961 CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); |
964 if (!pFakeXMLRoot) { | 962 if (!pFakeXMLRoot) { |
965 CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); | 963 CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); |
966 pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : nullptr; | 964 pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : nullptr; |
967 } | 965 } |
968 if (!pFakeXMLRoot) { | 966 if (!pFakeXMLRoot) |
969 CFX_WideStringC wsClassName; | 967 pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(GetClassName())); |
970 GetClassName(wsClassName); | 968 |
971 pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(wsClassName)); | |
972 } | |
973 if (bIgnoreRoot) { | 969 if (bIgnoreRoot) { |
974 CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); | 970 CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); |
975 while (pXMLChild) { | 971 while (pXMLChild) { |
976 CFDE_XMLNode* pXMLSibling = | 972 CFDE_XMLNode* pXMLSibling = |
977 pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling); | 973 pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling); |
978 pXMLNode->RemoveChildNode(pXMLChild); | 974 pXMLNode->RemoveChildNode(pXMLChild); |
979 pFakeXMLRoot->InsertChildNode(pXMLChild); | 975 pFakeXMLRoot->InsertChildNode(pXMLChild); |
980 pXMLChild = pXMLSibling; | 976 pXMLChild = pXMLSibling; |
981 } | 977 } |
982 } else { | 978 } else { |
(...skipping 4280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5263 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5259 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
5264 } | 5260 } |
5265 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5261 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
5266 return m_pAttachNode->RemoveChild(pNode); | 5262 return m_pAttachNode->RemoveChild(pNode); |
5267 } | 5263 } |
5268 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5264 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
5269 return m_pAttachNode->GetChild( | 5265 return m_pAttachNode->GetChild( |
5270 iIndex, XFA_Element::Unknown, | 5266 iIndex, XFA_Element::Unknown, |
5271 m_pAttachNode->GetElementType() == XFA_Element::Subform); | 5267 m_pAttachNode->GetElementType() == XFA_Element::Subform); |
5272 } | 5268 } |
OLD | NEW |