| 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/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
| 8 #include "../include/fpdf_flatten.h" | 8 #include "../include/fpdf_flatten.h" |
| 9 | 9 |
| 10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; | 10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 if (!pContentsObj) | 208 if (!pContentsObj) |
| 209 { | 209 { |
| 210 pContentsObj = pPage->GetArray("Contents"); | 210 pContentsObj = pPage->GetArray("Contents"); |
| 211 } | 211 } |
| 212 | 212 |
| 213 if (!pContentsObj) | 213 if (!pContentsObj) |
| 214 { | 214 { |
| 215 //Create a new contents dictionary | 215 //Create a new contents dictionary |
| 216 if (!key.IsEmpty()) | 216 if (!key.IsEmpty()) |
| 217 { | 217 { |
| 218 » » » CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, FX_
NEW CPDF_Dictionary); | 218 » » » CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new
CPDF_Dictionary); |
| 219 pPage->SetAtReference("Contents", pDocument, pDocument->
AddIndirectObject(pNewContents)); | 219 pPage->SetAtReference("Contents", pDocument, pDocument->
AddIndirectObject(pNewContents)); |
| 220 | 220 |
| 221 CFX_ByteString sStream; | 221 CFX_ByteString sStream; |
| 222 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str())
; | 222 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str())
; |
| 223 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLe
ngth(), FALSE, FALSE); | 223 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLe
ngth(), FALSE, FALSE); |
| 224 } | 224 } |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 | 227 |
| 228 int iType = pContentsObj->GetType(); | 228 int iType = pContentsObj->GetType(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 254 break; | 254 break; |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (!pContentsArray)return; | 257 if (!pContentsArray)return; |
| 258 | 258 |
| 259 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContentsArray); | 259 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContentsArray); |
| 260 pPage->SetAtReference("Contents", pDocument, dwObjNum); | 260 pPage->SetAtReference("Contents", pDocument, dwObjNum); |
| 261 | 261 |
| 262 if (!key.IsEmpty()) | 262 if (!key.IsEmpty()) |
| 263 { | 263 { |
| 264 » » CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, FX_NEW CPDF
_Dictionary); | 264 » » CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new CPDF_Di
ctionary); |
| 265 dwObjNum = pDocument->AddIndirectObject(pNewContents); | 265 dwObjNum = pDocument->AddIndirectObject(pNewContents); |
| 266 pContentsArray->AddReference(pDocument, dwObjNum); | 266 pContentsArray->AddReference(pDocument, dwObjNum); |
| 267 » » | 267 |
| 268 CFX_ByteString sStream; | 268 CFX_ByteString sStream; |
| 269 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); | 269 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); |
| 270 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(),
FALSE, FALSE); | 270 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(),
FALSE, FALSE); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 CFX_AffineMatrix GetMatrix(CPDF_Rect rcAnnot, CPDF_Rect rcStream, CFX_AffineMatr
ix matrix) | 274 CFX_AffineMatrix GetMatrix(CPDF_Rect rcAnnot, CPDF_Rect rcStream, CFX_AffineMatr
ix matrix) |
| 275 { | 275 { |
| 276 if(rcStream.IsEmpty()) | 276 if(rcStream.IsEmpty()) |
| 277 return CFX_AffineMatrix(); | 277 return CFX_AffineMatrix(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 pCropBox->Add(new CPDF_Number(rcOriginalCB.bottom)); | 392 pCropBox->Add(new CPDF_Number(rcOriginalCB.bottom)); |
| 393 pCropBox->Add(new CPDF_Number(rcOriginalCB.right)); | 393 pCropBox->Add(new CPDF_Number(rcOriginalCB.right)); |
| 394 pCropBox->Add(new CPDF_Number(rcOriginalCB.top)); | 394 pCropBox->Add(new CPDF_Number(rcOriginalCB.top)); |
| 395 pPageDict->SetAt("ArtBox", pCropBox); | 395 pPageDict->SetAt("ArtBox", pCropBox); |
| 396 } | 396 } |
| 397 | 397 |
| 398 CPDF_Dictionary* pRes = pPageDict->GetDict("Resources"); | 398 CPDF_Dictionary* pRes = pPageDict->GetDict("Resources"); |
| 399 if (!pRes) | 399 if (!pRes) |
| 400 { | 400 { |
| 401 pRes = new CPDF_Dictionary; | 401 pRes = new CPDF_Dictionary; |
| 402 » » pPageDict->SetAt("Resources", pRes); | 402 » » pPageDict->SetAt("Resources", pRes ); |
| 403 } | 403 } |
| 404 | 404 |
| 405 » CPDF_Stream* pNewXObject = new CPDF_Stream(NULL, 0, FX_NEW CPDF_Dictiona
ry); | 405 » CPDF_Stream* pNewXObject = new CPDF_Stream(NULL, 0, new CPDF_Dictionary)
; |
| 406 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pNewXObject); | 406 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pNewXObject); |
| 407 CPDF_Dictionary* pPageXObject = pRes->GetDict("XObject"); | 407 CPDF_Dictionary* pPageXObject = pRes->GetDict("XObject"); |
| 408 if (!pPageXObject) | 408 if (!pPageXObject) |
| 409 { | 409 { |
| 410 pPageXObject = new CPDF_Dictionary; | 410 pPageXObject = new CPDF_Dictionary; |
| 411 pRes->SetAt("XObject", pPageXObject); | 411 pRes->SetAt("XObject", pPageXObject); |
| 412 } | 412 } |
| 413 | 413 |
| 414 CFX_ByteString key = ""; | 414 CFX_ByteString key = ""; |
| 415 int nStreams = ObjectArray.GetSize(); | 415 int nStreams = ObjectArray.GetSize(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 548 |
| 549 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F
ALSE, FALSE); | 549 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F
ALSE, FALSE); |
| 550 } | 550 } |
| 551 pPageDict->RemoveAt( "Annots" ); | 551 pPageDict->RemoveAt( "Annots" ); |
| 552 | 552 |
| 553 ObjectArray.RemoveAll(); | 553 ObjectArray.RemoveAll(); |
| 554 RectArray.RemoveAll(); | 554 RectArray.RemoveAll(); |
| 555 | 555 |
| 556 return FLATTEN_SUCCESS; | 556 return FLATTEN_SUCCESS; |
| 557 } | 557 } |
| OLD | NEW |