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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 CPDF_Stream* pStream = new CPDF_Stream; | 56 CPDF_Stream* pStream = new CPDF_Stream; |
57 pStream->SetData(buf.GetBuffer(), buf.GetLength()); | 57 pStream->SetData(buf.GetBuffer(), buf.GetLength()); |
58 m_pDocument->AddIndirectObject(pStream); | 58 m_pDocument->AddIndirectObject(pStream); |
59 pPageDict->SetReferenceFor("Contents", m_pDocument, pStream->GetObjNum()); | 59 pPageDict->SetReferenceFor("Contents", m_pDocument, pStream->GetObjNum()); |
60 } | 60 } |
61 | 61 |
62 CFX_ByteString CPDF_PageContentGenerator::RealizeResource( | 62 CFX_ByteString CPDF_PageContentGenerator::RealizeResource( |
63 CPDF_Object* pResourceObj, | 63 CPDF_Object* pResourceObj, |
64 const CFX_ByteString& bsType) { | 64 const CFX_ByteString& bsType) { |
65 if (!m_pPage->m_pResources) { | 65 if (!m_pPage->m_pResources) { |
66 m_pPage->m_pResources = new CPDF_Dictionary; | 66 m_pPage->m_pResources = |
| 67 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
67 int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); | 68 int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); |
68 m_pPage->m_pFormDict->SetReferenceFor("Resources", m_pDocument, objnum); | 69 m_pPage->m_pFormDict->SetReferenceFor("Resources", m_pDocument, objnum); |
69 } | 70 } |
70 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType); | 71 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType); |
71 if (!pResList) { | 72 if (!pResList) { |
72 pResList = new CPDF_Dictionary; | 73 pResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
73 m_pPage->m_pResources->SetFor(bsType, pResList); | 74 m_pPage->m_pResources->SetFor(bsType, pResList); |
74 } | 75 } |
75 m_pDocument->AddIndirectObject(pResourceObj); | 76 m_pDocument->AddIndirectObject(pResourceObj); |
76 CFX_ByteString name; | 77 CFX_ByteString name; |
77 int idnum = 1; | 78 int idnum = 1; |
78 while (1) { | 79 while (1) { |
79 name.Format("FX%c%d", bsType[0], idnum); | 80 name.Format("FX%c%d", bsType[0], idnum); |
80 if (!pResList->KeyExist(name)) { | 81 if (!pResList->KeyExist(name)) { |
81 break; | 82 break; |
82 } | 83 } |
(...skipping 22 matching lines...) Expand all Loading... |
105 } | 106 } |
106 } | 107 } |
107 | 108 |
108 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, | 109 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, |
109 const uint8_t* data, | 110 const uint8_t* data, |
110 uint32_t size, | 111 uint32_t size, |
111 CFX_Matrix& matrix) { | 112 CFX_Matrix& matrix) { |
112 if (!data || !size) | 113 if (!data || !size) |
113 return; | 114 return; |
114 | 115 |
115 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; | 116 CPDF_Dictionary* pFormDict = |
| 117 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
116 pFormDict->SetNameFor("Type", "XObject"); | 118 pFormDict->SetNameFor("Type", "XObject"); |
117 pFormDict->SetNameFor("Subtype", "Form"); | 119 pFormDict->SetNameFor("Subtype", "Form"); |
118 | 120 |
119 CFX_FloatRect bbox = m_pPage->GetPageBBox(); | 121 CFX_FloatRect bbox = m_pPage->GetPageBBox(); |
120 matrix.TransformRect(bbox); | 122 matrix.TransformRect(bbox); |
121 pFormDict->SetRectFor("BBox", bbox); | 123 pFormDict->SetRectFor("BBox", bbox); |
122 | 124 |
123 CPDF_Stream* pStream = new CPDF_Stream; | 125 CPDF_Stream* pStream = new CPDF_Stream; |
124 pStream->InitStream(data, size, pFormDict); | 126 pStream->InitStream(data, size, pFormDict); |
125 buf << "q " << matrix << " cm "; | 127 buf << "q " << matrix << " cm "; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 CPDF_StreamAcc contentStream; | 169 CPDF_StreamAcc contentStream; |
168 contentStream.LoadAllData(pStream); | 170 contentStream.LoadAllData(pStream); |
169 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 171 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
170 } | 172 } |
171 CPDF_Stream* pStream = new CPDF_Stream; | 173 CPDF_Stream* pStream = new CPDF_Stream; |
172 pStream->SetData(buf.GetBuffer(), buf.GetLength()); | 174 pStream->SetData(buf.GetBuffer(), buf.GetLength()); |
173 m_pDocument->AddIndirectObject(pStream); | 175 m_pDocument->AddIndirectObject(pStream); |
174 m_pPage->m_pFormDict->SetReferenceFor("Contents", m_pDocument, | 176 m_pPage->m_pFormDict->SetReferenceFor("Contents", m_pDocument, |
175 pStream->GetObjNum()); | 177 pStream->GetObjNum()); |
176 } | 178 } |
OLD | NEW |