Replace some Release() calls with virtual destructors.
authorTom Sepez <tsepez@chromium.org>
Thu, 18 Jun 2015 19:47:11 +0000 (12:47 -0700)
committerTom Sepez <tsepez@chromium.org>
Thu, 18 Jun 2015 19:47:11 +0000 (12:47 -0700)
Required fixing xfa-specific code.

Original Review URL: https://codereview.chromium.org/1192013002.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1176413004.

17 files changed:
core/include/fxcodec/fx_codec.h
core/include/fxcrt/fx_arb.h
core/include/fxge/fx_font.h
core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
core/src/fpdfapi/fpdf_font/ttgsubtable.h
core/src/fpdftext/fpdf_text.cpp
core/src/fpdftext/fpdf_text_int.cpp
core/src/fxcodec/codec/fx_codec.cpp
core/src/fxcrt/fx_arabic.cpp
core/src/fxcrt/fx_arabic.h
fpdfsdk/include/fsdk_actionhandler.h
fpdfsdk/include/fsdk_baseform.h
fpdfsdk/src/fpdfview.cpp
fpdfsdk/src/fsdk_actionhandler.cpp
fpdfsdk/src/fsdk_baseform.cpp
fpdfsdk/src/fsdk_mgr.cpp
xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.cpp

index dc2595b..218999a 100644 (file)
@@ -7,13 +7,15 @@
 #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_
 #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_
 
+#include "../../../third_party/base/nonstd_unique_ptr.h"
+#include "../fxcrt/fx_basic.h"
 #include "../fxcrt/fx_ext.h"
 #include "fx_codec_def.h"
 #include "fx_codec_provider.h"
 
 class CFX_DIBSource;
 class ICodec_ScanlineDecoder;
-class ICodec_ProgressiveDecoder;\r
+class ICodec_ProgressiveDecoder;
 class ICodec_BasicModule;
 class ICodec_FaxModule;
 class ICodec_JpegModule;
@@ -22,92 +24,43 @@ class ICodec_Jbig2Module;
 class ICodec_IccModule;
 class ICodec_FlateModule;
 class ICodec_Jbig2Encoder;
-class ICodec_PngModule;\r
-class ICodec_GifModule;\r
-class ICodec_BmpModule;\r
-class ICodec_TiffModule;\r
-class CFX_DIBAttribute;\r
+class ICodec_PngModule;
+class ICodec_GifModule;
+class ICodec_BmpModule;
+class ICodec_TiffModule;
+class CFX_DIBAttribute;
 class ICodec_ScanlineDecoder;
