diff options
author | dsinclair <dsinclair@chromium.org> | 2016-05-18 13:16:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-18 13:16:12 -0700 |
commit | cbfef5772c52fbd3378905a61fc9432da1515433 (patch) | |
tree | be4c25e41d2467609612232a92e598ccd9baa7eb /xfa | |
parent | 1763f62972a3ebf080f645899a8de79b00dbfb23 (diff) | |
download | pdfium-cbfef5772c52fbd3378905a61fc9432da1515433.tar.xz |
Cleanup XFA_HASHCODE usage.
This CL cleans up several uses of XFA_HASHCODE. The defines have been converted
into an enum.
For the SavePackage call the type is now used as the param instead of a string.
The callers pass in the correct type instead of doing an internal conversion.
The GetXFAObject accepting a string was removed as it was unused. The other
variant was changed to accept the XFA_HashCode type instead of uint32_t.
GetPackageData was removed as it is unused.
Review-Url: https://codereview.chromium.org/1989313002
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffdoc.cpp | 29 | ||||
-rw-r--r-- | xfa/fxfa/include/fxfa_basic.h | 60 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffdoc.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datadescription_imp.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_imp.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_serialize.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_script_imp.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_script_resolveprocessor.cpp | 17 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_script_resolveprocessor.h | 4 |
10 files changed, 65 insertions, 70 deletions
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 8621430d3f..f93881564d 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -351,36 +351,23 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, return pDibSource; } -CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { - uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); - CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); - if (!pNode) { - return NULL; - } - CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); - return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) - ? static_cast<CFDE_XMLElement*>(pXMLNode) - : NULL; -} - -FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - CXFA_ChecksumContext* pCSContext) { +bool CXFA_FFDoc::SavePackage(XFA_HashCode code, + IFX_FileWrite* pFile, + CXFA_ChecksumContext* pCSContext) { std::unique_ptr<CXFA_DataExporter> pExport( new CXFA_DataExporter(m_pDocument)); - uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); - CXFA_Node* pNode = packetHash == XFA_HASHCODE_Xfa + CXFA_Node* pNode = code == XFA_HASHCODE_Xfa ? m_pDocument->GetRoot() - : ToNode(m_pDocument->GetXFAObject(packetHash)); + : ToNode(m_pDocument->GetXFAObject(code)); if (!pNode) - return pExport->Export(pFile); + return !!pExport->Export(pFile); CFX_ByteString bsChecksum; if (pCSContext) bsChecksum = pCSContext->GetChecksum(); - return pExport->Export(pFile, pNode, 0, - bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); + return !!pExport->Export( + pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); } FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { diff --git a/xfa/fxfa/include/fxfa_basic.h b/xfa/fxfa/include/fxfa_basic.h index 30b7b6bdfe..f5f52c7a7f 100644 --- a/xfa/fxfa/include/fxfa_basic.h +++ b/xfa/fxfa/include/fxfa_basic.h @@ -11,32 +11,39 @@ #include "xfa/fxjse/include/fxjse.h" class CXFA_Measurement; -#define XFA_HASHCODE_Xfa 0xc56b9ff -#define XFA_HASHCODE_Config 0x4e1e39b6 -#define XFA_HASHCODE_Template 0x803550fc -#define XFA_HASHCODE_Datasets 0x99b95079 -#define XFA_HASHCODE_Data 0xbde9abda -#define XFA_HASHCODE_Form 0xcd309ff4 -#define XFA_HASHCODE_LocaleSet 0x5473b6dc -#define XFA_HASHCODE_ConnectionSet 0xe14c801c -#define XFA_HASHCODE_SourceSet 0x811929d -#define XFA_HASHCODE_Xdc 0xc56afbf -#define XFA_HASHCODE_Pdf 0xb843dba -#define XFA_HASHCODE_Xfdf 0x48d004a8 -#define XFA_HASHCODE_Xmpmeta 0x132a8fbc -#define XFA_HASHCODE_Signature 0x8b036f32 -#define XFA_HASHCODE_Stylesheet 0x6038580a -#define XFA_HASHCODE_XDP 0xc56afcc -#define XFA_HASHCODE_Record 0x5779d65f -#define XFA_HASHCODE_DataWindow 0x83a550d2 -#define XFA_HASHCODE_Host 0xdb075bde -#define XFA_HASHCODE_Log 0x0b1b3d22 -#define XFA_HASHCODE_Event 0x185e41e2 -#define XFA_HASHCODE_Layout 0x7e7e845e -#define XFA_HASHCODE_Occur 0xf7eebe1c -#define XFA_HASHCODE_This 0x2d574d58 -#define XFA_HASHCODE_DataDescription 0x2b5df51e -#define XFA_HASHCODE_Name 0x31b19c1 + +enum XFA_HashCode : uint32_t { + XFA_HASHCODE_None = 0, + + XFA_HASHCODE_Config = 0x4e1e39b6, + XFA_HASHCODE_ConnectionSet = 0xe14c801c, + XFA_HASHCODE_Data = 0xbde9abda, + XFA_HASHCODE_DataDescription = 0x2b5df51e, + XFA_HASHCODE_Datasets = 0x99b95079, + XFA_HASHCODE_DataWindow = 0x83a550d2, + XFA_HASHCODE_Event = 0x185e41e2, + XFA_HASHCODE_Form = 0xcd309ff4, + XFA_HASHCODE_Group = 0xf7f75fcd, + XFA_HASHCODE_Host = 0xdb075bde, + XFA_HASHCODE_Layout = 0x7e7e845e, + XFA_HASHCODE_LocaleSet = 0x5473b6dc, + XFA_HASHCODE_Log = 0x0b1b3d22, + XFA_HASHCODE_Name = 0x31b19c1, + XFA_HASHCODE_Occur = 0xf7eebe1c, + XFA_HASHCODE_Pdf = 0xb843dba, + XFA_HASHCODE_Record = 0x5779d65f, + XFA_HASHCODE_Signature = 0x8b036f32, + XFA_HASHCODE_SourceSet = 0x811929d, + XFA_HASHCODE_Stylesheet = 0x6038580a, + XFA_HASHCODE_Template = 0x803550fc, + XFA_HASHCODE_This = 0x2d574d58, + XFA_HASHCODE_Xdc = 0xc56afbf, + XFA_HASHCODE_XDP = 0xc56afcc, + XFA_HASHCODE_Xfa = 0xc56b9ff, + XFA_HASHCODE_Xfdf = 0x48d004a8, + XFA_HASHCODE_Xmpmeta = 0x132a8fbc +}; + enum XFA_PACKET { XFA_PACKET_USER, XFA_PACKET_SourceSet, @@ -54,6 +61,7 @@ enum XFA_PACKET { XFA_PACKET_Form, XFA_PACKET_ConnectionSet, }; + enum XFA_XDPPACKET { XFA_XDPPACKET_UNKNOWN = 0, XFA_XDPPACKET_Config = 1 << XFA_PACKET_Config, diff --git a/xfa/fxfa/include/xfa_ffdoc.h b/xfa/fxfa/include/xfa_ffdoc.h index 2569b505ff..af1f8d79cf 100644 --- a/xfa/fxfa/include/xfa_ffdoc.h +++ b/xfa/fxfa/include/xfa_ffdoc.h @@ -46,10 +46,10 @@ class CXFA_FFDoc { CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, int32_t& iImageXDpi, int32_t& iImageYDpi); - CFDE_XMLElement* GetPackageData(const CFX_WideStringC& wsPackage); - FX_BOOL SavePackage(const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - CXFA_ChecksumContext* pCSContext = NULL); + + bool SavePackage(XFA_HashCode code, + IFX_FileWrite* pFile, + CXFA_ChecksumContext* pCSContext); FX_BOOL ImportData(IFX_FileRead* pStream, FX_BOOL bXDP = TRUE); protected: diff --git a/xfa/fxfa/parser/xfa_document.h b/xfa/fxfa/parser/xfa_document.h index 86b2a6f62c..5279d3a995 100644 --- a/xfa/fxfa/parser/xfa_document.h +++ b/xfa/fxfa/parser/xfa_document.h @@ -65,8 +65,7 @@ class CXFA_Document { CXFA_DocumentParser* GetParser() const { return m_pParser; } CXFA_FFNotify* GetNotify() const; void SetRoot(CXFA_Node* pNewRoot); - CXFA_Object* GetXFAObject(const CFX_WideStringC& wsNodeName); - CXFA_Object* GetXFAObject(uint32_t wsNodeNameHash); + CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash); void AddPurgeNode(CXFA_Node* pNode); FX_BOOL RemovePurgeNode(CXFA_Node* pNode); void PurgeNodes(); diff --git a/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp index 31cf4119ad..27d89b4146 100644 --- a/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp @@ -13,8 +13,6 @@ #include "xfa/fxfa/parser/xfa_script.h" #include "xfa/fxfa/parser/xfa_utils.h" -#define XFA_HASHCODE_Group 0xf7f75fcd - class CXFA_TraverseStrategy_DDGroup { public: static inline CXFA_Node* GetFirstChild(CXFA_Node* pDDGroupNode) { diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp index 0421683e07..c6f9295dcc 100644 --- a/xfa/fxfa/parser/xfa_document_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_imp.cpp @@ -77,13 +77,12 @@ void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { m_pRootNode = pNewRoot; RemovePurgeNode(pNewRoot); } + CXFA_FFNotify* CXFA_Document::GetNotify() const { return m_pParser->GetNotify(); } -CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { - return GetXFAObject(FX_HashCode_GetW(wsNodeName, false)); -} -CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) { + +CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { switch (dwNodeNameHash) { case XFA_HASHCODE_Data: { CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index ef85d0e266..96c70cb3fc 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -443,7 +443,7 @@ void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode, pStream->WriteString(pURI, FXSYS_wcslen(pURI)); CFX_WideString wsVersionNumber; XFA_DataExporter_RecognizeXFAVersionNumber( - ToNode(pNode->GetDocument()->GetXFAObject(XFA_XDPPACKET_Template)), + ToNode(pNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Template)), wsVersionNumber); if (wsVersionNumber.IsEmpty()) { wsVersionNumber = FX_WSTRC(L"2.8"); diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index 893c5b79ea..b218121165 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -174,7 +174,8 @@ void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, XFA_FM2JS_GlobalPropertyGetter(lpScriptContext->m_hFM2JSContext, hValue); return; } - uint32_t uHashCode = FX_HashCode_GetW(wsPropName.AsStringC(), false); + XFA_HashCode uHashCode = static_cast<XFA_HashCode>( + FX_HashCode_GetW(wsPropName.AsStringC(), false)); if (uHashCode != XFA_HASHCODE_Layout) { CXFA_Object* pObject = lpScriptContext->GetDocument()->GetXFAObject(uHashCode); diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp index fa21a50b3e..138ac66165 100644 --- a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp +++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp @@ -49,7 +49,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) { return XFA_ResolveNodes_NumberSign(rnd); case '*': return XFA_ResolveNodes_Asterisk(rnd); - // TODO(dsinclair@chromium.org): We could probably remove this. + // TODO(dsinclair): We could probably remove this. case '.': return XFA_ResolveNodes_AnyChild(rnd); default: @@ -119,8 +119,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( if (rnd.m_nLevel > 0) { return -1; } - uint32_t dwNameHash = FX_HashCode_GetW( - CFX_WideStringC(wsName.c_str() + 1, iNameLen - 1), false); + XFA_HashCode dwNameHash = static_cast<XFA_HashCode>(FX_HashCode_GetW( + CFX_WideStringC(wsName.c_str() + 1, iNameLen - 1), false)); if (dwNameHash == XFA_HASHCODE_Xfa) { nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); } else { @@ -148,7 +148,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory( rndFind.m_pSC = rnd.m_pSC; rndFind.m_CurNode = datasets; rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1); - rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false); + rndFind.m_uHashName = static_cast<XFA_HashCode>( + FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false)); rndFind.m_nLevel = rnd.m_nLevel + 1; rndFind.m_dwStyles = XFA_RESOLVENODE_Children; rndFind.m_wsCondition = rnd.m_wsCondition; @@ -174,7 +175,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign( rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName; rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes; rndFind.m_wsName = wsName; - rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false); + rndFind.m_uHashName = static_cast<XFA_HashCode>( + FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false)); rndFind.m_wsCondition = wsCondition; rndFind.m_CurNode = curNode; XFA_ResolveNodes_Normal(rndFind); @@ -215,7 +217,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal( int32_t nNum = nodes.GetSize(); uint32_t dwStyles = rnd.m_dwStyles; CFX_WideString& wsName = rnd.m_wsName; - uint32_t uNameHash = rnd.m_uHashName; + XFA_HashCode uNameHash = rnd.m_uHashName; CFX_WideString& wsCondition = rnd.m_wsCondition; CXFA_ResolveNodesData rndFind; rndFind.m_wsName = rnd.m_wsName; @@ -612,7 +614,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter( wsCondition.ReleaseBuffer(nConditionCount); wsCondition.TrimLeft(); wsCondition.TrimRight(); - rnd.m_uHashName = FX_HashCode_GetW(wsName.AsStringC(), false); + rnd.m_uHashName = + static_cast<XFA_HashCode>(FX_HashCode_GetW(wsName.AsStringC(), false)); return nStart; } void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.h b/xfa/fxfa/parser/xfa_script_resolveprocessor.h index b63cced721..9789ffd7b8 100644 --- a/xfa/fxfa/parser/xfa_script_resolveprocessor.h +++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.h @@ -19,7 +19,7 @@ class CXFA_ResolveNodesData { : m_pSC(pSC), m_CurNode(NULL), m_wsName(), - m_uHashName(0), + m_uHashName(XFA_HASHCODE_None), m_wsCondition(), m_nLevel(0), m_Nodes(), @@ -30,7 +30,7 @@ class CXFA_ResolveNodesData { CXFA_ScriptContext* m_pSC; CXFA_Object* m_CurNode; CFX_WideString m_wsName; - uint32_t m_uHashName; + XFA_HashCode m_uHashName; CFX_WideString m_wsCondition; int32_t m_nLevel; CXFA_ObjArray m_Nodes; |