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_dictionary.h" | 7 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 m_Map.erase(it); | 192 m_Map.erase(it); |
193 } | 193 } |
194 | 194 |
195 void CPDF_Dictionary::ConvertToIndirectObjectFor( | 195 void CPDF_Dictionary::ConvertToIndirectObjectFor( |
196 const CFX_ByteString& key, | 196 const CFX_ByteString& key, |
197 CPDF_IndirectObjectHolder* pHolder) { | 197 CPDF_IndirectObjectHolder* pHolder) { |
198 auto it = m_Map.find(key); | 198 auto it = m_Map.find(key); |
199 if (it == m_Map.end() || it->second->IsReference()) | 199 if (it == m_Map.end() || it->second->IsReference()) |
200 return; | 200 return; |
201 | 201 |
202 uint32_t objnum = pHolder->AddIndirectObject(it->second); | 202 CPDF_Object* pObj = |
203 it->second = new CPDF_Reference(pHolder, objnum); | 203 pHolder->AddIndirectObject(pdfium::WrapUnique(it->second)); |
| 204 it->second = new CPDF_Reference(pHolder, pObj->GetObjNum()); |
204 } | 205 } |
205 | 206 |
206 void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) { | 207 void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) { |
207 auto it = m_Map.find(key); | 208 auto it = m_Map.find(key); |
208 if (it == m_Map.end()) | 209 if (it == m_Map.end()) |
209 return; | 210 return; |
210 | 211 |
211 delete it->second; | 212 delete it->second; |
212 m_Map.erase(it); | 213 m_Map.erase(it); |
213 } | 214 } |
(...skipping 30 matching lines...) Expand all Loading... |
244 const CFX_ByteString& str) { | 245 const CFX_ByteString& str) { |
245 SetFor(key, new CPDF_String(MaybeIntern(str), false)); | 246 SetFor(key, new CPDF_String(MaybeIntern(str), false)); |
246 } | 247 } |
247 | 248 |
248 void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, | 249 void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, |
249 CPDF_IndirectObjectHolder* pDoc, | 250 CPDF_IndirectObjectHolder* pDoc, |
250 uint32_t objnum) { | 251 uint32_t objnum) { |
251 SetFor(key, new CPDF_Reference(pDoc, objnum)); | 252 SetFor(key, new CPDF_Reference(pDoc, objnum)); |
252 } | 253 } |
253 | 254 |
| 255 void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, |
| 256 CPDF_IndirectObjectHolder* pDoc, |
| 257 CPDF_Object* pObj) { |
| 258 ASSERT(!pObj->IsInline()); |
| 259 SetFor(key, new CPDF_Reference(pDoc, pObj->GetObjNum())); |
| 260 } |
| 261 |
254 void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) { | 262 void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) { |
255 SetFor(key, new CPDF_Number(f)); | 263 SetFor(key, new CPDF_Number(f)); |
256 } | 264 } |
257 | 265 |
258 void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) { | 266 void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) { |
259 SetFor(key, new CPDF_Boolean(bValue)); | 267 SetFor(key, new CPDF_Boolean(bValue)); |
260 } | 268 } |
261 | 269 |
262 void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key, | 270 void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key, |
263 const CFX_FloatRect& rect) { | 271 const CFX_FloatRect& rect) { |
(...skipping 13 matching lines...) Expand all Loading... |
277 pArray->AddNumber(matrix.c); | 285 pArray->AddNumber(matrix.c); |
278 pArray->AddNumber(matrix.d); | 286 pArray->AddNumber(matrix.d); |
279 pArray->AddNumber(matrix.e); | 287 pArray->AddNumber(matrix.e); |
280 pArray->AddNumber(matrix.f); | 288 pArray->AddNumber(matrix.f); |
281 SetFor(key, pArray); | 289 SetFor(key, pArray); |
282 } | 290 } |
283 | 291 |
284 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) { | 292 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) { |
285 return m_pPool ? m_pPool->Intern(str) : str; | 293 return m_pPool ? m_pPool->Intern(str) : str; |
286 } | 294 } |
OLD | NEW |