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_validate.h" | 7 #include "xfa/fxfa/parser/cxfa_validate.h" |
8 | 8 |
9 #include "xfa/fxfa/parser/xfa_object.h" | 9 #include "xfa/fxfa/parser/xfa_object.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 int32_t CXFA_Validate::GetNullTest() { | 34 int32_t CXFA_Validate::GetNullTest() { |
35 return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest); | 35 return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest); |
36 } | 36 } |
37 | 37 |
38 int32_t CXFA_Validate::GetScriptTest() { | 38 int32_t CXFA_Validate::GetScriptTest() { |
39 return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest); | 39 return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest); |
40 } | 40 } |
41 | 41 |
42 void CXFA_Validate::GetMessageText(CFX_WideString& wsMessage, | 42 void CXFA_Validate::GetMessageText(CFX_WideString& wsMessage, |
43 const CFX_WideString& wsMessageType) { | 43 const CFX_WideString& wsMessageType) { |
44 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, FALSE); | 44 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Message, FALSE); |
45 if (!pNode) | 45 if (!pNode) |
46 return; | 46 return; |
47 | 47 |
48 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 48 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
49 for (; pItemNode; | 49 for (; pItemNode; |
50 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 50 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
51 if (pItemNode->GetClassID() != XFA_ELEMENT_Text) | 51 if (pItemNode->GetClassID() != XFA_Element::Text) |
52 continue; | 52 continue; |
53 | 53 |
54 CFX_WideStringC wsName; | 54 CFX_WideStringC wsName; |
55 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName); | 55 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName); |
56 if (wsName.IsEmpty() || wsName == wsMessageType) { | 56 if (wsName.IsEmpty() || wsName == wsMessageType) { |
57 pItemNode->TryContent(wsMessage); | 57 pItemNode->TryContent(wsMessage); |
58 return; | 58 return; |
59 } | 59 } |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) { | 63 void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) { |
64 SetMessageText(wsMessage, L"formatTest"); | 64 SetMessageText(wsMessage, L"formatTest"); |
65 } | 65 } |
66 | 66 |
67 void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) { | 67 void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) { |
68 GetMessageText(wsMessage, L"formatTest"); | 68 GetMessageText(wsMessage, L"formatTest"); |
69 } | 69 } |
70 | 70 |
71 void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) { | 71 void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) { |
72 SetMessageText(wsMessage, L"nullTest"); | 72 SetMessageText(wsMessage, L"nullTest"); |
73 } | 73 } |
74 | 74 |
75 void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) { | 75 void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) { |
76 GetMessageText(wsMessage, L"nullTest"); | 76 GetMessageText(wsMessage, L"nullTest"); |
77 } | 77 } |
78 | 78 |
79 void CXFA_Validate::SetMessageText(CFX_WideString& wsMessage, | 79 void CXFA_Validate::SetMessageText(CFX_WideString& wsMessage, |
80 const CFX_WideString& wsMessageType) { | 80 const CFX_WideString& wsMessageType) { |
81 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, TRUE); | 81 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Message, TRUE); |
82 if (!pNode) | 82 if (!pNode) |
83 return; | 83 return; |
84 | 84 |
85 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 85 CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
86 for (; pItemNode; | 86 for (; pItemNode; |
87 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 87 pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
88 if (pItemNode->GetClassID() != XFA_ELEMENT_Text) | 88 if (pItemNode->GetClassID() != XFA_Element::Text) |
89 continue; | 89 continue; |
90 | 90 |
91 CFX_WideStringC wsName; | 91 CFX_WideStringC wsName; |
92 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName); | 92 pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName); |
93 if (wsName.IsEmpty() || wsName == wsMessageType) { | 93 if (wsName.IsEmpty() || wsName == wsMessageType) { |
94 pItemNode->SetContent(wsMessage, wsMessage, FALSE); | 94 pItemNode->SetContent(wsMessage, wsMessage, FALSE); |
95 return; | 95 return; |
96 } | 96 } |
97 } | 97 } |
98 CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_ELEMENT_Text); | 98 CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_Element::Text); |
99 pNode->InsertChild(pTextNode); | 99 pNode->InsertChild(pTextNode); |
100 pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, FALSE); | 100 pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, FALSE); |
101 pTextNode->SetContent(wsMessage, wsMessage, FALSE); | 101 pTextNode->SetContent(wsMessage, wsMessage, FALSE); |
102 } | 102 } |
103 | 103 |
104 void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) { | 104 void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) { |
105 GetMessageText(wsMessage, L"scriptTest"); | 105 GetMessageText(wsMessage, L"scriptTest"); |
106 } | 106 } |
107 | 107 |
108 void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) { | 108 void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) { |
109 SetMessageText(wsMessage, L"scriptTest"); | 109 SetMessageText(wsMessage, L"scriptTest"); |
110 } | 110 } |
111 | 111 |
112 void CXFA_Validate::GetPicture(CFX_WideString& wsPicture) { | 112 void CXFA_Validate::GetPicture(CFX_WideString& wsPicture) { |
113 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) | 113 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Picture)) |
114 pNode->TryContent(wsPicture); | 114 pNode->TryContent(wsPicture); |
115 } | 115 } |
116 | 116 |
117 CXFA_Script CXFA_Validate::GetScript() { | 117 CXFA_Script CXFA_Validate::GetScript() { |
118 return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script)); | 118 return CXFA_Script(m_pNode->GetChild(0, XFA_Element::Script)); |
119 } | 119 } |
OLD | NEW |