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_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 Loading... |
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 Loading... |
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 } |
OLD | NEW |