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/fpdf_parser/include/cpdf_dictionary.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" | 9 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 const CFX_ByteStringC& key) const { | 61 const CFX_ByteStringC& key) const { |
62 CPDF_Object* p = GetObjectBy(key); | 62 CPDF_Object* p = GetObjectBy(key); |
63 return p ? p->GetDirect() : nullptr; | 63 return p ? p->GetDirect() : nullptr; |
64 } | 64 } |
65 | 65 |
66 CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key) const { | 66 CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key) const { |
67 CPDF_Object* p = GetObjectBy(key); | 67 CPDF_Object* p = GetObjectBy(key); |
68 return p ? p->GetString() : CFX_ByteString(); | 68 return p ? p->GetString() : CFX_ByteString(); |
69 } | 69 } |
70 | 70 |
71 CFX_ByteStringC CPDF_Dictionary::GetConstStringBy( | |
72 const CFX_ByteStringC& key) const { | |
73 CPDF_Object* p = GetObjectBy(key); | |
74 return p ? p->GetConstString() : CFX_ByteStringC(); | |
75 } | |
76 | |
77 CFX_WideString CPDF_Dictionary::GetUnicodeTextBy( | 71 CFX_WideString CPDF_Dictionary::GetUnicodeTextBy( |
78 const CFX_ByteStringC& key) const { | 72 const CFX_ByteStringC& key) const { |
79 CPDF_Object* p = GetObjectBy(key); | 73 CPDF_Object* p = GetObjectBy(key); |
80 if (CPDF_Reference* pRef = ToReference(p)) | 74 if (CPDF_Reference* pRef = ToReference(p)) |
81 p = pRef->GetDirect(); | 75 p = pRef->GetDirect(); |
82 return p ? p->GetUnicodeText() : CFX_WideString(); | 76 return p ? p->GetUnicodeText() : CFX_WideString(); |
83 } | 77 } |
84 | 78 |
85 CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key, | 79 CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key, |
86 const CFX_ByteStringC& def) const { | 80 const CFX_ByteStringC& def) const { |
87 CPDF_Object* p = GetObjectBy(key); | 81 CPDF_Object* p = GetObjectBy(key); |
88 return p ? p->GetString() : CFX_ByteString(def); | 82 return p ? p->GetString() : CFX_ByteString(def); |
89 } | 83 } |
90 | 84 |
91 CFX_ByteStringC CPDF_Dictionary::GetConstStringBy( | |
92 const CFX_ByteStringC& key, | |
93 const CFX_ByteStringC& def) const { | |
94 CPDF_Object* p = GetObjectBy(key); | |
95 return p ? p->GetConstString() : CFX_ByteStringC(def); | |
96 } | |
97 | |
98 int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key) const { | 85 int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key) const { |
99 CPDF_Object* p = GetObjectBy(key); | 86 CPDF_Object* p = GetObjectBy(key); |
100 return p ? p->GetInteger() : 0; | 87 return p ? p->GetInteger() : 0; |
101 } | 88 } |
102 | 89 |
103 int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key, int def) const { | 90 int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key, int def) const { |
104 CPDF_Object* p = GetObjectBy(key); | 91 CPDF_Object* p = GetObjectBy(key); |
105 return p ? p->GetInteger() : def; | 92 return p ? p->GetInteger() : def; |
106 } | 93 } |
107 | 94 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 const CFX_Matrix& matrix) { | 249 const CFX_Matrix& matrix) { |
263 CPDF_Array* pArray = new CPDF_Array; | 250 CPDF_Array* pArray = new CPDF_Array; |
264 pArray->AddNumber(matrix.a); | 251 pArray->AddNumber(matrix.a); |
265 pArray->AddNumber(matrix.b); | 252 pArray->AddNumber(matrix.b); |
266 pArray->AddNumber(matrix.c); | 253 pArray->AddNumber(matrix.c); |
267 pArray->AddNumber(matrix.d); | 254 pArray->AddNumber(matrix.d); |
268 pArray->AddNumber(matrix.e); | 255 pArray->AddNumber(matrix.e); |
269 pArray->AddNumber(matrix.f); | 256 pArray->AddNumber(matrix.f); |
270 SetAt(key, pArray); | 257 SetAt(key, pArray); |
271 } | 258 } |
OLD | NEW |