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/page/cpdf_docpagedata.h" | 9 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
10 #include "core/fpdfapi/page/cpdf_image.h" | 10 #include "core/fpdfapi/page/cpdf_image.h" |
11 #include "core/fpdfapi/page/cpdf_imageobject.h" | 11 #include "core/fpdfapi/page/cpdf_imageobject.h" |
12 #include "core/fpdfapi/page/cpdf_page.h" | 12 #include "core/fpdfapi/page/cpdf_page.h" |
13 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 13 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
14 #include "core/fpdfapi/parser/cpdf_document.h" | 14 #include "core/fpdfapi/parser/cpdf_document.h" |
15 #include "core/fpdfapi/parser/cpdf_name.h" | 15 #include "core/fpdfapi/parser/cpdf_name.h" |
16 #include "core/fpdfapi/parser/cpdf_reference.h" | 16 #include "core/fpdfapi/parser/cpdf_reference.h" |
17 #include "core/fpdfapi/parser/cpdf_stream.h" | 17 #include "core/fpdfapi/parser/cpdf_stream.h" |
18 #include "core/fpdfapi/parser/fpdf_parser_decode.h" | 18 #include "core/fpdfapi/parser/fpdf_parser_decode.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, CFX_Matrix& matrix) { | 22 CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, const CFX_Matrix& matrix) { |
23 ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " | 23 ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " |
24 << matrix.e << " " << matrix.f; | 24 << matrix.e << " " << matrix.f; |
25 return ar; | 25 return ar; |
26 } | 26 } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage) | 30 CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage) |
31 : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument) { | 31 : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument) { |
32 for (const auto& pObj : *pPage->GetPageObjectList()) { | 32 for (const auto& pObj : *pPage->GetPageObjectList()) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 break; | 77 break; |
78 } | 78 } |
79 idnum++; | 79 idnum++; |
80 } | 80 } |
81 pResList->SetNewFor<CPDF_Reference>(name, m_pDocument, dwResourceObjNum); | 81 pResList->SetNewFor<CPDF_Reference>(name, m_pDocument, dwResourceObjNum); |
82 return name; | 82 return name; |
83 } | 83 } |
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->matrix().a == 0 && pImageObj->matrix().b == 0) || |
88 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { | 88 (pImageObj->matrix().c == 0 && pImageObj->matrix().d == 0)) { |
89 return; | 89 return; |
90 } | 90 } |
91 *buf << "q " << pImageObj->m_Matrix << " cm "; | 91 *buf << "q " << pImageObj->matrix() << " cm "; |
92 | 92 |
93 CPDF_Image* pImage = pImageObj->GetImage(); | 93 CPDF_Image* pImage = pImageObj->GetImage(); |
94 if (pImage->IsInline()) | 94 if (pImage->IsInline()) |
95 return; | 95 return; |
96 | 96 |
97 CPDF_Stream* pStream = pImage->GetStream(); | 97 CPDF_Stream* pStream = pImage->GetStream(); |
98 if (!pStream) | 98 if (!pStream) |
99 return; | 99 return; |
100 | 100 |
101 bool bWasInline = pStream->IsInline(); | 101 bool bWasInline = pStream->IsInline(); |
102 if (bWasInline) | 102 if (bWasInline) |
103 pImage->ConvertStreamToIndirectObject(); | 103 pImage->ConvertStreamToIndirectObject(); |
104 | 104 |
105 uint32_t dwObjNum = pStream->GetObjNum(); | 105 uint32_t dwObjNum = pStream->GetObjNum(); |
106 CFX_ByteString name = RealizeResource(dwObjNum, "XObject"); | 106 CFX_ByteString name = RealizeResource(dwObjNum, "XObject"); |
107 if (bWasInline) | 107 if (bWasInline) |
108 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(dwObjNum)); | 108 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(dwObjNum)); |
109 | 109 |
110 *buf << "/" << PDF_NameEncode(name) << " Do Q\n"; | 110 *buf << "/" << PDF_NameEncode(name) << " Do Q\n"; |
111 } | 111 } |
OLD | NEW |