| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 CPDF_Dictionary* pNewRoot = m_pDestPDFDoc->GetRoot(); | 153 CPDF_Dictionary* pNewRoot = m_pDestPDFDoc->GetRoot(); |
| 154 if (!pNewRoot) | 154 if (!pNewRoot) |
| 155 return false; | 155 return false; |
| 156 | 156 |
| 157 CPDF_Dictionary* pDocInfoDict = m_pDestPDFDoc->GetInfo(); | 157 CPDF_Dictionary* pDocInfoDict = m_pDestPDFDoc->GetInfo(); |
| 158 if (!pDocInfoDict) | 158 if (!pDocInfoDict) |
| 159 return false; | 159 return false; |
| 160 | 160 |
| 161 CFX_ByteString producerstr; | 161 CFX_ByteString producerstr; |
| 162 producerstr.Format("PDFium"); | 162 producerstr.Format("PDFium"); |
| 163 pDocInfoDict->SetFor("Producer", new CPDF_String(producerstr, false)); | 163 pDocInfoDict->SetFor("Producer", |
| 164 new CPDF_String(nullptr, producerstr, false)); |
| 164 | 165 |
| 165 CFX_ByteString cbRootType = pNewRoot->GetStringFor("Type", ""); | 166 CFX_ByteString cbRootType = pNewRoot->GetStringFor("Type", ""); |
| 166 if (cbRootType.IsEmpty()) | 167 if (cbRootType.IsEmpty()) |
| 167 pNewRoot->SetFor("Type", new CPDF_Name("Catalog")); | 168 pNewRoot->SetFor("Type", new CPDF_Name(nullptr, "Catalog")); |
| 168 | 169 |
| 169 CPDF_Object* pElement = pNewRoot->GetObjectFor("Pages"); | 170 CPDF_Object* pElement = pNewRoot->GetObjectFor("Pages"); |
| 170 CPDF_Dictionary* pNewPages = | 171 CPDF_Dictionary* pNewPages = |
| 171 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; | 172 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; |
| 172 if (!pNewPages) { | 173 if (!pNewPages) { |
| 173 pNewPages = m_pDestPDFDoc->NewIndirect<CPDF_Dictionary>( | 174 pNewPages = m_pDestPDFDoc->NewIndirect<CPDF_Dictionary>(); |
| 174 m_pDestPDFDoc->GetByteStringPool()); | |
| 175 pNewRoot->SetReferenceFor("Pages", m_pDestPDFDoc, pNewPages); | 175 pNewRoot->SetReferenceFor("Pages", m_pDestPDFDoc, pNewPages); |
| 176 } | 176 } |
| 177 | 177 |
| 178 CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", ""); | 178 CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", ""); |
| 179 if (cbPageType.IsEmpty()) | 179 if (cbPageType.IsEmpty()) |
| 180 pNewPages->SetFor("Type", new CPDF_Name("Pages")); | 180 pNewPages->SetFor("Type", new CPDF_Name(nullptr, "Pages")); |
| 181 | 181 |
| 182 if (!pNewPages->GetArrayFor("Kids")) { | 182 if (!pNewPages->GetArrayFor("Kids")) { |
| 183 pNewPages->SetIntegerFor("Count", 0); | 183 pNewPages->SetIntegerFor("Count", 0); |
| 184 pNewPages->SetReferenceFor("Kids", m_pDestPDFDoc, | 184 pNewPages->SetReferenceFor("Kids", m_pDestPDFDoc, |
| 185 m_pDestPDFDoc->NewIndirect<CPDF_Array>()); | 185 m_pDestPDFDoc->NewIndirect<CPDF_Array>()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 | 190 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return false; | 383 return false; |
| 384 | 384 |
| 385 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); | 385 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); |
| 386 if (!pDstDict) | 386 if (!pDstDict) |
| 387 return false; | 387 return false; |
| 388 | 388 |
| 389 pDstDict->SetFor("ViewerPreferences", | 389 pDstDict->SetFor("ViewerPreferences", |
| 390 pSrcDict->CloneDirectObject().release()); | 390 pSrcDict->CloneDirectObject().release()); |
| 391 return true; | 391 return true; |
| 392 } | 392 } |
| OLD | NEW |