Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1437)

Unified Diff: xfa/fxfa/parser/cxfa_simple_parser.cpp

Issue 2165993002: Move xfa_basic_imp to cxfa_widetextread. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Review feedback Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_scriptcontext.cpp ('k') | xfa/fxfa/parser/cxfa_stroke.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxfa/parser/cxfa_simple_parser.cpp
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 7f70c81d386dd1db9bf9a18795b522550720cefd..043c56a27043b3e808ebbf602d5b9c99e591f6a3 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)) {
« no previous file with comments | « xfa/fxfa/parser/cxfa_scriptcontext.cpp ('k') | xfa/fxfa/parser/cxfa_stroke.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698