| 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 "../../public/fpdf_flatten.h" | 7 #include "../../public/fpdf_flatten.h" |
| 8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_page.h" | 10 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 CPDF_Document* pDocument) { | 190 CPDF_Document* pDocument) { |
| 191 CPDF_Object* pContentsObj = pPage->GetStream("Contents"); | 191 CPDF_Object* pContentsObj = pPage->GetStream("Contents"); |
| 192 if (!pContentsObj) { | 192 if (!pContentsObj) { |
| 193 pContentsObj = pPage->GetArray("Contents"); | 193 pContentsObj = pPage->GetArray("Contents"); |
| 194 } | 194 } |
| 195 | 195 |
| 196 if (!pContentsObj) { | 196 if (!pContentsObj) { |
| 197 // Create a new contents dictionary | 197 // Create a new contents dictionary |
| 198 if (!key.IsEmpty()) { | 198 if (!key.IsEmpty()) { |
| 199 CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new CPDF_Dictionary); | 199 CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new CPDF_Dictionary); |
| 200 if (!pNewContents) | |
| 201 return; | |
| 202 pPage->SetAtReference("Contents", pDocument, | 200 pPage->SetAtReference("Contents", pDocument, |
| 203 pDocument->AddIndirectObject(pNewContents)); | 201 pDocument->AddIndirectObject(pNewContents)); |
| 204 | 202 |
| 205 CFX_ByteString sStream; | 203 CFX_ByteString sStream; |
| 206 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); | 204 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); |
| 207 pNewContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 205 pNewContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
| 208 FALSE); | 206 FALSE); |
| 209 } | 207 } |
| 210 return; | 208 return; |
| 211 } | 209 } |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 525 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
| 528 FALSE); | 526 FALSE); |
| 529 } | 527 } |
| 530 pPageDict->RemoveAt("Annots"); | 528 pPageDict->RemoveAt("Annots"); |
| 531 | 529 |
| 532 ObjectArray.RemoveAll(); | 530 ObjectArray.RemoveAll(); |
| 533 RectArray.RemoveAll(); | 531 RectArray.RemoveAll(); |
| 534 | 532 |
| 535 return FLATTEN_SUCCESS; | 533 return FLATTEN_SUCCESS; |
| 536 } | 534 } |
| OLD | NEW |