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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser_old.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
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_parser.cpp ('k') | core/fpdfapi/fpdf_parser/cfdf_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 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 <limits.h> 9 #include <limits.h>
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 dest_buf, dest_size); 114 dest_buf, dest_size);
115 } 115 }
116 if (decoder == "LZWDecode" || decoder == "LZW") { 116 if (decoder == "LZWDecode" || decoder == "LZW") {
117 return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, 117 return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf,
118 dest_size); 118 dest_size);
119 } 119 }
120 if (decoder == "DCTDecode" || decoder == "DCT") { 120 if (decoder == "DCTDecode" || decoder == "DCT") {
121 CCodec_ScanlineDecoder* pDecoder = 121 CCodec_ScanlineDecoder* pDecoder =
122 CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( 122 CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
123 src_buf, limit, width, height, 0, 123 src_buf, limit, width, height, 0,
124 pParam ? pParam->GetIntegerBy("ColorTransform", 1) : 1); 124 pParam ? pParam->GetIntegerFor("ColorTransform", 1) : 1);
125 return DecodeAllScanlines(pDecoder, dest_buf, dest_size); 125 return DecodeAllScanlines(pDecoder, dest_buf, dest_size);
126 } 126 }
127 if (decoder == "RunLengthDecode" || decoder == "RL") { 127 if (decoder == "RunLengthDecode" || decoder == "RL") {
128 return RunLengthDecode(src_buf, limit, dest_buf, dest_size); 128 return RunLengthDecode(src_buf, limit, dest_buf, dest_size);
129 } 129 }
130 dest_size = 0; 130 dest_size = 0;
131 dest_buf = 0; 131 dest_buf = 0;
132 return (uint32_t)-1; 132 return (uint32_t)-1;
133 } 133 }
134 134
135 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, 135 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
136 CPDF_Dictionary* pDict, 136 CPDF_Dictionary* pDict,
137 CPDF_Object* pCSObj) { 137 CPDF_Object* pCSObj) {
138 if (m_Pos == m_Size) 138 if (m_Pos == m_Size)
139 return nullptr; 139 return nullptr;
140 140
141 if (PDFCharIsWhitespace(m_pBuf[m_Pos])) 141 if (PDFCharIsWhitespace(m_pBuf[m_Pos]))
142 m_Pos++; 142 m_Pos++;
143 143
144 CFX_ByteString Decoder; 144 CFX_ByteString Decoder;
145 CPDF_Dictionary* pParam = nullptr; 145 CPDF_Dictionary* pParam = nullptr;
146 CPDF_Object* pFilter = pDict->GetDirectObjectBy("Filter"); 146 CPDF_Object* pFilter = pDict->GetDirectObjectFor("Filter");
147 if (pFilter) { 147 if (pFilter) {
148 if (CPDF_Array* pArray = pFilter->AsArray()) { 148 if (CPDF_Array* pArray = pFilter->AsArray()) {
149 Decoder = pArray->GetStringAt(0); 149 Decoder = pArray->GetStringAt(0);
150 CPDF_Array* pParams = pDict->GetArrayBy("DecodeParms"); 150 CPDF_Array* pParams = pDict->GetArrayFor("DecodeParms");
151 if (pParams) 151 if (pParams)
152 pParam = pParams->GetDictAt(0); 152 pParam = pParams->GetDictAt(0);
153 } else { 153 } else {
154 Decoder = pFilter->GetString(); 154 Decoder = pFilter->GetString();
155 pParam = pDict->GetDictBy("DecodeParms"); 155 pParam = pDict->GetDictFor("DecodeParms");
156 } 156 }
157 } 157 }
158 uint32_t width = pDict->GetIntegerBy("Width"); 158 uint32_t width = pDict->GetIntegerFor("Width");
159 uint32_t height = pDict->GetIntegerBy("Height"); 159 uint32_t height = pDict->GetIntegerFor("Height");
160 uint32_t OrigSize = 0; 160 uint32_t OrigSize = 0;
161 if (pCSObj) { 161 if (pCSObj) {
162 uint32_t bpc = pDict->GetIntegerBy("BitsPerComponent"); 162 uint32_t bpc = pDict->GetIntegerFor("BitsPerComponent");
163 uint32_t nComponents = 1; 163 uint32_t nComponents = 1;
164 CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj); 164 CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj);
165 if (pCS) { 165 if (pCS) {
166 nComponents = pCS->CountComponents(); 166 nComponents = pCS->CountComponents();
167 pDoc->GetPageData()->ReleaseColorSpace(pCSObj); 167 pDoc->GetPageData()->ReleaseColorSpace(pCSObj);
168 } else { 168 } else {
169 nComponents = 3; 169 nComponents = 3;
170 } 170 }
171 uint32_t pitch = width; 171 uint32_t pitch = width;
172 if (bpc && pitch > INT_MAX / bpc) 172 if (bpc && pitch > INT_MAX / bpc)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 m_Pos = dwPrevPos; 229 m_Pos = dwPrevPos;
230 break; 230 break;
231 } 231 }
232 dwStreamSize += m_Pos - dwPrevPos; 232 dwStreamSize += m_Pos - dwPrevPos;
233 } 233 }
234 m_Pos = dwSavePos; 234 m_Pos = dwSavePos;
235 pData = FX_Alloc(uint8_t, dwStreamSize); 235 pData = FX_Alloc(uint8_t, dwStreamSize);
236 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); 236 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
237 m_Pos += dwStreamSize; 237 m_Pos += dwStreamSize;
238 } 238 }
239 pDict->SetAtInteger("Length", (int)dwStreamSize); 239 pDict->SetIntegerFor("Length", (int)dwStreamSize);
240 return new CPDF_Stream(pData, dwStreamSize, pDict); 240 return new CPDF_Stream(pData, dwStreamSize, pDict);
241 } 241 }
242 242
243 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { 243 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
244 if (m_pLastObj) { 244 if (m_pLastObj) {
245 m_pLastObj->Release(); 245 m_pLastObj->Release();
246 m_pLastObj = nullptr; 246 m_pLastObj = nullptr;
247 } 247 }
248 248
249 m_WordSize = 0; 249 m_WordSize = 0;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)); 362 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
363 CPDF_Object* pObj = ReadNextObject(true, 0); 363 CPDF_Object* pObj = ReadNextObject(true, 0);
364 if (!pObj) { 364 if (!pObj) {
365 pDict->Release(); 365 pDict->Release();
366 return nullptr; 366 return nullptr;
367 } 367 }
368 368
369 if (key.IsEmpty()) 369 if (key.IsEmpty())
370 pObj->Release(); 370 pObj->Release();
371 else 371 else
372 pDict->SetAt(key, pObj); 372 pDict->SetFor(key, pObj);
373 } 373 }
374 return pDict; 374 return pDict;
375 } 375 }
376 376
377 if (first_char == '[') { 377 if (first_char == '[') {
378 if ((!bAllowNestedArray && dwInArrayLevel) || 378 if ((!bAllowNestedArray && dwInArrayLevel) ||
379 dwInArrayLevel > kMaxNestedArrayLevel) { 379 dwInArrayLevel > kMaxNestedArrayLevel) {
380 return nullptr; 380 return nullptr;
381 } 381 }
382 382
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 !pPage->m_pFormDict) { 644 !pPage->m_pFormDict) {
645 m_Status = Done; 645 m_Status = Done;
646 return; 646 return;
647 } 647 }
648 m_pObjectHolder = pPage; 648 m_pObjectHolder = pPage;
649 m_bForm = FALSE; 649 m_bForm = FALSE;
650 m_Status = ToBeContinued; 650 m_Status = ToBeContinued;
651 m_InternalStage = STAGE_GETCONTENT; 651 m_InternalStage = STAGE_GETCONTENT;
652 m_CurrentOffset = 0; 652 m_CurrentOffset = 0;
653 653
654 CPDF_Object* pContent = pPage->m_pFormDict->GetDirectObjectBy("Contents"); 654 CPDF_Object* pContent = pPage->m_pFormDict->GetDirectObjectFor("Contents");
655 if (!pContent) { 655 if (!pContent) {
656 m_Status = Done; 656 m_Status = Done;
657 return; 657 return;
658 } 658 }
659 if (CPDF_Stream* pStream = pContent->AsStream()) { 659 if (CPDF_Stream* pStream = pContent->AsStream()) {
660 m_nStreams = 0; 660 m_nStreams = 0;
661 m_pSingleStream.reset(new CPDF_StreamAcc); 661 m_pSingleStream.reset(new CPDF_StreamAcc);
662 m_pSingleStream->LoadAllData(pStream, FALSE); 662 m_pSingleStream->LoadAllData(pStream, FALSE);
663 } else if (CPDF_Array* pArray = pContent->AsArray()) { 663 } else if (CPDF_Array* pArray = pContent->AsArray()) {
664 m_nStreams = pArray->GetCount(); 664 m_nStreams = pArray->GetCount();
665 if (m_nStreams) 665 if (m_nStreams)
666 m_StreamArray.resize(m_nStreams); 666 m_StreamArray.resize(m_nStreams);
667 else 667 else
668 m_Status = Done; 668 m_Status = Done;
669 } else { 669 } else {
670 m_Status = Done; 670 m_Status = Done;
671 } 671 }
672 } 672 }
673 673
674 void CPDF_ContentParser::Start(CPDF_Form* pForm, 674 void CPDF_ContentParser::Start(CPDF_Form* pForm,
675 CPDF_AllStates* pGraphicStates, 675 CPDF_AllStates* pGraphicStates,
676 const CFX_Matrix* pParentMatrix, 676 const CFX_Matrix* pParentMatrix,
677 CPDF_Type3Char* pType3Char, 677 CPDF_Type3Char* pType3Char,
678 int level) { 678 int level) {
679 m_pType3Char = pType3Char; 679 m_pType3Char = pType3Char;
680 m_pObjectHolder = pForm; 680 m_pObjectHolder = pForm;
681 m_bForm = TRUE; 681 m_bForm = TRUE;
682 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); 682 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix");
683 if (pGraphicStates) { 683 if (pGraphicStates) {
684 form_matrix.Concat(pGraphicStates->m_CTM); 684 form_matrix.Concat(pGraphicStates->m_CTM);
685 } 685 }
686 CPDF_Array* pBBox = pForm->m_pFormDict->GetArrayBy("BBox"); 686 CPDF_Array* pBBox = pForm->m_pFormDict->GetArrayFor("BBox");
687 CFX_FloatRect form_bbox; 687 CFX_FloatRect form_bbox;
688 CPDF_Path ClipPath; 688 CPDF_Path ClipPath;
689 if (pBBox) { 689 if (pBBox) {
690 form_bbox = pBBox->GetRect(); 690 form_bbox = pBBox->GetRect();
691 ClipPath.Emplace(); 691 ClipPath.Emplace();
692 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, 692 ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right,
693 form_bbox.top); 693 form_bbox.top);
694 ClipPath.Transform(&form_matrix); 694 ClipPath.Transform(&form_matrix);
695 if (pParentMatrix) { 695 if (pParentMatrix) {
696 ClipPath.Transform(pParentMatrix); 696 ClipPath.Transform(pParentMatrix);
697 } 697 }
698 form_bbox.Transform(&form_matrix); 698 form_bbox.Transform(&form_matrix);
699 if (pParentMatrix) { 699 if (pParentMatrix) {
700 form_bbox.Transform(pParentMatrix); 700 form_bbox.Transform(pParentMatrix);
701 } 701 }
702 } 702 }
703 CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictBy("Resources"); 703 CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
704 m_pParser.reset(new CPDF_StreamContentParser( 704 m_pParser.reset(new CPDF_StreamContentParser(
705 pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, 705 pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
706 pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level)); 706 pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level));
707 m_pParser->GetCurStates()->m_CTM = form_matrix; 707 m_pParser->GetCurStates()->m_CTM = form_matrix;
708 m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; 708 m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
709 if (ClipPath) { 709 if (ClipPath) {
710 m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, 710 m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING,
711 TRUE); 711 TRUE);
712 } 712 }
713 if (pForm->m_Transparency & PDFTRANS_GROUP) { 713 if (pForm->m_Transparency & PDFTRANS_GROUP) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 752 }
753 m_StreamArray.clear(); 753 m_StreamArray.clear();
754 } else { 754 } else {
755 m_pData = (uint8_t*)m_pSingleStream->GetData(); 755 m_pData = (uint8_t*)m_pSingleStream->GetData();
756 m_Size = m_pSingleStream->GetSize(); 756 m_Size = m_pSingleStream->GetSize();
757 } 757 }
758 m_InternalStage = STAGE_PARSE; 758 m_InternalStage = STAGE_PARSE;
759 m_CurrentOffset = 0; 759 m_CurrentOffset = 0;
760 } else { 760 } else {
761 CPDF_Array* pContent = 761 CPDF_Array* pContent =
762 m_pObjectHolder->m_pFormDict->GetArrayBy("Contents"); 762 m_pObjectHolder->m_pFormDict->GetArrayFor("Contents");
763 m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc); 763 m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc);
764 CPDF_Stream* pStreamObj = ToStream( 764 CPDF_Stream* pStreamObj = ToStream(
765 pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr); 765 pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr);
766 m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, FALSE); 766 m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, FALSE);
767 m_CurrentOffset++; 767 m_CurrentOffset++;
768 } 768 }
769 } 769 }
770 if (m_InternalStage == STAGE_PARSE) { 770 if (m_InternalStage == STAGE_PARSE) {
771 if (!m_pParser) { 771 if (!m_pParser) {
772 m_pParser.reset(new CPDF_StreamContentParser( 772 m_pParser.reset(new CPDF_StreamContentParser(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 817 }
818 m_Status = Done; 818 m_Status = Done;
819 return; 819 return;
820 } 820 }
821 steps++; 821 steps++;
822 if (pPause && pPause->NeedToPauseNow()) { 822 if (pPause && pPause->NeedToPauseNow()) {
823 break; 823 break;
824 } 824 }
825 } 825 }
826 } 826 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_parser.cpp ('k') | core/fpdfapi/fpdf_parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698