1 // Copyright 2016 PDFium Authors. All rights reserved. 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/fpdfapi/parser/cpdf_name.h" 8 9 #include "core/fpdfapi/parser/fpdf_parser_decode.h" 10 #include "third_party/base/ptr_util.h" 11 CPDF_Name(CFX_WeakPtr<CFX_ByteStringPool> pPool,const CFX_ByteString & str)12CPDF_Name::CPDF_Name(CFX_WeakPtr<CFX_ByteStringPool> pPool, 13 const CFX_ByteString& str) 14 : m_Name(str) { 15 if (pPool) 16 m_Name = pPool->Intern(m_Name); 17 } 18 ~CPDF_Name()19CPDF_Name::~CPDF_Name() {} 20 GetType() const21CPDF_Object::Type CPDF_Name::GetType() const { 22 return NAME; 23 } 24 Clone() const25std::unique_ptr<CPDF_Object> CPDF_Name::Clone() const { 26 return pdfium::MakeUnique<CPDF_Name>(nullptr, m_Name); 27 } 28 GetString() const29CFX_ByteString CPDF_Name::GetString() const { 30 return m_Name; 31 } 32 SetString(const CFX_ByteString & str)33void CPDF_Name::SetString(const CFX_ByteString& str) { 34 m_Name = str; 35 } 36 IsName() const37bool CPDF_Name::IsName() const { 38 return true; 39 } 40 AsName()41CPDF_Name* CPDF_Name::AsName() { 42 return this; 43 } 44 AsName() const45const CPDF_Name* CPDF_Name::AsName() const { 46 return this; 47 } 48 GetUnicodeText() const49CFX_WideString CPDF_Name::GetUnicodeText() const { 50 return PDF_DecodeText(m_Name); 51 } 52