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_ppo.h" | 7 #include "public/fpdf_ppo.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo(); | 58 CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo(); |
59 if (!DInfoDict) | 59 if (!DInfoDict) |
60 return FALSE; | 60 return FALSE; |
61 | 61 |
62 CFX_ByteString producerstr; | 62 CFX_ByteString producerstr; |
63 producerstr.Format("PDFium"); | 63 producerstr.Format("PDFium"); |
64 DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE)); | 64 DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE)); |
65 | 65 |
66 // Set type | 66 // Set type |
67 CFX_ByteString cbRootType = pNewRoot->GetStringBy("Type", ""); | 67 CFX_ByteString cbRootType = pNewRoot->GetStringBy("Type", ""); |
68 if (cbRootType.Equal("")) { | 68 if (cbRootType == "") { |
Lei Zhang
2016/04/01 01:02:36
Replace with IsEmpty()?
Tom Sepez
2016/04/01 17:06:12
Done.
| |
69 pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); | 69 pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); |
70 } | 70 } |
71 | 71 |
72 CPDF_Object* pElement = pNewRoot->GetObjectBy("Pages"); | 72 CPDF_Object* pElement = pNewRoot->GetObjectBy("Pages"); |
73 CPDF_Dictionary* pNewPages = | 73 CPDF_Dictionary* pNewPages = |
74 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; | 74 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; |
75 if (!pNewPages) { | 75 if (!pNewPages) { |
76 pNewPages = new CPDF_Dictionary; | 76 pNewPages = new CPDF_Dictionary; |
77 uint32_t NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); | 77 uint32_t NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); |
78 pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); | 78 pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); |
79 } | 79 } |
80 | 80 |
81 CFX_ByteString cbPageType = pNewPages->GetStringBy("Type", ""); | 81 CFX_ByteString cbPageType = pNewPages->GetStringBy("Type", ""); |
82 if (cbPageType.Equal("")) { | 82 if (cbPageType == "") { |
83 pNewPages->SetAt("Type", new CPDF_Name("Pages")); | 83 pNewPages->SetAt("Type", new CPDF_Name("Pages")); |
84 } | 84 } |
85 | 85 |
86 CPDF_Array* pKeysArray = pNewPages->GetArrayBy("Kids"); | 86 CPDF_Array* pKeysArray = pNewPages->GetArrayBy("Kids"); |
87 if (!pKeysArray) { | 87 if (!pKeysArray) { |
88 CPDF_Array* pNewKids = new CPDF_Array; | 88 CPDF_Array* pNewKids = new CPDF_Array; |
89 uint32_t Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids); | 89 uint32_t Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids); |
90 | 90 |
91 pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); | 91 pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); |
92 pNewPages->SetAt("Count", new CPDF_Number(0)); | 92 pNewPages->SetAt("Count", new CPDF_Number(0)); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 if (!pSrcDict) | 406 if (!pSrcDict) |
407 return FALSE; | 407 return FALSE; |
408 | 408 |
409 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); | 409 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); |
410 if (!pDstDict) | 410 if (!pDstDict) |
411 return FALSE; | 411 return FALSE; |
412 | 412 |
413 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); | 413 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); |
414 return TRUE; | 414 return TRUE; |
415 } | 415 } |
OLD | NEW |