| 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/fpdf_edit/include/cpdf_pagecontentgenerator.h" | 7 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" | 9 #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" |
| 10 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, | 85 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, |
| 86 CPDF_ImageObject* pImageObj) { | 86 CPDF_ImageObject* pImageObj) { |
| 87 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || | 87 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || |
| 88 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { | 88 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 buf << "q " << pImageObj->m_Matrix << " cm "; | 91 buf << "q " << pImageObj->m_Matrix << " cm "; |
| 92 if (!pImageObj->m_pImage->IsInline()) { | 92 if (!pImageObj->m_pImage->IsInline()) { |
| 93 CPDF_Stream* pStream = pImageObj->m_pImage->GetStream(); | 93 CPDF_Stream* pStream = pImageObj->m_pImage->GetStream(); |
| 94 FX_DWORD dwSavedObjNum = pStream->GetObjNum(); | 94 uint32_t dwSavedObjNum = pStream->GetObjNum(); |
| 95 CFX_ByteString name = RealizeResource(pStream, "XObject"); | 95 CFX_ByteString name = RealizeResource(pStream, "XObject"); |
| 96 if (dwSavedObjNum == 0) { | 96 if (dwSavedObjNum == 0) { |
| 97 if (pImageObj->m_pImage) | 97 if (pImageObj->m_pImage) |
| 98 pImageObj->m_pImage->Release(); | 98 pImageObj->m_pImage->Release(); |
| 99 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pStream); | 99 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pStream); |
| 100 } | 100 } |
| 101 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; | 101 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, | 104 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, |
| 105 const uint8_t* data, | 105 const uint8_t* data, |
| 106 FX_DWORD size, | 106 uint32_t size, |
| 107 CFX_Matrix& matrix) { | 107 CFX_Matrix& matrix) { |
| 108 if (!data || !size) { | 108 if (!data || !size) { |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 111 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
| 112 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; | 112 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; |
| 113 pFormDict->SetAtName("Type", "XObject"); | 113 pFormDict->SetAtName("Type", "XObject"); |
| 114 pFormDict->SetAtName("Subtype", "Form"); | 114 pFormDict->SetAtName("Subtype", "Form"); |
| 115 CFX_FloatRect bbox = m_pPage->GetPageBBox(); | 115 CFX_FloatRect bbox = m_pPage->GetPageBBox(); |
| 116 matrix.TransformRect(bbox); | 116 matrix.TransformRect(bbox); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 CPDF_StreamAcc contentStream; | 159 CPDF_StreamAcc contentStream; |
| 160 contentStream.LoadAllData(pStream); | 160 contentStream.LoadAllData(pStream); |
| 161 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 161 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
| 162 } | 162 } |
| 163 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 163 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
| 164 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 164 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
| 165 m_pDocument->AddIndirectObject(pStream); | 165 m_pDocument->AddIndirectObject(pStream); |
| 166 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, | 166 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, |
| 167 pStream->GetObjNum()); | 167 pStream->GetObjNum()); |
| 168 } | 168 } |
| OLD | NEW |