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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(szType); | 67 CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(szType); |
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(szType, 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", szType[0], idnum); |
77 if (!pResList->KeyExist(name.AsStringC())) { | 77 if (!pResList->KeyExist(name)) { |
78 break; | 78 break; |
79 } | 79 } |
80 idnum++; | 80 idnum++; |
81 } | 81 } |
82 pResList->AddReference(name.AsStringC(), m_pDocument, | 82 pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum()); |
83 pResourceObj->GetObjNum()); | |
84 return name; | 83 return name; |
85 } | 84 } |
86 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, | 85 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, |
87 CPDF_ImageObject* pImageObj) { | 86 CPDF_ImageObject* pImageObj) { |
88 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || | 87 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || |
89 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { | 88 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { |
90 return; | 89 return; |
91 } | 90 } |
92 buf << "q " << pImageObj->m_Matrix << " cm "; | 91 buf << "q " << pImageObj->m_Matrix << " cm "; |
93 if (!pImageObj->m_pImage->IsInline()) { | 92 if (!pImageObj->m_pImage->IsInline()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 CPDF_StreamAcc contentStream; | 158 CPDF_StreamAcc contentStream; |
160 contentStream.LoadAllData(pStream); | 159 contentStream.LoadAllData(pStream); |
161 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 160 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
162 } | 161 } |
163 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 162 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
164 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 163 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
165 m_pDocument->AddIndirectObject(pStream); | 164 m_pDocument->AddIndirectObject(pStream); |
166 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, | 165 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, |
167 pStream->GetObjNum()); | 166 pStream->GetObjNum()); |
168 } | 167 } |
OLD | NEW |