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_string.h" | 7 #include "core/fpdfapi/parser/cpdf_string.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_String::CPDF_String() : m_bHex(false) {} | 12 CPDF_String::CPDF_String() : m_bHex(false) {} |
13 | 13 |
14 CPDF_String::CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool, | 14 CPDF_String::CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool, |
15 const CFX_ByteString& str, | 15 const CFX_ByteString& str, |
16 bool bHex) | 16 bool bHex) |
17 : m_String(str), m_bHex(bHex) { | 17 : m_String(str), m_bHex(bHex) { |
18 if (pPool) | 18 if (pPool) |
19 m_String = pPool->Intern(m_String); | 19 m_String = pPool->Intern(m_String); |
20 } | 20 } |
21 | 21 |
22 CPDF_String::CPDF_String(const CFX_WideString& str) : m_bHex(false) { | 22 CPDF_String::CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool, |
23 m_String = PDF_EncodeText(str); | 23 const CFX_WideString& str) |
| 24 : m_String(PDF_EncodeText(str)), m_bHex(false) { |
| 25 if (pPool) |
| 26 m_String = pPool->Intern(m_String); |
24 } | 27 } |
25 | 28 |
26 CPDF_String::~CPDF_String() {} | 29 CPDF_String::~CPDF_String() {} |
27 | 30 |
28 CPDF_Object::Type CPDF_String::GetType() const { | 31 CPDF_Object::Type CPDF_String::GetType() const { |
29 return STRING; | 32 return STRING; |
30 } | 33 } |
31 | 34 |
32 std::unique_ptr<CPDF_Object> CPDF_String::Clone() const { | 35 std::unique_ptr<CPDF_Object> CPDF_String::Clone() const { |
33 auto pRet = pdfium::MakeUnique<CPDF_String>(); | 36 auto pRet = pdfium::MakeUnique<CPDF_String>(); |
(...skipping 18 matching lines...) Expand all Loading... |
52 return this; | 55 return this; |
53 } | 56 } |
54 | 57 |
55 const CPDF_String* CPDF_String::AsString() const { | 58 const CPDF_String* CPDF_String::AsString() const { |
56 return this; | 59 return this; |
57 } | 60 } |
58 | 61 |
59 CFX_WideString CPDF_String::GetUnicodeText() const { | 62 CFX_WideString CPDF_String::GetUnicodeText() const { |
60 return PDF_DecodeText(m_String); | 63 return PDF_DecodeText(m_String); |
61 } | 64 } |
OLD | NEW |