+
 class CCodec_ModuleMgr
 {
 public:
-
-    static CCodec_ModuleMgr*   Create();
-
-    void                               Destroy();
-
-    void                               InitJbig2Decoder();
-
-    void                               InitJpxDecoder();
-
-
-    void                               InitIccDecoder();
-
-\r
-    ICodec_ProgressiveDecoder* CreateProgressiveDecoder();\r
-\r
-    ICodec_Jbig2Encoder*               CreateJbig2Encoder();
-protected:
     CCodec_ModuleMgr();
-    ~CCodec_ModuleMgr();
-public:
-    ICodec_BasicModule*        GetBasicModule()
-    {
-        return m_pBasicModule;
-    }
-    ICodec_FaxModule*  GetFaxModule()
-    {
-        return m_pFaxModule;
-    }
-    ICodec_JpegModule* GetJpegModule()
-    {
-        return m_pJpegModule;
-    }
-    ICodec_JpxModule*  GetJpxModule()
-    {
-        return m_pJpxModule;
-    }
-    ICodec_Jbig2Module*        GetJbig2Module()
-    {
-        return m_pJbig2Module;
-    }
-    ICodec_IccModule*  GetIccModule()
-    {
-        return m_pIccModule;
-    }
-    ICodec_FlateModule*        GetFlateModule()
-    {
-        return m_pFlateModule;
-    }
-    ICodec_PngModule*  GetPngModule()\r
-    {\r
-        return m_pPngModule;\r
-    }\r
-    ICodec_GifModule*  GetGifModule()\r
-    {\r
-        return m_pGifModule;\r
-    }\r
-    ICodec_BmpModule*  GetBmpModule()\r
-    {\r
-        return m_pBmpModule;\r
-    }\r
-    ICodec_TiffModule* GetTiffModule()\r
-    {\r
-        return m_pTiffModule;\r
-    }\r
-protected:
-    ICodec_BasicModule*        m_pBasicModule;
-    ICodec_FaxModule*  m_pFaxModule;
-    ICodec_JpegModule* m_pJpegModule;
-    ICodec_JpxModule*  m_pJpxModule;
-    ICodec_Jbig2Module*        m_pJbig2Module;
-    ICodec_IccModule*  m_pIccModule;
-    ICodec_FlateModule*        m_pFlateModule;
-    ICodec_PngModule*  m_pPngModule;\r
-    ICodec_GifModule*  m_pGifModule;\r
-    ICodec_BmpModule*  m_pBmpModule;\r
-    ICodec_TiffModule* m_pTiffModule;\r
+    ICodec_ProgressiveDecoder* CreateProgressiveDecoder();
+    ICodec_Jbig2Encoder* CreateJbig2Encoder();
+    ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
+    ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
+    ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
+    ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
+    ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
+    ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
+    ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
+    ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
+    ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
+    ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
+    ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
 
+protected:
+    nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule;
+    nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule;
+    nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule;
+    nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule;
+    nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module;
+    nonstd::unique_ptr<ICodec_IccModule> m_pIccModule;
+    nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule;
+    nonstd::unique_ptr<ICodec_PngModule> m_pPngModule;
+    nonstd::unique_ptr<ICodec_GifModule> m_pGifModule;
+    nonstd::unique_ptr<ICodec_BmpModule> m_pBmpModule;
+    nonstd::unique_ptr<ICodec_TiffModule> m_pTiffModule;
 };
 class ICodec_BasicModule
 {
index 8022daa..5d3b0eb 100644 (file)
@@ -61,16 +61,14 @@ void FX_BidiLine(CFX_RTFCharArray &chars, int32_t iCount, int32_t iBaseLevel = 0
 class IFX_BidiChar
 {
 public:
-    static IFX_BidiChar*       Create();
-    virtual void                       Release() = 0;
-    virtual void                       SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0;
-    virtual FX_BOOL                    AppendChar(FX_WCHAR wch) = 0;
-    virtual FX_BOOL                    EndChar() = 0;
-    virtual int32_t            GetBidiInfo(int32_t &iStart, int32_t &iCount) = 0;
-    virtual void                       Reset() = 0;
+    static IFX_BidiChar* Create();
+    virtual ~IFX_BidiChar() {}
 
-protected:
-    ~IFX_BidiChar() { }
+    virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0;
+    virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0;
+    virtual FX_BOOL EndChar() = 0;
+    virtual int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) = 0;
+    virtual void Reset() = 0;
 };
 
 #endif  // CORE_INCLUDE_FXCRT_FX_ARB_H_
index bd49e01..80dd1a4 100644 (file)
@@ -465,12 +465,9 @@ FX_BOOL    OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size,
 class IFX_GSUBTable
 {
 public:
-    virtual void       Release() = 0;
+    static IFX_GSUBTable* Create(CFX_Font* pFont);
+    virtual ~IFX_GSUBTable() { }
     virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0;
-
-protected:
-     ~IFX_GSUBTable() { }
 };
-IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont);
 
 #endif  // CORE_INCLUDE_FXGE_FX_FONT_H_
index 3dde7fb..a65359c 100644 (file)
@@ -4,9 +4,11 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../../third_party/base/nonstd_unique_ptr.h"
 #include "../../../include/fxge/fx_ge.h"
 #include "../../../include/fxge/fx_freetype.h"
 #include "ttgsubtable.h"
+
 CFX_GlyphMap::CFX_GlyphMap()
 {
 }
@@ -422,7 +424,8 @@ FX_BOOL CFX_GSUBTable::GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum)
 {
     return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum);
 }
-IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont)
+// static
+IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont)
 {
     if (!pFont) {
         return NULL;
@@ -439,11 +442,10 @@ IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont)
     }
     int error = FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, pFont->m_pGsubData, NULL);
     if (!error && pFont->m_pGsubData) {
-        CFX_GSUBTable* pGsubTable = new CFX_GSUBTable;
+        nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable);
         if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->m_pGsubData)) {
-            return pGsubTable;
+            return pGsubTable.release();
         }
-        pGsubTable->Release();
     }
     return NULL;
 }
