summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_value.cpp40
-rw-r--r--xfa/fxfa/parser/cxfa_value.h12
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp7
4 files changed, 36 insertions, 25 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index a9c4a69dc6..7797be342b 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1940,7 +1940,7 @@ WideString CXFA_Node::GetValidateCaptionName(bool bVersionFlag) {
if (caption) {
CXFA_Value* capValue = caption->GetValueIfExists();
if (capValue) {
- CXFA_Text* captionText = capValue->GetText();
+ CXFA_Text* captionText = capValue->GetTextIfExists();
if (captionText)
wsCaptionName = captionText->GetContent();
}
diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp
index dc93bba25c..7a952f7df3 100644
--- a/xfa/fxfa/parser/cxfa_value.cpp
+++ b/xfa/fxfa/parser/cxfa_value.cpp
@@ -63,31 +63,41 @@ XFA_Element CXFA_Value::GetChildValueClassID() const {
WideString CXFA_Value::GetChildValueContent() const {
CXFA_Node* pNode = GetFirstChild();
- if (!pNode)
- return L"";
- return pNode->JSObject()->TryContent(false, true).value_or(L"");
+ return pNode ? pNode->JSObject()->TryContent(false, true).value_or(L"") : L"";
}
-CXFA_Arc* CXFA_Value::GetArc() const {
- return static_cast<CXFA_Arc*>(GetFirstChild());
+CXFA_Arc* CXFA_Value::GetArcIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Arc);
+ return static_cast<CXFA_Arc*>(node);
}
-CXFA_Line* CXFA_Value::GetLine() const {
- return static_cast<CXFA_Line*>(GetFirstChild());
+CXFA_Line* CXFA_Value::GetLineIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Line);
+ return static_cast<CXFA_Line*>(node);
}
-CXFA_Rectangle* CXFA_Value::GetRectangle() const {
- return static_cast<CXFA_Rectangle*>(GetFirstChild());
+CXFA_Rectangle* CXFA_Value::GetRectangleIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Rectangle);
+ return static_cast<CXFA_Rectangle*>(node);
}
-CXFA_Text* CXFA_Value::GetText() const {
- return static_cast<CXFA_Text*>(GetFirstChild());
+CXFA_Text* CXFA_Value::GetTextIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Text);
+ return static_cast<CXFA_Text*>(node);
}
-CXFA_ExData* CXFA_Value::GetExData() const {
- return static_cast<CXFA_ExData*>(GetFirstChild());
+CXFA_ExData* CXFA_Value::GetExDataIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::ExData);
+ return static_cast<CXFA_ExData*>(node);
}
-CXFA_Image* CXFA_Value::GetImage() const {
- return static_cast<CXFA_Image*>(GetFirstChild());
+CXFA_Image* CXFA_Value::GetImageIfExists() const {
+ CXFA_Node* node = GetFirstChild();
+ ASSERT(!node || node->GetElementType() == XFA_Element::Image);
+ return static_cast<CXFA_Image*>(node);
}
diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h
index 5067b715db..47aeefede2 100644
--- a/xfa/fxfa/parser/cxfa_value.h
+++ b/xfa/fxfa/parser/cxfa_value.h
@@ -24,12 +24,12 @@ class CXFA_Value : public CXFA_Node {
XFA_Element GetChildValueClassID() const;
WideString GetChildValueContent() const;
- CXFA_Arc* GetArc() const;
- CXFA_Line* GetLine() const;
- CXFA_Rectangle* GetRectangle() const;
- CXFA_Text* GetText() const;
- CXFA_ExData* GetExData() const;
- CXFA_Image* GetImage() const;
+ CXFA_Arc* GetArcIfExists() const;
+ CXFA_Line* GetLineIfExists() const;
+ CXFA_Rectangle* GetRectangleIfExists() const;
+ CXFA_Text* GetTextIfExists() const;
+ CXFA_ExData* GetExDataIfExists() const;
+ CXFA_Image* GetImageIfExists() const;
};
#endif // XFA_FXFA_PARSER_CXFA_VALUE_H_
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 3332d90b66..65746c5caf 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -140,7 +140,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
WideString wsValue;
switch (eUIType) {
case XFA_Element::ImageEdit: {
- CXFA_Image* image = defValue ? defValue->GetImage() : nullptr;
+ CXFA_Image* image = defValue ? defValue->GetImageIfExists() : nullptr;
WideString wsContentType;
WideString wsHref;
if (image) {
@@ -293,7 +293,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
case XFA_Element::ImageEdit: {
FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Image);
- CXFA_Image* image = defValue ? defValue->GetImage() : nullptr;
+ CXFA_Image* image = defValue ? defValue->GetImageIfExists() : nullptr;
if (image) {
CFX_XMLElement* pXMLDataElement =
static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode());
@@ -329,7 +329,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
wsNormalizeValue += wsItem;
}
- CXFA_ExData* exData = defValue ? defValue->GetExData() : nullptr;
+ CXFA_ExData* exData =
+ defValue ? defValue->GetExDataIfExists() : nullptr;
ASSERT(exData);
exData->SetContentType(single ? L"text/plain" : L"text/xml");