summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/xfa/cjx_node.cpp5
-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
4 files changed, 31 insertions, 38 deletions
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index dc4cd30132..44a5a1a42c 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -352,10 +352,7 @@ CJS_Return CJX_Node::saveXML(CFX_V8* runtime,
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);
+ XFA_DataExporter_RegenerateFormFile(GetXFANode(), pMemoryStream, true);
} else {
pElement->Save(pMemoryStream);
}
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(