| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // Set the document information | 47 // Set the document information |
| 48 CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo(); | 48 CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo(); |
| 49 if (!DInfoDict) | 49 if (!DInfoDict) |
| 50 return FALSE; | 50 return FALSE; |
| 51 | 51 |
| 52 CFX_ByteString producerstr; | 52 CFX_ByteString producerstr; |
| 53 producerstr.Format("PDFium"); | 53 producerstr.Format("PDFium"); |
| 54 DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE)); | 54 DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE)); |
| 55 | 55 |
| 56 // Set type | 56 // Set type |
| 57 CFX_ByteString cbRootType = pNewRoot->GetString("Type", ""); | 57 CFX_ByteString cbRootType = pNewRoot->GetStringBy("Type", ""); |
| 58 if (cbRootType.Equal("")) { | 58 if (cbRootType.Equal("")) { |
| 59 pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); | 59 pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); |
| 60 } | 60 } |
| 61 | 61 |
| 62 CPDF_Object* pElement = pNewRoot->GetElement("Pages"); | 62 CPDF_Object* pElement = pNewRoot->GetElement("Pages"); |
| 63 CPDF_Dictionary* pNewPages = | 63 CPDF_Dictionary* pNewPages = |
| 64 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; | 64 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; |
| 65 if (!pNewPages) { | 65 if (!pNewPages) { |
| 66 pNewPages = new CPDF_Dictionary; | 66 pNewPages = new CPDF_Dictionary; |
| 67 FX_DWORD NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); | 67 FX_DWORD NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); |
| 68 pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); | 68 pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 CFX_ByteString cbPageType = pNewPages->GetString("Type", ""); | 71 CFX_ByteString cbPageType = pNewPages->GetStringBy("Type", ""); |
| 72 if (cbPageType.Equal("")) { | 72 if (cbPageType.Equal("")) { |
| 73 pNewPages->SetAt("Type", new CPDF_Name("Pages")); | 73 pNewPages->SetAt("Type", new CPDF_Name("Pages")); |
| 74 } | 74 } |
| 75 | 75 |
| 76 CPDF_Array* pKeysArray = pNewPages->GetArray("Kids"); | 76 CPDF_Array* pKeysArray = pNewPages->GetArrayBy("Kids"); |
| 77 if (!pKeysArray) { | 77 if (!pKeysArray) { |
| 78 CPDF_Array* pNewKids = new CPDF_Array; | 78 CPDF_Array* pNewKids = new CPDF_Array; |
| 79 FX_DWORD Kidsobjnum = -1; | 79 FX_DWORD Kidsobjnum = -1; |
| 80 Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids); | 80 Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids); |
| 81 | 81 |
| 82 pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); | 82 pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); |
| 83 pNewPages->SetAt("Count", new CPDF_Number(0)); | 83 pNewPages->SetAt("Count", new CPDF_Number(0)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 return TRUE; | 86 return TRUE; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 CPDF_Object* pDirect = pRef->GetDirect(); | 278 CPDF_Object* pDirect = pRef->GetDirect(); |
| 279 if (!pDirect) | 279 if (!pDirect) |
| 280 return 0; | 280 return 0; |
| 281 | 281 |
| 282 CPDF_Object* pClone = pDirect->Clone(); | 282 CPDF_Object* pClone = pDirect->Clone(); |
| 283 if (!pClone) | 283 if (!pClone) |
| 284 return 0; | 284 return 0; |
| 285 | 285 |
| 286 if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) { | 286 if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) { |
| 287 if (pDictClone->KeyExist("Type")) { | 287 if (pDictClone->KeyExist("Type")) { |
| 288 CFX_ByteString strType = pDictClone->GetString("Type"); | 288 CFX_ByteString strType = pDictClone->GetStringBy("Type"); |
| 289 if (!FXSYS_stricmp(strType, "Pages")) { | 289 if (!FXSYS_stricmp(strType, "Pages")) { |
| 290 pDictClone->Release(); | 290 pDictClone->Release(); |
| 291 return 4; | 291 return 4; |
| 292 } | 292 } |
| 293 if (!FXSYS_stricmp(strType, "Page")) { | 293 if (!FXSYS_stricmp(strType, "Page")) { |
| 294 pDictClone->Release(); | 294 pDictClone->Release(); |
| 295 return 0; | 295 return 0; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 } | 298 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 FPDF_DOCUMENT src_doc) { | 387 FPDF_DOCUMENT src_doc) { |
| 388 CPDF_Document* pDstDoc = CPDFDocumentFromFPDFDocument(dest_doc); | 388 CPDF_Document* pDstDoc = CPDFDocumentFromFPDFDocument(dest_doc); |
| 389 if (!pDstDoc) | 389 if (!pDstDoc) |
| 390 return FALSE; | 390 return FALSE; |
| 391 | 391 |
| 392 CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc); | 392 CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc); |
| 393 if (!pSrcDoc) | 393 if (!pSrcDoc) |
| 394 return FALSE; | 394 return FALSE; |
| 395 | 395 |
| 396 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); | 396 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); |
| 397 pSrcDict = pSrcDict->GetDict("ViewerPreferences"); | 397 pSrcDict = pSrcDict->GetDictBy("ViewerPreferences"); |
| 398 if (!pSrcDict) | 398 if (!pSrcDict) |
| 399 return FALSE; | 399 return FALSE; |
| 400 | 400 |
| 401 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); | 401 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); |
| 402 if (!pDstDict) | 402 if (!pDstDict) |
| 403 return FALSE; | 403 return FALSE; |
| 404 | 404 |
| 405 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); | 405 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); |
| 406 return TRUE; | 406 return TRUE; |
| 407 } | 407 } |
| OLD | NEW |