summaryrefslogtreecommitdiff
path: root/core/src/fpdftext
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fpdftext')
-rw-r--r--core/src/fpdftext/fpdf_text.cpp15
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp23
2 files changed, 18 insertions, 20 deletions
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 5aff3a02be..8d32c11ba6 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 4ad2cd4e77..84edf812d7 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -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)
{