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

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

Issue 1636503006: Merge to XFA: War on #defines, part 1. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Stray ! Created 4 years, 10 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 "pageint.h" 7 #include "pageint.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
11 11
12 CPDF_PageObject* CPDF_PageObject::Create(int type) { 12 CPDF_PageObject* CPDF_PageObject::Create(int type) {
13 switch (type) { 13 switch (type) {
14 case PDFPAGE_TEXT: 14 case TEXT:
15 return new CPDF_TextObject; 15 return new CPDF_TextObject;
16 case PDFPAGE_IMAGE: 16 case IMAGE:
17 return new CPDF_ImageObject; 17 return new CPDF_ImageObject;
18 case PDFPAGE_PATH: 18 case PATH:
19 return new CPDF_PathObject; 19 return new CPDF_PathObject;
20 case PDFPAGE_SHADING: 20 case SHADING:
21 return new CPDF_ShadingObject; 21 return new CPDF_ShadingObject;
22 case PDFPAGE_FORM: 22 case FORM:
23 return new CPDF_FormObject; 23 return new CPDF_FormObject;
24 } 24 }
25 return NULL; 25 return NULL;
26 } 26 }
27 CPDF_PageObject::~CPDF_PageObject() {} 27 CPDF_PageObject::~CPDF_PageObject() {}
28 CPDF_PageObject* CPDF_PageObject::Clone() const { 28 CPDF_PageObject* CPDF_PageObject::Clone() const {
29 CPDF_PageObject* pObj = Create(m_Type); 29 CPDF_PageObject* pObj = Create(m_Type);
30 pObj->Copy(this); 30 pObj->Copy(this);
31 return pObj; 31 return pObj;
32 } 32 }
(...skipping 14 matching lines...) Expand all
47 m_ClipPath.AppendPath(path, type, bAutoMerge); 47 m_ClipPath.AppendPath(path, type, bAutoMerge);
48 } 48 }
49 void CPDF_PageObject::CopyClipPath(CPDF_PageObject* pObj) { 49 void CPDF_PageObject::CopyClipPath(CPDF_PageObject* pObj) {
50 m_ClipPath = pObj->m_ClipPath; 50 m_ClipPath = pObj->m_ClipPath;
51 } 51 }
52 void CPDF_PageObject::RemoveClipPath() { 52 void CPDF_PageObject::RemoveClipPath() {
53 m_ClipPath.SetNull(); 53 m_ClipPath.SetNull();
54 } 54 }
55 void CPDF_PageObject::RecalcBBox() { 55 void CPDF_PageObject::RecalcBBox() {
56 switch (m_Type) { 56 switch (m_Type) {
57 case PDFPAGE_TEXT: 57 case TEXT:
58 ((CPDF_TextObject*)this)->RecalcPositionData(); 58 ((CPDF_TextObject*)this)->RecalcPositionData();
59 break; 59 break;
60 case PDFPAGE_PATH: 60 case PATH:
61 ((CPDF_PathObject*)this)->CalcBoundingBox(); 61 ((CPDF_PathObject*)this)->CalcBoundingBox();
62 break; 62 break;
63 case PDFPAGE_SHADING: 63 case SHADING:
64 ((CPDF_ShadingObject*)this)->CalcBoundingBox(); 64 ((CPDF_ShadingObject*)this)->CalcBoundingBox();
65 break; 65 break;
66 default:
67 break;
66 } 68 }
67 } 69 }
68 void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) { 70 void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) {
69 if (m_ClipPath.IsNull()) { 71 if (m_ClipPath.IsNull()) {
70 return; 72 return;
71 } 73 }
72 m_ClipPath.GetModify(); 74 m_ClipPath.GetModify();
73 m_ClipPath.Transform(matrix); 75 m_ClipPath.Transform(matrix);
74 } 76 }
75 void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) { 77 void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) {
76 if (m_GeneralState.IsNull()) { 78 if (m_GeneralState.IsNull()) {
77 return; 79 return;
78 } 80 }
79 CPDF_GeneralStateData* pGS = m_GeneralState.GetModify(); 81 CPDF_GeneralStateData* pGS = m_GeneralState.GetModify();
80 pGS->m_Matrix.Concat(matrix); 82 pGS->m_Matrix.Concat(matrix);
81 } 83 }
82 FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const { 84 FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
83 CFX_FloatRect rect(m_Left, m_Bottom, m_Right, m_Top); 85 CFX_FloatRect rect(m_Left, m_Bottom, m_Right, m_Top);
84 if (pMatrix) { 86 if (pMatrix) {
85 pMatrix->TransformRect(rect); 87 pMatrix->TransformRect(rect);
86 } 88 }
87 return rect.GetOutterRect(); 89 return rect.GetOutterRect();
88 } 90 }
89 91
90 CPDF_TextObject::CPDF_TextObject() 92 CPDF_TextObject::CPDF_TextObject()
91 : m_PosX(0), 93 : CPDF_PageObject(TEXT),
94 m_PosX(0),
92 m_PosY(0), 95 m_PosY(0),
93 m_nChars(0), 96 m_nChars(0),
94 m_pCharCodes(nullptr), 97 m_pCharCodes(nullptr),
95 m_pCharPos(nullptr) { 98 m_pCharPos(nullptr) {}
96 m_Type = PDFPAGE_TEXT;
97 }
98 99
99 CPDF_TextObject::~CPDF_TextObject() { 100 CPDF_TextObject::~CPDF_TextObject() {
100 if (m_nChars > 1) { 101 if (m_nChars > 1) {
101 FX_Free(m_pCharCodes); 102 FX_Free(m_pCharCodes);
102 } 103 }
103 FX_Free(m_pCharPos); 104 FX_Free(m_pCharPos);
104 } 105 }
105 106
106 void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { 107 void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const {
107 pInfo->m_CharCode = 108 pInfo->m_CharCode =
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 FXSYS_memcpy(m_pCharPos, pCharPos, sizeof(FX_FLOAT) * (nChars - 1)); 601 FXSYS_memcpy(m_pCharPos, pCharPos, sizeof(FX_FLOAT) * (nChars - 1));
601 } 602 }
602 RecalcPositionData(); 603 RecalcPositionData();
603 } 604 }
604 605
605 void CPDF_TextObject::SetTextState(CPDF_TextState TextState) { 606 void CPDF_TextObject::SetTextState(CPDF_TextState TextState) {
606 m_TextState = TextState; 607 m_TextState = TextState;
607 CalcPositionData(nullptr, nullptr, 0); 608 CalcPositionData(nullptr, nullptr, 0);
608 } 609 }
609 610
610 CPDF_ShadingObject::CPDF_ShadingObject() { 611 CPDF_ShadingObject::CPDF_ShadingObject()
611 m_pShading = NULL; 612 : CPDF_PageObject(SHADING), m_pShading(nullptr) {}
612 m_Type = PDFPAGE_SHADING; 613
613 }
614 CPDF_ShadingObject::~CPDF_ShadingObject() {} 614 CPDF_ShadingObject::~CPDF_ShadingObject() {}
615
615 void CPDF_ShadingObject::CopyData(const CPDF_PageObject* pSrc) { 616 void CPDF_ShadingObject::CopyData(const CPDF_PageObject* pSrc) {
616 CPDF_ShadingObject* pSrcObj = (CPDF_ShadingObject*)pSrc; 617 CPDF_ShadingObject* pSrcObj = (CPDF_ShadingObject*)pSrc;
617 m_pShading = pSrcObj->m_pShading; 618 m_pShading = pSrcObj->m_pShading;
618 if (m_pShading && m_pShading->m_pDocument) { 619 if (m_pShading && m_pShading->m_pDocument) {
619 CPDF_DocPageData* pDocPageData = m_pShading->m_pDocument->GetPageData(); 620 CPDF_DocPageData* pDocPageData = m_pShading->m_pDocument->GetPageData();
620 m_pShading = (CPDF_ShadingPattern*)pDocPageData->GetPattern( 621 m_pShading = (CPDF_ShadingPattern*)pDocPageData->GetPattern(
621 m_pShading->m_pShadingObj, m_pShading->m_bShadingObj, 622 m_pShading->m_pShadingObj, m_pShading->m_bShadingObj,
622 &m_pShading->m_ParentMatrix); 623 &m_pShading->m_ParentMatrix);
623 } 624 }
624 m_Matrix = pSrcObj->m_Matrix; 625 m_Matrix = pSrcObj->m_Matrix;
625 } 626 }
627
626 void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { 628 void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
627 if (!m_ClipPath.IsNull()) { 629 if (!m_ClipPath.IsNull()) {
628 m_ClipPath.GetModify(); 630 m_ClipPath.GetModify();
629 m_ClipPath.Transform(matrix); 631 m_ClipPath.Transform(matrix);
630 } 632 }
631 m_Matrix.Concat(matrix); 633 m_Matrix.Concat(matrix);
632 if (!m_ClipPath.IsNull()) { 634 if (!m_ClipPath.IsNull()) {
633 CalcBoundingBox(); 635 CalcBoundingBox();
634 } else { 636 } else {
635 matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); 637 matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
636 } 638 }
637 } 639 }
640
638 void CPDF_ShadingObject::CalcBoundingBox() { 641 void CPDF_ShadingObject::CalcBoundingBox() {
639 if (m_ClipPath.IsNull()) { 642 if (m_ClipPath.IsNull()) {
640 return; 643 return;
641 } 644 }
642 CFX_FloatRect rect = m_ClipPath.GetClipBox(); 645 CFX_FloatRect rect = m_ClipPath.GetClipBox();
643 m_Left = rect.left; 646 m_Left = rect.left;
644 m_Bottom = rect.bottom; 647 m_Bottom = rect.bottom;
645 m_Right = rect.right; 648 m_Right = rect.right;
646 m_Top = rect.top; 649 m_Top = rect.top;
647 } 650 }
651
648 CPDF_FormObject::~CPDF_FormObject() { 652 CPDF_FormObject::~CPDF_FormObject() {
649 delete m_pForm; 653 delete m_pForm;
650 } 654 }
651 void CPDF_FormObject::Transform(const CFX_Matrix& matrix) { 655 void CPDF_FormObject::Transform(const CFX_Matrix& matrix) {
652 m_FormMatrix.Concat(matrix); 656 m_FormMatrix.Concat(matrix);
653 CalcBoundingBox(); 657 CalcBoundingBox();
654 } 658 }
655 void CPDF_FormObject::CopyData(const CPDF_PageObject* pSrc) { 659 void CPDF_FormObject::CopyData(const CPDF_PageObject* pSrc) {
656 const CPDF_FormObject* pSrcObj = (const CPDF_FormObject*)pSrc; 660 const CPDF_FormObject* pSrcObj = (const CPDF_FormObject*)pSrc;
657 delete m_pForm; 661 delete m_pForm;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 (FX_FLOAT)y0); 986 (FX_FLOAT)y0);
983 matrix = m_PageMatrix; 987 matrix = m_PageMatrix;
984 matrix.Concat(display_matrix); 988 matrix.Concat(display_matrix);
985 } 989 }
986 CPDF_ParseOptions::CPDF_ParseOptions() { 990 CPDF_ParseOptions::CPDF_ParseOptions() {
987 m_bTextOnly = FALSE; 991 m_bTextOnly = FALSE;
988 m_bMarkedContent = TRUE; 992 m_bMarkedContent = TRUE;
989 m_bSeparateForm = TRUE; 993 m_bSeparateForm = TRUE;
990 m_bDecodeInlineImage = FALSE; 994 m_bDecodeInlineImage = FALSE;
991 } 995 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698