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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { | 92 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { |
93 return; | 93 return; |
94 } | 94 } |
95 buf << "q " << pImageObj->m_Matrix << " cm "; | 95 buf << "q " << pImageObj->m_Matrix << " cm "; |
96 CPDF_Image* pImage = pImageObj->GetImage(); | 96 CPDF_Image* pImage = pImageObj->GetImage(); |
97 if (!pImage->IsInline()) { | 97 if (!pImage->IsInline()) { |
98 CPDF_Stream* pStream = pImage->GetStream(); | 98 CPDF_Stream* pStream = pImage->GetStream(); |
99 uint32_t dwSavedObjNum = pStream->GetObjNum(); | 99 uint32_t dwSavedObjNum = pStream->GetObjNum(); |
100 CFX_ByteString name = RealizeResource(pStream, "XObject"); | 100 CFX_ByteString name = RealizeResource(pStream, "XObject"); |
101 if (dwSavedObjNum == 0) { | 101 if (dwSavedObjNum == 0) { |
102 pImage->Release(); | 102 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); |
103 pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pStream); | |
104 } | 103 } |
105 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; | 104 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; |
106 } | 105 } |
107 } | 106 } |
| 107 |
108 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, | 108 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, |
109 const uint8_t* data, | 109 const uint8_t* data, |
110 uint32_t size, | 110 uint32_t size, |
111 CFX_Matrix& matrix) { | 111 CFX_Matrix& matrix) { |
112 if (!data || !size) { | 112 if (!data || !size) { |
113 return; | 113 return; |
114 } | 114 } |
115 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); | 115 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); |
116 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; | 116 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; |
117 pFormDict->SetAtName("Type", "XObject"); | 117 pFormDict->SetAtName("Type", "XObject"); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 CPDF_StreamAcc contentStream; | 163 CPDF_StreamAcc contentStream; |
164 contentStream.LoadAllData(pStream); | 164 contentStream.LoadAllData(pStream); |
165 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 165 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
166 } | 166 } |
167 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); | 167 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); |
168 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 168 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
169 m_pDocument->AddIndirectObject(pStream); | 169 m_pDocument->AddIndirectObject(pStream); |
170 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, | 170 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, |
171 pStream->GetObjNum()); | 171 pStream->GetObjNum()); |
172 } | 172 } |
OLD | NEW |