| 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 10 matching lines...) Expand all Loading... |
| 21 m_pDocument = m_pPage->m_pDocument; | 21 m_pDocument = m_pPage->m_pDocument; |
| 22 } | 22 } |
| 23 FX_POSITION pos = pPage->GetFirstObjectPosition(); | 23 FX_POSITION pos = pPage->GetFirstObjectPosition(); |
| 24 while (pos) { | 24 while (pos) { |
| 25 InsertPageObject(pPage->GetNextObject(pos)); | 25 InsertPageObject(pPage->GetNextObject(pos)); |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 CPDF_PageContentGenerate::~CPDF_PageContentGenerate() | 28 CPDF_PageContentGenerate::~CPDF_PageContentGenerate() |
| 29 { | 29 { |
| 30 } | 30 } |
| 31 FX_BOOL CPDF_PageContentGenerate::InsertPageObject(CPDF_PageObject* pPageObject) | 31 bool CPDF_PageContentGenerate::InsertPageObject(CPDF_PageObject* pPageObject) |
| 32 { | 32 { |
| 33 if (!pPageObject) { | 33 if (!pPageObject) { |
| 34 return FALSE; | 34 return false; |
| 35 } | 35 } |
| 36 return m_pageObjects.Add(pPageObject); | 36 return m_pageObjects.Add(pPageObject); |
| 37 } | 37 } |
| 38 void CPDF_PageContentGenerate::GenerateContent() | 38 void CPDF_PageContentGenerate::GenerateContent() |
| 39 { | 39 { |
| 40 CFX_ByteTextBuf buf; | 40 CFX_ByteTextBuf buf; |
| 41 CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; | 41 CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; |
| 42 for (int i = 0; i < m_pageObjects.GetSize(); ++i) { | 42 for (int i = 0; i < m_pageObjects.GetSize(); ++i) { |
| 43 CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_pageObjects[i]; | 43 CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_pageObjects[i]; |
| 44 if (!pPageObj || pPageObj->m_Type != PDFPAGE_IMAGE) { | 44 if (!pPageObj || pPageObj->m_Type != PDFPAGE_IMAGE) { |
| 45 continue; | 45 continue; |
| 46 } | 46 } |
| 47 ProcessImage(buf, (CPDF_ImageObject*)pPageObj); | 47 ProcessImage(buf, (CPDF_ImageObject*)pPageObj); |
| 48 } | 48 } |
| 49 CPDF_Object* pContent = pPageDict ? pPageDict->GetElementValue("Contents") :
NULL; | 49 CPDF_Object* pContent = pPageDict ? pPageDict->GetElementValue("Contents") :
NULL; |
| 50 if (pContent != NULL) { | 50 if (pContent != NULL) { |
| 51 pPageDict->RemoveAt("Contents"); | 51 pPageDict->RemoveAt("Contents"); |
| 52 } | 52 } |
| 53 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 53 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
| 54 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 54 pStream->SetData(buf.GetBuffer(), buf.GetLength(), false, false); |
| 55 m_pDocument->AddIndirectObject(pStream); | 55 m_pDocument->AddIndirectObject(pStream); |
| 56 pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); | 56 pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); |
| 57 } | 57 } |
| 58 CFX_ByteString CPDF_PageContentGenerate::RealizeResource(CPDF_Object* pResourceO
bj, const FX_CHAR* szType) | 58 CFX_ByteString CPDF_PageContentGenerate::RealizeResource(CPDF_Object* pResourceO
bj, const FX_CHAR* szType) |
| 59 { | 59 { |
| 60 if (m_pPage->m_pResources == NULL) { | 60 if (m_pPage->m_pResources == NULL) { |
| 61 m_pPage->m_pResources = new CPDF_Dictionary; | 61 m_pPage->m_pResources = new CPDF_Dictionary; |
| 62 int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); | 62 int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); |
| 63 m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); | 63 m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); |
| 64 } | 64 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 ProcessForm(buf, pBuf, size, matrix); | 152 ProcessForm(buf, pBuf, size, matrix); |
| 153 FX_Free(pBuf); | 153 FX_Free(pBuf); |
| 154 FX_Free(pContentArray); | 154 FX_Free(pContentArray); |
| 155 } else if (type == PDFOBJ_STREAM) { | 155 } else if (type == PDFOBJ_STREAM) { |
| 156 CPDF_StreamAcc contentStream; | 156 CPDF_StreamAcc contentStream; |
| 157 contentStream.LoadAllData((CPDF_Stream*)pContent); | 157 contentStream.LoadAllData((CPDF_Stream*)pContent); |
| 158 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matri
x); | 158 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matri
x); |
| 159 } | 159 } |
| 160 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 160 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
| 161 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 161 pStream->SetData(buf.GetBuffer(), buf.GetLength(), false, false); |
| 162 m_pDocument->AddIndirectObject(pStream); | 162 m_pDocument->AddIndirectObject(pStream); |
| 163 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, pStream->GetOb
jNum()); | 163 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, pStream->GetOb
jNum()); |
| 164 } | 164 } |
| OLD | NEW |