| 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 "core/include/fpdfdoc/fpdf_ap.h" | 7 #include "core/include/fpdfdoc/fpdf_ap.h" |
| 8 #include "core/include/fpdfdoc/fpdf_doc.h" | 8 #include "core/include/fpdfdoc/fpdf_doc.h" |
| 9 #include "core/include/fpdfdoc/fpdf_vt.h" | 9 #include "core/include/fpdfdoc/fpdf_vt.h" |
| 10 #include "doc_utils.h" | 10 #include "doc_utils.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 pDRFontDict = pDRDict->GetDict("Font"); | 304 pDRFontDict = pDRDict->GetDict("Font"); |
| 305 if (pDRFontDict) { | 305 if (pDRFontDict) { |
| 306 pFontDict = pDRFontDict->GetDict(sFontName.Mid(1)); | 306 pFontDict = pDRFontDict->GetDict(sFontName.Mid(1)); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 if (!pDRFontDict) { | 310 if (!pDRFontDict) { |
| 311 return FALSE; | 311 return FALSE; |
| 312 } | 312 } |
| 313 if (!pFontDict) { | 313 if (!pFontDict) { |
| 314 pFontDict = CPDF_Dictionary::Create(); | 314 pFontDict = new CPDF_Dictionary; |
| 315 if (!pFontDict) { | |
| 316 return FALSE; | |
| 317 } | |
| 318 pFontDict->SetAtName("Type", "Font"); | 315 pFontDict->SetAtName("Type", "Font"); |
| 319 pFontDict->SetAtName("Subtype", "Type1"); | 316 pFontDict->SetAtName("Subtype", "Type1"); |
| 320 pFontDict->SetAtName("BaseFont", "Helvetica"); | 317 pFontDict->SetAtName("BaseFont", "Helvetica"); |
| 321 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); | 318 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); |
| 322 pDoc->AddIndirectObject(pFontDict); | 319 pDoc->AddIndirectObject(pFontDict); |
| 323 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); | 320 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); |
| 324 } | 321 } |
| 325 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); | 322 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); |
| 326 if (!pDefFont) { | 323 if (!pDefFont) { |
| 327 return FALSE; | 324 return FALSE; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 dsBorder); | 409 dsBorder); |
| 413 if (sBorderStream.GetLength() > 0) { | 410 if (sBorderStream.GetLength() > 0) { |
| 414 sAppStream << "q\n" << sBorderStream << "Q\n"; | 411 sAppStream << "q\n" << sBorderStream << "Q\n"; |
| 415 } | 412 } |
| 416 CPDF_Rect rcBody = | 413 CPDF_Rect rcBody = |
| 417 CPDF_Rect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, | 414 CPDF_Rect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, |
| 418 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); | 415 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); |
| 419 rcBody.Normalize(); | 416 rcBody.Normalize(); |
| 420 CPDF_Dictionary* pAPDict = pAnnotDict->GetDict("AP"); | 417 CPDF_Dictionary* pAPDict = pAnnotDict->GetDict("AP"); |
| 421 if (!pAPDict) { | 418 if (!pAPDict) { |
| 422 pAPDict = CPDF_Dictionary::Create(); | 419 pAPDict = new CPDF_Dictionary; |
| 423 pAnnotDict->SetAt("AP", pAPDict); | 420 pAnnotDict->SetAt("AP", pAPDict); |
| 424 } | 421 } |
| 425 CPDF_Stream* pNormalStream = pAPDict->GetStream("N"); | 422 CPDF_Stream* pNormalStream = pAPDict->GetStream("N"); |
| 426 if (!pNormalStream) { | 423 if (!pNormalStream) { |
| 427 pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); | 424 pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); |
| 428 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); | 425 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); |
| 429 pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum); | 426 pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum); |
| 430 } | 427 } |
| 431 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); | 428 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); |
| 432 if (pStreamDict) { | 429 if (pStreamDict) { |
| 433 pStreamDict->SetAtMatrix("Matrix", matrix); | 430 pStreamDict->SetAtMatrix("Matrix", matrix); |
| 434 pStreamDict->SetAtRect("BBox", rcBBox); | 431 pStreamDict->SetAtRect("BBox", rcBBox); |
| 435 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 432 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
| 436 if (pStreamResList) { | 433 if (pStreamResList) { |
| 437 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font"); | 434 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font"); |
| 438 if (!pStreamResFontList) { | 435 if (!pStreamResFontList) { |
| 439 pStreamResFontList = CPDF_Dictionary::Create(); | 436 pStreamResFontList = new CPDF_Dictionary; |
| 440 if (!pStreamResFontList) { | |
| 441 return FALSE; | |
| 442 } | |
| 443 pStreamResList->SetAt("Font", pStreamResFontList); | 437 pStreamResList->SetAt("Font", pStreamResFontList); |
| 444 } | 438 } |
| 445 if (!pStreamResFontList->KeyExist(sFontName)) { | 439 if (!pStreamResFontList->KeyExist(sFontName)) { |
| 446 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); | 440 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); |
| 447 } | 441 } |
| 448 } else { | 442 } else { |
| 449 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); | 443 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); |
| 450 pStreamResList = pStreamDict->GetDict("Resources"); | 444 pStreamResList = pStreamDict->GetDict("Resources"); |
| 451 } | 445 } |
| 452 } | 446 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), | 671 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), |
| 678 sAppStream.GetSize(), FALSE, FALSE); | 672 sAppStream.GetSize(), FALSE, FALSE); |
| 679 pStreamDict = pNormalStream->GetDict(); | 673 pStreamDict = pNormalStream->GetDict(); |
| 680 if (pStreamDict) { | 674 if (pStreamDict) { |
| 681 pStreamDict->SetAtMatrix("Matrix", matrix); | 675 pStreamDict->SetAtMatrix("Matrix", matrix); |
| 682 pStreamDict->SetAtRect("BBox", rcBBox); | 676 pStreamDict->SetAtRect("BBox", rcBBox); |
| 683 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 677 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
| 684 if (pStreamResList) { | 678 if (pStreamResList) { |
| 685 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font"); | 679 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font"); |
| 686 if (!pStreamResFontList) { | 680 if (!pStreamResFontList) { |
| 687 pStreamResFontList = CPDF_Dictionary::Create(); | 681 pStreamResFontList = new CPDF_Dictionary; |
| 688 if (!pStreamResFontList) { | |
| 689 return FALSE; | |
| 690 } | |
| 691 pStreamResList->SetAt("Font", pStreamResFontList); | 682 pStreamResList->SetAt("Font", pStreamResFontList); |
| 692 } | 683 } |
| 693 if (!pStreamResFontList->KeyExist(sFontName)) { | 684 if (!pStreamResFontList->KeyExist(sFontName)) { |
| 694 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); | 685 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); |
| 695 } | 686 } |
| 696 } else { | 687 } else { |
| 697 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); | 688 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); |
| 698 pStreamResList = pStreamDict->GetDict("Resources"); | 689 pStreamResList = pStreamDict->GetDict("Resources"); |
| 699 } | 690 } |
| 700 } | 691 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 << "\n"; | 913 << "\n"; |
| 923 break; | 914 break; |
| 924 case CT_CMYK: | 915 case CT_CMYK: |
| 925 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 916 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 926 << color.fColor3 << " " << color.fColor4 << " " | 917 << color.fColor3 << " " << color.fColor4 << " " |
| 927 << (bFillOrStroke ? "k" : "K") << "\n"; | 918 << (bFillOrStroke ? "k" : "K") << "\n"; |
| 928 break; | 919 break; |
| 929 } | 920 } |
| 930 return sColorStream.GetByteString(); | 921 return sColorStream.GetByteString(); |
| 931 } | 922 } |
| OLD | NEW |