summaryrefslogtreecommitdiff
path: root/core/src/fpdftext
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-29 15:01:55 -0700
committerLei Zhang <thestig@chromium.org>2015-10-29 15:01:55 -0700
commitee02ea37e8f85920885600d56df706d690e648ff (patch)
tree055bbc66a5c95a8bc75ccc491f73505bb8eb6676 /core/src/fpdftext
parent5a88b1131c450dee0500a02f80f0838385e4c4d2 (diff)
downloadpdfium-ee02ea37e8f85920885600d56df706d690e648ff.tar.xz
XFA: Manual merge of Clean up IFX_BidiChar
- Replace IFX_BidiChar with just CFX_BidiChar - Document implementation - Change out parameters to pointers - Remove dead code - Add an enum for bidi directions - Move several externs to a header - Add unit tests Original CL: https://codereview.chromium.org/1197643002 This version does not remove fx_arb.h and fx_arabic.h, as there is code on the XFA branch that still uses parts of it. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1423103002 .
Diffstat (limited to 'core/src/fpdftext')
-rw-r--r--core/src/fpdftext/fpdf_text.cpp16
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp36
-rw-r--r--core/src/fpdftext/text_int.h2
3 files changed, 27 insertions, 27 deletions
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 2bd8b7d6ce..9ecbc21bda 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -9,7 +9,7 @@
#include "../../include/fpdfapi/fpdf_pageobj.h"
#include "../../include/fpdfapi/fpdf_resource.h"
#include "../../include/fpdftext/fpdf_text.h"
-#include "../../include/fxcrt/fx_arb.h"
+#include "../../include/fxcrt/fx_bidi.h"
#include "../../include/fxcrt/fx_ucd.h"
#include "text_int.h"
#include "txtproc.h"
@@ -315,35 +315,35 @@ void NormalizeString(CFX_WideString& str) {
return;
}
CFX_WideString sBuffer;
- nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create());
+ nonstd::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar);
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 (pBidiChar->AppendChar(str.GetAt(i))) {
- int32_t ret = pBidiChar->GetBidiInfo(start, count);
+ CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
order.Add(start);
order.Add(count);
order.Add(ret);
if (!bR2L) {
- if (ret == 2) {
+ if (ret == CFX_BidiChar::RIGHT) {
nR2L++;
- } else if (ret == 1) {
+ } else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
}
}
}
}
if (pBidiChar->EndChar()) {
- int32_t ret = pBidiChar->GetBidiInfo(start, count);
+ CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
order.Add(start);
order.Add(count);
order.Add(ret);
if (!bR2L) {
- if (ret == 2) {
+ if (ret == CFX_BidiChar::RIGHT) {
nR2L++;
- } else if (ret == 1) {
+ } else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
}
}
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index aa25728c15..202fab45fa 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -13,7 +13,7 @@
#include "../../include/fpdfapi/fpdf_pageobj.h"
#include "../../include/fpdfapi/fpdf_resource.h"
#include "../../include/fpdftext/fpdf_text.h"
-#include "../../include/fxcrt/fx_arb.h"
+#include "../../include/fxcrt/fx_bidi.h"
#include "../../include/fxcrt/fx_ucd.h"
#include "text_int.h"
@@ -1001,10 +1001,10 @@ int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const {
}
return w;
}
-void CPDF_TextPage::OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str) {
+void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) {
int32_t start, count;
- int32_t ret = pBidi->GetBidiInfo(start, count);
- if (ret == 2) {
+ CFX_BidiChar::Direction ret = pBidi->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
for (int i = start + count - 1; i >= start; i--) {
m_TextBuf.AppendChar(str.GetAt(i));
m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i));
@@ -1085,7 +1085,7 @@ void CPDF_TextPage::CloseTempLine() {
if (count1 <= 0) {
return;
}
- nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create());
+ nonstd::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar);
CFX_WideString str = m_TempTextBuf.GetWideString();
CFX_WordArray order;
FX_BOOL bR2L = FALSE;
@@ -1107,28 +1107,28 @@ void CPDF_TextPage::CloseTempLine() {
bPrevSpace = FALSE;
}
if (pBidiChar->AppendChar(str.GetAt(i))) {
- int32_t ret = pBidiChar->GetBidiInfo(start, count);
+ CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
order.Add(start);
order.Add(count);
order.Add(ret);
if (!bR2L) {
- if (ret == 2) {
+ if (ret == CFX_BidiChar::RIGHT) {
nR2L++;
- } else if (ret == 1) {
+ } else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
}
}
}
}
if (pBidiChar->EndChar()) {
- int32_t ret = pBidiChar->GetBidiInfo(start, count);
+ CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
order.Add(start);
order.Add(count);
order.Add(ret);
if (!bR2L) {
- if (ret == 2) {
+ if (ret == CFX_BidiChar::RIGHT) {
nR2L++;
- } else if (ret == 1) {
+ } else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
}
}
@@ -1560,7 +1560,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix);
FX_BOOL bIsBidiAndMirrosInverse = FALSE;
- IFX_BidiChar* BidiChar = IFX_BidiChar::Create();
+ CFX_BidiChar* BidiChar = new CFX_BidiChar;
int32_t nR2L = 0;
int32_t nL2R = 0;
int32_t start = 0, count = 0;
@@ -1579,19 +1579,19 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
continue;
}
if (BidiChar && BidiChar->AppendChar(wChar)) {
- int32_t ret = BidiChar->GetBidiInfo(start, count);
- if (ret == 2) {
+ CFX_BidiChar::Direction ret = BidiChar->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
nR2L++;
- } else if (ret == 1) {
+ } else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
}
}
}
if (BidiChar && BidiChar->EndChar()) {
- int32_t ret = BidiChar->GetBidiInfo(start, count);
- if (ret == 2) {
+ CFX_BidiChar::Direction ret = BidiChar->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
nR2L++;
- } else if (ret == 1) {
+ } else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
}
}
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index b5a7734e54..d10c5501e6 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -119,7 +119,7 @@ class CPDF_TextPage : public IPDF_TextPage {
CPDF_TextObject* pTextObj2);
int GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const;
void CloseTempLine();
- void OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str);
+ void OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str);
int32_t PreMarkedContent(PDFTEXT_Obj pObj);
void ProcessMarkedContent(PDFTEXT_Obj pObj);
void CheckMarkedContentObject(int32_t& start, int32_t& nCount) const;