index 31eff14..69ccc3e 100644 (file)
@@ -411,16 +411,10 @@ private:
 class CFX_GSUBTable final : public IFX_GSUBTable
 {
 public:
-    virtual void       Release() override
-    {
-        delete this;
-    }
+    ~CFX_GSUBTable() override {}
     virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) override;
 
     CFX_CTTGSUBTable m_GsubImp;
-
-private:
-    ~CFX_GSUBTable() { }
 };
 
 #endif  // CORE_SRC_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_
index 5aff3a0..8d32c11 100644 (file)
@@ -4,6 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../third_party/base/nonstd_unique_ptr.h"
 #include "../../include/fpdfapi/fpdf_page.h"
 #include "../../include/fpdfapi/fpdf_pageobj.h"
 #include "../../include/fpdftext/fpdf_text.h"
@@ -308,17 +309,14 @@ void NormalizeString(CFX_WideString& str)
         return;
     }
     CFX_WideString sBuffer;
-    IFX_BidiChar* BidiChar = IFX_BidiChar::Create();
-    if (NULL == BidiChar)      {
-        return;
-    }
+    nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create());
     CFX_WordArray order;
     FX_BOOL bR2L = FALSE;
     int32_t start = 0, count = 0, i = 0;
     int nR2L = 0, nL2R = 0;
     for (i = 0; i < str.GetLength(); i++) {
-        if(BidiChar->AppendChar(str.GetAt(i))) {
-            int32_t ret = BidiChar->GetBidiInfo(start, count);
+        if(pBidiChar->AppendChar(str.GetAt(i))) {
+            int32_t ret = pBidiChar->GetBidiInfo(start, count);
             order.Add(start);
             order.Add(count);
             order.Add(ret);
@@ -331,8 +329,8 @@ void NormalizeString(CFX_WideString& str)
             }
         }
     }
-    if(BidiChar->EndChar()) {
-        int32_t ret = BidiChar->GetBidiInfo(start, count);
+    if(pBidiChar->EndChar()) {
+        int32_t ret = pBidiChar->GetBidiInfo(start, count);
         order.Add(start);
         order.Add(count);
         order.Add(ret);
@@ -428,7 +426,6 @@ void NormalizeString(CFX_WideString& str)
     }
     str.Empty();
     str += sBuffer;
-    BidiChar->Release();
 }
 static FX_BOOL IsNumber(CFX_WideString& str)
 {
index 4ad2cd4..84edf81 100644 (file)
@@ -4,13 +4,15 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "../../include/fpdfapi/fpdf_resource.h"
-#include "../../include/fpdfapi/fpdf_pageobj.h"
-#include "../../include/fpdftext/fpdf_text.h"
-#include "../../include/fpdfapi/fpdf_page.h"
-#include "../../include/fpdfapi/fpdf_module.h"
 #include <ctype.h>
 #include <algorithm>
+
+#include "../../../third_party/base/nonstd_unique_ptr.h"
+#include "../../include/fpdfapi/fpdf_module.h"
+#include "../../include/fpdfapi/fpdf_page.h"
+#include "../../include/fpdfapi/fpdf_pageobj.h"
+#include "../../include/fpdfapi/fpdf_resource.h"
+#include "../../include/fpdftext/fpdf_text.h"
 #include "text_int.h"
 
 namespace {
@@ -1228,7 +1230,7 @@ void CPDF_TextPage::CloseTempLine()
     if (count1 <= 0) {
         return;
     }
-    IFX_BidiChar* BidiChar = IFX_BidiChar::Create();
+    nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create());
     CFX_WideString str = m_TempTextBuf.GetWideString();
     CFX_WordArray order;
     FX_BOOL bR2L = FALSE;
@@ -1249,8 +1251,8 @@ void CPDF_TextPage::CloseTempLine()
         } else {
             bPrevSpace = FALSE;
         }
-        if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) {
-            int32_t ret = BidiChar->GetBidiInfo(start, count);
+        if(pBidiChar->AppendChar(str.GetAt(i))) {
+            int32_t ret = pBidiChar->GetBidiInfo(start, count);
             order.Add(start);
             order.Add(count);
             order.Add(ret);
@@ -1263,8 +1265,8 @@ void CPDF_TextPage::CloseTempLine()
             }
         }
     }
