Chromium Code Reviews| 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_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fpdfapi/fpdf_serial.h" | 9 #include "../../../include/fpdfapi/fpdf_serial.h" |
| 10 #include "pageint.h" | 10 #include "pageint.h" |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 void CPDF_StreamContentParser::Handle_SetCachedDevice() { | 664 void CPDF_StreamContentParser::Handle_SetCachedDevice() { |
| 665 for (int i = 0; i < 6; i++) { | 665 for (int i = 0; i < 6; i++) { |
| 666 m_Type3Data[i] = GetNumber(5 - i); | 666 m_Type3Data[i] = GetNumber(5 - i); |
| 667 } | 667 } |
| 668 m_bColored = FALSE; | 668 m_bColored = FALSE; |
| 669 } | 669 } |
| 670 void CPDF_StreamContentParser::Handle_ExecuteXObject() { | 670 void CPDF_StreamContentParser::Handle_ExecuteXObject() { |
| 671 CFX_ByteString name = GetString(0); | 671 CFX_ByteString name = GetString(0); |
| 672 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && | 672 if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && |
| 673 m_pLastImage->GetStream()->GetObjNum()) { | 673 m_pLastImage->GetStream()->GetObjNum()) { |
| 674 AddImage(NULL, m_pLastImage, FALSE); | 674 AddImage(nullptr, m_pLastImage, FALSE); |
| 675 return; | 675 return; |
| 676 } | 676 } |
| 677 | |
| 677 if (m_Options.m_bTextOnly) { | 678 if (m_Options.m_bTextOnly) { |
| 678 CPDF_Object* pRes = NULL; | 679 CPDF_Object* pRes = nullptr; |
|
Lei Zhang
2015/10/22 21:26:51
move this down to where it's used
Tom Sepez
2015/10/22 21:49:14
nit: Move this down and combine with initializatio
dsinclair
2015/10/26 13:55:44
Done.
dsinclair
2015/10/26 13:55:44
Done.
| |
| 679 if (m_pResources == NULL) { | 680 if (!m_pResources) |
| 680 return; | 681 return; |
| 682 | |
| 683 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); | |
| 684 if (!pList) { | |
| 685 if (m_pResources == m_pPageResources || !m_pPageResources) | |
| 686 return; | |
| 687 CPDF_Dictionary* pList = m_pPageResources->GetDict(FX_BSTRC("XObject")); | |
|
Lei Zhang
2015/10/22 21:26:51
There's a shadow variable here.
Tom Sepez
2015/10/22 21:49:13
Argh, shadowing of pList at 683! This would be a
dsinclair
2015/10/26 13:55:44
Mistake in my simplification. Should not have been
| |
| 688 if (!pList) | |
| 689 return; | |
| 681 } | 690 } |
| 682 if (m_pResources == m_pPageResources) { | 691 pRes = pList->GetElement(name); |
|
Tom Sepez
2015/10/22 21:49:13
nit: maybe
CPDF_Reference* pRes = ToReference(
dsinclair
2015/10/26 13:55:44
Done.
| |
| 683 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); | 692 if (!ToReference(pRes)) |
| 684 if (pList == NULL) { | 693 return; |
| 685 return; | 694 |
|
Tom Sepez
2015/10/22 21:49:14
And I think the whole thing reduces down to this (
dsinclair
2015/10/26 13:55:44
Done.
| |
| 686 } | |
| 687 pRes = pList->GetElement(name); | |
| 688 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { | |
| 689 return; | |
| 690 } | |
| 691 } else { | |
| 692 CPDF_Dictionary* pList = m_pResources->GetDict(FX_BSTRC("XObject")); | |
| 693 if (pList == NULL) { | |
| 694 if (m_pPageResources == NULL) { | |
| 695 return; | |
| 696 } | |
| 697 CPDF_Dictionary* pList = m_pPageResources->GetDict(FX_BSTRC("XObject")); | |
| 698 if (pList == NULL) { | |
| 699 return; | |
| 700 } | |
| 701 pRes = pList->GetElement(name); | |
| 702 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { | |
| 703 return; | |
| 704 } | |
| 705 } else { | |
| 706 pRes = pList->GetElement(name); | |
| 707 if (pRes == NULL || pRes->GetType() != PDFOBJ_REFERENCE) { | |
| 708 return; | |
| 709 } | |
| 710 } | |
| 711 } | |
| 712 FX_BOOL bForm; | 695 FX_BOOL bForm; |
| 713 if (m_pDocument->IsFormStream(((CPDF_Reference*)pRes)->GetRefObjNum(), | 696 if (m_pDocument->IsFormStream(pRes->AsReference()->GetRefObjNum(), bForm) && |
|
Tom Sepez
2015/10/22 21:49:14
nit: then you can lose the redundant AsReference h
dsinclair
2015/10/26 13:55:44
Done.
| |
| 714 bForm) && | 697 !bForm) |
| 715 !bForm) { | |
| 716 return; | 698 return; |
| 717 } | |
| 718 } | 699 } |
| 700 | |
| 719 CPDF_Stream* pXObject = ToStream(FindResourceObj(FX_BSTRC("XObject"), name)); | 701 CPDF_Stream* pXObject = ToStream(FindResourceObj(FX_BSTRC("XObject"), name)); |
| 720 if (!pXObject) { | 702 if (!pXObject) { |
| 721 m_bResourceMissing = TRUE; | 703 m_bResourceMissing = TRUE; |
| 722 return; | 704 return; |
| 723 } | 705 } |
| 724 | 706 |
| 725 CFX_ByteStringC type = | 707 CFX_ByteStringC type = |
| 726 pXObject->GetDict() | 708 pXObject->GetDict() |
| 727 ? pXObject->GetDict()->GetConstString(FX_BSTRC("Subtype")) | 709 ? pXObject->GetDict()->GetConstString(FX_BSTRC("Subtype")) |
| 728 : CFX_ByteStringC(); | 710 : CFX_ByteStringC(); |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 buf.AppendChar((char)code); | 1568 buf.AppendChar((char)code); |
| 1587 } | 1569 } |
| 1588 bFirst = !bFirst; | 1570 bFirst = !bFirst; |
| 1589 } | 1571 } |
| 1590 } | 1572 } |
| 1591 if (!bFirst) { | 1573 if (!bFirst) { |
| 1592 buf.AppendChar((char)code); | 1574 buf.AppendChar((char)code); |
| 1593 } | 1575 } |
| 1594 return buf.GetByteString(); | 1576 return buf.GetByteString(); |
| 1595 } | 1577 } |
| OLD | NEW |