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/include/cpdf_pageobjectholder.h" |
| 8 |
| 9 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 10 |
| 11 CPDF_PageObjectHolder::CPDF_PageObjectHolder() |
| 12 : m_pFormDict(nullptr), |
| 13 m_pFormStream(nullptr), |
| 14 m_pDocument(nullptr), |
| 15 m_pPageResources(nullptr), |
| 16 m_pResources(nullptr), |
| 17 m_Transparency(0), |
| 18 m_bBackgroundAlphaNeeded(FALSE), |
| 19 m_bHasImageMask(FALSE), |
| 20 m_ParseState(CONTENT_NOT_PARSED) {} |
| 21 |
| 22 void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) { |
| 23 if (!m_pParser) { |
| 24 return; |
| 25 } |
| 26 m_pParser->Continue(pPause); |
| 27 if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { |
| 28 m_ParseState = CONTENT_PARSED; |
| 29 m_pParser.reset(); |
| 30 } |
| 31 } |
| 32 |
| 33 void CPDF_PageObjectHolder::Transform(const CFX_Matrix& matrix) { |
| 34 for (auto& pObj : m_PageObjectList) |
| 35 pObj->Transform(matrix); |
| 36 } |
| 37 |
| 38 CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const { |
| 39 if (m_PageObjectList.empty()) |
| 40 return CFX_FloatRect(0, 0, 0, 0); |
| 41 |
| 42 FX_FLOAT left = 1000000.0f; |
| 43 FX_FLOAT right = -1000000.0f; |
| 44 FX_FLOAT bottom = 1000000.0f; |
| 45 FX_FLOAT top = -1000000.0f; |
| 46 for (const auto& pObj : m_PageObjectList) { |
| 47 left = std::min(left, pObj->m_Left); |
| 48 right = std::max(right, pObj->m_Right); |
| 49 bottom = std::min(bottom, pObj->m_Bottom); |
| 50 top = std::max(top, pObj->m_Top); |
| 51 } |
| 52 return CFX_FloatRect(left, bottom, right, top); |
| 53 } |
| 54 |
| 55 void CPDF_PageObjectHolder::LoadTransInfo() { |
| 56 if (!m_pFormDict) { |
| 57 return; |
| 58 } |
| 59 CPDF_Dictionary* pGroup = m_pFormDict->GetDictBy("Group"); |
| 60 if (!pGroup) { |
| 61 return; |
| 62 } |
| 63 if (pGroup->GetStringBy("S") != "Transparency") { |
| 64 return; |
| 65 } |
| 66 m_Transparency |= PDFTRANS_GROUP; |
| 67 if (pGroup->GetIntegerBy("I")) { |
| 68 m_Transparency |= PDFTRANS_ISOLATED; |
| 69 } |
| 70 if (pGroup->GetIntegerBy("K")) { |
| 71 m_Transparency |= PDFTRANS_KNOCKOUT; |
| 72 } |
| 73 } |
OLD | NEW |