| 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 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) | 41 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) |
| 42 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr)); | 42 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr)); |
| 43 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); | 43 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); |
| 44 } | 44 } |
| 45 | 45 |
| 46 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); | 46 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); |
| 47 return new CPDFXFA_Document(pDoc, pApp); | 47 return new CPDFXFA_Document(pDoc, pApp); |
| 48 } | 48 } |
| 49 | 49 |
| 50 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { | 50 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { |
| 51 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 51 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 52 if (pDoc == NULL) | 52 if (!pDoc || page_index < 0 || page_index >= pDoc->GetPageCount()) |
| 53 return; | |
| 54 if (page_index < 0 || page_index >= pDoc->GetPageCount()) | |
| 55 return; | 53 return; |
| 56 | 54 |
| 57 pDoc->DeletePage(page_index); | 55 pDoc->DeletePage(page_index); |
| 58 } | 56 } |
| 59 | 57 |
| 60 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, | 58 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, |
| 61 int page_index, | 59 int page_index, |
| 62 double width, | 60 double width, |
| 63 double height) { | 61 double height) { |
| 64 if (!document) | 62 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 65 return NULL; | 63 if (!pDoc) |
| 64 return nullptr; |
| 66 | 65 |
| 67 // CPDF_Parser* pParser = (CPDF_Parser*)document; | |
| 68 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | |
| 69 if (page_index < 0) | 66 if (page_index < 0) |
| 70 page_index = 0; | 67 page_index = 0; |
| 71 if (pDoc->GetPageCount() < page_index) | 68 if (pDoc->GetPageCount() < page_index) |
| 72 page_index = pDoc->GetPageCount(); | 69 page_index = pDoc->GetPageCount(); |
| 73 // if (page_index < 0 || page_index >= pDoc->GetPageCount()) | |
| 74 // return NULL; | |
| 75 | 70 |
| 76 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); | 71 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); |
| 77 if (!pPageDict) | 72 if (!pPageDict) |
| 78 return NULL; | 73 return NULL; |
| 79 CPDF_Array* pMediaBoxArray = new CPDF_Array; | 74 CPDF_Array* pMediaBoxArray = new CPDF_Array; |
| 80 pMediaBoxArray->Add(new CPDF_Number(0)); | 75 pMediaBoxArray->Add(new CPDF_Number(0)); |
| 81 pMediaBoxArray->Add(new CPDF_Number(0)); | 76 pMediaBoxArray->Add(new CPDF_Number(0)); |
| 82 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); | 77 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); |
| 83 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); | 78 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); |
| 84 | 79 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 328 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
| 334 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 329 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 335 "Page")) { | 330 "Page")) { |
| 336 return; | 331 return; |
| 337 } | 332 } |
| 338 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 333 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 339 rotate %= 4; | 334 rotate %= 4; |
| 340 | 335 |
| 341 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); | 336 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); |
| 342 } | 337 } |
| OLD | NEW |