summaryrefslogtreecommitdiff
path: root/fxjs/xfa/cjx_node.cpp
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 /fxjs/xfa/cjx_node.cpp
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 'fxjs/xfa/cjx_node.cpp')
-rw-r--r--fxjs/xfa/cjx_node.cpp24
1 files changed, 12 insertions, 12 deletions
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"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ ByteString bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\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<CFX_MemoryStream>(true);
- auto pStream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(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<CFX_SeekableStreamProxy>(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())));