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

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

Issue 1414393006: 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 (CPDF_Reference* pReference = ToReference(pContentObj)) { 138 } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) {
139 CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
139 CPDF_Object* pDirectObj = pReference->GetDirect(); 140 CPDF_Object* pDirectObj = pReference->GetDirect();
140 if (pDirectObj) { 141 if (pDirectObj) {
141 if (CPDF_Array* pArray = pDirectObj->AsArray()) { 142 if (CPDF_Array* pArray = pDirectObj->AsArray()) {
142 pContentArray = pArray; 143 pContentArray = pArray;
143 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 144 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
144 pContentArray->InsertAt(0, pRef); 145 pContentArray->InsertAt(0, pRef);
145 pContentArray->AddReference(pDoc, pEndStream); 146 pContentArray->AddReference(pDoc, pEndStream);
146 } else if (pDirectObj->IsStream()) { 147 } else if (pDirectObj->IsStream()) {
147 pContentArray = new CPDF_Array(); 148 pContentArray = new CPDF_Array();
148 pContentArray->AddReference(pDoc, pStream->GetObjNum()); 149 pContentArray->AddReference(pDoc, pStream->GetObjNum());
149 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); 150 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
150 pContentArray->AddReference(pDoc, pEndStream); 151 pContentArray->AddReference(pDoc, pEndStream);
151 pPageDic->SetAtReference("Contents", pDoc, 152 pPageDic->SetAtReference("Contents", pDoc,
152 pDoc->AddIndirectObject(pContentArray)); 153 pDoc->AddIndirectObject(pContentArray));
153 } 154 }
154 } 155 }
155 } 156 }
156 157
157 // Need to transform the patterns as well. 158 // Need to transform the patterns as well.
158 CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources")); 159 CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources"));
159 if (pRes) { 160 if (pRes) {
160 CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern")); 161 CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern"));
161 if (pPattenDict) { 162 if (pPattenDict) {
162 FX_POSITION pos = pPattenDict->GetStartPos(); 163 FX_POSITION pos = pPattenDict->GetStartPos();
163 while (pos) { 164 while (pos) {
164 CPDF_Dictionary* pDict = nullptr; 165 CPDF_Dictionary* pDict = nullptr;
165 CFX_ByteString key; 166 CFX_ByteString key;
166 CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key); 167 CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
167 if (pObj->IsReference()) 168 if (pObj->GetType() == PDFOBJ_REFERENCE)
168 pObj = pObj->GetDirect(); 169 pObj = pObj->GetDirect();
169 170
170 if (pObj->IsDictionary()) 171 if (pObj->IsDictionary())
171 pDict = pObj->AsDictionary(); 172 pDict = pObj->AsDictionary();
172 else if (CPDF_Stream* pStream = pObj->AsStream()) 173 else if (CPDF_Stream* pStream = pObj->AsStream())
173 pDict = pStream->GetDict(); 174 pDict = pStream->GetDict();
174 else 175 else
175 continue; 176 continue;
176 177
177 CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix")); 178 CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 CPDF_Document* pDoc = pPage->m_pDocument; 299 CPDF_Document* pDoc = pPage->m_pDocument;
299 if (!pDoc) 300 if (!pDoc)
300 return; 301 return;
301 pDoc->AddIndirectObject(pStream); 302 pDoc->AddIndirectObject(pStream);
302 303
303 CPDF_Array* pContentArray = nullptr; 304 CPDF_Array* pContentArray = nullptr;
304 if (CPDF_Array* pArray = ToArray(pContentObj)) { 305 if (CPDF_Array* pArray = ToArray(pContentObj)) {
305 pContentArray = pArray; 306 pContentArray = pArray;
306 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 307 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
307 pContentArray->InsertAt(0, pRef); 308 pContentArray->InsertAt(0, pRef);
308 } else if (CPDF_Reference* pReference = ToReference(pContentObj)) { 309 } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) {
310 CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
309 CPDF_Object* pDirectObj = pReference->GetDirect(); 311 CPDF_Object* pDirectObj = pReference->GetDirect();
310 if (pDirectObj) { 312 if (pDirectObj) {
311 if (CPDF_Array* pArray = pDirectObj->AsArray()) { 313 if (CPDF_Array* pArray = pDirectObj->AsArray()) {
312 pContentArray = pArray; 314 pContentArray = pArray;
313 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 315 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
314 pContentArray->InsertAt(0, pRef); 316 pContentArray->InsertAt(0, pRef);
315 } else if (pDirectObj->IsStream()) { 317 } else if (pDirectObj->IsStream()) {
316 pContentArray = new CPDF_Array(); 318 pContentArray = new CPDF_Array();
317 pContentArray->AddReference(pDoc, pStream->GetObjNum()); 319 pContentArray->AddReference(pDoc, pStream->GetObjNum());
318 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); 320 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
319 pPageDic->SetAtReference("Contents", pDoc, 321 pPageDic->SetAtReference("Contents", pDoc,
320 pDoc->AddIndirectObject(pContentArray)); 322 pDoc->AddIndirectObject(pContentArray));
321 } 323 }
322 } 324 }
323 } 325 }
324 } 326 }
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