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

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

Issue 1089823004: Replace FX_NEW with new, remove tests from fpdfsdk (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebased Created 5 years, 8 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/fpdfeditimg.cpp ('k') | fpdfsdk/src/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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fpdfedit.h" 8 #include "../include/fpdfedit.h"
9 9
10 10
11 #if _FX_OS_ == _FX_ANDROID_ 11 #if _FX_OS_ == _FX_ANDROID_
12 #include "time.h" 12 #include "time.h"
13 #else 13 #else
14 #include <ctime> 14 #include <ctime>
15 #endif 15 #endif
16 16
17 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() 17 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument()
18 { 18 {
19 » CPDF_Document* pDoc = FX_NEW CPDF_Document; 19 » CPDF_Document* pDoc = new CPDF_Document;
20 » if (!pDoc)
21 » » return NULL;
22 pDoc->CreateNewDoc(); 20 pDoc->CreateNewDoc();
23 time_t currentTime; 21 time_t currentTime;
24 22
25 CFX_ByteString DateStr; 23 CFX_ByteString DateStr;
26 24
27 if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 25 if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
28 { 26 {
29 if ( -1 != time( &currentTime ) ) 27 if ( -1 != time( &currentTime ) )
30 { 28 {
31 tm * pTM = localtime( &currentTime ); 29 tm * pTM = localtime( &currentTime );
32 if ( pTM ) 30 if ( pTM )
33 { 31 {
34 DateStr.Format( "D:%04d%02d%02d%02d%02d%02d", pT M->tm_year+1900, pTM->tm_mon+1, 32 DateStr.Format( "D:%04d%02d%02d%02d%02d%02d", pT M->tm_year+1900, pTM->tm_mon+1,
35 pTM->tm_mday, pTM->tm_hour, pTM->tm_min, pTM->tm_sec ); 33 pTM->tm_mday, pTM->tm_hour, pTM->tm_min, 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 { 41 {
44 if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 42 if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
45 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr )); 43 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr ));
46 » » pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"PDFium")); 44 » » pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
47 } 45 }
48 46
49 return pDoc; 47 return pDoc;
50 } 48 }
51 49
52 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) 50 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index)
53 { 51 {
54 CPDF_Document* pDoc = (CPDF_Document*)document; 52 CPDF_Document* pDoc = (CPDF_Document*)document;
55 if (pDoc == NULL) 53 if (pDoc == NULL)
56 return; 54 return;
(...skipping 13 matching lines...) Expand all
70 if(page_index < 0) 68 if(page_index < 0)
71 page_index = 0; 69 page_index = 0;
72 if(pDoc->GetPageCount()<page_index) 70 if(pDoc->GetPageCount()<page_index)
73 page_index = pDoc->GetPageCount(); 71 page_index = pDoc->GetPageCount();
74 // if (page_index < 0 || page_index >= pDoc->GetPageCount()) 72 // if (page_index < 0 || page_index >= pDoc->GetPageCount())
75 // return NULL; 73 // return NULL;
76 74
77 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); 75 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
78 if(!pPageDict) 76 if(!pPageDict)
79 return NULL; 77 return NULL;
80 » CPDF_Array* pMediaBoxArray = FX_NEW CPDF_Array; 78 » CPDF_Array* pMediaBoxArray = new CPDF_Array;
81 » pMediaBoxArray->Add(FX_NEW CPDF_Number(0)); 79 » pMediaBoxArray->Add(new CPDF_Number(0));
82 » pMediaBoxArray->Add(FX_NEW CPDF_Number(0)); 80 » pMediaBoxArray->Add(new CPDF_Number(0));
83 » pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(width))); 81 » pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
84 » pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(height))); 82 » pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));
85 83
86 pPageDict->SetAt("MediaBox", pMediaBoxArray); 84 pPageDict->SetAt("MediaBox", pMediaBoxArray);
87 » pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0)); 85 » pPageDict->SetAt("Rotate", new CPDF_Number(0));
88 » pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary); 86 » pPageDict->SetAt("Resources", new CPDF_Dictionary);
89 87
90 » CPDF_Page* pPage = FX_NEW CPDF_Page; 88 » CPDF_Page* pPage = new CPDF_Page;
91 pPage->Load(pDoc,pPageDict); 89 pPage->Load(pDoc,pPageDict);
92 pPage->ParseContent(); 90 pPage->ParseContent();
93 91
94 return pPage; 92 return pPage;
95 } 93 }
96 94
97 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) 95 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
98 { 96 {
99 CPDF_Page* pPage = (CPDF_Page*)page; 97 CPDF_Page* pPage = (CPDF_Page*)page;
100 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 98 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 266
269 return TRUE; 267 return TRUE;
270 } 268 }
271 269
272 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, 270 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
273 double a, double b, double c, double d, double e, doubl e f) 271 double a, double b, double c, double d, double e, doubl e f)
274 { 272 {
275 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; 273 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
276 if(pPageObj == NULL) 274 if(pPageObj == NULL)
277 return; 275 return;
278 //PDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject;
279 CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d, (FX_FLOAT)e,(FX_FLOAT)f); 276 CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d, (FX_FLOAT)e,(FX_FLOAT)f);
280 pPageObj->Transform(matrix); 277 pPageObj->Transform(matrix);
281 } 278 }
282 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, 279 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
283 double a, double b, double c, double d, double e, double f) 280 double a, double b, double c, double d, double e, double f)
284 { 281 {
285 if(page == NULL) 282 if(page == NULL)
286 return; 283 return;
287 CPDF_Page* pPage = (CPDF_Page*)page; 284 CPDF_Page* pPage = (CPDF_Page*)page;
288 CPDF_AnnotList AnnotList(pPage); 285 CPDF_AnnotList AnnotList(pPage);
289 for (int i=0; i<AnnotList.Count();i++) 286 for (int i=0; i<AnnotList.Count();i++)
290 { 287 {
291 CPDF_Annot* pAnnot = AnnotList.GetAt(i); 288 CPDF_Annot* pAnnot = AnnotList.GetAt(i);
292 // transformAnnots Rectangle 289 // transformAnnots Rectangle
293 CPDF_Rect rect; 290 CPDF_Rect rect;
294 pAnnot->GetRect(rect); 291 pAnnot->GetRect(rect);
295 CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_ FLOAT)d,(FX_FLOAT)e,(FX_FLOAT)f); 292 CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_ FLOAT)d,(FX_FLOAT)e,(FX_FLOAT)f);
296 rect.Transform(&matrix); 293 rect.Transform(&matrix);
297 CPDF_Array *pRectArray = NULL; 294 CPDF_Array *pRectArray = NULL;
298 pRectArray = pAnnot->m_pAnnotDict->GetArray("Rect"); 295 pRectArray = pAnnot->m_pAnnotDict->GetArray("Rect");
299 if (!pRectArray) pRectArray=CPDF_Array::Create(); 296 if (!pRectArray) pRectArray=CPDF_Array::Create();
300 » » pRectArray->SetAt(0,FX_NEW CPDF_Number(rect.left)); 297 » » pRectArray->SetAt(0, new CPDF_Number(rect.left));
301 » » pRectArray->SetAt(1,FX_NEW CPDF_Number(rect.bottom)); 298 » » pRectArray->SetAt(1, new CPDF_Number(rect.bottom));
302 » » pRectArray->SetAt(2,FX_NEW CPDF_Number(rect.right)); 299 » » pRectArray->SetAt(2, new CPDF_Number(rect.right));
303 » » pRectArray->SetAt(3,FX_NEW CPDF_Number(rect.top)); 300 » » pRectArray->SetAt(3, new CPDF_Number(rect.top));
304 pAnnot->m_pAnnotDict->SetAt("Rect",pRectArray); 301 pAnnot->m_pAnnotDict->SetAt("Rect",pRectArray);
305 302
306 //Transform AP's rectangle 303 //Transform AP's rectangle
307 //To Do 304 //To Do
308
309 } 305 }
310 306
311 } 307 }
312 308
313 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) 309 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate)
314 { 310 {
315 CPDF_Page* pPage = (CPDF_Page*)page; 311 CPDF_Page* pPage = (CPDF_Page*)page;
316 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 312 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
317 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 313 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page"))
318 { 314 {
319 return; 315 return;
320 } 316 }
321 CPDF_Dictionary* pDict = pPage->m_pFormDict; 317 CPDF_Dictionary* pDict = pPage->m_pFormDict;
322 rotate %=4; 318 rotate %=4;
323 319
324 » pDict->SetAt("Rotate", FX_NEW CPDF_Number(rotate * 90)); 320 » pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
325 } 321 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfeditimg.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698