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

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

Issue 1396283006: Fix layering violation in 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
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 CPDF_Document* pDestDoc = CPDF_Document::FromFPDFDocument(dest_doc); 372 CPDF_Document* pDestDoc = CPDFDocumentFromFPDFDocument(dest_doc);
373 if (!dest_doc) 373 if (!dest_doc)
374 return FALSE; 374 return FALSE;
375 375
376 CPDF_Document* pSrcDoc = CPDF_Document::FromFPDFDocument(src_doc); 376 CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc);
377 if (!pSrcDoc) 377 if (!pSrcDoc)
378 return FALSE; 378 return FALSE;
379 379
380 CFX_WordArray pageArray; 380 CFX_WordArray pageArray;
381 int nCount = pSrcDoc->GetPageCount(); 381 int nCount = pSrcDoc->GetPageCount();
382 if (pagerange) { 382 if (pagerange) {
383 if (!ParserPageRangeString(pagerange, &pageArray, nCount)) 383 if (!ParserPageRangeString(pagerange, &pageArray, nCount))
384 return FALSE; 384 return FALSE;
385 } else { 385 } else {
386 for (int i = 1; i <= nCount; ++i) { 386 for (int i = 1; i <= nCount; ++i) {
387 pageArray.Add(i); 387 pageArray.Add(i);
388 } 388 }
389 } 389 }
390 390
391 CPDF_PageOrganizer pageOrg; 391 CPDF_PageOrganizer pageOrg;
392 pageOrg.PDFDocInit(pDestDoc, pSrcDoc); 392 pageOrg.PDFDocInit(pDestDoc, pSrcDoc);
393 return pageOrg.ExportPage(pSrcDoc, &pageArray, pDestDoc, index); 393 return pageOrg.ExportPage(pSrcDoc, &pageArray, pDestDoc, index);
394 } 394 }
395 395
396 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, 396 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc,
397 FPDF_DOCUMENT src_doc) { 397 FPDF_DOCUMENT src_doc) {
398 CPDF_Document* pDstDoc = CPDF_Document::FromFPDFDocument(dest_doc); 398 CPDF_Document* pDstDoc = CPDFDocumentFromFPDFDocument(dest_doc);
399 if (!pDstDoc) 399 if (!pDstDoc)
400 return FALSE; 400 return FALSE;
401 401
402 CPDF_Document* pSrcDoc = CPDF_Document::FromFPDFDocument(src_doc); 402 CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc);
403 if (!pSrcDoc) 403 if (!pSrcDoc)
404 return FALSE; 404 return FALSE;
405 405
406 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); 406 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot();
407 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences")); 407 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));
408 if (!pSrcDict) 408 if (!pSrcDict)
409 return FALSE; 409 return FALSE;
410 410
411 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 411 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
412 if (!pDstDict) 412 if (!pDstDict)
413 return FALSE; 413 return FALSE;
414 414
415 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE)); 415 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE));
416 return TRUE; 416 return TRUE;
417 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698