From 6515cf256ca6dc30b43b34eaf88908aaf4784fd3 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 13 Feb 2018 21:50:44 +0000 Subject: Split CFX_XMLNode::SaveXMLNode apart This CL removes the switch from SaveXMLNode and moves the required code into override methods in the child classes. The method is renamed from SaveXMLNode to just Save. Change-Id: I2011b80525e99635c573b4e0cf977e94f6b7cea6 Reviewed-on: https://pdfium-review.googlesource.com/26590 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/xml/cfx_xmlinstruction.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'core/fxcrt/xml/cfx_xmlinstruction.cpp') diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp index 75a4a2eec6..dabd538b4b 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.cpp +++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp @@ -8,6 +8,7 @@ #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_extension.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -36,3 +37,37 @@ void CFX_XMLInstruction::RemoveData(int32_t index) { if (pdfium::IndexInBounds(m_TargetData, index)) m_TargetData.erase(m_TargetData.begin() + index); } + +void CFX_XMLInstruction::Save( + const RetainPtr& pXMLStream) { + if (GetName().CompareNoCase(L"xml") == 0) { + WideString ws = L"GetCodePage(); + if (wCodePage == FX_CODEPAGE_UTF16LE) + ws += L"UTF-16"; + else if (wCodePage == FX_CODEPAGE_UTF16BE) + ws += L"UTF-16be"; + else + ws += L"UTF-8"; + + ws += L"\"?>"; + pXMLStream->WriteString(ws.AsStringView()); + return; + } + + pXMLStream->WriteString( + WideString::Format(L"WriteString( + AttributeToString(it.first, it.second).AsStringView()); + } + + for (auto target : m_TargetData) { + WideString ws = L" \""; + ws += target; + ws += L"\""; + pXMLStream->WriteString(ws.AsStringView()); + } + + pXMLStream->WriteString(WideStringView(L"?>")); +} -- cgit v1.2.3