summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fxcodec/fx_codec.h70
-rw-r--r--core/include/fxcrt/fx_arb.h16
-rw-r--r--core/include/fxge/fx_font.h7
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.h8
-rw-r--r--core/src/fpdftext/fpdf_text.cpp15
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp24
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp42
-rw-r--r--core/src/fxcrt/fx_arabic.cpp5
-rw-r--r--core/src/fxcrt/fx_arabic.h20
10 files changed, 70 insertions, 147 deletions
diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h
index e8faf3f78f..e3d69e5dc9 100644
--- a/core/include/fxcodec/fx_codec.h
+++ b/core/include/fxcodec/fx_codec.h
@@ -7,6 +7,7 @@
#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 "fx_codec_def.h"
#include "fx_codec_provider.h"
@@ -22,63 +23,28 @@ class ICodec_IccModule;
class ICodec_FlateModule;
class ICodec_Jbig2Encoder;
class ICodec_ScanlineDecoder;
+
class CCodec_ModuleMgr
{
public:
-
- static CCodec_ModuleMgr* Create();
-
- void Destroy();
-
- void InitJbig2Decoder();
-
- void InitJpxDecoder();
-
-
- void InitIccDecoder();
-
- 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;
- }
-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_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(); }
+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;
};
class ICodec_BasicModule
{
diff --git a/core/include/fxcrt/fx_arb.h b/core/include/fxcrt/fx_arb.h
index 3485ce27bb..7ce21e5086 100644
--- a/core/include/fxcrt/fx_arb.h
+++ b/core/include/fxcrt/fx_arb.h
@@ -12,16 +12,14 @@
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_
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index 49b8f9a974..31794d6743 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -424,12 +424,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_
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
index 3dde7fbdf6..a65359c1d4 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -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;
}
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
index 31eff141b4..69ccc3e453 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
@@ -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_
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 30934f6820..91d0e41b8d 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -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)
{
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 712de4893c..6755939ca2 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -7,6 +7,7 @@
#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"
@@ -1228,7 +1229,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 +1250,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 +1264,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 +1362,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)
{
@@ -1854,7 +1854,7 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
const CPDF_Font* pFont,
int nItems) const
{
- IFX_BidiChar* BidiChar = IFX_BidiChar::Create();
+ nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create());
int32_t nR2L = 0;
int32_t nL2R = 0;
int32_t start = 0, count = 0;
@@ -1872,8 +1872,8 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
if (!wChar) {
continue;
}
- if (BidiChar && BidiChar->AppendChar(wChar)) {
- int32_t ret = BidiChar->GetBidiInfo(start, count);
+ if (pBidiChar->AppendChar(wChar)) {
+ int32_t ret = pBidiChar->GetBidiInfo(start, count);
if (ret == 2) {
nR2L++;
}
@@ -1882,8 +1882,8 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
}
}
}
- if (BidiChar && BidiChar->EndChar()) {
- int32_t ret = BidiChar->GetBidiInfo(start, count);
+ if (pBidiChar->EndChar()) {
+ int32_t ret = pBidiChar->GetBidiInfo(start, count);
if (ret == 2) {
nR2L++;
}
@@ -1891,8 +1891,6 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
nL2R++;
}
}
- if (BidiChar)
- BidiChar->Release();
return (nR2L > 0 && nR2L >= nL2R);
}
int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj)
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index db95053efd..9bbcce105f 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -7,33 +7,13 @@
#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_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) {
}
CCodec_ScanlineDecoder::CCodec_ScanlineDecoder()
{
@@ -241,14 +221,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;
-}
class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder
{
public:
diff --git a/core/src/fxcrt/fx_arabic.cpp b/core/src/fxcrt/fx_arabic.cpp
index 94b514bd0d..3cb2fd067a 100644
--- a/core/src/fxcrt/fx_arabic.cpp
+++ b/core/src/fxcrt/fx_arabic.cpp
@@ -22,6 +22,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];
diff --git a/core/src/fxcrt/fx_arabic.h b/core/src/fxcrt/fx_arabic.h
index e7e6a28c43..e4c1ddacf2 100644
--- a/core/src/fxcrt/fx_arabic.h
+++ b/core/src/fxcrt/fx_arabic.h
@@ -13,21 +13,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;