From 455a4199482324c888ea5892c660da354435c091 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 16 Mar 2016 09:48:56 -0400 Subject: Move core/include/fpdfapi/fpdf_page.h to correct locations. This CL splits the fpdf_page.h header into the individual classes and moves them to the correct core/fpdfapi locations. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1805663002 . --- .../fpdf_edit/cpdf_pagecontentgenerator.cpp | 163 +++++++++++++++++++++ core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp | 161 -------------------- core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 1 - core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp | 2 +- core/fpdfapi/fpdf_edit/include/cpdf_creator.h | 1 - .../fpdf_edit/include/cpdf_pagecontentgenerator.h | 42 ++++++ core/fpdfapi/fpdf_font/fpdf_font.cpp | 2 +- core/fpdfapi/fpdf_font/fpdf_font_charset.cpp | 1 - core/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 1 - core/fpdfapi/fpdf_page/cpdf_form.cpp | 65 ++++++++ core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp | 73 +++++++++ core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp | 17 +++ core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h | 21 +++ core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp | 12 ++ core/fpdfapi/fpdf_page/cpdf_parseoptions.h | 22 +++ core/fpdfapi/fpdf_page/fpdf_page.cpp | 133 +---------------- core/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 1 - core/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 1 - core/fpdfapi/fpdf_page/fpdf_page_func.cpp | 1 - core/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 1 - core/fpdfapi/fpdf_page/fpdf_page_image.cpp | 1 - core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 2 +- core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 3 +- core/fpdfapi/fpdf_page/fpdf_page_path.cpp | 1 - core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp | 2 +- core/fpdfapi/fpdf_page/include/cpdf_form.h | 44 ++++++ core/fpdfapi/fpdf_page/include/cpdf_page.h | 57 +++++++ .../fpdf_page/include/cpdf_pageobjectholder.h | 67 +++++++++ core/fpdfapi/fpdf_page/pageint.h | 3 +- core/fpdfapi/fpdf_render/fpdf_render.cpp | 2 + core/fpdfapi/fpdf_render/fpdf_render_cache.cpp | 2 + core/fpdfapi/fpdf_render/fpdf_render_image.cpp | 3 + core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 1 + core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 2 + core/fpdfapi/fpdf_render/fpdf_render_text.cpp | 2 + .../fpdf_render/include/cpdf_progressiverenderer.h | 2 +- 36 files changed, 606 insertions(+), 309 deletions(-) create mode 100644 core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp delete mode 100644 core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp create mode 100644 core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h create mode 100644 core/fpdfapi/fpdf_page/cpdf_form.cpp create mode 100644 core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp create mode 100644 core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp create mode 100644 core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h create mode 100644 core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp create mode 100644 core/fpdfapi/fpdf_page/cpdf_parseoptions.h create mode 100644 core/fpdfapi/fpdf_page/include/cpdf_form.h create mode 100644 core/fpdfapi/fpdf_page/include/cpdf_page.h create mode 100644 core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp new file mode 100644 index 0000000000..a09aa1f9b3 --- /dev/null +++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp @@ -0,0 +1,163 @@ +// 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_edit/include/cpdf_pagecontentgenerator.h" + +#include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" +#include "core/fpdfapi/fpdf_page/pageint.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/fpdf_parser/include/fpdf_parser_decode.h" + +CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, CFX_Matrix& matrix) { + ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " + << matrix.e << " " << matrix.f; + return ar; +} + +CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage) + : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument) { + for (const auto& pObj : *pPage->GetPageObjectList()) + InsertPageObject(pObj.get()); +} + +FX_BOOL CPDF_PageContentGenerator::InsertPageObject( + CPDF_PageObject* pPageObject) { + return pPageObject && m_pageObjects.Add(pPageObject); +} + +void CPDF_PageContentGenerator::GenerateContent() { + CFX_ByteTextBuf buf; + CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; + for (int i = 0; i < m_pageObjects.GetSize(); ++i) { + CPDF_PageObject* pPageObj = m_pageObjects[i]; + if (!pPageObj || !pPageObj->IsImage()) { + continue; + } + ProcessImage(buf, pPageObj->AsImage()); + } + CPDF_Object* pContent = + pPageDict ? pPageDict->GetElementValue("Contents") : NULL; + if (pContent) { + pPageDict->RemoveAt("Contents"); + } + CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); + pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); + m_pDocument->AddIndirectObject(pStream); + pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); +} +CFX_ByteString CPDF_PageContentGenerator::RealizeResource( + CPDF_Object* pResourceObj, + const FX_CHAR* szType) { + if (!m_pPage->m_pResources) { + m_pPage->m_pResources = new CPDF_Dictionary; + int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); + m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); + } + CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(szType); + if (!pResList) { + pResList = new CPDF_Dictionary; + m_pPage->m_pResources->SetAt(szType, pResList); + } + m_pDocument->AddIndirectObject(pResourceObj); + CFX_ByteString name; + int idnum = 1; + while (1) { + name.Format("FX%c%d", szType[0], idnum); + if (!pResList->KeyExist(name)) { + break; + } + idnum++; + } + pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum()); + return name; +} +void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, + CPDF_ImageObject* pImageObj) { + if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || + (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { + return; + } + buf << "q " << pImageObj->m_Matrix << " cm "; + if (!pImageObj->m_pImage->IsInline()) { + CPDF_Stream* pStream = pImageObj->m_pImage->GetStream(); + FX_DWORD dwSavedObjNum = pStream->GetObjNum(); + CFX_ByteString name = RealizeResource(pStream, "XObject"); + if (dwSavedObjNum == 0) { + if (pImageObj->m_pImage) + pImageObj->m_pImage->Release(); + pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pStream); + } + buf << "/" << PDF_NameEncode(name) << " Do Q\n"; + } +} +void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, + const uint8_t* data, + FX_DWORD size, + CFX_Matrix& matrix) { + if (!data || !size) { + return; + } + CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); + CPDF_Dictionary* pFormDict = new CPDF_Dictionary; + pFormDict->SetAtName("Type", "XObject"); + pFormDict->SetAtName("Subtype", "Form"); + CFX_FloatRect bbox = m_pPage->GetPageBBox(); + matrix.TransformRect(bbox); + pFormDict->SetAtRect("BBox", bbox); + pStream->InitStream((uint8_t*)data, size, pFormDict); + buf << "q " << matrix << " cm "; + CFX_ByteString name = RealizeResource(pStream, "XObject"); + buf << "/" << PDF_NameEncode(name) << " Do Q\n"; +} +void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { + CPDF_Dictionary* pDict = m_pPage->m_pFormDict; + CPDF_Object* pContent = pDict ? pDict->GetElementValue("Contents") : NULL; + if (!pContent) + return; + + CFX_ByteTextBuf buf; + if (CPDF_Array* pArray = pContent->AsArray()) { + int iCount = pArray->GetCount(); + CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount); + int size = 0; + int i = 0; + for (i = 0; i < iCount; ++i) { + pContent = pArray->GetElement(i); + CPDF_Stream* pStream = ToStream(pContent); + if (!pStream) + continue; + + CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc(); + pStreamAcc->LoadAllData(pStream); + pContentArray[i] = pStreamAcc; + size += pContentArray[i]->GetSize() + 1; + } + int pos = 0; + uint8_t* pBuf = FX_Alloc(uint8_t, size); + for (i = 0; i < iCount; ++i) { + FXSYS_memcpy(pBuf + pos, pContentArray[i]->GetData(), + pContentArray[i]->GetSize()); + pos += pContentArray[i]->GetSize() + 1; + pBuf[pos - 1] = ' '; + delete pContentArray[i]; + } + ProcessForm(buf, pBuf, size, matrix); + FX_Free(pBuf); + FX_Free(pContentArray); + } else if (CPDF_Stream* pStream = pContent->AsStream()) { + CPDF_StreamAcc contentStream; + contentStream.LoadAllData(pStream); + ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); + } + CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); + pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); + m_pDocument->AddIndirectObject(pStream); + m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, + pStream->GetObjNum()); +} diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp deleted file mode 100644 index 6010a04369..0000000000 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2014 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_edit/include/cpdf_creator.h" -#include "core/fpdfapi/fpdf_page/pageint.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/fpdf_parser/include/fpdf_parser_decode.h" -#include "core/include/fpdfapi/fpdf_page.h" - -CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, CFX_Matrix& matrix) { - ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " - << matrix.e << " " << matrix.f; - return ar; -} - -CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage) - : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument) { - for (const auto& pObj : *pPage->GetPageObjectList()) - InsertPageObject(pObj.get()); -} - -FX_BOOL CPDF_PageContentGenerator::InsertPageObject( - CPDF_PageObject* pPageObject) { - return pPageObject && m_pageObjects.Add(pPageObject); -} - -void CPDF_PageContentGenerator::GenerateContent() { - CFX_ByteTextBuf buf; - CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; - for (int i = 0; i < m_pageObjects.GetSize(); ++i) { - CPDF_PageObject* pPageObj = m_pageObjects[i]; - if (!pPageObj || !pPageObj->IsImage()) { - continue; - } - ProcessImage(buf, pPageObj->AsImage()); - } - CPDF_Object* pContent = - pPageDict ? pPageDict->GetElementValue("Contents") : NULL; - if (pContent) { - pPageDict->RemoveAt("Contents"); - } - CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); - pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); - m_pDocument->AddIndirectObject(pStream); - pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); -} -CFX_ByteString CPDF_PageContentGenerator::RealizeResource( - CPDF_Object* pResourceObj, - const FX_CHAR* szType) { - if (!m_pPage->m_pResources) { - m_pPage->m_pResources = new CPDF_Dictionary; - int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources); - m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum); - } - CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(szType); - if (!pResList) { - pResList = new CPDF_Dictionary; - m_pPage->m_pResources->SetAt(szType, pResList); - } - m_pDocument->AddIndirectObject(pResourceObj); - CFX_ByteString name; - int idnum = 1; - while (1) { - name.Format("FX%c%d", szType[0], idnum); - if (!pResList->KeyExist(name)) { - break; - } - idnum++; - } - pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum()); - return name; -} -void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, - CPDF_ImageObject* pImageObj) { - if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || - (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { - return; - } - buf << "q " << pImageObj->m_Matrix << " cm "; - if (!pImageObj->m_pImage->IsInline()) { - CPDF_Stream* pStream = pImageObj->m_pImage->GetStream(); - FX_DWORD dwSavedObjNum = pStream->GetObjNum(); - CFX_ByteString name = RealizeResource(pStream, "XObject"); - if (dwSavedObjNum == 0) { - if (pImageObj->m_pImage) - pImageObj->m_pImage->Release(); - pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pStream); - } - buf << "/" << PDF_NameEncode(name) << " Do Q\n"; - } -} -void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, - const uint8_t* data, - FX_DWORD size, - CFX_Matrix& matrix) { - if (!data || !size) { - return; - } - CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); - CPDF_Dictionary* pFormDict = new CPDF_Dictionary; - pFormDict->SetAtName("Type", "XObject"); - pFormDict->SetAtName("Subtype", "Form"); - CFX_FloatRect bbox = m_pPage->GetPageBBox(); - matrix.TransformRect(bbox); - pFormDict->SetAtRect("BBox", bbox); - pStream->InitStream((uint8_t*)data, size, pFormDict); - buf << "q " << matrix << " cm "; - CFX_ByteString name = RealizeResource(pStream, "XObject"); - buf << "/" << PDF_NameEncode(name) << " Do Q\n"; -} -void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { - CPDF_Dictionary* pDict = m_pPage->m_pFormDict; - CPDF_Object* pContent = pDict ? pDict->GetElementValue("Contents") : NULL; - if (!pContent) - return; - - CFX_ByteTextBuf buf; - if (CPDF_Array* pArray = pContent->AsArray()) { - int iCount = pArray->GetCount(); - CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount); - int size = 0; - int i = 0; - for (i = 0; i < iCount; ++i) { - pContent = pArray->GetElement(i); - CPDF_Stream* pStream = ToStream(pContent); - if (!pStream) - continue; - - CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc(); - pStreamAcc->LoadAllData(pStream); - pContentArray[i] = pStreamAcc; - size += pContentArray[i]->GetSize() + 1; - } - int pos = 0; - uint8_t* pBuf = FX_Alloc(uint8_t, size); - for (i = 0; i < iCount; ++i) { - FXSYS_memcpy(pBuf + pos, pContentArray[i]->GetData(), - pContentArray[i]->GetSize()); - pos += pContentArray[i]->GetSize() + 1; - pBuf[pos - 1] = ' '; - delete pContentArray[i]; - } - ProcessForm(buf, pBuf, size, matrix); - FX_Free(pBuf); - FX_Free(pContentArray); - } else if (CPDF_Stream* pStream = pContent->AsStream()) { - CPDF_StreamAcc contentStream; - contentStream.LoadAllData(pStream); - ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); - } - CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); - pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); - m_pDocument->AddIndirectObject(pStream); - m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, - pStream->GetObjNum()); -} diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 121498ccd2..46d6d1feeb 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -13,7 +13,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fpdfapi/ipdf_rendermodule.h" -#include "core/include/fpdfapi/fpdf_page.h" CPDF_Document::CPDF_Document() : CPDF_IndirectObjectHolder(NULL) { m_pRootDict = NULL; diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp index fec596cdb2..50e4f79881 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp @@ -4,6 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" @@ -13,7 +14,6 @@ #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" #include "core/fpdfapi/fpdf_render/render_int.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxcodec/fx_codec.h" CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) { diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h index 5b5671b7e9..7be92f956b 100644 --- a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h +++ b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h @@ -7,7 +7,6 @@ #ifndef CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ #define CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" class CPDF_Parser; diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h b/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h new file mode 100644 index 0000000000..8aea084798 --- /dev/null +++ b/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h @@ -0,0 +1,42 @@ +// 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_EDIT_INCLUDE_CPDF_PAGECONTENTGENERATOR_H_ +#define CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_PAGECONTENTGENERATOR_H_ + +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" + +class CPDF_Object; +class CPDF_Page; +class CPDF_PageObject; +class CPDF_ImageObject; + +class CPDF_PageContentGenerator { + public: + explicit CPDF_PageContentGenerator(CPDF_Page* pPage); + + FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject); + void GenerateContent(); + void TransformContent(CFX_Matrix& matrix); + + private: + void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj); + void ProcessForm(CFX_ByteTextBuf& buf, + const uint8_t* data, + FX_DWORD size, + CFX_Matrix& matrix); + CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, + const FX_CHAR* szType); + + CPDF_Page* m_pPage; + CPDF_Document* m_pDocument; + CFX_ArrayTemplate m_pageObjects; +}; + +#endif // CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_PAGECONTENTGENERATOR_H_ diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index b1db0ebe09..5e9b0edfa0 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp @@ -6,6 +6,7 @@ #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" @@ -14,7 +15,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_pageobj.h" #include "core/include/fpdfapi/fpdf_resource.h" #include "core/include/fxcrt/fx_ext.h" diff --git a/core/fpdfapi/fpdf_font/fpdf_font_charset.cpp b/core/fpdfapi/fpdf_font/fpdf_font_charset.cpp index 40ec22107b..642efd62ca 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_charset.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_charset.cpp @@ -5,7 +5,6 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_resource.h" #include "core/include/fxge/fx_freetype.h" diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 321fc593fe..1295c624ad 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -12,7 +12,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_resource.h" #include "core/include/fxcrt/fx_ext.h" #include "core/include/fxge/fx_freetype.h" 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(*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 +#include + +class CPDF_PageObject; + +class CPDF_PageObjectList + : public std::deque> { + 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 +#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(*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 #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 +#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 +#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 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 #include -#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; diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index 94398df296..b52a7459eb 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/fpdf_render/render_int.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" diff --git a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp index fbe07842d9..298dea0504 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" +#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index 963ff246d9..b2c89853d7 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -9,6 +9,9 @@ #include #include +#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 905e7a60c6..56af308232 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -10,6 +10,7 @@ #include #include +#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 2e259126cf..8fef5b3ae4 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/fpdf_render/render_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index 4db224939d..07790bdf4d 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/fpdf_render/render_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" diff --git a/core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h b/core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h index eddd4b0c83..e5c0d9d6d8 100644 --- a/core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h +++ b/core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h @@ -9,8 +9,8 @@ #include +#include "core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" -#include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fxcrt/fx_coordinates.h" #include "core/include/fxcrt/fx_system.h" -- cgit v1.2.3