diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-11 14:19:51 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-11 14:19:51 +0000 |
commit | 8b68d30fdc8ae33a8a5c2d647bd7a67f1271ff90 (patch) | |
tree | af41a878d0e7a662655391f4a235af17aeee6460 /fxjs/xfa/cjx_object.cpp | |
parent | 89fa5dfee5107736597682f174fdc95d0baec830 (diff) | |
download | pdfium-8b68d30fdc8ae33a8a5c2d647bd7a67f1271ff90.tar.xz |
Rename Getvalidate and GetOrCreateValidate
This CL renames the validation methods to make it clear they can return
nullptr.
Change-Id: I60d0c41cdfe9902049d99cd790f851517b11a6d9
Reviewed-on: https://pdfium-review.googlesource.com/22682
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/xfa/cjx_object.cpp')
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 40 |
1 files changed, 25 insertions, 15 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; |