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

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

Issue 1417823005: Add type cast definitions for CPDF_Name. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 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
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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fdrm/fx_crypt.h" 9 #include "../../../include/fdrm/fx_crypt.h"
10 #include "../fpdf_font/font_int.h" 10 #include "../fpdf_font/font_int.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (fontData->get()) { 301 if (fontData->get()) {
302 fontData->RemoveRef(); 302 fontData->RemoveRef();
303 if (fontData->use_count() == 0) { 303 if (fontData->use_count() == 0) {
304 fontData->clear(); 304 fontData->clear();
305 } 305 }
306 } 306 }
307 } 307 }
308 308
309 CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(CPDF_Object* pCSObj, 309 CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(CPDF_Object* pCSObj,
310 CPDF_Dictionary* pResources) { 310 CPDF_Dictionary* pResources) {
311 if (!pCSObj) { 311 if (!pCSObj)
312 return NULL; 312 return nullptr;
313 } 313
314 if (pCSObj->GetType() == PDFOBJ_NAME) { 314 if (pCSObj->IsName()) {
315 CFX_ByteString name = pCSObj->GetConstString(); 315 CFX_ByteString name = pCSObj->GetConstString();
316 CPDF_ColorSpace* pCS = _CSFromName(name); 316 CPDF_ColorSpace* pCS = _CSFromName(name);
317 if (!pCS && pResources) { 317 if (!pCS && pResources) {
318 CPDF_Dictionary* pList = pResources->GetDict(FX_BSTRC("ColorSpace")); 318 CPDF_Dictionary* pList = pResources->GetDict(FX_BSTRC("ColorSpace"));
319 if (pList) { 319 if (pList) {
320 pCSObj = pList->GetElementValue(name); 320 pCSObj = pList->GetElementValue(name);
321 return GetColorSpace(pCSObj, NULL); 321 return GetColorSpace(pCSObj, nullptr);
322 } 322 }
323 } 323 }
324 if (pCS == NULL || pResources == NULL) { 324 if (!pCS || !pResources)
325 return pCS; 325 return pCS;
326 } 326
327 CPDF_Dictionary* pColorSpaces = pResources->GetDict(FX_BSTRC("ColorSpace")); 327 CPDF_Dictionary* pColorSpaces = pResources->GetDict(FX_BSTRC("ColorSpace"));
328 if (pColorSpaces == NULL) { 328 if (!pColorSpaces)
329 return pCS; 329 return pCS;
330 } 330
331 CPDF_Object* pDefaultCS = NULL; 331 CPDF_Object* pDefaultCS = nullptr;
332 switch (pCS->GetFamily()) { 332 switch (pCS->GetFamily()) {
333 case PDFCS_DEVICERGB: 333 case PDFCS_DEVICERGB:
334 pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultRGB")); 334 pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultRGB"));
335 break; 335 break;
336 case PDFCS_DEVICEGRAY: 336 case PDFCS_DEVICEGRAY:
337 pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultGray")); 337 pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultGray"));
338 break; 338 break;
339 case PDFCS_DEVICECMYK: 339 case PDFCS_DEVICECMYK:
340 pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultCMYK")); 340 pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultCMYK"));
341 break; 341 break;
342 } 342 }
343 if (pDefaultCS == NULL) { 343 return pDefaultCS ? GetColorSpace(pDefaultCS, nullptr) : pCS;
344 return pCS;
345 }
346 return GetColorSpace(pDefaultCS, NULL);
347 } 344 }
348 345
349 if (pCSObj->GetType() != PDFOBJ_ARRAY) 346 if (pCSObj->GetType() != PDFOBJ_ARRAY)
350 return nullptr; 347 return nullptr;
351 CPDF_Array* pArray = (CPDF_Array*)pCSObj; 348 CPDF_Array* pArray = (CPDF_Array*)pCSObj;
352 if (pArray->GetCount() == 0) 349 if (pArray->GetCount() == 0)
353 return nullptr; 350 return nullptr;
354 if (pArray->GetCount() == 1) 351 if (pArray->GetCount() == 1)
355 return GetColorSpace(pArray->GetElementValue(0), pResources); 352 return GetColorSpace(pArray->GetElementValue(0), pResources);
356 353
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 598 }
602 599
603 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( 600 CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(
604 CPDF_Object* pPatternObj) const { 601 CPDF_Object* pPatternObj) const {
605 if (!pPatternObj) 602 if (!pPatternObj)
606 return nullptr; 603 return nullptr;
607 604
608 auto it = m_PatternMap.find(pPatternObj); 605 auto it = m_PatternMap.find(pPatternObj);
609 return it != m_PatternMap.end() ? it->second : nullptr; 606 return it != m_PatternMap.end() ? it->second : nullptr;
610 } 607 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698