| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/edit/cpdf_pagecontentgenerator.h" | 7 #include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/edit/cpdf_creator.h" | 9 #include "core/fpdfapi/edit/cpdf_creator.h" |
| 10 #include "core/fpdfapi/page/cpdf_docpagedata.h" | 10 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return name; | 87 return name; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, | 90 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, |
| 91 CPDF_ImageObject* pImageObj) { | 91 CPDF_ImageObject* pImageObj) { |
| 92 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || | 92 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || |
| 93 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { | 93 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 buf << "q " << pImageObj->m_Matrix << " cm "; | 96 buf << "q " << pImageObj->m_Matrix << " cm "; |
| 97 |
| 97 CPDF_Image* pImage = pImageObj->GetImage(); | 98 CPDF_Image* pImage = pImageObj->GetImage(); |
| 98 if (!pImage->IsInline()) { | 99 if (pImage->IsInline()) |
| 99 CPDF_Stream* pStream = pImage->GetStream(); | 100 return; |
| 100 uint32_t dwSavedObjNum = pStream->GetObjNum(); | 101 |
| 101 CFX_ByteString name = RealizeResource(pStream, "XObject"); | 102 CPDF_Stream* pStream = pImage->GetStream(); |
| 102 if (dwSavedObjNum == 0) { | 103 if (!pStream) |
| 103 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); | 104 return; |
| 104 } | 105 |
| 105 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; | 106 bool bWasInline = pStream->IsInline(); |
| 106 } | 107 CFX_ByteString name = RealizeResource(pStream, "XObject"); |
| 108 if (bWasInline) |
| 109 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); |
| 110 |
| 111 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; |
| 107 } | 112 } |
| 108 | 113 |
| 109 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, | 114 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, |
| 110 const uint8_t* data, | 115 const uint8_t* data, |
| 111 uint32_t size, | 116 uint32_t size, |
| 112 CFX_Matrix& matrix) { | 117 CFX_Matrix& matrix) { |
| 113 if (!data || !size) | 118 if (!data || !size) |
| 114 return; | 119 return; |
| 115 | 120 |
| 116 CPDF_Dictionary* pFormDict = | 121 CPDF_Dictionary* pFormDict = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } else if (CPDF_Stream* pStream = pContent->AsStream()) { | 173 } else if (CPDF_Stream* pStream = pContent->AsStream()) { |
| 169 CPDF_StreamAcc contentStream; | 174 CPDF_StreamAcc contentStream; |
| 170 contentStream.LoadAllData(pStream); | 175 contentStream.LoadAllData(pStream); |
| 171 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 176 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
| 172 } | 177 } |
| 173 CPDF_Stream* pStream = new CPDF_Stream; | 178 CPDF_Stream* pStream = new CPDF_Stream; |
| 174 pStream->SetData(buf.GetBuffer(), buf.GetLength()); | 179 pStream->SetData(buf.GetBuffer(), buf.GetLength()); |
| 175 m_pPage->m_pFormDict->SetReferenceFor( | 180 m_pPage->m_pFormDict->SetReferenceFor( |
| 176 "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream)); | 181 "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream)); |
| 177 } | 182 } |
| OLD | NEW |