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

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

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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 | « 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 if (csName.Compare(csLeft) < 0 || csName.Compare(csRight) > 0) { 97 if (csName.Compare(csLeft) < 0 || csName.Compare(csRight) > 0) {
98 return NULL; 98 return NULL;
99 } 99 }
100 } 100 }
101 CPDF_Array* pNames = pNode->GetArray(FX_BSTRC("Names")); 101 CPDF_Array* pNames = pNode->GetArray(FX_BSTRC("Names"));
102 if (pNames) { 102 if (pNames) {
103 FX_DWORD dwCount = pNames->GetCount() / 2; 103 FX_DWORD dwCount = pNames->GetCount() / 2;
104 for (FX_DWORD i = 0; i < dwCount; i ++) { 104 for (FX_DWORD i = 0; i < dwCount; i ++) {
105 CFX_ByteString csValue = pNames->GetString(i * 2); 105 CFX_ByteString csValue = pNames->GetString(i * 2);
106 FX_INT32 iCompare = csValue.Compare(csName); 106 int32_t iCompare = csValue.Compare(csName);
107 if (iCompare <= 0) { 107 if (iCompare <= 0) {
108 if (ppFind != NULL) { 108 if (ppFind != NULL) {
109 *ppFind = pNames; 109 *ppFind = pNames;
110 } 110 }
111 if (iCompare < 0) { 111 if (iCompare < 0) {
112 continue; 112 continue;
113 } 113 }
114 } else { 114 } else {
115 break; 115 break;
116 } 116 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return ChangeSlashToPDF(filepath.GetPtr()); 398 return ChangeSlashToPDF(filepath.GetPtr());
399 #else 399 #else
400 return filepath; 400 return filepath;
401 #endif 401 #endif
402 } 402 }
403 CPDF_Stream* CPDF_FileSpec::GetFileStream() const 403 CPDF_Stream* CPDF_FileSpec::GetFileStream() const
404 { 404 {
405 if (m_pObj == NULL) { 405 if (m_pObj == NULL) {
406 return NULL; 406 return NULL;
407 } 407 }
408 FX_INT32 iType = m_pObj->GetType(); 408 int32_t iType = m_pObj->GetType();
409 if (iType == PDFOBJ_STREAM) { 409 if (iType == PDFOBJ_STREAM) {
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, FX_WSTR wsFileName, FX_BOOL bURL) 420 static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object *pObj, FX_WSTR wsFileName, FX_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 FX_INT32 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(FX_WSTR wsFileName, FX_BOOL bURL) 438 void CPDF_FileSpec::SetFileName(FX_WSTR wsFileName, FX_BOOL bURL)
439 { 439 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 CFX_ByteString bsNumberingStyle = pLabel->GetString(FX_BSTRC("S"), N ULL); 533 CFX_ByteString bsNumberingStyle = pLabel->GetString(FX_BSTRC("S"), N ULL);
534 int nLabelNum = nPage - n + pLabel->GetInteger(FX_BSTRC("St"), 1); 534 int nLabelNum = nPage - n + pLabel->GetInteger(FX_BSTRC("St"), 1);
535 CFX_WideString wsNumPortion = _GetLabelNumPortion(nLabelNum, bsNumbe ringStyle); 535 CFX_WideString wsNumPortion = _GetLabelNumPortion(nLabelNum, bsNumbe ringStyle);
536 wsLabel += wsNumPortion; 536 wsLabel += wsNumPortion;
537 return wsLabel; 537 return wsLabel;
538 } 538 }
539 } 539 }
540 wsLabel.Format(L"%d", nPage + 1); 540 wsLabel.Format(L"%d", nPage + 1);
541 return wsLabel; 541 return wsLabel;
542 } 542 }
543 FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_BSTR bsLabel) const 543 int32_t CPDF_PageLabel::GetPageByLabel(FX_BSTR bsLabel) const
544 { 544 {
545 if (m_pDocument == NULL) { 545 if (m_pDocument == NULL) {
546 return -1; 546 return -1;
547 } 547 }
548 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); 548 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
549 if (pPDFRoot == NULL) { 549 if (pPDFRoot == NULL) {
550 return -1; 550 return -1;
551 } 551 }
552 int nPages = m_pDocument->GetPageCount(); 552 int nPages = m_pDocument->GetPageCount();
553 CFX_ByteString bsLbl; 553 CFX_ByteString bsLbl;
554 CFX_ByteString bsOrig = bsLabel; 554 CFX_ByteString bsOrig = bsLabel;
555 for (int i = 0; i < nPages; i++) { 555 for (int i = 0; i < nPages; i++) {
556 bsLbl = PDF_EncodeText(GetLabel(i)); 556 bsLbl = PDF_EncodeText(GetLabel(i));
557 if (!bsLbl.Compare(bsOrig)) { 557 if (!bsLbl.Compare(bsOrig)) {
558 return i; 558 return i;
559 } 559 }
560 } 560 }
561 bsLbl = bsOrig; 561 bsLbl = bsOrig;
562 int nPage = FXSYS_atoi(bsLbl); 562 int nPage = FXSYS_atoi(bsLbl);
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 FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_WSTR wsLabel) const 568 int32_t CPDF_PageLabel::GetPageByLabel(FX_WSTR 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