From 41cb62ec84f8e8ca4ce8075fd4d825f8e22292a2 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 23 Jun 2016 09:20:32 -0700 Subject: Cleanup some variable namings. This CL cleans up some variable namings from the XFA_Element enum change. Review-Url: https://codereview.chromium.org/2093663002 --- xfa/fxfa/parser/cxfa_widgetdata.cpp | 14 ++- .../parser/xfa_document_datadescription_imp.cpp | 16 ++-- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 34 +++---- xfa/fxfa/parser/xfa_document_datamerger_imp.h | 2 +- xfa/fxfa/parser/xfa_document_serialize.cpp | 4 +- xfa/fxfa/parser/xfa_layout_itemlayout.cpp | 20 ++-- xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp | 7 +- xfa/fxfa/parser/xfa_object.h | 24 ++--- xfa/fxfa/parser/xfa_object_imp.cpp | 101 ++++++++++----------- xfa/fxfa/parser/xfa_script_imp.cpp | 10 +- xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp | 18 ++-- xfa/fxfa/parser/xfa_script_nodehelper.cpp | 12 +-- xfa/fxfa/parser/xfa_utils_imp.cpp | 12 +-- 13 files changed, 127 insertions(+), 147 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index ed53f8324b..07ed3b36c1 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -1328,7 +1328,7 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, if (!pNode) return TRUE; - XFA_Element uiType = pNode->GetElementType(); + XFA_Element eType = pNode->GetElementType(); if (!wsPicture.IsEmpty()) { CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); IFX_Locale* pLocale = GetLocal(); @@ -1339,7 +1339,7 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, wsPicture, pLocale, pLocalMgr); wsNewText = widgetValue.GetValue(); - if (uiType == XFA_Element::NumericEdit) { + if (eType == XFA_Element::NumericEdit) { int32_t iLeadDigits = 0; int32_t iFracDigits = 0; GetLeadDigits(iLeadDigits); @@ -1349,7 +1349,7 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, bSyncData = TRUE; } } else { - if (uiType == XFA_Element::NumericEdit) { + if (eType == XFA_Element::NumericEdit) { if (wsNewText != FX_WSTRC(L"0")) { int32_t iLeadDigits = 0; int32_t iFracDigits = 0; @@ -1360,7 +1360,7 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue, bSyncData = TRUE; } } - if (uiType != XFA_Element::NumericEdit || bSyncData) + if (eType != XFA_Element::NumericEdit || bSyncData) SyncValue(wsNewText, true); return bValidate; @@ -1493,8 +1493,7 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue, if (!pNode) return TRUE; - XFA_Element uiType = GetUIChild()->GetElementType(); - switch (uiType) { + switch (GetUIChild()->GetElementType()) { case XFA_Element::ChoiceList: { if (eValueType == XFA_VALUEPICTURE_Display) { int32_t iSelItemIndex = GetSelectedItem(0); @@ -1598,8 +1597,7 @@ FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideString& wsValue, return FALSE; int32_t iVTType = XFA_VT_NULL; - XFA_Element eType = pValueChild->GetElementType(); - switch (eType) { + switch (pValueChild->GetElementType()) { case XFA_Element::Decimal: iVTType = XFA_VT_DECIMAL; break; diff --git a/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp index 5c7fdfe83a..97ea8dd54b 100644 --- a/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp @@ -31,18 +31,17 @@ void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode, pDataChild; pDataChild = pDataChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { uint32_t dwNameHash = pDataChild->GetNameHash(); - XFA_Element eType = pDataChild->GetElementType(); - if (!dwNameHash) { + if (!dwNameHash) continue; - } + CXFA_NodeIteratorTemplate sIterator(pDataDescriptionNode); for (CXFA_Node* pDDGroupNode = sIterator.GetCurrent(); pDDGroupNode; pDDGroupNode = sIterator.MoveToNext()) { if (pDDGroupNode != pDataDescriptionNode) { - if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) { + if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) continue; - } + CFX_WideString wsNamespace; if (!pDDGroupNode->TryNamespace(wsNamespace) || wsNamespace != FX_WSTRC(L"http://ns.adobe.com/data-description/")) { @@ -50,12 +49,11 @@ void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode, } } CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash); - if (!pDDNode) { + if (!pDDNode) continue; - } - if (pDDNode->GetElementType() != eType) { + if (pDDNode->GetElementType() != pDataChild->GetElementType()) break; - } + pDataChild->SetDataDescriptionNode(pDDNode); XFA_DataDescription_UpdateDataRelation(pDataChild, pDDNode); break; diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index dc52c504a7..d1aeae92dd 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -104,8 +104,8 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, FX_BOOL bDataToForm = TRUE) { pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode); pDataNode->AddBindItem(pFormNode); - XFA_Element eClass = pFormNode->GetElementType(); - if (eClass != XFA_Element::Field && eClass != XFA_Element::ExclGroup) { + XFA_Element eType = pFormNode->GetElementType(); + if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) { return; } CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); @@ -465,13 +465,13 @@ static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, return NULL; } CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, - XFA_Element eClassID, + XFA_Element eType, uint32_t dwNameHash, CXFA_Node* pFormParent) { CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); for (; pFormChild; pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pFormChild->GetElementType() == eClassID && + if (pFormChild->GetElementType() == eType && pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) { return pFormChild; } @@ -750,7 +750,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( CXFA_Node* pDataScope, FX_BOOL bOneInstance, FX_BOOL bDataMerge) { - XFA_Element eElement = pTemplateNode->GetElementType(); + XFA_Element eType = pTemplateNode->GetElementType(); CXFA_Node* pOccurNode = NULL; CXFA_Node* pFirstInstance = NULL; FX_BOOL bUseInstanceManager = @@ -758,8 +758,8 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( CXFA_Node* pInstMgrNode = NULL; CXFA_NodeArray subformArray; CXFA_NodeArray* pSearchArray = NULL; - if (!bOneInstance && (eElement == XFA_Element::SubformSet || - eElement == XFA_Element::Subform)) { + if (!bOneInstance && + (eType == XFA_Element::SubformSet || eType == XFA_Element::Subform)) { pInstMgrNode = bUseInstanceManager ? XFA_NodeMerge_CloneOrMergeInstanceManager( @@ -796,7 +796,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); } XFA_ATTRIBUTEENUM eRelation = - eElement == XFA_Element::SubformSet + eType == XFA_Element::SubformSet ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) : XFA_ATTRIBUTEENUM_Ordered; int32_t iCurRepeatIndex = 0; @@ -805,7 +805,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( CXFA_NodeIteratorTemplate sNodeIterator(pTemplateNode); FX_BOOL bAccessedDataDOM = FALSE; - if (eElement == XFA_Element::SubformSet || eElement == XFA_Element::Area) { + if (eType == XFA_Element::SubformSet || eType == XFA_Element::Area) { sNodeIterator.MoveToNext(); } else { CFX_MapPtrTemplate subformMapArray; @@ -1091,10 +1091,10 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, FX_BOOL bDataRef, FX_BOOL bParentDataRef) { FX_BOOL bMatchRef = TRUE; - XFA_Element eClassID = pFormNode->GetElementType(); + XFA_Element eType = pFormNode->GetElementType(); CXFA_Node* pDataNode = pFormNode->GetBindData(); - if (eClassID == XFA_Element::Subform || eClassID == XFA_Element::ExclGroup || - eClassID == XFA_Element::Field) { + if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup || + eType == XFA_Element::Field) { CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); CXFA_Node* pTemplateNodeBind = pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind) @@ -1114,7 +1114,7 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, if (pFormNode->GetNameHash() != 0 && pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) != XFA_ATTRIBUTEENUM_None) { - XFA_Element eDataNodeType = (eClassID == XFA_Element::Subform || + XFA_Element eDataNodeType = (eType == XFA_Element::Subform || XFA_FieldIsMultiListBox(pFormNode)) ? XFA_Element::DataGroup : XFA_Element::DataValue; @@ -1145,7 +1145,7 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, if (dwNameHash != 0 && !pDataNode) { pDataNode = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); if (!pDataNode) { - XFA_Element eDataNodeType = (eClassID == XFA_Element::Subform || + XFA_Element eDataNodeType = (eType == XFA_Element::Subform || XFA_FieldIsMultiListBox(pFormNode)) ? XFA_Element::DataGroup : XFA_Element::DataValue; @@ -1195,9 +1195,9 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, } } if (bMatchRef && - (eClassID == XFA_Element::Subform || - eClassID == XFA_Element::SubformSet || eClassID == XFA_Element::Area || - eClassID == XFA_Element::PageArea || eClassID == XFA_Element::PageSet)) { + (eType == XFA_Element::Subform || eType == XFA_Element::SubformSet || + eType == XFA_Element::Area || eType == XFA_Element::PageArea || + eType == XFA_Element::PageSet)) { for (CXFA_Node* pFormChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); pFormChild; diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.h b/xfa/fxfa/parser/xfa_document_datamerger_imp.h index dcf6902ba9..f62ff8dace 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.h +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.h @@ -17,7 +17,7 @@ CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer( CXFA_NodeArray* pSubformArray = NULL); CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode); CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, - XFA_Element eClassID, + XFA_Element eType, uint32_t dwNameHash, CXFA_Node* pFormParent); diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index 5555673f8d..5db2025f6c 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -371,8 +371,8 @@ static void XFA_DataExporter_RegenerateFormFile_Container( CXFA_Node* pNode, IFX_Stream* pStream, FX_BOOL bSaveXML = FALSE) { - XFA_Element eElement = pNode->GetElementType(); - if (eElement == XFA_Element::Field || eElement == XFA_Element::Draw || + XFA_Element eType = pNode->GetElementType(); + if (eType == XFA_Element::Field || eType == XFA_Element::Draw || !pNode->IsContainerNode()) { CFX_WideTextBuf buf; XFA_DataExporter_RegenerateFormFile_Changed(pNode, buf, bSaveXML); diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp index f5857178da..5b33e70c36 100644 --- a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp +++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp @@ -901,29 +901,29 @@ static inline void XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( fContainerHeight = 0; bContainerWidthAutoSize = TRUE; bContainerHeightAutoSize = TRUE; - XFA_Element eClassID = pFormNode->GetElementType(); + XFA_Element eType = pFormNode->GetElementType(); CXFA_Measurement mTmpValue; - if (bContainerWidthAutoSize && (eClassID == XFA_Element::Subform || - eClassID == XFA_Element::ExclGroup) && + if (bContainerWidthAutoSize && + (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) && pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, FALSE) && mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); bContainerWidthAutoSize = FALSE; } - if (bContainerHeightAutoSize && (eClassID == XFA_Element::Subform || - eClassID == XFA_Element::ExclGroup) && + if (bContainerHeightAutoSize && + (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) && pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, FALSE) && mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); bContainerHeightAutoSize = FALSE; } - if (bContainerWidthAutoSize && eClassID == XFA_Element::Subform && + if (bContainerWidthAutoSize && eType == XFA_Element::Subform && pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, FALSE) && mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); bContainerWidthAutoSize = FALSE; } - if (bContainerHeightAutoSize && eClassID == XFA_Element::Subform && + if (bContainerHeightAutoSize && eType == XFA_Element::Subform && pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, FALSE) && mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); @@ -1218,8 +1218,7 @@ static inline void XFA_ItemLayoutProcessor_UpdateWidgetSize( FX_FLOAT& fHeight) { CXFA_Node* pNode = pLayoutItem->m_pFormNode; ASSERT(pNode); - XFA_Element eClassID = pNode->GetElementType(); - switch (eClassID) { + switch (pNode->GetElementType()) { case XFA_Element::Subform: case XFA_Element::Area: case XFA_Element::ExclGroup: @@ -2911,8 +2910,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayout( FX_FLOAT fHeightLimit, FX_FLOAT fRealHeight, CXFA_LayoutContext* pContext) { - XFA_Element eClassID = m_pFormNode->GetElementType(); - switch (eClassID) { + switch (m_pFormNode->GetElementType()) { case XFA_Element::Subform: case XFA_Element::Area: case XFA_Element::ExclGroup: diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp index f5a3832594..36e72dbd2d 100644 --- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp @@ -1782,9 +1782,8 @@ void CXFA_LayoutPageMgr::MergePageSetContents() { while (pNode) { if (pNode->IsUnusedNode()) { if (pNode->IsContainerNode()) { - XFA_Element eCurId = pNode->GetElementType(); - if (eCurId == XFA_Element::PageArea || - eCurId == XFA_Element::PageSet) { + XFA_Element eType = pNode->GetElementType(); + if (eType == XFA_Element::PageArea || eType == XFA_Element::PageSet) { CXFA_ContainerIterator iteChild(pNode); CXFA_Node* pChildNode = iteChild.MoveToNext(); for (; pChildNode; pChildNode = iteChild.MoveToNext()) { @@ -1795,7 +1794,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() { delete pLayoutItem; } } - } else if (eCurId != XFA_Element::ContentArea) { + } else if (eType != XFA_Element::ContentArea) { CXFA_LayoutItem* pLayoutItem = static_cast( pNode->GetUserData(XFA_LAYOUTITEMKEY)); if (pLayoutItem) { diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h index 09d8183ce3..54cacc318a 100644 --- a/xfa/fxfa/parser/xfa_object.h +++ b/xfa/fxfa/parser/xfa_object.h @@ -48,7 +48,7 @@ class CXFA_Object : public CFXJSE_HostObject { public: CXFA_Object(CXFA_Document* pDocument, XFA_ObjectType objectType, - XFA_Element elementType); + XFA_Element eType); ~CXFA_Object() override; CXFA_Document* GetDocument() const { return m_pDocument; } @@ -93,8 +93,8 @@ class CXFA_Object : public CFXJSE_HostObject { protected: CXFA_Document* const m_pDocument; - XFA_ObjectType m_objectType; - XFA_Element m_elementType; + const XFA_ObjectType m_objectType; + const XFA_Element m_elementType; }; using CXFA_ObjArray = CFX_ArrayTemplate; @@ -285,11 +285,11 @@ class CXFA_Node : public CXFA_Object { return TryUserData(pKey, pData, bProtoAlso) ? pData : NULL; } CXFA_Node* GetProperty(int32_t index, - XFA_Element eProperty, + XFA_Element eType, FX_BOOL bCreateProperty = TRUE); - int32_t CountChildren(XFA_Element eElement, FX_BOOL bOnlyChild = FALSE); + int32_t CountChildren(XFA_Element eType, FX_BOOL bOnlyChild = FALSE); CXFA_Node* GetChild(int32_t index, - XFA_Element eElement, + XFA_Element eType, FX_BOOL bOnlyChild = FALSE); int32_t InsertChild(int32_t index, CXFA_Node* pNode); FX_BOOL InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode = NULL); @@ -300,9 +300,9 @@ class CXFA_Node : public CXFA_Object { int32_t GetNodeList(CXFA_NodeArray& nodes, uint32_t dwTypeFilter = XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties, - XFA_Element eElementFilter = XFA_Element::Unknown, + XFA_Element eTypeFilter = XFA_Element::Unknown, int32_t iLevel = 1); - CXFA_Node* CreateSamePacketNode(XFA_Element eElement, + CXFA_Node* CreateSamePacketNode(XFA_Element eType, uint32_t dwFlags = XFA_NodeFlag_Initialized); CXFA_Node* CloneTemplateToForm(FX_BOOL bRecursive); CXFA_Node* GetTemplateNode() const; @@ -320,10 +320,10 @@ class CXFA_Node : public CXFA_Object { XFA_ATTRIBUTEENUM GetIntact(); CXFA_Node* GetFirstChildByName(const CFX_WideStringC& wsNodeName) const; CXFA_Node* GetFirstChildByName(uint32_t dwNodeNameHash) const; - CXFA_Node* GetFirstChildByClass(XFA_Element eNodeClass) const; + CXFA_Node* GetFirstChildByClass(XFA_Element eType) const; CXFA_Node* GetNextSameNameSibling(uint32_t dwNodeNameHash) const; CXFA_Node* GetNextSameNameSibling(const CFX_WideStringC& wsNodeName) const; - CXFA_Node* GetNextSameClassSibling(XFA_Element eNodeClass) const; + CXFA_Node* GetNextSameClassSibling(XFA_Element eType) const; int32_t GetNodeSameNameIndex() const; int32_t GetNodeSameClassIndex() const; void GetSOMExpression(CFX_WideString& wsSOMExpression); @@ -616,7 +616,7 @@ class CXFA_Node : public CXFA_Object { protected: friend class CXFA_Document; - CXFA_Node(CXFA_Document* pDoc, uint16_t ePacket, XFA_Element eElement); + CXFA_Node(CXFA_Document* pDoc, uint16_t ePacket, XFA_Element eType); ~CXFA_Node() override; bool HasFlag(XFA_NodeFlag dwFlag) const; @@ -633,7 +633,7 @@ class CXFA_Node : public CXFA_Object { void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify); void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, FX_BOOL bScriptModify); int32_t execSingleEventByName(const CFX_WideStringC& wsEventName, - XFA_Element eElementType); + XFA_Element eType); FX_BOOL SetScriptContent(const CFX_WideString& wsContent, const CFX_WideString& wsXMLValue, bool bNotify = true, diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp index 946df7a66a..06ffb10a18 100644 --- a/xfa/fxfa/parser/xfa_object_imp.cpp +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -43,8 +43,8 @@ void XFA_CopyWideString(void*& pData) { XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString, XFA_CopyWideString}; -XFA_ObjectType XFA_GetElementObjectType(XFA_Element eElement) { - return XFA_GetElementByID(eElement)->eObjectType; +XFA_ObjectType XFA_GetElementObjectType(XFA_Element eType) { + return XFA_GetElementByID(eType)->eObjectType; } void XFA_DataNodeDeleteBindItem(void* pData) { @@ -108,10 +108,8 @@ XFA_MAPMODULEDATA::XFA_MAPMODULEDATA() {} XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {} -CXFA_Node::CXFA_Node(CXFA_Document* pDoc, - uint16_t ePacket, - XFA_Element eElement) - : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement), eElement), +CXFA_Node::CXFA_Node(CXFA_Document* pDoc, uint16_t ePacket, XFA_Element eType) + : CXFA_Object(pDoc, XFA_GetElementObjectType(eType), eType), m_pNext(nullptr), m_pChild(nullptr), m_pLastChild(nullptr), @@ -240,18 +238,18 @@ CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem, int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, uint32_t dwTypeFilter, - XFA_Element eElementFilter, + XFA_Element eTypeFilter, int32_t iLevel) { if (--iLevel < 0) { return nodes.GetSize(); } - if (eElementFilter != XFA_Element::Unknown) { + if (eTypeFilter != XFA_Element::Unknown) { CXFA_Node* pChild = m_pChild; while (pChild) { - if (pChild->GetElementType() == eElementFilter) { + if (pChild->GetElementType() == eTypeFilter) { nodes.Add(pChild); if (iLevel > 0) { - GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); + GetNodeList(nodes, dwTypeFilter, eTypeFilter, iLevel); } } pChild = pChild->m_pNext; @@ -262,7 +260,7 @@ int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, while (pChild) { nodes.Add(pChild); if (iLevel > 0) { - GetNodeList(nodes, dwTypeFilter, eElementFilter, iLevel); + GetNodeList(nodes, dwTypeFilter, eTypeFilter, iLevel); } pChild = pChild->m_pNext; } @@ -316,10 +314,10 @@ int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes, return nodes.GetSize(); } -CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eElement, +CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eType, uint32_t dwFlags) { CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); - CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eElement); + CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eType); pNode->SetFlag(dwFlags, true); return pNode; } @@ -439,14 +437,14 @@ CXFA_WidgetData* CXFA_Node::GetWidgetData() { CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { if (GetPacketID() != XFA_XDPPACKET_Form) return nullptr; - XFA_Element classID = GetElementType(); - if (classID == XFA_Element::ExclGroup) + XFA_Element eType = GetElementType(); + if (eType == XFA_Element::ExclGroup) return nullptr; CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); if (pParentNode && pParentNode->GetElementType() == XFA_Element::ExclGroup) return nullptr; - if (classID == XFA_Element::Field) { + if (eType == XFA_Element::Field) { CXFA_WidgetData* pFieldWidgetData = GetWidgetData(); if (pFieldWidgetData && pFieldWidgetData->GetChoiceListOpen() == @@ -531,7 +529,6 @@ FX_BOOL CXFA_Node::GetLocaleName(CFX_WideString& wsLocaleName) { } XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { - XFA_Element eElement = GetElementType(); CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep); XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout); if (pKeep) { @@ -563,7 +560,7 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { return eIntact; } } - switch (eElement) { + switch (GetElementType()) { case XFA_Element::Subform: switch (eLayoutType) { case XFA_ATTRIBUTEENUM_Position: @@ -1286,8 +1283,7 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( } bool bNeedFindContainer = false; - XFA_Element eType = GetElementType(); - switch (eType) { + switch (GetElementType()) { case XFA_Element::Caption: bNeedFindContainer = true; pNotify->OnValueChanged(this, eAttribute, this, @@ -1383,8 +1379,8 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( if (!pValueNode) { return; } - XFA_Element eNodeType = pValueNode->GetElementType(); - if (eNodeType == XFA_Element::Value) { + XFA_Element eType = pValueNode->GetElementType(); + if (eType == XFA_Element::Value) { bNeedFindContainer = true; CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); if (pNode && pNode->IsContainerNode()) { @@ -1397,7 +1393,7 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( pNode->GetNodeItem(XFA_NODEITEM_Parent)); } } else { - if (eNodeType == XFA_Element::Items) { + if (eType == XFA_Element::Items) { CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); if (pNode && pNode->IsContainerNode()) { pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode); @@ -1598,14 +1594,16 @@ void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - XFA_Element classID = GetElementType(); - if (classID == XFA_Element::Field) { + XFA_Element eType = GetElementType(); + if (eType == XFA_Element::Field) { Script_Field_DefaultValue(pValue, bSetting, eAttribute); return; - } else if (classID == XFA_Element::Draw) { + } + if (eType == XFA_Element::Draw) { Script_Draw_DefaultValue(pValue, bSetting, eAttribute); return; - } else if (classID == XFA_Element::Boolean) { + } + if (eType == XFA_Element::Boolean) { Script_Boolean_Value(pValue, bSetting, eAttribute); return; } @@ -1644,13 +1642,12 @@ void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); } else { CFX_WideString content = GetScriptContent(TRUE); - if (content.IsEmpty() && classID != XFA_Element::Text && - classID != XFA_Element::SubmitUrl) { + if (content.IsEmpty() && eType != XFA_Element::Text && + eType != XFA_Element::SubmitUrl) { pValue->SetNull(); - } else if (classID == XFA_Element::Integer) { + } else if (eType == XFA_Element::Integer) { pValue->SetInteger(FXSYS_wtoi(content.c_str())); - } else if (classID == XFA_Element::Float || - classID == XFA_Element::Decimal) { + } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) { CFX_Decimal decimal(content.AsStringC()); pValue->SetFloat((FX_FLOAT)(double)decimal); } else { @@ -1947,11 +1944,10 @@ void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, pValue->SetNull(); } else { CXFA_Node* pUIChild = pWidgetData->GetUIChild(); - XFA_Element eUI = pUIChild->GetElementType(); CXFA_Value defVal = pWidgetData->GetFormValue(); CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); if (pNode && pNode->GetElementType() == XFA_Element::Decimal) { - if (eUI == XFA_Element::NumericEdit && + if (pUIChild->GetElementType() == XFA_Element::NumericEdit && (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { pValue->SetString( FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); @@ -3601,8 +3597,8 @@ void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { uint32_t dwKey = FX_HashCode_GetW(wsKey, false); return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom); } -void* XFA_GetMapKey_Element(XFA_Element eElement, XFA_ATTRIBUTE eAttribute) { - return (void*)(uintptr_t)((static_cast(eElement) << 16) | +void* XFA_GetMapKey_Element(XFA_Element eType, XFA_ATTRIBUTE eAttribute) { + return (void*)(uintptr_t)((static_cast(eType) << 16) | (eAttribute << 8) | XFA_KEYTYPE_Element); } FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) { @@ -4358,10 +4354,10 @@ FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { CXFA_Node* CXFA_Node::GetProperty(int32_t index, XFA_Element eProperty, FX_BOOL bCreateProperty) { - XFA_Element eElement = GetElementType(); + XFA_Element eType = GetElementType(); uint32_t dwPacket = GetPacketID(); const XFA_PROPERTY* pProperty = - XFA_GetPropertyOfElement(eElement, eProperty, dwPacket); + XFA_GetPropertyOfElement(eType, eProperty, dwPacket); if (!pProperty || index >= pProperty->uOccur) return nullptr; @@ -4382,7 +4378,7 @@ CXFA_Node* CXFA_Node::GetProperty(int32_t index, pNode = m_pChild; for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { const XFA_PROPERTY* pExistProperty = - XFA_GetPropertyOfElement(eElement, pNode->GetElementType(), dwPacket); + XFA_GetPropertyOfElement(eType, pNode->GetElementType(), dwPacket); if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) return nullptr; } @@ -4399,12 +4395,11 @@ CXFA_Node* CXFA_Node::GetProperty(int32_t index, } return pNewNode; } -int32_t CXFA_Node::CountChildren(XFA_Element eElement, FX_BOOL bOnlyChild) { +int32_t CXFA_Node::CountChildren(XFA_Element eType, FX_BOOL bOnlyChild) { CXFA_Node* pNode = m_pChild; int32_t iCount = 0; for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetElementType() == eElement || - eElement == XFA_Element::Unknown) { + if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { if (bOnlyChild) { const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); @@ -4418,14 +4413,13 @@ int32_t CXFA_Node::CountChildren(XFA_Element eElement, FX_BOOL bOnlyChild) { return iCount; } CXFA_Node* CXFA_Node::GetChild(int32_t index, - XFA_Element eElement, + XFA_Element eType, FX_BOOL bOnlyChild) { ASSERT(index > -1); CXFA_Node* pNode = m_pChild; int32_t iCount = 0; for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetElementType() == eElement || - eElement == XFA_Element::Unknown) { + if (pNode->GetElementType() == eType || eType == XFA_Element::Unknown) { if (bOnlyChild) { const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN); @@ -4610,10 +4604,10 @@ CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const { } return nullptr; } -CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_Element eElement) const { +CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_Element eType) const { for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetElementType() == eElement) { + if (pNode->GetElementType() == eType) { return pNode; } } @@ -4632,10 +4626,10 @@ CXFA_Node* CXFA_Node::GetNextSameNameSibling( const CFX_WideStringC& wsNodeName) const { return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false)); } -CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_Element eElement) const { +CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_Element eType) const { for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pNode->GetElementType() == eElement) { + if (pNode->GetElementType() == eType) { return pNode; } } @@ -4745,7 +4739,7 @@ void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, } int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, - XFA_Element eElementType) { + XFA_Element eType) { int32_t iRet = XFA_EVENTERROR_NotExist; const XFA_ExecEventParaInfo* eventParaInfo = GetEventParaInfoByName(wsEventName); @@ -4761,13 +4755,12 @@ int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, FALSE, FALSE); } else if (validFlags == 3) { - if (eElementType == XFA_Element::Subform) { + if (eType == XFA_Element::Subform) { iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, FALSE, FALSE); } } else if (validFlags == 4) { - if (eElementType == XFA_Element::ExclGroup || - eElementType == XFA_Element::Field) { + if (eType == XFA_Element::ExclGroup || eType == XFA_Element::Field) { CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); if (pParentNode && pParentNode->GetElementType() == XFA_Element::ExclGroup) { @@ -4778,7 +4771,7 @@ int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, FALSE, FALSE); } } else if (validFlags == 5) { - if (eElementType == XFA_Element::Field) { + if (eType == XFA_Element::Field) { iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType, FALSE, FALSE); } diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index b2f9b25ec2..ee7576ebf1 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -357,13 +357,13 @@ int32_t CXFA_ScriptContext::NormalPropTypeGetter( CXFA_ScriptContext* lpScriptContext = pObject->GetDocument()->GetScriptContext(); pObject = lpScriptContext->GetVariablesThis(pObject); - XFA_Element objElement = pObject->GetElementType(); + XFA_Element eType = pObject->GetElementType(); CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); - if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) { + if (XFA_GetMethodByName(eType, wsPropName.AsStringC())) { return FXJSE_ClassPropType_Method; } if (bQueryIn && - !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) { + !XFA_GetScriptAttributeByName(eType, wsPropName.AsStringC())) { return FXJSE_ClassPropType_None; } return FXJSE_ClassPropType_Property; @@ -379,9 +379,9 @@ int32_t CXFA_ScriptContext::GlobalPropTypeGetter( CXFA_ScriptContext* lpScriptContext = pObject->GetDocument()->GetScriptContext(); pObject = lpScriptContext->GetVariablesThis(pObject); - XFA_Element objElement = pObject->GetElementType(); + XFA_Element eType = pObject->GetElementType(); CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); - if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) { + if (XFA_GetMethodByName(eType, wsPropName.AsStringC())) { return FXJSE_ClassPropType_Method; } return FXJSE_ClassPropType_Property; diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp index 81c7335e30..de47bd2e91 100644 --- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp @@ -248,12 +248,9 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( if (!pItemChild->IsContentLayoutItem()) { continue; } - XFA_Element eElementType = - pItemChild->m_pFormNode->GetElementType(); - if (eElementType != XFA_Element::Field && - eElementType != XFA_Element::Draw && - eElementType != XFA_Element::Subform && - eElementType != XFA_Element::Area) { + XFA_Element eType = pItemChild->m_pFormNode->GetElementType(); + if (eType != XFA_Element::Field && eType != XFA_Element::Draw && + eType != XFA_Element::Subform && eType != XFA_Element::Area) { continue; } if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) @@ -273,12 +270,9 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( if (!pItemChild->IsContentLayoutItem()) { continue; } - XFA_Element eElementType = - pItemChild->m_pFormNode->GetElementType(); - if (eElementType != XFA_Element::Field && - eElementType != XFA_Element::Draw && - eElementType != XFA_Element::Subform && - eElementType != XFA_Element::Area) { + XFA_Element eType = pItemChild->m_pFormNode->GetElementType(); + if (eType != XFA_Element::Field && eType != XFA_Element::Draw && + eType != XFA_Element::Subform && eType != XFA_Element::Area) { continue; } if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) diff --git a/xfa/fxfa/parser/xfa_script_nodehelper.cpp b/xfa/fxfa/parser/xfa_script_nodehelper.cpp index 5c3944371d..0fd5ff21d5 100644 --- a/xfa/fxfa/parser/xfa_script_nodehelper.cpp +++ b/xfa/fxfa/parser/xfa_script_nodehelper.cpp @@ -223,9 +223,9 @@ CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetParent( if (parent == NULL) { break; } - XFA_Element parentElement = parent->GetElementType(); - if ((!parent->IsUnnamed() && parentElement != XFA_Element::SubformSet) || - parentElement == XFA_Element::Variables) { + XFA_Element parentType = parent->GetElementType(); + if ((!parent->IsUnnamed() && parentType != XFA_Element::SubformSet) || + parentType == XFA_Element::Variables) { break; } node = parent; @@ -305,10 +305,10 @@ FX_BOOL CXFA_NodeHelper::XFA_NodeIsTransparent(CXFA_Node* refNode) { if (refNode == NULL) { return FALSE; } - XFA_Element eRefNode = refNode->GetElementType(); + XFA_Element refNodeType = refNode->GetElementType(); if ((refNode->IsUnnamed() && refNode->IsContainerNode()) || - eRefNode == XFA_Element::SubformSet || eRefNode == XFA_Element::Area || - eRefNode == XFA_Element::Proto) { + refNodeType == XFA_Element::SubformSet || + refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto) { return TRUE; } return FALSE; diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp index 9e9788e19f..9220601d50 100644 --- a/xfa/fxfa/parser/xfa_utils_imp.cpp +++ b/xfa/fxfa/parser/xfa_utils_imp.cpp @@ -62,12 +62,13 @@ CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { 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->GetElementType(); - if (eChild == XFA_Element::Extras || eChild == XFA_Element::Picture) { + XFA_Element eChildType = pChild->GetElementType(); + if (eChildType == XFA_Element::Extras || + eChildType == XFA_Element::Picture) { continue; } - const XFA_PROPERTY* pProperty = - XFA_GetPropertyOfElement(XFA_Element::Ui, eChild, XFA_XDPPACKET_Form); + const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement( + XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form); if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) { pUIChild = pChild; break; @@ -153,8 +154,7 @@ CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { return CXFA_LocaleValue(); } int32_t iVTType = XFA_VT_NULL; - XFA_Element eType = pValueChild->GetElementType(); - switch (eType) { + switch (pValueChild->GetElementType()) { case XFA_Element::Decimal: iVTType = XFA_VT_DECIMAL; break; -- cgit v1.2.3