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

Side by Side Diff: fpdfsdk/src/fpdfeditpage.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/fpdfeditimg.cpp ('k') | fpdfsdk/src/fpdfformfill.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_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*)document; 47 CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
48 if (pDoc == NULL) 48 if (!pDoc || page_index < 0 || page_index >= pDoc->GetPageCount())
49 return;
50 if (page_index < 0 || page_index >= pDoc->GetPageCount())
51 return; 49 return;
52 50
53 pDoc->DeletePage(page_index); 51 pDoc->DeletePage(page_index);
54 } 52 }
55 53
56 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, 54 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
57 int page_index, 55 int page_index,
58 double width, 56 double width,
59 double height) { 57 double height) {
60 if (!document) 58 CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
61 return NULL; 59 if (!pDoc)
60 return nullptr;
62 61
63 // CPDF_Parser* pParser = (CPDF_Parser*)document;
64 CPDF_Document* pDoc = (CPDF_Document*)document;
65 if (page_index < 0) 62 if (page_index < 0)
66 page_index = 0; 63 page_index = 0;
67 if (pDoc->GetPageCount() < page_index) 64 if (pDoc->GetPageCount() < page_index)
68 page_index = pDoc->GetPageCount(); 65 page_index = pDoc->GetPageCount();
69 // if (page_index < 0 || page_index >= pDoc->GetPageCount())
70 // return NULL;
71 66
72 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); 67 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
73 if (!pPageDict) 68 if (!pPageDict)
74 return NULL; 69 return NULL;
75 CPDF_Array* pMediaBoxArray = new CPDF_Array; 70 CPDF_Array* pMediaBoxArray = new CPDF_Array;
76 pMediaBoxArray->Add(new CPDF_Number(0)); 71 pMediaBoxArray->Add(new CPDF_Number(0));
77 pMediaBoxArray->Add(new CPDF_Number(0)); 72 pMediaBoxArray->Add(new CPDF_Number(0));
78 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); 73 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
79 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); 74 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));
80 75
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 315 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
321 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 316 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
322 "Page")) { 317 "Page")) {
323 return; 318 return;
324 } 319 }
325 CPDF_Dictionary* pDict = pPage->m_pFormDict; 320 CPDF_Dictionary* pDict = pPage->m_pFormDict;
326 rotate %= 4; 321 rotate %= 4;
327 322
328 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); 323 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
329 } 324 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfeditimg.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698