| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (pAPDic->KeyExist("Rect")) | 401 if (pAPDic->KeyExist("Rect")) |
| 402 rcStream = pAPDic->GetRectFor("Rect"); | 402 rcStream = pAPDic->GetRectFor("Rect"); |
| 403 else if (pAPDic->KeyExist("BBox")) | 403 else if (pAPDic->KeyExist("BBox")) |
| 404 rcStream = pAPDic->GetRectFor("BBox"); | 404 rcStream = pAPDic->GetRectFor("BBox"); |
| 405 | 405 |
| 406 if (rcStream.IsEmpty()) | 406 if (rcStream.IsEmpty()) |
| 407 continue; | 407 continue; |
| 408 | 408 |
| 409 CPDF_Object* pObj = pAPStream; | 409 CPDF_Object* pObj = pAPStream; |
| 410 if (pObj->IsInline()) { | 410 if (pObj->IsInline()) { |
| 411 pObj = pObj->Clone(); | 411 std::unique_ptr<CPDF_Object> pNew = pObj->Clone(); |
| 412 pDocument->AddIndirectObject(pObj); | 412 pObj = pNew.get(); |
| 413 pDocument->AddIndirectObject(pNew.release()); |
| 413 } | 414 } |
| 414 | 415 |
| 415 CPDF_Dictionary* pObjDic = pObj->GetDict(); | 416 CPDF_Dictionary* pObjDic = pObj->GetDict(); |
| 416 if (pObjDic) { | 417 if (pObjDic) { |
| 417 pObjDic->SetNameFor("Type", "XObject"); | 418 pObjDic->SetNameFor("Type", "XObject"); |
| 418 pObjDic->SetNameFor("Subtype", "Form"); | 419 pObjDic->SetNameFor("Subtype", "Form"); |
| 419 } | 420 } |
| 420 | 421 |
| 421 CPDF_Dictionary* pXObject = pNewXORes->GetDictFor("XObject"); | 422 CPDF_Dictionary* pXObject = pNewXORes->GetDictFor("XObject"); |
| 422 if (!pXObject) { | 423 if (!pXObject) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 448 sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, | 449 sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, |
| 449 sFormName.c_str()); | 450 sFormName.c_str()); |
| 450 sStream += sTemp; | 451 sStream += sTemp; |
| 451 pNewXObject->SetData(sStream.raw_str(), sStream.GetLength()); | 452 pNewXObject->SetData(sStream.raw_str(), sStream.GetLength()); |
| 452 } | 453 } |
| 453 pPageDict->RemoveFor("Annots"); | 454 pPageDict->RemoveFor("Annots"); |
| 454 | 455 |
| 455 RectArray.RemoveAll(); | 456 RectArray.RemoveAll(); |
| 456 return FLATTEN_SUCCESS; | 457 return FLATTEN_SUCCESS; |
| 457 } | 458 } |
| OLD | NEW |