Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Side by Side Diff: fpdfsdk/src/fpdfppo.cpp

Issue 1395493007: Introduce CPDF_Document::FromFPDFDocument(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fpdfformfill.cpp ('k') | fpdfsdk/src/fpdfsave.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../third_party/base/nonstd_unique_ptr.h" 8 #include "../../third_party/base/nonstd_unique_ptr.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 10
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 nStringFrom = nStringTo + 1; 362 nStringFrom = nStringTo + 1;
363 } 363 }
364 } 364 }
365 return TRUE; 365 return TRUE;
366 } 366 }
367 367
368 DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, 368 DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
369 FPDF_DOCUMENT src_doc, 369 FPDF_DOCUMENT src_doc,
370 FPDF_BYTESTRING pagerange, 370 FPDF_BYTESTRING pagerange,
371 int index) { 371 int index) {
372 if (!dest_doc || !src_doc) 372 CPDF_Document* pDestDoc = CPDF_Document::FromFPDFDocument(dest_doc);
373 if (!dest_doc)
374 return FALSE;
375
376 CPDF_Document* pSrcDoc = CPDF_Document::FromFPDFDocument(src_doc);
377 if (!pSrcDoc)
373 return FALSE; 378 return FALSE;
374 379
375 CFX_WordArray pageArray; 380 CFX_WordArray pageArray;
376 CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
377 int nCount = pSrcDoc->GetPageCount(); 381 int nCount = pSrcDoc->GetPageCount();
378 if (pagerange) { 382 if (pagerange) {
379 if (!ParserPageRangeString(pagerange, &pageArray, nCount)) 383 if (!ParserPageRangeString(pagerange, &pageArray, nCount))
380 return FALSE; 384 return FALSE;
381 } else { 385 } else {
382 for (int i = 1; i <= nCount; ++i) { 386 for (int i = 1; i <= nCount; ++i) {
383 pageArray.Add(i); 387 pageArray.Add(i);
384 } 388 }
385 } 389 }
386 390
387 CPDF_Document* pDestDoc = (CPDF_Document*)dest_doc;
388 CPDF_PageOrganizer pageOrg; 391 CPDF_PageOrganizer pageOrg;
389
390 pageOrg.PDFDocInit(pDestDoc, pSrcDoc); 392 pageOrg.PDFDocInit(pDestDoc, pSrcDoc);
391
392 return pageOrg.ExportPage(pSrcDoc, &pageArray, pDestDoc, index); 393 return pageOrg.ExportPage(pSrcDoc, &pageArray, pDestDoc, index);
393 } 394 }
394 395
395 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, 396 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc,
396 FPDF_DOCUMENT src_doc) { 397 FPDF_DOCUMENT src_doc) {
397 if (!src_doc || !dest_doc) 398 CPDF_Document* pDstDoc = CPDF_Document::FromFPDFDocument(dest_doc);
398 return false; 399 if (!pDstDoc)
400 return FALSE;
399 401
400 CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc; 402 CPDF_Document* pSrcDoc = CPDF_Document::FromFPDFDocument(src_doc);
403 if (!pSrcDoc)
404 return FALSE;
405
401 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); 406 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot();
402 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences")); 407 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));
403 ;
404 if (!pSrcDict) 408 if (!pSrcDict)
405 return FALSE; 409 return FALSE;
406 410
407 CPDF_Document* pDstDoc = (CPDF_Document*)dest_doc;
408 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 411 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
409 if (!pDstDict) 412 if (!pDstDict)
410 return FALSE; 413 return FALSE;
414
411 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE)); 415 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE));
412 return TRUE; 416 return TRUE;
413 } 417 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfformfill.cpp ('k') | fpdfsdk/src/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698