summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_pageobjectholder.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-04 11:29:35 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-04 11:29:36 -0700
commit41872fa5ac7448a50f66ad56d7bde8d1aa77db4b (patch)
tree49f8162a8ed05ace693d7164f9ba116286427919 /core/fpdfapi/page/cpdf_pageobjectholder.cpp
parentbc5e6d289ed40efec2b0e03427e8fc2947bf53e3 (diff)
downloadpdfium-41872fa5ac7448a50f66ad56d7bde8d1aa77db4b.tar.xz
Move core/fpdfapi/fpdf_page to core/fpdfapi/page
BUG=pdfium:603 Review-Url: https://codereview.chromium.org/2386423004
Diffstat (limited to 'core/fpdfapi/page/cpdf_pageobjectholder.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
new file mode 100644
index 0000000000..bd7830de4d
--- /dev/null
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -0,0 +1,77 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
+
+#include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h"
+#include "core/fpdfapi/page/cpdf_pageobject.h"
+#include "core/fpdfapi/page/pageint.h"
+
+CPDF_PageObjectHolder::CPDF_PageObjectHolder()
+ : m_pFormDict(nullptr),
+ m_pFormStream(nullptr),
+ m_pDocument(nullptr),
+ m_pPageResources(nullptr),
+ m_pResources(nullptr),
+ m_Transparency(0),
+ m_bBackgroundAlphaNeeded(FALSE),
+ m_bHasImageMask(FALSE),
+ m_ParseState(CONTENT_NOT_PARSED) {}
+
+CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {}
+
+void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) {
+ if (!m_pParser) {
+ return;
+ }
+ m_pParser->Continue(pPause);
+ if (m_pParser->GetStatus() == CPDF_ContentParser::Done) {
+ m_ParseState = CONTENT_PARSED;
+ m_pParser.reset();
+ }
+}
+
+void CPDF_PageObjectHolder::Transform(const CFX_Matrix& matrix) {
+ for (auto& pObj : m_PageObjectList)
+ pObj->Transform(matrix);
+}
+
+CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const {
+ if (m_PageObjectList.empty())
+ return CFX_FloatRect(0, 0, 0, 0);
+
+ FX_FLOAT left = 1000000.0f;
+ FX_FLOAT right = -1000000.0f;
+ FX_FLOAT bottom = 1000000.0f;
+ FX_FLOAT top = -1000000.0f;
+ for (const auto& pObj : m_PageObjectList) {
+ left = std::min(left, pObj->m_Left);
+ right = std::max(right, pObj->m_Right);
+ bottom = std::min(bottom, pObj->m_Bottom);
+ top = std::max(top, pObj->m_Top);
+ }
+ return CFX_FloatRect(left, bottom, right, top);
+}
+
+void CPDF_PageObjectHolder::LoadTransInfo() {
+ if (!m_pFormDict) {
+ return;
+ }
+ CPDF_Dictionary* pGroup = m_pFormDict->GetDictFor("Group");
+ if (!pGroup) {
+ return;
+ }
+ if (pGroup->GetStringFor("S") != "Transparency") {
+ return;
+ }
+ m_Transparency |= PDFTRANS_GROUP;
+ if (pGroup->GetIntegerFor("I")) {
+ m_Transparency |= PDFTRANS_ISOLATED;
+ }
+ if (pGroup->GetIntegerFor("K")) {
+ m_Transparency |= PDFTRANS_KNOCKOUT;
+ }
+}