summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-19 17:17:54 -0700
committerLei Zhang <thestig@chromium.org>2015-06-19 17:17:54 -0700
commitfa6eb28e08d924271d91758f945ce48a1c2dbf0c (patch)
tree6d4e627b18c5ac50cca976709ae5fb2c01b525c6 /core/src
parente5b0bd1a79f90b7758246655e18ef965a87bcd0b (diff)
downloadpdfium-fa6eb28e08d924271d91758f945ce48a1c2dbf0c.tar.xz
Merge to XFA: Make CPDF_PageModuleDef and CPDF_RenderModuleDef pure virtual.
Get rid of the dummy implementations, which are never used when the modules have been initialized. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1177383003. (cherry picked from commit 5fef754bc09e971f1bf1ba79da98c0a7ee1e1c8d) Review URL: https://codereview.chromium.org/1189413006.
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdfapi/fpdf_basic_module.cpp52
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp25
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp43
5 files changed, 65 insertions, 59 deletions
diff --git a/core/src/fpdfapi/fpdf_basic_module.cpp b/core/src/fpdfapi/fpdf_basic_module.cpp
index 62be616d3d..03cfd66afb 100644
--- a/core/src/fpdfapi/fpdf_basic_module.cpp
+++ b/core/src/fpdfapi/fpdf_basic_module.cpp
@@ -6,50 +6,44 @@
#include "../../include/fxcodec/fx_codec.h"
#include "../../include/fpdfapi/fpdf_module.h"
-static CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = NULL;
+
+namespace {
+
+CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = nullptr;
+
+const char kAddinNameCJK[] = "Eastern Asian Language Support";
+
+} // namespace
+
+// static
CPDF_ModuleMgr* CPDF_ModuleMgr::Get()
{
return g_FPDFAPI_pDefaultMgr;
}
+
+// static
void CPDF_ModuleMgr::Create()
{
+ ASSERT(!g_FPDFAPI_pDefaultMgr);
g_FPDFAPI_pDefaultMgr = new CPDF_ModuleMgr;
- g_FPDFAPI_pDefaultMgr->Initialize();
}
+
+// static
void CPDF_ModuleMgr::Destroy()
{
- if (g_FPDFAPI_pDefaultMgr) {
- delete g_FPDFAPI_pDefaultMgr;
- }
- g_FPDFAPI_pDefaultMgr = NULL;
+ delete g_FPDFAPI_pDefaultMgr;
+ g_FPDFAPI_pDefaultMgr = nullptr;
}
+
CPDF_ModuleMgr::CPDF_ModuleMgr()
+ : m_pCodecModule(nullptr)
{
- m_pCodecModule = NULL;
- m_pPageModule = NULL;
- m_pRenderModule = NULL;
- m_FileBufSize = 512;
-}
-void CPDF_ModuleMgr::Initialize()
-{
- InitModules();
- m_FileBufSize = 512;
-}
-void CPDF_ModuleMgr::InitModules()
-{
- m_pCodecModule = NULL;
- m_pPageModule = new CPDF_PageModuleDef;
- m_pRenderModule = new CPDF_RenderModuleDef;
}
+
CPDF_ModuleMgr::~CPDF_ModuleMgr()
{
- if (m_pPageModule) {
- delete m_pPageModule;
- }
- if (m_pRenderModule) {
- delete m_pRenderModule;
- }
}
+
void CPDF_ModuleMgr::SetDownloadCallback(FX_BOOL (*callback)(const FX_CHAR* module_name))
{
m_pDownloadCallback = callback;
@@ -63,10 +57,8 @@ FX_BOOL CPDF_ModuleMgr::DownloadModule(const FX_CHAR* module_name)
}
void CPDF_ModuleMgr::NotifyModuleAvailable(const FX_CHAR* module_name)
{
- if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) {
+ if (FXSYS_strcmp(module_name, kAddinNameCJK) == 0) {
m_pPageModule->NotifyCJKAvailable();
- } else if (FXSYS_strcmp(module_name, ADDIN_NAME_DECODER) == 0) {
- m_pRenderModule->NotifyDecoderAvailable();
}
}
void CPDF_ModuleMgr::RegisterSecurityHandler(const FX_CHAR* filter, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param)
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 984baedf16..97b28574fc 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -898,7 +898,7 @@ void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse)
CPDF_Page::~CPDF_Page()
{
if (m_pPageRender) {
- CPDF_RenderModuleDef* pModule = CPDF_ModuleMgr::Get()->GetRenderModule();
+ IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule();
pModule->DestroyPageCache(m_pPageRender);
}
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
index 49c158c52f..05233a12a4 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
@@ -10,7 +10,7 @@
#include "../fpdf_font/font_int.h"
#include "pageint.h"
-class CPDF_PageModule : public CPDF_PageModuleDef
+class CPDF_PageModule : public IPDF_PageModule
{
public:
CPDF_PageModule()
@@ -26,24 +26,30 @@ private:
{
return new CPDF_DocPageData(pDoc);
}
- virtual void ReleaseDoc(CPDF_Document* pDoc);
- virtual void ClearDoc(CPDF_Document* pDoc);
- virtual CPDF_FontGlobals* GetFontGlobals()
+
+ void ReleaseDoc(CPDF_Document* pDoc) override;
+ void ClearDoc(CPDF_Document* pDoc) override;
+
+ CPDF_FontGlobals* GetFontGlobals() override
{
return &m_FontGlobals;
}
- virtual void ClearStockFont(CPDF_Document* pDoc)
+
+ void ClearStockFont(CPDF_Document* pDoc) override
{
m_FontGlobals.Clear(pDoc);
}
- virtual CPDF_ColorSpace* GetStockCS(int family);
- virtual void NotifyCJKAvailable();
+
+ 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;
};
+
CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family)
{
if (family == PDFCS_DEVICEGRAY) {
@@ -60,11 +66,12 @@ CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family)
}
return NULL;
}
+
void CPDF_ModuleMgr::InitPageModule()
{
- delete m_pPageModule;
- m_pPageModule = new CPDF_PageModule;
+ m_pPageModule.reset(new CPDF_PageModule);
}
+
void CPDF_PageModule::ReleaseDoc(CPDF_Document* pDoc)
{
delete pDoc->GetPageData();
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 4362735d72..9f5acb5257 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1690,7 +1690,7 @@ CPDF_SyntaxParser::CPDF_SyntaxParser()
m_pFileAccess = NULL;
m_pCryptoHandler = NULL;
m_pFileBuf = NULL;
- m_BufSize = CPDF_ModuleMgr::Get()->m_FileBufSize;
+ m_BufSize = CPDF_ModuleMgr::kFileBufSize;
m_pFileBuf = NULL;
m_MetadataObjnum = 0;
m_dwWordPos = 0;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 608e124118..06c9ea614f 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -78,34 +78,40 @@ void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont)
if (m_Type3FaceMap.Lookup(pFont, pCache))
pCache->RemoveRef();
}
-class CPDF_RenderModule : public CPDF_RenderModuleDef
+
+class CPDF_RenderModule : public IPDF_RenderModule
{
public:
- virtual ~CPDF_RenderModule() {}
- virtual FX_BOOL Installed()
- {
- return TRUE;
- }
- virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc);
- virtual void DestroyDocData(CPDF_DocRenderData* p);
- virtual void ClearDocData(CPDF_DocRenderData* p);
- virtual CPDF_DocRenderData* GetRenderData()
+ 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;
}
- virtual CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage)
+
+ CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage) override
{
return new CPDF_PageRenderCache(pPage);
}
- virtual void DestroyPageCache(CPDF_PageRenderCache* pCache);
- virtual CPDF_RenderConfig* GetConfig()
+
+ void DestroyPageCache(CPDF_PageRenderCache* pCache) override;
+
+ CPDF_RenderConfig* GetConfig() override
{
return &m_RenderConfig;
}
-private:
- CPDF_DocRenderData m_RenderData;
- CPDF_RenderConfig m_RenderConfig;
+
+ CPDF_DocRenderData m_RenderData;
+ CPDF_RenderConfig m_RenderConfig;
};
+
CPDF_DocRenderData* CPDF_RenderModule::CreateDocData(CPDF_Document* pDoc)
{
CPDF_DocRenderData* pData = new CPDF_DocRenderData(pDoc);
@@ -126,11 +132,12 @@ void CPDF_RenderModule::DestroyPageCache(CPDF_PageRenderCache* pCache)
{
delete pCache;
}
+
void CPDF_ModuleMgr::InitRenderModule()
{
- delete m_pRenderModule;
- m_pRenderModule = new CPDF_RenderModule;
+ m_pRenderModule.reset(new CPDF_RenderModule);
}
+
CPDF_RenderOptions::CPDF_RenderOptions()
: m_ColorMode(RENDER_COLOR_NORMAL)
, m_Flags(RENDER_CLEARTYPE)