int32_t CXFA_NodeHelper::XFA_CountSiblings(CXFA_Node* pNode, XFA_LOGIC_TYPE eLogicType, CXFA_NodeArray* pSiblings, FX_BOOL bIsClassName) { if (!pNode) return 0; CXFA_Node* parent = XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent); if (!parent) return 0; XFA_LPCPROPERTY pPropert = XFA_GetPropertyOfElement( parent->GetClassID(), pNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); if (!pPropert && eLogicType == XFA_LOGIC_Transparent) { parent = XFA_ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent); if (parent == NULL) { return 0; } } if (bIsClassName) { return XFA_NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(), pSiblings, eLogicType, bIsClassName); } else { return XFA_NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings, eLogicType, bIsClassName); } }
void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { m_bLayoutEvent = TRUE; FX_BOOL bChanged = FALSE; CXFA_Node* pFormNode = NULL; if (pWidgetAcc) { bChanged = ResetSingleWidgetAccData(pWidgetAcc); pFormNode = pWidgetAcc->GetNode(); } else { pFormNode = GetRootSubform(); } if (!pFormNode) { return; } if (pFormNode->GetClassID() != XFA_ELEMENT_Field && pFormNode->GetClassID() != XFA_ELEMENT_ExclGroup) { CXFA_WidgetAccIterator Iterator(this, pFormNode); while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { bChanged |= ResetSingleWidgetAccData(pAcc); if (pAcc->GetNode()->GetClassID() == XFA_ELEMENT_ExclGroup) { Iterator.SkipTree(); } } } if (bChanged) { m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); } }
CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetParent( CXFA_Node* pNode, XFA_LOGIC_TYPE eLogicType) { if (!pNode) { return NULL; } if (eLogicType == XFA_LOGIC_NoTransparent) { return pNode->GetNodeItem(XFA_NODEITEM_Parent); } CXFA_Node* parent; CXFA_Node* node = pNode; while (TRUE) { parent = XFA_ResolveNodes_GetParent(node); if (parent == NULL) { break; } XFA_ELEMENT parentElement = parent->GetClassID(); if ((!parent->IsUnnamed() && parentElement != XFA_ELEMENT_SubformSet) || parentElement == XFA_ELEMENT_Variables) { break; } node = parent; } return parent; }
FX_BOOL CXFA_NodeHelper::XFA_NodeIsProperty(CXFA_Node* refNode) { FX_BOOL bRes = FALSE; CXFA_Node* parent = XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); if (parent != NULL && refNode != NULL) { XFA_LPCPROPERTY pPropert = XFA_GetPropertyOfElement( parent->GetClassID(), refNode->GetClassID(), XFA_XDPPACKET_UNKNOWN); if (pPropert) { bRes = TRUE; } } return bRes; }
FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { FX_BOOL bRet = FALSE; if (!pFieldNode) { return bRet; } CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_ELEMENT_Ui); if (pUIChild) { CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); if (pFirstChild && pFirstChild->GetClassID() == XFA_ELEMENT_ChoiceList) { bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) == XFA_ATTRIBUTEENUM_MultiSelect; } } return bRet; }
int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, FX_BOOL bIsFormReady, FX_BOOL bRecursive, CXFA_Node* pExclude) { int32_t iRet = XFA_EVENTERROR_NotExist; if (pFormNode == pExclude) { return iRet; } XFA_ELEMENT elementType = pFormNode->GetClassID(); if (elementType == XFA_ELEMENT_Field) { if (eEventType == XFA_EVENT_IndexChange) { return iRet; } CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); if (pWidgetAcc == NULL) { return iRet; } CXFA_EventParam eParam; eParam.m_eType = eEventType; eParam.m_pTarget = pWidgetAcc; eParam.m_bIsFormReady = bIsFormReady; return XFA_ProcessEvent(this, pWidgetAcc, &eParam); } if (bRecursive) { for (CXFA_Node* pNode = pFormNode->GetNodeItem( XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling, XFA_OBJECTTYPE_ContainerNode)) { elementType = pNode->GetClassID(); if (elementType != XFA_ELEMENT_Variables && elementType != XFA_ELEMENT_Draw) { iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, bRecursive, pExclude); } } } CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); if (pWidgetAcc == NULL) { return iRet; } CXFA_EventParam eParam; eParam.m_eType = eEventType; eParam.m_pTarget = pWidgetAcc; eParam.m_bIsFormReady = bIsFormReady; iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam); return iRet; }
CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { CXFA_Node* pNodeValue = pWidgetData->GetNode()->GetChild(0, XFA_ELEMENT_Value); if (!pNodeValue) { return CXFA_LocaleValue(); } CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); if (!pValueChild) { return CXFA_LocaleValue(); } int32_t iVTType = XFA_VT_NULL; XFA_ELEMENT eType = pValueChild->GetClassID(); switch (eType) { case XFA_ELEMENT_Decimal: iVTType = XFA_VT_DECIMAL; break; case XFA_ELEMENT_Float: iVTType = XFA_VT_FLOAT; break; case XFA_ELEMENT_Date: iVTType = XFA_VT_DATE; break; case XFA_ELEMENT_Time: iVTType = XFA_VT_TIME; break; case XFA_ELEMENT_DateTime: iVTType = XFA_VT_DATETIME; break; case XFA_ELEMENT_Boolean: iVTType = XFA_VT_BOOLEAN; break; case XFA_ELEMENT_Integer: iVTType = XFA_VT_INTEGER; break; case XFA_ELEMENT_Text: iVTType = XFA_VT_TEXT; break; default: iVTType = XFA_VT_NULL; break; } return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); }
FX_BOOL CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { CXFA_Node* pNode = pWidgetAcc->GetNode(); XFA_ELEMENT eType = pNode->GetClassID(); if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_ExclGroup) { return FALSE; } FX_BOOL bNotify = IsStaticNotify(); pWidgetAcc->ResetData(); pWidgetAcc->UpdateUIDisplay(); if (bNotify) { pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, NULL, NULL); } if (CXFA_Validate validate = pWidgetAcc->GetValidate()) { AddValidateWidget(pWidgetAcc); validate.GetNode()->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE); } return TRUE; }
void CXFA_ResolveProcessor::XFA_ResolveNode_FilterCondition( CXFA_ResolveNodesData& rnd, CFX_WideString wsCondition) { CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; int32_t iCurrIndex = 0; const CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); int32_t iSize = array.GetSize(); if (iSize) { CXFA_Node* curNode = array[iSize - 1]; FX_BOOL bIsProperty = m_pNodeHelper->XFA_NodeIsProperty(curNode); if (curNode->IsUnnamed() || (bIsProperty && curNode->GetClassID() != XFA_ELEMENT_PageSet)) { iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, bIsProperty, TRUE); } else { iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, bIsProperty, FALSE); } } int32_t iFoundCount = findNodes.GetSize(); wsCondition.TrimLeft(); wsCondition.TrimRight(); int32_t iLen = wsCondition.GetLength(); if (!iLen) { if (rnd.m_dwStyles & XFA_RESOLVENODE_ALL) { return; } if (iFoundCount == 1) { return; } if (iFoundCount <= iCurrIndex) { if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); m_pNodeHelper->m_iCreateCount = iCurrIndex - iFoundCount + 1; } findNodes.RemoveAll(); return; } else { CXFA_Node* ret = findNodes[iCurrIndex]; findNodes.RemoveAll(); findNodes.Add(ret); return; } } FX_WCHAR wTypeChar = wsCondition[0]; switch (wTypeChar) { case '[': XFA_ResolveNode_ConditionArray(iCurrIndex, wsCondition, iFoundCount, rnd); return; case '(': return; case '"': return; case '.': if (iLen > 1 && (wsCondition[1] == '[' || wsCondition[1] == '(')) { XFA_ResolveNode_DoPredicateFilter(iCurrIndex, wsCondition, iFoundCount, rnd); } default: return; } }
int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal( CXFA_ResolveNodesData& rnd) { if (rnd.m_nLevel > 32) { return 0; } if (!rnd.m_CurNode->IsNode()) { return 0; } CXFA_Node* curNode = ToNode(rnd.m_CurNode); CXFA_ObjArray& nodes = rnd.m_Nodes; int32_t nNum = nodes.GetSize(); FX_DWORD dwStyles = rnd.m_dwStyles; CFX_WideString& wsName = rnd.m_wsName; uint32_t uNameHash = rnd.m_uHashName; CFX_WideString& wsCondition = rnd.m_wsCondition; CXFA_ResolveNodesData rndFind; rndFind.m_wsName = rnd.m_wsName; rndFind.m_wsCondition = rnd.m_wsCondition; rndFind.m_pSC = rnd.m_pSC; rndFind.m_nLevel = rnd.m_nLevel + 1; rndFind.m_uHashName = uNameHash; CXFA_NodeArray children; CXFA_NodeArray properties; CXFA_Node* pVariablesNode = NULL; CXFA_Node* pPageSetNode = NULL; CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild); while (pChild) { if (pChild->GetClassID() == XFA_ELEMENT_Variables) { pVariablesNode = pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); continue; } else if (pChild->GetClassID() == XFA_ELEMENT_PageSet) { pPageSetNode = pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); continue; } else { XFA_LPCPROPERTY pPropert = XFA_GetPropertyOfElement( curNode->GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); if (pPropert) { properties.Add(pChild); } else { children.Add(pChild); } } pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); } if ((dwStyles & XFA_RESOLVENODE_Properties) && pVariablesNode) { uint32_t uPropHash = pVariablesNode->GetClassHashCode(); if (uPropHash == uNameHash) { nodes.Add(pVariablesNode); } else { rndFind.m_CurNode = pVariablesNode; XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); CFX_WideString wsSaveCondition = rndFind.m_wsCondition; rndFind.m_wsCondition.Empty(); XFA_ResolveNodes_Normal(rndFind); rndFind.m_wsCondition = wsSaveCondition; if (rndFind.m_Nodes.GetSize() > 0) { nodes.Append(rndFind.m_Nodes); rndFind.m_Nodes.RemoveAll(); } } if (nodes.GetSize() > nNum) { XFA_ResolveNode_FilterCondition(rnd, wsCondition); if (nodes.GetSize() > 0) { return 1; } return 0; } } if (dwStyles & XFA_RESOLVENODE_Children) { FX_BOOL bSetFlag = FALSE; if (pPageSetNode && (dwStyles & XFA_RESOLVENODE_Properties)) { children.Add(pPageSetNode); } for (int32_t i = 0; i < children.GetSize(); i++) { CXFA_Node* child = children[i]; if (dwStyles & XFA_RESOLVENODE_TagName) { if (child->GetClassHashCode() == uNameHash) { nodes.Add(child); } } else if (child->GetNameHash() == uNameHash) { nodes.Add(child); } if (m_pNodeHelper->XFA_NodeIsTransparent(child) && child->GetClassID() != XFA_ELEMENT_PageSet) { if (!bSetFlag) { XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); bSetFlag = TRUE; } rndFind.m_CurNode = child; CFX_WideString wsSaveCondition = rndFind.m_wsCondition; rndFind.m_wsCondition.Empty(); XFA_ResolveNodes_Normal(rndFind); rndFind.m_wsCondition = wsSaveCondition; if (rndFind.m_Nodes.GetSize() > 0) { nodes.Append(rndFind.m_Nodes); rndFind.m_Nodes.RemoveAll(); } } } if (nodes.GetSize() > nNum) { if (!(dwStyles & XFA_RESOLVENODE_ALL)) { CXFA_NodeArray upArrayNodes; if (m_pNodeHelper->XFA_NodeIsTransparent(ToNode(curNode))) { m_pNodeHelper->XFA_CountSiblings( ToNode(nodes[0]), XFA_LOGIC_Transparent, &upArrayNodes, !!(dwStyles & XFA_RESOLVENODE_TagName)); } if (upArrayNodes.GetSize() > nodes.GetSize()) { upArrayNodes[0] = ToNode(nodes[0]); nodes.RemoveAll(); nodes.Append((CXFA_ObjArray&)upArrayNodes); upArrayNodes.RemoveAll(); } } XFA_ResolveNode_FilterCondition(rnd, wsCondition); if (nodes.GetSize() > 0) { return 1; } return 0; } } if (dwStyles & XFA_RESOLVENODE_Attributes) { if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName)) { return 1; } } if (dwStyles & XFA_RESOLVENODE_Properties) { for (int32_t i = 0; i < properties.GetSize(); i++) { CXFA_Node* childProperty = properties[i]; if (childProperty->IsUnnamed()) { uint32_t uPropHash = childProperty->GetClassHashCode(); if (uPropHash == uNameHash) { nodes.Add(childProperty); } } else if (childProperty->GetNameHash() == uNameHash && childProperty->GetClassID() != XFA_ELEMENT_Extras && childProperty->GetClassID() != XFA_ELEMENT_Items) { nodes.Add(childProperty); } } if (nodes.GetSize() > nNum) { XFA_ResolveNode_FilterCondition(rnd, wsCondition); if (nodes.GetSize() > 0) { return 1; } return 0; } CXFA_Node* pProp = NULL; if (XFA_ELEMENT_Subform == curNode->GetClassID() && XFA_HASHCODE_Occur == uNameHash) { CXFA_Node* pInstanceManager = curNode->AsNode()->GetInstanceMgrOfSubform(); if (pInstanceManager) { pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE); } } else { XFA_LPCELEMENTINFO pElement = XFA_GetElementByName(wsName); if (pElement) { pProp = curNode->AsNode()->GetProperty( 0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet); } } if (pProp) { nodes.Add(pProp); return nodes.GetSize(); } } CXFA_Node* parentNode = m_pNodeHelper->XFA_ResolveNodes_GetParent( curNode->AsNode(), XFA_LOGIC_NoTransparent); uint32_t uCurClassHash = curNode->GetClassHashCode(); if (!parentNode) { if (uCurClassHash == uNameHash) { nodes.Add(curNode->AsNode()); XFA_ResolveNode_FilterCondition(rnd, wsCondition); if (nodes.GetSize() > 0) { return 1; } } return 0; } if (dwStyles & XFA_RESOLVENODE_Siblings) { CXFA_Node* child = parentNode->GetNodeItem(XFA_NODEITEM_FirstChild); FX_DWORD dwSubStyles = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties; if (dwStyles & XFA_RESOLVENODE_TagName) { dwSubStyles |= XFA_RESOLVENODE_TagName; } if (dwStyles & XFA_RESOLVENODE_ALL) { dwSubStyles |= XFA_RESOLVENODE_ALL; } rndFind.m_dwStyles = dwSubStyles; while (child) { if (child == curNode) { if (dwStyles & XFA_RESOLVENODE_TagName) { if (uCurClassHash == uNameHash) { nodes.Add(curNode); } } else { if (child->GetNameHash() == uNameHash) { nodes.Add(curNode); if (rnd.m_nLevel == 0 && wsCondition.GetLength() == 0) { nodes.RemoveAll(); nodes.Add(curNode); return 1; } } } child = child->GetNodeItem(XFA_NODEITEM_NextSibling); continue; } if (dwStyles & XFA_RESOLVENODE_TagName) { if (child->GetClassHashCode() == uNameHash) { nodes.Add(child); } } else if (child->GetNameHash() == uNameHash) { nodes.Add(child); } XFA_LPCPROPERTY pPropert = XFA_GetPropertyOfElement( parentNode->GetClassID(), child->GetClassID(), XFA_XDPPACKET_UNKNOWN); FX_BOOL bInnerSearch = FALSE; if (pPropert) { if ((child->GetClassID() == XFA_ELEMENT_Variables || child->GetClassID() == XFA_ELEMENT_PageSet)) { bInnerSearch = TRUE; } } else { if (m_pNodeHelper->XFA_NodeIsTransparent(child)) { bInnerSearch = TRUE; } } if (bInnerSearch) { rndFind.m_CurNode = child; CFX_WideString wsOriginCondition = rndFind.m_wsCondition; rndFind.m_wsCondition.Empty(); FX_DWORD dwOriginStyle = rndFind.m_dwStyles; rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL; XFA_ResolveNodes_Normal(rndFind); rndFind.m_dwStyles = dwOriginStyle; rndFind.m_wsCondition = wsOriginCondition; if (rndFind.m_Nodes.GetSize() > 0) { nodes.Append(rndFind.m_Nodes); rndFind.m_Nodes.RemoveAll(); } } child = child->GetNodeItem(XFA_NODEITEM_NextSibling); } if (nodes.GetSize() > nNum) { if (m_pNodeHelper->XFA_NodeIsTransparent(parentNode)) { CXFA_NodeArray upArrayNodes; m_pNodeHelper->XFA_CountSiblings( ToNode(nodes[0]), XFA_LOGIC_Transparent, &upArrayNodes, !!(dwStyles & XFA_RESOLVENODE_TagName)); if (upArrayNodes.GetSize() > nodes.GetSize()) { upArrayNodes[0] = ToNode(nodes[0]); nodes.RemoveAll(); nodes.Append((CXFA_ObjArray&)upArrayNodes); upArrayNodes.RemoveAll(); } } XFA_ResolveNode_FilterCondition(rnd, wsCondition); if (nodes.GetSize() > 0) { return 1; } return 0; } } if (dwStyles & XFA_RESOLVENODE_Parent) { FX_DWORD dwSubStyles = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Properties; if (dwStyles & XFA_RESOLVENODE_TagName) { dwSubStyles |= XFA_RESOLVENODE_TagName; } if (dwStyles & XFA_RESOLVENODE_ALL) { dwSubStyles |= XFA_RESOLVENODE_ALL; } rndFind.m_dwStyles = dwSubStyles; rndFind.m_CurNode = parentNode; CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); array.Add(parentNode); XFA_ResolveNodes_Normal(rndFind); if (rndFind.m_Nodes.GetSize() > 0) { nodes.Append(rndFind.m_Nodes); rndFind.m_Nodes.RemoveAll(); } if (nodes.GetSize() > nNum) { return 1; } } return 0; }
int32_t CXFA_NodeHelper::XFA_NodeAcc_TraverseSiblings(CXFA_Node* parent, FX_DWORD dNameHash, CXFA_NodeArray* pSiblings, XFA_LOGIC_TYPE eLogicType, FX_BOOL bIsClassName, FX_BOOL bIsFindProperty) { if (parent == NULL || pSiblings == NULL) { return 0; } int32_t nCount = 0; int32_t i = 0; if (bIsFindProperty) { CXFA_NodeArray properties; parent->GetNodeList(properties, XFA_NODEFILTER_Properties); int32_t nProperties = properties.GetSize(); for (i = 0; i < nProperties; ++i) { CXFA_Node* child = properties[i]; if (bIsClassName) { if (child->GetClassHashCode() == dNameHash) { pSiblings->Add(child); nCount++; } } else { if (child->GetNameHash() == dNameHash) { if (child->GetClassID() != XFA_ELEMENT_PageSet && child->GetClassID() != XFA_ELEMENT_Extras && child->GetClassID() != XFA_ELEMENT_Items) { pSiblings->Add(child); nCount++; } } } if (child->IsUnnamed() && child->GetClassID() == XFA_ELEMENT_PageSet) { nCount += XFA_NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, eLogicType, bIsClassName, FALSE); } } if (nCount > 0) { return nCount; } } CXFA_NodeArray children; parent->GetNodeList(children, XFA_NODEFILTER_Children); int32_t nChildren = children.GetSize(); for (i = 0; i < nChildren; i++) { CXFA_Node* child = children[i]; if (child->GetClassID() == XFA_ELEMENT_Variables) { continue; } if (bIsClassName) { if (child->GetClassHashCode() == dNameHash) { if (pSiblings) { pSiblings->Add(child); } nCount++; } } else { if (child->GetNameHash() == dNameHash) { if (pSiblings) { pSiblings->Add(child); } nCount++; } } if (eLogicType == XFA_LOGIC_NoTransparent) { continue; } if (XFA_NodeIsTransparent(child) && child->GetClassID() != XFA_ELEMENT_PageSet) { nCount += XFA_NodeAcc_TraverseSiblings(child, dNameHash, pSiblings, eLogicType, bIsClassName, FALSE); } } return nCount; }
CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_ELEMENT& eWidgetType) { XFA_ELEMENT eType = pNode->GetClassID(); eWidgetType = eType; if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_Draw) { return NULL; } eWidgetType = XFA_ELEMENT_UNKNOWN; XFA_ELEMENT eUIType = XFA_ELEMENT_UNKNOWN; CXFA_Value defValue(pNode->GetProperty(0, XFA_ELEMENT_Value, TRUE)); XFA_ELEMENT eValueType = (XFA_ELEMENT)defValue.GetChildValueClassID(); switch (eValueType) { case XFA_ELEMENT_Boolean: eUIType = XFA_ELEMENT_CheckButton; break; case XFA_ELEMENT_Integer: case XFA_ELEMENT_Decimal: case XFA_ELEMENT_Float: eUIType = XFA_ELEMENT_NumericEdit; break; case XFA_ELEMENT_ExData: case XFA_ELEMENT_Text: eUIType = XFA_ELEMENT_TextEdit; eWidgetType = XFA_ELEMENT_Text; break; case XFA_ELEMENT_Date: case XFA_ELEMENT_Time: case XFA_ELEMENT_DateTime: eUIType = XFA_ELEMENT_DateTimeEdit; break; case XFA_ELEMENT_Image: eUIType = XFA_ELEMENT_ImageEdit; eWidgetType = XFA_ELEMENT_Image; break; ; case XFA_ELEMENT_Arc: case XFA_ELEMENT_Line: case XFA_ELEMENT_Rectangle: eUIType = XFA_ELEMENT_DefaultUi; eWidgetType = eValueType; break; default: break; } CXFA_Node* pUIChild = NULL; CXFA_Node* pUI = pNode->GetProperty(0, XFA_ELEMENT_Ui, TRUE); CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { XFA_ELEMENT eChild = pChild->GetClassID(); if (eChild == XFA_ELEMENT_Extras || eChild == XFA_ELEMENT_Picture) { continue; } XFA_LPCPROPERTY pProterty = XFA_GetPropertyOfElement(XFA_ELEMENT_Ui, eChild, XFA_XDPPACKET_Form); if (pProterty && (pProterty->uFlags & XFA_PROPERTYFLAG_OneOf)) { pUIChild = pChild; break; } } if (eType == XFA_ELEMENT_Draw) { XFA_ELEMENT eDraw = pUIChild ? pUIChild->GetClassID() : XFA_ELEMENT_UNKNOWN; switch (eDraw) { case XFA_ELEMENT_TextEdit: eWidgetType = XFA_ELEMENT_Text; break; case XFA_ELEMENT_ImageEdit: eWidgetType = XFA_ELEMENT_Image; break; default: eWidgetType = eWidgetType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_Text : eWidgetType; break; } } else { if (pUIChild && pUIChild->GetClassID() == XFA_ELEMENT_DefaultUi) { eWidgetType = XFA_ELEMENT_TextEdit; } else { eWidgetType = pUIChild ? pUIChild->GetClassID() : (eUIType == XFA_ELEMENT_UNKNOWN ? XFA_ELEMENT_TextEdit : eUIType); } } if (!pUIChild) { if (eUIType == XFA_ELEMENT_UNKNOWN) { eUIType = XFA_ELEMENT_TextEdit; defValue.GetNode()->GetProperty(0, XFA_ELEMENT_Text, TRUE); } pUIChild = pUI->GetProperty(0, eUIType, TRUE); } else if (eUIType == XFA_ELEMENT_UNKNOWN) { switch (pUIChild->GetClassID()) { case XFA_ELEMENT_CheckButton: { eValueType = XFA_ELEMENT_Text; if (CXFA_Node* pItems = pNode->GetChild(0, XFA_ELEMENT_Items)) { if (CXFA_Node* pItem = pItems->GetChild(0, XFA_ELEMENT_UNKNOWN)) { eValueType = pItem->GetClassID(); } } } break; case XFA_ELEMENT_DateTimeEdit: eValueType = XFA_ELEMENT_DateTime; break; case XFA_ELEMENT_ImageEdit: eValueType = XFA_ELEMENT_Image; break; case XFA_ELEMENT_NumericEdit: eValueType = XFA_ELEMENT_Float; break; case XFA_ELEMENT_ChoiceList: { eValueType = (pUIChild->GetEnum(XFA_ATTRIBUTE_Open) == XFA_ATTRIBUTEENUM_MultiSelect) ? XFA_ELEMENT_ExData : XFA_ELEMENT_Text; } break; case XFA_ELEMENT_Barcode: case XFA_ELEMENT_Button: case XFA_ELEMENT_PasswordEdit: case XFA_ELEMENT_Signature: case XFA_ELEMENT_TextEdit: default: eValueType = XFA_ELEMENT_Text; break; } defValue.GetNode()->GetProperty(0, eValueType, TRUE); } return pUIChild; }