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/parser/cpdf_document.h" | 7 #include "core/fpdfapi/parser/cpdf_document.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | |
12 #include <vector> | 11 #include <vector> |
13 | 12 |
14 #include "core/fpdfapi/cpdf_modulemgr.h" | 13 #include "core/fpdfapi/cpdf_modulemgr.h" |
15 #include "core/fpdfapi/font/cpdf_fontencoding.h" | 14 #include "core/fpdfapi/font/cpdf_fontencoding.h" |
16 #include "core/fpdfapi/page/cpdf_docpagedata.h" | 15 #include "core/fpdfapi/page/cpdf_docpagedata.h" |
17 #include "core/fpdfapi/page/cpdf_pagemodule.h" | 16 #include "core/fpdfapi/page/cpdf_pagemodule.h" |
18 #include "core/fpdfapi/page/pageint.h" | 17 #include "core/fpdfapi/page/pageint.h" |
19 #include "core/fpdfapi/parser/cpdf_array.h" | 18 #include "core/fpdfapi/parser/cpdf_array.h" |
20 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 19 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
21 #include "core/fpdfapi/parser/cpdf_number.h" | 20 #include "core/fpdfapi/parser/cpdf_number.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 int size = end - start + 1; | 233 int size = end - start + 1; |
235 int* widths = FX_Alloc(int, size); | 234 int* widths = FX_Alloc(int, size); |
236 int i; | 235 int i; |
237 for (i = 0; i < size; i++) { | 236 for (i = 0; i < size; i++) { |
238 int glyph_index = pEncoding->GlyphFromCharCode(start + i); | 237 int glyph_index = pEncoding->GlyphFromCharCode(start + i); |
239 widths[i] = pFont->GetGlyphWidth(glyph_index); | 238 widths[i] = pFont->GetGlyphWidth(glyph_index); |
240 } | 239 } |
241 InsertWidthArrayImpl(widths, size, pWidthArray); | 240 InsertWidthArrayImpl(widths, size, pWidthArray); |
242 } | 241 } |
243 | 242 |
| 243 int InsertDeletePDFPage(CPDF_Document* pDoc, |
| 244 CPDF_Dictionary* pPages, |
| 245 int nPagesToGo, |
| 246 CPDF_Dictionary* pPage, |
| 247 FX_BOOL bInsert, |
| 248 std::set<CPDF_Dictionary*>* pVisited) { |
| 249 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); |
| 250 if (!pKidList) |
| 251 return -1; |
| 252 |
| 253 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
| 254 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
| 255 if (pKid->GetStringFor("Type") == "Page") { |
| 256 if (nPagesToGo == 0) { |
| 257 if (bInsert) { |
| 258 pKidList->InsertAt(i, new CPDF_Reference(pDoc, pPage->GetObjNum())); |
| 259 pPage->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); |
| 260 } else { |
| 261 pKidList->RemoveAt(i); |
| 262 } |
| 263 pPages->SetIntegerFor( |
| 264 "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); |
| 265 return 1; |
| 266 } |
| 267 nPagesToGo--; |
| 268 } else { |
| 269 int nPages = pKid->GetIntegerFor("Count"); |
| 270 if (nPagesToGo < nPages) { |
| 271 if (pdfium::ContainsKey(*pVisited, pKid)) |
| 272 return -1; |
| 273 |
| 274 pdfium::ScopedSetInsertion<CPDF_Dictionary*> insertion(pVisited, pKid); |
| 275 if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert, |
| 276 pVisited) < 0) { |
| 277 return -1; |
| 278 } |
| 279 pPages->SetIntegerFor( |
| 280 "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); |
| 281 return 1; |
| 282 } |
| 283 nPagesToGo -= nPages; |
| 284 } |
| 285 } |
| 286 return 0; |
| 287 } |
| 288 |
| 289 int InsertNewPage(CPDF_Document* pDoc, |
| 290 int iPage, |
| 291 CPDF_Dictionary* pPageDict, |
| 292 CFX_ArrayTemplate<uint32_t>& pageList) { |
| 293 CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
| 294 CPDF_Dictionary* pPages = pRoot ? pRoot->GetDictFor("Pages") : nullptr; |
| 295 if (!pPages) |
| 296 return -1; |
| 297 |
| 298 int nPages = pDoc->GetPageCount(); |
| 299 if (iPage < 0 || iPage > nPages) |
| 300 return -1; |
| 301 |
| 302 if (iPage == nPages) { |
| 303 CPDF_Array* pPagesList = pPages->GetArrayFor("Kids"); |
| 304 if (!pPagesList) { |
| 305 pPagesList = new CPDF_Array; |
| 306 pPages->SetFor("Kids", pPagesList); |
| 307 } |
| 308 pPagesList->Add(new CPDF_Reference(pDoc, pPageDict->GetObjNum())); |
| 309 pPages->SetIntegerFor("Count", nPages + 1); |
| 310 pPageDict->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); |
| 311 } else { |
| 312 std::set<CPDF_Dictionary*> stack = {pPages}; |
| 313 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0) |
| 314 return -1; |
| 315 } |
| 316 pageList.InsertAt(iPage, pPageDict->GetObjNum()); |
| 317 return iPage; |
| 318 } |
| 319 |
244 int CountPages(CPDF_Dictionary* pPages, | 320 int CountPages(CPDF_Dictionary* pPages, |
245 std::set<CPDF_Dictionary*>* visited_pages) { | 321 std::set<CPDF_Dictionary*>* visited_pages) { |
246 int count = pPages->GetIntegerFor("Count"); | 322 int count = pPages->GetIntegerFor("Count"); |
247 if (count > 0 && count < FPDF_PAGE_MAX_NUM) | 323 if (count > 0 && count < FPDF_PAGE_MAX_NUM) |
248 return count; | 324 return count; |
249 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); | 325 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); |
250 if (!pKidList) | 326 if (!pKidList) |
251 return 0; | 327 return 0; |
252 count = 0; | 328 count = 0; |
253 for (size_t i = 0; i < pKidList->GetCount(); i++) { | 329 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 return pFontDesc; | 406 return pFontDesc; |
331 } | 407 } |
332 | 408 |
333 } // namespace | 409 } // namespace |
334 | 410 |
335 CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser) | 411 CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser) |
336 : CPDF_IndirectObjectHolder(), | 412 : CPDF_IndirectObjectHolder(), |
337 m_pParser(std::move(pParser)), | 413 m_pParser(std::move(pParser)), |
338 m_pRootDict(nullptr), | 414 m_pRootDict(nullptr), |
339 m_pInfoDict(nullptr), | 415 m_pInfoDict(nullptr), |
340 m_iLastPageTraversed(-1), | |
341 m_bLinearized(false), | 416 m_bLinearized(false), |
342 m_iFirstPageNo(0), | 417 m_iFirstPageNo(0), |
343 m_dwFirstPageObjNum(0), | 418 m_dwFirstPageObjNum(0), |
344 m_pDocPage(new CPDF_DocPageData(this)), | 419 m_pDocPage(new CPDF_DocPageData(this)), |
345 m_pDocRender(new CPDF_DocRenderData(this)), | 420 m_pDocRender(new CPDF_DocRenderData(this)), |
346 m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) { | 421 m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) { |
347 if (pParser) | 422 if (pParser) |
348 SetLastObjNum(m_pParser->GetLastObjNum()); | 423 SetLastObjNum(m_pParser->GetLastObjNum()); |
349 } | 424 } |
350 | 425 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 470 |
396 CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O"); | 471 CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O"); |
397 if (ToNumber(pObjNum)) | 472 if (ToNumber(pObjNum)) |
398 m_dwFirstPageObjNum = pObjNum->GetInteger(); | 473 m_dwFirstPageObjNum = pObjNum->GetInteger(); |
399 } | 474 } |
400 | 475 |
401 void CPDF_Document::LoadPages() { | 476 void CPDF_Document::LoadPages() { |
402 m_PageList.SetSize(RetrievePageCount()); | 477 m_PageList.SetSize(RetrievePageCount()); |
403 } | 478 } |
404 | 479 |
405 CPDF_Dictionary* CPDF_Document::TraversePDFPages(int iPage, int nPagesToGo) { | 480 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, |
406 std::pair<CPDF_Dictionary*, int>* lastProc = &m_pTreeTraversal.top(); | 481 int iPage, |
407 CPDF_Dictionary* pPages = lastProc->first; | 482 int nPagesToGo, |
| 483 int level) { |
408 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); | 484 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); |
409 if (!pKidList) { | 485 if (!pKidList) |
410 m_pTreeTraversal.pop(); | 486 return nPagesToGo == 0 ? pPages : nullptr; |
411 if (nPagesToGo != 1) | |
412 return nullptr; | |
413 m_PageList.SetAt(iPage, pPages->GetObjNum()); | |
414 return pPages; | |
415 } | |
416 | 487 |
417 if (m_pTreeTraversal.size() >= FX_MAX_PAGE_LEVEL) { | 488 if (level >= FX_MAX_PAGE_LEVEL) |
418 m_pTreeTraversal.pop(); | |
419 return nullptr; | 489 return nullptr; |
420 } | |
421 | 490 |
422 bool shouldFinish = pPages->GetIntegerFor("Count") <= nPagesToGo; | 491 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
423 CPDF_Dictionary* page = nullptr; | |
424 for (size_t i = lastProc->second + 1; i < pKidList->GetCount(); i++) { | |
425 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 492 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
426 if (!pKid) { | 493 if (!pKid) { |
427 nPagesToGo--; | 494 nPagesToGo--; |
428 lastProc->second++; | |
429 continue; | 495 continue; |
430 } | 496 } |
431 if (pKid == pPages) { | 497 if (pKid == pPages) |
432 lastProc->second++; | |
433 continue; | 498 continue; |
434 } | |
435 if (!pKid->KeyExist("Kids")) { | 499 if (!pKid->KeyExist("Kids")) { |
436 m_PageList.SetAt(iPage - nPagesToGo + 1, pKid->GetObjNum()); | 500 if (nPagesToGo == 0) |
| 501 return pKid; |
| 502 |
| 503 m_PageList.SetAt(iPage - nPagesToGo, pKid->GetObjNum()); |
437 nPagesToGo--; | 504 nPagesToGo--; |
438 lastProc->second++; | |
439 if (nPagesToGo == 0) { | |
440 page = pKid; | |
441 break; | |
442 } | |
443 } else { | 505 } else { |
444 int nPages = pKid->GetIntegerFor("Count"); | 506 int nPages = pKid->GetIntegerFor("Count"); |
445 m_pTreeTraversal.push(std::make_pair(pKid, -1)); | 507 if (nPagesToGo < nPages) |
446 CPDF_Dictionary* pageKid = TraversePDFPages(iPage, nPagesToGo); | 508 return FindPDFPage(pKid, iPage, nPagesToGo, level + 1); |
447 // If the stack top is current element, kid was completely processed. | 509 |
448 if (lastProc == &m_pTreeTraversal.top()) | |
449 lastProc->second++; | |
450 if (nPagesToGo <= nPages) { | |
451 page = pageKid; | |
452 break; | |
453 } | |
454 nPagesToGo -= nPages; | 510 nPagesToGo -= nPages; |
455 } | 511 } |
456 } | 512 } |
457 if (shouldFinish || | 513 return nullptr; |
458 lastProc->second == static_cast<int>(pKidList->GetCount() - 1)) { | |
459 m_pTreeTraversal.pop(); | |
460 } | |
461 return page; | |
462 } | 514 } |
463 | 515 |
464 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { | 516 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { |
465 CPDF_Dictionary* pRoot = GetRoot(); | 517 CPDF_Dictionary* pRoot = GetRoot(); |
466 return pRoot ? pRoot->GetDictFor("Pages") : nullptr; | 518 return pRoot ? pRoot->GetDictFor("Pages") : nullptr; |
467 } | 519 } |
468 | 520 |
469 bool CPDF_Document::IsPageLoaded(int iPage) const { | 521 bool CPDF_Document::IsPageLoaded(int iPage) const { |
470 return !!m_PageList.GetAt(iPage); | 522 return !!m_PageList.GetAt(iPage); |
471 } | 523 } |
472 | 524 |
473 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { | 525 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { |
474 if (iPage < 0 || iPage >= m_PageList.GetSize()) | 526 if (iPage < 0 || iPage >= m_PageList.GetSize()) |
475 return nullptr; | 527 return nullptr; |
476 | 528 |
477 if (m_bLinearized && (iPage == m_iFirstPageNo)) { | 529 if (m_bLinearized && (iPage == m_iFirstPageNo)) { |
478 if (CPDF_Dictionary* pDict = | 530 if (CPDF_Dictionary* pDict = |
479 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { | 531 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { |
480 return pDict; | 532 return pDict; |
481 } | 533 } |
482 } | 534 } |
483 | 535 |
484 int objnum = m_PageList.GetAt(iPage); | 536 int objnum = m_PageList.GetAt(iPage); |
485 if (!objnum || m_iLastPageTraversed < iPage) { | 537 if (objnum) { |
486 CPDF_Dictionary* pPages = GetPagesDict(); | 538 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) |
487 if (!pPages) | 539 return pDict; |
488 return nullptr; | |
489 if (m_pTreeTraversal.empty()) | |
490 m_pTreeTraversal.push(std::make_pair(pPages, -1)); | |
491 CPDF_Dictionary* page = TraversePDFPages(m_iLastPageTraversed + 1, | |
492 iPage - m_iLastPageTraversed); | |
493 m_iLastPageTraversed = iPage; | |
494 return page; | |
495 } | 540 } |
496 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) | 541 |
497 return pDict; | 542 CPDF_Dictionary* pPages = GetPagesDict(); |
498 return nullptr; | 543 if (!pPages) |
| 544 return nullptr; |
| 545 |
| 546 CPDF_Dictionary* pPage = FindPDFPage(pPages, iPage, iPage, 0); |
| 547 if (!pPage) |
| 548 return nullptr; |
| 549 |
| 550 m_PageList.SetAt(iPage, pPage->GetObjNum()); |
| 551 return pPage; |
499 } | 552 } |
500 | 553 |
501 void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) { | 554 void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) { |
502 m_PageList.SetAt(iPage, objNum); | 555 m_PageList.SetAt(iPage, objNum); |
503 } | 556 } |
504 | 557 |
505 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, | 558 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, |
506 uint32_t& skip_count, | 559 uint32_t& skip_count, |
507 uint32_t objnum, | 560 uint32_t objnum, |
508 int& index, | 561 int& index, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 pPages->SetFor("Kids", new CPDF_Array); | 703 pPages->SetFor("Kids", new CPDF_Array); |
651 m_pRootDict->SetReferenceFor("Pages", this, AddIndirectObject(pPages)); | 704 m_pRootDict->SetReferenceFor("Pages", this, AddIndirectObject(pPages)); |
652 m_pInfoDict = new CPDF_Dictionary(m_pByteStringPool); | 705 m_pInfoDict = new CPDF_Dictionary(m_pByteStringPool); |
653 AddIndirectObject(m_pInfoDict); | 706 AddIndirectObject(m_pInfoDict); |
654 } | 707 } |
655 | 708 |
656 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { | 709 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { |
657 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pByteStringPool); | 710 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pByteStringPool); |
658 pDict->SetNameFor("Type", "Page"); | 711 pDict->SetNameFor("Type", "Page"); |
659 uint32_t dwObjNum = AddIndirectObject(pDict); | 712 uint32_t dwObjNum = AddIndirectObject(pDict); |
660 if (InsertNewPage(iPage, pDict, m_PageList) < 0) { | 713 if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) { |
661 ReleaseIndirectObject(dwObjNum); | 714 ReleaseIndirectObject(dwObjNum); |
662 return nullptr; | 715 return nullptr; |
663 } | 716 } |
664 return pDict; | 717 return pDict; |
665 } | 718 } |
666 | 719 |
667 int CPDF_Document::InsertDeletePDFPage(CPDF_Dictionary* pPages, | |
668 int nPagesToGo, | |
669 CPDF_Dictionary* pPage, | |
670 FX_BOOL bInsert, | |
671 std::set<CPDF_Dictionary*>* pVisited) { | |
672 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); | |
673 if (!pKidList) | |
674 return -1; | |
675 | |
676 for (size_t i = 0; i < pKidList->GetCount(); i++) { | |
677 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | |
678 if (pKid->GetStringFor("Type") == "Page") { | |
679 if (nPagesToGo == 0) { | |
680 if (bInsert) { | |
681 pKidList->InsertAt(i, new CPDF_Reference(this, pPage->GetObjNum())); | |
682 pPage->SetReferenceFor("Parent", this, pPages->GetObjNum()); | |
683 } else { | |
684 pKidList->RemoveAt(i); | |
685 } | |
686 pPages->SetIntegerFor( | |
687 "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); | |
688 // Tree will change, so reset tree transversal variables | |
689 m_iLastPageTraversed = -1; | |
690 m_pTreeTraversal = std::stack<std::pair<CPDF_Dictionary*, int>>(); | |
691 return 1; | |
692 } | |
693 nPagesToGo--; | |
694 } else { | |
695 int nPages = pKid->GetIntegerFor("Count"); | |
696 if (nPagesToGo < nPages) { | |
697 if (pdfium::ContainsKey(*pVisited, pKid)) | |
698 return -1; | |
699 | |
700 pdfium::ScopedSetInsertion<CPDF_Dictionary*> insertion(pVisited, pKid); | |
701 if (InsertDeletePDFPage(pKid, nPagesToGo, pPage, bInsert, pVisited) < | |
702 0) { | |
703 return -1; | |
704 } | |
705 pPages->SetIntegerFor( | |
706 "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); | |
707 return 1; | |
708 } | |
709 nPagesToGo -= nPages; | |
710 } | |
711 } | |
712 return 0; | |
713 } | |
714 | |
715 int CPDF_Document::InsertNewPage(int iPage, | |
716 CPDF_Dictionary* pPageDict, | |
717 CFX_ArrayTemplate<uint32_t>& pageList) { | |
718 CPDF_Dictionary* pRoot = GetRoot(); | |
719 CPDF_Dictionary* pPages = pRoot ? pRoot->GetDictFor("Pages") : nullptr; | |
720 if (!pPages) | |
721 return -1; | |
722 | |
723 int nPages = GetPageCount(); | |
724 if (iPage < 0 || iPage > nPages) | |
725 return -1; | |
726 | |
727 if (iPage == nPages) { | |
728 CPDF_Array* pPagesList = pPages->GetArrayFor("Kids"); | |
729 if (!pPagesList) { | |
730 pPagesList = new CPDF_Array; | |
731 pPages->SetFor("Kids", pPagesList); | |
732 } | |
733 pPagesList->Add(new CPDF_Reference(this, pPageDict->GetObjNum())); | |
734 pPages->SetIntegerFor("Count", nPages + 1); | |
735 pPageDict->SetReferenceFor("Parent", this, pPages->GetObjNum()); | |
736 } else { | |
737 std::set<CPDF_Dictionary*> stack = {pPages}; | |
738 if (InsertDeletePDFPage(pPages, iPage, pPageDict, TRUE, &stack) < 0) | |
739 return -1; | |
740 } | |
741 pageList.InsertAt(iPage, pPageDict->GetObjNum()); | |
742 return iPage; | |
743 } | |
744 | |
745 void CPDF_Document::DeletePage(int iPage) { | 720 void CPDF_Document::DeletePage(int iPage) { |
746 CPDF_Dictionary* pPages = GetPagesDict(); | 721 CPDF_Dictionary* pPages = GetPagesDict(); |
747 if (!pPages) | 722 if (!pPages) |
748 return; | 723 return; |
749 | 724 |
750 int nPages = pPages->GetIntegerFor("Count"); | 725 int nPages = pPages->GetIntegerFor("Count"); |
751 if (iPage < 0 || iPage >= nPages) | 726 if (iPage < 0 || iPage >= nPages) |
752 return; | 727 return; |
753 | 728 |
754 std::set<CPDF_Dictionary*> stack = {pPages}; | 729 std::set<CPDF_Dictionary*> stack = {pPages}; |
755 if (InsertDeletePDFPage(pPages, iPage, nullptr, FALSE, &stack) < 0) | 730 if (InsertDeletePDFPage(this, pPages, iPage, nullptr, FALSE, &stack) < 0) |
756 return; | 731 return; |
757 | 732 |
758 m_PageList.RemoveAt(iPage); | 733 m_PageList.RemoveAt(iPage); |
759 } | 734 } |
760 | 735 |
761 CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, | 736 CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, |
762 CPDF_FontEncoding* pEncoding) { | 737 CPDF_FontEncoding* pEncoding) { |
763 CFX_ByteString name(font); | 738 CFX_ByteString name(font); |
764 if (PDF_GetStandardFontName(&name) < 0) | 739 if (PDF_GetStandardFontName(&name) < 0) |
765 return nullptr; | 740 return nullptr; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 pBBox, pLogFont->lfWeight / 5); | 1013 pBBox, pLogFont->lfWeight / 5); |
1039 pFontDesc->SetIntegerFor("CapHeight", capheight); | 1014 pFontDesc->SetIntegerFor("CapHeight", capheight); |
1040 pFontDict->SetReferenceFor("FontDescriptor", this, | 1015 pFontDict->SetReferenceFor("FontDescriptor", this, |
1041 AddIndirectObject(pFontDesc)); | 1016 AddIndirectObject(pFontDesc)); |
1042 hFont = SelectObject(hDC, hFont); | 1017 hFont = SelectObject(hDC, hFont); |
1043 DeleteObject(hFont); | 1018 DeleteObject(hFont); |
1044 DeleteDC(hDC); | 1019 DeleteDC(hDC); |
1045 return LoadFont(pBaseDict); | 1020 return LoadFont(pBaseDict); |
1046 } | 1021 } |
1047 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1022 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
OLD | NEW |