summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-18 15:25:58 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-18 20:32:11 +0000
commitfdf7d4092a5fa9c79bbb4a626a4d3d087053ae2c (patch)
treea05497438a59e21948e63a88d4d557909659054a /xfa/fxfa/parser
parent152bfe0f60763263e8bf7292762885eb2aec9b85 (diff)
downloadpdfium-fdf7d4092a5fa9c79bbb4a626a4d3d087053ae2c.tar.xz
Remove IFGAS_Stream::CreateWideStringReadStream
This Cl removes the wide string read stream and passes through a memory stream as needed. The callers were updated to pass the correct types. Change-Id: I8e2660859a85e38ed1c3f4c596ef7c8242762084 Reviewed-on: https://pdfium-review.googlesource.com/4172 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h4
3 files changed, 15 insertions, 27 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index d29df39e8e..90e93fbda5 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -996,8 +996,8 @@ void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
resoveNodeRS.pScriptAttribute;
if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) {
- std::unique_ptr<CFXJSE_Value> pValue(
- new CFXJSE_Value(pScriptContext->GetRuntime()));
+ auto pValue =
+ pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
(resoveNodeRS.objects.front()->*(lpAttributeInfo->lpfnCallback))(
pValue.get(), false, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
pArguments->GetReturnValue()->Assign(pValue.get());
@@ -1271,25 +1271,21 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
ThrowParamCountMismatchException(L"loadXML");
return;
}
- CFX_WideString wsExpression;
+
bool bIgnoreRoot = true;
bool bOverwrite = 0;
- wsExpression =
- CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
+ CFX_ByteString wsExpression = pArguments->GetUTF8String(0);
if (wsExpression.IsEmpty())
return;
if (iLength >= 2)
bIgnoreRoot = !!pArguments->GetInt32(1);
if (iLength >= 3)
bOverwrite = !!pArguments->GetInt32(2);
- std::unique_ptr<CXFA_SimpleParser> pParser(
- new CXFA_SimpleParser(m_pDocument, false));
+ auto pParser = pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument, false);
if (!pParser)
return;
- CFDE_XMLNode* pXMLNode = nullptr;
- int32_t iParserStatus =
- pParser->ParseXMLData(wsExpression, pXMLNode, nullptr);
- if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode)
+ CFDE_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression, nullptr);
+ if (!pXMLNode)
return;
if (bIgnoreRoot &&
(pXMLNode->GetType() != FDE_XMLNODE_Element ||
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 806e5445a0..1ebed10b4d 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -317,30 +317,24 @@ int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) {
return XFA_PARSESTATUS_Done;
}
-int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML,
- CFDE_XMLNode*& pXMLNode,
- IFX_Pause* pPause) {
+CFDE_XMLNode* CXFA_SimpleParser::ParseXMLData(const CFX_ByteString& wsXML,
+ IFX_Pause* pPause) {
CloseParser();
- pXMLNode = nullptr;
m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>();
+
CFX_RetainPtr<IFGAS_Stream> pStream =
- IFGAS_Stream::CreateWideStringReadStream(wsXML);
+ IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
+ const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength()));
auto pParser =
pdfium::MakeUnique<CFDE_XMLParser>(m_pXMLDoc->GetRoot(), pStream);
pParser->m_dwCheckStatus = 0x03;
if (!m_pXMLDoc->LoadXML(std::move(pParser)))
- return XFA_PARSESTATUS_StatusErr;
+ return nullptr;
int32_t iRet = m_pXMLDoc->DoLoad(pPause);
if (iRet < 0 || iRet >= 100)
m_pXMLDoc->CloseXML();
- if (iRet < 0)
- return XFA_PARSESTATUS_SyntaxErr;
- if (iRet < 100)
- return iRet / 2;
-
- pXMLNode = GetDocumentNode(m_pXMLDoc.get());
- return XFA_PARSESTATUS_Done;
+ return iRet < 100 ? nullptr : GetDocumentNode(m_pXMLDoc.get());
}
void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index ccb258a7d4..7671e8d740 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -29,9 +29,7 @@ class CXFA_SimpleParser {
int32_t StartParse(const CFX_RetainPtr<IFX_SeekableStream>& pStream,
XFA_XDPPACKET ePacketID);
int32_t DoParse(IFX_Pause* pPause);
- int32_t ParseXMLData(const CFX_WideString& wsXML,
- CFDE_XMLNode*& pXMLNode,
- IFX_Pause* pPause);
+ CFDE_XMLNode* ParseXMLData(const CFX_ByteString& wsXML, IFX_Pause* pPause);
void ConstructXFANode(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLNode);
CXFA_Node* GetRootNode() const;
CFDE_XMLDoc* GetXMLDoc() const;