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

Side by Side Diff: fpdfsdk/fpdfeditpage.cpp

Issue 2031653003: Get rid of NULLs in fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_core
Patch Set: rebase Created 4 years, 6 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/fpdfeditimg.cpp ('k') | fpdfsdk/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 8
9 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h" 9 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h"
10 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 10 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 if (-1 != time(&currentTime)) { 46 if (-1 != time(&currentTime)) {
47 tm* pTM = localtime(&currentTime); 47 tm* pTM = localtime(&currentTime);
48 if (pTM) { 48 if (pTM) {
49 DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900, 49 DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900,
50 pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min, 50 pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min,
51 pTM->tm_sec); 51 pTM->tm_sec);
52 } 52 }
53 } 53 }
54 } 54 }
55 55
56 CPDF_Dictionary* pInfoDict = NULL; 56 CPDF_Dictionary* pInfoDict = nullptr;
57 pInfoDict = pDoc->GetInfo(); 57 pInfoDict = pDoc->GetInfo();
58 if (pInfoDict) { 58 if (pInfoDict) {
59 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 59 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
60 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr, FALSE)); 60 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr, FALSE));
61 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); 61 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
62 } 62 }
63 63
64 return FPDFDocumentFromCPDFDocument(pDoc); 64 return FPDFDocumentFromCPDFDocument(pDoc);
65 } 65 }
66 66
(...skipping 10 matching lines...) Expand all
77 if (!pDoc) 77 if (!pDoc)
78 return nullptr; 78 return nullptr;
79 79
80 if (page_index < 0) 80 if (page_index < 0)
81 page_index = 0; 81 page_index = 0;
82 if (pDoc->GetPageCount() < page_index) 82 if (pDoc->GetPageCount() < page_index)
83 page_index = pDoc->GetPageCount(); 83 page_index = pDoc->GetPageCount();
84 84
85 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); 85 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
86 if (!pPageDict) 86 if (!pPageDict)
87 return NULL; 87 return nullptr;
88 CPDF_Array* pMediaBoxArray = new CPDF_Array; 88 CPDF_Array* pMediaBoxArray = new CPDF_Array;
89 pMediaBoxArray->Add(new CPDF_Number(0)); 89 pMediaBoxArray->Add(new CPDF_Number(0));
90 pMediaBoxArray->Add(new CPDF_Number(0)); 90 pMediaBoxArray->Add(new CPDF_Number(0));
91 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); 91 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
92 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); 92 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));
93 93
94 pPageDict->SetAt("MediaBox", pMediaBoxArray); 94 pPageDict->SetAt("MediaBox", pMediaBoxArray);
95 pPageDict->SetAt("Rotate", new CPDF_Number(0)); 95 pPageDict->SetAt("Rotate", new CPDF_Number(0));
96 pPageDict->SetAt("Resources", new CPDF_Dictionary); 96 pPageDict->SetAt("Resources", new CPDF_Dictionary);
97 97
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 return FALSE; 211 return FALSE;
212 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject; 212 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject;
213 213
214 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; 214 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
215 int blend_type = 215 int blend_type =
216 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL; 216 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;
217 if (blend_type != FXDIB_BLEND_NORMAL) 217 if (blend_type != FXDIB_BLEND_NORMAL)
218 return TRUE; 218 return TRUE;
219 219
220 CPDF_Dictionary* pSMaskDict = 220 CPDF_Dictionary* pSMaskDict =
221 pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL; 221 pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : nullptr;
222 if (pSMaskDict) 222 if (pSMaskDict)
223 return TRUE; 223 return TRUE;
224 224
225 if (pGeneralState && pGeneralState->m_FillAlpha != 1.0f) 225 if (pGeneralState && pGeneralState->m_FillAlpha != 1.0f)
226 return TRUE; 226 return TRUE;
227 227
228 if (pPageObj->IsPath()) { 228 if (pPageObj->IsPath()) {
229 if (pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f) 229 if (pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f)
230 return TRUE; 230 return TRUE;
231 } 231 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 return; 284 return;
285 CPDF_AnnotList AnnotList(pPage); 285 CPDF_AnnotList AnnotList(pPage);
286 for (size_t i = 0; i < AnnotList.Count(); ++i) { 286 for (size_t i = 0; i < AnnotList.Count(); ++i) {
287 CPDF_Annot* pAnnot = AnnotList.GetAt(i); 287 CPDF_Annot* pAnnot = AnnotList.GetAt(i);
288 // transformAnnots Rectangle 288 // transformAnnots Rectangle
289 CFX_FloatRect rect; 289 CFX_FloatRect rect;
290 pAnnot->GetRect(rect); 290 pAnnot->GetRect(rect);
291 CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, 291 CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
292 (FX_FLOAT)e, (FX_FLOAT)f); 292 (FX_FLOAT)e, (FX_FLOAT)f);
293 rect.Transform(&matrix); 293 rect.Transform(&matrix);
294 CPDF_Array* pRectArray = NULL; 294 CPDF_Array* pRectArray = pAnnot->GetAnnotDict()->GetArrayBy("Rect");
295 pRectArray = pAnnot->GetAnnotDict()->GetArrayBy("Rect");
296 if (!pRectArray) 295 if (!pRectArray)
297 pRectArray = new CPDF_Array; 296 pRectArray = new CPDF_Array;
298 pRectArray->SetAt(0, new CPDF_Number(rect.left)); 297 pRectArray->SetAt(0, new CPDF_Number(rect.left));
299 pRectArray->SetAt(1, new CPDF_Number(rect.bottom)); 298 pRectArray->SetAt(1, new CPDF_Number(rect.bottom));
300 pRectArray->SetAt(2, new CPDF_Number(rect.right)); 299 pRectArray->SetAt(2, new CPDF_Number(rect.right));
301 pRectArray->SetAt(3, new CPDF_Number(rect.top)); 300 pRectArray->SetAt(3, new CPDF_Number(rect.top));
302 pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray); 301 pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray);
303 302
304 // Transform AP's rectangle 303 // Transform AP's rectangle
305 // To Do 304 // To Do
306 } 305 }
307 } 306 }
308 307
309 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { 308 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
310 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 309 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
311 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 310 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
312 !pPage->m_pFormDict->GetObjectBy("Type")->GetDirect() || 311 !pPage->m_pFormDict->GetObjectBy("Type")->GetDirect() ||
313 pPage->m_pFormDict->GetObjectBy("Type")->GetDirect()->GetString().Compare( 312 pPage->m_pFormDict->GetObjectBy("Type")->GetDirect()->GetString().Compare(
314 "Page")) { 313 "Page")) {
315 return; 314 return;
316 } 315 }
317 CPDF_Dictionary* pDict = pPage->m_pFormDict; 316 CPDF_Dictionary* pDict = pPage->m_pFormDict;
318 rotate %= 4; 317 rotate %= 4;
319 318
320 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); 319 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
321 } 320 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfeditimg.cpp ('k') | fpdfsdk/fpdfformfill.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698