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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_doc.cpp

Issue 2334323005: Rename dictionary set and get methods (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 continue; 178 continue;
179 179
180 CPDF_Type1Font* pT1Font = pFont->AsType1Font(); 180 CPDF_Type1Font* pT1Font = pFont->AsType1Font();
181 if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) 181 if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding))
182 continue; 182 continue;
183 183
184 return fontData->AddRef(); 184 return fontData->AddRef();
185 } 185 }
186 186
187 CPDF_Dictionary* pDict = new CPDF_Dictionary; 187 CPDF_Dictionary* pDict = new CPDF_Dictionary;
188 pDict->SetAtName("Type", "Font"); 188 pDict->SetNameFor("Type", "Font");
189 pDict->SetAtName("Subtype", "Type1"); 189 pDict->SetNameFor("Subtype", "Type1");
190 pDict->SetAtName("BaseFont", fontName); 190 pDict->SetNameFor("BaseFont", fontName);
191 if (pEncoding) { 191 if (pEncoding) {
192 pDict->SetAt("Encoding", pEncoding->Realize()); 192 pDict->SetFor("Encoding", pEncoding->Realize());
193 } 193 }
194 m_pPDFDoc->AddIndirectObject(pDict); 194 m_pPDFDoc->AddIndirectObject(pDict);
195 CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict); 195 CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict);
196 if (!pFont) { 196 if (!pFont) {
197 return nullptr; 197 return nullptr;
198 } 198 }
199 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont); 199 CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont);
200 m_FontMap[pDict] = fontData; 200 m_FontMap[pDict] = fontData;
201 return fontData->AddRef(); 201 return fontData->AddRef();
202 } 202 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!pCSObj) 234 if (!pCSObj)
235 return nullptr; 235 return nullptr;
236 236
237 if (pdfium::ContainsKey(*pVisited, pCSObj)) 237 if (pdfium::ContainsKey(*pVisited, pCSObj))
238 return nullptr; 238 return nullptr;
239 239
240 if (pCSObj->IsName()) { 240 if (pCSObj->IsName()) {
241 CFX_ByteString name = pCSObj->GetString(); 241 CFX_ByteString name = pCSObj->GetString();
242 CPDF_ColorSpace* pCS = CPDF_ColorSpace::ColorspaceFromName(name); 242 CPDF_ColorSpace* pCS = CPDF_ColorSpace::ColorspaceFromName(name);
243 if (!pCS && pResources) { 243 if (!pCS && pResources) {
244 CPDF_Dictionary* pList = pResources->GetDictBy("ColorSpace"); 244 CPDF_Dictionary* pList = pResources->GetDictFor("ColorSpace");
245 if (pList) { 245 if (pList) {
246 pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj); 246 pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
247 return GetColorSpaceImpl(pList->GetDirectObjectBy(name), nullptr, 247 return GetColorSpaceImpl(pList->GetDirectObjectFor(name), nullptr,
248 pVisited); 248 pVisited);
249 } 249 }
250 } 250 }
251 if (!pCS || !pResources) 251 if (!pCS || !pResources)
252 return pCS; 252 return pCS;
253 253
254 CPDF_Dictionary* pColorSpaces = pResources->GetDictBy("ColorSpace"); 254 CPDF_Dictionary* pColorSpaces = pResources->GetDictFor("ColorSpace");
255 if (!pColorSpaces) 255 if (!pColorSpaces)
256 return pCS; 256 return pCS;
257 257
258 CPDF_Object* pDefaultCS = nullptr; 258 CPDF_Object* pDefaultCS = nullptr;
259 switch (pCS->GetFamily()) { 259 switch (pCS->GetFamily()) {
260 case PDFCS_DEVICERGB: 260 case PDFCS_DEVICERGB:
261 pDefaultCS = pColorSpaces->GetDirectObjectBy("DefaultRGB"); 261 pDefaultCS = pColorSpaces->GetDirectObjectFor("DefaultRGB");
262 break; 262 break;
263 case PDFCS_DEVICEGRAY: 263 case PDFCS_DEVICEGRAY:
264 pDefaultCS = pColorSpaces->GetDirectObjectBy("DefaultGray"); 264 pDefaultCS = pColorSpaces->GetDirectObjectFor("DefaultGray");
265 break; 265 break;
266 case PDFCS_DEVICECMYK: 266 case PDFCS_DEVICECMYK:
267 pDefaultCS = pColorSpaces->GetDirectObjectBy("DefaultCMYK"); 267 pDefaultCS = pColorSpaces->GetDirectObjectFor("DefaultCMYK");
268 break; 268 break;
269 } 269 }
270 if (!pDefaultCS) 270 if (!pDefaultCS)
271 return pCS; 271 return pCS;
272 272
273 pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj); 273 pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
274 return GetColorSpaceImpl(pDefaultCS, nullptr, pVisited); 274 return GetColorSpaceImpl(pDefaultCS, nullptr, pVisited);
275 } 275 }
276 276
277 CPDF_Array* pArray = pCSObj->AsArray(); 277 CPDF_Array* pArray = pCSObj->AsArray();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (ptData->get()) { 350 if (ptData->get()) {
351 return ptData->AddRef(); 351 return ptData->AddRef();
352 } 352 }
353 } 353 }
354 CPDF_Pattern* pPattern = nullptr; 354 CPDF_Pattern* pPattern = nullptr;
355 if (bShading) { 355 if (bShading) {
356 pPattern = new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, TRUE, matrix); 356 pPattern = new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, TRUE, matrix);
357 } else { 357 } else {
358 CPDF_Dictionary* pDict = pPatternObj ? pPatternObj->GetDict() : nullptr; 358 CPDF_Dictionary* pDict = pPatternObj ? pPatternObj->GetDict() : nullptr;
359 if (pDict) { 359 if (pDict) {
360 int type = pDict->GetIntegerBy("PatternType"); 360 int type = pDict->GetIntegerFor("PatternType");
361 if (type == CPDF_Pattern::TILING) { 361 if (type == CPDF_Pattern::TILING) {
362 pPattern = new CPDF_TilingPattern(m_pPDFDoc, pPatternObj, matrix); 362 pPattern = new CPDF_TilingPattern(m_pPDFDoc, pPatternObj, matrix);
363 } else if (type == CPDF_Pattern::SHADING) { 363 } else if (type == CPDF_Pattern::SHADING) {
364 pPattern = 364 pPattern =
365 new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, FALSE, matrix); 365 new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, FALSE, matrix);
366 } 366 }
367 } 367 }
368 } 368 }
369 if (!pPattern) 369 if (!pPattern)
370 return nullptr; 370 return nullptr;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 CPDF_StreamAcc* CPDF_DocPageData::GetFontFileStreamAcc( 485 CPDF_StreamAcc* CPDF_DocPageData::GetFontFileStreamAcc(
486 CPDF_Stream* pFontStream) { 486 CPDF_Stream* pFontStream) {
487 ASSERT(pFontStream); 487 ASSERT(pFontStream);
488 488
489 auto it = m_FontFileMap.find(pFontStream); 489 auto it = m_FontFileMap.find(pFontStream);
490 if (it != m_FontFileMap.end()) 490 if (it != m_FontFileMap.end())
491 return it->second->AddRef(); 491 return it->second->AddRef();
492 492
493 CPDF_Dictionary* pFontDict = pFontStream->GetDict(); 493 CPDF_Dictionary* pFontDict = pFontStream->GetDict();
494 int32_t org_size = pFontDict->GetIntegerBy("Length1") + 494 int32_t org_size = pFontDict->GetIntegerFor("Length1") +
495 pFontDict->GetIntegerBy("Length2") + 495 pFontDict->GetIntegerFor("Length2") +
496 pFontDict->GetIntegerBy("Length3"); 496 pFontDict->GetIntegerFor("Length3");
497 org_size = std::max(org_size, 0); 497 org_size = std::max(org_size, 0);
498 498
499 CPDF_StreamAcc* pFontFile = new CPDF_StreamAcc; 499 CPDF_StreamAcc* pFontFile = new CPDF_StreamAcc;
500 pFontFile->LoadAllData(pFontStream, FALSE, org_size); 500 pFontFile->LoadAllData(pFontStream, FALSE, org_size);
501 501
502 CPDF_CountedStreamAcc* pCountedFont = new CPDF_CountedStreamAcc(pFontFile); 502 CPDF_CountedStreamAcc* pCountedFont = new CPDF_CountedStreamAcc(pFontFile);
503 m_FontFileMap[pFontStream] = pCountedFont; 503 m_FontFileMap[pFontStream] = pCountedFont;
504 return pCountedFont->AddRef(); 504 return pCountedFont->AddRef();
505 } 505 }
506 506
(...skipping 29 matching lines...) Expand all
536 } 536 }
537 537
538 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( 538 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(
539 CPDF_Object* pPatternObj) const { 539 CPDF_Object* pPatternObj) const {
540 if (!pPatternObj) 540 if (!pPatternObj)
541 return nullptr; 541 return nullptr;
542 542
543 auto it = m_PatternMap.find(pPatternObj); 543 auto it = m_PatternMap.find(pPatternObj);
544 return it != m_PatternMap.end() ? it->second : nullptr; 544 return it != m_PatternMap.end() ? it->second : nullptr;
545 } 545 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698