-    if(BidiChar && BidiChar->EndChar()) {
-        int32_t ret = BidiChar->GetBidiInfo(start, count);
+    if(pBidiChar->EndChar()) {
+        int32_t ret = pBidiChar->GetBidiInfo(start, count);
         order.Add(start);
         order.Add(count);
         order.Add(ret);
@@ -1361,7 +1363,6 @@ void CPDF_TextPage::CloseTempLine()
     order.RemoveAll();
     m_TempCharList.RemoveAll();
     m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength());
-    BidiChar->Release();
 }
 void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj, const CFX_AffineMatrix& formMatrix, FX_POSITION ObjPos)
 {
index 319e66e..96366fa 100644 (file)
@@ -6,38 +6,19 @@
 
 #include "../../../include/fxcodec/fx_codec.h"
 #include "codec_int.h"
+
 CCodec_ModuleMgr::CCodec_ModuleMgr()
-{
-    m_pBasicModule = new CCodec_BasicModule;
-    m_pFaxModule = new CCodec_FaxModule;
-    m_pJpegModule = new CCodec_JpegModule;
-    m_pJpxModule = new CCodec_JpxModule;
-    m_pJbig2Module = new CCodec_Jbig2Module;
-    m_pIccModule = new CCodec_IccModule;
-    m_pPngModule = new CCodec_PngModule;
-    m_pGifModule = new CCodec_GifModule;
-    m_pBmpModule = new CCodec_BmpModule;
-    m_pTiffModule = new CCodec_TiffModule;
-    m_pFlateModule = new CCodec_FlateModule;
-}
-CCodec_ModuleMgr::~CCodec_ModuleMgr()
-{
-    delete m_pBasicModule;
-    delete m_pFaxModule;
-    delete m_pJpegModule;
-    delete m_pFlateModule;
-    delete m_pJpxModule;
-    delete m_pJbig2Module;
-    delete m_pIccModule;
-}
-void CCodec_ModuleMgr::InitJbig2Decoder()
-{
-}
-void CCodec_ModuleMgr::InitJpxDecoder()
-{
-}
-void CCodec_ModuleMgr::InitIccDecoder()
-{
+  : m_pBasicModule(new CCodec_BasicModule),
+    m_pFaxModule(new CCodec_FaxModule),
+    m_pJpegModule(new CCodec_JpegModule),
+    m_pJpxModule(new CCodec_JpxModule),
+    m_pJbig2Module(new CCodec_Jbig2Module),
+    m_pIccModule(new CCodec_IccModule),
+    m_pFlateModule(new CCodec_FlateModule),
+    m_pPngModule(new CCodec_PngModule),
+    m_pGifModule(new CCodec_GifModule),
+    m_pBmpModule(new CCodec_BmpModule),
+    m_pTiffModule(new CCodec_TiffModule) {
 }
 CCodec_ScanlineDecoder::CCodec_ScanlineDecoder()
 {
@@ -245,14 +226,6 @@ FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size,
 {
     return FALSE;
 }
-CCodec_ModuleMgr* CCodec_ModuleMgr::Create()
-{
-    return new CCodec_ModuleMgr;
-}
-void CCodec_ModuleMgr::Destroy()
-{
-    delete this;
-}
 CFX_DIBAttribute::CFX_DIBAttribute()
 {
     FXSYS_memset(this, 0, sizeof(CFX_DIBAttribute));
index 159c0bb..fc2ec41 100644 (file)
@@ -1099,6 +1099,11 @@ CFX_BidiChar::CFX_BidiChar()
     , m_iLastCount(0)
 {
 }
+void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral)
+{
+    m_bSeparateNeutral = bSeparateNeutral;
+}
+
 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch)
 {
     FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch];
index 862aabb..1693832 100644 (file)
@@ -184,21 +184,15 @@ class CFX_BidiChar final : public IFX_BidiChar
 {
 public:
     CFX_BidiChar();
-    virtual void               Release() override
-    {
-        delete this;
-    }
-    virtual void               SetPolicy(FX_BOOL bSeparateNeutral = TRUE) override
-    {
-        m_bSeparateNeutral = bSeparateNeutral;
-    }
-    virtual FX_BOOL            AppendChar(FX_WCHAR wch) override;
-    virtual FX_BOOL            EndChar() override;
-    virtual int32_t    GetBidiInfo(int32_t &iStart, int32_t &iCount) override;
-    virtual void               Reset() override;
+    ~CFX_BidiChar() override {}
+
+    void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) override;
+    FX_BOOL AppendChar(FX_WCHAR wch) override;
+    FX_BOOL EndChar() override;
+    int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) override;
+    void Reset() override;
 
 private:
-    ~CFX_BidiChar() { }
     FX_BOOL    m_bSeparateNeutral;
     int32_t    m_iCurStart;
     int32_t    m_iCurCount;
index 311380e..39ec4f4 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "../../core/include/fpdfdoc/fpdf_doc.h"
 #include "../../core/include/fxcrt/fx_string.h"
+#include "../../third_party/base/nonstd_unique_ptr.h"
 #include "fsdk_baseform.h"
 
 class CFX_PtrList;
@@ -36,53 +37,48 @@ public:
        FX_BOOL DoAction_Movie(const CPDF_Action& action, CPDFSDK_Document* pDocument);
 };
 
