diff options
author | dsinclair <dsinclair@chromium.org> | 2016-07-21 12:01:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-21 12:01:39 -0700 |
commit | 9eb0db1d7f6273de7eb28b0e1490eaf893e3bfb5 (patch) | |
tree | 545c467efb1d21ce95e0bba7ad40a5e27eed7ef9 /xfa/fxfa/parser/cxfa_simple_parser.cpp | |
parent | e283e47aa3e6786dad94392db292e08ce18ccd5e (diff) | |
download | pdfium-9eb0db1d7f6273de7eb28b0e1490eaf893e3bfb5.tar.xz |
Move xfa_basic_imp to cxfa_widetextread.
This Cl splits out the CXFA_WideTextRead class into it's own file. The helper
methods have been moved into xfa_utils.cpp and their pre-declarations into
xfa_utils.h.
Review-Url: https://codereview.chromium.org/2165993002
Diffstat (limited to 'xfa/fxfa/parser/cxfa_simple_parser.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 7f70c81d38..043c56a270 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -6,11 +6,15 @@ #include "xfa/fxfa/parser/cxfa_simple_parser.h" +#include "core/fxcrt/include/fx_ext.h" #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_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 { @@ -224,6 +228,26 @@ void ConvertXMLToPlainText(CFDE_XMLElement* pRootXMLNode, } } +const XFA_PACKETINFO* GetPacketByName(const CFX_WideStringC& wsName) { + if (wsName.IsEmpty()) + return nullptr; + + uint32_t uHash = FX_HashCode_GetW(wsName, false); + int32_t iStart = 0; + int32_t iEnd = g_iXFAPacketCount - 1; + do { + int32_t iMid = (iStart + iEnd) / 2; + const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; + if (uHash == pInfo->uHash) + return pInfo; + if (uHash < pInfo->uHash) + iEnd = iMid - 1; + else + iStart = iMid + 1; + } while (iStart <= iEnd); + return nullptr; +} + } // namespace FX_BOOL XFA_RecognizeRichText(CFDE_XMLElement* pRichTextXMLNode) { @@ -301,10 +325,7 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, CloseParser(); pXMLNode = nullptr; - std::unique_ptr<IFX_Stream> pStream(XFA_CreateWideTextRead(wsXML)); - if (!pStream) - return XFA_PARSESTATUS_StreamErr; - + std::unique_ptr<IFX_Stream> pStream(new CXFA_WideTextRead(wsXML)); m_pXMLDoc.reset(new CFDE_XMLDoc); CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), pStream.get()); @@ -504,7 +525,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( CFX_WideString wsPacketName; pElement->GetLocalTagName(wsPacketName); const XFA_PACKETINFO* pPacketInfo = - XFA_GetPacketByName(wsPacketName.AsStringC()); + GetPacketByName(wsPacketName.AsStringC()); if (pPacketInfo && pPacketInfo->pURI) { if (!MatchNodeName(pElement, pPacketInfo->pName, pPacketInfo->pURI, pPacketInfo->eFlags)) { |