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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 uint32_t size, | 119 uint32_t size, |
120 CFX_Matrix& matrix) { | 120 CFX_Matrix& matrix) { |
121 if (!data || !size) | 121 if (!data || !size) |
122 return; | 122 return; |
123 | 123 |
124 buf << "q " << matrix << " cm "; | 124 buf << "q " << matrix << " cm "; |
125 | 125 |
126 CFX_FloatRect bbox = m_pPage->GetPageBBox(); | 126 CFX_FloatRect bbox = m_pPage->GetPageBBox(); |
127 matrix.TransformRect(bbox); | 127 matrix.TransformRect(bbox); |
128 | 128 |
129 CPDF_Dictionary* pFormDict = | 129 auto pFormDict = |
130 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); | 130 pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool()); |
131 pFormDict->SetNewFor<CPDF_Name>("Type", "XObject"); | 131 pFormDict->SetNewFor<CPDF_Name>("Type", "XObject"); |
132 pFormDict->SetNewFor<CPDF_Name>("Subtype", "Form"); | 132 pFormDict->SetNewFor<CPDF_Name>("Subtype", "Form"); |
133 pFormDict->SetRectFor("BBox", bbox); | 133 pFormDict->SetRectFor("BBox", bbox); |
134 | 134 |
135 CPDF_Stream* pStream = m_pDocument->NewIndirect<CPDF_Stream>(); | 135 CPDF_Stream* pStream = m_pDocument->NewIndirect<CPDF_Stream>(); |
136 pStream->InitStream(data, size, pFormDict); | 136 pStream->InitStream(data, size, std::move(pFormDict)); |
137 | 137 |
138 CFX_ByteString name = RealizeResource(pStream->GetObjNum(), "XObject"); | 138 CFX_ByteString name = RealizeResource(pStream->GetObjNum(), "XObject"); |
139 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; | 139 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; |
140 } | 140 } |
141 | 141 |
142 void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { | 142 void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { |
143 CPDF_Dictionary* pDict = m_pPage->m_pFormDict; | 143 CPDF_Dictionary* pDict = m_pPage->m_pFormDict; |
144 CPDF_Object* pContent = | 144 CPDF_Object* pContent = |
145 pDict ? pDict->GetDirectObjectFor("Contents") : nullptr; | 145 pDict ? pDict->GetDirectObjectFor("Contents") : nullptr; |
146 if (!pContent) | 146 if (!pContent) |
(...skipping 30 matching lines...) Expand all Loading... |
177 } else if (CPDF_Stream* pStream = pContent->AsStream()) { | 177 } else if (CPDF_Stream* pStream = pContent->AsStream()) { |
178 CPDF_StreamAcc contentStream; | 178 CPDF_StreamAcc contentStream; |
179 contentStream.LoadAllData(pStream); | 179 contentStream.LoadAllData(pStream); |
180 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 180 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
181 } | 181 } |
182 CPDF_Stream* pStream = m_pDocument->NewIndirect<CPDF_Stream>(); | 182 CPDF_Stream* pStream = m_pDocument->NewIndirect<CPDF_Stream>(); |
183 pStream->SetData(buf.GetBuffer(), buf.GetLength()); | 183 pStream->SetData(buf.GetBuffer(), buf.GetLength()); |
184 m_pPage->m_pFormDict->SetNewFor<CPDF_Reference>("Contents", m_pDocument, | 184 m_pPage->m_pFormDict->SetNewFor<CPDF_Reference>("Contents", m_pDocument, |
185 pStream->GetObjNum()); | 185 pStream->GetObjNum()); |
186 } | 186 } |
OLD | NEW |