OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
8 #include "../../../include/fpdfapi/fpdf_serial.h" | 8 #include "../../../include/fpdfapi/fpdf_serial.h" |
9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return; | 124 return; |
125 | 125 |
126 CFX_ByteTextBuf buf; | 126 CFX_ByteTextBuf buf; |
127 if (CPDF_Array* pArray = pContent->AsArray()) { | 127 if (CPDF_Array* pArray = pContent->AsArray()) { |
128 int iCount = pArray->GetCount(); | 128 int iCount = pArray->GetCount(); |
129 CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount); | 129 CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount); |
130 int size = 0; | 130 int size = 0; |
131 int i = 0; | 131 int i = 0; |
132 for (i = 0; i < iCount; ++i) { | 132 for (i = 0; i < iCount; ++i) { |
133 pContent = pArray->GetElement(i); | 133 pContent = pArray->GetElement(i); |
134 if (!pContent || pContent->GetType() != PDFOBJ_STREAM) { | 134 CPDF_Stream* pStream = ToStream(pContent); |
| 135 if (!pStream) |
135 continue; | 136 continue; |
136 } | 137 |
137 CPDF_StreamAcc* pStream = new CPDF_StreamAcc(); | 138 CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc(); |
138 pStream->LoadAllData((CPDF_Stream*)pContent); | 139 pStreamAcc->LoadAllData(pStream); |
139 pContentArray[i] = pStream; | 140 pContentArray[i] = pStreamAcc; |
140 size += pContentArray[i]->GetSize() + 1; | 141 size += pContentArray[i]->GetSize() + 1; |
141 } | 142 } |
142 int pos = 0; | 143 int pos = 0; |
143 uint8_t* pBuf = FX_Alloc(uint8_t, size); | 144 uint8_t* pBuf = FX_Alloc(uint8_t, size); |
144 for (i = 0; i < iCount; ++i) { | 145 for (i = 0; i < iCount; ++i) { |
145 FXSYS_memcpy(pBuf + pos, pContentArray[i]->GetData(), | 146 FXSYS_memcpy(pBuf + pos, pContentArray[i]->GetData(), |
146 pContentArray[i]->GetSize()); | 147 pContentArray[i]->GetSize()); |
147 pos += pContentArray[i]->GetSize() + 1; | 148 pos += pContentArray[i]->GetSize() + 1; |
148 pBuf[pos - 1] = ' '; | 149 pBuf[pos - 1] = ' '; |
149 delete pContentArray[i]; | 150 delete pContentArray[i]; |
150 } | 151 } |
151 ProcessForm(buf, pBuf, size, matrix); | 152 ProcessForm(buf, pBuf, size, matrix); |
152 FX_Free(pBuf); | 153 FX_Free(pBuf); |
153 FX_Free(pContentArray); | 154 FX_Free(pContentArray); |
154 } else if (pContent->GetType() == PDFOBJ_STREAM) { | 155 } else if (CPDF_Stream* pStream = pContent->AsStream()) { |
155 CPDF_StreamAcc contentStream; | 156 CPDF_StreamAcc contentStream; |
156 contentStream.LoadAllData((CPDF_Stream*)pContent); | 157 contentStream.LoadAllData(pStream); |
157 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 158 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
158 } | 159 } |
159 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 160 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
160 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 161 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
161 m_pDocument->AddIndirectObject(pStream); | 162 m_pDocument->AddIndirectObject(pStream); |
162 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, | 163 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, |
163 pStream->GetObjNum()); | 164 pStream->GetObjNum()); |
164 } | 165 } |
OLD | NEW |