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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 388 } |
389 | 389 |
390 CFX_ByteString key = ""; | 390 CFX_ByteString key = ""; |
391 int nStreams = ObjectArray.GetSize(); | 391 int nStreams = ObjectArray.GetSize(); |
392 | 392 |
393 if (nStreams > 0) { | 393 if (nStreams > 0) { |
394 for (int iKey = 0; /*iKey < 100*/; iKey++) { | 394 for (int iKey = 0; /*iKey < 100*/; iKey++) { |
395 char sExtend[5] = {}; | 395 char sExtend[5] = {}; |
396 FXSYS_itoa(iKey, sExtend, 10); | 396 FXSYS_itoa(iKey, sExtend, 10); |
397 key = CFX_ByteString("FFT") + CFX_ByteString(sExtend); | 397 key = CFX_ByteString("FFT") + CFX_ByteString(sExtend); |
398 if (!pPageXObject->KeyExist(key.AsByteStringC())) | 398 if (!pPageXObject->KeyExist(key.AsStringC())) |
399 break; | 399 break; |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 SetPageContents(key, pPageDict, pDocument); | 403 SetPageContents(key, pPageDict, pDocument); |
404 | 404 |
405 CPDF_Dictionary* pNewXORes = NULL; | 405 CPDF_Dictionary* pNewXORes = NULL; |
406 | 406 |
407 if (!key.IsEmpty()) { | 407 if (!key.IsEmpty()) { |
408 pPageXObject->SetAtReference(key.AsByteStringC(), pDocument, dwObjNum); | 408 pPageXObject->SetAtReference(key.AsStringC(), pDocument, dwObjNum); |
409 CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict(); | 409 CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict(); |
410 pNewXORes = new CPDF_Dictionary; | 410 pNewXORes = new CPDF_Dictionary; |
411 pNewOXbjectDic->SetAt("Resources", pNewXORes); | 411 pNewOXbjectDic->SetAt("Resources", pNewXORes); |
412 pNewOXbjectDic->SetAtName("Type", "XObject"); | 412 pNewOXbjectDic->SetAtName("Type", "XObject"); |
413 pNewOXbjectDic->SetAtName("Subtype", "Form"); | 413 pNewOXbjectDic->SetAtName("Subtype", "Form"); |
414 pNewOXbjectDic->SetAtInteger("FormType", 1); | 414 pNewOXbjectDic->SetAtInteger("FormType", 1); |
415 pNewOXbjectDic->SetAtName("Name", "FRM"); | 415 pNewOXbjectDic->SetAtName("Name", "FRM"); |
416 CFX_FloatRect rcBBox = pPageDict->GetRectBy("ArtBox"); | 416 CFX_FloatRect rcBBox = pPageDict->GetRectBy("ArtBox"); |
417 pNewOXbjectDic->SetAtRect("BBox", rcBBox); | 417 pNewOXbjectDic->SetAtRect("BBox", rcBBox); |
418 } | 418 } |
(...skipping 11 matching lines...) Expand all Loading... |
430 if (!pAnnotAP) | 430 if (!pAnnotAP) |
431 continue; | 431 continue; |
432 | 432 |
433 CPDF_Stream* pAPStream = pAnnotAP->GetStreamBy("N"); | 433 CPDF_Stream* pAPStream = pAnnotAP->GetStreamBy("N"); |
434 if (!pAPStream) { | 434 if (!pAPStream) { |
435 CPDF_Dictionary* pAPDic = pAnnotAP->GetDictBy("N"); | 435 CPDF_Dictionary* pAPDic = pAnnotAP->GetDictBy("N"); |
436 if (!pAPDic) | 436 if (!pAPDic) |
437 continue; | 437 continue; |
438 | 438 |
439 if (!sAnnotState.IsEmpty()) { | 439 if (!sAnnotState.IsEmpty()) { |
440 pAPStream = pAPDic->GetStreamBy(sAnnotState.AsByteStringC()); | 440 pAPStream = pAPDic->GetStreamBy(sAnnotState.AsStringC()); |
441 } else { | 441 } else { |
442 auto it = pAPDic->begin(); | 442 auto it = pAPDic->begin(); |
443 if (it != pAPDic->end()) { | 443 if (it != pAPDic->end()) { |
444 CPDF_Object* pFirstObj = it->second; | 444 CPDF_Object* pFirstObj = it->second; |
445 if (pFirstObj) { | 445 if (pFirstObj) { |
446 if (pFirstObj->IsReference()) | 446 if (pFirstObj->IsReference()) |
447 pFirstObj = pFirstObj->GetDirect(); | 447 pFirstObj = pFirstObj->GetDirect(); |
448 if (!pFirstObj->IsStream()) | 448 if (!pFirstObj->IsStream()) |
449 continue; | 449 continue; |
450 pAPStream = pFirstObj->AsStream(); | 450 pAPStream = pFirstObj->AsStream(); |
(...skipping 28 matching lines...) Expand all Loading... |
479 | 479 |
480 CPDF_Dictionary* pXObject = pNewXORes->GetDictBy("XObject"); | 480 CPDF_Dictionary* pXObject = pNewXORes->GetDictBy("XObject"); |
481 if (!pXObject) { | 481 if (!pXObject) { |
482 pXObject = new CPDF_Dictionary; | 482 pXObject = new CPDF_Dictionary; |
483 pNewXORes->SetAt("XObject", pXObject); | 483 pNewXORes->SetAt("XObject", pXObject); |
484 } | 484 } |
485 | 485 |
486 CFX_ByteString sFormName; | 486 CFX_ByteString sFormName; |
487 sFormName.Format("F%d", i); | 487 sFormName.Format("F%d", i); |
488 uint32_t dwObjNum = pDocument->AddIndirectObject(pObj); | 488 uint32_t dwObjNum = pDocument->AddIndirectObject(pObj); |
489 pXObject->SetAtReference(sFormName.AsByteStringC(), pDocument, dwObjNum); | 489 pXObject->SetAtReference(sFormName.AsStringC(), pDocument, dwObjNum); |
490 | 490 |
491 CPDF_StreamAcc acc; | 491 CPDF_StreamAcc acc; |
492 acc.LoadAllData(pNewXObject); | 492 acc.LoadAllData(pNewXObject); |
493 | 493 |
494 const uint8_t* pData = acc.GetData(); | 494 const uint8_t* pData = acc.GetData(); |
495 CFX_ByteString sStream(pData, acc.GetSize()); | 495 CFX_ByteString sStream(pData, acc.GetSize()); |
496 CFX_ByteString sTemp; | 496 CFX_ByteString sTemp; |
497 | 497 |
498 if (matrix.IsIdentity()) { | 498 if (matrix.IsIdentity()) { |
499 matrix.a = 1.0f; | 499 matrix.a = 1.0f; |
(...skipping 12 matching lines...) Expand all Loading... |
512 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 512 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
513 FALSE); | 513 FALSE); |
514 } | 514 } |
515 pPageDict->RemoveAt("Annots"); | 515 pPageDict->RemoveAt("Annots"); |
516 | 516 |
517 ObjectArray.RemoveAll(); | 517 ObjectArray.RemoveAll(); |
518 RectArray.RemoveAll(); | 518 RectArray.RemoveAll(); |
519 | 519 |
520 return FLATTEN_SUCCESS; | 520 return FLATTEN_SUCCESS; |
521 } | 521 } |
OLD | NEW |