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

Side by Side Diff: fpdfsdk/src/fpdfeditpage.cpp

Issue 1383933003: XFA: Remove checks for new returning NULL in fpdfsdk. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase 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/fpdf_flatten.cpp ('k') | fpdfsdk/src/fpdfview.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 #include "../include/fpdfxfa/fpdfxfa_doc.h" 10 #include "../include/fpdfxfa/fpdfxfa_doc.h"
11 #include "../include/fpdfxfa/fpdfxfa_app.h" 11 #include "../include/fpdfxfa/fpdfxfa_app.h"
12 #include "../include/fpdfxfa/fpdfxfa_page.h" 12 #include "../include/fpdfxfa/fpdfxfa_page.h"
13 13
14 #if _FX_OS_ == _FX_ANDROID_ 14 #if _FX_OS_ == _FX_ANDROID_
15 #include "time.h" 15 #include "time.h"
16 #else 16 #else
17 #include <ctime> 17 #include <ctime>
18 #endif 18 #endif
19 19
20 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { 20 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
21 CPDF_Document* pDoc = new CPDF_Document; 21 CPDF_Document* pDoc = new CPDF_Document;
22 if (!pDoc)
23 return NULL;
24 pDoc->CreateNewDoc(); 22 pDoc->CreateNewDoc();
25 time_t currentTime; 23 time_t currentTime;
26 24
27 CFX_ByteString DateStr; 25 CFX_ByteString DateStr;
28 26
29 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) { 27 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) {
30 if (-1 != time(&currentTime)) { 28 if (-1 != time(&currentTime)) {
31 tm* pTM = localtime(&currentTime); 29 tm* pTM = localtime(&currentTime);
32 if (pTM) { 30 if (pTM) {
33 DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900, 31 DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900,
34 pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min, 32 pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min,
35 pTM->tm_sec); 33 pTM->tm_sec);
36 } 34 }
37 } 35 }
38 } 36 }
39 37
40 CPDF_Dictionary* pInfoDict = NULL; 38 CPDF_Dictionary* pInfoDict = NULL;
41 pInfoDict = pDoc->GetInfo(); 39 pInfoDict = pDoc->GetInfo();
42 if (pInfoDict) { 40 if (pInfoDict) {
43 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 41 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
44 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr)); 42 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr));
45 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); 43 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
46 } 44 }
47 45
48 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); 46 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
49 CPDFXFA_Document* document = new CPDFXFA_Document(pDoc, pApp); 47 return new CPDFXFA_Document(pDoc, pApp);
50 return document;
51 } 48 }
52 49
53 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { 50 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
54 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 51 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
55 if (pDoc == NULL) 52 if (pDoc == NULL)
56 return; 53 return;
57 if (page_index < 0 || page_index >= pDoc->GetPageCount()) 54 if (page_index < 0 || page_index >= pDoc->GetPageCount())
58 return; 55 return;
59 56
60 pDoc->DeletePage(page_index); 57 pDoc->DeletePage(page_index);
(...skipping 21 matching lines...) Expand all
82 CPDF_Array* pMediaBoxArray = new CPDF_Array; 79 CPDF_Array* pMediaBoxArray = new CPDF_Array;
83 pMediaBoxArray->Add(new CPDF_Number(0)); 80 pMediaBoxArray->Add(new CPDF_Number(0));
84 pMediaBoxArray->Add(new CPDF_Number(0)); 81 pMediaBoxArray->Add(new CPDF_Number(0));
85 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); 82 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
86 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); 83 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));
87 84
88 pPageDict->SetAt("MediaBox", pMediaBoxArray); 85 pPageDict->SetAt("MediaBox", pMediaBoxArray);
89 pPageDict->SetAt("Rotate", new CPDF_Number(0)); 86 pPageDict->SetAt("Rotate", new CPDF_Number(0));
90 pPageDict->SetAt("Resources", new CPDF_Dictionary); 87 pPageDict->SetAt("Resources", new CPDF_Dictionary);
91 88
92 // CPDF_Page* pPage = new CPDF_Page;
93 // pPage->Load(pDoc,pPageDict);
94 // pPage->ParseContent();
95
96 CPDFXFA_Page* pPage = 89 CPDFXFA_Page* pPage =
97 new CPDFXFA_Page((CPDFXFA_Document*)document, page_index); 90 new CPDFXFA_Page((CPDFXFA_Document*)document, page_index);
98 pPage->LoadPDFPage(pPageDict); 91 pPage->LoadPDFPage(pPageDict);
99 92
100 return pPage; 93 return pPage;
101 } 94 }
102 95
103 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) { 96 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
104 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 97 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
105 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 98 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, 274 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
282 double a, 275 double a,
283 double b, 276 double b,
284 double c, 277 double c,
285 double d, 278 double d,
286 double e, 279 double e,
287 double f) { 280 double f) {
288 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; 281 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
289 if (pPageObj == NULL) 282 if (pPageObj == NULL)
290 return; 283 return;
291 // PDF_ImageObject* pImageObj = new CPDF_ImageObject; 284
292 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, 285 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
293 (FX_FLOAT)e, (FX_FLOAT)f); 286 (FX_FLOAT)e, (FX_FLOAT)f);
294 pPageObj->Transform(matrix); 287 pPageObj->Transform(matrix);
295 } 288 }
296 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, 289 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
297 double a, 290 double a,
298 double b, 291 double b,
299 double c, 292 double c,
300 double d, 293 double d,
301 double e, 294 double e,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 333 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
341 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 334 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
342 "Page")) { 335 "Page")) {
343 return; 336 return;
344 } 337 }
345 CPDF_Dictionary* pDict = pPage->m_pFormDict; 338 CPDF_Dictionary* pDict = pPage->m_pFormDict;
346 rotate %= 4; 339 rotate %= 4;
347 340
348 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); 341 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
349 } 342 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_flatten.cpp ('k') | fpdfsdk/src/fpdfview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698