| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 int nSize = pdfium::CollectionSize<int>(*pPageNums); | 98 int nSize = pdfium::CollectionSize<int>(*pPageNums); |
| 99 for (int i = 0; i < nSize; ++i) { | 99 for (int i = 0; i < nSize; ++i) { |
| 100 CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); | 100 CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); |
| 101 CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(pPageNums->at(i) - 1); | 101 CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(pPageNums->at(i) - 1); |
| 102 if (!pSrcPageDict || !pCurPageDict) | 102 if (!pSrcPageDict || !pCurPageDict) |
| 103 return FALSE; | 103 return FALSE; |
| 104 | 104 |
| 105 // Clone the page dictionary | 105 // Clone the page dictionary |
| 106 for (const auto& it : *pSrcPageDict) { | 106 for (const auto& it : *pSrcPageDict) { |
| 107 const CFX_ByteString& cbSrcKeyStr = it.first; | 107 const CFX_ByteString& cbSrcKeyStr = it.first; |
| 108 CPDF_Object* pObj = it.second; | 108 CPDF_Object* pObj = it.second.get(); |
| 109 if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) { | 109 if (cbSrcKeyStr.Compare("Type") && cbSrcKeyStr.Compare("Parent")) { |
| 110 if (pCurPageDict->KeyExist(cbSrcKeyStr)) | 110 if (pCurPageDict->KeyExist(cbSrcKeyStr)) |
| 111 pCurPageDict->RemoveFor(cbSrcKeyStr); | 111 pCurPageDict->RemoveFor(cbSrcKeyStr); |
| 112 pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone()); | 112 pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone()); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 // inheritable item | 116 // inheritable item |
| 117 CPDF_Object* pInheritable = nullptr; | 117 CPDF_Object* pInheritable = nullptr; |
| 118 // 1 MediaBox //required | 118 // 1 MediaBox //required |
| 119 if (!pCurPageDict->KeyExist("MediaBox")) { | 119 if (!pCurPageDict->KeyExist("MediaBox")) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 if (newobjnum == 0) | 212 if (newobjnum == 0) |
| 213 return FALSE; | 213 return FALSE; |
| 214 pReference->SetRef(pDoc, newobjnum); | 214 pReference->SetRef(pDoc, newobjnum); |
| 215 break; | 215 break; |
| 216 } | 216 } |
| 217 case CPDF_Object::DICTIONARY: { | 217 case CPDF_Object::DICTIONARY: { |
| 218 CPDF_Dictionary* pDict = pObj->AsDictionary(); | 218 CPDF_Dictionary* pDict = pObj->AsDictionary(); |
| 219 auto it = pDict->begin(); | 219 auto it = pDict->begin(); |
| 220 while (it != pDict->end()) { | 220 while (it != pDict->end()) { |
| 221 const CFX_ByteString& key = it->first; | 221 const CFX_ByteString& key = it->first; |
| 222 CPDF_Object* pNextObj = it->second; | 222 CPDF_Object* pNextObj = it->second.get(); |
| 223 ++it; | 223 ++it; |
| 224 if (key == "Parent" || key == "Prev" || key == "First") | 224 if (key == "Parent" || key == "Prev" || key == "First") |
| 225 continue; | 225 continue; |
| 226 if (!pNextObj) | 226 if (!pNextObj) |
| 227 return FALSE; | 227 return FALSE; |
| 228 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) | 228 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) |
| 229 pDict->RemoveFor(key); | 229 pDict->RemoveFor(key); |
| 230 } | 230 } |
| 231 break; | 231 break; |
| 232 } | 232 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 if (!pSrcDict) | 396 if (!pSrcDict) |
| 397 return FALSE; | 397 return FALSE; |
| 398 | 398 |
| 399 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); | 399 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); |
| 400 if (!pDstDict) | 400 if (!pDstDict) |
| 401 return FALSE; | 401 return FALSE; |
| 402 | 402 |
| 403 pDstDict->SetFor("ViewerPreferences", pSrcDict->CloneDirectObject()); | 403 pDstDict->SetFor("ViewerPreferences", pSrcDict->CloneDirectObject()); |
| 404 return TRUE; | 404 return TRUE; |
| 405 } | 405 } |
| OLD | NEW |