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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page.cpp

Issue 1805663002: Move core/include/fpdfapi/fpdf_page.h to correct locations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
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_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
14 #include "core/fpdfapi/include/cpdf_modulemgr.h" 16 #include "core/fpdfapi/include/cpdf_modulemgr.h"
15 #include "core/fpdfapi/ipdf_rendermodule.h" 17 #include "core/fpdfapi/ipdf_rendermodule.h"
16 #include "core/include/fpdfapi/fpdf_page.h"
17 #include "third_party/base/stl_util.h" 18 #include "third_party/base/stl_util.h"
18 19
19 CPDF_PageObject::CPDF_PageObject() {} 20 CPDF_PageObject::CPDF_PageObject() {}
20 21
21 CPDF_PageObject::~CPDF_PageObject() {} 22 CPDF_PageObject::~CPDF_PageObject() {}
22 23
23 void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) { 24 void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) {
24 CopyStates(*pSrc); 25 CopyStates(*pSrc);
25 m_Left = pSrc->m_Left; 26 m_Left = pSrc->m_Left;
26 m_Right = pSrc->m_Right; 27 m_Right = pSrc->m_Right;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 457
457 void CPDF_FormObject::CalcBoundingBox() { 458 void CPDF_FormObject::CalcBoundingBox() {
458 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); 459 CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
459 form_rect.Transform(&m_FormMatrix); 460 form_rect.Transform(&m_FormMatrix);
460 m_Left = form_rect.left; 461 m_Left = form_rect.left;
461 m_Bottom = form_rect.bottom; 462 m_Bottom = form_rect.bottom;
462 m_Right = form_rect.right; 463 m_Right = form_rect.right;
463 m_Top = form_rect.top; 464 m_Top = form_rect.top;
464 } 465 }
465 466
466 CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) {
467 if (index < 0 || index >= pdfium::CollectionSize<int>(*this))
468 return nullptr;
469 return (*this)[index].get();
470 }
471
472 CPDF_PageObjectHolder::CPDF_PageObjectHolder()
473 : m_pFormDict(nullptr),
474 m_pFormStream(nullptr),
475 m_pDocument(nullptr),
476 m_pPageResources(nullptr),
477 m_pResources(nullptr),
478 m_Transparency(0),
479 m_bBackgroundAlphaNeeded(FALSE),
480 m_bHasImageMask(FALSE),
481 m_ParseState(CONTENT_NOT_PARSED) {}
482
483 void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) {
484 if (!m_pParser) {
485 return;
486 }
487 m_pParser->Continue(pPause);
488 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) {
489 m_ParseState = CONTENT_PARSED;
490 m_pParser.reset();
491 }
492 }
493
494 void CPDF_PageObjectHolder::Transform(const CFX_Matrix& matrix) {
495 for (auto& pObj : m_PageObjectList)
496 pObj->Transform(matrix);
497 }
498
499 CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const {
500 if (m_PageObjectList.empty())
501 return CFX_FloatRect(0, 0, 0, 0);
502
503 FX_FLOAT left = 1000000.0f;
504 FX_FLOAT right = -1000000.0f;
505 FX_FLOAT bottom = 1000000.0f;
506 FX_FLOAT top = -1000000.0f;
507 for (const auto& pObj : m_PageObjectList) {
508 left = std::min(left, pObj->m_Left);
509 right = std::max(right, pObj->m_Right);
510 bottom = std::min(bottom, pObj->m_Bottom);
511 top = std::max(top, pObj->m_Top);
512 }
513 return CFX_FloatRect(left, bottom, right, top);
514 }
515
516 void CPDF_PageObjectHolder::LoadTransInfo() {
517 if (!m_pFormDict) {
518 return;
519 }
520 CPDF_Dictionary* pGroup = m_pFormDict->GetDictBy("Group");
521 if (!pGroup) {
522 return;
523 }
524 if (pGroup->GetStringBy("S") != "Transparency") {
525 return;
526 }
527 m_Transparency |= PDFTRANS_GROUP;
528 if (pGroup->GetIntegerBy("I")) {
529 m_Transparency |= PDFTRANS_ISOLATED;
530 }
531 if (pGroup->GetIntegerBy("K")) {
532 m_Transparency |= PDFTRANS_KNOCKOUT;
533 }
534 }
535
536 CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {} 467 CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {}
537 468
538 void CPDF_Page::Load(CPDF_Document* pDocument, 469 void CPDF_Page::Load(CPDF_Document* pDocument,
539 CPDF_Dictionary* pPageDict, 470 CPDF_Dictionary* pPageDict,
540 FX_BOOL bPageCache) { 471 FX_BOOL bPageCache) {
541 m_pDocument = (CPDF_Document*)pDocument; 472 m_pDocument = (CPDF_Document*)pDocument;
542 m_pFormDict = pPageDict; 473 m_pFormDict = pPageDict;
543 if (bPageCache) { 474 if (bPageCache) {
544 m_pPageRender = 475 m_pPageRender =
545 CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this); 476 CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if (level == 1000) { 574 if (level == 1000) {
644 return NULL; 575 return NULL;
645 } 576 }
646 } 577 }
647 } 578 }
648 579
649 CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteStringC& name) const { 580 CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteStringC& name) const {
650 return FPDFAPI_GetPageAttr(m_pFormDict, name); 581 return FPDFAPI_GetPageAttr(m_pFormDict, name);
651 } 582 }
652 583
653 CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
654 CPDF_Dictionary* pPageResources,
655 CPDF_Stream* pFormStream,
656 CPDF_Dictionary* pParentResources) {
657 m_pDocument = pDoc;
658 m_pFormStream = pFormStream;
659 m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL;
660 m_pResources = m_pFormDict->GetDictBy("Resources");
661 m_pPageResources = pPageResources;
662 if (!m_pResources) {
663 m_pResources = pParentResources;
664 }
665 if (!m_pResources) {
666 m_pResources = pPageResources;
667 }
668 m_Transparency = 0;
669 LoadTransInfo();
670 }
671
672 CPDF_Form::~CPDF_Form() {}
673
674 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
675 CFX_Matrix* pParentMatrix,
676 CPDF_Type3Char* pType3Char,
677 CPDF_ParseOptions* pOptions,
678 int level) {
679 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
680 return;
681 }
682 m_pParser.reset(new CPDF_ContentParser);
683 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions,
684 level);
685 m_ParseState = CONTENT_PARSING;
686 }
687
688 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates,
689 CFX_Matrix* pParentMatrix,
690 CPDF_Type3Char* pType3Char,
691 CPDF_ParseOptions* pOptions,
692 int level) {
693 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level);
694 ContinueParse(NULL);
695 }
696
697 CPDF_Form* CPDF_Form::Clone() const {
698 CPDF_Form* pCloneForm =
699 new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources);
700 for (const auto& pObj : m_PageObjectList)
701 pCloneForm->m_PageObjectList.emplace_back(pObj->Clone());
702
703 return pCloneForm;
704 }
705
706 void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, 584 void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
707 int xPos, 585 int xPos,
708 int yPos, 586 int yPos,
709 int xSize, 587 int xSize,
710 int ySize, 588 int ySize,
711 int iRotate) const { 589 int iRotate) const {
712 if (m_PageWidth == 0 || m_PageHeight == 0) { 590 if (m_PageWidth == 0 || m_PageHeight == 0) {
713 return; 591 return;
714 } 592 }
715 CFX_Matrix display_matrix; 593 CFX_Matrix display_matrix;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 y2 = yPos; 627 y2 = yPos;
750 break; 628 break;
751 } 629 }
752 display_matrix.Set( 630 display_matrix.Set(
753 ((FX_FLOAT)(x2 - x0)) / m_PageWidth, ((FX_FLOAT)(y2 - y0)) / m_PageWidth, 631 ((FX_FLOAT)(x2 - x0)) / m_PageWidth, ((FX_FLOAT)(y2 - y0)) / m_PageWidth,
754 ((FX_FLOAT)(x1 - x0)) / m_PageHeight, 632 ((FX_FLOAT)(x1 - x0)) / m_PageHeight,
755 ((FX_FLOAT)(y1 - y0)) / m_PageHeight, (FX_FLOAT)x0, (FX_FLOAT)y0); 633 ((FX_FLOAT)(y1 - y0)) / m_PageHeight, (FX_FLOAT)x0, (FX_FLOAT)y0);
756 matrix = m_PageMatrix; 634 matrix = m_PageMatrix;
757 matrix.Concat(display_matrix); 635 matrix.Concat(display_matrix);
758 } 636 }
759
760 CPDF_ParseOptions::CPDF_ParseOptions() {
761 m_bTextOnly = FALSE;
762 m_bMarkedContent = TRUE;
763 m_bSeparateForm = TRUE;
764 m_bDecodeInlineImage = FALSE;
765 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_colors.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698