-class  CPDFSDK_ActionHandler /*: public CReader_ActionHandler*/
+class CPDFSDK_ActionHandler
 {
 public:
        CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi);
-       virtual ~CPDFSDK_ActionHandler();
 
-       virtual void            Destroy();
-       virtual FX_BOOL         DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CPDFSDK_DocView *pDocView*/);
-       virtual FX_BOOL         DoAction_JavaScript(const CPDF_Action& JsAction,CFX_WideString csJSName, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/);
-       virtual FX_BOOL         DoAction_Page(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/);
-       virtual FX_BOOL         DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/);
-       virtual FX_BOOL         DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/);
-       virtual FX_BOOL         DoAction_Screen(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,/* CReader_DocView *pDocView,*/ CPDFSDK_Annot* pScreen);
-       virtual FX_BOOL         DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/);
-       virtual FX_BOOL         DoAction_Field(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ CPDF_FormField* pFormField, PDFSDK_FieldAction& data);
-       virtual FX_BOOL         DoAction_FieldJavaScript(const CPDF_Action& JsAction, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data);
-public:
-       void                            SetFormActionHandler(CPDFSDK_FormActionHandler* pHandler);
-       void                            SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler);
+       void SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler);
+
+       FX_BOOL         DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument);
+       FX_BOOL         DoAction_JavaScript(const CPDF_Action& JsAction,CFX_WideString csJSName, CPDFSDK_Document* pDocument);
+       FX_BOOL         DoAction_Page(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument);
+       FX_BOOL         DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument);
+       FX_BOOL         DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument);
+       FX_BOOL         DoAction_Screen(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen);
+       FX_BOOL         DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument);
+       FX_BOOL         DoAction_Field(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,  CPDF_FormField* pFormField, PDFSDK_FieldAction& data);
+       FX_BOOL         DoAction_FieldJavaScript(const CPDF_Action& JsAction, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data);
 
 private:
-       FX_BOOL                         ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ CFX_PtrList& list);
-       FX_BOOL                         ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ CFX_PtrList& list);
-       FX_BOOL                         ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CPDF_FormField* pFormField, PDFSDK_FieldAction& data, CFX_PtrList& list);
-       FX_BOOL                         ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CPDFSDK_Annot* pScreen, CFX_PtrList& list);
-       FX_BOOL                         ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CPDF_Bookmark* pBookmark, CFX_PtrList& list);
-       FX_BOOL                         ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CFX_PtrList& list);
+       FX_BOOL                         ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_Document* pDocument,  CFX_PtrList& list);
+       FX_BOOL                         ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,  CFX_PtrList& list);
+       FX_BOOL                         ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,  CPDF_FormField* pFormField, PDFSDK_FieldAction& data, CFX_PtrList& list);
+       FX_BOOL                         ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,  CPDFSDK_Annot* pScreen, CFX_PtrList& list);
+       FX_BOOL                         ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument,  CPDF_Bookmark* pBookmark, CFX_PtrList& list);
+       FX_BOOL                         ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_Document* pDocument,  CFX_PtrList& list);
 
-       void                            DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/);
+       void                            DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument);
        void                            RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, CPDF_AAction::AActionType type, const CFX_WideString& script);
        void                            RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, const CFX_WideString& sScriptName, const CFX_WideString& script);
        void                            RunFieldJavaScript(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, const CFX_WideString& script);
 
-private:
        FX_BOOL                         IsValidField(CPDFSDK_Document* pDocument, CPDF_Dictionary* pFieldDict);
-       FX_BOOL                         IsValidDocView(CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/);
+       FX_BOOL                         IsValidDocView(CPDFSDK_Document* pDocument);
 
