summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp31
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.h5
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.h3
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h3
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h5
9 files changed, 45 insertions, 29 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index f97e8a34ed..9760261baf 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -197,17 +197,20 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
if (!pRichTextXML)
break;
- IFX_MemoryStream* pMemStream = IFX_MemoryStream::Create(true);
+ CFX_RetainPtr<IFX_MemoryStream> pMemStream =
+ IFX_MemoryStream::Create(true);
+
+ // Note: ambiguous without cast below.
IFGAS_Stream* pTempStream = IFGAS_Stream::CreateStream(
- (IFX_SeekableWriteStream*)pMemStream, FX_STREAMACCESS_Text |
- FX_STREAMACCESS_Write |
- FX_STREAMACCESS_Append);
+ CFX_RetainPtr<IFX_SeekableWriteStream>(pMemStream),
+ FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
+ FX_STREAMACCESS_Append);
+
pTempStream->SetCodePage(FX_CODEPAGE_UTF8);
pRichTextXML->SaveXMLNode(pTempStream);
wsChildren += CFX_WideString::FromUTF8(
CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize()));
pTempStream->Release();
- pMemStream->Release();
} else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml &&
wsContentType == FX_WSTRC(L"text/xml")) {
CFX_WideString wsRawValue;
@@ -444,18 +447,20 @@ CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument)
ASSERT(m_pDocument);
}
-bool CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite) {
+bool CXFA_DataExporter::Export(
+ const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite) {
return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr);
}
-bool CXFA_DataExporter::Export(IFX_SeekableWriteStream* pWrite,
- CXFA_Node* pNode,
- uint32_t dwFlag,
- const FX_CHAR* pChecksum) {
- if (!pWrite) {
- ASSERT(false);
+bool CXFA_DataExporter::Export(
+ const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite,
+ CXFA_Node* pNode,
+ uint32_t dwFlag,
+ const FX_CHAR* pChecksum) {
+ ASSERT(pWrite);
+ if (!pWrite)
return false;
- }
+
IFGAS_Stream* pStream = IFGAS_Stream::CreateStream(
pWrite,
FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.h b/xfa/fxfa/parser/cxfa_dataexporter.h
index 8496e0d9a6..f3c784a86a 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.h
+++ b/xfa/fxfa/parser/cxfa_dataexporter.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_PARSER_CXFA_DATAEXPORTER_H_
#define XFA_FXFA_PARSER_CXFA_DATAEXPORTER_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_string.h"
class CXFA_Document;
@@ -18,8 +19,8 @@ class CXFA_DataExporter {
public:
explicit CXFA_DataExporter(CXFA_Document* pDocument);
- bool Export(IFX_SeekableWriteStream* pWrite);
- bool Export(IFX_SeekableWriteStream* pWrite,
+ bool Export(const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite);
+ bool Export(const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite,
CXFA_Node* pNode,
uint32_t dwFlag,
const FX_CHAR* pChecksum);
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp
index c0c798dfe6..0199028ecd 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp
@@ -9,6 +9,7 @@
#include <memory>
#include "core/fxcrt/fx_stream.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/fxfa_basic.h"
@@ -21,9 +22,10 @@ CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument)
ASSERT(m_pDocument);
}
-bool CXFA_DataImporter::ImportData(IFX_SeekableReadStream* pDataDocument) {
- std::unique_ptr<CXFA_SimpleParser> pDataDocumentParser(
- new CXFA_SimpleParser(m_pDocument, false));
+bool CXFA_DataImporter::ImportData(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pDataDocument) {
+ auto pDataDocumentParser =
+ pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument, false);
if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) !=
XFA_PARSESTATUS_Ready) {
return false;
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.h b/xfa/fxfa/parser/cxfa_dataimporter.h
index 86e41a8130..bf04b05846 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.h
+++ b/xfa/fxfa/parser/cxfa_dataimporter.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_PARSER_CXFA_DATAIMPORTER_H_
#define XFA_FXFA_PARSER_CXFA_DATAIMPORTER_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_system.h"
class CXFA_Document;
@@ -16,7 +17,7 @@ class CXFA_DataImporter {
public:
explicit CXFA_DataImporter(CXFA_Document* pDocument);
- bool ImportData(IFX_SeekableReadStream* pDataDocument);
+ bool ImportData(const CFX_RetainPtr<IFX_SeekableReadStream>& pDataDocument);
protected:
CXFA_Document* const m_pDocument;
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index fe3cb933aa..1bf327d667 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -15,8 +15,9 @@ CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify)
CXFA_DocumentParser::~CXFA_DocumentParser() {
}
-int32_t CXFA_DocumentParser::StartParse(IFX_SeekableReadStream* pStream,
- XFA_XDPPACKET ePacketID) {
+int32_t CXFA_DocumentParser::StartParse(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ XFA_XDPPACKET ePacketID) {
m_pDocument.reset();
m_nodeParser.CloseParser();
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index 29aeca39bc..617bddf55b 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -23,7 +23,8 @@ class CXFA_DocumentParser {
explicit CXFA_DocumentParser(CXFA_FFNotify* pNotify);
~CXFA_DocumentParser();
- int32_t StartParse(IFX_SeekableReadStream* pStream, XFA_XDPPACKET ePacketID);
+ int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ XFA_XDPPACKET ePacketID);
int32_t DoParse(IFX_Pause* pPause);
CFDE_XMLDoc* GetXMLDoc() const;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 16062f7b6f..5dd6c52717 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1441,13 +1441,16 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
}
XFA_DataExporter_DealWithDataGroupNode(this);
}
- std::unique_ptr<IFX_MemoryStream, ReleaseDeleter<IFX_MemoryStream>>
- pMemoryStream(IFX_MemoryStream::Create(true));
+ CFX_RetainPtr<IFX_MemoryStream> pMemoryStream =
+ IFX_MemoryStream::Create(true);
+
+ // Note: ambiguious below without static_cast.
std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> pStream(
IFGAS_Stream::CreateStream(
- static_cast<IFX_SeekableWriteStream*>(pMemoryStream.get()),
+ CFX_RetainPtr<IFX_SeekableWriteStream>(pMemoryStream),
FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
FX_STREAMACCESS_Append));
+
if (!pStream) {
pArguments->GetReturnValue()->SetString(bsXMLHeader);
return;
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index a9025fa42a..2329e86874 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -277,8 +277,9 @@ void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) {
m_pFactory = pFactory;
}
-int32_t CXFA_SimpleParser::StartParse(IFX_SeekableReadStream* pStream,
- XFA_XDPPACKET ePacketID) {
+int32_t CXFA_SimpleParser::StartParse(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ XFA_XDPPACKET ePacketID) {
CloseParser();
m_pFileRead = pStream;
m_pStream.reset(IFGAS_Stream::CreateStream(
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index fa9fdb3014..559df7124b 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -24,7 +24,8 @@ class CXFA_SimpleParser {
CXFA_SimpleParser(CXFA_Document* pFactory, bool bDocumentParser);
~CXFA_SimpleParser();
- int32_t StartParse(IFX_SeekableReadStream* pStream, XFA_XDPPACKET ePacketID);
+ int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ XFA_XDPPACKET ePacketID);
int32_t DoParse(IFX_Pause* pPause);
int32_t ParseXMLData(const CFX_WideString& wsXML,
CFDE_XMLNode*& pXMLNode,
@@ -78,7 +79,7 @@ class CXFA_SimpleParser {
CXFA_XMLParser* m_pXMLParser;
std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc;
std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> m_pStream;
- IFX_SeekableReadStream* m_pFileRead;
+ CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
CXFA_Document* m_pFactory;
CXFA_Node* m_pRootNode;
XFA_XDPPACKET m_ePacketID;