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 pPageDict->SetReferenceFor("Contents", m_pDocument, | 58 pPageDict->SetReferenceFor("Contents", m_pDocument, |
59 m_pDocument->AddIndirectObject(pStream)); | 59 m_pDocument->AddIndirectObject(pStream)); |
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 m_pPage->m_pFormDict->SetReferenceFor( | 68 m_pPage->m_pFormDict->SetReferenceFor( |
68 "Resources", m_pDocument, | 69 "Resources", m_pDocument, |
69 m_pDocument->AddIndirectObject(m_pPage->m_pResources)); | 70 m_pDocument->AddIndirectObject(m_pPage->m_pResources)); |
70 } | 71 } |
71 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType); | 72 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictFor(bsType); |
72 if (!pResList) { | 73 if (!pResList) { |
73 pResList = new CPDF_Dictionary; | 74 pResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
74 m_pPage->m_pResources->SetFor(bsType, pResList); | 75 m_pPage->m_pResources->SetFor(bsType, pResList); |
75 } | 76 } |
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 } |
83 idnum++; | 84 idnum++; |
(...skipping 22 matching lines...) Expand all Loading... |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, | 110 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, |
110 const uint8_t* data, | 111 const uint8_t* data, |
111 uint32_t size, | 112 uint32_t size, |
112 CFX_Matrix& matrix) { | 113 CFX_Matrix& matrix) { |
113 if (!data || !size) | 114 if (!data || !size) |
114 return; | 115 return; |
115 | 116 |
116 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; | 117 CPDF_Dictionary* pFormDict = |
| 118 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); |
117 pFormDict->SetNameFor("Type", "XObject"); | 119 pFormDict->SetNameFor("Type", "XObject"); |
118 pFormDict->SetNameFor("Subtype", "Form"); | 120 pFormDict->SetNameFor("Subtype", "Form"); |
119 | 121 |
120 CFX_FloatRect bbox = m_pPage->GetPageBBox(); | 122 CFX_FloatRect bbox = m_pPage->GetPageBBox(); |
121 matrix.TransformRect(bbox); | 123 matrix.TransformRect(bbox); |
122 pFormDict->SetRectFor("BBox", bbox); | 124 pFormDict->SetRectFor("BBox", bbox); |
123 | 125 |
124 CPDF_Stream* pStream = new CPDF_Stream; | 126 CPDF_Stream* pStream = new CPDF_Stream; |
125 pStream->InitStream(data, size, pFormDict); | 127 pStream->InitStream(data, size, pFormDict); |
126 buf << "q " << matrix << " cm "; | 128 buf << "q " << matrix << " cm "; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } else if (CPDF_Stream* pStream = pContent->AsStream()) { | 169 } else if (CPDF_Stream* pStream = pContent->AsStream()) { |
168 CPDF_StreamAcc contentStream; | 170 CPDF_StreamAcc contentStream; |
169 contentStream.LoadAllData(pStream); | 171 contentStream.LoadAllData(pStream); |
170 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 172 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
171 } | 173 } |
172 CPDF_Stream* pStream = new CPDF_Stream; | 174 CPDF_Stream* pStream = new CPDF_Stream; |
173 pStream->SetData(buf.GetBuffer(), buf.GetLength()); | 175 pStream->SetData(buf.GetBuffer(), buf.GetLength()); |
174 m_pPage->m_pFormDict->SetReferenceFor( | 176 m_pPage->m_pFormDict->SetReferenceFor( |
175 "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream)); | 177 "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream)); |
176 } | 178 } |
OLD | NEW |