diff options
37 files changed, 150 insertions, 137 deletions
@@ -1370,6 +1370,8 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_corner.h", "xfa/fxfa/parser/cxfa_data.cpp", "xfa/fxfa/parser/cxfa_data.h", + "xfa/fxfa/parser/cxfa_document.cpp", + "xfa/fxfa/parser/cxfa_document.h", "xfa/fxfa/parser/cxfa_document_parser.cpp", "xfa/fxfa/parser/cxfa_document_parser.h", "xfa/fxfa/parser/cxfa_edge.h", @@ -1441,10 +1443,8 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/xfa_basic_data_element_script.cpp", "xfa/fxfa/parser/xfa_basic_data_enum.cpp", "xfa/fxfa/parser/xfa_basic_data_packets.cpp", - "xfa/fxfa/parser/xfa_document.h", "xfa/fxfa/parser/xfa_document_datamerger_imp.cpp", "xfa/fxfa/parser/xfa_document_datamerger_imp.h", - "xfa/fxfa/parser/xfa_document_imp.cpp", "xfa/fxfa/parser/xfa_document_serialize.cpp", "xfa/fxfa/parser/xfa_document_serialize.h", "xfa/fxfa/parser/xfa_layout_appadapter.cpp", @@ -475,6 +475,8 @@ "xfa/fxfa/parser/cxfa_contentlayoutitem.h", "xfa/fxfa/parser/cxfa_data.cpp", "xfa/fxfa/parser/cxfa_data.h", + "xfa/fxfa/parser/cxfa_document.cpp", + "xfa/fxfa/parser/cxfa_document.h", "xfa/fxfa/parser/cxfa_document_parser.cpp", "xfa/fxfa/parser/cxfa_document_parser.h", "xfa/fxfa/parser/cxfa_edge.h", @@ -546,10 +548,8 @@ "xfa/fxfa/parser/xfa_basic_data_enum.cpp", "xfa/fxfa/parser/xfa_basic_data_packets.cpp", "xfa/fxfa/parser/xfa_basic_data.h", - "xfa/fxfa/parser/xfa_document.h", "xfa/fxfa/parser/xfa_document_datamerger_imp.cpp", "xfa/fxfa/parser/xfa_document_datamerger_imp.h", - "xfa/fxfa/parser/xfa_document_imp.cpp", "xfa/fxfa/parser/xfa_document_serialize.cpp", "xfa/fxfa/parser/xfa_document_serialize.h", "xfa/fxfa/parser/xfa_layout_appadapter.cpp", diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 294839152e..6ca1704fc6 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -21,7 +21,7 @@ #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffwidget.h" #include "xfa/fxfa/include/xfa_fontmgr.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_document_serialize.h" namespace { diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/xfa_ffnotify.h index 322caa3652..07e5419842 100644 --- a/xfa/fxfa/app/xfa_ffnotify.h +++ b/xfa/fxfa/app/xfa_ffnotify.h @@ -8,7 +8,7 @@ #define XFA_FXFA_APP_XFA_FFNOTIFY_H_ #include "xfa/fxfa/include/cxfa_eventparam.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" class CXFA_FFWidgetHandler; diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 357fd7e3fe..4afcb32e6f 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -15,8 +15,8 @@ #include "xfa/fgas/localization/fgas_locale.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/fm2js/xfa_program.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localevalue.h" namespace { diff --git a/xfa/fxfa/include/xfa_ffdoc.h b/xfa/fxfa/include/xfa_ffdoc.h index 0f32c4300c..ddbc0049f1 100644 --- a/xfa/fxfa/include/xfa_ffdoc.h +++ b/xfa/fxfa/include/xfa_ffdoc.h @@ -11,8 +11,8 @@ #include <memory> #include "xfa/fxfa/include/fxfa.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_document_parser.h" -#include "xfa/fxfa/parser/xfa_document.h" class CXFA_ChecksumContext; class CXFA_FFApp; diff --git a/xfa/fxfa/include/xfa_ffwidgethandler.h b/xfa/fxfa/include/xfa_ffwidgethandler.h index 1cd28ce2f0..40447f7533 100644 --- a/xfa/fxfa/include/xfa_ffwidgethandler.h +++ b/xfa/fxfa/include/xfa_ffwidgethandler.h @@ -11,7 +11,7 @@ #include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/fxfa.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" class CXFA_FFDocView; enum class FWL_WidgetHit; diff --git a/xfa/fxfa/parser/cscript_datawindow.cpp b/xfa/fxfa/parser/cscript_datawindow.cpp index 9378b2013c..fbf9704aac 100644 --- a/xfa/fxfa/parser/cscript_datawindow.cpp +++ b/xfa/fxfa/parser/cscript_datawindow.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_datawindow.h" #include "fxjs/include/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 16b25862b4..c961164c4d 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -10,8 +10,8 @@ #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/include/cxfa_eventparam.h" #include "xfa/fxfa/include/xfa_ffwidgethandler.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index a6487351e6..4448180436 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -8,9 +8,9 @@ #include "fxjs/include/cfxjse_arguments.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.h b/xfa/fxfa/parser/cscript_hostpseudomodel.h index f07ba956c5..0cfb4f8a19 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.h +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.h @@ -8,7 +8,7 @@ #define XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ #include "fxjs/include/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_object.h" class CScript_HostPseudoModel : public CXFA_Object { diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 227a2074f6..492e8d9db9 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -13,11 +13,11 @@ #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutitem.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.cpp b/xfa/fxfa/parser/cscript_logpseudomodel.cpp index 247a81d26a..96c61a9e0f 100644 --- a/xfa/fxfa/parser/cscript_logpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_logpseudomodel.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_logpseudomodel.h" #include "fxjs/include/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp index 0e7cf65076..071ae39900 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp @@ -8,8 +8,8 @@ #include "fxjs/include/cfxjse_arguments.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 633e2e2209..346690b484 100644 --- a/xfa/fxfa/parser/xfa_document_imp.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -12,15 +12,77 @@ #include "xfa/fxfa/parser/cscript_layoutpseudomodel.h" #include "xfa/fxfa/parser/cscript_logpseudomodel.h" #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_document_parser.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" +namespace { + +void MergeNodeRecurse(CXFA_Document* pDocument, + CXFA_Node* pDestNodeParent, + CXFA_Node* pProtoNode) { + CXFA_Node* pExistingNode = nullptr; + for (CXFA_Node* pFormChild = + pDestNodeParent->GetNodeItem(XFA_NODEITEM_FirstChild); + pFormChild; + pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pFormChild->GetElementType() == pProtoNode->GetElementType() && + pFormChild->GetNameHash() == pProtoNode->GetNameHash() && + pFormChild->IsUnusedNode()) { + pFormChild->ClearFlag(XFA_NodeFlag_UnusedNode); + pExistingNode = pFormChild; + break; + } + } + + if (pExistingNode) { + pExistingNode->SetTemplateNode(pProtoNode); + for (CXFA_Node* pTemplateChild = + pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( + XFA_NODEITEM_NextSibling)) { + MergeNodeRecurse(pDocument, pExistingNode, pTemplateChild); + } + return; + } + CXFA_Node* pNewNode = pProtoNode->Clone(TRUE); + pNewNode->SetTemplateNode(pProtoNode); + pDestNodeParent->InsertChild(pNewNode, nullptr); +} + +void MergeNode(CXFA_Document* pDocument, + CXFA_Node* pDestNode, + CXFA_Node* pProtoNode) { + { + CXFA_NodeIterator sIterator(pDestNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); + } + } + pDestNode->SetTemplateNode(pProtoNode); + for (CXFA_Node* pTemplateChild = + pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); + pTemplateChild; + pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { + MergeNodeRecurse(pDocument, pDestNode, pTemplateChild); + } + { + CXFA_NodeIterator sIterator(pDestNode); + for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; + pNode = sIterator.MoveToNext()) { + pNode->ClearFlag(XFA_NodeFlag_UnusedNode); + } + } +} + +} // namespace + CXFA_Document::CXFA_Document(CXFA_DocumentParser* pParser) : m_pParser(pParser), m_pScriptContext(nullptr), @@ -37,6 +99,7 @@ CXFA_Document::CXFA_Document(CXFA_DocumentParser* pParser) m_dwDocFlags(0) { ASSERT(m_pParser); } + CXFA_Document::~CXFA_Document() { delete m_pRootNode; PurgeNodes(); @@ -64,9 +127,9 @@ void CXFA_Document::ClearLayoutData() { } void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { - if (m_pRootNode) { + if (m_pRootNode) AddPurgeNode(m_pRootNode); - } + m_pRootNode = pNewRoot; RemovePurgeNode(pNewRoot); } @@ -83,28 +146,26 @@ CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { switch (dwNodeNameHash) { case XFA_HASHCODE_Data: { CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); - if (!pDatasetsNode) { + if (!pDatasetsNode) return nullptr; - } + for (CXFA_Node* pDatasetsChild = pDatasetsNode->GetFirstChildByClass(XFA_Element::DataGroup); pDatasetsChild; pDatasetsChild = pDatasetsChild->GetNextSameClassSibling( XFA_Element::DataGroup)) { - if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) { + if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) continue; - } + CFX_WideString wsNamespaceURI; - if (!pDatasetsChild->TryNamespace(wsNamespaceURI)) { + if (!pDatasetsChild->TryNamespace(wsNamespaceURI)) continue; - } + CFX_WideString wsDatasetsURI; - if (!pDatasetsNode->TryNamespace(wsDatasetsURI)) { + if (!pDatasetsNode->TryNamespace(wsDatasetsURI)) continue; - } - if (wsNamespaceURI == wsDatasetsURI) { + if (wsNamespaceURI == wsDatasetsURI) return pDatasetsChild; - } } return nullptr; } @@ -147,6 +208,7 @@ CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { return m_pRootNode->GetFirstChildByName(dwNodeNameHash); } } + CXFA_Node* CXFA_Document::CreateNode(uint32_t dwPacket, XFA_Element eElement) { return CreateNode(XFA_GetPacketByID(dwPacket), eElement); } @@ -184,29 +246,29 @@ void CXFA_Document::PurgeNodes() { } void CXFA_Document::SetFlag(uint32_t dwFlag, FX_BOOL bOn) { - if (bOn) { + if (bOn) m_dwDocFlags |= dwFlag; - } else { + else m_dwDocFlags &= ~dwFlag; - } } + FX_BOOL CXFA_Document::IsInteractive() { - if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) { + if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) return !!(m_dwDocFlags & XFA_DOCFLAG_Interactive); - } + CXFA_Node* pConfig = ToNode(GetXFAObject(XFA_HASHCODE_Config)); - if (!pConfig) { + if (!pConfig) return FALSE; - } + CFX_WideString wsInteractive; CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_Element::Present); - if (!pPresent) { + if (!pPresent) return FALSE; - } + CXFA_Node* pPDF = pPresent->GetFirstChildByClass(XFA_Element::Pdf); - if (!pPDF) { + if (!pPDF) return FALSE; - } + CXFA_Node* pInteractive = pPDF->GetChild(0, XFA_Element::Interactive); if (pInteractive) { m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; @@ -218,6 +280,7 @@ FX_BOOL CXFA_Document::IsInteractive() { } return FALSE; } + CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() { if (!m_pLocalMgr) { CFX_WideString wsLanguage; @@ -227,17 +290,20 @@ CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() { } return m_pLocalMgr; } + CXFA_ScriptContext* CXFA_Document::InitScriptContext(v8::Isolate* pIsolate) { if (!m_pScriptContext) m_pScriptContext = new CXFA_ScriptContext(this); m_pScriptContext->Initialize(pIsolate); return m_pScriptContext; } + CXFA_ScriptContext* CXFA_Document::GetScriptContext() { if (!m_pScriptContext) m_pScriptContext = new CXFA_ScriptContext(this); return m_pScriptContext; } + XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( CFX_WideString& wsTemplateNS) { CFX_WideStringC wsTemplateURIPrefix = @@ -248,98 +314,44 @@ XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( return XFA_VERSION_UNKNOWN; } FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength); - if (nDotPos == (FX_STRSIZE)-1) { + if (nDotPos == (FX_STRSIZE)-1) return XFA_VERSION_UNKNOWN; - } + int8_t iMajor = FXSYS_wtoi( wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength).c_str()); int8_t iMinor = FXSYS_wtoi( wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2) .c_str()); XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor); - if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) { + if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) return XFA_VERSION_UNKNOWN; - } + m_eCurVersionMode = eVersion; return eVersion; } + CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID) { - if (!pRoot || wsID.IsEmpty()) { + if (!pRoot || wsID.IsEmpty()) return nullptr; - } + CXFA_NodeIterator sIterator(pRoot); for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; pNode = sIterator.MoveToNext()) { CFX_WideStringC wsIDVal; if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { - if (wsIDVal == wsID) { + if (wsIDVal == wsID) return pNode; - } } } return nullptr; } -static void XFA_ProtoMerge_MergeNodeRecurse(CXFA_Document* pDocument, - CXFA_Node* pDestNodeParent, - CXFA_Node* pProtoNode) { - CXFA_Node* pExistingNode = nullptr; - for (CXFA_Node* pFormChild = - pDestNodeParent->GetNodeItem(XFA_NODEITEM_FirstChild); - pFormChild; - pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - if (pFormChild->GetElementType() == pProtoNode->GetElementType() && - pFormChild->GetNameHash() == pProtoNode->GetNameHash() && - pFormChild->IsUnusedNode()) { - pFormChild->ClearFlag(XFA_NodeFlag_UnusedNode); - pExistingNode = pFormChild; - break; - } - } - if (pExistingNode) { - pExistingNode->SetTemplateNode(pProtoNode); - for (CXFA_Node* pTemplateChild = - pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( - XFA_NODEITEM_NextSibling)) { - XFA_ProtoMerge_MergeNodeRecurse(pDocument, pExistingNode, pTemplateChild); - } - return; - } - CXFA_Node* pNewNode = pProtoNode->Clone(TRUE); - pNewNode->SetTemplateNode(pProtoNode); - pDestNodeParent->InsertChild(pNewNode, nullptr); -} -static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument, - CXFA_Node* pDestNode, - CXFA_Node* pProtoNode) { - { - CXFA_NodeIterator sIterator(pDestNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); - } - } - pDestNode->SetTemplateNode(pProtoNode); - for (CXFA_Node* pTemplateChild = - pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); - pTemplateChild; - pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { - XFA_ProtoMerge_MergeNodeRecurse(pDocument, pDestNode, pTemplateChild); - } - { - CXFA_NodeIterator sIterator(pDestNode); - for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; - pNode = sIterator.MoveToNext()) { - pNode->ClearFlag(XFA_NodeFlag_UnusedNode); - } - } -} + void CXFA_Document::DoProtoMerge() { CXFA_Node* pTemplateRoot = ToNode(GetXFAObject(XFA_HASHCODE_Template)); - if (!pTemplateRoot) { + if (!pTemplateRoot) return; - } + CFX_MapPtrTemplate<uint32_t, CXFA_Node*> mIDMap; CXFA_NodeSet sUseNodes; CXFA_NodeIterator sIterator(pTemplateRoot); @@ -357,6 +369,7 @@ void CXFA_Document::DoProtoMerge() { sUseNodes.insert(pNode); } } + for (CXFA_Node* pUseHrefNode : sUseNodes) { CFX_WideString wsUseVal; CFX_WideStringC wsURI, wsID, wsSOM; @@ -381,15 +394,15 @@ void CXFA_Document::DoProtoMerge() { } } else if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) { - if (wsUseVal[0] == '#') { + if (wsUseVal[0] == '#') wsID = CFX_WideStringC(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1); - } else { + else wsSOM = CFX_WideStringC(wsUseVal.c_str(), wsUseVal.GetLength()); - } } - if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) { + + if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) continue; - } + CXFA_Node* pProtoNode = nullptr; if (!wsSOM.IsEmpty()) { uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | @@ -406,9 +419,9 @@ void CXFA_Document::DoProtoMerge() { continue; } } - if (!pProtoNode) { + if (!pProtoNode) continue; - } - XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); + + MergeNode(this, pUseHrefNode, pProtoNode); } } diff --git a/xfa/fxfa/parser/xfa_document.h b/xfa/fxfa/parser/cxfa_document.h index fbc027a8d4..8258ab1dad 100644 --- a/xfa/fxfa/parser/xfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_PARSER_XFA_DOCUMENT_H_ -#define XFA_FXFA_PARSER_XFA_DOCUMENT_H_ +#ifndef XFA_FXFA_PARSER_CXFA_DOCUMENT_H_ +#define XFA_FXFA_PARSER_CXFA_DOCUMENT_H_ #include "xfa/fxfa/include/fxfa.h" #include "xfa/fxfa/parser/xfa_localemgr.h" @@ -123,4 +123,4 @@ class CXFA_Document { uint32_t m_dwDocFlags; }; -#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_H_ +#endif // XFA_FXFA_PARSER_CXFA_DOCUMENT_H_ diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index ff54fb3d87..daf5221489 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_document_parser.h" #include "xfa/fxfa/include/fxfa.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify) {} diff --git a/xfa/fxfa/parser/cxfa_layoutitem.h b/xfa/fxfa/parser/cxfa_layoutitem.h index 785272bd86..c8b29811e8 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.h +++ b/xfa/fxfa/parser/cxfa_layoutitem.h @@ -7,7 +7,7 @@ #ifndef XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_ #define XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_ -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" class CXFA_ContainerLayoutItem; class CXFA_ContentLayoutItem; diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp index 7ebe5285e3..89ea0ce5bb 100644 --- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp @@ -6,8 +6,8 @@ #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" #include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 800ada43fb..fd185771aa 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -17,13 +17,13 @@ #include "xfa/fgas/crt/fgas_system.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/include/cxfa_eventparam.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_occur.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/cxfa_simple_parser.h" #include "xfa/fxfa/parser/xfa_basic_data.h" -#include "xfa/fxfa/parser/xfa_document.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp index f5b4c04655..4fc6830a73 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.cpp +++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp @@ -7,8 +7,8 @@ #include "xfa/fxfa/parser/cxfa_nodehelper.h" #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/parser/cxfa_nodelist.cpp b/xfa/fxfa/parser/cxfa_nodelist.cpp index 61e5091c56..86575e6b3f 100644 --- a/xfa/fxfa/parser/cxfa_nodelist.cpp +++ b/xfa/fxfa/parser/cxfa_nodelist.cpp @@ -7,8 +7,8 @@ #include "xfa/fxfa/parser/xfa_object.h" #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) : CXFA_Object(pDocument, diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index fd553dd096..78f39ee6bc 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -9,7 +9,7 @@ #include "core/fxcrt/include/fx_ext.h" #include "fxjs/include/cfxjse_value.h" #include "xfa/fxfa/app/xfa_ffnotify.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" CXFA_Object::CXFA_Object(CXFA_Document* pDocument, XFA_ObjectType objectType, diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp index 578c2dc651..2a281f9c4b 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp @@ -7,9 +7,9 @@ #include "xfa/fxfa/parser/cxfa_resolveprocessor.h" #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_nodehelper.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index 24c3e503ce..e91e350d32 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -12,10 +12,10 @@ #include "fxjs/include/cfxjse_value.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/include/cxfa_eventparam.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_nodehelper.h" #include "xfa/fxfa/parser/cxfa_resolveprocessor.h" #include "xfa/fxfa/parser/xfa_basic_data.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.h b/xfa/fxfa/parser/cxfa_scriptcontext.h index f06279024c..a6737e6125 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.h +++ b/xfa/fxfa/parser/cxfa_scriptcontext.h @@ -14,7 +14,7 @@ #include "fxjs/include/cfxjse_arguments.h" #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" #include "xfa/fxfa/include/cxfa_eventparam.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #define XFA_RESOLVENODE_TagName 0x0002 diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 043c56a270..1a773d621b 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -10,10 +10,10 @@ #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/include/fxfa.h" #include "xfa/fxfa/include/xfa_checksum.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_widetextread.h" #include "xfa/fxfa/parser/cxfa_xml_parser.h" #include "xfa/fxfa/parser/xfa_basic_data.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index ae3fecea2c..07f0ebb04d 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -9,9 +9,9 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fxbarcode/include/BC_Library.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_event.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localevalue.h" #include "xfa/fxfa/parser/xfa_object.h" diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 19b0698662..11a44b917d 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -8,10 +8,10 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fde/xml/fde_xml_imp.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_occur.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index a524c733d2..ae30165a2d 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -8,8 +8,8 @@ #include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_simple_parser.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.cpp b/xfa/fxfa/parser/xfa_layout_appadapter.cpp index 3dc9b5f052..fdf9a27d0b 100644 --- a/xfa/fxfa/parser/xfa_layout_appadapter.cpp +++ b/xfa/fxfa/parser/xfa_layout_appadapter.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/app/xfa_ffnotify.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" #include "xfa/fxfa/parser/xfa_localemgr.h" diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp index 99432d80f5..2a467a54f1 100644 --- a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp +++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp @@ -10,9 +10,9 @@ #include <memory> #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_occur.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" #include "xfa/fxfa/parser/xfa_localemgr.h" diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp index 779e783b9a..914ce6fb36 100644 --- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp @@ -7,11 +7,11 @@ #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" #include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp index 48e0f1eef5..67a9760646 100644 --- a/xfa/fxfa/parser/xfa_locale.cpp +++ b/xfa/fxfa/parser/xfa_locale.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/xfa_locale.h" #include "core/fxcrt/include/fx_xml.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp index 4b80f3e0f4..24f240ddd0 100644 --- a/xfa/fxfa/parser/xfa_localemgr.cpp +++ b/xfa/fxfa/parser/xfa_localemgr.cpp @@ -9,7 +9,7 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_xml.h" #include "core/fxge/include/fx_ge.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_locale.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/xfa_localevalue.cpp b/xfa/fxfa/parser/xfa_localevalue.cpp index 0ec38d523f..0324c569f3 100644 --- a/xfa/fxfa/parser/xfa_localevalue.cpp +++ b/xfa/fxfa/parser/xfa_localevalue.cpp @@ -8,7 +8,7 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fgas/localization/fgas_localeimp.h" -#include "xfa/fxfa/parser/xfa_document.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp index 064ef6c323..da5b68516b 100644 --- a/xfa/fxfa/parser/xfa_utils_imp.cpp +++ b/xfa/fxfa/parser/xfa_utils_imp.cpp @@ -8,9 +8,9 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fde/xml/fde_xml_imp.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/xfa_basic_data.h" -#include "xfa/fxfa/parser/xfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_localevalue.h" #include "xfa/fxfa/parser/xfa_object.h" |