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

Side by Side Diff: fpdfsdk/src/fpdfeditpage.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_edit.h" 7 #include "../../public/fpdf_edit.h"
8 #include "../../public/fpdf_formfill.h" 8 #include "../../public/fpdf_formfill.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 10
(...skipping 26 matching lines...) Expand all
37 if (pInfoDict) { 37 if (pInfoDict) {
38 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 38 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
39 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr)); 39 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr));
40 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); 40 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
41 } 41 }
42 42
43 return pDoc; 43 return pDoc;
44 } 44 }
45 45
46 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { 46 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
47 CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document); 47 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
48 if (!pDoc || page_index < 0 || page_index >= pDoc->GetPageCount()) 48 if (!pDoc || page_index < 0 || page_index >= pDoc->GetPageCount())
49 return; 49 return;
50 50
51 pDoc->DeletePage(page_index); 51 pDoc->DeletePage(page_index);
52 } 52 }
53 53
54 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, 54 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
55 int page_index, 55 int page_index,
56 double width, 56 double width,
57 double height) { 57 double height) {
58 CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document); 58 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
59 if (!pDoc) 59 if (!pDoc)
60 return nullptr; 60 return nullptr;
61 61
62 if (page_index < 0) 62 if (page_index < 0)
63 page_index = 0; 63 page_index = 0;
64 if (pDoc->GetPageCount() < page_index) 64 if (pDoc->GetPageCount() < page_index)
65 page_index = pDoc->GetPageCount(); 65 page_index = pDoc->GetPageCount();
66 66
67 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); 67 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
68 if (!pPageDict) 68 if (!pPageDict)
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 315 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
316 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 316 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
317 "Page")) { 317 "Page")) {
318 return; 318 return;
319 } 319 }
320 CPDF_Dictionary* pDict = pPage->m_pFormDict; 320 CPDF_Dictionary* pDict = pPage->m_pFormDict;
321 rotate %= 4; 321 rotate %= 4;
322 322
323 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); 323 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
324 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698