| 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 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 10 | 10 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 nStringFrom = nStringTo + 1; | 373 nStringFrom = nStringTo + 1; |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 return TRUE; | 376 return TRUE; |
| 377 } | 377 } |
| 378 | 378 |
| 379 DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, | 379 DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, |
| 380 FPDF_DOCUMENT src_doc, | 380 FPDF_DOCUMENT src_doc, |
| 381 FPDF_BYTESTRING pagerange, | 381 FPDF_BYTESTRING pagerange, |
| 382 int index) { | 382 int index) { |
| 383 if (dest_doc == NULL || src_doc == NULL) | 383 CPDF_Document* pDestDoc = CPDFDocumentFromFPDFDocument(dest_doc); |
| 384 if (!dest_doc) |
| 385 return FALSE; |
| 386 |
| 387 CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc); |
| 388 if (!pSrcDoc) |
| 384 return FALSE; | 389 return FALSE; |
| 385 CFX_WordArray pageArray; | 390 CFX_WordArray pageArray; |
| 386 CPDFXFA_Document* pSrcDoc = (CPDFXFA_Document*)src_doc; | 391 int nCount = pSrcDoc->GetPageCount(); |
| 387 CPDF_Document* pSrcPDFDoc = pSrcDoc->GetPDFDoc(); | |
| 388 int nCount = pSrcPDFDoc->GetPageCount(); | |
| 389 if (pagerange) { | 392 if (pagerange) { |
| 390 if (ParserPageRangeString(pagerange, &pageArray, nCount) == FALSE) | 393 if (ParserPageRangeString(pagerange, &pageArray, nCount) == FALSE) |
| 391 return FALSE; | 394 return FALSE; |
| 392 } else { | 395 } else { |
| 393 for (int i = 1; i <= nCount; i++) { | 396 for (int i = 1; i <= nCount; i++) { |
| 394 pageArray.Add(i); | 397 pageArray.Add(i); |
| 395 } | 398 } |
| 396 } | 399 } |
| 397 | 400 |
| 398 CPDFXFA_Document* pDestDoc = (CPDFXFA_Document*)dest_doc; | |
| 399 CPDF_Document* pDestPDFDoc = pDestDoc->GetPDFDoc(); | |
| 400 CPDF_PageOrganizer pageOrg; | 401 CPDF_PageOrganizer pageOrg; |
| 401 | 402 pageOrg.PDFDocInit(pDestDoc, pSrcDoc); |
| 402 pageOrg.PDFDocInit(pDestPDFDoc, pSrcPDFDoc); | 403 return pageOrg.ExportPage(pSrcDoc, &pageArray, pDestDoc, index); |
| 403 | |
| 404 if (pageOrg.ExportPage(pSrcPDFDoc, &pageArray, pDestPDFDoc, index)) | |
| 405 return TRUE; | |
| 406 return FALSE; | |
| 407 } | 404 } |
| 408 | 405 |
| 409 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, | 406 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, |
| 410 FPDF_DOCUMENT src_doc) { | 407 FPDF_DOCUMENT src_doc) { |
| 411 if (src_doc == NULL || dest_doc == NULL) | 408 CPDF_Document* pDstDoc = CPDFDocumentFromFPDFDocument(dest_doc); |
| 412 return false; | 409 if (!pDstDoc) |
| 413 CPDFXFA_Document* pSrcDoc = (CPDFXFA_Document*)src_doc; | 410 return FALSE; |
| 414 CPDF_Document* pSrcPDFDoc = pSrcDoc->GetPDFDoc(); | 411 |
| 415 CPDF_Dictionary* pSrcDict = pSrcPDFDoc->GetRoot(); | 412 CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc); |
| 413 if (!pSrcDoc) |
| 414 return FALSE; |
| 415 |
| 416 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); |
| 416 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences")); | 417 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences")); |
| 417 if (!pSrcDict) | 418 if (!pSrcDict) |
| 418 return FALSE; | 419 return FALSE; |
| 419 CPDFXFA_Document* pDstDoc = (CPDFXFA_Document*)dest_doc; | 420 |
| 420 CPDF_Document* pDstPDFDoc = pDstDoc->GetPDFDoc(); | 421 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); |
| 421 CPDF_Dictionary* pDstDict = pDstPDFDoc->GetRoot(); | |
| 422 if (!pDstDict) | 422 if (!pDstDict) |
| 423 return FALSE; | 423 return FALSE; |
| 424 |
| 424 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE)); | 425 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE)); |
| 425 return TRUE; | 426 return TRUE; |
| 426 } | 427 } |
| OLD | NEW |