| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 m_Map[key] = UniqueObject(pObj); | 181 m_Map[key] = UniqueObject(pObj); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void CPDF_Dictionary::ConvertToIndirectObjectFor( | 184 void CPDF_Dictionary::ConvertToIndirectObjectFor( |
| 185 const CFX_ByteString& key, | 185 const CFX_ByteString& key, |
| 186 CPDF_IndirectObjectHolder* pHolder) { | 186 CPDF_IndirectObjectHolder* pHolder) { |
| 187 auto it = m_Map.find(key); | 187 auto it = m_Map.find(key); |
| 188 if (it == m_Map.end() || it->second->IsReference()) | 188 if (it == m_Map.end() || it->second->IsReference()) |
| 189 return; | 189 return; |
| 190 | 190 |
| 191 uint32_t objnum = pHolder->AddIndirectObject(it->second.release()); | 191 CPDF_Object* pObj = pHolder->AddIndirectObject(std::move(it->second)); |
| 192 it->second = UniqueReference(new CPDF_Reference(pHolder, objnum)); | 192 it->second = UniqueReference(new CPDF_Reference(pHolder, pObj->GetObjNum())); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) { | 195 void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) { |
| 196 m_Map.erase(key); | 196 m_Map.erase(key); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey, | 199 void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey, |
| 200 const CFX_ByteString& newkey) { | 200 const CFX_ByteString& newkey) { |
| 201 if (oldkey == newkey) | 201 if (oldkey == newkey) |
| 202 return; | 202 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 222 const CFX_ByteString& str) { | 222 const CFX_ByteString& str) { |
| 223 SetFor(key, new CPDF_String(MaybeIntern(str), FALSE)); | 223 SetFor(key, new CPDF_String(MaybeIntern(str), FALSE)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, | 226 void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, |
| 227 CPDF_IndirectObjectHolder* pDoc, | 227 CPDF_IndirectObjectHolder* pDoc, |
| 228 uint32_t objnum) { | 228 uint32_t objnum) { |
| 229 SetFor(key, new CPDF_Reference(pDoc, objnum)); | 229 SetFor(key, new CPDF_Reference(pDoc, objnum)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key, |
| 233 CPDF_IndirectObjectHolder* pDoc, |
| 234 const CPDF_Object* pObj) { |
| 235 SetReferenceFor(key, pDoc, pObj->GetObjNum()); |
| 236 } |
| 237 |
| 232 void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) { | 238 void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) { |
| 233 SetFor(key, new CPDF_Number(f)); | 239 SetFor(key, new CPDF_Number(f)); |
| 234 } | 240 } |
| 235 | 241 |
| 236 void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) { | 242 void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) { |
| 237 SetFor(key, new CPDF_Boolean(bValue)); | 243 SetFor(key, new CPDF_Boolean(bValue)); |
| 238 } | 244 } |
| 239 | 245 |
| 240 void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key, | 246 void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key, |
| 241 const CFX_FloatRect& rect) { | 247 const CFX_FloatRect& rect) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 255 pArray->AddNumber(matrix.c); | 261 pArray->AddNumber(matrix.c); |
| 256 pArray->AddNumber(matrix.d); | 262 pArray->AddNumber(matrix.d); |
| 257 pArray->AddNumber(matrix.e); | 263 pArray->AddNumber(matrix.e); |
| 258 pArray->AddNumber(matrix.f); | 264 pArray->AddNumber(matrix.f); |
| 259 SetFor(key, pArray); | 265 SetFor(key, pArray); |
| 260 } | 266 } |
| 261 | 267 |
| 262 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) { | 268 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) { |
| 263 return m_pPool ? m_pPool->Intern(str) : str; | 269 return m_pPool ? m_pPool->Intern(str) : str; |
| 264 } | 270 } |
| OLD | NEW |