From bc069b7a855998ab28f487d2f09152851dddb16a Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 17 Apr 2018 18:12:38 +0000 Subject: 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 Reviewed-by: Tom Sepez --- fxjs/xfa/cjx_node.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'fxjs/xfa') diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index 125c52ca93..dc4cd30132 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp @@ -332,7 +332,7 @@ CJS_Return CJX_Node::saveXML(CFX_V8* runtime, // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. - WideString bsXMLHeader = L"\n"; + ByteString bsXMLHeader = "\n"; if (GetXFANode()->GetPacketType() != XFA_PacketType::Form && GetXFANode()->GetPacketType() != XFA_PacketType::Datasets) { return CJS_Return(runtime->NewString("")); @@ -342,23 +342,23 @@ CJS_Return CJX_Node::saveXML(CFX_V8* runtime, if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) { pElement = GetXFANode()->GetXMLMappingNode(); if (!pElement || pElement->GetType() != FX_XMLNODE_Element) { - return CJS_Return( - runtime->NewString(bsXMLHeader.UTF8Encode().AsStringView())); + return CJS_Return(runtime->NewString(bsXMLHeader.AsStringView())); } XFA_DataExporter_DealWithDataGroupNode(GetXFANode()); } auto pMemoryStream = pdfium::MakeRetain(true); - auto pStream = - pdfium::MakeRetain(pMemoryStream, true); - pStream->SetCodePage(FX_CODEPAGE_UTF8); - pStream->WriteString(bsXMLHeader.AsStringView()); - - if (GetXFANode()->GetPacketType() == XFA_PacketType::Form) - XFA_DataExporter_RegenerateFormFile(GetXFANode(), pStream, true); - else - pElement->Save(pStream); + pMemoryStream->WriteString(bsXMLHeader.AsStringView()); + + if (GetXFANode()->GetPacketType() == XFA_PacketType::Form) { + auto proxy = + pdfium::MakeRetain(pMemoryStream, true); + proxy->SetCodePage(FX_CODEPAGE_UTF8); + XFA_DataExporter_RegenerateFormFile(GetXFANode(), proxy, true); + } else { + pElement->Save(pMemoryStream); + } return CJS_Return(runtime->NewString( ByteStringView(pMemoryStream->GetBuffer(), pMemoryStream->GetSize()))); -- cgit v1.2.3