Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1339)

Unified Diff: core/src/fpdftext/fpdf_text_int.cpp

Issue 1398383002: core/ difference with XFA (for information only). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 2015-11-24 version Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_formfield.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdftext/fpdf_text_int.cpp
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 4ed11e3986cb757183939f4947f873a6176833cf..c69ffc8ee831cd0c5de256082a8562ece5b577c4 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -1525,8 +1525,52 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
int nItems = pTextObj->CountItems();
FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix);
+#ifndef PDF_ENABLE_XFA
const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems);
const FX_BOOL bIsBidiAndMirrorInverse =
+#else
+ FX_BOOL bIsBidiAndMirrosInverse = FALSE;
+ CFX_BidiChar* BidiChar = new CFX_BidiChar;
+ int32_t nR2L = 0;
+ int32_t nL2R = 0;
+ int32_t start = 0, count = 0;
+ CPDF_TextObjectItem item;
+ for (int32_t i = 0; i < nItems; i++) {
+ pTextObj->GetItemInfo(i, &item);
+ if (item.m_CharCode == (FX_DWORD)-1) {
+ continue;
+ }
+ CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
+ FX_WCHAR wChar = wstrItem.GetAt(0);
+ if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
+ wChar = (FX_WCHAR)item.m_CharCode;
+ }
+ if (!wChar) {
+ continue;
+ }
+ if (BidiChar && BidiChar->AppendChar(wChar)) {
+ CFX_BidiChar::Direction ret = BidiChar->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
+ nR2L++;
+ } else if (ret == CFX_BidiChar::LEFT) {
+ nL2R++;
+ }
+ }
+ }
+ if (BidiChar && BidiChar->EndChar()) {
+ CFX_BidiChar::Direction ret = BidiChar->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
+ nR2L++;
+ } else if (ret == CFX_BidiChar::LEFT) {
+ nL2R++;
+ }
+ }
+ FX_BOOL bR2L = FALSE;
+ if (nR2L > 0 && nR2L >= nL2R) {
+ bR2L = TRUE;
+ }
+ bIsBidiAndMirrosInverse =
+#endif
bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0;
int32_t iBufStartAppend = m_TempTextBuf.GetLength();
int32_t iCharListStartAppend = m_TempCharList.GetSize();
@@ -1685,6 +1729,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
}
}
}
+#ifndef PDF_ENABLE_XFA
if (bIsBidiAndMirrorInverse) {
SwapTempTextBuf(iCharListStartAppend, iBufStartAppend);
}
@@ -1722,7 +1767,17 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
FX_WCHAR wChar = wstrItem.GetAt(0);
if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
wChar = (FX_WCHAR)item.m_CharCode;
- }
+#else
+ if (bIsBidiAndMirrosInverse) {
+ int32_t i, j;
+ i = iCharListStartAppend;
+ j = m_TempCharList.GetSize() - 1;
+ for (; i < j; i++, j--) {
+ std::swap(m_TempCharList[i], m_TempCharList[j]);
+ std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index);
+#endif
+ }
+#ifndef PDF_ENABLE_XFA
if (!wChar) {
continue;
}
@@ -1741,9 +1796,18 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
nR2L++;
} else if (ret == CFX_BidiChar::LEFT) {
nL2R++;
+#else
+ FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
+ i = iBufStartAppend;
+ j = m_TempTextBuf.GetLength() - 1;
+ for (; i < j; i++, j--) {
+ std::swap(pTempBuffer[i], pTempBuffer[j]);
+#endif
}
}
+#ifndef PDF_ENABLE_XFA
return (nR2L > 0 && nR2L >= nL2R);
+#endif
}
int32_t CPDF_TextPage::GetTextObjectWritingMode(
const CPDF_TextObject* pTextObj) {
« no previous file with comments | « core/src/fpdfdoc/doc_formfield.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698