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

Side by Side Diff: core/src/fpdfdoc/doc_basic.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 | « core/src/fpdfdoc/doc_ap.cpp ('k') | core/src/fpdfdoc/doc_form.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/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 const int nMaxRecursion = 32; 8 const int nMaxRecursion = 32;
9 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) 9 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc)
10 { 10 {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return result; 307 return result;
308 } 308 }
309 CFX_WideString result; 309 CFX_WideString result;
310 result += '\\'; 310 result += '\\';
311 result += ChangeSlashToPlatform(filepath.GetPtr()); 311 result += ChangeSlashToPlatform(filepath.GetPtr());
312 return result; 312 return result;
313 #else 313 #else
314 return filepath; 314 return filepath;
315 #endif 315 #endif
316 } 316 }
317 FX_BOOL CPDF_FileSpec::GetFileName(CFX_WideString &csFileName) const 317 bool CPDF_FileSpec::GetFileName(CFX_WideString &csFileName) const
318 { 318 {
319 if (m_pObj == NULL) { 319 if (m_pObj == NULL) {
320 return FALSE; 320 return false;
321 } 321 }
322 if (m_pObj->GetType() == PDFOBJ_DICTIONARY) { 322 if (m_pObj->GetType() == PDFOBJ_DICTIONARY) {
323 CPDF_Dictionary* pDict = (CPDF_Dictionary*)m_pObj; 323 CPDF_Dictionary* pDict = (CPDF_Dictionary*)m_pObj;
324 csFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); 324 csFileName = pDict->GetUnicodeText(FX_BSTRC("UF"));
325 if (csFileName.IsEmpty()) { 325 if (csFileName.IsEmpty()) {
326 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F" ))); 326 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F" )));
327 } 327 }
328 if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) { 328 if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) {
329 return TRUE; 329 return true;
330 } 330 }
331 if (csFileName.IsEmpty()) { 331 if (csFileName.IsEmpty()) {
332 if (pDict->KeyExist(FX_BSTRC("DOS"))) { 332 if (pDict->KeyExist(FX_BSTRC("DOS"))) {
333 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC ("DOS"))); 333 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC ("DOS")));
334 } else if (pDict->KeyExist(FX_BSTRC("Mac"))) { 334 } else if (pDict->KeyExist(FX_BSTRC("Mac"))) {
335 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC ("Mac"))); 335 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC ("Mac")));
336 } else if (pDict->KeyExist(FX_BSTRC("Unix"))) { 336 } else if (pDict->KeyExist(FX_BSTRC("Unix"))) {
337 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC ("Unix"))); 337 csFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC ("Unix")));
338 } else { 338 } else {
339 return FALSE; 339 return false;
340 } 340 }
341 } 341 }
342 } else { 342 } else {
343 csFileName = CFX_WideString::FromLocal(m_pObj->GetString()); 343 csFileName = CFX_WideString::FromLocal(m_pObj->GetString());
344 } 344 }
345 csFileName = FILESPEC_DecodeFileName(csFileName); 345 csFileName = FILESPEC_DecodeFileName(csFileName);
346 return TRUE; 346 return true;
347 } 347 }
348 CPDF_FileSpec::CPDF_FileSpec() 348 CPDF_FileSpec::CPDF_FileSpec()
349 { 349 {
350 m_pObj = CPDF_Dictionary::Create(); 350 m_pObj = CPDF_Dictionary::Create();
351 if (m_pObj != NULL) { 351 if (m_pObj != NULL) {
352 ((CPDF_Dictionary*)m_pObj)->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Filesp ec")); 352 ((CPDF_Dictionary*)m_pObj)->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Filesp ec"));
353 } 353 }
354 } 354 }
355 FX_BOOL CPDF_FileSpec::IsURL() const 355 bool CPDF_FileSpec::IsURL() const
356 { 356 {
357 if (m_pObj == NULL) { 357 if (m_pObj == NULL) {
358 return FALSE; 358 return false;
359 } 359 }
360 if (m_pObj->GetType() != PDFOBJ_DICTIONARY) { 360 if (m_pObj->GetType() != PDFOBJ_DICTIONARY) {
361 return FALSE; 361 return false;
362 } 362 }
363 return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == FX_BSTRC("UR L"); 363 return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == FX_BSTRC("UR L");
364 } 364 }
365 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath) 365 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath)
366 { 366 {
367 if (filepath.GetLength() <= 1) { 367 if (filepath.GetLength() <= 1) {
368 return CFX_WideString(); 368 return CFX_WideString();
369 } 369 }
370 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 370 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
371 if (filepath.GetAt(1) == ':') { 371 if (filepath.GetAt(1) == ':') {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 return (CPDF_Stream*)m_pObj; 410 return (CPDF_Stream*)m_pObj;
411 } else if (iType == PDFOBJ_DICTIONARY) { 411 } else if (iType == PDFOBJ_DICTIONARY) {
412 CPDF_Dictionary *pEF = ((CPDF_Dictionary*)m_pObj)->GetDict(FX_BSTRC("EF" )); 412 CPDF_Dictionary *pEF = ((CPDF_Dictionary*)m_pObj)->GetDict(FX_BSTRC("EF" ));
413 if (pEF == NULL) { 413 if (pEF == NULL) {
414 return NULL; 414 return NULL;
415 } 415 }
416 return pEF->GetStream(FX_BSTRC("F")); 416 return pEF->GetStream(FX_BSTRC("F"));
417 } 417 }
418 return NULL; 418 return NULL;
419 } 419 }
420 static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object *pObj, const CFX_WideString C& wsFileName, FX_BOOL bURL) 420 static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object *pObj, const CFX_WideString C& wsFileName, bool bURL)
421 { 421 {
422 ASSERT(pObj != NULL); 422 ASSERT(pObj != NULL);
423 CFX_WideString wsStr; 423 CFX_WideString wsStr;
424 if (bURL) { 424 if (bURL) {
425 wsStr = wsFileName; 425 wsStr = wsFileName;
426 } else { 426 } else {
427 wsStr = FILESPEC_EncodeFileName(wsFileName); 427 wsStr = FILESPEC_EncodeFileName(wsFileName);
428 } 428 }
429 int32_t iType = pObj->GetType(); 429 int32_t iType = pObj->GetType();
430 if (iType == PDFOBJ_STRING) { 430 if (iType == PDFOBJ_STRING) {
431 pObj->SetString(CFX_ByteString::FromUnicode(wsStr)); 431 pObj->SetString(CFX_ByteString::FromUnicode(wsStr));
432 } else if (iType == PDFOBJ_DICTIONARY) { 432 } else if (iType == PDFOBJ_DICTIONARY) {
433 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; 433 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
434 pDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(wsStr)); 434 pDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(wsStr));
435 pDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(wsStr)); 435 pDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(wsStr));
436 } 436 }
437 } 437 }
438 void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL) 438 void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName, bool bURL)
439 { 439 {
440 ASSERT(m_pObj != NULL); 440 ASSERT(m_pObj != NULL);
441 if (m_pObj->GetType() == PDFOBJ_DICTIONARY && bURL) { 441 if (m_pObj->GetType() == PDFOBJ_DICTIONARY && bURL) {
442 ((CPDF_Dictionary*)m_pObj)->SetAtName(FX_BSTRC("FS"), "URL"); 442 ((CPDF_Dictionary*)m_pObj)->SetAtName(FX_BSTRC("FS"), "URL");
443 } 443 }
444 FPDFDOC_FILESPEC_SetFileName(m_pObj, wsFileName, bURL); 444 FPDFDOC_FILESPEC_SetFileName(m_pObj, wsFileName, bURL);
445 } 445 }
446 static CFX_WideString _MakeRoman(int num) 446 static CFX_WideString _MakeRoman(int num)
447 { 447 {
448 const int arabic[] = { 448 const int arabic[] = {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 if (nPage > 0 && nPage <= nPages) { 563 if (nPage > 0 && nPage <= nPages) {
564 return nPage; 564 return nPage;
565 } 565 }
566 return -1; 566 return -1;
567 } 567 }
568 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const 568 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const
569 { 569 {
570 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); 570 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr());
571 return GetPageByLabel(bsLabel); 571 return GetPageByLabel(bsLabel);
572 } 572 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_ap.cpp ('k') | core/src/fpdfdoc/doc_form.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698