summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_captiondata.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_captiondata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_value.cpp36
-rw-r--r--xfa/fxfa/parser/cxfa_value.h17
-rw-r--r--xfa/fxfa/parser/cxfa_valuedata.cpp58
-rw-r--r--xfa/fxfa/parser/cxfa_valuedata.h35
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h4
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp39
9 files changed, 95 insertions, 128 deletions
diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp
index 6d9f02b1ab..e48e5f34bb 100644
--- a/xfa/fxfa/parser/cxfa_captiondata.cpp
+++ b/xfa/fxfa/parser/cxfa_captiondata.cpp
@@ -8,6 +8,7 @@
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
CXFA_CaptionData::CXFA_CaptionData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
@@ -46,7 +47,8 @@ CXFA_FontData CXFA_CaptionData::GetFontData() const {
: nullptr);
}
-CXFA_ValueData CXFA_CaptionData::GetValueData() const {
- return CXFA_ValueData(
- m_pNode ? m_pNode->GetChild(0, XFA_Element::Value, false) : nullptr);
+CXFA_Value* CXFA_CaptionData::GetValue() const {
+ return m_pNode ? static_cast<CXFA_Value*>(
+ m_pNode->GetChild(0, XFA_Element::Value, false))
+ : nullptr;
}
diff --git a/xfa/fxfa/parser/cxfa_captiondata.h b/xfa/fxfa/parser/cxfa_captiondata.h
index fd8af7273b..119c34e4b1 100644
--- a/xfa/fxfa/parser/cxfa_captiondata.h
+++ b/xfa/fxfa/parser/cxfa_captiondata.h
@@ -10,9 +10,9 @@
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_fontdata.h"
#include "xfa/fxfa/parser/cxfa_margindata.h"
-#include "xfa/fxfa/parser/cxfa_valuedata.h"
class CXFA_Node;
+class CXFA_Value;
class CXFA_CaptionData : public CXFA_DataData {
public:
@@ -24,7 +24,7 @@ class CXFA_CaptionData : public CXFA_DataData {
float GetReserve() const;
CXFA_MarginData GetMarginData() const;
CXFA_FontData GetFontData() const;
- CXFA_ValueData GetValueData() const;
+ CXFA_Value* GetValue() const;
};
#endif // XFA_FXFA_PARSER_CXFA_CAPTIONDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp
index 4de833a8fc..aae11da211 100644
--- a/xfa/fxfa/parser/cxfa_value.cpp
+++ b/xfa/fxfa/parser/cxfa_value.cpp
@@ -50,3 +50,39 @@ CXFA_Value::CXFA_Value(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Value>(this)) {}
CXFA_Value::~CXFA_Value() {}
+
+XFA_Element CXFA_Value::GetChildValueClassID() const {
+ CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild);
+ return pNode ? pNode->GetElementType() : XFA_Element::Unknown;
+}
+
+WideString CXFA_Value::GetChildValueContent() const {
+ CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pNode)
+ return L"";
+ return pNode->JSObject()->TryContent(false, true).value_or(L"");
+}
+
+CXFA_ArcData CXFA_Value::GetArcData() const {
+ return CXFA_ArcData(GetNodeItem(XFA_NODEITEM_FirstChild));
+}
+
+CXFA_LineData CXFA_Value::GetLineData() const {
+ return CXFA_LineData(GetNodeItem(XFA_NODEITEM_FirstChild));
+}
+
+CXFA_RectangleData CXFA_Value::GetRectangleData() const {
+ return CXFA_RectangleData(GetNodeItem(XFA_NODEITEM_FirstChild));
+}
+
+CXFA_TextData CXFA_Value::GetTextData() const {
+ return CXFA_TextData(GetNodeItem(XFA_NODEITEM_FirstChild));
+}
+
+CXFA_ExDataData CXFA_Value::GetExData() const {
+ return CXFA_ExDataData(GetNodeItem(XFA_NODEITEM_FirstChild));
+}
+
+CXFA_ImageData CXFA_Value::GetImageData() const {
+ return CXFA_ImageData(GetNodeItem(XFA_NODEITEM_FirstChild));
+}
diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h
index 01f8c4a1ee..0a964ff353 100644
--- a/xfa/fxfa/parser/cxfa_value.h
+++ b/xfa/fxfa/parser/cxfa_value.h
@@ -7,12 +7,29 @@
#ifndef XFA_FXFA_PARSER_CXFA_VALUE_H_
#define XFA_FXFA_PARSER_CXFA_VALUE_H_
+#include "core/fxcrt/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_arcdata.h"
+#include "xfa/fxfa/parser/cxfa_datadata.h"
+#include "xfa/fxfa/parser/cxfa_exdatadata.h"
+#include "xfa/fxfa/parser/cxfa_imagedata.h"
+#include "xfa/fxfa/parser/cxfa_linedata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_rectangledata.h"
+#include "xfa/fxfa/parser/cxfa_textdata.h"
class CXFA_Value : public CXFA_Node {
public:
CXFA_Value(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Value() override;
+
+ XFA_Element GetChildValueClassID() const;
+ WideString GetChildValueContent() const;
+ CXFA_ArcData GetArcData() const;
+ CXFA_LineData GetLineData() const;
+ CXFA_RectangleData GetRectangleData() const;
+ CXFA_TextData GetTextData() const;
+ CXFA_ExDataData GetExData() const;
+ CXFA_ImageData GetImageData() const;
};
#endif // XFA_FXFA_PARSER_CXFA_VALUE_H_
diff --git a/xfa/fxfa/parser/cxfa_valuedata.cpp b/xfa/fxfa/parser/cxfa_valuedata.cpp
deleted file mode 100644
index c88af7a422..0000000000
--- a/xfa/fxfa/parser/cxfa_valuedata.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/parser/cxfa_valuedata.h"
-
-#include "xfa/fxfa/parser/cxfa_node.h"
-
-XFA_Element CXFA_ValueData::GetChildValueClassID() const {
- if (!m_pNode)
- return XFA_Element::Unknown;
- if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
- return pNode->GetElementType();
- return XFA_Element::Unknown;
-}
-
-WideString CXFA_ValueData::GetChildValueContent() const {
- if (!m_pNode)
- return L"";
-
- CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pNode)
- return L"";
-
- return pNode->JSObject()->TryContent(false, true).value_or(L"");
-}
-
-CXFA_ArcData CXFA_ValueData::GetArcData() const {
- return CXFA_ArcData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-
-CXFA_LineData CXFA_ValueData::GetLineData() const {
- return CXFA_LineData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-
-CXFA_RectangleData CXFA_ValueData::GetRectangleData() const {
- return CXFA_RectangleData(
- m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr);
-}
-
-CXFA_TextData CXFA_ValueData::GetTextData() const {
- return CXFA_TextData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-
-CXFA_ExDataData CXFA_ValueData::GetExData() const {
- return CXFA_ExDataData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-
-CXFA_ImageData CXFA_ValueData::GetImageData() const {
- return CXFA_ImageData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
diff --git a/xfa/fxfa/parser/cxfa_valuedata.h b/xfa/fxfa/parser/cxfa_valuedata.h
deleted file mode 100644
index 101c960325..0000000000
--- a/xfa/fxfa/parser/cxfa_valuedata.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_VALUEDATA_H_
-#define XFA_FXFA_PARSER_CXFA_VALUEDATA_H_
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/parser/cxfa_arcdata.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_exdatadata.h"
-#include "xfa/fxfa/parser/cxfa_imagedata.h"
-#include "xfa/fxfa/parser/cxfa_linedata.h"
-#include "xfa/fxfa/parser/cxfa_rectangledata.h"
-#include "xfa/fxfa/parser/cxfa_textdata.h"
-
-class CXFA_Node;
-
-class CXFA_ValueData : public CXFA_DataData {
- public:
- explicit CXFA_ValueData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
- XFA_Element GetChildValueClassID() const;
- WideString GetChildValueContent() const;
- CXFA_ArcData GetArcData() const;
- CXFA_LineData GetLineData() const;
- CXFA_RectangleData GetRectangleData() const;
- CXFA_TextData GetTextData() const;
- CXFA_ExDataData GetExData() const;
- CXFA_ImageData GetImageData() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_VALUEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 58c934132c..bb1f259d00 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -16,6 +16,7 @@
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_utils.h"
namespace {
@@ -69,9 +70,10 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
eWidgetType = XFA_Element::Unknown;
XFA_Element eUIType = XFA_Element::Unknown;
- CXFA_ValueData defValueData(
+ auto* defValue = static_cast<CXFA_Value*>(
pNode->JSObject()->GetProperty(0, XFA_Element::Value, true));
- XFA_Element eValueType = defValueData.GetChildValueClassID();
+ XFA_Element eValueType =
+ defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown;
switch (eValueType) {
case XFA_Element::Boolean:
eUIType = XFA_Element::CheckButton;
@@ -152,8 +154,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
if (!pUIChild) {
if (eUIType == XFA_Element::Unknown) {
eUIType = XFA_Element::TextEdit;
- defValueData.GetNode()->JSObject()->GetProperty(0, XFA_Element::Text,
- true);
+ defValue->JSObject()->GetProperty(0, XFA_Element::Text, true);
}
return pUI->JSObject()->GetProperty(0, eUIType, true);
}
@@ -195,7 +196,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
eValueType = XFA_Element::Text;
break;
}
- defValueData.GetNode()->JSObject()->GetProperty(0, eValueType, true);
+ defValue->JSObject()->GetProperty(0, eValueType, true);
return pUIChild;
}
@@ -295,15 +296,14 @@ std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity(
return events;
}
-CXFA_ValueData CXFA_WidgetData::GetDefaultValueData() {
+CXFA_Value* CXFA_WidgetData::GetDefaultValue() {
CXFA_Node* pTemNode = m_pNode->GetTemplateNode();
- return CXFA_ValueData(
- pTemNode ? pTemNode->JSObject()->GetProperty(0, XFA_Element::Value, false)
- : nullptr);
+ return static_cast<CXFA_Value*>(
+ pTemNode->JSObject()->GetProperty(0, XFA_Element::Value, false));
}
-CXFA_ValueData CXFA_WidgetData::GetFormValueData() {
- return CXFA_ValueData(
+CXFA_Value* CXFA_WidgetData::GetFormValue() {
+ return static_cast<CXFA_Value*>(
m_pNode->JSObject()->GetProperty(0, XFA_Element::Value, false));
}
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 592226cb0b..21e4e848ec 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -63,8 +63,8 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_FontData GetFontData(bool bModified);
CXFA_MarginData GetMarginData();
CXFA_ParaData GetParaData();
- CXFA_ValueData GetDefaultValueData();
- CXFA_ValueData GetFormValueData();
+ CXFA_Value* GetDefaultValue();
+ CXFA_Value* GetFormValue();
CXFA_CalculateData GetCalculateData();
CXFA_Validate* GetValidate(bool bModified);
CXFA_BorderData GetUIBorderData();
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 66f4a2eb21..30d45787f5 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -23,6 +23,7 @@
#include "xfa/fxfa/parser/cxfa_occurdata.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -123,13 +124,14 @@ void CreateDataBinding(CXFA_Node* pFormNode,
CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
ASSERT(pWidgetData);
XFA_Element eUIType = pWidgetData->GetUIType();
- CXFA_ValueData defValueData(
+ auto* defValue = static_cast<CXFA_Value*>(
pFormNode->JSObject()->GetProperty(0, XFA_Element::Value, true));
if (!bDataToForm) {
WideString wsValue;
switch (eUIType) {
case XFA_Element::ImageEdit: {
- CXFA_ImageData imageData = defValueData.GetImageData();
+ CXFA_ImageData imageData =
+ defValue ? defValue->GetImageData() : CXFA_ImageData(nullptr);
WideString wsContentType;
WideString wsHref;
if (imageData.HasValidNode()) {
@@ -151,7 +153,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
break;
}
case XFA_Element::ChoiceList:
- wsValue = defValueData.GetChildValueContent();
+ wsValue = defValue ? defValue->GetChildValueContent() : L"";
if (pWidgetData->IsChoiceListMultiSelect()) {
std::vector<WideString> wsSelTextArray =
pWidgetData->GetSelectedItemsValue();
@@ -178,7 +180,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
}
break;
case XFA_Element::CheckButton:
- wsValue = defValueData.GetChildValueContent();
+ wsValue = defValue ? defValue->GetChildValueContent() : L"";
if (wsValue.IsEmpty())
break;
@@ -192,11 +194,12 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (pChild->GetElementType() != XFA_Element::Field)
continue;
- CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value, false);
+ auto* pValue = static_cast<CXFA_Value*>(
+ pChild->GetChild(0, XFA_Element::Value, false));
if (!pValue)
continue;
- wsValue = CXFA_ValueData(pValue).GetChildValueContent();
+ wsValue = pValue->GetChildValueContent();
if (wsValue.IsEmpty())
continue;
@@ -245,7 +248,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
break;
}
case XFA_Element::NumericEdit: {
- wsValue = defValueData.GetChildValueContent();
+ wsValue = defValue ? defValue->GetChildValueContent() : L"";
if (wsValue.IsEmpty())
break;
@@ -258,7 +261,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
break;
}
default:
- wsValue = defValueData.GetChildValueContent();
+ wsValue = defValue ? defValue->GetChildValueContent() : L"";
if (wsValue.IsEmpty())
break;
@@ -276,9 +279,10 @@ void CreateDataBinding(CXFA_Node* pFormNode,
false);
switch (eUIType) {
case XFA_Element::ImageEdit: {
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Image);
- CXFA_ImageData imageData = defValueData.GetImageData();
+ CXFA_ImageData imageData =
+ defValue ? defValue->GetImageData() : CXFA_ImageData(nullptr);
if (imageData.HasValidNode()) {
CFX_XMLElement* pXMLDataElement =
static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode());
@@ -314,20 +318,21 @@ void CreateDataBinding(CXFA_Node* pFormNode,
wsNormalizeValue += wsItem;
}
- CXFA_ExDataData exData = defValueData.GetExData();
+ CXFA_ExDataData exData =
+ defValue ? defValue->GetExData() : CXFA_ExDataData(nullptr);
ASSERT(exData.HasValidNode());
exData.SetContentType(single ? L"text/plain" : L"text/xml");
}
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::ExData);
} else {
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Text);
}
break;
case XFA_Element::CheckButton:
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Text);
break;
case XFA_Element::ExclGroup: {
@@ -336,7 +341,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
break;
}
case XFA_Element::DateTimeEdit:
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::DateTime);
break;
case XFA_Element::NumericEdit: {
@@ -345,7 +350,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (wsPicture.IsEmpty())
wsNormalizeValue = pWidgetData->NormalizeNumStr(wsNormalizeValue);
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Float);
break;
}
@@ -355,7 +360,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
case XFA_Element::Signature:
case XFA_Element::TextEdit:
default:
- FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue,
+ FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Text);
break;
}