7#include "xfa/fxfa/parser/cxfa_validate.h"
9#include "fxjs/xfa/cjx_node.h"
10#include "fxjs/xfa/cjx_object.h"
11#include "xfa/fxfa/parser/cxfa_document.h"
12#include "xfa/fxfa/parser/cxfa_message.h"
13#include "xfa/fxfa/parser/cxfa_picture.h"
14#include "xfa/fxfa/parser/cxfa_script.h"
15#include "xfa/fxfa/parser/xfa_basic_data.h"
39constexpr wchar_t kFormatTest[] = L"formatTest";
40constexpr wchar_t kNullTest[] = L"nullTest";
41constexpr wchar_t kScriptTest[] = L"scriptTest";
45CXFA_Validate::CXFA_Validate(CXFA_Document* doc,
XFA_PacketType packet)
48 {XFA_XDPPACKET::kConfig, XFA_XDPPACKET::kTemplate,
49 XFA_XDPPACKET::kForm},
50 XFA_ObjectType::ContentNode,
51 XFA_Element::Validate,
52 kValidatePropertyData,
53 kValidateAttributeData,
54 cppgc::MakeGarbageCollected<CJX_Node>(
55 doc->GetHeap()->GetAllocationHandle(),
65 absl::optional<XFA_AttributeValue> item =
66 XFA_GetAttributeValueByName(wsValue.AsStringView());
68 XFA_Attribute::NullTest,
69 item.has_value() ? item.value() : XFA_AttributeValue::Disabled,
false);
80WideString CXFA_Validate::GetMessageText(
const WideString& wsMessageType) {
82 JSObject()->GetProperty<CXFA_Message>(0,
XFA_Element::Message);
86 for (
CXFA_Node* pItemNode = pNode->GetFirstChild(); pItemNode;
87 pItemNode = pItemNode->GetNextSibling()) {
91 WideString wsName = pItemNode->JSObject()->GetCData(
XFA_Attribute::Name);
93 return pItemNode->JSObject()->GetContent(
false);
99 SetMessageText(kFormatTest, wsMessage);
103 return GetMessageText(kFormatTest);
107 SetMessageText(kNullTest, wsMessage);
111 return GetMessageText(kNullTest);
115 return GetMessageText(kScriptTest);
119 SetMessageText(kScriptTest, wsMessage);
122void CXFA_Validate::SetMessageText(
const WideString& wsMessageType,
123 const WideString& wsMessage) {
124 CXFA_Message* pNode =
125 JSObject()->GetOrCreateProperty<CXFA_Message>(0,
XFA_Element::Message);
129 for (
CXFA_Node* pItemNode = pNode->GetFirstChild(); pItemNode;
130 pItemNode = pItemNode->GetNextSibling()) {
134 WideString wsName = pItemNode->JSObject()->GetCData(
XFA_Attribute::Name);
136 pItemNode->JSObject()->SetContent(wsMessage, wsMessage,
false,
false,
143 pNode->InsertChildAndNotify(pTextNode,
nullptr);
144 pTextNode->JSObject()->SetCData(
XFA_Attribute::Name, wsMessageType);
145 pTextNode->JSObject()->SetContent(wsMessage, wsMessage,
false,
false,
true);
149 const auto* pNode = GetChild<CXFA_Picture>(0,
XFA_Element::Picture,
false);
150 return pNode ? pNode->JSObject()->GetContent(
false) : WideString
();
154 return GetChild<CXFA_Script>(0,
XFA_Element::Script,
false);
CXFA_Node * CreateSamePacketNode(XFA_Element eType)
XFA_Element GetElementType() const
XFA_AttributeValue GetNullTest()
~CXFA_Validate() override
XFA_AttributeValue GetFormatTest()
void SetScriptMessageText(const WideString &wsMessage)
WideString GetNullMessageText()
WideString GetScriptMessageText()
CXFA_Script * GetScriptIfExists()
void SetNullTest(const WideString &wsValue)
XFA_AttributeValue GetScriptTest()
WideString GetPicture() const
void SetNullMessageText(const WideString &wsMessage)
WideString GetFormatMessageText()
void SetFormatMessageText(const WideString &wsMessage)
bool operator==(const WideString &other) const