| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, | 100 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, |
| 101 int page_index, | 101 int page_index, |
| 102 double width, | 102 double width, |
| 103 double height) { | 103 double height) { |
| 104 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 104 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 105 if (!pDoc) | 105 if (!pDoc) |
| 106 return nullptr; | 106 return nullptr; |
| 107 | 107 |
| 108 // TODO(dsinclair): Verify if this is correct for XFA page counts. |
| 108 page_index = std::min(std::max(page_index, 0), pDoc->GetPageCount()); | 109 page_index = std::min(std::max(page_index, 0), pDoc->GetPageCount()); |
| 109 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); | 110 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); |
| 110 if (!pPageDict) | 111 if (!pPageDict) |
| 111 return nullptr; | 112 return nullptr; |
| 112 | 113 |
| 113 CPDF_Array* pMediaBoxArray = new CPDF_Array; | 114 CPDF_Array* pMediaBoxArray = new CPDF_Array; |
| 114 pMediaBoxArray->Add(new CPDF_Number(0)); | 115 pMediaBoxArray->Add(new CPDF_Number(0)); |
| 115 pMediaBoxArray->Add(new CPDF_Number(0)); | 116 pMediaBoxArray->Add(new CPDF_Number(0)); |
| 116 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); | 117 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); |
| 117 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); | 118 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 311 |
| 311 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { | 312 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { |
| 312 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 313 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 313 if (!IsPageObject(pPage)) | 314 if (!IsPageObject(pPage)) |
| 314 return; | 315 return; |
| 315 | 316 |
| 316 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 317 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 317 rotate %= 4; | 318 rotate %= 4; |
| 318 pDict->SetFor("Rotate", new CPDF_Number(rotate * 90)); | 319 pDict->SetFor("Rotate", new CPDF_Number(rotate * 90)); |
| 319 } | 320 } |
| OLD | NEW |