CXFA_Node* XFA_DataDescription_MaybeCreateDataNode( CXFA_Document* pDocument, CXFA_Node* pDataParent, XFA_Element eNodeType, const CFX_WideString& wsName) { if (!pDataParent) { return nullptr; } CXFA_Node* pParentDDNode = pDataParent->GetDataDescriptionNode(); if (!pParentDDNode) { CXFA_Node* pDataNode = pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); ASSERT(pDataNode); pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); pDataNode->CreateXMLMappingNode(); pDataParent->InsertChild(pDataNode); pDataNode->SetFlag(XFA_NodeFlag_Initialized, false); return pDataNode; } else { CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup> sIterator(pParentDDNode); for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; pDDGroupNode = sIterator.MoveToNext()) { if (pDDGroupNode != pParentDDNode) { if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) { continue; } CFX_WideString wsNamespace; if (!pDDGroupNode->TryNamespace(wsNamespace) || wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { continue; } } CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName.AsStringC()); if (!pDDNode) { continue; } if (pDDNode->GetElementType() != eNodeType) { break; } CXFA_Node* pDataNode = pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType); ASSERT(pDataNode); pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName); pDataNode->CreateXMLMappingNode(); if (eNodeType == XFA_Element::DataValue && pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData); } pDataParent->InsertChild(pDataNode); pDataNode->SetDataDescriptionNode(pDDNode); pDataNode->SetFlag(XFA_NodeFlag_Initialized, false); return pDataNode; } return nullptr; } }
IXFA_Widget* CXFA_FFWidgetHandler::CreateWidget(IXFA_Widget* hParent, XFA_WIDGETTYPE eType, IXFA_Widget* hBefore) { CXFA_Node* pParentFormItem = hParent ? static_cast<CXFA_FFWidget*>(hParent)->GetDataAcc()->GetNode() : NULL; CXFA_Node* pBeforeFormItem = hBefore ? static_cast<CXFA_FFWidget*>(hBefore)->GetDataAcc()->GetNode() : NULL; CXFA_Node* pNewFormItem = CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); if (pNewFormItem == NULL) { return NULL; } pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized); pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized); m_pDocView->RunLayout(); CXFA_LayoutItem* pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); return (IXFA_Widget*)pLayout; }