diff options
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_FontMap.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_FontMap.h | 18 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.h | 3 |
4 files changed, 17 insertions, 23 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/pdfwindow/PWL_FontMap.cpp index 9192afd5e8..96acb78ec2 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/pdfwindow/PWL_FontMap.cpp @@ -35,14 +35,11 @@ const char* const g_sDEStandardFontName[] = {"Courier", } // namespace CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler) - : m_pPDFDoc(nullptr), m_pSystemHandler(pSystemHandler) { + : m_pSystemHandler(pSystemHandler) { ASSERT(m_pSystemHandler); } CPWL_FontMap::~CPWL_FontMap() { - delete m_pPDFDoc; - m_pPDFDoc = nullptr; - Empty(); } @@ -53,12 +50,12 @@ void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) { CPDF_Document* CPWL_FontMap::GetDocument() { if (!m_pPDFDoc) { if (CPDF_ModuleMgr::Get()) { - m_pPDFDoc = new CPDF_Document(nullptr); + m_pPDFDoc.reset(new CPDF_Document(nullptr)); m_pPDFDoc->CreateNewDoc(); } } - return m_pPDFDoc; + return m_pPDFDoc.get(); } CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) { @@ -413,7 +410,7 @@ int32_t CPWL_FontMap::GetNativeCharset() { return nCharset; } -const CPWL_FontMap::CharsetFontMap CPWL_FontMap::defaultTTFMap[] = { +const FPDF_CharsetFontMap CPWL_FontMap::defaultTTFMap[] = { {ANSI_CHARSET, "Helvetica"}, {GB2312_CHARSET, "SimSun"}, {CHINESEBIG5_CHARSET, "MingLiU"}, {SHIFTJIS_CHARSET, "MS Gothic"}, {HANGUL_CHARSET, "Batang"}, {RUSSIAN_CHARSET, "Arial"}, diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.h b/fpdfsdk/pdfwindow/PWL_FontMap.h index 2c40c92a97..7f347f5eb5 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.h +++ b/fpdfsdk/pdfwindow/PWL_FontMap.h @@ -7,6 +7,8 @@ #ifndef FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ #define FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ +#include <memory> + #include "core/fpdfdoc/include/ipvt_fontmap.h" #include "fpdfsdk/fxedit/include/fx_edit.h" #include "public/fpdf_sysfontinfo.h" @@ -80,6 +82,8 @@ class CPWL_FontMap : public IPVT_FontMap { CFX_ByteString& sFontName, uint8_t nCharset); + static const FPDF_CharsetFontMap defaultTTFMap[]; + protected: virtual void Initialize(); virtual CPDF_Document* GetDocument(); @@ -102,6 +106,9 @@ class CPWL_FontMap : public IPVT_FontMap { int32_t nCharset); CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); + CFX_ArrayTemplate<CPWL_FontMap_Data*> m_aData; + CFX_ArrayTemplate<CPWL_FontMap_Native*> m_aNativeFont; + private: CFX_ByteString GetFontName(int32_t nFontIndex); int32_t FindFont(const CFX_ByteString& sFontName, @@ -109,16 +116,7 @@ class CPWL_FontMap : public IPVT_FontMap { CFX_ByteString GetNativeFont(int32_t nCharset); - public: - using CharsetFontMap = FPDF_CharsetFontMap; - static const CharsetFontMap defaultTTFMap[]; - - protected: - CFX_ArrayTemplate<CPWL_FontMap_Data*> m_aData; - CFX_ArrayTemplate<CPWL_FontMap_Native*> m_aNativeFont; - - private: - CPDF_Document* m_pPDFDoc; + std::unique_ptr<CPDF_Document> m_pPDFDoc; CFX_SystemHandler* m_pSystemHandler; }; diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index e680652bb3..4a479de0dc 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -80,15 +80,13 @@ void CPWL_Timer::TimerProc(int32_t idEvent) { pTimer->m_pAttached->TimerProc(); } -CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(nullptr) {} +CPWL_TimerHandler::CPWL_TimerHandler() {} -CPWL_TimerHandler::~CPWL_TimerHandler() { - delete m_pTimer; -} +CPWL_TimerHandler::~CPWL_TimerHandler() {} void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { if (!m_pTimer) - m_pTimer = new CPWL_Timer(this, GetSystemHandler()); + m_pTimer.reset(new CPWL_Timer(this, GetSystemHandler())); if (m_pTimer) m_pTimer->SetPWLTimer(nElapse); diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index 3dfaf5afda..de48a8c82d 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h @@ -7,6 +7,7 @@ #ifndef FPDFSDK_PDFWINDOW_PWL_WND_H_ #define FPDFSDK_PDFWINDOW_PWL_WND_H_ +#include <memory> #include <vector> #include "core/fpdfdoc/include/cpdf_formcontrol.h" @@ -238,7 +239,7 @@ class CPWL_TimerHandler { virtual CFX_SystemHandler* GetSystemHandler() const = 0; private: - CPWL_Timer* m_pTimer; + std::unique_ptr<CPWL_Timer> m_pTimer; }; class CPWL_Wnd : public CPWL_TimerHandler { |