OLD | NEW |
| (Empty) |
1 // Copyright 2016 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "core/fpdfapi/fpdf_page/cpdf_pageobjectholder.h" | |
8 | |
9 #include "core/fpdfapi/fpdf_page/cpdf_pageobject.h" | |
10 #include "core/fpdfapi/fpdf_page/pageint.h" | |
11 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h" | |
12 | |
13 CPDF_PageObjectHolder::CPDF_PageObjectHolder() | |
14 : m_pFormDict(nullptr), | |
15 m_pFormStream(nullptr), | |
16 m_pDocument(nullptr), | |
17 m_pPageResources(nullptr), | |
18 m_pResources(nullptr), | |
19 m_Transparency(0), | |
20 m_bBackgroundAlphaNeeded(FALSE), | |
21 m_bHasImageMask(FALSE), | |
22 m_ParseState(CONTENT_NOT_PARSED) {} | |
23 | |
24 CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {} | |
25 | |
26 void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) { | |
27 if (!m_pParser) { | |
28 return; | |
29 } | |
30 m_pParser->Continue(pPause); | |
31 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { | |
32 m_ParseState = CONTENT_PARSED; | |
33 m_pParser.reset(); | |
34 } | |
35 } | |
36 | |
37 void CPDF_PageObjectHolder::Transform(const CFX_Matrix& matrix) { | |
38 for (auto& pObj : m_PageObjectList) | |
39 pObj->Transform(matrix); | |
40 } | |
41 | |
42 CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const { | |
43 if (m_PageObjectList.empty()) | |
44 return CFX_FloatRect(0, 0, 0, 0); | |
45 | |
46 FX_FLOAT left = 1000000.0f; | |
47 FX_FLOAT right = -1000000.0f; | |
48 FX_FLOAT bottom = 1000000.0f; | |
49 FX_FLOAT top = -1000000.0f; | |
50 for (const auto& pObj : m_PageObjectList) { | |
51 left = std::min(left, pObj->m_Left); | |
52 right = std::max(right, pObj->m_Right); | |
53 bottom = std::min(bottom, pObj->m_Bottom); | |
54 top = std::max(top, pObj->m_Top); | |
55 } | |
56 return CFX_FloatRect(left, bottom, right, top); | |
57 } | |
58 | |
59 void CPDF_PageObjectHolder::LoadTransInfo() { | |
60 if (!m_pFormDict) { | |
61 return; | |
62 } | |
63 CPDF_Dictionary* pGroup = m_pFormDict->GetDictFor("Group"); | |
64 if (!pGroup) { | |
65 return; | |
66 } | |
67 if (pGroup->GetStringFor("S") != "Transparency") { | |
68 return; | |
69 } | |
70 m_Transparency |= PDFTRANS_GROUP; | |
71 if (pGroup->GetIntegerFor("I")) { | |
72 m_Transparency |= PDFTRANS_ISOLATED; | |
73 } | |
74 if (pGroup->GetIntegerFor("K")) { | |
75 m_Transparency |= PDFTRANS_KNOCKOUT; | |
76 } | |
77 } | |
OLD | NEW |