summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 20:47:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 20:47:55 +0000
commit3ffde1bc73156098e78e5e303b3f5198a1d073b8 (patch)
treec3a13bfda69bfb9bc4a85855d588d64d27faaa57 /xfa/fxfa
parent326c38c4f2749e61fa2dec1d0f326e4099d6a24c (diff)
downloadpdfium-3ffde1bc73156098e78e5e303b3f5198a1d073b8.tar.xz
Rename GetTemplateNode to GetTemplateNodeIfExists
This CL makes it explicit that GetTemplateNodeIfExists can return nullptr. Various call sites are updated as needed. Change-Id: If6edd5962b59e7e4ce3dbe9bbdc957783cf76abe Reviewed-on: https://pdfium-review.googlesource.com/22678 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp21
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp15
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp14
-rw-r--r--xfa/fxfa/parser/cxfa_node.h2
-rw-r--r--xfa/fxfa/parser/cxfa_nodehelper.cpp4
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp6
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp2
8 files changed, 46 insertions, 20 deletions
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 857a3c6687..87a013cee2 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -254,7 +254,11 @@ CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent,
if (!pNewFormItem)
return nullptr;
- pNewFormItem->GetTemplateNode()->SetFlag(XFA_NodeFlag_Initialized, true);
+ CXFA_Node* templateNode = pNewFormItem->GetTemplateNodeIfExists();
+ if (!templateNode)
+ return nullptr;
+
+ templateNode->SetFlag(XFA_NodeFlag_Initialized, true);
pNewFormItem->SetFlag(XFA_NodeFlag_Initialized, true);
m_pDocView->RunLayout();
CXFA_LayoutItem* pLayout =
@@ -485,7 +489,13 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent,
CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement,
CXFA_Node* pParent,
CXFA_Node* pBefore) const {
- CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr;
+ if (!pParent)
+ return nullptr;
+
+ CXFA_Node* pTemplateParent = pParent->GetTemplateNodeIfExists();
+ if (!pTemplateParent)
+ return nullptr;
+
CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(false);
if (pParent)
pParent->InsertChild(pNewFormItem, pBefore);
@@ -495,10 +505,13 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement,
CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_Element eElement,
CXFA_Node* pParent,
CXFA_Node* pBefore) const {
- CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr;
+ if (!pParent)
+ return nullptr;
+
+ CXFA_Node* pTemplateParent = pParent->GetTemplateNodeIfExists();
CXFA_Node* pNewNode =
CreateTemplateNode(eElement, pTemplateParent,
- pBefore ? pBefore->GetTemplateNode() : nullptr)
+ pBefore ? pBefore->GetTemplateNodeIfExists() : nullptr)
->Clone(false);
if (pParent)
pParent->InsertChild(pNewNode, pBefore);
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 6275650370..d5bbeef2ec 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -2824,7 +2824,7 @@ bool CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur(
if (!pFormNode)
return false;
- CXFA_Node* pTemplate = pFormNode->GetTemplateNode();
+ CXFA_Node* pTemplate = pFormNode->GetTemplateNodeIfExists();
if (!pTemplate)
pTemplate = pFormNode;
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index c5b7d52caa..d30143c035 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -144,6 +144,9 @@ void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) {
CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
bool bNewExprStyle,
WideString& wsTargetAll) {
+ if (!pPageSetRoot)
+ return nullptr;
+
CXFA_Document* pDocument = pPageSetRoot->GetDocument();
if (wsTargetAll.IsEmpty())
return nullptr;
@@ -282,7 +285,7 @@ CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() {
bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
PrepareLayout();
- CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode();
+ CXFA_Node* pTemplateNode = pFormNode->GetTemplateNodeIfExists();
if (!pTemplateNode)
return false;
@@ -811,7 +814,7 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
WideString wsBreakLeader;
WideString wsBreakTrailer;
CXFA_Node* pFormNode = pCurNode->GetContainerParent();
- CXFA_Node* pContainer = pFormNode->GetTemplateNode();
+ CXFA_Node* pContainer = pFormNode->GetTemplateNodeIfExists();
bool bStartNew =
pCurNode->JSObject()->GetInteger(XFA_Attribute::StartNew) != 0;
CXFA_Script* pScript =
@@ -938,7 +941,7 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
CXFA_Node*& pTrailerTemplate,
bool bCreatePage) {
CXFA_Node* pContainer =
- pOverflowNode->GetContainerParent()->GetTemplateNode();
+ pOverflowNode->GetContainerParent()->GetTemplateNodeIfExists();
if (pOverflowNode->GetElementType() == XFA_Element::Break) {
WideString wsOverflowLeader =
pOverflowNode->JSObject()->GetCData(XFA_Attribute::OverflowLeader);
@@ -1069,7 +1072,8 @@ bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
CXFA_Node* pBookendNode,
bool bLeader,
CXFA_Node*& pBookendAppendTemplate) {
- CXFA_Node* pContainer = pBookendNode->GetContainerParent()->GetTemplateNode();
+ CXFA_Node* pContainer =
+ pBookendNode->GetContainerParent()->GetTemplateNodeIfExists();
if (pBookendNode->GetElementType() == XFA_Element::Break) {
WideString leader = pBookendNode->JSObject()->GetCData(
bLeader ? XFA_Attribute::BookendLeader : XFA_Attribute::BookendTrailer);
@@ -1800,7 +1804,8 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode;
for (CXFA_Node* pChildNode = pParentNode->GetFirstChild(); pChildNode;
pChildNode = pChildNode->GetNextSibling()) {
- if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) {
+ if (pChildNode->GetTemplateNodeIfExists() !=
+ pContainerItem->m_pFormNode) {
continue;
}
pContainerItem->m_pFormNode = pChildNode;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 12a6ee4a0a..54b4661ce3 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -478,7 +478,7 @@ CXFA_Node* CXFA_Node::CloneTemplateToForm(bool bRecursive) {
return pClone;
}
-CXFA_Node* CXFA_Node::GetTemplateNode() const {
+CXFA_Node* CXFA_Node::GetTemplateNodeIfExists() const {
return m_pAuxNode;
}
@@ -1286,7 +1286,10 @@ void CXFA_Node::RemoveItem(CXFA_Node* pRemoveInstance,
CXFA_Node* CXFA_Node::CreateInstance(bool bDataMerge) {
CXFA_Document* pDocument = GetDocument();
- CXFA_Node* pTemplateNode = GetTemplateNode();
+ CXFA_Node* pTemplateNode = GetTemplateNodeIfExists();
+ if (!pTemplateNode)
+ return nullptr;
+
CXFA_Node* pFormParent = GetParent();
CXFA_Node* pDataScope = nullptr;
for (CXFA_Node* pRootBoundNode = pFormParent;
@@ -1300,6 +1303,7 @@ CXFA_Node* CXFA_Node::CreateInstance(bool bDataMerge) {
pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
ASSERT(pDataScope);
}
+
CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer(
pTemplateNode, pFormParent, pDataScope, true, bDataMerge, true);
if (pInstance) {
@@ -1590,8 +1594,10 @@ bool CXFA_Node::IsOpenAccess() {
}
CXFA_Value* CXFA_Node::GetDefaultValue() {
- CXFA_Node* pTemNode = GetTemplateNode();
- return pTemNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
+ CXFA_Node* pTemNode = GetTemplateNodeIfExists();
+ return pTemNode ? pTemNode->JSObject()->GetProperty<CXFA_Value>(
+ 0, XFA_Element::Value)
+ : nullptr;
}
CXFA_Value* CXFA_Node::GetFormValue() const {
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index f4ff51382f..1dcaeec0e5 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -190,7 +190,7 @@ class CXFA_Node : public CXFA_Object {
XFA_Element eTypeFilter);
CXFA_Node* CreateSamePacketNode(XFA_Element eType);
CXFA_Node* CloneTemplateToForm(bool bRecursive);
- CXFA_Node* GetTemplateNode() const;
+ CXFA_Node* GetTemplateNodeIfExists() const;
void SetTemplateNode(CXFA_Node* pTemplateNode);
CXFA_Node* GetDataDescriptionNode();
void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode);
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index 6a090ffe96..c09d4f3c2d 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -368,9 +368,9 @@ bool CXFA_NodeHelper::ResolveNodes_CreateNode(WideString wsName,
}
void CXFA_NodeHelper::SetCreateNodeType(CXFA_Node* refNode) {
- if (!refNode) {
+ if (!refNode)
return;
- }
+
if (refNode->GetElementType() == XFA_Element::Subform) {
m_eLastCreateType = XFA_Element::DataGroup;
} else if (refNode->GetElementType() == XFA_Element::Field) {
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index e2e212f70b..3332d90b66 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -1090,7 +1090,7 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
CXFA_Node* pDataNode = pFormNode->GetBindData();
if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup ||
eType == XFA_Element::Field) {
- CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode();
+ CXFA_Node* pTemplateNode = pFormNode->GetTemplateNodeIfExists();
CXFA_Bind* pTemplateNodeBind =
pTemplateNode
? pTemplateNode->GetFirstChildByClass<CXFA_Bind>(XFA_Element::Bind)
@@ -1168,7 +1168,9 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
bParentDataRef = true;
if (!pDataNode && bDataRef) {
WideString wsRef =
- pTemplateNodeBind->JSObject()->GetCData(XFA_Attribute::Ref);
+ pTemplateNodeBind
+ ? pTemplateNodeBind->JSObject()->GetCData(XFA_Attribute::Ref)
+ : L"";
uint32_t dFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode;
XFA_RESOLVENODE_RS rs;
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index bda4c2c92f..7e1f44d5dd 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -285,7 +285,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
}
default:
if (pNode->GetElementType() == XFA_Element::Items) {
- CXFA_Node* pTemplateNode = pNode->GetTemplateNode();
+ CXFA_Node* pTemplateNode = pNode->GetTemplateNodeIfExists();
if (!pTemplateNode ||
pTemplateNode->CountChildren(XFA_Element::Unknown, false) !=
pNode->CountChildren(XFA_Element::Unknown, false)) {