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 | 9 |
10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; | 10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 return; | 205 return; |
206 } | 206 } |
207 | 207 |
208 int iType = pContentsObj->GetType(); | 208 int iType = pContentsObj->GetType(); |
209 CPDF_Array* pContentsArray = NULL; | 209 CPDF_Array* pContentsArray = NULL; |
210 | 210 |
211 switch (iType) { | 211 switch (iType) { |
212 case PDFOBJ_STREAM: { | 212 case PDFOBJ_STREAM: { |
213 pContentsArray = new CPDF_Array; | 213 pContentsArray = new CPDF_Array; |
214 CPDF_Stream* pContents = (CPDF_Stream*)pContentsObj; | 214 CPDF_Stream* pContents = pContentsObj->AsStream(); |
215 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContents); | 215 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContents); |
216 CPDF_StreamAcc acc; | 216 CPDF_StreamAcc acc; |
217 acc.LoadAllData(pContents); | 217 acc.LoadAllData(pContents); |
218 CFX_ByteString sStream = "q\n"; | 218 CFX_ByteString sStream = "q\n"; |
219 CFX_ByteString sBody = | 219 CFX_ByteString sBody = |
220 CFX_ByteString((const FX_CHAR*)acc.GetData(), acc.GetSize()); | 220 CFX_ByteString((const FX_CHAR*)acc.GetData(), acc.GetSize()); |
221 sStream = sStream + sBody + "\nQ"; | 221 sStream = sStream + sBody + "\nQ"; |
222 pContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 222 pContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
223 FALSE); | 223 FALSE); |
224 pContentsArray->AddReference(pDocument, dwObjNum); | 224 pContentsArray->AddReference(pDocument, dwObjNum); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 pAPStream = pAPDic->GetStream(sAnnotState); | 440 pAPStream = pAPDic->GetStream(sAnnotState); |
441 } else { | 441 } else { |
442 FX_POSITION pos = pAPDic->GetStartPos(); | 442 FX_POSITION pos = pAPDic->GetStartPos(); |
443 if (pos) { | 443 if (pos) { |
444 CFX_ByteString sKey; | 444 CFX_ByteString sKey; |
445 CPDF_Object* pFirstObj = pAPDic->GetNextElement(pos, sKey); | 445 CPDF_Object* pFirstObj = pAPDic->GetNextElement(pos, sKey); |
446 if (pFirstObj) { | 446 if (pFirstObj) { |
447 if (pFirstObj->GetType() == PDFOBJ_REFERENCE) | 447 if (pFirstObj->GetType() == PDFOBJ_REFERENCE) |
448 pFirstObj = pFirstObj->GetDirect(); | 448 pFirstObj = pFirstObj->GetDirect(); |
449 | 449 |
450 if (pFirstObj->GetType() != PDFOBJ_STREAM) | 450 if (!pFirstObj->IsStream()) |
451 continue; | 451 continue; |
452 | 452 |
453 pAPStream = (CPDF_Stream*)pFirstObj; | 453 pAPStream = pFirstObj->AsStream(); |
454 } | 454 } |
455 } | 455 } |
456 } | 456 } |
457 } | 457 } |
458 | |
459 if (!pAPStream) | 458 if (!pAPStream) |
460 continue; | 459 continue; |
461 | 460 |
462 CPDF_Dictionary* pAPDic = pAPStream->GetDict(); | 461 CPDF_Dictionary* pAPDic = pAPStream->GetDict(); |
463 CFX_AffineMatrix matrix = pAPDic->GetMatrix("Matrix"); | 462 CFX_AffineMatrix matrix = pAPDic->GetMatrix("Matrix"); |
464 | 463 |
465 CPDF_Rect rcStream; | 464 CPDF_Rect rcStream; |
466 if (pAPDic->KeyExist("Rect")) | 465 if (pAPDic->KeyExist("Rect")) |
467 rcStream = pAPDic->GetRect("Rect"); | 466 rcStream = pAPDic->GetRect("Rect"); |
468 else if (pAPDic->KeyExist("BBox")) | 467 else if (pAPDic->KeyExist("BBox")) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 515 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
517 FALSE); | 516 FALSE); |
518 } | 517 } |
519 pPageDict->RemoveAt("Annots"); | 518 pPageDict->RemoveAt("Annots"); |
520 | 519 |
521 ObjectArray.RemoveAll(); | 520 ObjectArray.RemoveAll(); |
522 RectArray.RemoveAll(); | 521 RectArray.RemoveAll(); |
523 | 522 |
524 return FLATTEN_SUCCESS; | 523 return FLATTEN_SUCCESS; |
525 } | 524 } |
OLD | NEW |