OLD | NEW |
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_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 | 9 |
10 CPDF_Document::CPDF_Document(CPDF_Parser* pParser) | 10 CPDF_Document::CPDF_Document(CPDF_Parser* pParser) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return -1; | 182 return -1; |
183 } | 183 } |
184 FX_DWORD count = pNode->GetInteger(FX_BSTRC("Count")); | 184 FX_DWORD count = pNode->GetInteger(FX_BSTRC("Count")); |
185 if (count <= skip_count) { | 185 if (count <= skip_count) { |
186 skip_count -= count; | 186 skip_count -= count; |
187 index += count; | 187 index += count; |
188 return -1; | 188 return -1; |
189 } | 189 } |
190 if (count && count == pKidList->GetCount()) { | 190 if (count && count == pKidList->GetCount()) { |
191 for (FX_DWORD i = 0; i < count; i++) { | 191 for (FX_DWORD i = 0; i < count; i++) { |
192 CPDF_Object* pKid = pKidList->GetElement(i); | 192 if (CPDF_Reference* pKid = ToReference(pKidList->GetElement(i))) { |
193 if (pKid && pKid->GetType() == PDFOBJ_REFERENCE) { | 193 if (pKid->GetRefObjNum() == objnum) { |
194 if (((CPDF_Reference*)pKid)->GetRefObjNum() == objnum) { | |
195 m_PageList.SetAt(index + i, objnum); | 194 m_PageList.SetAt(index + i, objnum); |
196 return index + i; | 195 return index + i; |
197 } | 196 } |
198 } | 197 } |
199 } | 198 } |
200 } | 199 } |
201 for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) { | 200 for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) { |
202 CPDF_Dictionary* pKid = pKidList->GetDict(i); | 201 CPDF_Dictionary* pKid = pKidList->GetDict(i); |
203 if (pKid == NULL) { | 202 if (pKid == NULL) { |
204 continue; | 203 continue; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 continue; | 299 continue; |
301 } | 300 } |
302 CPDF_Object* pContents = | 301 CPDF_Object* pContents = |
303 pPageDict ? pPageDict->GetElement(FX_BSTRC("Contents")) : NULL; | 302 pPageDict ? pPageDict->GetElement(FX_BSTRC("Contents")) : NULL; |
304 if (pContents == NULL) { | 303 if (pContents == NULL) { |
305 continue; | 304 continue; |
306 } | 305 } |
307 if (pContents->GetDirectType() == PDFOBJ_ARRAY) { | 306 if (pContents->GetDirectType() == PDFOBJ_ARRAY) { |
308 CPDF_Array* pArray = pContents->GetDirect()->AsArray(); | 307 CPDF_Array* pArray = pContents->GetDirect()->AsArray(); |
309 for (FX_DWORD j = 0; j < pArray->GetCount(); j++) { | 308 for (FX_DWORD j = 0; j < pArray->GetCount(); j++) { |
310 CPDF_Object* pRef = pArray->GetElement(j); | 309 CPDF_Reference* pRef = ToReference(pArray->GetElement(j)); |
311 if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { | 310 if (pRef && pRef->GetRefObjNum() == objnum) |
312 continue; | |
313 } | |
314 if (((CPDF_Reference*)pRef)->GetRefObjNum() == objnum) { | |
315 return TRUE; | 311 return TRUE; |
316 } | |
317 } | 312 } |
318 } else if (pContents->GetObjNum() == objnum) { | 313 } else if (pContents->GetObjNum() == objnum) { |
319 return TRUE; | 314 return TRUE; |
320 } | 315 } |
321 } | 316 } |
322 return FALSE; | 317 return FALSE; |
323 } | 318 } |
324 FX_DWORD CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const { | 319 FX_DWORD CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const { |
325 if (m_pParser == NULL) { | 320 if (m_pParser == NULL) { |
326 return (FX_DWORD)-1; | 321 return (FX_DWORD)-1; |
(...skipping 26 matching lines...) Expand all Loading... |
353 void CPDF_Document::ClearPageData() { | 348 void CPDF_Document::ClearPageData() { |
354 if (m_pDocPage) { | 349 if (m_pDocPage) { |
355 CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this); | 350 CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this); |
356 } | 351 } |
357 } | 352 } |
358 void CPDF_Document::ClearRenderData() { | 353 void CPDF_Document::ClearRenderData() { |
359 if (m_pDocRender) { | 354 if (m_pDocRender) { |
360 CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender); | 355 CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender); |
361 } | 356 } |
362 } | 357 } |
OLD | NEW |