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

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

Issue 1258093002: FX Bool considered harmful, part 3 (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_transformpage.cpp ('k') | fpdfsdk/src/fpdfeditimg.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 "../../public/fpdf_doc.h" 8 #include "../../public/fpdf_doc.h"
9 9
10 static int THISMODULE = 0; 10 static int THISMODULE = 0;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 { 201 {
202 if (!pDict) 202 if (!pDict)
203 return NULL; 203 return NULL;
204 CPDF_Link link((CPDF_Dictionary*)pDict); 204 CPDF_Link link((CPDF_Dictionary*)pDict);
205 return link.GetAction().GetDict(); 205 return link.GetAction().GetDict();
206 } 206 }
207 207
208 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP DF_LINK* linkAnnot) 208 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP DF_LINK* linkAnnot)
209 { 209 {
210 if(!page || !startPos || !linkAnnot) 210 if(!page || !startPos || !linkAnnot)
211 return FALSE; 211 return false;
212 CPDF_Page* pPage = (CPDF_Page*)page; 212 CPDF_Page* pPage = (CPDF_Page*)page;
213 if(!pPage->m_pFormDict) 213 if(!pPage->m_pFormDict)
214 return FALSE; 214 return false;
215 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); 215 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
216 if(!pAnnots) 216 if(!pAnnots)
217 return FALSE; 217 return false;
218 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { 218 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) {
219 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); 219 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i);
220 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) 220 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY)
221 continue; 221 continue;
222 if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) { 222 if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) {
223 *startPos = i + 1; 223 *startPos = i + 1;
224 *linkAnnot = (FPDF_LINK)pDict; 224 *linkAnnot = (FPDF_LINK)pDict;
225 return TRUE; 225 return true;
226 } 226 }
227 } 227 }
228 return FALSE; 228 return false;
229 } 229 }
230 230
231 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF* rect) 231 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF* rect)
232 { 232 {
233 if(!linkAnnot || !rect) 233 if(!linkAnnot || !rect)
234 return FALSE; 234 return false;
235 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; 235 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
236 CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect")); 236 CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect"));
237 rect->left = rt.left; 237 rect->left = rt.left;
238 rect->bottom = rt.bottom; 238 rect->bottom = rt.bottom;
239 rect->right = rt.right; 239 rect->right = rt.right;
240 rect->top = rt.top; 240 rect->top = rt.top;
241 return TRUE; 241 return true;
242 } 242 }
243 243
244 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) 244 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot)
245 { 245 {
246 if(!linkAnnot) 246 if(!linkAnnot)
247 return 0; 247 return 0;
248 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; 248 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
249 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); 249 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
250 if (!pArray) 250 if (!pArray)
251 return 0; 251 return 0;
252 return pArray->GetCount() / 8; 252 return pArray->GetCount() / 8;
253 } 253 }
254 254
255 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quad Index, FS_QUADPOINTSF* quadPoints) 255 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quad Index, FS_QUADPOINTSF* quadPoints)
256 { 256 {
257 if(!linkAnnot || !quadPoints) 257 if(!linkAnnot || !quadPoints)
258 return FALSE; 258 return false;
259 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; 259 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot;
260 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); 260 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints"));
261 if (pArray) { 261 if (pArray) {
262 if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || ((quadInd ex*8+7) >= (int)pArray->GetCount())) 262 if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || ((quadInd ex*8+7) >= (int)pArray->GetCount()))
263 return FALSE; 263 return false;
264 quadPoints->x1 = pArray->GetNumber(quadIndex*8); 264 quadPoints->x1 = pArray->GetNumber(quadIndex*8);
265 quadPoints->y1 = pArray->GetNumber(quadIndex*8+1); 265 quadPoints->y1 = pArray->GetNumber(quadIndex*8+1);
266 quadPoints->x2 = pArray->GetNumber(quadIndex*8+2); 266 quadPoints->x2 = pArray->GetNumber(quadIndex*8+2);
267 quadPoints->y2 = pArray->GetNumber(quadIndex*8+3); 267 quadPoints->y2 = pArray->GetNumber(quadIndex*8+3);
268 quadPoints->x3 = pArray->GetNumber(quadIndex*8+4); 268 quadPoints->x3 = pArray->GetNumber(quadIndex*8+4);
269 quadPoints->y3 = pArray->GetNumber(quadIndex*8+5); 269 quadPoints->y3 = pArray->GetNumber(quadIndex*8+5);
270 quadPoints->x4 = pArray->GetNumber(quadIndex*8+6); 270 quadPoints->x4 = pArray->GetNumber(quadIndex*8+6);
271 quadPoints->y4 = pArray->GetNumber(quadIndex*8+7); 271 quadPoints->y4 = pArray->GetNumber(quadIndex*8+7);
272 return TRUE; 272 return true;
273 } 273 }
274 return FALSE; 274 return false;
275 } 275 }
276 276
277 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR ING tag, 277 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR ING tag,
278 void* buffer, unsigned long buf len) 278 void* buffer, unsigned long buf len)
279 { 279 {
280 if (!doc || !tag) 280 if (!doc || !tag)
281 return 0; 281 return 0;
282 CPDF_Document* pDoc = (CPDF_Document*)doc; 282 CPDF_Document* pDoc = (CPDF_Document*)doc;
283 // Get info dictionary 283 // Get info dictionary
284 CPDF_Dictionary* pInfo = pDoc->GetInfo(); 284 CPDF_Dictionary* pInfo = pDoc->GetInfo();
285 if (!pInfo) 285 if (!pInfo)
286 return 0; 286 return 0;
287 CFX_WideString text = pInfo->GetUnicodeText(tag); 287 CFX_WideString text = pInfo->GetUnicodeText(tag);
288 // Use UTF-16LE encoding 288 // Use UTF-16LE encoding
289 CFX_ByteString encodedText = text.UTF16LE_Encode(); 289 CFX_ByteString encodedText = text.UTF16LE_Encode();
290 unsigned long len = encodedText.GetLength(); 290 unsigned long len = encodedText.GetLength();
291 if (buffer && buflen >= len) { 291 if (buffer && buflen >= len) {
292 FXSYS_memcpy(buffer, encodedText.c_str(), len); 292 FXSYS_memcpy(buffer, encodedText.c_str(), len);
293 } 293 }
294 return len; 294 return len;
295 } 295 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_transformpage.cpp ('k') | fpdfsdk/src/fpdfeditimg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698