summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_validatedata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_validatedata.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_validatedata.cpp81
1 files changed, 45 insertions, 36 deletions
diff --git a/xfa/fxfa/parser/cxfa_validatedata.cpp b/xfa/fxfa/parser/cxfa_validatedata.cpp
index 94c5829288..8b3f539d48 100644
--- a/xfa/fxfa/parser/cxfa_validatedata.cpp
+++ b/xfa/fxfa/parser/cxfa_validatedata.cpp
@@ -9,35 +9,42 @@
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/xfa_utils.h"
+namespace {
+
+constexpr wchar_t kFormatTest[] = L"formatTest";
+constexpr wchar_t kNullTest[] = L"nullTest";
+constexpr wchar_t kScriptTest[] = L"scriptTest";
+
+} // namespace
+
CXFA_ValidateData::CXFA_ValidateData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-int32_t CXFA_ValidateData::GetFormatTest() {
+XFA_ATTRIBUTEENUM CXFA_ValidateData::GetFormatTest() const {
return m_pNode->JSNode()->GetEnum(XFA_Attribute::FormatTest);
}
-bool CXFA_ValidateData::SetNullTest(WideString wsValue) {
+void CXFA_ValidateData::SetNullTest(const WideString& wsValue) {
const XFA_ATTRIBUTEENUMINFO* pInfo =
XFA_GetAttributeEnumByName(wsValue.AsStringView());
m_pNode->JSNode()->SetEnum(XFA_Attribute::NullTest,
pInfo ? pInfo->eName : XFA_ATTRIBUTEENUM_Disabled,
false);
- return true;
}
-int32_t CXFA_ValidateData::GetNullTest() {
+XFA_ATTRIBUTEENUM CXFA_ValidateData::GetNullTest() const {
return m_pNode->JSNode()->GetEnum(XFA_Attribute::NullTest);
}
-int32_t CXFA_ValidateData::GetScriptTest() {
+XFA_ATTRIBUTEENUM CXFA_ValidateData::GetScriptTest() const {
return m_pNode->JSNode()->GetEnum(XFA_Attribute::ScriptTest);
}
-void CXFA_ValidateData::GetMessageText(WideString& wsMessage,
- const WideString& wsMessageType) {
+WideString CXFA_ValidateData::GetMessageText(
+ const WideString& wsMessageType) const {
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Message, false);
if (!pNode)
- return;
+ return L"";
for (CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
pItemNode;
@@ -46,38 +53,45 @@ void CXFA_ValidateData::GetMessageText(WideString& wsMessage,
continue;
WideString wsName = pItemNode->JSNode()->GetCData(XFA_Attribute::Name);
- if (wsName.IsEmpty() || wsName == wsMessageType) {
- wsMessage = pItemNode->JSNode()->GetContent(false);
- return;
- }
+ if (wsName.IsEmpty() || wsName == wsMessageType)
+ return pItemNode->JSNode()->GetContent(false);
}
+ return L"";
+}
+
+void CXFA_ValidateData::SetFormatMessageText(const WideString& wsMessage) {
+ SetMessageText(kFormatTest, wsMessage);
}
-void CXFA_ValidateData::SetFormatMessageText(WideString wsMessage) {
- SetMessageText(wsMessage, L"formatTest");
+WideString CXFA_ValidateData::GetFormatMessageText() const {
+ return GetMessageText(kFormatTest);
}
-void CXFA_ValidateData::GetFormatMessageText(WideString& wsMessage) {
- GetMessageText(wsMessage, L"formatTest");
+void CXFA_ValidateData::SetNullMessageText(const WideString& wsMessage) {
+ SetMessageText(kNullTest, wsMessage);
}
-void CXFA_ValidateData::SetNullMessageText(WideString wsMessage) {
- SetMessageText(wsMessage, L"nullTest");
+WideString CXFA_ValidateData::GetNullMessageText() const {
+ return GetMessageText(kNullTest);
}
-void CXFA_ValidateData::GetNullMessageText(WideString& wsMessage) {
- GetMessageText(wsMessage, L"nullTest");
+WideString CXFA_ValidateData::GetScriptMessageText() const {
+ return GetMessageText(kScriptTest);
}
-void CXFA_ValidateData::SetMessageText(WideString& wsMessage,
- const WideString& wsMessageType) {
+void CXFA_ValidateData::SetScriptMessageText(const WideString& wsMessage) {
+ SetMessageText(kScriptTest, wsMessage);
+}
+
+void CXFA_ValidateData::SetMessageText(const WideString& wsMessageType,
+ const WideString& wsMessage) {
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Message, true);
if (!pNode)
return;
- CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pItemNode;
+ for (CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ pItemNode;
pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pItemNode->GetElementType() != XFA_Element::Text)
continue;
@@ -88,6 +102,7 @@ void CXFA_ValidateData::SetMessageText(WideString& wsMessage,
return;
}
}
+
CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_Element::Text);
pNode->InsertChild(pTextNode, nullptr);
pTextNode->JSNode()->SetCData(XFA_Attribute::Name, wsMessageType, false,
@@ -95,19 +110,13 @@ void CXFA_ValidateData::SetMessageText(WideString& wsMessage,
pTextNode->JSNode()->SetContent(wsMessage, wsMessage, false, false, true);
}
-void CXFA_ValidateData::GetScriptMessageText(WideString& wsMessage) {
- GetMessageText(wsMessage, L"scriptTest");
-}
-
-void CXFA_ValidateData::SetScriptMessageText(WideString wsMessage) {
- SetMessageText(wsMessage, L"scriptTest");
-}
-
-void CXFA_ValidateData::GetPicture(WideString& wsPicture) {
- if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Picture, false))
- wsPicture = pNode->JSNode()->GetContent(false);
+WideString CXFA_ValidateData::GetPicture() const {
+ CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Picture, false);
+ if (pNode)
+ return pNode->JSNode()->GetContent(false);
+ return L"";
}
-CXFA_ScriptData CXFA_ValidateData::GetScriptData() {
+CXFA_ScriptData CXFA_ValidateData::GetScriptData() const {
return CXFA_ScriptData(m_pNode->GetChild(0, XFA_Element::Script, false));
}