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