| 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 14 matching lines...) Expand all Loading... |
| 25 using ObjectNumberMap = std::map<uint32_t, uint32_t>; | 25 using ObjectNumberMap = std::map<uint32_t, uint32_t>; |
| 26 CPDF_PageOrganizer(); | 26 CPDF_PageOrganizer(); |
| 27 ~CPDF_PageOrganizer(); | 27 ~CPDF_PageOrganizer(); |
| 28 | 28 |
| 29 FX_BOOL PDFDocInit(CPDF_Document* pDestPDFDoc, CPDF_Document* pSrcPDFDoc); | 29 FX_BOOL PDFDocInit(CPDF_Document* pDestPDFDoc, CPDF_Document* pSrcPDFDoc); |
| 30 FX_BOOL ExportPage(CPDF_Document* pSrcPDFDoc, | 30 FX_BOOL ExportPage(CPDF_Document* pSrcPDFDoc, |
| 31 std::vector<uint16_t>* pPageNums, | 31 std::vector<uint16_t>* pPageNums, |
| 32 CPDF_Document* pDestPDFDoc, | 32 CPDF_Document* pDestPDFDoc, |
| 33 int nIndex); | 33 int nIndex); |
| 34 CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict, | 34 CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict, |
| 35 CFX_ByteString nSrctag); | 35 const CFX_ByteString& bsSrctag); |
| 36 FX_BOOL UpdateReference(CPDF_Object* pObj, | 36 FX_BOOL UpdateReference(CPDF_Object* pObj, |
| 37 CPDF_Document* pDoc, | 37 CPDF_Document* pDoc, |
| 38 ObjectNumberMap* pObjNumberMap); | 38 ObjectNumberMap* pObjNumberMap); |
| 39 uint32_t GetNewObjId(CPDF_Document* pDoc, | 39 uint32_t GetNewObjId(CPDF_Document* pDoc, |
| 40 ObjectNumberMap* pObjNumberMap, | 40 ObjectNumberMap* pObjNumberMap, |
| 41 CPDF_Reference* pRef); | 41 CPDF_Reference* pRef); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 CPDF_PageOrganizer::CPDF_PageOrganizer() {} | 44 CPDF_PageOrganizer::CPDF_PageOrganizer() {} |
| 45 | 45 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get()); | 169 UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get()); |
| 170 ++curpage; | 170 ++curpage; |
| 171 } | 171 } |
| 172 | 172 |
| 173 return TRUE; | 173 return TRUE; |
| 174 } | 174 } |
| 175 | 175 |
| 176 CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( | 176 CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( |
| 177 CPDF_Dictionary* pDict, | 177 CPDF_Dictionary* pDict, |
| 178 CFX_ByteString nSrctag) { | 178 const CFX_ByteString& bsSrcTag) { |
| 179 if (!pDict || nSrctag.IsEmpty()) | 179 if (!pDict || bsSrcTag.IsEmpty()) |
| 180 return nullptr; | 180 return nullptr; |
| 181 if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type")) | 181 if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type")) |
| 182 return nullptr; | 182 return nullptr; |
| 183 | 183 |
| 184 CPDF_Object* pType = pDict->GetObjectBy("Type")->GetDirect(); | 184 CPDF_Object* pType = pDict->GetObjectBy("Type")->GetDirect(); |
| 185 if (!ToName(pType)) | 185 if (!ToName(pType)) |
| 186 return nullptr; | 186 return nullptr; |
| 187 if (pType->GetString().Compare("Page")) | 187 if (pType->GetString().Compare("Page")) |
| 188 return nullptr; | 188 return nullptr; |
| 189 | 189 |
| 190 CPDF_Dictionary* pp = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect()); | 190 CPDF_Dictionary* pp = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect()); |
| 191 if (!pp) | 191 if (!pp) |
| 192 return nullptr; | 192 return nullptr; |
| 193 | 193 |
| 194 CFX_ByteStringC sSrcTag = nSrctag.AsStringC(); | 194 if (pDict->KeyExist(bsSrcTag)) |
| 195 if (pDict->KeyExist(sSrcTag)) | 195 return pDict->GetObjectBy(bsSrcTag); |
| 196 return pDict->GetObjectBy(sSrcTag); | |
| 197 | 196 |
| 198 while (pp) { | 197 while (pp) { |
| 199 if (pp->KeyExist(sSrcTag)) | 198 if (pp->KeyExist(bsSrcTag)) |
| 200 return pp->GetObjectBy(sSrcTag); | 199 return pp->GetObjectBy(bsSrcTag); |
| 201 if (!pp->KeyExist("Parent")) | 200 if (!pp->KeyExist("Parent")) |
| 202 break; | 201 break; |
| 203 pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect()); | 202 pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect()); |
| 204 } | 203 } |
| 205 return nullptr; | 204 return nullptr; |
| 206 } | 205 } |
| 207 | 206 |
| 208 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, | 207 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, |
| 209 CPDF_Document* pDoc, | 208 CPDF_Document* pDoc, |
| 210 ObjectNumberMap* pObjNumberMap) { | 209 ObjectNumberMap* pObjNumberMap) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 if (!pSrcDict) | 403 if (!pSrcDict) |
| 405 return FALSE; | 404 return FALSE; |
| 406 | 405 |
| 407 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); | 406 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); |
| 408 if (!pDstDict) | 407 if (!pDstDict) |
| 409 return FALSE; | 408 return FALSE; |
| 410 | 409 |
| 411 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); | 410 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); |
| 412 return TRUE; | 411 return TRUE; |
| 413 } | 412 } |
| OLD | NEW |