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

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

Issue 2060913003: Make code compile with clang_use_chrome_plugin (part II) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 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/fpdfdoc/csection.h ('k') | core/fpdfdoc/doc_formcontrol.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 "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
9 #include "core/fpdfdoc/doc_utils.h" 9 #include "core/fpdfdoc/doc_utils.h"
10 #include "core/fpdfdoc/include/fpdf_doc.h" 10 #include "core/fpdfdoc/include/fpdf_doc.h"
(...skipping 13 matching lines...) Expand all
24 24
25 CPDF_Object* pPage = pArray->GetDirectObjectAt(0); 25 CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
26 if (!pPage) 26 if (!pPage)
27 return 0; 27 return 0;
28 if (pPage->IsNumber()) 28 if (pPage->IsNumber())
29 return pPage->GetInteger(); 29 return pPage->GetInteger();
30 if (!pPage->IsDictionary()) 30 if (!pPage->IsDictionary())
31 return 0; 31 return 0;
32 return pDoc->GetPageIndex(pPage->GetObjNum()); 32 return pDoc->GetPageIndex(pPage->GetObjNum());
33 } 33 }
34
34 uint32_t CPDF_Dest::GetPageObjNum() { 35 uint32_t CPDF_Dest::GetPageObjNum() {
35 CPDF_Array* pArray = ToArray(m_pObj); 36 CPDF_Array* pArray = ToArray(m_pObj);
36 if (!pArray) 37 if (!pArray)
37 return 0; 38 return 0;
38 39
39 CPDF_Object* pPage = pArray->GetDirectObjectAt(0); 40 CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
40 if (!pPage) 41 if (!pPage)
41 return 0; 42 return 0;
42 if (pPage->IsNumber()) 43 if (pPage->IsNumber())
43 return pPage->GetInteger(); 44 return pPage->GetInteger();
(...skipping 17 matching lines...) Expand all
61 return i + 1; 62 return i + 1;
62 } 63 }
63 64
64 return 0; 65 return 0;
65 } 66 }
66 67
67 FX_FLOAT CPDF_Dest::GetParam(int index) { 68 FX_FLOAT CPDF_Dest::GetParam(int index) {
68 CPDF_Array* pArray = ToArray(m_pObj); 69 CPDF_Array* pArray = ToArray(m_pObj);
69 return pArray ? pArray->GetNumberAt(2 + index) : 0; 70 return pArray ? pArray->GetNumberAt(2 + index) : 0;
70 } 71 }
72
71 CFX_ByteString CPDF_Dest::GetRemoteName() { 73 CFX_ByteString CPDF_Dest::GetRemoteName() {
72 return m_pObj ? m_pObj->GetString() : CFX_ByteString(); 74 return m_pObj ? m_pObj->GetString() : CFX_ByteString();
73 } 75 }
74 76
75 CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc, 77 CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc,
76 const CFX_ByteString& category) 78 const CFX_ByteString& category)
77 : m_pRoot(nullptr) { 79 : m_pRoot(nullptr) {
78 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 80 CPDF_Dictionary* pRoot = pDoc->GetRoot();
79 if (!pRoot) 81 if (!pRoot)
80 return; 82 return;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const { 219 int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const {
218 if (!m_pRoot) { 220 if (!m_pRoot) {
219 return -1; 221 return -1;
220 } 222 }
221 size_t nIndex = 0; 223 size_t nIndex = 0;
222 if (!SearchNameNode(m_pRoot, csName, nIndex, nullptr)) { 224 if (!SearchNameNode(m_pRoot, csName, nIndex, nullptr)) {
223 return -1; 225 return -1;
224 } 226 }
225 return nIndex; 227 return nIndex;
226 } 228 }
229
227 CPDF_Object* CPDF_NameTree::LookupValue(int nIndex, 230 CPDF_Object* CPDF_NameTree::LookupValue(int nIndex,
228 CFX_ByteString& csName) const { 231 CFX_ByteString& csName) const {
229 if (!m_pRoot) { 232 if (!m_pRoot) {
230 return nullptr; 233 return nullptr;
231 } 234 }
232 size_t nCurIndex = 0; 235 size_t nCurIndex = 0;
233 return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, nullptr); 236 return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, nullptr);
234 } 237 }
238
235 CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const { 239 CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
236 if (!m_pRoot) { 240 if (!m_pRoot) {
237 return nullptr; 241 return nullptr;
238 } 242 }
239 size_t nIndex = 0; 243 size_t nIndex = 0;
240 return SearchNameNode(m_pRoot, csName, nIndex, nullptr); 244 return SearchNameNode(m_pRoot, csName, nIndex, nullptr);
241 } 245 }
246
242 CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, 247 CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
243 const CFX_ByteString& sName) { 248 const CFX_ByteString& sName) {
244 CPDF_Object* pValue = LookupValue(sName); 249 CPDF_Object* pValue = LookupValue(sName);
245 if (!pValue) { 250 if (!pValue) {
246 CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests"); 251 CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests");
247 if (!pDests) 252 if (!pDests)
248 return nullptr; 253 return nullptr;
249 pValue = pDests->GetDirectObjectBy(sName); 254 pValue = pDests->GetDirectObjectBy(sName);
250 } 255 }
251 if (!pValue) 256 if (!pValue)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 const int nLetterCount = 26; 440 const int nLetterCount = 26;
436 num -= 1; 441 num -= 1;
437 int count = num / nLetterCount + 1; 442 int count = num / nLetterCount + 1;
438 count %= nMaxCount; 443 count %= nMaxCount;
439 FX_WCHAR ch = L'a' + num % nLetterCount; 444 FX_WCHAR ch = L'a' + num % nLetterCount;
440 for (int i = 0; i < count; i++) { 445 for (int i = 0; i < count; i++) {
441 wsLetters += ch; 446 wsLetters += ch;
442 } 447 }
443 return wsLetters; 448 return wsLetters;
444 } 449 }
450
445 static CFX_WideString _GetLabelNumPortion(int num, 451 static CFX_WideString _GetLabelNumPortion(int num,
446 const CFX_ByteString& bsStyle) { 452 const CFX_ByteString& bsStyle) {
447 CFX_WideString wsNumPortion; 453 CFX_WideString wsNumPortion;
448 if (bsStyle.IsEmpty()) { 454 if (bsStyle.IsEmpty()) {
449 return wsNumPortion; 455 return wsNumPortion;
450 } 456 }
451 if (bsStyle == "D") { 457 if (bsStyle == "D") {
452 wsNumPortion.Format(L"%d", num); 458 wsNumPortion.Format(L"%d", num);
453 } else if (bsStyle == "R") { 459 } else if (bsStyle == "R") {
454 wsNumPortion = _MakeRoman(num); 460 wsNumPortion = _MakeRoman(num);
455 wsNumPortion.MakeUpper(); 461 wsNumPortion.MakeUpper();
456 } else if (bsStyle == "r") { 462 } else if (bsStyle == "r") {
457 wsNumPortion = _MakeRoman(num); 463 wsNumPortion = _MakeRoman(num);
458 } else if (bsStyle == "A") { 464 } else if (bsStyle == "A") {
459 wsNumPortion = _MakeLetters(num); 465 wsNumPortion = _MakeLetters(num);
460 wsNumPortion.MakeUpper(); 466 wsNumPortion.MakeUpper();
461 } else if (bsStyle == "a") { 467 } else if (bsStyle == "a") {
462 wsNumPortion = _MakeLetters(num); 468 wsNumPortion = _MakeLetters(num);
463 } 469 }
464 return wsNumPortion; 470 return wsNumPortion;
465 } 471 }
472
473 IPDF_FormNotify::~IPDF_FormNotify() {}
474
475 int IPDF_FormNotify::BeforeValueChange(CPDF_FormField* pField,
476 const CFX_WideString& csValue) {
477 return 0;
478 }
479
480 void IPDF_FormNotify::AfterValueChange(CPDF_FormField* pField) {}
481
482 int IPDF_FormNotify::BeforeSelectionChange(CPDF_FormField* pField,
483 const CFX_WideString& csValue) {
484 return 0;
485 }
486
487 void IPDF_FormNotify::AfterSelectionChange(CPDF_FormField* pField) {}
488
489 void IPDF_FormNotify::AfterCheckedStatusChange(CPDF_FormField* pField) {}
490
491 int IPDF_FormNotify::BeforeFormReset(CPDF_InterForm* pForm) {
492 return 0;
493 }
494
495 void IPDF_FormNotify::AfterFormReset(CPDF_InterForm* pForm) {}
496
497 int IPDF_FormNotify::BeforeFormImportData(CPDF_InterForm* pForm) {
498 return 0;
499 }
500
501 void IPDF_FormNotify::AfterFormImportData(CPDF_InterForm* pForm) {}
502
503 CPDF_PageLabel::CPDF_PageLabel(CPDF_Document* pDocument)
504 : m_pDocument(pDocument) {}
505
466 CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { 506 CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
467 CFX_WideString wsLabel; 507 CFX_WideString wsLabel;
468 if (!m_pDocument) { 508 if (!m_pDocument) {
469 return wsLabel; 509 return wsLabel;
470 } 510 }
471 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); 511 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
472 if (!pPDFRoot) { 512 if (!pPDFRoot) {
473 return wsLabel; 513 return wsLabel;
474 } 514 }
475 CPDF_Dictionary* pLabels = pPDFRoot->GetDictBy("PageLabels"); 515 CPDF_Dictionary* pLabels = pPDFRoot->GetDictBy("PageLabels");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return i; 555 return i;
516 } 556 }
517 557
518 int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate. 558 int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate.
519 return nPage > 0 && nPage <= nPages ? nPage : -1; 559 return nPage > 0 && nPage <= nPages ? nPage : -1;
520 } 560 }
521 561
522 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { 562 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
523 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC()); 563 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC());
524 } 564 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/csection.h ('k') | core/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698