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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 if (pContent) { | 51 if (pContent) { |
52 pPageDict->RemoveAt("Contents"); | 52 pPageDict->RemoveAt("Contents"); |
53 } | 53 } |
54 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 54 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
55 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 55 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
56 m_pDocument->AddIndirectObject(pStream); | 56 m_pDocument->AddIndirectObject(pStream); |
57 pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); | 57 pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); |
58 } | 58 } |
59 CFX_ByteString CPDF_PageContentGenerator::RealizeResource( | 59 CFX_ByteString CPDF_PageContentGenerator::RealizeResource( |
60 CPDF_Object* pResourceObj, | 60 CPDF_Object* pResourceObj, |
61 const FX_CHAR* szType) { | 61 const CFX_ByteString& bsType) { |
62 if (!m_pPage->m_pResources) { | 62 if (!m_pPage->m_pResources) { |
63 m_pPage->m_pResources = new CPDF_Dictionary; | 63 m_pPage->m_pResources = new CPDF_Dictionary; |
64 int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); | 64 int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); |
65 m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); | 65 m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); |
66 } | 66 } |
67 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(szType); | 67 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(bsType); |
68 if (!pResList) { | 68 if (!pResList) { |
69 pResList = new CPDF_Dictionary; | 69 pResList = new CPDF_Dictionary; |
70 m_pPage->m_pResources->SetAt(szType, pResList); | 70 m_pPage->m_pResources->SetAt(bsType, pResList); |
71 } | 71 } |
72 m_pDocument->AddIndirectObject(pResourceObj); | 72 m_pDocument->AddIndirectObject(pResourceObj); |
73 CFX_ByteString name; | 73 CFX_ByteString name; |
74 int idnum = 1; | 74 int idnum = 1; |
75 while (1) { | 75 while (1) { |
76 name.Format("FX%c%d", szType[0], idnum); | 76 name.Format("FX%c%d", bsType[0], idnum); |
77 if (!pResList->KeyExist(name)) { | 77 if (!pResList->KeyExist(name)) { |
78 break; | 78 break; |
79 } | 79 } |
80 idnum++; | 80 idnum++; |
81 } | 81 } |
82 pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum()); | 82 pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum()); |
83 return name; | 83 return name; |
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) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 CPDF_StreamAcc contentStream; | 158 CPDF_StreamAcc contentStream; |
159 contentStream.LoadAllData(pStream); | 159 contentStream.LoadAllData(pStream); |
160 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 160 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
161 } | 161 } |
162 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 162 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
163 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 163 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
164 m_pDocument->AddIndirectObject(pStream); | 164 m_pDocument->AddIndirectObject(pStream); |
165 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, | 165 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, |
166 pStream->GetObjNum()); | 166 pStream->GetObjNum()); |
167 } | 167 } |
OLD | NEW |