Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: core/fpdfapi/parser/cpdf_dictionary.cpp

Issue 2424533003: Revert "Update CPDF_IndirectObjectHolder APIs for unique objects." (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_dictionary.h ('k') | core/fpdfapi/parser/cpdf_document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 CPDF_Object* pObj = pHolder->AddIndirectObject(std::move(it->second)); 191 uint32_t objnum = pHolder->AddIndirectObject(it->second.release());
192 it->second = UniqueReference(new CPDF_Reference(pHolder, pObj->GetObjNum())); 192 it->second = UniqueReference(new CPDF_Reference(pHolder, objnum));
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
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
238 void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) { 232 void CPDF_Dictionary::SetNumberFor(const CFX_ByteString& key, FX_FLOAT f) {
239 SetFor(key, new CPDF_Number(f)); 233 SetFor(key, new CPDF_Number(f));
240 } 234 }
241 235
242 void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) { 236 void CPDF_Dictionary::SetBooleanFor(const CFX_ByteString& key, bool bValue) {
243 SetFor(key, new CPDF_Boolean(bValue)); 237 SetFor(key, new CPDF_Boolean(bValue));
244 } 238 }
245 239
246 void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key, 240 void CPDF_Dictionary::SetRectFor(const CFX_ByteString& key,
247 const CFX_FloatRect& rect) { 241 const CFX_FloatRect& rect) {
(...skipping 13 matching lines...) Expand all
261 pArray->AddNumber(matrix.c); 255 pArray->AddNumber(matrix.c);
262 pArray->AddNumber(matrix.d); 256 pArray->AddNumber(matrix.d);
263 pArray->AddNumber(matrix.e); 257 pArray->AddNumber(matrix.e);
264 pArray->AddNumber(matrix.f); 258 pArray->AddNumber(matrix.f);
265 SetFor(key, pArray); 259 SetFor(key, pArray);
266 } 260 }
267 261
268 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) { 262 CFX_ByteString CPDF_Dictionary::MaybeIntern(const CFX_ByteString& str) {
269 return m_pPool ? m_pPool->Intern(str) : str; 263 return m_pPool ? m_pPool->Intern(str) : str;
270 } 264 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_dictionary.h ('k') | core/fpdfapi/parser/cpdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698