diff options
Diffstat (limited to 'core/fpdfapi')
24 files changed, 156 insertions, 298 deletions
diff --git a/core/fpdfapi/fpdf_basic_module.cpp b/core/fpdfapi/fpdf_basic_module.cpp index efa93d6f76..75450bf975 100644 --- a/core/fpdfapi/fpdf_basic_module.cpp +++ b/core/fpdfapi/fpdf_basic_module.cpp @@ -6,7 +6,7 @@ #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fpdfapi/ipdf_rendermodule.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fxcodec/include/fx_codec.h" namespace { diff --git a/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp b/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp index b6a9132b5d..119c42b5c1 100644 --- a/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp +++ b/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp @@ -8,6 +8,7 @@ #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcrt/include/fx_basic.h" diff --git a/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp b/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp index 702bf06c75..34a43858b4 100644 --- a/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp +++ b/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp @@ -8,6 +8,7 @@ #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcrt/include/fx_basic.h" diff --git a/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp b/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp index 43f7e0ee2b..6299579081 100644 --- a/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp +++ b/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp @@ -8,6 +8,7 @@ #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcrt/include/fx_basic.h" diff --git a/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp b/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp index 77f65dfe3c..ac6346cf7f 100644 --- a/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp +++ b/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp @@ -8,6 +8,7 @@ #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcrt/include/fx_basic.h" diff --git a/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp b/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp index 9248efb718..e0c5b9b7d6 100644 --- a/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp +++ b/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp @@ -7,6 +7,7 @@ #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" void FPDFAPI_FindEmbeddedCMap(const char* name, diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index addf9e2b0e..843c8f884b 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -17,33 +17,38 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" +#include "core/fpdfapi/fpdf_render/render_int.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fpdfapi/ipdf_rendermodule.h" #include "third_party/base/stl_util.h" -CPDF_Document::CPDF_Document() : CPDF_IndirectObjectHolder(NULL) { - m_pRootDict = NULL; - m_pInfoDict = NULL; - m_bLinearized = FALSE; - m_dwFirstPageNo = 0; - m_dwFirstPageObjNum = 0; - m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); - m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this); -} +CPDF_Document::CPDF_Document() + : CPDF_IndirectObjectHolder(nullptr), + m_pRootDict(nullptr), + m_pInfoDict(nullptr), + m_bLinearized(FALSE), + m_dwFirstPageNo(0), + m_dwFirstPageObjNum(0), + m_pDocPage(new CPDF_DocPageData(this)), + m_pDocRender(new CPDF_DocRenderData(this)) {} + void CPDF_Document::CreateNewDoc() { ASSERT(!m_pRootDict && !m_pInfoDict); + m_pRootDict = new CPDF_Dictionary; m_pRootDict->SetAtName("Type", "Catalog"); int objnum = AddIndirectObject(m_pRootDict); + CPDF_Dictionary* pPages = new CPDF_Dictionary; pPages->SetAtName("Type", "Pages"); pPages->SetAtNumber("Count", 0); pPages->SetAt("Kids", new CPDF_Array); objnum = AddIndirectObject(pPages); m_pRootDict->SetAtReference("Pages", this, objnum); + m_pInfoDict = new CPDF_Dictionary; AddIndirectObject(m_pInfoDict); } + static const uint16_t g_FX_CP874Unicodes[128] = { 0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018, diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp index 6089e75ec2..f5405b197f 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp @@ -10,6 +10,7 @@ #include "core/fpdfapi/fpdf_font/font_int.h" #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" #include "core/fpdfapi/fpdf_font/ttgsubtable.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.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_stream_acc.h" diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp index 5056276eba..f143bed541 100644 --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp @@ -13,6 +13,7 @@ #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" #include "core/fpdfapi/fpdf_font/font_int.h" #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.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_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index 0ef49ce6c2..f3f651c52e 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/cpdf_pagemodule.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" diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index aa31f9cbac..32e2945818 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -6,6 +6,7 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.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_page/cpdf_pagemodule.cpp b/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp new file mode 100644 index 0000000000..0d2f547835 --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp @@ -0,0 +1,19 @@ +// 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_pagemodule.h" + +CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family) { + if (family == PDFCS_DEVICEGRAY) + return &m_StockGrayCS; + if (family == PDFCS_DEVICERGB) + return &m_StockRGBCS; + if (family == PDFCS_DEVICECMYK) + return &m_StockCMYKCS; + if (family == PDFCS_PATTERN) + return &m_StockPatternCS; + return nullptr; +} diff --git a/core/fpdfapi/fpdf_page/cpdf_pagemodule.h b/core/fpdfapi/fpdf_page/cpdf_pagemodule.h new file mode 100644 index 0000000000..c609de9c58 --- /dev/null +++ b/core/fpdfapi/fpdf_page/cpdf_pagemodule.h @@ -0,0 +1,37 @@ +// 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_PAGEMODULE_H_ +#define CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEMODULE_H_ + +#include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" +#include "core/fpdfapi/fpdf_page/pageint.h" + +class CPDF_Document; + +class CPDF_PageModule { + public: + CPDF_PageModule() + : m_StockGrayCS(nullptr, PDFCS_DEVICEGRAY), + m_StockRGBCS(nullptr, PDFCS_DEVICERGB), + m_StockCMYKCS(nullptr, PDFCS_DEVICECMYK), + m_StockPatternCS(nullptr) {} + ~CPDF_PageModule() {} + + CPDF_FontGlobals* GetFontGlobals() { return &m_FontGlobals; } + CPDF_ColorSpace* GetStockCS(int family); + void ClearStockFont(CPDF_Document* pDoc) { m_FontGlobals.Clear(pDoc); } + + private: + CPDF_FontGlobals m_FontGlobals; + CPDF_DeviceCS m_StockGrayCS; + CPDF_DeviceCS m_StockRGBCS; + CPDF_DeviceCS m_StockCMYKCS; + CPDF_PatternCS m_StockPatternCS; +}; + +#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEMODULE_H_ diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index aed6e1e05c..14621fc2b3 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -9,6 +9,7 @@ #include "core/fdrm/crypto/include/fx_crypt.h" #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" #include "core/fpdfapi/fpdf_font/font_int.h" +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" #include "core/fpdfapi/fpdf_page/cpdf_pattern.h" #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" #include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h" @@ -18,76 +19,11 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fpdfapi/ipdf_pagemodule.h" - -namespace { - -class CPDF_PageModule : public IPDF_PageModule { - public: - CPDF_PageModule() - : m_StockGrayCS(nullptr, PDFCS_DEVICEGRAY), - m_StockRGBCS(nullptr, PDFCS_DEVICERGB), - m_StockCMYKCS(nullptr, PDFCS_DEVICECMYK), - m_StockPatternCS(nullptr) {} - - private: - ~CPDF_PageModule() override {} - - CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc) override { - return new CPDF_DocPageData(pDoc); - } - - void ReleaseDoc(CPDF_Document* pDoc) override; - void ClearDoc(CPDF_Document* pDoc) override; - - CPDF_FontGlobals* GetFontGlobals() override { return &m_FontGlobals; } - - void ClearStockFont(CPDF_Document* pDoc) override { - m_FontGlobals.Clear(pDoc); - } - - CPDF_ColorSpace* GetStockCS(int family) override; - void NotifyCJKAvailable() override; - - CPDF_FontGlobals m_FontGlobals; - CPDF_DeviceCS m_StockGrayCS; - CPDF_DeviceCS m_StockRGBCS; - CPDF_DeviceCS m_StockCMYKCS; - CPDF_PatternCS m_StockPatternCS; -}; - -} // namespace - -CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family) { - if (family == PDFCS_DEVICEGRAY) { - return &m_StockGrayCS; - } - if (family == PDFCS_DEVICERGB) { - return &m_StockRGBCS; - } - if (family == PDFCS_DEVICECMYK) { - return &m_StockCMYKCS; - } - if (family == PDFCS_PATTERN) { - return &m_StockPatternCS; - } - return NULL; -} void CPDF_ModuleMgr::InitPageModule() { m_pPageModule.reset(new CPDF_PageModule); } -void CPDF_PageModule::ReleaseDoc(CPDF_Document* pDoc) { - delete pDoc->GetPageData(); -} -void CPDF_PageModule::ClearDoc(CPDF_Document* pDoc) { - pDoc->GetPageData()->Clear(FALSE); -} -void CPDF_PageModule::NotifyCJKAvailable() { - m_FontGlobals.m_CMapManager.ReloadAll(); -} - CPDF_Font* CPDF_Document::LoadFont(CPDF_Dictionary* pFontDict) { ASSERT(pFontDict); return GetValidatePageData()->GetFont(pFontDict, FALSE); diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp index 808a468016..4557af2b9e 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp @@ -8,6 +8,8 @@ #include <set> +#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.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_parser.h" @@ -15,7 +17,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfapi/fpdf_render/render_int.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fpdfapi/ipdf_rendermodule.h" #include "core/fxge/include/fx_font.h" #include "third_party/base/stl_util.h" @@ -54,30 +55,33 @@ int CountPages(CPDF_Dictionary* pPages, } // namespace CPDF_Document::CPDF_Document(CPDF_Parser* pParser) - : CPDF_IndirectObjectHolder(pParser) { + : CPDF_IndirectObjectHolder(pParser), + m_pRootDict(nullptr), + m_pInfoDict(nullptr), + m_bLinearized(false), + m_dwFirstPageNo(0), + m_dwFirstPageObjNum(0), + m_pDocPage(new CPDF_DocPageData(this)), + m_pDocRender(new CPDF_DocRenderData(this)) { ASSERT(pParser); - m_pRootDict = NULL; - m_pInfoDict = NULL; - m_bLinearized = FALSE; - m_dwFirstPageNo = 0; - m_dwFirstPageObjNum = 0; - m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); - m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this); } + CPDF_DocPageData* CPDF_Document::GetValidatePageData() { - if (m_pDocPage) { + if (m_pDocPage) return m_pDocPage; - } - m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); + + m_pDocPage = new CPDF_DocPageData(this); return m_pDocPage; } + CPDF_DocRenderData* CPDF_Document::GetValidateRenderData() { - if (m_pDocRender) { + if (m_pDocRender) return m_pDocRender; - } - m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this); + + m_pDocRender = new CPDF_DocRenderData(this); return m_pDocRender; } + void CPDF_Document::LoadDoc() { m_LastObjNum = m_pParser->GetLastObjNum(); CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum()); @@ -128,18 +132,20 @@ void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) { if (ToNumber(pObjNum)) m_dwFirstPageObjNum = pObjNum->GetInteger(); } + void CPDF_Document::LoadPages() { m_PageList.SetSize(RetrievePageCount()); } + CPDF_Document::~CPDF_Document() { if (m_pDocPage) { - CPDF_ModuleMgr::Get()->GetPageModule()->ReleaseDoc(this); + delete this->GetPageData(); CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); } - if (m_pDocRender) { - CPDF_ModuleMgr::Get()->GetRenderModule()->DestroyDocData(m_pDocRender); - } + if (m_pDocRender) + delete m_pDocRender; } + #define FX_MAX_PAGE_LEVEL 1024 CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages, int iPage, @@ -337,12 +343,12 @@ FX_BOOL CPDF_Document::IsFormStream(uint32_t objnum, FX_BOOL& bForm) const { void CPDF_Document::ClearPageData() { if (m_pDocPage) - CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this); + this->GetPageData()->Clear(FALSE); } void CPDF_Document::ClearRenderData() { if (m_pDocRender) - CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender); + m_pDocRender->Clear(FALSE); } void CPDF_Document::ClearRenderFont() { diff --git a/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp b/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp deleted file mode 100644 index 0b98b9889e..0000000000 --- a/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// 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_parser/ipdf_occontext.h" - -#include "core/fpdfapi/fpdf_page/cpdf_contentmarkitem.h" -#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" - -IPDF_OCContext::~IPDF_OCContext() {} - -FX_BOOL IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) { - const CPDF_ContentMarkData* pData = pObj->m_ContentMark; - int nItems = pData->CountItems(); - for (int i = 0; i < nItems; i++) { - const CPDF_ContentMarkItem& item = pData->GetItem(i); - if (item.GetName() == "OC" && - item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict && - !CheckOCGVisible(item.GetParam())) { - return FALSE; - } - } - return TRUE; -} diff --git a/core/fpdfapi/fpdf_parser/ipdf_occontext.h b/core/fpdfapi/fpdf_parser/ipdf_occontext.h deleted file mode 100644 index 0108787342..0000000000 --- a/core/fpdfapi/fpdf_parser/ipdf_occontext.h +++ /dev/null @@ -1,23 +0,0 @@ -// 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_PARSER_IPDF_OCCONTEXT_H_ -#define CORE_FPDFAPI_FPDF_PARSER_IPDF_OCCONTEXT_H_ - -#include "core/fxcrt/include/fx_system.h" - -class CPDF_Dictionary; -class CPDF_PageObject; - -class IPDF_OCContext { - public: - virtual ~IPDF_OCContext(); - - virtual FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCG) = 0; - FX_BOOL CheckObjectVisible(const CPDF_PageObject* pObj); -}; - -#endif // CORE_FPDFAPI_FPDF_PARSER_IPDF_OCCONTEXT_H_ diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index c8fa406a08..4f83370ad2 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -22,13 +22,12 @@ #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/ipdf_occontext.h" #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" #include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fpdfapi/ipdf_rendermodule.h" +#include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fxge/include/fx_ge.h" CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) @@ -88,37 +87,6 @@ void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) { it->second->RemoveRef(); } -class CPDF_RenderModule : public IPDF_RenderModule { - public: - CPDF_RenderModule() {} - - private: - ~CPDF_RenderModule() override {} - - CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc) override; - void DestroyDocData(CPDF_DocRenderData* p) override; - void ClearDocData(CPDF_DocRenderData* p) override; - - CPDF_DocRenderData* GetRenderData() override { return &m_RenderData; } - - CPDF_DocRenderData m_RenderData; -}; - -CPDF_DocRenderData* CPDF_RenderModule::CreateDocData(CPDF_Document* pDoc) { - return new CPDF_DocRenderData(pDoc); -} -void CPDF_RenderModule::DestroyDocData(CPDF_DocRenderData* pDocData) { - delete pDocData; -} -void CPDF_RenderModule::ClearDocData(CPDF_DocRenderData* p) { - if (p) { - p->Clear(FALSE); - } -} -void CPDF_ModuleMgr::InitRenderModule() { - m_pRenderModule.reset(new CPDF_RenderModule); -} - CPDF_RenderOptions::CPDF_RenderOptions() : m_ColorMode(RENDER_COLOR_NORMAL), m_Flags(RENDER_CLEARTYPE), @@ -242,7 +210,7 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, } else { m_InitialStates.DefaultStates(); } - m_pObjectRenderer.reset(); + m_pImageRenderer.reset(); m_Transparency = transparency; return TRUE; } @@ -295,13 +263,13 @@ void CPDF_RenderStatus::RenderSingleObject(const CPDF_PageObject* pObj, FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device, IFX_Pause* pPause) { - if (m_pObjectRenderer) { - if (m_pObjectRenderer->Continue(pPause)) + if (m_pImageRenderer) { + if (m_pImageRenderer->Continue(pPause)) return TRUE; - if (!m_pObjectRenderer->m_Result) + if (!m_pImageRenderer->m_Result) DrawObjWithBackground(pObj, pObj2Device); - m_pObjectRenderer.reset(); + m_pImageRenderer.reset(); return FALSE; } @@ -316,11 +284,11 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, return FALSE; if (pObj->IsImage()) { - m_pObjectRenderer.reset(IPDF_ObjectRenderer::Create()); - if (!m_pObjectRenderer->Start(this, pObj, pObj2Device, FALSE)) { - if (!m_pObjectRenderer->m_Result) + m_pImageRenderer.reset(new CPDF_ImageRenderer); + if (!m_pImageRenderer->Start(this, pObj, pObj2Device, FALSE)) { + if (!m_pImageRenderer->m_Result) DrawObjWithBackground(pObj, pObj2Device); - m_pObjectRenderer.reset(); + m_pImageRenderer.reset(); return FALSE; } return ContinueSingleObject(pObj, pObj2Device, pPause); @@ -330,10 +298,6 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, return FALSE; } -IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create() { - return new CPDF_ImageRenderer; -} - FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device, FX_BOOL bLogical, diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index aedf8036cb..528ad78d2b 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -19,10 +19,10 @@ #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/ipdf_occontext.h" #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" +#include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_safe_types.h" #include "core/fxge/include/fx_ge.h" diff --git a/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h b/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h index 6935d695be..2590dbbd2d 100644 --- a/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h +++ b/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h @@ -10,7 +10,7 @@ #include "core/fxcrt/include/fx_system.h" #include "core/fxge/include/fx_dib.h" -class IPDF_OCContext; +class CPDF_OCContext; #define RENDER_COLOR_NORMAL 0 #define RENDER_COLOR_GRAY 1 @@ -44,7 +44,7 @@ class CPDF_RenderOptions { uint32_t m_Flags; int m_Interpolation; uint32_t m_AddFlags; - IPDF_OCContext* m_pOCContext; + CPDF_OCContext* m_pOCContext; uint32_t m_dwLimitCacheSize; int m_HalftoneLimit; }; diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h index a94820ab8e..464ca38784 100644 --- a/core/fpdfapi/fpdf_render/render_int.h +++ b/core/fpdfapi/fpdf_render/render_int.h @@ -16,32 +16,33 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" -class CPDF_PageObjectHolder; -class CPDF_PageRenderCache; -class CPDF_RenderStatus; +class CCodec_ScanlineDecoder; +class CFX_FontCache; class CFX_GlyphBitmap; class CFX_ImageTransformer; +class CPDF_Color; +class CPDF_Dictionary; +class CPDF_Document; +class CPDF_Font; +class CPDF_FormObject; class CPDF_ImageCacheEntry; class CPDF_ImageLoaderHandle; -class CCodec_ScanlineDecoder; -class CPDF_Type3Font; -class CPDF_Type3Cache; -class CPDF_Type3Char; -class CPDF_TransferFunc; -class CPDF_Document; +class CPDF_ImageObject; +class CPDF_ImageRenderer; class CPDF_Object; -class CFX_FontCache; -class CPDF_Font; class CPDF_PageObject; +class CPDF_PageObjectHolder; +class CPDF_PageRenderCache; class CPDF_PathObject; +class CPDF_RenderStatus; class CPDF_ShadingObject; -class CPDF_FormObject; class CPDF_ShadingPattern; -class CPDF_TilingPattern; -class CPDF_Color; -class CPDF_Dictionary; -class CPDF_ImageObject; class CPDF_Stream; +class CPDF_TilingPattern; +class CPDF_TransferFunc; +class CPDF_Type3Cache; +class CPDF_Type3Char; +class CPDF_Type3Font; #define TYPE3_MAX_BLUES 16 @@ -118,19 +119,6 @@ class CPDF_DocRenderData { CPDF_TransferFuncMap m_TransferFuncMap; }; -class IPDF_ObjectRenderer { - public: - static IPDF_ObjectRenderer* Create(); - virtual ~IPDF_ObjectRenderer() {} - virtual FX_BOOL Start(CPDF_RenderStatus* pRenderStatus, - const CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bStdCS, - int blendType = FXDIB_BLEND_NORMAL) = 0; - virtual FX_BOOL Continue(IFX_Pause* pPause) = 0; - FX_BOOL m_Result; -}; - class CPDF_RenderStatus { public: CPDF_RenderStatus(); @@ -275,7 +263,7 @@ class CPDF_RenderStatus { const CPDF_PageObject* m_pStopObj; CPDF_GraphicStates m_InitialStates; int m_HalftoneLimit; - std::unique_ptr<IPDF_ObjectRenderer> m_pObjectRenderer; + std::unique_ptr<CPDF_ImageRenderer> m_pImageRenderer; FX_BOOL m_bPrint; int m_Transparency; int m_DitherBits; @@ -342,18 +330,17 @@ class CPDF_ImageLoaderHandle { int32_t m_nDownsampleHeight; }; -class CPDF_ImageRenderer : public IPDF_ObjectRenderer { +class CPDF_ImageRenderer { public: CPDF_ImageRenderer(); - ~CPDF_ImageRenderer() override; + ~CPDF_ImageRenderer(); - // IPDF_ObjectRenderer FX_BOOL Start(CPDF_RenderStatus* pStatus, const CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device, FX_BOOL bStdCS, - int blendType = FXDIB_BLEND_NORMAL) override; - FX_BOOL Continue(IFX_Pause* pPause) override; + int blendType = FXDIB_BLEND_NORMAL); + FX_BOOL Continue(IFX_Pause* pPause); FX_BOOL Start(CPDF_RenderStatus* pStatus, const CFX_DIBSource* pDIBSource, @@ -364,7 +351,16 @@ class CPDF_ImageRenderer : public IPDF_ObjectRenderer { FX_BOOL bStdCS, int blendType = FXDIB_BLEND_NORMAL); + FX_BOOL m_Result; + protected: + FX_BOOL StartBitmapAlpha(); + FX_BOOL StartDIBSource(); + FX_BOOL StartRenderDIBSource(); + FX_BOOL StartLoadDIBSource(); + FX_BOOL DrawMaskedImage(); + FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device); + CPDF_RenderStatus* m_pRenderStatus; const CPDF_ImageObject* m_pImageObject; int m_Status; @@ -383,12 +379,6 @@ class CPDF_ImageRenderer : public IPDF_ObjectRenderer { CPDF_ImageLoaderHandle* m_LoadHandle; FX_BOOL m_bStdCS; int m_BlendType; - FX_BOOL StartBitmapAlpha(); - FX_BOOL StartDIBSource(); - FX_BOOL StartRenderDIBSource(); - FX_BOOL StartLoadDIBSource(); - FX_BOOL DrawMaskedImage(); - FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device); }; class CPDF_ScaledRenderBuffer { diff --git a/core/fpdfapi/include/cpdf_modulemgr.h b/core/fpdfapi/include/cpdf_modulemgr.h index 16a6e7bd4f..e54bd07a90 100644 --- a/core/fpdfapi/include/cpdf_modulemgr.h +++ b/core/fpdfapi/include/cpdf_modulemgr.h @@ -9,7 +9,6 @@ #include <memory> -#include "core/fpdfapi/ipdf_pagemodule.h" #include "core/fxcrt/include/fx_basic.h" class CCodec_ModuleMgr; @@ -20,8 +19,7 @@ class CCodec_Jbig2Module; class CCodec_JpegModule; class CCodec_JpxModule; -class IPDF_PageModule; -class IPDF_RenderModule; +class CPDF_PageModule; class CPDF_ModuleMgr { public: @@ -34,10 +32,8 @@ class CPDF_ModuleMgr { CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; } void InitPageModule(); - void InitRenderModule(); - IPDF_RenderModule* GetRenderModule() const { return m_pRenderModule.get(); } - IPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); } + CPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); } void LoadEmbeddedGB1CMaps(); void LoadEmbeddedCNS1CMaps(); @@ -62,8 +58,7 @@ class CPDF_ModuleMgr { ~CPDF_ModuleMgr(); CCodec_ModuleMgr* m_pCodecModule; - std::unique_ptr<IPDF_RenderModule> m_pRenderModule; - std::unique_ptr<IPDF_PageModule> m_pPageModule; + std::unique_ptr<CPDF_PageModule> m_pPageModule; CFX_PrivateData m_privateData; }; diff --git a/core/fpdfapi/ipdf_pagemodule.h b/core/fpdfapi/ipdf_pagemodule.h deleted file mode 100644 index 3765cd91d2..0000000000 --- a/core/fpdfapi/ipdf_pagemodule.h +++ /dev/null @@ -1,28 +0,0 @@ -// 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_IPDF_PAGEMODULE_H_ -#define CORE_FPDFAPI_IPDF_PAGEMODULE_H_ - -class CPDF_ColorSpace; -class CPDF_DocPageData; -class CPDF_Document; -class CPDF_FontGlobals; - -class IPDF_PageModule { - public: - virtual ~IPDF_PageModule() {} - - virtual CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc) = 0; - virtual void ReleaseDoc(CPDF_Document* pDoc) = 0; - virtual void ClearDoc(CPDF_Document* pDoc) = 0; - virtual CPDF_FontGlobals* GetFontGlobals() = 0; - virtual void ClearStockFont(CPDF_Document* pDoc) = 0; - virtual void NotifyCJKAvailable() = 0; - virtual CPDF_ColorSpace* GetStockCS(int family) = 0; -}; - -#endif // CORE_FPDFAPI_IPDF_PAGEMODULE_H_ diff --git a/core/fpdfapi/ipdf_rendermodule.h b/core/fpdfapi/ipdf_rendermodule.h deleted file mode 100644 index b871c36230..0000000000 --- a/core/fpdfapi/ipdf_rendermodule.h +++ /dev/null @@ -1,26 +0,0 @@ -// 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_IPDF_RENDERMODULE_H_ -#define CORE_FPDFAPI_IPDF_RENDERMODULE_H_ - -class CPDF_DocRenderData; -class CPDF_Document; -class CPDF_Page; -class CPDF_PageRenderCache; - -class IPDF_RenderModule { - public: - virtual ~IPDF_RenderModule() {} - - virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc) = 0; - virtual void DestroyDocData(CPDF_DocRenderData* pDocRenderData) = 0; - virtual void ClearDocData(CPDF_DocRenderData* pDocRenderData) = 0; - - virtual CPDF_DocRenderData* GetRenderData() = 0; -}; - -#endif // CORE_FPDFAPI_IPDF_RENDERMODULE_H_ |