xref: /aosp_15_r20/external/pdfium/core/fxcrt/xml/cfx_xmltext.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2017 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "core/fxcrt/xml/cfx_xmltext.h"
8 
9 #include "core/fxcrt/xml/cfx_xmldocument.h"
10 
CFX_XMLText(const WideString & wsText)11 CFX_XMLText::CFX_XMLText(const WideString& wsText) : text_(wsText) {}
12 
13 CFX_XMLText::~CFX_XMLText() = default;
14 
GetType() const15 CFX_XMLNode::Type CFX_XMLText::GetType() const {
16   return Type::kText;
17 }
18 
Clone(CFX_XMLDocument * doc)19 CFX_XMLNode* CFX_XMLText::Clone(CFX_XMLDocument* doc) {
20   return doc->CreateNode<CFX_XMLText>(text_);
21 }
22 
Save(const RetainPtr<IFX_RetainableWriteStream> & pXMLStream)23 void CFX_XMLText::Save(const RetainPtr<IFX_RetainableWriteStream>& pXMLStream) {
24   pXMLStream->WriteString(GetText().EncodeEntities().ToUTF8().AsStringView());
25 }
26