summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-23 20:03:19 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-23 20:03:19 +0000
commita3dd6c390ebc2af63fc0b706a4747315acef02bf (patch)
treedc6986faa242a997abbb01696a9935b829868fea
parent76e202c638e343cb59f255df59580f4d658d2f9c (diff)
downloadpdfium-a3dd6c390ebc2af63fc0b706a4747315acef02bf.tar.xz
Change CFX_XML Save to take a write stream
This CL changes CFX_XML to use an IFX_SeekableWriteStream instead of the more generic IFX_SeekableStream. This is a reland of https://pdfium-review.googlesource.com/c/pdfium/+/30877 without pulling in the XML lifetime changes. Change-Id: I5091da6ad37715fff77f3f22d35ab0105f2bc3d0 Reviewed-on: https://pdfium-review.googlesource.com/31194 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fxcrt/xml/cfx_xmlchardata.cpp3
-rw-r--r--core/fxcrt/xml/cfx_xmlchardata.h2
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.cpp3
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.h2
-rw-r--r--core/fxcrt/xml/cfx_xmlinstruction.cpp3
-rw-r--r--core/fxcrt/xml/cfx_xmlinstruction.h2
-rw-r--r--core/fxcrt/xml/cfx_xmlnode.h2
-rw-r--r--core/fxcrt/xml/cfx_xmltext.cpp2
-rw-r--r--core/fxcrt/xml/cfx_xmltext.h2
9 files changed, 12 insertions, 9 deletions
diff --git a/core/fxcrt/xml/cfx_xmlchardata.cpp b/core/fxcrt/xml/cfx_xmlchardata.cpp
index dec2e4618f..e62a43ac53 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.cpp
+++ b/core/fxcrt/xml/cfx_xmlchardata.cpp
@@ -21,7 +21,8 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLCharData::Clone() {
return pdfium::MakeUnique<CFX_XMLCharData>(GetText());
}
-void CFX_XMLCharData::Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) {
+void CFX_XMLCharData::Save(
+ const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
pXMLStream->WriteString("<![CDATA[");
pXMLStream->WriteString(GetText().UTF8Encode().AsStringView());
pXMLStream->WriteString("]]>");
diff --git a/core/fxcrt/xml/cfx_xmlchardata.h b/core/fxcrt/xml/cfx_xmlchardata.h
index 5b00597955..0cdc348f26 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.h
+++ b/core/fxcrt/xml/cfx_xmlchardata.h
@@ -20,7 +20,7 @@ class CFX_XMLCharData : public CFX_XMLText {
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- void Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) override;
+ void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
};
#endif // CORE_FXCRT_XML_CFX_XMLCHARDATA_H_
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 5e79da63cf..3befb242c9 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -96,7 +96,8 @@ void CFX_XMLElement::SetTextData(const WideString& wsText) {
AppendChild(pdfium::MakeUnique<CFX_XMLText>(wsText));
}
-void CFX_XMLElement::Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) {
+void CFX_XMLElement::Save(
+ const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
ByteString bsNameEncoded = name_.UTF8Encode();
pXMLStream->WriteString("<");
diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h
index c1d9fea3f0..678ba6d996 100644
--- a/core/fxcrt/xml/cfx_xmlelement.h
+++ b/core/fxcrt/xml/cfx_xmlelement.h
@@ -22,7 +22,7 @@ class CFX_XMLElement : public CFX_XMLNode {
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- void Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) override;
+ void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
WideString GetName() const { return name_; }
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp
index 7b844e6808..d0f5cbb68b 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp
@@ -40,7 +40,8 @@ bool CFX_XMLInstruction::IsAcrobat() const {
return name_ == L"acrobat";
}
-void CFX_XMLInstruction::Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) {
+void CFX_XMLInstruction::Save(
+ const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
if (name_.CompareNoCase(L"xml") == 0) {
pXMLStream->WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
return;
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.h b/core/fxcrt/xml/cfx_xmlinstruction.h
index 045610bd8a..3be9d48573 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.h
+++ b/core/fxcrt/xml/cfx_xmlinstruction.h
@@ -21,7 +21,7 @@ class CFX_XMLInstruction : public CFX_XMLNode {
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- void Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) override;
+ void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
bool IsOriginalXFAVersion() const;
bool IsAcrobat() const;
diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h
index 288095403c..c7dfbc8071 100644
--- a/core/fxcrt/xml/cfx_xmlnode.h
+++ b/core/fxcrt/xml/cfx_xmlnode.h
@@ -27,7 +27,7 @@ class CFX_XMLNode {
virtual FX_XMLNODETYPE GetType() const = 0;
virtual std::unique_ptr<CFX_XMLNode> Clone() = 0;
- virtual void Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) = 0;
+ virtual void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) = 0;
CFX_XMLNode* GetRoot();
CFX_XMLNode* GetParent() const { return parent_.Get(); }
diff --git a/core/fxcrt/xml/cfx_xmltext.cpp b/core/fxcrt/xml/cfx_xmltext.cpp
index 9bed941dd4..2c324be1c9 100644
--- a/core/fxcrt/xml/cfx_xmltext.cpp
+++ b/core/fxcrt/xml/cfx_xmltext.cpp
@@ -21,7 +21,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLText::Clone() {
return pdfium::MakeUnique<CFX_XMLText>(m_wsText);
}
-void CFX_XMLText::Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) {
+void CFX_XMLText::Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
pXMLStream->WriteString(
EncodeEntities(GetText()).UTF8Encode().AsStringView());
}
diff --git a/core/fxcrt/xml/cfx_xmltext.h b/core/fxcrt/xml/cfx_xmltext.h
index bbf14be257..cc9c71d01c 100644
--- a/core/fxcrt/xml/cfx_xmltext.h
+++ b/core/fxcrt/xml/cfx_xmltext.h
@@ -20,7 +20,7 @@ class CFX_XMLText : public CFX_XMLNode {
// CFX_XMLNode
FX_XMLNODETYPE GetType() const override;
std::unique_ptr<CFX_XMLNode> Clone() override;
- void Save(const RetainPtr<IFX_SeekableStream>& pXMLStream) override;
+ void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
WideString GetText() const { return m_wsText; }
void SetText(const WideString& wsText) { m_wsText = wsText; }