diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-06-17 16:38:51 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-06-17 16:38:51 -0700 |
commit | ff8347a4b16f000be628c5e10d03a1e1c17537eb (patch) | |
tree | 1d46e77a1ef6b28def6af3ffdd576017a6cfe229 /core/src/fpdftext/fpdf_text_int.cpp | |
parent | c4d9f6ad2dc922b574862cd2f6f0a899d7e169e3 (diff) | |
download | pdfium-ff8347a4b16f000be628c5e10d03a1e1c17537eb.tar.xz |
Replace some Release() calls with virtual destructors.
A virtual method that does |delete this| is an anti-pattern.
Some classes can be de-virtualized instead.
Throw in some unique_ptrs and delete dead code for good measure.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1192013002.
Diffstat (limited to 'core/src/fpdftext/fpdf_text_int.cpp')
-rw-r--r-- | core/src/fpdftext/fpdf_text_int.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
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) |