summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/xfa/cjx_object.cpp40
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_node.h4
5 files changed, 32 insertions, 22 deletions
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 7b1bb3cbef..027c151d3f 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1395,26 +1395,29 @@ void CJX_Object::Script_Som_Message(CFXJSE_Value* pValue,
bool bSetting,
XFA_SOM_MESSAGETYPE iMessageType) {
bool bNew = false;
- CXFA_Validate* validate = ToNode(object_.Get())->GetValidate();
+ CXFA_Validate* validate = ToNode(object_.Get())->GetValidateIfExists();
if (!validate) {
- validate = ToNode(object_.Get())->GetOrCreateValidate();
+ validate = ToNode(object_.Get())->GetOrCreateValidateIfPossible();
bNew = true;
}
if (bSetting) {
- switch (iMessageType) {
- case XFA_SOM_ValidationMessage:
- validate->SetScriptMessageText(pValue->ToWideString());
- break;
- case XFA_SOM_FormatMessage:
- validate->SetFormatMessageText(pValue->ToWideString());
- break;
- case XFA_SOM_MandatoryMessage:
- validate->SetNullMessageText(pValue->ToWideString());
- break;
- default:
- break;
+ if (validate) {
+ switch (iMessageType) {
+ case XFA_SOM_ValidationMessage:
+ validate->SetScriptMessageText(pValue->ToWideString());
+ break;
+ case XFA_SOM_FormatMessage:
+ validate->SetFormatMessageText(pValue->ToWideString());
+ break;
+ case XFA_SOM_MandatoryMessage:
+ validate->SetNullMessageText(pValue->ToWideString());
+ break;
+ default:
+ break;
+ }
}
+
if (!bNew) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
@@ -1425,6 +1428,12 @@ void CJX_Object::Script_Som_Message(CFXJSE_Value* pValue,
return;
}
+ if (!validate) {
+ // TODO(dsinclair): Better error message?
+ ThrowInvalidPropertyException();
+ return;
+ }
+
WideString wsMessage;
switch (iMessageType) {
case XFA_SOM_ValidationMessage:
@@ -1579,7 +1588,8 @@ void CJX_Object::Script_Som_DataNode(CFXJSE_Value* pValue,
void CJX_Object::Script_Som_Mandatory(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_Validate* validate = ToNode(object_.Get())->GetOrCreateValidate();
+ CXFA_Validate* validate =
+ ToNode(object_.Get())->GetOrCreateValidateIfPossible();
if (!validate)
return;
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 94931bda33..31996315df 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -228,7 +228,7 @@ bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) {
pWidgetAcc->ResetData();
pWidgetAcc->UpdateUIDisplay(this, nullptr);
- CXFA_Validate* validate = pNode->GetValidate();
+ CXFA_Validate* validate = pNode->GetValidateIfExists();
if (!validate)
return true;
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 3a9ff9a316..d4ead07ba9 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -198,7 +198,7 @@ bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc,
return calc && calc->GetScript();
}
case XFA_EVENT_Validate: {
- CXFA_Validate* validate = node->GetValidate();
+ CXFA_Validate* validate = node->GetValidateIfExists();
return validate && validate->GetScript();
}
default:
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 74263c7643..5a08d16986 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1608,11 +1608,11 @@ CXFA_Calculate* CXFA_Node::GetCalculateIfExists() const {
return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate);
}
-CXFA_Validate* CXFA_Node::GetValidate() const {
+CXFA_Validate* CXFA_Node::GetValidateIfExists() const {
return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate);
}
-CXFA_Validate* CXFA_Node::GetOrCreateValidate() {
+CXFA_Validate* CXFA_Node::GetOrCreateValidateIfPossible() {
return JSObject()->GetOrCreateProperty<CXFA_Validate>(0,
XFA_Element::Validate);
}
@@ -1878,7 +1878,7 @@ int32_t CXFA_Node::ProcessValidate(CXFA_FFDocView* docView, int32_t iFlags) {
if (GetElementType() == XFA_Element::Draw)
return XFA_EVENTERROR_NotExist;
- CXFA_Validate* validate = GetValidate();
+ CXFA_Validate* validate = GetValidateIfExists();
if (!validate)
return XFA_EVENTERROR_NotExist;
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index cafe6676fd..543d895aeb 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -249,8 +249,8 @@ class CXFA_Node : public CXFA_Object {
CXFA_Margin* GetMarginIfExists() const;
CXFA_Para* GetParaIfExists() const;
CXFA_Calculate* GetCalculateIfExists() const;
- CXFA_Validate* GetValidate() const;
- CXFA_Validate* GetOrCreateValidate();
+ CXFA_Validate* GetValidateIfExists() const;
+ CXFA_Validate* GetOrCreateValidateIfPossible();
CXFA_Value* GetDefaultValue();
CXFA_Value* GetFormValue() const;