-       void                            DoAction_GoTo(CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ const CPDF_Action& action);
+       void                            DoAction_GoTo(CPDFSDK_Document* pDocument,  const CPDF_Action& action);
        void                            DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action);
        void                            DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action);
        void                            DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action);
        void                            DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action);
-       void                            DoAction_SetOCGState(CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ const CPDF_Action& action);
+       void                            DoAction_SetOCGState(CPDFSDK_Document* pDocument, const CPDF_Action& action);
 
-private:
-       CPDFSDK_FormActionHandler*              m_pFormActionHandler;
-       CPDFSDK_MediaActionHandler*             m_pMediaActionHandler;
+    nonstd::unique_ptr<CPDFSDK_FormActionHandler> m_pFormActionHandler;
+    CPDFSDK_MediaActionHandler* m_pMediaActionHandler;
 };
 
 #endif  // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_
index 7d9b01e..f808138 100644 (file)
@@ -64,7 +64,7 @@ typedef struct _PDFSDK_FieldAction
        FX_BOOL                                 bFieldFull;             //in
        FX_BOOL                                 bRC;                    //in[out]
 }PDFSDK_FieldAction;
-class CPDFSDK_Widget:public CPDFSDK_BAAnnot
+class CPDFSDK_Widget : public CPDFSDK_BAAnnot
 {
 public:
        IXFA_Widget*                                            GetMixXFAWidget();
@@ -226,14 +226,12 @@ private:
 class CPDFSDK_InterForm : public CPDF_FormNotify
 {
 public:
-       CPDFSDK_InterForm(CPDFSDK_Document* pDocument);
-       virtual ~CPDFSDK_InterForm();
+       explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument);
+       ~CPDFSDK_InterForm() override;
 
-public:
-       virtual void                                    Destroy();
-       virtual CPDF_InterForm*                 GetInterForm();
+       CPDF_InterForm* GetInterForm() const { return m_pInterForm; }
+       CPDFSDK_Document* GetDocument() const { return m_pDocument; }
 
-       CPDFSDK_Document*                               GetDocument();
        FX_BOOL                                                 HighlightWidgets();
 
        CPDFSDK_Widget*                                 GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const;
index 80aad14..227843e 100644 (file)
@@ -177,11 +177,11 @@ FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy)
        return FALSE;
 }
 
-CCodec_ModuleMgr*      g_pCodecModule = NULL;
+CCodec_ModuleMgr* g_pCodecModule = nullptr;
 
 DLLEXPORT void STDCALL FPDF_InitLibrary()
 {
-    g_pCodecModule = CCodec_ModuleMgr::Create();
+    g_pCodecModule = new CCodec_ModuleMgr();
 
     CFX_GEModule::Create();
     CFX_GEModule::Get()->SetCodecModule(g_pCodecModule);
@@ -199,7 +199,9 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary()
     CPDFXFA_App::ReleaseInstance();
     CPDF_ModuleMgr::Destroy();
     CFX_GEModule::Destroy();
-    g_pCodecModule->Destroy();
+
+    delete g_pCodecModule;
+    g_pCodecModule = nullptr;
 }
 
 #ifndef _WIN32
index dd176ee..485852c 100644 (file)
 
 /* -------------------------- CBA_ActionHandler -------------------------- */
 
-CPDFSDK_ActionHandler::CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi) :
-       m_pFormActionHandler(NULL),
-       m_pMediaActionHandler(NULL)
-{
-               m_pFormActionHandler = new CPDFSDK_FormActionHandler;
-}
-
-CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler()
-{
-       if(m_pFormActionHandler)
-       {
-               delete m_pFormActionHandler;
-               m_pFormActionHandler = NULL;
-       }
-}
-
-void CPDFSDK_ActionHandler::SetFormActionHandler(CPDFSDK_FormActionHandler* pHandler)
-{
-       ASSERT(pHandler != NULL);
-       ASSERT(m_pFormActionHandler == NULL);
-       m_pFormActionHandler = pHandler;
+CPDFSDK_ActionHandler::CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi)
+    : m_pFormActionHandler(new CPDFSDK_FormActionHandler),
+      m_pMediaActionHandler(NULL) {
 }
 
 void CPDFSDK_ActionHandler::SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler)
