summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-04-17 18:12:38 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-17 18:12:38 +0000
commitbc069b7a855998ab28f487d2f09152851dddb16a (patch)
treeb50e3713a80177034a3fc7a2c12920c15aeb7056 /xfa/fxfa
parent8b4a3c7ef32b2ffb4874e4cc65b38ee555d8806e (diff)
downloadpdfium-bc069b7a855998ab28f487d2f09152851dddb16a.tar.xz
Use an IFX_SeekableStream for XML saving
This CL converts the CFX_XML Save methods to take an IFX_SeekableStream instead of a CFX_SeekableStreamProxy. Change-Id: I6b3f6acc9f51e73b3c863b965b4dcdcbd25ba949 Reviewed-on: https://pdfium-review.googlesource.com/30850 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp24
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp6
2 files changed, 11 insertions, 19 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 389b9dbacb..1bd81e820a 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -18,30 +18,23 @@ CXFA_DataExporter::CXFA_DataExporter() = default;
CXFA_DataExporter::~CXFA_DataExporter() = default;
-bool CXFA_DataExporter::Export(const RetainPtr<IFX_SeekableStream>& pWrite,
+bool CXFA_DataExporter::Export(const RetainPtr<IFX_SeekableStream>& pStream,
CXFA_Node* pNode) {
- ASSERT(pWrite);
- if (!pWrite)
- return false;
+ ASSERT(pStream);
- auto pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(pWrite, true);
- pStream->SetCodePage(FX_CODEPAGE_UTF8);
- return Export(pStream, pNode);
-}
+ if (!pStream)
+ return false;
-bool CXFA_DataExporter::Export(
- const RetainPtr<CFX_SeekableStreamProxy>& pStream,
- CXFA_Node* pNode) {
if (pNode->IsModelNode()) {
switch (pNode->GetPacketType()) {
case XFA_PacketType::Xdp: {
pStream->WriteString(
- L"<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">");
+ "<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">");
for (CXFA_Node* pChild = pNode->GetFirstChild(); pChild;
pChild = pChild->GetNextSibling()) {
Export(pStream, pChild);
}
- pStream->WriteString(L"</xdp:xdp\n>");
+ pStream->WriteString("</xdp:xdp\n>");
break;
}
case XFA_PacketType::Datasets: {
@@ -57,7 +50,10 @@ bool CXFA_DataExporter::Export(
break;
}
case XFA_PacketType::Form: {
- XFA_DataExporter_RegenerateFormFile(pNode, pStream, false);
+ auto proxy =
+ pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream, false);
+ proxy->SetCodePage(FX_CODEPAGE_UTF8);
+ XFA_DataExporter_RegenerateFormFile(pNode, proxy, false);
break;
}
case XFA_PacketType::Template:
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index ebe087aa64..55baf10229 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -216,11 +216,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
break;
auto pMemStream = pdfium::MakeRetain<CFX_MemoryStream>(true);
- auto pTempStream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(pMemStream, true);
-
- pTempStream->SetCodePage(FX_CODEPAGE_UTF8);
- pRichTextXML->Save(pTempStream);
+ pRichTextXML->Save(pMemStream);
wsChildren += WideString::FromUTF8(
ByteStringView(pMemStream->GetBuffer(), pMemStream->GetSize()));
} else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml &&