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

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

Issue 1254703002: FX_BOOL considered harmful, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 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_sysfontinfo.cpp ('k') | fpdfsdk/src/fpdfdoc.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_transformpage.h" 7 #include "../../public/fpdf_transformpage.h"
8 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
9 9
10 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bo ttom, float right, float top) 10 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bo ttom, float right, float top)
(...skipping 24 matching lines...) Expand all
35 pCropBoxArray->Add(new CPDF_Number(bottom)); 35 pCropBoxArray->Add(new CPDF_Number(bottom));
36 pCropBoxArray->Add(new CPDF_Number(FX_FLOAT(right))); 36 pCropBoxArray->Add(new CPDF_Number(FX_FLOAT(right)));
37 pCropBoxArray->Add(new CPDF_Number(FX_FLOAT(top))); 37 pCropBoxArray->Add(new CPDF_Number(FX_FLOAT(top)));
38 pPageDict->SetAt("CropBox", pCropBoxArray); 38 pPageDict->SetAt("CropBox", pCropBoxArray);
39 } 39 }
40 40
41 41
42 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, fl oat* bottom, float* right, float* top) 42 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, fl oat* bottom, float* right, float* top)
43 { 43 {
44 if(!page) 44 if(!page)
45 » » return FALSE; 45 » » return false;
46 CPDF_Page* pPage = (CPDF_Page*)page; 46 CPDF_Page* pPage = (CPDF_Page*)page;
47 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; 47 CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
48 CPDF_Array* pArray = pPageDict->GetArray("MediaBox"); 48 CPDF_Array* pArray = pPageDict->GetArray("MediaBox");
49 if(pArray) 49 if(pArray)
50 { 50 {
51 *left = pArray->GetFloat(0); 51 *left = pArray->GetFloat(0);
52 *bottom = pArray->GetFloat(1); 52 *bottom = pArray->GetFloat(1);
53 *right = pArray->GetFloat(2); 53 *right = pArray->GetFloat(2);
54 *top = pArray->GetFloat(3); 54 *top = pArray->GetFloat(3);
55 » » return TRUE; 55 » » return true;
56 } 56 }
57 » return FALSE; 57 » return false;
58 } 58 }
59 59
60 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, float* left, flo at* bottom, float* right, float* top) 60 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, float* left, flo at* bottom, float* right, float* top)
61 { 61 {
62 if(!page) 62 if(!page)
63 » » return FALSE; 63 » » return false;
64 CPDF_Page* pPage = (CPDF_Page*)page; 64 CPDF_Page* pPage = (CPDF_Page*)page;
65 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; 65 CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
66 CPDF_Array* pArray = pPageDict->GetArray("CropBox"); 66 CPDF_Array* pArray = pPageDict->GetArray("CropBox");
67 if(pArray) 67 if(pArray)
68 { 68 {
69 *left = pArray->GetFloat(0); 69 *left = pArray->GetFloat(0);
70 *bottom = pArray->GetFloat(1); 70 *bottom = pArray->GetFloat(1);
71 *right = pArray->GetFloat(2); 71 *right = pArray->GetFloat(2);
72 *top = pArray->GetFloat(3); 72 *top = pArray->GetFloat(3);
73 » » return TRUE; 73 » » return true;
74 } 74 }
75 » return FALSE; 75 » return false;
76 } 76 }
77 77
78 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX * matrix, FS_RECTF* clipRect) 78 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX * matrix, FS_RECTF* clipRect)
79 { 79 {
80 if(!page) 80 if(!page)
81 » » return FALSE; 81 » » return false;
82 82
83 CFX_ByteTextBuf textBuf; 83 CFX_ByteTextBuf textBuf;
84 textBuf<<"q "; 84 textBuf<<"q ";
85 CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right, cl ipRect->top); 85 CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right, cl ipRect->top);
86 rect.Normalize(); 86 rect.Normalize();
87 CFX_ByteString bsClipping; 87 CFX_ByteString bsClipping;
88 bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom, rect.W idth(), rect.Height()); 88 bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom, rect.W idth(), rect.Height());
89 textBuf<<bsClipping; 89 textBuf<<bsClipping;
90 90
91 CFX_ByteString bsMatix; 91 CFX_ByteString bsMatix;
92 bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,matrix->c,m atrix->d,matrix->e,matrix->f); 92 bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,matrix->c,m atrix->d,matrix->e,matrix->f);
93 textBuf<<bsMatix; 93 textBuf<<bsMatix;
94 94
95 95
96 CPDF_Page* pPage = (CPDF_Page*)page; 96 CPDF_Page* pPage = (CPDF_Page*)page;
97 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; 97 CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
98 CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL; 98 CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
99 if(!pContentObj) 99 if(!pContentObj)
100 pContentObj = pPageDic ? pPageDic->GetArray("Contents") : NULL; 100 pContentObj = pPageDic ? pPageDic->GetArray("Contents") : NULL;
101 if(!pContentObj) 101 if(!pContentObj)
102 » » return FALSE; 102 » » return false;
103 103
104 CPDF_Dictionary* pDic = new CPDF_Dictionary; 104 CPDF_Dictionary* pDic = new CPDF_Dictionary;
105 CPDF_Stream* pStream = new CPDF_Stream(NULL,0, pDic); 105 CPDF_Stream* pStream = new CPDF_Stream(NULL,0, pDic);
106 » pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE); 106 » pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), false, false);
107 CPDF_Document* pDoc = pPage->m_pDocument; 107 CPDF_Document* pDoc = pPage->m_pDocument;
108 if(!pDoc) 108 if(!pDoc)
109 » » return FALSE; 109 » » return false;
110 pDoc->AddIndirectObject(pStream); 110 pDoc->AddIndirectObject(pStream);
111 111
112 pDic = new CPDF_Dictionary; 112 pDic = new CPDF_Dictionary;
113 CPDF_Stream* pEndStream = new CPDF_Stream(NULL,0, pDic); 113 CPDF_Stream* pEndStream = new CPDF_Stream(NULL,0, pDic);
114 » pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE); 114 » pEndStream->SetData((const uint8_t*)" Q", 2, false, false);
115 pDoc->AddIndirectObject(pEndStream); 115 pDoc->AddIndirectObject(pEndStream);
116 116
117 CPDF_Array* pContentArray = NULL; 117 CPDF_Array* pContentArray = NULL;
118 if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY) 118 if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
119 { 119 {
120 pContentArray = (CPDF_Array*)pContentObj; 120 pContentArray = (CPDF_Array*)pContentObj;
121 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjN um()); 121 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjN um());
122 pContentArray->InsertAt(0, pRef); 122 pContentArray->InsertAt(0, pRef);
123 pContentArray->AddReference(pDoc,pEndStream); 123 pContentArray->AddReference(pDoc,pEndStream);
124 124
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 continue; 174 continue;
175 175
176 CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC(" Matrix")); 176 CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC(" Matrix"));
177 CFX_AffineMatrix t = *(CFX_AffineMatrix*)matrix; 177 CFX_AffineMatrix t = *(CFX_AffineMatrix*)matrix;
178 m.Concat(t); 178 m.Concat(t);
179 pDict->SetAtMatrix(FX_BSTRC("Matrix"), m); 179 pDict->SetAtMatrix(FX_BSTRC("Matrix"), m);
180 } 180 }
181 } 181 }
182 } 182 }
183 183
184 » return TRUE; 184 » return true;
185 } 185 }
186 186
187 DLLEXPORT void STDCALL FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object ,double a, double b, double c, double d, double e, double f) 187 DLLEXPORT void STDCALL FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object ,double a, double b, double c, double d, double e, double f)
188 { 188 {
189 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; 189 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
190 if(pPageObj == NULL) 190 if(pPageObj == NULL)
191 return; 191 return;
192 CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d, (FX_FLOAT)e,(FX_FLOAT)f); 192 CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d, (FX_FLOAT)e,(FX_FLOAT)f);
193 193
194 //Special treatment to shading object, because the ClipPath for shading object is already transformed. 194 //Special treatment to shading object, because the ClipPath for shading object is already transformed.
195 if(pPageObj->m_Type != PDFPAGE_SHADING) 195 if(pPageObj->m_Type != PDFPAGE_SHADING)
196 pPageObj->TransformClipPath(matrix); 196 pPageObj->TransformClipPath(matrix);
197 pPageObj->TransformGeneralState(matrix); 197 pPageObj->TransformGeneralState(matrix);
198 } 198 }
199 199
200 200
201 DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, float bottom, fl oat right, float top) 201 DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, float bottom, fl oat right, float top)
202 { 202 {
203 CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath(); 203 CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath();
204 pNewClipPath->GetModify(); 204 pNewClipPath->GetModify();
205 CPDF_Path Path; 205 CPDF_Path Path;
206 Path.GetModify(); 206 Path.GetModify();
207 Path.AppendRect(left, bottom, right, top); 207 Path.AppendRect(left, bottom, right, top);
208 » pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, FALSE); 208 » pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, false);
209 return pNewClipPath; 209 return pNewClipPath;
210 } 210 }
211 211
212 DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath) 212 DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath)
213 { 213 {
214 delete (CPDF_ClipPath*)clipPath; 214 delete (CPDF_ClipPath*)clipPath;
215 } 215 }
216 216
217 void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) 217 void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path)
218 { 218 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } else { 275 } else {
276 OutputPath(strClip, path); 276 OutputPath(strClip, path);
277 if (iClipType == FXFILL_WINDING) 277 if (iClipType == FXFILL_WINDING)
278 strClip << "W n\n"; 278 strClip << "W n\n";
279 else 279 else
280 strClip << "W* n\n"; 280 strClip << "W* n\n";
281 } 281 }
282 } 282 }
283 CPDF_Dictionary* pDic = new CPDF_Dictionary; 283 CPDF_Dictionary* pDic = new CPDF_Dictionary;
284 CPDF_Stream* pStream = new CPDF_Stream(NULL,0, pDic); 284 CPDF_Stream* pStream = new CPDF_Stream(NULL,0, pDic);
285 » pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE); 285 » pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), false, false);
286 CPDF_Document* pDoc = pPage->m_pDocument; 286 CPDF_Document* pDoc = pPage->m_pDocument;
287 if(!pDoc) 287 if(!pDoc)
288 return; 288 return;
289 pDoc->AddIndirectObject(pStream); 289 pDoc->AddIndirectObject(pStream);
290 290
291 CPDF_Array* pContentArray = NULL; 291 CPDF_Array* pContentArray = NULL;
292 if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY) 292 if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
293 { 293 {
294 pContentArray = (CPDF_Array*)pContentObj; 294 pContentArray = (CPDF_Array*)pContentObj;
295 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjN um()); 295 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjN um());
(...skipping 15 matching lines...) Expand all
311 { 311 {
312 pContentArray = new CPDF_Array(); 312 pContentArray = new CPDF_Array();
313 pContentArray->AddReference(pDoc,pStream->GetObj Num()); 313 pContentArray->AddReference(pDoc,pStream->GetObj Num());
314 pContentArray->AddReference(pDoc,pDirectObj->Get ObjNum()); 314 pContentArray->AddReference(pDoc,pDirectObj->Get ObjNum());
315 pPageDic->SetAtReference("Contents", pDoc, pDoc- >AddIndirectObject(pContentArray)); 315 pPageDic->SetAtReference("Contents", pDoc, pDoc- >AddIndirectObject(pContentArray));
316 } 316 }
317 } 317 }
318 } 318 }
319 } 319 }
320 320
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_sysfontinfo.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698