From a3dd6c390ebc2af63fc0b706a4747315acef02bf Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 23 Apr 2018 20:03:19 +0000 Subject: 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 Commit-Queue: dsinclair --- core/fxcrt/xml/cfx_xmlchardata.cpp | 3 ++- core/fxcrt/xml/cfx_xmlchardata.h | 2 +- core/fxcrt/xml/cfx_xmlelement.cpp | 3 ++- core/fxcrt/xml/cfx_xmlelement.h | 2 +- core/fxcrt/xml/cfx_xmlinstruction.cpp | 3 ++- core/fxcrt/xml/cfx_xmlinstruction.h | 2 +- core/fxcrt/xml/cfx_xmlnode.h | 2 +- core/fxcrt/xml/cfx_xmltext.cpp | 2 +- core/fxcrt/xml/cfx_xmltext.h | 2 +- 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_XMLCharData::Clone() { return pdfium::MakeUnique(GetText()); } -void CFX_XMLCharData::Save(const RetainPtr& pXMLStream) { +void CFX_XMLCharData::Save( + const RetainPtr& pXMLStream) { pXMLStream->WriteString("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 Clone() override; - void Save(const RetainPtr& pXMLStream) override; + void Save(const RetainPtr& 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(wsText)); } -void CFX_XMLElement::Save(const RetainPtr& pXMLStream) { +void CFX_XMLElement::Save( + const RetainPtr& 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 Clone() override; - void Save(const RetainPtr& pXMLStream) override; + void Save(const RetainPtr& 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& pXMLStream) { +void CFX_XMLInstruction::Save( + const RetainPtr& pXMLStream) { if (name_.CompareNoCase(L"xml") == 0) { pXMLStream->WriteString("\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 Clone() override; - void Save(const RetainPtr& pXMLStream) override; + void Save(const RetainPtr& 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 Clone() = 0; - virtual void Save(const RetainPtr& pXMLStream) = 0; + virtual void Save(const RetainPtr& 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_XMLText::Clone() { return pdfium::MakeUnique(m_wsText); } -void CFX_XMLText::Save(const RetainPtr& pXMLStream) { +void CFX_XMLText::Save(const RetainPtr& 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 Clone() override; - void Save(const RetainPtr& pXMLStream) override; + void Save(const RetainPtr& pXMLStream) override; WideString GetText() const { return m_wsText; } void SetText(const WideString& wsText) { m_wsText = wsText; } -- cgit v1.2.3