summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp28
-rw-r--r--xfa/fxfa/cxfa_ffnotify.h6
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp3
4 files changed, 28 insertions, 15 deletions
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 21273f246d..5dc06f90b8 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -99,14 +99,22 @@ void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetAcc* pSender,
}
}
-CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
- CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
- CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
+CXFA_ContainerLayoutItem* CXFA_FFNotify::OnCreateContainerLayoutItem(
+ CXFA_Node* pNode) {
+ XFA_Element type = pNode->GetElementType();
+ ASSERT(type == XFA_Element::ContentArea || type == XFA_Element::PageArea);
+
+ if (type == XFA_Element::PageArea) {
+ CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
+ return new CXFA_FFPageView(m_pDoc->GetDocView(pLayout), pNode);
+ }
+ return new CXFA_ContainerLayoutItem(pNode);
+}
+
+CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem(
+ CXFA_Node* pNode) {
XFA_Element eType = pNode->GetElementType();
- if (eType == XFA_Element::PageArea)
- return new CXFA_FFPageView(pDocView, pNode);
- if (eType == XFA_Element::ContentArea)
- return new CXFA_ContainerLayoutItem(pNode);
+ ASSERT(eType != XFA_Element::ContentArea && eType != XFA_Element::PageArea);
// We only need to create the widget for certain types of objects.
if (!XFA_IsCreateWidget(eType))
@@ -177,8 +185,10 @@ CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
break;
}
- if (pWidget)
- pWidget->SetDocView(pDocView);
+ if (pWidget) {
+ CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
+ pWidget->SetDocView(m_pDoc->GetDocView(pLayout));
+ }
return pWidget;
}
diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h
index 35b38fd91a..924a060210 100644
--- a/xfa/fxfa/cxfa_ffnotify.h
+++ b/xfa/fxfa/cxfa_ffnotify.h
@@ -11,6 +11,8 @@
#include "xfa/fxfa/parser/cxfa_document.h"
class CXFA_FFWidgetHandler;
+class CXFA_ContainerLayoutItem;
+class CXFA_ContentLayoutItem;
class CXFA_FFNotify {
public:
@@ -35,7 +37,9 @@ class CXFA_FFNotify {
void OnChildAdded(CXFA_Node* pSender);
void OnChildRemoved();
- CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode);
+ CXFA_ContainerLayoutItem* OnCreateContainerLayoutItem(CXFA_Node* pNode);
+ CXFA_ContentLayoutItem* OnCreateContentLayoutItem(CXFA_Node* pNode);
+
void OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
CXFA_LayoutItem* pSender,
int32_t iPageIdx,
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index bd21cdcf11..398a5e8f7c 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -1184,9 +1184,9 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem(
m_pOldLayoutItem = m_pOldLayoutItem->m_pNext;
return pLayoutItem;
}
- pLayoutItem = (CXFA_ContentLayoutItem*)pFormNode->GetDocument()
- ->GetNotify()
- ->OnCreateLayoutItem(pFormNode);
+ pLayoutItem =
+ pFormNode->GetDocument()->GetNotify()->OnCreateContentLayoutItem(
+ pFormNode);
CXFA_ContentLayoutItem* pPrevLayoutItem =
static_cast<CXFA_ContentLayoutItem*>(
pFormNode->JSObject()->GetLayoutItem());
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 61caae762f..20902906f0 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -580,8 +580,7 @@ void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord,
pNewPageAreaLayoutItem = pContainerItem;
} else {
CXFA_FFNotify* pNotify = pNewPageArea->GetDocument()->GetNotify();
- auto* pContainerItem = static_cast<CXFA_ContainerLayoutItem*>(
- pNotify->OnCreateLayoutItem(pNewPageArea));
+ auto* pContainerItem = pNotify->OnCreateContainerLayoutItem(pNewPageArea);
m_PageArray.push_back(pContainerItem);
m_nAvailPages++;
pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved);