OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/parser/cpdf_name.h" | 7 #include "core/fpdfapi/parser/cpdf_name.h" |
8 | 8 |
9 #include "core/fpdfapi/parser/fpdf_parser_decode.h" | 9 #include "core/fpdfapi/parser/fpdf_parser_decode.h" |
10 #include "third_party/base/ptr_util.h" | 10 #include "third_party/base/ptr_util.h" |
11 | 11 |
12 CPDF_Name::CPDF_Name(const CFX_ByteString& str) : m_Name(str) {} | 12 CPDF_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 } |
13 | 18 |
14 CPDF_Name::~CPDF_Name() {} | 19 CPDF_Name::~CPDF_Name() {} |
15 | 20 |
16 CPDF_Object::Type CPDF_Name::GetType() const { | 21 CPDF_Object::Type CPDF_Name::GetType() const { |
17 return NAME; | 22 return NAME; |
18 } | 23 } |
19 | 24 |
20 std::unique_ptr<CPDF_Object> CPDF_Name::Clone() const { | 25 std::unique_ptr<CPDF_Object> CPDF_Name::Clone() const { |
21 return pdfium::MakeUnique<CPDF_Name>(m_Name); | 26 return pdfium::MakeUnique<CPDF_Name>(nullptr, m_Name); |
22 } | 27 } |
23 | 28 |
24 CFX_ByteString CPDF_Name::GetString() const { | 29 CFX_ByteString CPDF_Name::GetString() const { |
25 return m_Name; | 30 return m_Name; |
26 } | 31 } |
27 | 32 |
28 void CPDF_Name::SetString(const CFX_ByteString& str) { | 33 void CPDF_Name::SetString(const CFX_ByteString& str) { |
29 m_Name = str; | 34 m_Name = str; |
30 } | 35 } |
31 | 36 |
32 bool CPDF_Name::IsName() const { | 37 bool CPDF_Name::IsName() const { |
33 return true; | 38 return true; |
34 } | 39 } |
35 | 40 |
36 CPDF_Name* CPDF_Name::AsName() { | 41 CPDF_Name* CPDF_Name::AsName() { |
37 return this; | 42 return this; |
38 } | 43 } |
39 | 44 |
40 const CPDF_Name* CPDF_Name::AsName() const { | 45 const CPDF_Name* CPDF_Name::AsName() const { |
41 return this; | 46 return this; |
42 } | 47 } |
43 | 48 |
44 CFX_WideString CPDF_Name::GetUnicodeText() const { | 49 CFX_WideString CPDF_Name::GetUnicodeText() const { |
45 return PDF_DecodeText(m_Name); | 50 return PDF_DecodeText(m_Name); |
46 } | 51 } |
OLD | NEW |