summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-04-17 18:23:28 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-17 18:23:28 +0000
commitffdae5fceb4e0b37bc649d99d12c15ccd6ae1b9e (patch)
tree3a719c2bf12bf2b16f473db9e739e9de15e5fafe /xfa/fxfa
parentbc069b7a855998ab28f487d2f09152851dddb16a (diff)
downloadpdfium-ffdae5fceb4e0b37bc649d99d12c15ccd6ae1b9e.tar.xz
Use IFX_SeekableStream in xfa_utils
This CL converts xfa_utils to use an IFX_SeekableStream instead of a CFX_SeekableStreamProxy. Change-Id: I824b477351ac29d54118df2f3c5442c503aa3671 Reviewed-on: https://pdfium-review.googlesource.com/30852 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.cpp8
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp52
-rw-r--r--xfa/fxfa/parser/xfa_utils.h4
3 files changed, 30 insertions, 34 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 1bd81e820a..eb3e04afd8 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -49,13 +49,9 @@ bool CXFA_DataExporter::Export(const RetainPtr<IFX_SeekableStream>& pStream,
pElement->Save(pStream);
break;
}
- case XFA_PacketType::Form: {
- auto proxy =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream, false);
- proxy->SetCodePage(FX_CODEPAGE_UTF8);
- XFA_DataExporter_RegenerateFormFile(pNode, proxy, false);
+ case XFA_PacketType::Form:
+ XFA_DataExporter_RegenerateFormFile(pNode, pStream, false);
break;
- }
case XFA_PacketType::Template:
default: {
CFX_XMLElement* pElement =
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 55baf10229..de0f76b6b4 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -29,7 +29,7 @@
namespace {
-constexpr const wchar_t kFormNS[] = L"http://www.xfa.org/schema/xfa-form/";
+constexpr const char kFormNS[] = "http://www.xfa.org/schema/xfa-form/";
const double fraction_scales[] = {0.1,
0.01,
@@ -330,10 +330,9 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
}
}
-void RegenerateFormFile_Container(
- CXFA_Node* pNode,
- const RetainPtr<CFX_SeekableStreamProxy>& pStream,
- bool bSaveXML) {
+void RegenerateFormFile_Container(CXFA_Node* pNode,
+ const RetainPtr<IFX_SeekableStream>& pStream,
+ bool bSaveXML) {
XFA_Element eType = pNode->GetElementType();
if (eType == XFA_Element::Field || eType == XFA_Element::Draw ||
!pNode->IsContainerNode()) {
@@ -341,13 +340,13 @@ void RegenerateFormFile_Container(
RegenerateFormFile_Changed(pNode, buf, bSaveXML);
size_t nLen = buf.GetLength();
if (nLen > 0)
- pStream->WriteString(buf.AsStringView());
+ pStream->WriteString(buf.MakeString().UTF8Encode().AsStringView());
return;
}
- WideStringView wsElement(pNode->GetClassName());
- pStream->WriteString(L"<");
- pStream->WriteString(wsElement);
+ WideString wsElement(pNode->GetClassName());
+ pStream->WriteString("<");
+ pStream->WriteString(wsElement.UTF8Encode().AsStringView());
WideString wsOutput;
SaveAttribute(pNode, XFA_Attribute::Name, L"name", true, wsOutput);
@@ -366,21 +365,22 @@ void RegenerateFormFile_Container(
}
if (!wsOutput.IsEmpty())
- pStream->WriteString(wsOutput.AsStringView());
+ pStream->WriteString(wsOutput.UTF8Encode().AsStringView());
CXFA_Node* pChildNode = pNode->GetFirstChild();
- if (pChildNode) {
- pStream->WriteString(L"\n>");
- while (pChildNode) {
- RegenerateFormFile_Container(pChildNode, pStream, bSaveXML);
- pChildNode = pChildNode->GetNextSibling();
- }
- pStream->WriteString(L"</");
- pStream->WriteString(wsElement);
- pStream->WriteString(L"\n>");
- } else {
- pStream->WriteString(L"\n/>");
+ if (!pChildNode) {
+ pStream->WriteString(" />\n");
+ return;
+ }
+
+ pStream->WriteString(">\n");
+ while (pChildNode) {
+ RegenerateFormFile_Container(pChildNode, pStream, bSaveXML);
+ pChildNode = pChildNode->GetNextSibling();
}
+ pStream->WriteString("</");
+ pStream->WriteString(wsElement.UTF8Encode().AsStringView());
+ pStream->WriteString(">\n");
}
WideString RecognizeXFAVersionNumber(CXFA_Node* pTemplateRoot) {
@@ -515,11 +515,11 @@ void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) {
void XFA_DataExporter_RegenerateFormFile(
CXFA_Node* pNode,
- const RetainPtr<CFX_SeekableStreamProxy>& pStream,
+ const RetainPtr<IFX_SeekableStream>& pStream,
bool bSaveXML) {
if (pNode->IsModelNode()) {
- pStream->WriteString(L"<form xmlns=\"");
- pStream->WriteString(WideStringView(kFormNS));
+ pStream->WriteString("<form xmlns=\"");
+ pStream->WriteString(kFormNS);
WideString wsVersionNumber = RecognizeXFAVersionNumber(
ToNode(pNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Template)));
@@ -527,14 +527,14 @@ void XFA_DataExporter_RegenerateFormFile(
wsVersionNumber = L"2.8";
wsVersionNumber += L"/\"\n>";
- pStream->WriteString(wsVersionNumber.AsStringView());
+ pStream->WriteString(wsVersionNumber.UTF8Encode().AsStringView());
CXFA_Node* pChildNode = pNode->GetFirstChild();
while (pChildNode) {
RegenerateFormFile_Container(pChildNode, pStream, false);
pChildNode = pChildNode->GetNextSibling();
}
- pStream->WriteString(L"</form\n>");
+ pStream->WriteString("</form\n>");
} else {
RegenerateFormFile_Container(pNode, pStream, bSaveXML);
}
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index d78b9ca57c..129dbec0ef 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_UTILS_H_
#define XFA_FXFA_PARSER_XFA_UTILS_H_
-#include "core/fxcrt/cfx_seekablestreamproxy.h"
+#include "core/fxcrt/fx_stream.h"
#include "xfa/fxfa/fxfa_basic.h"
class CFX_XMLElement;
@@ -31,7 +31,7 @@ bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode);
void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode);
void XFA_DataExporter_RegenerateFormFile(
CXFA_Node* pNode,
- const RetainPtr<CFX_SeekableStreamProxy>& pStream,
+ const RetainPtr<IFX_SeekableStream>& pStream,
bool bSaveXML);
const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(