OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" | 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 CPDF_Document* pDocument, | 52 CPDF_Document* pDocument, |
53 const CPDF_Font* pFont, | 53 const CPDF_Font* pFont, |
54 CFX_ByteString& csNameTag); | 54 CFX_ByteString& csNameTag); |
55 | 55 |
56 void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { | 56 void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { |
57 if (!pDocument) | 57 if (!pDocument) |
58 return; | 58 return; |
59 | 59 |
60 if (!pFormDict) { | 60 if (!pFormDict) { |
61 pFormDict = new CPDF_Dictionary; | 61 pFormDict = new CPDF_Dictionary; |
62 uint32_t dwObjNum = pDocument->AddIndirectObject(pFormDict); | 62 pDocument->GetRoot()->SetReferenceFor( |
63 CPDF_Dictionary* pRoot = pDocument->GetRoot(); | 63 "AcroForm", pDocument, pDocument->AddIndirectObject(pFormDict)); |
64 pRoot->SetReferenceFor("AcroForm", pDocument, dwObjNum); | |
65 } | 64 } |
66 | 65 |
67 CFX_ByteString csDA; | 66 CFX_ByteString csDA; |
68 if (!pFormDict->KeyExist("DR")) { | 67 if (!pFormDict->KeyExist("DR")) { |
69 CFX_ByteString csBaseName; | 68 CFX_ByteString csBaseName; |
70 CFX_ByteString csDefault; | 69 CFX_ByteString csDefault; |
71 uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); | 70 uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); |
72 CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); | 71 CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); |
73 if (pFont) { | 72 if (pFont) { |
74 AddFont(pFormDict, pDocument, pFont, csBaseName); | 73 AddFont(pFormDict, pDocument, pFont, csBaseName); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (!pFonts) { | 398 if (!pFonts) { |
400 pFonts = new CPDF_Dictionary; | 399 pFonts = new CPDF_Dictionary; |
401 pDR->SetFor("Font", pFonts); | 400 pDR->SetFor("Font", pFonts); |
402 } | 401 } |
403 if (csNameTag.IsEmpty()) | 402 if (csNameTag.IsEmpty()) |
404 csNameTag = pFont->GetBaseFont(); | 403 csNameTag = pFont->GetBaseFont(); |
405 | 404 |
406 csNameTag.Remove(' '); | 405 csNameTag.Remove(' '); |
407 csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, | 406 csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, |
408 csNameTag.c_str()); | 407 csNameTag.c_str()); |
409 pFonts->SetReferenceFor(csNameTag, pDocument, pFont->GetFontDict()); | 408 pFonts->SetReferenceFor(csNameTag, pDocument, |
| 409 pFont->GetFontDict()->GetObjNum()); |
410 } | 410 } |
411 | 411 |
412 CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, | 412 CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict, |
413 CPDF_Document* pDocument, | 413 CPDF_Document* pDocument, |
414 uint8_t charSet, | 414 uint8_t charSet, |
415 CFX_ByteString& csNameTag) { | 415 CFX_ByteString& csNameTag) { |
416 if (!pFormDict) | 416 if (!pFormDict) |
417 InitDict(pFormDict, pDocument); | 417 InitDict(pFormDict, pDocument); |
418 | 418 |
419 CFX_ByteString csTemp; | 419 CFX_ByteString csTemp; |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 FDF_ImportField(pField, L"", bNotify); | 1624 FDF_ImportField(pField, L"", bNotify); |
1625 } | 1625 } |
1626 if (bNotify && m_pFormNotify) | 1626 if (bNotify && m_pFormNotify) |
1627 m_pFormNotify->AfterFormImportData(this); | 1627 m_pFormNotify->AfterFormImportData(this); |
1628 return TRUE; | 1628 return TRUE; |
1629 } | 1629 } |
1630 | 1630 |
1631 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { | 1631 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { |
1632 m_pFormNotify = pNotify; | 1632 m_pFormNotify = pNotify; |
1633 } | 1633 } |
OLD | NEW |