| 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_doc.h" | 7 #include "core/include/fpdfdoc/fpdf_doc.h" |
| 8 #include "doc_utils.h" | 8 #include "doc_utils.h" |
| 9 | 9 |
| 10 static const int FPDFDOC_UTILS_MAXRECURSION = 32; | 10 static const int FPDFDOC_UTILS_MAXRECURSION = 32; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 tm.Set(f[0], f[1], f[2], f[3], f[4], f[5]); | 222 tm.Set(f[0], f[1], f[2], f[3], f[4], f[5]); |
| 223 } | 223 } |
| 224 return tm; | 224 return tm; |
| 225 } | 225 } |
| 226 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { | 226 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { |
| 227 if (!pDocument) { | 227 if (!pDocument) { |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 if (!pFormDict) { | 230 if (!pFormDict) { |
| 231 pFormDict = CPDF_Dictionary::Create(); | 231 pFormDict = new CPDF_Dictionary; |
| 232 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pFormDict); | 232 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pFormDict); |
| 233 CPDF_Dictionary* pRoot = pDocument->GetRoot(); | 233 CPDF_Dictionary* pRoot = pDocument->GetRoot(); |
| 234 pRoot->SetAtReference("AcroForm", pDocument, dwObjNum); | 234 pRoot->SetAtReference("AcroForm", pDocument, dwObjNum); |
| 235 } | 235 } |
| 236 CFX_ByteString csDA; | 236 CFX_ByteString csDA; |
| 237 if (!pFormDict->KeyExist("DR")) { | 237 if (!pFormDict->KeyExist("DR")) { |
| 238 CPDF_Font* pFont = NULL; | 238 CPDF_Font* pFont = NULL; |
| 239 CFX_ByteString csBaseName, csDefault; | 239 CFX_ByteString csBaseName, csDefault; |
| 240 uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); | 240 uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); |
| 241 pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); | 241 pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 CFX_ByteString csTag; | 553 CFX_ByteString csTag; |
| 554 if (FindInterFormFont(pFormDict, pFont, csTag)) { | 554 if (FindInterFormFont(pFormDict, pFont, csTag)) { |
| 555 csNameTag = csTag; | 555 csNameTag = csTag; |
| 556 return; | 556 return; |
| 557 } | 557 } |
| 558 if (!pFormDict) { | 558 if (!pFormDict) { |
| 559 InitInterFormDict(pFormDict, pDocument); | 559 InitInterFormDict(pFormDict, pDocument); |
| 560 } | 560 } |
| 561 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 561 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); |
| 562 if (!pDR) { | 562 if (!pDR) { |
| 563 pDR = CPDF_Dictionary::Create(); | 563 pDR = new CPDF_Dictionary; |
| 564 pFormDict->SetAt("DR", pDR); | 564 pFormDict->SetAt("DR", pDR); |
| 565 } | 565 } |
| 566 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 566 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); |
| 567 if (!pFonts) { | 567 if (!pFonts) { |
| 568 pFonts = CPDF_Dictionary::Create(); | 568 pFonts = new CPDF_Dictionary; |
| 569 pDR->SetAt("Font", pFonts); | 569 pDR->SetAt("Font", pFonts); |
| 570 } | 570 } |
| 571 if (csNameTag.IsEmpty()) { | 571 if (csNameTag.IsEmpty()) { |
| 572 csNameTag = pFont->GetBaseFont(); | 572 csNameTag = pFont->GetBaseFont(); |
| 573 } | 573 } |
| 574 csNameTag.Remove(' '); | 574 csNameTag.Remove(' '); |
| 575 csNameTag = | 575 csNameTag = |
| 576 CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag); | 576 CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag); |
| 577 pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict()); | 577 pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict()); |
| 578 } | 578 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); | 712 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); |
| 713 if (pAttr) { | 713 if (pAttr) { |
| 714 return pAttr; | 714 return pAttr; |
| 715 } | 715 } |
| 716 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); | 716 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); |
| 717 if (!pParent) { | 717 if (!pParent) { |
| 718 return NULL; | 718 return NULL; |
| 719 } | 719 } |
| 720 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); | 720 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); |
| 721 } | 721 } |
| OLD | NEW |