OLD | NEW |
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_document.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 } | 506 } |
507 return nullptr; | 507 return nullptr; |
508 } | 508 } |
509 | 509 |
510 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { | 510 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { |
511 CPDF_Dictionary* pRoot = GetRoot(); | 511 CPDF_Dictionary* pRoot = GetRoot(); |
512 return pRoot ? pRoot->GetDictFor("Pages") : nullptr; | 512 return pRoot ? pRoot->GetDictFor("Pages") : nullptr; |
513 } | 513 } |
514 | 514 |
| 515 bool CPDF_Document::IsPageLoaded(int iPage) const { |
| 516 return !!m_PageList.GetAt(iPage); |
| 517 } |
| 518 |
515 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { | 519 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { |
516 if (iPage < 0 || iPage >= m_PageList.GetSize()) | 520 if (iPage < 0 || iPage >= m_PageList.GetSize()) |
517 return nullptr; | 521 return nullptr; |
518 | 522 |
519 if (m_bLinearized && (iPage == m_iFirstPageNo)) { | 523 if (m_bLinearized && (iPage == m_iFirstPageNo)) { |
520 if (CPDF_Dictionary* pDict = | 524 if (CPDF_Dictionary* pDict = |
521 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { | 525 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { |
522 return pDict; | 526 return pDict; |
523 } | 527 } |
524 } | 528 } |
525 | 529 |
526 int objnum = m_PageList.GetAt(iPage); | 530 int objnum = m_PageList.GetAt(iPage); |
527 if (objnum) { | 531 if (objnum) { |
528 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) | 532 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) |
529 return pDict; | 533 return pDict; |
530 } | 534 } |
531 | 535 |
532 CPDF_Dictionary* pPages = GetPagesDict(); | 536 CPDF_Dictionary* pPages = GetPagesDict(); |
533 if (!pPages) | 537 if (!pPages) |
534 return nullptr; | 538 return nullptr; |
535 | 539 |
536 CPDF_Dictionary* pPage = FindPDFPage(pPages, iPage, iPage, 0); | 540 CPDF_Dictionary* pPage = FindPDFPage(pPages, iPage, iPage, 0); |
537 if (!pPage) | 541 if (!pPage) |
538 return nullptr; | 542 return nullptr; |
539 | 543 |
540 m_PageList.SetAt(iPage, pPage->GetObjNum()); | 544 m_PageList.SetAt(iPage, pPage->GetObjNum()); |
541 return pPage; | 545 return pPage; |
542 } | 546 } |
543 | 547 |
| 548 void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) { |
| 549 m_PageList.SetAt(iPage, objNum); |
| 550 } |
| 551 |
544 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, | 552 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, |
545 uint32_t& skip_count, | 553 uint32_t& skip_count, |
546 uint32_t objnum, | 554 uint32_t objnum, |
547 int& index, | 555 int& index, |
548 int level) { | 556 int level) { |
549 if (!pNode->KeyExist("Kids")) { | 557 if (!pNode->KeyExist("Kids")) { |
550 if (objnum == pNode->GetObjNum()) | 558 if (objnum == pNode->GetObjNum()) |
551 return index; | 559 return index; |
552 | 560 |
553 if (skip_count) | 561 if (skip_count) |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 pLogFont->lfWeight / 5); | 1007 pLogFont->lfWeight / 5); |
1000 pFontDesc->SetIntegerFor("CapHeight", capheight); | 1008 pFontDesc->SetIntegerFor("CapHeight", capheight); |
1001 AddIndirectObject(pFontDesc); | 1009 AddIndirectObject(pFontDesc); |
1002 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); | 1010 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); |
1003 hFont = SelectObject(hDC, hFont); | 1011 hFont = SelectObject(hDC, hFont); |
1004 DeleteObject(hFont); | 1012 DeleteObject(hFont); |
1005 DeleteDC(hDC); | 1013 DeleteDC(hDC); |
1006 return LoadFont(pBaseDict); | 1014 return LoadFont(pBaseDict); |
1007 } | 1015 } |
1008 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1016 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
OLD | NEW |