diff options
Diffstat (limited to 'core/fpdfapi/fpdf_page')
20 files changed, 386 insertions, 141 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_form.cpp b/core/fpdfapi/fpdf_page/cpdf_form.cpp new file mode 100644 index 0000000000..a1160397fc --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_form.cpp @@ -0,0 +1,65 @@ +// 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/fpdf_page/include/cpdf_form.h" + +#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" +#include "core/fpdfapi/fpdf_page/pageint.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" + +CPDF_Form::CPDF_Form(CPDF_Document* pDoc, + CPDF_Dictionary* pPageResources, + CPDF_Stream* pFormStream, + CPDF_Dictionary* pParentResources) { + m_pDocument = pDoc; + m_pFormStream = pFormStream; + m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL; + m_pResources = m_pFormDict->GetDictBy("Resources"); + m_pPageResources = pPageResources; + if (!m_pResources) { + m_pResources = pParentResources; + } + if (!m_pResources) { + m_pResources = pPageResources; + } + m_Transparency = 0; + LoadTransInfo(); +} + +CPDF_Form::~CPDF_Form() {} + +void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, + CFX_Matrix* pParentMatrix, + CPDF_Type3Char* pType3Char, + CPDF_ParseOptions* pOptions, + int level) { + if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { + return; + } + m_pParser.reset(new CPDF_ContentParser); + m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, + level); + m_ParseState = CONTENT_PARSING; +} + +void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, + CFX_Matrix* pParentMatrix, + CPDF_Type3Char* pType3Char, + CPDF_ParseOptions* pOptions, + int level) { + StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); + ContinueParse(NULL); +} + +CPDF_Form* CPDF_Form::Clone() const { + CPDF_Form* pCloneForm = + new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); + for (const auto& pObj : m_PageObjectList) + pCloneForm->m_PageObjectList.emplace_back(pObj->Clone()); + + return pCloneForm; +} diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp new file mode 100644 index 0000000000..a1392f647e --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp @@ -0,0 +1,73 @@ +// 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/fpdf_page/include/cpdf_pageobjectholder.h" + +#include "core/fpdfapi/fpdf_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) {} + +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->GetDictBy("Group"); + if (!pGroup) { + return; + } + if (pGroup->GetStringBy("S") != "Transparency") { + return; + } + m_Transparency |= PDFTRANS_GROUP; + if (pGroup->GetIntegerBy("I")) { + m_Transparency |= PDFTRANS_ISOLATED; + } + if (pGroup->GetIntegerBy("K")) { + m_Transparency |= PDFTRANS_KNOCKOUT; + } +} diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp new file mode 100644 index 0000000000..36fb672849 --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp @@ -0,0 +1,17 @@ +// 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/fpdf_page/cpdf_pageobjectlist.h" + +#include "core/fpdfapi/fpdf_page/pageint.h" +#include "core/include/fpdfapi/fpdf_pageobj.h" +#include "third_party/base/stl_util.h" + +CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) { + if (index < 0 || index >= pdfium::CollectionSize<int>(*this)) + return nullptr; + return (*this)[index].get(); +} diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h b/core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h new file mode 100644 index 0000000000..360bb26e8b --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h @@ -0,0 +1,21 @@ +// 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 + +#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEOBJECTLIST_H_ +#define CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEOBJECTLIST_H_ + +#include <deque> +#include <memory> + +class CPDF_PageObject; + +class CPDF_PageObjectList + : public std::deque<std::unique_ptr<CPDF_PageObject>> { + public: + CPDF_PageObject* GetPageObjectByIndex(int index); +}; + +#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEOBJECTLIST_H_ diff --git a/core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp b/core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp new file mode 100644 index 0000000000..d22b6f13c9 --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp @@ -0,0 +1,12 @@ +// 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/fpdf_page/cpdf_parseoptions.h" + +CPDF_ParseOptions::CPDF_ParseOptions() + : m_bTextOnly(FALSE), + m_bMarkedContent(TRUE), + m_bSeparateForm(TRUE), + m_bDecodeInlineImage(FALSE) {} diff --git a/core/fpdfapi/fpdf_page/cpdf_parseoptions.h b/core/fpdfapi/fpdf_page/cpdf_parseoptions.h new file mode 100644 index 0000000000..cd1bb69948 --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_parseoptions.h @@ -0,0 +1,22 @@ +// 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 + +#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PARSEOPTIONS_H_ +#define CORE_FPDFAPI_FPDF_PAGE_CPDF_PARSEOPTIONS_H_ + +#include "core/include/fxcrt/fx_system.h" + +class CPDF_ParseOptions { + public: + CPDF_ParseOptions(); + + FX_BOOL m_bTextOnly; + FX_BOOL m_bMarkedContent; + FX_BOOL m_bSeparateForm; + FX_BOOL m_bDecodeInlineImage; +}; + +#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PARSEOPTIONS_H_ diff --git a/core/fpdfapi/fpdf_page/fpdf_page.cpp b/core/fpdfapi/fpdf_page/fpdf_page.cpp index 2cec0928dd..ad54e320bc 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page.cpp @@ -8,12 +8,13 @@ #include <algorithm> +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fpdfapi/ipdf_rendermodule.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "third_party/base/stl_util.h" CPDF_PageObject::CPDF_PageObject() {} @@ -463,76 +464,6 @@ void CPDF_FormObject::CalcBoundingBox() { m_Top = form_rect.top; } -CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) { - if (index < 0 || index >= pdfium::CollectionSize<int>(*this)) - return nullptr; - return (*this)[index].get(); -} - -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) {} - -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->GetDictBy("Group"); - if (!pGroup) { - return; - } - if (pGroup->GetStringBy("S") != "Transparency") { - return; - } - m_Transparency |= PDFTRANS_GROUP; - if (pGroup->GetIntegerBy("I")) { - m_Transparency |= PDFTRANS_ISOLATED; - } - if (pGroup->GetIntegerBy("K")) { - m_Transparency |= PDFTRANS_KNOCKOUT; - } -} - CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {} void CPDF_Page::Load(CPDF_Document* pDocument, @@ -650,59 +581,6 @@ CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteStringC& name) const { return FPDFAPI_GetPageAttr(m_pFormDict, name); } -CPDF_Form::CPDF_Form(CPDF_Document* pDoc, - CPDF_Dictionary* pPageResources, - CPDF_Stream* pFormStream, - CPDF_Dictionary* pParentResources) { - m_pDocument = pDoc; - m_pFormStream = pFormStream; - m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL; - m_pResources = m_pFormDict->GetDictBy("Resources"); - m_pPageResources = pPageResources; - if (!m_pResources) { - m_pResources = pParentResources; - } - if (!m_pResources) { - m_pResources = pPageResources; - } - m_Transparency = 0; - LoadTransInfo(); -} - -CPDF_Form::~CPDF_Form() {} - -void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, - CFX_Matrix* pParentMatrix, - CPDF_Type3Char* pType3Char, - CPDF_ParseOptions* pOptions, - int level) { - if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { - return; - } - m_pParser.reset(new CPDF_ContentParser); - m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, - level); - m_ParseState = CONTENT_PARSING; -} - -void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, - CFX_Matrix* pParentMatrix, - CPDF_Type3Char* pType3Char, - CPDF_ParseOptions* pOptions, - int level) { - StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); - ContinueParse(NULL); -} - -CPDF_Form* CPDF_Form::Clone() const { - CPDF_Form* pCloneForm = - new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); - for (const auto& pObj : m_PageObjectList) - pCloneForm->m_PageObjectList.emplace_back(pObj->Clone()); - - return pCloneForm; -} - void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, int xPos, int yPos, @@ -756,10 +634,3 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, matrix = m_PageMatrix; matrix.Concat(display_matrix); } - -CPDF_ParseOptions::CPDF_ParseOptions() { - m_bTextOnly = FALSE; - m_bMarkedContent = TRUE; - m_bSeparateForm = TRUE; - m_bDecodeInlineImage = FALSE; -} diff --git a/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 040821bc06..d4b69f2d3f 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -15,7 +15,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxcodec/fx_codec.h" namespace { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 9da5d1fe00..0d0c373c56 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -13,7 +13,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fpdfapi/ipdf_pagemodule.h" -#include "core/include/fpdfapi/fpdf_page.h" namespace { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp index 00ca2d8d18..4bf7c06a7b 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -15,7 +15,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxcrt/fx_safe_types.h" #include "third_party/base/numerics/safe_conversions_impl.h" diff --git a/core/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp index 99156411f6..cd81b97112 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -12,7 +12,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_render/render_int.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" #include "third_party/base/stl_util.h" diff --git a/core/fpdfapi/fpdf_page/fpdf_page_image.cpp b/core/fpdfapi/fpdf_page/fpdf_page_image.cpp index cd89725de2..247b0b9703 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_image.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_image.cpp @@ -8,7 +8,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" CPDF_ImageObject::CPDF_ImageObject() : m_pImage(nullptr) {} diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 69ff8da21f..b62579813a 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -9,6 +9,7 @@ #include <vector> #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" @@ -16,7 +17,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" -#include "core/include/fpdfapi/fpdf_page.h" namespace { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 36be007b68..c1bb70ff80 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -8,6 +8,8 @@ #include <limits.h> +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" #include "core/fpdfapi/fpdf_parser/cpdf_null.h" #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" @@ -19,7 +21,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxcrt/fx_ext.h" #include "core/include/fxcrt/fx_safe_types.h" diff --git a/core/fpdfapi/fpdf_page/fpdf_page_path.cpp b/core/fpdfapi/fpdf_page/fpdf_page_path.cpp index 07c6ae1a80..286dfdfb1c 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_path.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_path.cpp @@ -6,7 +6,6 @@ #include "core/fpdfapi/fpdf_page/pageint.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" CPDF_PathObject::CPDF_PathObject() {} diff --git a/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp index 7e22661624..fbb2c28373 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp @@ -8,10 +8,10 @@ #include <algorithm> +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" -#include "core/include/fpdfapi/fpdf_page.h" namespace { diff --git a/core/fpdfapi/fpdf_page/include/cpdf_form.h b/core/fpdfapi/fpdf_page/include/cpdf_form.h new file mode 100644 index 0000000000..3b9f1cc7fb --- /dev/null +++ b/core/fpdfapi/fpdf_page/include/cpdf_form.h @@ -0,0 +1,44 @@ +// 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 + +#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_FORM_H_ +#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_FORM_H_ + +#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" + +class CPDF_Document; +class CPDF_Dictionary; +class CPDF_Stream; +class CPDF_AllStates; +class CFX_Matrix; +class CPDF_Type3Char; +class CPDF_ParseOptions; + +class CPDF_Form : public CPDF_PageObjectHolder { + public: + CPDF_Form(CPDF_Document* pDocument, + CPDF_Dictionary* pPageResources, + CPDF_Stream* pFormStream, + CPDF_Dictionary* pParentResources = NULL); + + ~CPDF_Form(); + + void StartParse(CPDF_AllStates* pGraphicStates, + CFX_Matrix* pParentMatrix, + CPDF_Type3Char* pType3Char, + CPDF_ParseOptions* pOptions, + int level = 0); + + void ParseContent(CPDF_AllStates* pGraphicStates, + CFX_Matrix* pParentMatrix, + CPDF_Type3Char* pType3Char, + CPDF_ParseOptions* pOptions, + int level = 0); + + CPDF_Form* Clone() const; +}; + +#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_FORM_H_ diff --git a/core/fpdfapi/fpdf_page/include/cpdf_page.h b/core/fpdfapi/fpdf_page/include/cpdf_page.h new file mode 100644 index 0000000000..82c88d1c37 --- /dev/null +++ b/core/fpdfapi/fpdf_page/include/cpdf_page.h @@ -0,0 +1,57 @@ +// 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 + +#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_ +#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_ + +#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" + +class CPDF_Document; +class CPDF_Dictionary; +class CPDF_Object; +class CPDF_PageRenderCache; +class CPDF_ParseOptions; + +class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData { + public: + CPDF_Page(); + ~CPDF_Page(); + + void Load(CPDF_Document* pDocument, + CPDF_Dictionary* pPageDict, + FX_BOOL bPageCache = TRUE); + + void ParseContent(CPDF_ParseOptions* pOptions); + + void GetDisplayMatrix(CFX_Matrix& matrix, + int xPos, + int yPos, + int xSize, + int ySize, + int iRotate) const; + + FX_FLOAT GetPageWidth() const { return m_PageWidth; } + FX_FLOAT GetPageHeight() const { return m_PageHeight; } + CFX_FloatRect GetPageBBox() const { return m_BBox; } + const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } + CPDF_Object* GetPageAttr(const CFX_ByteStringC& name) const; + CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; } + + protected: + friend class CPDF_ContentParser; + + void StartParse(CPDF_ParseOptions* pOptions); + + FX_FLOAT m_PageWidth; + FX_FLOAT m_PageHeight; + CFX_Matrix m_PageMatrix; + CPDF_PageRenderCache* m_pPageRender; +}; + +#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_ diff --git a/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h b/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h new file mode 100644 index 0000000000..b0ab376956 --- /dev/null +++ b/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h @@ -0,0 +1,67 @@ +// 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 + +#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGEOBJECTHOLDER_H_ +#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGEOBJECTHOLDER_H_ + +#include "core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h" +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" + +class IFX_Pause; +class CPDF_Dictionary; +class CPDF_Stream; +class CPDF_Document; +class CPDF_ContentParser; + +#define PDFTRANS_GROUP 0x0100 +#define PDFTRANS_ISOLATED 0x0200 +#define PDFTRANS_KNOCKOUT 0x0400 + +class CPDF_PageObjectHolder { + public: + CPDF_PageObjectHolder(); + + void ContinueParse(IFX_Pause* pPause); + bool IsParsed() const { return m_ParseState == CONTENT_PARSED; } + + CPDF_PageObjectList* GetPageObjectList() { return &m_PageObjectList; } + const CPDF_PageObjectList* GetPageObjectList() const { + return &m_PageObjectList; + } + + FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } + void SetBackgroundAlphaNeeded(FX_BOOL needed) { + m_bBackgroundAlphaNeeded = needed; + } + + FX_BOOL HasImageMask() const { return m_bHasImageMask; } + void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; } + + void Transform(const CFX_Matrix& matrix); + CFX_FloatRect CalcBoundingBox() const; + + CPDF_Dictionary* m_pFormDict; + CPDF_Stream* m_pFormStream; + CPDF_Document* m_pDocument; + CPDF_Dictionary* m_pPageResources; + CPDF_Dictionary* m_pResources; + CFX_FloatRect m_BBox; + int m_Transparency; + + protected: + enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED }; + + void LoadTransInfo(); + + FX_BOOL m_bBackgroundAlphaNeeded; + FX_BOOL m_bHasImageMask; + ParseState m_ParseState; + std::unique_ptr<CPDF_ContentParser> m_pParser; + CPDF_PageObjectList m_PageObjectList; +}; + +#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGEOBJECTHOLDER_H_ diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h index 8818bc9af0..eab3d42b2b 100644 --- a/core/fpdfapi/fpdf_page/pageint.h +++ b/core/fpdfapi/fpdf_page/pageint.h @@ -12,7 +12,8 @@ #include <unordered_map> #include <vector> -#include "core/include/fpdfapi/fpdf_page.h" +#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" #include "core/include/fpdfapi/fpdf_pageobj.h" class CPDF_AllStates; |