@@ -42,11 +24,6 @@ void CPDFSDK_ActionHandler::SetMediaActionHandler(CPDFSDK_MediaActionHandler* pH
        m_pMediaActionHandler = pHandler;
 }
 
-void CPDFSDK_ActionHandler::Destroy()
-{
-       delete this;
-}
-
 //document open
 FX_BOOL        CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument)
 {
index 9ea2f4e..3e5e563 100644 (file)
@@ -2410,7 +2410,6 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
 
 CPDFSDK_InterForm::~CPDFSDK_InterForm()
 {
-       ASSERT(m_pInterForm != NULL);
        delete m_pInterForm;
        m_pInterForm = NULL;
 
@@ -2418,21 +2417,6 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm()
        m_XFAMap.RemoveAll();
 }
 
-void CPDFSDK_InterForm::Destroy()
-{
-       delete this;
-}
-
-CPDF_InterForm* CPDFSDK_InterForm::GetInterForm()
-{
-       return m_pInterForm;
-}
-
-CPDFSDK_Document* CPDFSDK_InterForm::GetDocument()
-{
-       return m_pDocument;
-}
-
 FX_BOOL CPDFSDK_InterForm::HighlightWidgets()
 {
        return FALSE;
index 3eb3c9d..69a9929 100644 (file)
@@ -316,25 +316,21 @@ CPDFSDK_Document::CPDFSDK_Document(CPDFXFA_Document* pDoc,CPDFDoc_Environment* p
 
 CPDFSDK_Document::~CPDFSDK_Document()
 {
-       FX_POSITION pos = m_pageMap.GetStartPosition();
-       while(pos)
-       {
-               CPDFXFA_Page* pPage = NULL;
-               CPDFSDK_PageView* pPageView = NULL;
-               m_pageMap.GetNextAssoc(pos, pPage, pPageView);
-               delete pPageView;
-       }
-       m_pageMap.RemoveAll();
-       if(m_pInterForm)
-       {
-               m_pInterForm->Destroy();
-               m_pInterForm = NULL;
-       }
-       if(m_pOccontent)
-       {
-               delete m_pOccontent;
-               m_pOccontent = NULL;
-       }
+    FX_POSITION pos = m_pageMap.GetStartPosition();
+    while(pos)
+    {
+        CPDFXFA_Page* pPage = NULL;
+        CPDFSDK_PageView* pPageView = NULL;
+        m_pageMap.GetNextAssoc(pos, pPage, pPageView);
+        delete pPageView;
+    }
+    m_pageMap.RemoveAll();
+
+    delete m_pInterForm;
+    m_pInterForm = nullptr;
+
+    delete m_pOccontent;
+    m_pOccontent = nullptr;
 }
 
 void CPDFSDK_Document::InitPageView()
index 423d2c7..7a266a7 100644 (file)
@@ -36,7 +36,7 @@ static CFX_DIBitmap* CreateDIBSource(IFX_FileRead* fileread)
     CFX_DIBitmap* bitmap = NULL;\r
     CCodec_ModuleMgr* pCodecMgr        = NULL;\r
     ICodec_ProgressiveDecoder* pImageCodec = NULL;\r
-    pCodecMgr = CCodec_ModuleMgr::Create();\r
+    pCodecMgr = new CCodec_ModuleMgr();\r
     pImageCodec = pCodecMgr->CreateProgressiveDecoder();\r
     FXCODEC_STATUS status = FXCODEC_STATUS_DECODE_FINISH;\r
     status = pImageCodec->LoadImageInfo(fileread, FXCODEC_IMAGE_UNKNOWN);\r
@@ -78,20 +78,16 @@ static CFX_DIBitmap* CreateDIBSource(IFX_FileRead* fileread)
         delete pImageCodec;\r
         pImageCodec = NULL;\r
     }\r
-    if (pCodecMgr) {\r
-        pCodecMgr->Destroy();\r
-        pCodecMgr = NULL;\r
-    }\r
+    delete pCodecMgr;\r
+    pCodecMgr = NULL;\r
     return bitmap;\r
 except:\r
     if (pImageCodec) {\r
         delete pImageCodec;\r
         pImageCodec = NULL;\r
     }\r
-    if (pCodecMgr) {\r
-        pCodecMgr->Destroy();\r
-        pCodecMgr = NULL;\r
-    }\r
+    delete pCodecMgr;\r
+    pCodecMgr = NULL;\r
     if (bitmap) {\r
         delete bitmap;\r
     }\r