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

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

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: s/NULL/nullptr/ Created 4 years, 6 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 <vector> 9 #include <vector>
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CFX_ByteStringC replacement; 75 CFX_ByteStringC replacement;
76 }; 76 };
77 77
78 class CPDF_StreamParserAutoClearer { 78 class CPDF_StreamParserAutoClearer {
79 public: 79 public:
80 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable, 80 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable,
81 CPDF_StreamParser* new_parser) 81 CPDF_StreamParser* new_parser)
82 : scoped_variable_(scoped_variable) { 82 : scoped_variable_(scoped_variable) {
83 *scoped_variable_ = new_parser; 83 *scoped_variable_ = new_parser;
84 } 84 }
85 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; } 85 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = nullptr; }
86 86
87 private: 87 private:
88 CPDF_StreamParser** scoped_variable_; 88 CPDF_StreamParser** scoped_variable_;
89 }; 89 };
90 90
91 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPair* table, 91 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPair* table,
92 size_t count, 92 size_t count,
93 const CFX_ByteStringC& abbr) { 93 const CFX_ByteStringC& abbr) {
94 auto it = std::find_if( 94 auto it = std::find_if(
95 table, table + count, 95 table, table + count,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 if (index == PARAM_BUF_SIZE) { 314 if (index == PARAM_BUF_SIZE) {
315 index = 0; 315 index = 0;
316 } 316 }
317 } 317 }
318 m_ParamStartPos = 0; 318 m_ParamStartPos = 0;
319 m_ParamCount = 0; 319 m_ParamCount = 0;
320 } 320 }
321 321
322 CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) { 322 CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
323 if (index >= m_ParamCount) { 323 if (index >= m_ParamCount) {
324 return NULL; 324 return nullptr;
325 } 325 }
326 int real_index = m_ParamStartPos + m_ParamCount - index - 1; 326 int real_index = m_ParamStartPos + m_ParamCount - index - 1;
327 if (real_index >= PARAM_BUF_SIZE) { 327 if (real_index >= PARAM_BUF_SIZE) {
328 real_index -= PARAM_BUF_SIZE; 328 real_index -= PARAM_BUF_SIZE;
329 } 329 }
330 ContentParam& param = m_ParamBuf[real_index]; 330 ContentParam& param = m_ParamBuf[real_index];
331 if (param.m_Type == ContentParam::NUMBER) { 331 if (param.m_Type == ContentParam::NUMBER) {
332 CPDF_Number* pNumber = param.m_Number.m_bInteger 332 CPDF_Number* pNumber = param.m_Number.m_bInteger
333 ? new CPDF_Number(param.m_Number.m_Integer) 333 ? new CPDF_Number(param.m_Number.m_Integer)
334 : new CPDF_Number(param.m_Number.m_Float); 334 : new CPDF_Number(param.m_Number.m_Float);
335 335
336 param.m_Type = ContentParam::OBJECT; 336 param.m_Type = ContentParam::OBJECT;
337 param.m_pObject = pNumber; 337 param.m_pObject = pNumber;
338 return pNumber; 338 return pNumber;
339 } 339 }
340 if (param.m_Type == ContentParam::NAME) { 340 if (param.m_Type == ContentParam::NAME) {
341 CPDF_Name* pName = new CPDF_Name( 341 CPDF_Name* pName = new CPDF_Name(
342 CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len)); 342 CFX_ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len));
343 param.m_Type = ContentParam::OBJECT; 343 param.m_Type = ContentParam::OBJECT;
344 param.m_pObject = pName; 344 param.m_pObject = pName;
345 return pName; 345 return pName;
346 } 346 }
347 if (param.m_Type == ContentParam::OBJECT) { 347 if (param.m_Type == ContentParam::OBJECT) {
348 return param.m_pObject; 348 return param.m_pObject;
349 } 349 }
350 ASSERT(FALSE); 350 ASSERT(FALSE);
351 return NULL; 351 return nullptr;
352 } 352 }
353 353
354 CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) { 354 CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) {
355 if (index >= m_ParamCount) { 355 if (index >= m_ParamCount) {
356 return CFX_ByteString(); 356 return CFX_ByteString();
357 } 357 }
358 int real_index = m_ParamStartPos + m_ParamCount - index - 1; 358 int real_index = m_ParamStartPos + m_ParamCount - index - 1;
359 if (real_index >= PARAM_BUF_SIZE) { 359 if (real_index >= PARAM_BUF_SIZE) {
360 real_index -= PARAM_BUF_SIZE; 360 real_index -= PARAM_BUF_SIZE;
361 } 361 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 m_pSyntax->ReadNextObject(false, 0)); 605 m_pSyntax->ReadNextObject(false, 0));
606 if (!key.IsEmpty()) { 606 if (!key.IsEmpty()) {
607 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; 607 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
608 if (dwObjNum) 608 if (dwObjNum)
609 pDict->SetAtReference(key, m_pDocument, dwObjNum); 609 pDict->SetAtReference(key, m_pDocument, dwObjNum);
610 else 610 else
611 pDict->SetAt(key, pObj.release()); 611 pDict->SetAt(key, pObj.release());
612 } 612 }
613 } 613 }
614 PDF_ReplaceAbbr(pDict); 614 PDF_ReplaceAbbr(pDict);
615 CPDF_Object* pCSObj = NULL; 615 CPDF_Object* pCSObj = nullptr;
616 if (pDict->KeyExist("ColorSpace")) { 616 if (pDict->KeyExist("ColorSpace")) {
617 pCSObj = pDict->GetDirectObjectBy("ColorSpace"); 617 pCSObj = pDict->GetDirectObjectBy("ColorSpace");
618 if (pCSObj->IsName()) { 618 if (pCSObj->IsName()) {
619 CFX_ByteString name = pCSObj->GetString(); 619 CFX_ByteString name = pCSObj->GetString();
620 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") { 620 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") {
621 pCSObj = FindResourceObj("ColorSpace", name); 621 pCSObj = FindResourceObj("ColorSpace", name);
622 if (pCSObj && !pCSObj->GetObjNum()) { 622 if (pCSObj && !pCSObj->GetObjNum()) {
623 pCSObj = pCSObj->Clone(); 623 pCSObj = pCSObj->Clone();
624 pDict->SetAt("ColorSpace", pCSObj); 624 pDict->SetAt("ColorSpace", pCSObj);
625 } 625 }
626 } 626 }
627 } 627 }
628 } 628 }
629 CPDF_Stream* pStream = 629 CPDF_Stream* pStream =
630 m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj); 630 m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj);
631 while (1) { 631 while (1) {
632 CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); 632 CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
633 if (type == CPDF_StreamParser::EndOfData) { 633 if (type == CPDF_StreamParser::EndOfData) {
634 break; 634 break;
635 } 635 }
636 if (type != CPDF_StreamParser::Keyword) { 636 if (type != CPDF_StreamParser::Keyword) {
637 continue; 637 continue;
638 } 638 }
639 if (m_pSyntax->GetWordSize() == 2 && m_pSyntax->GetWordBuf()[0] == 'E' && 639 if (m_pSyntax->GetWordSize() == 2 && m_pSyntax->GetWordBuf()[0] == 'E' &&
640 m_pSyntax->GetWordBuf()[1] == 'I') { 640 m_pSyntax->GetWordBuf()[1] == 'I') {
641 break; 641 break;
642 } 642 }
643 } 643 }
644 pDict->SetAtName("Subtype", "Image"); 644 pDict->SetAtName("Subtype", "Image");
645 CPDF_ImageObject* pImgObj = AddImage(pStream, NULL, TRUE); 645 CPDF_ImageObject* pImgObj = AddImage(pStream, nullptr, TRUE);
646 if (!pImgObj) { 646 if (!pImgObj) {
647 if (pStream) { 647 if (pStream) {
648 pStream->Release(); 648 pStream->Release();
649 } else { 649 } else {
650 pDict->Release(); 650 pDict->Release();
651 } 651 }
652 } 652 }
653 } 653 }
654 654
655 void CPDF_StreamContentParser::Handle_BeginMarkedContent() { 655 void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
656 CFX_ByteString tag = GetString(0); 656 CFX_ByteString tag = GetString(0);
657 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); 657 m_CurContentMark.GetModify()->AddMark(tag, nullptr, FALSE);
658 } 658 }
659 659
660 void CPDF_StreamContentParser::Handle_BeginText() { 660 void CPDF_StreamContentParser::Handle_BeginText() {
661 m_pCurStates->m_TextMatrix.Set(1.0f, 0, 0, 1.0f, 0, 0); 661 m_pCurStates->m_TextMatrix.Set(1.0f, 0, 0, 1.0f, 0, 0);
662 OnChangeTextMatrix(); 662 OnChangeTextMatrix();
663 m_pCurStates->m_TextX = 0; 663 m_pCurStates->m_TextX = 0;
664 m_pCurStates->m_TextY = 0; 664 m_pCurStates->m_TextY = 0;
665 m_pCurStates->m_TextLineX = 0; 665 m_pCurStates->m_TextLineX = 0;
666 m_pCurStates->m_TextLineY = 0; 666 m_pCurStates->m_TextLineY = 0;
667 } 667 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 if (!pXObject) { 731 if (!pXObject) {
732 m_bResourceMissing = TRUE; 732 m_bResourceMissing = TRUE;
733 return; 733 return;
734 } 734 }
735 735
736 CFX_ByteString type; 736 CFX_ByteString type;
737 if (pXObject->GetDict()) 737 if (pXObject->GetDict())
738 type = pXObject->GetDict()->GetStringBy("Subtype"); 738 type = pXObject->GetDict()->GetStringBy("Subtype");
739 739
740 if (type == "Image") { 740 if (type == "Image") {
741 CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); 741 CPDF_ImageObject* pObj = AddImage(pXObject, nullptr, FALSE);
742 m_LastImageName = name; 742 m_LastImageName = name;
743 m_pLastImage = pObj->m_pImage; 743 m_pLastImage = pObj->m_pImage;
744 if (!m_pObjectHolder->HasImageMask()) 744 if (!m_pObjectHolder->HasImageMask())
745 m_pObjectHolder->SetHasImageMask(m_pLastImage->IsMask()); 745 m_pObjectHolder->SetHasImageMask(m_pLastImage->IsMask());
746 } else if (type == "Form") { 746 } else if (type == "Form") {
747 AddForm(pXObject); 747 AddForm(pXObject);
748 } 748 }
749 } 749 }
750 750
751 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { 751 void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
(...skipping 14 matching lines...) Expand all
766 } 766 }
767 pFormObj->CalcBoundingBox(); 767 pFormObj->CalcBoundingBox();
768 SetGraphicStates(pFormObj.get(), TRUE, TRUE, TRUE); 768 SetGraphicStates(pFormObj.get(), TRUE, TRUE, TRUE);
769 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj)); 769 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj));
770 } 770 }
771 771
772 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, 772 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream,
773 CPDF_Image* pImage, 773 CPDF_Image* pImage,
774 FX_BOOL bInline) { 774 FX_BOOL bInline) {
775 if (!pStream && !pImage) { 775 if (!pStream && !pImage) {
776 return NULL; 776 return nullptr;
777 } 777 }
778 CFX_Matrix ImageMatrix; 778 CFX_Matrix ImageMatrix;
779 ImageMatrix.Copy(m_pCurStates->m_CTM); 779 ImageMatrix.Copy(m_pCurStates->m_CTM);
780 ImageMatrix.Concat(m_mtContentToUser); 780 ImageMatrix.Concat(m_mtContentToUser);
781 781
782 std::unique_ptr<CPDF_ImageObject> pImageObj(new CPDF_ImageObject); 782 std::unique_ptr<CPDF_ImageObject> pImageObj(new CPDF_ImageObject);
783 if (pImage) { 783 if (pImage) {
784 pImageObj->m_pImage = 784 pImageObj->m_pImage =
785 m_pDocument->GetPageData()->GetImage(pImage->GetStream()); 785 m_pDocument->GetPageData()->GetImage(pImage->GetStream());
786 } else if (pStream->GetObjNum()) { 786 } else if (pStream->GetObjNum()) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1003
1004 void CPDF_StreamContentParser::Handle_SetColor_Fill() { 1004 void CPDF_StreamContentParser::Handle_SetColor_Fill() {
1005 FX_FLOAT values[4]; 1005 FX_FLOAT values[4];
1006 int nargs = m_ParamCount; 1006 int nargs = m_ParamCount;
1007 if (nargs > 4) { 1007 if (nargs > 4) {
1008 nargs = 4; 1008 nargs = 4;
1009 } 1009 }
1010 for (int i = 0; i < nargs; i++) { 1010 for (int i = 0; i < nargs; i++) {
1011 values[i] = GetNumber(nargs - i - 1); 1011 values[i] = GetNumber(nargs - i - 1);
1012 } 1012 }
1013 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nargs); 1013 m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nargs);
1014 } 1014 }
1015 1015
1016 void CPDF_StreamContentParser::Handle_SetColor_Stroke() { 1016 void CPDF_StreamContentParser::Handle_SetColor_Stroke() {
1017 FX_FLOAT values[4]; 1017 FX_FLOAT values[4];
1018 int nargs = m_ParamCount; 1018 int nargs = m_ParamCount;
1019 if (nargs > 4) { 1019 if (nargs > 4) {
1020 nargs = 4; 1020 nargs = 4;
1021 } 1021 }
1022 for (int i = 0; i < nargs; i++) { 1022 for (int i = 0; i < nargs; i++) {
1023 values[i] = GetNumber(nargs - i - 1); 1023 values[i] = GetNumber(nargs - i - 1);
1024 } 1024 }
1025 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nargs); 1025 m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nargs);
1026 } 1026 }
1027 1027
1028 void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { 1028 void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
1029 CPDF_Object* pLastParam = GetObject(0); 1029 CPDF_Object* pLastParam = GetObject(0);
1030 if (!pLastParam) { 1030 if (!pLastParam) {
1031 return; 1031 return;
1032 } 1032 }
1033 uint32_t nargs = m_ParamCount; 1033 uint32_t nargs = m_ParamCount;
1034 uint32_t nvalues = nargs; 1034 uint32_t nvalues = nargs;
1035 if (pLastParam->IsName()) 1035 if (pLastParam->IsName())
1036 nvalues--; 1036 nvalues--;
1037 FX_FLOAT* values = NULL; 1037 FX_FLOAT* values = nullptr;
1038 if (nvalues) { 1038 if (nvalues) {
1039 values = FX_Alloc(FX_FLOAT, nvalues); 1039 values = FX_Alloc(FX_FLOAT, nvalues);
1040 for (uint32_t i = 0; i < nvalues; i++) { 1040 for (uint32_t i = 0; i < nvalues; i++) {
1041 values[i] = GetNumber(nargs - i - 1); 1041 values[i] = GetNumber(nargs - i - 1);
1042 } 1042 }
1043 } 1043 }
1044 if (nvalues != nargs) { 1044 if (nvalues != nargs) {
1045 CPDF_Pattern* pPattern = FindPattern(GetString(0), false); 1045 CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
1046 if (pPattern) { 1046 if (pPattern) {
1047 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues); 1047 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
1048 } 1048 }
1049 } else { 1049 } else {
1050 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); 1050 m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nvalues);
1051 } 1051 }
1052 FX_Free(values); 1052 FX_Free(values);
1053 } 1053 }
1054 1054
1055 void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { 1055 void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
1056 CPDF_Object* pLastParam = GetObject(0); 1056 CPDF_Object* pLastParam = GetObject(0);
1057 if (!pLastParam) { 1057 if (!pLastParam) {
1058 return; 1058 return;
1059 } 1059 }
1060 int nargs = m_ParamCount; 1060 int nargs = m_ParamCount;
1061 int nvalues = nargs; 1061 int nvalues = nargs;
1062 if (pLastParam->IsName()) 1062 if (pLastParam->IsName())
1063 nvalues--; 1063 nvalues--;
1064 1064
1065 FX_FLOAT* values = NULL; 1065 FX_FLOAT* values = nullptr;
1066 if (nvalues) { 1066 if (nvalues) {
1067 values = FX_Alloc(FX_FLOAT, nvalues); 1067 values = FX_Alloc(FX_FLOAT, nvalues);
1068 for (int i = 0; i < nvalues; i++) { 1068 for (int i = 0; i < nvalues; i++) {
1069 values[i] = GetNumber(nargs - i - 1); 1069 values[i] = GetNumber(nargs - i - 1);
1070 } 1070 }
1071 } 1071 }
1072 if (nvalues != nargs) { 1072 if (nvalues != nargs) {
1073 CPDF_Pattern* pPattern = FindPattern(GetString(0), false); 1073 CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
1074 if (pPattern) { 1074 if (pPattern) {
1075 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues); 1075 m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues);
1076 } 1076 }
1077 } else { 1077 } else {
1078 m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues); 1078 m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nvalues);
1079 } 1079 }
1080 FX_Free(values); 1080 FX_Free(values);
1081 } 1081 }
1082 1082
1083 void CPDF_StreamContentParser::Handle_ShadeFill() { 1083 void CPDF_StreamContentParser::Handle_ShadeFill() {
1084 CPDF_Pattern* pPattern = FindPattern(GetString(0), true); 1084 CPDF_Pattern* pPattern = FindPattern(GetString(0), true);
1085 if (!pPattern) 1085 if (!pPattern)
1086 return; 1086 return;
1087 1087
1088 CPDF_ShadingPattern* pShading = pPattern->AsShadingPattern(); 1088 CPDF_ShadingPattern* pShading = pPattern->AsShadingPattern();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 CPDF_Font* pFont = FindFont(GetString(1)); 1133 CPDF_Font* pFont = FindFont(GetString(1));
1134 if (pFont) { 1134 if (pFont) {
1135 m_pCurStates->m_TextState.SetFont(pFont); 1135 m_pCurStates->m_TextState.SetFont(pFont);
1136 } 1136 }
1137 } 1137 }
1138 1138
1139 CPDF_Object* CPDF_StreamContentParser::FindResourceObj( 1139 CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
1140 const CFX_ByteString& type, 1140 const CFX_ByteString& type,
1141 const CFX_ByteString& name) { 1141 const CFX_ByteString& name) {
1142 if (!m_pResources) { 1142 if (!m_pResources) {
1143 return NULL; 1143 return nullptr;
1144 } 1144 }
1145 if (m_pResources == m_pPageResources) { 1145 if (m_pResources == m_pPageResources) {
1146 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); 1146 CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
1147 if (!pList) { 1147 if (!pList) {
1148 return NULL; 1148 return nullptr;
1149 } 1149 }
1150 CPDF_Object* pRes = pList->GetDirectObjectBy(name); 1150 CPDF_Object* pRes = pList->GetDirectObjectBy(name);
1151 return pRes; 1151 return pRes;
1152 } 1152 }
1153 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); 1153 CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
1154 if (!pList) { 1154 if (!pList) {
1155 if (!m_pPageResources) { 1155 if (!m_pPageResources) {
1156 return NULL; 1156 return nullptr;
1157 } 1157 }
1158 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); 1158 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type);
1159 if (!pList) { 1159 if (!pList) {
1160 return NULL; 1160 return nullptr;
1161 } 1161 }
1162 CPDF_Object* pRes = pList->GetDirectObjectBy(name); 1162 CPDF_Object* pRes = pList->GetDirectObjectBy(name);
1163 return pRes; 1163 return pRes;
1164 } 1164 }
1165 CPDF_Object* pRes = pList->GetDirectObjectBy(name); 1165 CPDF_Object* pRes = pList->GetDirectObjectBy(name);
1166 return pRes; 1166 return pRes;
1167 } 1167 }
1168 1168
1169 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { 1169 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
1170 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); 1170 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
(...skipping 26 matching lines...) Expand all
1197 if (name == "DeviceRGB") { 1197 if (name == "DeviceRGB") {
1198 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); 1198 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
1199 } 1199 }
1200 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); 1200 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
1201 } 1201 }
1202 return m_pDocument->LoadColorSpace(pDefObj); 1202 return m_pDocument->LoadColorSpace(pDefObj);
1203 } 1203 }
1204 CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name); 1204 CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
1205 if (!pCSObj) { 1205 if (!pCSObj) {
1206 m_bResourceMissing = TRUE; 1206 m_bResourceMissing = TRUE;
1207 return NULL; 1207 return nullptr;
1208 } 1208 }
1209 return m_pDocument->LoadColorSpace(pCSObj); 1209 return m_pDocument->LoadColorSpace(pCSObj);
1210 } 1210 }
1211 1211
1212 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, 1212 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
1213 bool bShading) { 1213 bool bShading) {
1214 CPDF_Object* pPattern = 1214 CPDF_Object* pPattern =
1215 FindResourceObj(bShading ? "Shading" : "Pattern", name); 1215 FindResourceObj(bShading ? "Shading" : "Pattern", name);
1216 if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) { 1216 if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) {
1217 m_bResourceMissing = TRUE; 1217 m_bResourceMissing = TRUE;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1000; 1292 1000;
1293 } 1293 }
1294 } 1294 }
1295 } 1295 }
1296 1296
1297 void CPDF_StreamContentParser::Handle_ShowText() { 1297 void CPDF_StreamContentParser::Handle_ShowText() {
1298 CFX_ByteString str = GetString(0); 1298 CFX_ByteString str = GetString(0);
1299 if (str.IsEmpty()) { 1299 if (str.IsEmpty()) {
1300 return; 1300 return;
1301 } 1301 }
1302 AddTextObject(&str, 0, NULL, 1); 1302 AddTextObject(&str, 0, nullptr, 1);
1303 } 1303 }
1304 1304
1305 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 1305 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
1306 CPDF_Array* pArray = ToArray(GetObject(0)); 1306 CPDF_Array* pArray = ToArray(GetObject(0));
1307 if (!pArray) 1307 if (!pArray)
1308 return; 1308 return;
1309 1309
1310 size_t n = pArray->GetCount(); 1310 size_t n = pArray->GetCount();
1311 size_t nsegs = 0; 1311 size_t nsegs = 0;
1312 for (size_t i = 0; i < n; i++) { 1312 for (size_t i = 0; i < n; i++) {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 } else { 1696 } else {
1697 PDF_ReplaceAbbr(pElement); 1697 PDF_ReplaceAbbr(pElement);
1698 } 1698 }
1699 } 1699 }
1700 break; 1700 break;
1701 } 1701 }
1702 default: 1702 default:
1703 break; 1703 break;
1704 } 1704 }
1705 } 1705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698