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

Side by Side Diff: fpdfsdk/src/fpdf_transformpage.cpp

Issue 1418923005: Revert "Revert "Add type cast definitions for CPDF_Reference."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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 | « fpdfsdk/src/fpdf_flatten.cpp ('k') | fpdfsdk/src/fpdfppo.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 "../../public/fpdf_transformpage.h" 7 #include "../../public/fpdf_transformpage.h"
8 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
9 9
10 namespace { 10 namespace {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic); 128 CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
129 pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE); 129 pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE);
130 pDoc->AddIndirectObject(pEndStream); 130 pDoc->AddIndirectObject(pEndStream);
131 131
132 CPDF_Array* pContentArray = nullptr; 132 CPDF_Array* pContentArray = nullptr;
133 if (CPDF_Array* pArray = ToArray(pContentObj)) { 133 if (CPDF_Array* pArray = ToArray(pContentObj)) {
134 pContentArray = pArray; 134 pContentArray = pArray;
135 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 135 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
136 pContentArray->InsertAt(0, pRef); 136 pContentArray->InsertAt(0, pRef);
137 pContentArray->AddReference(pDoc, pEndStream); 137 pContentArray->AddReference(pDoc, pEndStream);
138 } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { 138 } else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
139 CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
140 CPDF_Object* pDirectObj = pReference->GetDirect(); 139 CPDF_Object* pDirectObj = pReference->GetDirect();
141 if (pDirectObj) { 140 if (pDirectObj) {
142 if (CPDF_Array* pArray = pDirectObj->AsArray()) { 141 if (CPDF_Array* pArray = pDirectObj->AsArray()) {
143 pContentArray = pArray; 142 pContentArray = pArray;
144 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 143 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
145 pContentArray->InsertAt(0, pRef); 144 pContentArray->InsertAt(0, pRef);
146 pContentArray->AddReference(pDoc, pEndStream); 145 pContentArray->AddReference(pDoc, pEndStream);
147 } else if (pDirectObj->IsStream()) { 146 } else if (pDirectObj->IsStream()) {
148 pContentArray = new CPDF_Array(); 147 pContentArray = new CPDF_Array();
149 pContentArray->AddReference(pDoc, pStream->GetObjNum()); 148 pContentArray->AddReference(pDoc, pStream->GetObjNum());
150 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); 149 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
151 pContentArray->AddReference(pDoc, pEndStream); 150 pContentArray->AddReference(pDoc, pEndStream);
152 pPageDic->SetAtReference("Contents", pDoc, 151 pPageDic->SetAtReference("Contents", pDoc,
153 pDoc->AddIndirectObject(pContentArray)); 152 pDoc->AddIndirectObject(pContentArray));
154 } 153 }
155 } 154 }
156 } 155 }
157 156
158 // Need to transform the patterns as well. 157 // Need to transform the patterns as well.
159 CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources")); 158 CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources"));
160 if (pRes) { 159 if (pRes) {
161 CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern")); 160 CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern"));
162 if (pPattenDict) { 161 if (pPattenDict) {
163 FX_POSITION pos = pPattenDict->GetStartPos(); 162 FX_POSITION pos = pPattenDict->GetStartPos();
164 while (pos) { 163 while (pos) {
165 CPDF_Dictionary* pDict = nullptr; 164 CPDF_Dictionary* pDict = nullptr;
166 CFX_ByteString key; 165 CFX_ByteString key;
167 CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key); 166 CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
168 if (pObj->GetType() == PDFOBJ_REFERENCE) 167 if (pObj->IsReference())
169 pObj = pObj->GetDirect(); 168 pObj = pObj->GetDirect();
170 169
171 if (pObj->IsDictionary()) 170 if (pObj->IsDictionary())
172 pDict = pObj->AsDictionary(); 171 pDict = pObj->AsDictionary();
173 else if (CPDF_Stream* pStream = pObj->AsStream()) 172 else if (CPDF_Stream* pStream = pObj->AsStream())
174 pDict = pStream->GetDict(); 173 pDict = pStream->GetDict();
175 else 174 else
176 continue; 175 continue;
177 176
178 CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix")); 177 CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 CPDF_Document* pDoc = pPage->m_pDocument; 298 CPDF_Document* pDoc = pPage->m_pDocument;
300 if (!pDoc) 299 if (!pDoc)
301 return; 300 return;
302 pDoc->AddIndirectObject(pStream); 301 pDoc->AddIndirectObject(pStream);
303 302
304 CPDF_Array* pContentArray = nullptr; 303 CPDF_Array* pContentArray = nullptr;
305 if (CPDF_Array* pArray = ToArray(pContentObj)) { 304 if (CPDF_Array* pArray = ToArray(pContentObj)) {
306 pContentArray = pArray; 305 pContentArray = pArray;
307 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 306 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
308 pContentArray->InsertAt(0, pRef); 307 pContentArray->InsertAt(0, pRef);
309 } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { 308 } else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
310 CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
311 CPDF_Object* pDirectObj = pReference->GetDirect(); 309 CPDF_Object* pDirectObj = pReference->GetDirect();
312 if (pDirectObj) { 310 if (pDirectObj) {
313 if (CPDF_Array* pArray = pDirectObj->AsArray()) { 311 if (CPDF_Array* pArray = pDirectObj->AsArray()) {
314 pContentArray = pArray; 312 pContentArray = pArray;
315 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 313 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
316 pContentArray->InsertAt(0, pRef); 314 pContentArray->InsertAt(0, pRef);
317 } else if (pDirectObj->IsStream()) { 315 } else if (pDirectObj->IsStream()) {
318 pContentArray = new CPDF_Array(); 316 pContentArray = new CPDF_Array();
319 pContentArray->AddReference(pDoc, pStream->GetObjNum()); 317 pContentArray->AddReference(pDoc, pStream->GetObjNum());
320 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); 318 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
321 pPageDic->SetAtReference("Contents", pDoc, 319 pPageDic->SetAtReference("Contents", pDoc,
322 pDoc->AddIndirectObject(pContentArray)); 320 pDoc->AddIndirectObject(pContentArray));
323 } 321 }
324 } 322 }
325 } 323 }
326 } 324 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_flatten.cpp ('k') | fpdfsdk/src/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698