summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-14 20:43:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-14 20:43:53 +0000
commit51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1 (patch)
treea365a0c3f25fff2f6511fbc23fd0e4d6b8d4eada
parent8489e901fb16fe508e23a36cd3eff93d8332c2a2 (diff)
downloadpdfium-51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1.tar.xz
Change CXFA_Node::GetChild to return proper types
Currently CXFA_Node::GetChild always returns a CXFA_Node* object. We know the type we want when we call GetChild, so this CL changes the code to add a template parameter to GetChild and return the correct CXFA_Node subtype for the desired element. Change-Id: I5aecf2e840504235dc246483abee48e0564841fe Reviewed-on: https://pdfium-review.googlesource.com/21210 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/xfa/cjx_object.cpp5
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp24
-rw-r--r--xfa/fxfa/cxfa_ffpageview.cpp10
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp36
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp11
-rw-r--r--xfa/fxfa/parser/cxfa_attachnodelist.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_binddata.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_calculatedata.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_captiondata.cpp13
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_filldata.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_linedata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_node.h10
-rw-r--r--xfa/fxfa/parser/cxfa_nodelocale.cpp17
-rw-r--r--xfa/fxfa/parser/cxfa_strokedata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_validate.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp77
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp11
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp39
24 files changed, 214 insertions, 134 deletions
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index f4f3030188..c49cc5bbce 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -807,8 +807,9 @@ pdfium::Optional<WideString> CJX_Object::TryContent(bool bScriptModify,
if (ToNode(GetXFAObject())->GetElementType() == XFA_Element::ExclGroup) {
pNode = ToNode(GetXFAObject());
} else {
- CXFA_Node* pValue =
- ToNode(GetXFAObject())->GetChild(0, XFA_Element::Value, false);
+ CXFA_Value* pValue =
+ ToNode(GetXFAObject())
+ ->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pValue)
return {};
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 30ae7124de..ed91020dff 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -29,8 +29,11 @@
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
#include "xfa/fxfa/cxfa_textprovider.h"
#include "xfa/fxfa/cxfa_widgetacciterator.h"
+#include "xfa/fxfa/parser/cxfa_acrobat.h"
#include "xfa/fxfa/parser/cxfa_binditemsdata.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_present.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
@@ -112,7 +115,8 @@ void CXFA_FFDocView::StopLayout() {
if (!pRootItem)
return;
- CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_Element::Subform, false);
+ CXFA_Subform* pSubformNode =
+ pRootItem->GetChild<CXFA_Subform>(0, XFA_Element::Subform, false);
if (!pSubformNode)
return;
@@ -267,16 +271,16 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
CXFA_Node* pConfigItem =
ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config));
if (pConfigItem) {
- CXFA_Node* pValidateNode = nullptr;
- CXFA_Node* pAcrobatNode =
- pConfigItem->GetChild(0, XFA_Element::Acrobat, false);
- pValidateNode =
- pAcrobatNode ? pAcrobatNode->GetChild(0, XFA_Element::Validate, false)
+ CXFA_Acrobat* pAcrobatNode =
+ pConfigItem->GetChild<CXFA_Acrobat>(0, XFA_Element::Acrobat, false);
+ CXFA_Validate* pValidateNode =
+ pAcrobatNode ? pAcrobatNode->GetChild<CXFA_Validate>(
+ 0, XFA_Element::Validate, false)
: nullptr;
if (!pValidateNode) {
- CXFA_Node* pPresentNode =
- pConfigItem->GetChild(0, XFA_Element::Present, false);
- pValidateNode = pPresentNode ? pPresentNode->GetChild(
+ CXFA_Present* pPresentNode =
+ pConfigItem->GetChild<CXFA_Present>(0, XFA_Element::Present, false);
+ pValidateNode = pPresentNode ? pPresentNode->GetChild<CXFA_Validate>(
0, XFA_Element::Validate, false)
: nullptr;
}
@@ -295,7 +299,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
if (!pRootItem)
return XFA_EVENTERROR_Error;
- pNode = pRootItem->GetChild(0, XFA_Element::Subform, false);
+ pNode = pRootItem->GetChild<CXFA_Node>(0, XFA_Element::Subform, false);
}
ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady,
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index 2234b4cfb1..1305938db3 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -21,6 +21,8 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_traversal.h"
+#include "xfa/fxfa/parser/cxfa_traverse.h"
namespace {
@@ -308,11 +310,11 @@ bool CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget(
CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget(
CXFA_FFWidget* pWidget) {
CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc();
- CXFA_Node* pTraversal =
- pAcc->GetNode()->GetChild(0, XFA_Element::Traversal, false);
+ CXFA_Traversal* pTraversal = pAcc->GetNode()->GetChild<CXFA_Traversal>(
+ 0, XFA_Element::Traversal, false);
if (pTraversal) {
- CXFA_Node* pTraverse =
- pTraversal->GetChild(0, XFA_Element::Traverse, false);
+ CXFA_Traverse* pTraverse =
+ pTraversal->GetChild<CXFA_Traverse>(0, XFA_Element::Traverse, false);
if (pTraverse) {
pdfium::Optional<WideString> traverseWidgetName =
pTraverse->JSObject()->TryAttribute(XFA_Attribute::Ref, true);
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index 5e242a459b..4795ab8cfb 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -27,9 +27,14 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
+#include "xfa/fxfa/parser/cxfa_caption.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
+#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localevalue.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_para.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -38,8 +43,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text) {
CXFA_Node* pElementNode = m_pWidgetAcc->GetNode();
- CXFA_Node* pValueNode =
- pElementNode->GetChild(0, XFA_Element::Value, false);
+ CXFA_Value* pValueNode =
+ pElementNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pValueNode)
return nullptr;
@@ -72,13 +77,14 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
}
if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) {
- CXFA_Node* pCaptionNode =
- m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, false);
+ CXFA_Caption* pCaptionNode =
+ m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(0, XFA_Element::Caption,
+ false);
if (!pCaptionNode)
return nullptr;
- CXFA_Node* pValueNode =
- pCaptionNode->GetChild(0, XFA_Element::Value, false);
+ CXFA_Value* pValueNode =
+ pCaptionNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pValueNode)
return nullptr;
@@ -93,8 +99,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
return pChildNode;
}
- CXFA_Node* pItemNode =
- m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItemNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Items>(
+ 0, XFA_Element::Items, false);
if (!pItemNode)
return nullptr;
@@ -115,19 +121,19 @@ CXFA_ParaData CXFA_TextProvider::GetParaData() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
return m_pWidgetAcc->GetParaData();
- CXFA_Node* pNode =
- m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, false);
- return CXFA_ParaData(pNode->GetChild(0, XFA_Element::Para, false));
+ CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
+ 0, XFA_Element::Caption, false);
+ return CXFA_ParaData(pNode->GetChild<CXFA_Para>(0, XFA_Element::Para, false));
}
CXFA_FontData CXFA_TextProvider::GetFontData() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
return m_pWidgetAcc->GetFontData(false);
- CXFA_Node* pNode =
- m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, false);
- pNode = pNode->GetChild(0, XFA_Element::Font, false);
- return pNode ? CXFA_FontData(pNode) : m_pWidgetAcc->GetFontData(false);
+ CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
+ 0, XFA_Element::Caption, false);
+ CXFA_Font* font = pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false);
+ return font ? CXFA_FontData(font) : m_pWidgetAcc->GetFontData(false);
}
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 29685b02e8..76b4f46e20 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -21,6 +21,7 @@
#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_textprovider.h"
+#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localevalue.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -206,15 +207,17 @@ void CXFA_WidgetAcc::ResetData() {
}
}
if (!done) {
- CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItems =
+ pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
continue;
WideString itemText;
if (pItems->CountChildren(XFA_Element::Unknown, false) > 1) {
- itemText = pItems->GetChild(1, XFA_Element::Unknown, false)
- ->JSObject()
- ->GetContent(false);
+ itemText =
+ pItems->GetChild<CXFA_Node>(1, XFA_Element::Unknown, false)
+ ->JSObject()
+ ->GetContent(false);
}
pAcc->SetValue(XFA_VALUEPICTURE_Raw, itemText);
}
diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.cpp b/xfa/fxfa/parser/cxfa_attachnodelist.cpp
index a793e02bc4..0a9be2ed4a 100644
--- a/xfa/fxfa/parser/cxfa_attachnodelist.cpp
+++ b/xfa/fxfa/parser/cxfa_attachnodelist.cpp
@@ -41,7 +41,7 @@ bool CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
}
CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) {
- return m_pAttachNode->GetChild(
+ return m_pAttachNode->GetChild<CXFA_Node>(
iIndex, XFA_Element::Unknown,
m_pAttachNode->GetElementType() == XFA_Element::Subform);
}
diff --git a/xfa/fxfa/parser/cxfa_binddata.cpp b/xfa/fxfa/parser/cxfa_binddata.cpp
index 62146e3419..7a7e2eef86 100644
--- a/xfa/fxfa/parser/cxfa_binddata.cpp
+++ b/xfa/fxfa/parser/cxfa_binddata.cpp
@@ -7,12 +7,12 @@
#include "xfa/fxfa/parser/cxfa_binddata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_picture.h"
CXFA_BindData::CXFA_BindData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
WideString CXFA_BindData::GetPicture() {
- CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture, false);
- if (!pPicture)
- return L"";
- return pPicture->JSObject()->GetContent(false);
+ CXFA_Picture* pPicture =
+ m_pNode->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
+ return pPicture ? pPicture->JSObject()->GetContent(false) : L"";
}
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp
index 8f2674cda0..7ada3bf00b 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.cpp
+++ b/xfa/fxfa/parser/cxfa_boxdata.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_boxdata.h"
#include "xfa/fxfa/parser/cxfa_cornerdata.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -135,7 +136,8 @@ CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const {
CXFA_MarginData CXFA_BoxData::GetMarginData() const {
return CXFA_MarginData(
- m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin, false) : nullptr);
+ m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
+ : nullptr);
}
std::tuple<XFA_AttributeEnum, bool, float> CXFA_BoxData::Get3DStyle() const {
diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp
index 3d7711d433..f919224687 100644
--- a/xfa/fxfa/parser/cxfa_calculatedata.cpp
+++ b/xfa/fxfa/parser/cxfa_calculatedata.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_calculatedata.h"
+#include "xfa/fxfa/parser/cxfa_message.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_script.h"
#include "xfa/fxfa/parser/cxfa_text.h"
@@ -20,16 +21,15 @@ XFA_AttributeEnum CXFA_CalculateData::GetOverride() const {
}
CXFA_Script* CXFA_CalculateData::GetScript() const {
- return static_cast<CXFA_Script*>(
- m_pNode->GetChild(0, XFA_Element::Script, false));
+ return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false);
}
WideString CXFA_CalculateData::GetMessageText() const {
- CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Message, false);
+ CXFA_Message* pNode =
+ m_pNode->GetChild<CXFA_Message>(0, XFA_Element::Message, false);
if (!pNode)
return L"";
- CXFA_Text* text =
- static_cast<CXFA_Text*>(pNode->GetChild(0, XFA_Element::Text, false));
+ CXFA_Text* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false);
return text ? text->GetContent() : L"";
}
diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp
index e48e5f34bb..59dbb2b008 100644
--- a/xfa/fxfa/parser/cxfa_captiondata.cpp
+++ b/xfa/fxfa/parser/cxfa_captiondata.cpp
@@ -6,6 +6,8 @@
#include "xfa/fxfa/parser/cxfa_captiondata.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_value.h"
@@ -39,16 +41,17 @@ float CXFA_CaptionData::GetReserve() const {
CXFA_MarginData CXFA_CaptionData::GetMarginData() const {
return CXFA_MarginData(
- m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin, false) : nullptr);
+ m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
+ : nullptr);
}
CXFA_FontData CXFA_CaptionData::GetFontData() const {
- return CXFA_FontData(m_pNode ? m_pNode->GetChild(0, XFA_Element::Font, false)
- : nullptr);
+ return CXFA_FontData(
+ m_pNode ? m_pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false)
+ : nullptr);
}
CXFA_Value* CXFA_CaptionData::GetValue() const {
- return m_pNode ? static_cast<CXFA_Value*>(
- m_pNode->GetChild(0, XFA_Element::Value, false))
+ return m_pNode ? m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false)
: nullptr;
}
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index e418c839c6..3ba5a44cf9 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -16,6 +16,7 @@
#include "xfa/fxfa/parser/cscript_logpseudomodel.h"
#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
#include "xfa/fxfa/parser/cxfa_document_parser.h"
+#include "xfa/fxfa/parser/cxfa_interactive.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -261,7 +262,8 @@ bool CXFA_Document::IsInteractive() {
if (!pPDF)
return false;
- CXFA_Node* pFormFiller = pPDF->GetChild(0, XFA_Element::Interactive, false);
+ CXFA_Interactive* pFormFiller =
+ pPDF->GetChild<CXFA_Interactive>(0, XFA_Element::Interactive, false);
if (pFormFiller) {
m_dwDocFlags |= XFA_DOCFLAG_HasInteractive;
diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp
index d5b170b734..89dcb4ed2a 100644
--- a/xfa/fxfa/parser/cxfa_eventdata.cpp
+++ b/xfa/fxfa/parser/cxfa_eventdata.cpp
@@ -33,11 +33,9 @@ WideString CXFA_EventData::GetRef() const {
}
CXFA_Script* CXFA_EventData::GetScript() const {
- return static_cast<CXFA_Script*>(
- m_pNode->GetChild(0, XFA_Element::Script, false));
+ return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false);
}
CXFA_Submit* CXFA_EventData::GetSubmit() const {
- return static_cast<CXFA_Submit*>(
- m_pNode->GetChild(0, XFA_Element::Submit, false));
+ return m_pNode->GetChild<CXFA_Submit>(0, XFA_Element::Submit, false);
}
diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp
index 2ea7652784..98df0aa3a4 100644
--- a/xfa/fxfa/parser/cxfa_filldata.cpp
+++ b/xfa/fxfa/parser/cxfa_filldata.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_filldata.h"
+#include "xfa/fxfa/parser/cxfa_color.h"
#include "xfa/fxfa/parser/cxfa_node.h"
CXFA_FillData::CXFA_FillData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
@@ -33,7 +34,8 @@ void CXFA_FillData::SetColor(FX_ARGB color) {
}
FX_ARGB CXFA_FillData::GetColor(bool bText) const {
- if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false)) {
+ if (CXFA_Color* pNode =
+ m_pNode->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pNode->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
@@ -61,8 +63,8 @@ XFA_AttributeEnum CXFA_FillData::GetPatternType() const {
}
FX_ARGB CXFA_FillData::GetPatternColor() const {
- if (CXFA_Node* pColor =
- GetPattern()->GetChild(0, XFA_Element::Color, false)) {
+ if (CXFA_Color* pColor =
+ GetPattern()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
@@ -79,8 +81,8 @@ int32_t CXFA_FillData::GetStippleRate() const {
}
FX_ARGB CXFA_FillData::GetStippleColor() const {
- if (CXFA_Node* pColor =
- GetStipple()->GetChild(0, XFA_Element::Color, false)) {
+ if (CXFA_Color* pColor =
+ GetStipple()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
@@ -97,7 +99,8 @@ XFA_AttributeEnum CXFA_FillData::GetLinearType() const {
}
FX_ARGB CXFA_FillData::GetLinearColor() const {
- if (CXFA_Node* pColor = GetLinear()->GetChild(0, XFA_Element::Color, false)) {
+ if (CXFA_Color* pColor =
+ GetLinear()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
@@ -114,7 +117,8 @@ bool CXFA_FillData::IsRadialToEdge() const {
}
FX_ARGB CXFA_FillData::GetRadialColor() const {
- if (CXFA_Node* pColor = GetRadial()->GetChild(0, XFA_Element::Color, false)) {
+ if (CXFA_Color* pColor =
+ GetRadial()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp
index c2b4a79fea..78ff2e89aa 100644
--- a/xfa/fxfa/parser/cxfa_fontdata.cpp
+++ b/xfa/fxfa/parser/cxfa_fontdata.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_fontdata.h"
#include "core/fxge/fx_dib.h"
+#include "xfa/fxfa/parser/cxfa_fill.h"
#include "xfa/fxfa/parser/cxfa_filldata.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -82,6 +83,7 @@ void CXFA_FontData::SetColor(FX_ARGB color) {
}
FX_ARGB CXFA_FontData::GetColor() const {
- CXFA_FillData fillData(m_pNode->GetChild(0, XFA_Element::Fill, false));
+ CXFA_FillData fillData(
+ m_pNode->GetChild<CXFA_Fill>(0, XFA_Element::Fill, false));
return fillData.HasValidNode() ? fillData.GetColor(true) : 0xFF000000;
}
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 4d70d7d50f..21b3aca235 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -10,12 +10,14 @@
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_contentarea.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_itemlayoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
+#include "xfa/fxfa/parser/cxfa_medium.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_object.h"
@@ -318,7 +320,8 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
return false;
CXFA_Document* pDocument = pTemplateNode->GetDocument();
- pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea, false);
+ pPageArea = m_pTemplatePageSetRoot->GetChild<CXFA_Node>(
+ 0, XFA_Element::PageArea, false);
if (!pPageArea) {
pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketType(),
XFA_Element::PageArea);
@@ -328,11 +331,11 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr);
pPageArea->SetFlag(XFA_NodeFlag_Initialized, true);
}
- CXFA_Node* pContentArea =
- pPageArea->GetChild(0, XFA_Element::ContentArea, false);
+ CXFA_ContentArea* pContentArea =
+ pPageArea->GetChild<CXFA_ContentArea>(0, XFA_Element::ContentArea, false);
if (!pContentArea) {
- pContentArea = pDocument->CreateNode(pPageArea->GetPacketType(),
- XFA_Element::ContentArea);
+ pContentArea = static_cast<CXFA_ContentArea*>(pDocument->CreateNode(
+ pPageArea->GetPacketType(), XFA_Element::ContentArea));
if (!pContentArea)
return false;
@@ -347,10 +350,11 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
pContentArea->JSObject()->SetMeasure(
XFA_Attribute::H, CXFA_Measurement(10.5f, XFA_Unit::In), false);
}
- CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium, false);
+ CXFA_Medium* pMedium =
+ pPageArea->GetChild<CXFA_Medium>(0, XFA_Element::Medium, false);
if (!pMedium) {
- pMedium =
- pDocument->CreateNode(pPageArea->GetPacketType(), XFA_Element::Medium);
+ pMedium = static_cast<CXFA_Medium*>(
+ pDocument->CreateNode(pPageArea->GetPacketType(), XFA_Element::Medium));
if (!pContentArea)
return false;
diff --git a/xfa/fxfa/parser/cxfa_linedata.cpp b/xfa/fxfa/parser/cxfa_linedata.cpp
index 47e45c77f5..37f4f2a48f 100644
--- a/xfa/fxfa/parser/cxfa_linedata.cpp
+++ b/xfa/fxfa/parser/cxfa_linedata.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_linedata.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_node.h"
XFA_AttributeEnum CXFA_LineData::GetHand() const {
@@ -18,5 +19,6 @@ bool CXFA_LineData::GetSlope() const {
}
CXFA_EdgeData CXFA_LineData::GetEdgeData() const {
- return CXFA_EdgeData(m_pNode->GetChild(0, XFA_Element::Edge, false));
+ return CXFA_EdgeData(
+ m_pNode->GetChild<CXFA_Edge>(0, XFA_Element::Edge, false));
}
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index bede0a722c..195af08bf7 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -786,9 +786,9 @@ int32_t CXFA_Node::CountChildren(XFA_Element eType, bool bOnlyChild) {
return iCount;
}
-CXFA_Node* CXFA_Node::GetChild(int32_t index,
- XFA_Element eType,
- bool bOnlyChild) {
+CXFA_Node* CXFA_Node::GetChildInternal(int32_t index,
+ XFA_Element eType,
+ bool bOnlyChild) {
ASSERT(index > -1);
int32_t iCount = 0;
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 2b0b476d36..c2c7605e85 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -153,7 +153,12 @@ class CXFA_Node : public CXFA_Object {
void UpdateNameHash();
int32_t CountChildren(XFA_Element eType, bool bOnlyChild);
- CXFA_Node* GetChild(int32_t index, XFA_Element eType, bool bOnlyChild);
+
+ template <typename T>
+ T* GetChild(int32_t index, XFA_Element eType, bool bOnlyChild) {
+ return static_cast<T*>(GetChildInternal(index, eType, bOnlyChild));
+ }
+
int32_t InsertChild(int32_t index, CXFA_Node* pNode);
bool InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode);
bool RemoveChild(CXFA_Node* pNode, bool bNotify);
@@ -225,6 +230,9 @@ class CXFA_Node : public CXFA_Object {
void OnRemoved(bool bNotify);
pdfium::Optional<void*> GetDefaultValue(XFA_Attribute attr,
XFA_AttributeType eType) const;
+ CXFA_Node* GetChildInternal(int32_t index,
+ XFA_Element eType,
+ bool bOnlyChild);
const PropertyData* const m_Properties;
const AttributeData* const m_Attributes;
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp
index 54440d5834..e7bba363cf 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp
@@ -9,6 +9,8 @@
#include <utility>
#include "core/fxcrt/xml/cxml_element.h"
+#include "xfa/fxfa/parser/cxfa_calendarsymbols.h"
+#include "xfa/fxfa/parser/cxfa_datetimesymbols.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -69,8 +71,9 @@ WideString CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const {
}
WideString CXFA_NodeLocale::GetDateTimeSymbols() const {
- CXFA_Node* pSymbols =
- m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols, false)
+ CXFA_DateTimeSymbols* pSymbols =
+ m_pLocale ? m_pLocale->GetChild<CXFA_DateTimeSymbols>(
+ 0, XFA_Element::DateTimeSymbols, false)
: nullptr;
return pSymbols ? pSymbols->JSObject()->GetContent(false) : WideString();
}
@@ -147,7 +150,7 @@ CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent,
WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement,
const WideStringView& symbol_type) const {
CXFA_Node* pSymbols =
- m_pLocale ? m_pLocale->GetChild(0, eElement, false) : nullptr;
+ m_pLocale ? m_pLocale->GetChild<CXFA_Node>(0, eElement, false) : nullptr;
CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type);
return pSymbol ? pSymbol->JSObject()->GetContent(false) : WideString();
}
@@ -155,8 +158,9 @@ WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement,
WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
int index,
bool bAbbr) const {
- CXFA_Node* pCalendar =
- m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols, false)
+ CXFA_CalendarSymbols* pCalendar =
+ m_pLocale ? m_pLocale->GetChild<CXFA_CalendarSymbols>(
+ 0, XFA_Element::CalendarSymbols, false)
: nullptr;
if (!pCalendar)
return WideString();
@@ -164,7 +168,8 @@ WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
if (pNode->JSObject()->GetBoolean(XFA_Attribute::Abbr) == bAbbr) {
- CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown, false);
+ CXFA_Node* pSymbol =
+ pNode->GetChild<CXFA_Node>(index, XFA_Element::Unknown, false);
return pSymbol ? pSymbol->JSObject()->GetContent(false) : WideString();
}
}
diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp
index 96d2866c37..4c4e810555 100644
--- a/xfa/fxfa/parser/cxfa_strokedata.cpp
+++ b/xfa/fxfa/parser/cxfa_strokedata.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_strokedata.h"
+#include "xfa/fxfa/parser/cxfa_color.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -51,7 +52,8 @@ FX_ARGB CXFA_StrokeData::GetColor() const {
if (!m_pNode)
return 0xFF000000;
- CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false);
+ CXFA_Color* pNode =
+ m_pNode->GetChild<CXFA_Color>(0, XFA_Element::Color, false);
if (!pNode)
return 0xFF000000;
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp
index 57cf5d4ecf..49f7f1aeff 100644
--- a/xfa/fxfa/parser/cxfa_validate.cpp
+++ b/xfa/fxfa/parser/cxfa_validate.cpp
@@ -8,6 +8,7 @@
#include "fxjs/xfa/cjx_validate.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_picture.h"
#include "xfa/fxfa/parser/cxfa_script.h"
namespace {
@@ -141,10 +142,10 @@ void CXFA_Validate::SetMessageText(const WideString& wsMessageType,
}
WideString CXFA_Validate::GetPicture() {
- CXFA_Node* pNode = GetChild(0, XFA_Element::Picture, false);
+ CXFA_Picture* pNode = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
return pNode ? pNode->JSObject()->GetContent(false) : L"";
}
CXFA_Script* CXFA_Validate::GetScript() {
- return static_cast<CXFA_Script*>(GetChild(0, XFA_Element::Script, false));
+ return GetChild<CXFA_Script>(0, XFA_Element::Script, false);
}
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index bb1f259d00..38f85e715b 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -10,11 +10,17 @@
#include "core/fxcrt/fx_extension.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
+#include "xfa/fxfa/parser/cxfa_comb.h"
+#include "xfa/fxfa/parser/cxfa_decimal.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_eventdata.h"
+#include "xfa/fxfa/parser/cxfa_format.h"
+#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_localevalue.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_picture.h"
+#include "xfa/fxfa/parser/cxfa_ui.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -165,9 +171,12 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
switch (pUIChild->GetElementType()) {
case XFA_Element::CheckButton: {
eValueType = XFA_Element::Text;
- if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items, false)) {
- if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown, false))
+ if (CXFA_Items* pItems =
+ pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
+ if (CXFA_Node* pItem =
+ pItems->GetChild<CXFA_Node>(0, XFA_Element::Unknown, false)) {
eValueType = pItem->GetElementType();
+ }
}
break;
}
@@ -402,7 +411,8 @@ XFA_AttributeEnum CXFA_WidgetData::GetButtonHighlight() {
}
bool CXFA_WidgetData::HasButtonRollover() const {
- CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItems =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
return false;
@@ -415,7 +425,8 @@ bool CXFA_WidgetData::HasButtonRollover() const {
}
bool CXFA_WidgetData::HasButtonDown() const {
- CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItems =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
return false;
@@ -468,7 +479,8 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
if (wsValue.IsEmpty())
return XFA_CHECKSTATE_Off;
- if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) {
+ if (CXFA_Items* pItems =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
int32_t i = 0;
while (pText) {
@@ -489,7 +501,8 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
if (exclGroup.HasValidNode()) {
WideString wsValue;
if (eCheckState != XFA_CHECKSTATE_Off) {
- if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) {
+ if (CXFA_Items* pItems =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pText)
wsValue = pText->JSObject()->GetContent(false);
@@ -501,7 +514,8 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
if (pChild->GetElementType() != XFA_Element::Field)
continue;
- CXFA_Node* pItem = pChild->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItem =
+ pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItem)
continue;
@@ -523,7 +537,8 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
}
exclGroup.SyncValue(wsValue, bNotify);
} else {
- CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItems =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
return;
@@ -590,7 +605,8 @@ void CXFA_WidgetData::SetSelectedMemberByValue(const WideStringView& wsValue,
if (pNode->GetElementType() != XFA_Element::Field)
continue;
- CXFA_Node* pItem = pNode->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItem =
+ pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItem)
continue;
@@ -735,7 +751,8 @@ pdfium::Optional<WideString> CXFA_WidgetData::GetChoiceListItem(
if (!pItems)
return {};
- CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown, false);
+ CXFA_Node* pItem =
+ pItems->GetChild<CXFA_Node>(nIndex, XFA_Element::Unknown, false);
if (pItem)
return {pItem->JSObject()->GetContent(false)};
return {};
@@ -1024,7 +1041,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue,
return;
CXFA_Node* pText =
- pLabelItems->GetChild(iSearch, XFA_Element::Unknown, false);
+ pLabelItems->GetChild<CXFA_Node>(iSearch, XFA_Element::Unknown, false);
if (pText)
wsLabel = pText->JSObject()->GetContent(false);
}
@@ -1067,7 +1084,8 @@ WideString CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel) {
if (iSearch < 0)
return L"";
- CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown, false);
+ CXFA_Node* pText =
+ pSaveItems->GetChild<CXFA_Node>(iSearch, XFA_Element::Unknown, false);
return pText ? pText->JSObject()->GetContent(false) : L"";
}
@@ -1128,7 +1146,8 @@ pdfium::Optional<int32_t> CXFA_WidgetData::GetNumberOfCells() {
CXFA_Node* pUIChild = GetUIChild();
if (!pUIChild)
return {};
- if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_Element::Comb, false))
+ if (CXFA_Comb* pNode =
+ pUIChild->GetChild<CXFA_Comb>(0, XFA_Element::Comb, false))
return {pNode->JSObject()->GetInteger(XFA_Attribute::NumberOfCells)};
return {};
}
@@ -1293,7 +1312,8 @@ bool CXFA_WidgetData::IsMultiLine() {
}
std::pair<XFA_Element, int32_t> CXFA_WidgetData::GetMaxChars() {
- if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value, false)) {
+ if (CXFA_Value* pNode =
+ m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false)) {
if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) {
switch (pChild->GetElementType()) {
case XFA_Element::Text:
@@ -1313,11 +1333,13 @@ std::pair<XFA_Element, int32_t> CXFA_WidgetData::GetMaxChars() {
}
int32_t CXFA_WidgetData::GetFracDigits() {
- CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value, false);
+ CXFA_Value* pNode =
+ m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pNode)
return -1;
- CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal, false);
+ CXFA_Decimal* pChild =
+ pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false);
if (!pChild)
return -1;
@@ -1327,11 +1349,13 @@ int32_t CXFA_WidgetData::GetFracDigits() {
}
int32_t CXFA_WidgetData::GetLeadDigits() {
- CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value, false);
+ CXFA_Value* pNode =
+ m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pNode)
return -1;
- CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal, false);
+ CXFA_Decimal* pChild =
+ pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false);
if (!pChild)
return -1;
@@ -1394,10 +1418,10 @@ WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) {
CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
switch (ePicture) {
case XFA_VALUEPICTURE_Display: {
- if (CXFA_Node* pFormat =
- m_pNode->GetChild(0, XFA_Element::Format, false)) {
- if (CXFA_Node* pPicture =
- pFormat->GetChild(0, XFA_Element::Picture, false)) {
+ if (CXFA_Format* pFormat =
+ m_pNode->GetChild<CXFA_Format>(0, XFA_Element::Format, false)) {
+ if (CXFA_Picture* pPicture = pFormat->GetChild<CXFA_Picture>(
+ 0, XFA_Element::Picture, false)) {
pdfium::Optional<WideString> picture =
pPicture->JSObject()->TryContent(false, true);
if (picture)
@@ -1426,10 +1450,10 @@ WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) {
}
}
case XFA_VALUEPICTURE_Edit: {
- CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui, false);
+ CXFA_Ui* pUI = m_pNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false);
if (pUI) {
- if (CXFA_Node* pPicture =
- pUI->GetChild(0, XFA_Element::Picture, false)) {
+ if (CXFA_Picture* pPicture =
+ pUI->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false)) {
pdfium::Optional<WideString> picture =
pPicture->JSObject()->TryContent(false, true);
if (picture)
@@ -1574,7 +1598,8 @@ WideString CXFA_WidgetData::GetFormatDataValue(const WideString& wsValue) {
WideString wsFormattedValue = wsValue;
if (IFX_Locale* pLocale = GetLocale()) {
ASSERT(GetNode());
- CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_Element::Value, false);
+ CXFA_Value* pNodeValue =
+ GetNode()->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pNodeValue)
return wsValue;
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 30d45787f5..22b339aba5 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -16,6 +16,7 @@
#include "third_party/base/logging.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -194,8 +195,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (pChild->GetElementType() != XFA_Element::Field)
continue;
- auto* pValue = static_cast<CXFA_Value*>(
- pChild->GetChild(0, XFA_Element::Value, false));
+ auto* pValue =
+ pChild->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pValue)
continue;
@@ -203,7 +204,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (wsValue.IsEmpty())
continue;
- CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItems =
+ pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
continue;
@@ -233,7 +235,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
CXFA_Node* pValue =
pChild->JSObject()->GetProperty(0, XFA_Element::Value, true);
- CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items, false);
+ CXFA_Items* pItems =
+ pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
CXFA_Node* pText =
pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr;
if (pText)
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 6706bb64ee..5f00f3e926 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -22,6 +22,8 @@
#include "xfa/fxfa/parser/cxfa_localevalue.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_ui.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
namespace {
@@ -422,15 +424,15 @@ int XFA_GetMaxFractionalScale() {
}
CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) {
- CXFA_Node* pNodeValue =
- pWidgetData->GetNode()->GetChild(0, XFA_Element::Value, false);
- if (!pNodeValue) {
+ CXFA_Value* pNodeValue = pWidgetData->GetNode()->GetChild<CXFA_Value>(
+ 0, XFA_Element::Value, false);
+ if (!pNodeValue)
return CXFA_LocaleValue();
- }
+
CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pValueChild) {
+ if (!pValueChild)
return CXFA_LocaleValue();
- }
+
int32_t iVTType = XFA_VT_NULL;
switch (pValueChild->GetElementType()) {
case XFA_Element::Decimal:
@@ -564,20 +566,21 @@ void XFA_DataExporter_RegenerateFormFile(
}
bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) {
- bool bRet = false;
if (!pFieldNode)
- return bRet;
-
- CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_Element::Ui, false);
- if (pUIChild) {
- CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pFirstChild &&
- pFirstChild->GetElementType() == XFA_Element::ChoiceList) {
- bRet = pFirstChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
- XFA_AttributeEnum::MultiSelect;
- }
+ return false;
+
+ CXFA_Ui* pUIChild = pFieldNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false);
+ if (!pUIChild)
+ return false;
+
+ CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pFirstChild ||
+ pFirstChild->GetElementType() != XFA_Element::ChoiceList) {
+ return false;
}
- return bRet;
+
+ return pFirstChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
+ XFA_AttributeEnum::MultiSelect;
}
int32_t XFA_MapRotation(int32_t nRotation) {