summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp112
1 files changed, 56 insertions, 56 deletions
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 4ed11e3986..ee768af3bc 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -1421,6 +1421,62 @@ void CPDF_TextPage::FindPreviousTextObject(void) {
m_pPreTextObj = preChar.m_pTextObj;
}
}
+void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
+ int32_t iBufStartAppend) {
+ 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);
+ }
+ FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
+ i = iBufStartAppend;
+ j = m_TempTextBuf.GetLength() - 1;
+ for (; i < j; i++, j--) {
+ std::swap(pTempBuffer[i], pTempBuffer[j]);
+ }
+}
+FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
+ const CPDF_Font* pFont,
+ int nItems) const {
+ nonstd::unique_ptr<CFX_BidiChar> pBidiChar(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 (pBidiChar->AppendChar(wChar)) {
+ CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
+ nR2L++;
+ } else if (ret == CFX_BidiChar::LEFT) {
+ nL2R++;
+ }
+ }
+ }
+ if (pBidiChar->EndChar()) {
+ CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
+ if (ret == CFX_BidiChar::RIGHT) {
+ nR2L++;
+ } else if (ret == CFX_BidiChar::LEFT) {
+ nL2R++;
+ }
+ }
+ return (nR2L > 0 && nR2L >= nL2R);
+}
void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
CPDF_TextObject* pTextObj = Obj.m_pTextObj;
if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) {
@@ -1689,62 +1745,6 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
SwapTempTextBuf(iCharListStartAppend, iBufStartAppend);
}
}
-void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
- int32_t iBufStartAppend) {
- 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);
- }
- FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
- i = iBufStartAppend;
- j = m_TempTextBuf.GetLength() - 1;
- for (; i < j; i++, j--) {
- std::swap(pTempBuffer[i], pTempBuffer[j]);
- }
-}
-FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
- const CPDF_Font* pFont,
- int nItems) const {
- nonstd::unique_ptr<CFX_BidiChar> pBidiChar(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 (pBidiChar->AppendChar(wChar)) {
- CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
- if (ret == CFX_BidiChar::RIGHT) {
- nR2L++;
- } else if (ret == CFX_BidiChar::LEFT) {
- nL2R++;
- }
- }
- }
- if (pBidiChar->EndChar()) {
- CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
- if (ret == CFX_BidiChar::RIGHT) {
- nR2L++;
- } else if (ret == CFX_BidiChar::LEFT) {
- nL2R++;
- }
- }
- return (nR2L > 0 && nR2L >= nL2R);
-}
int32_t CPDF_TextPage::GetTextObjectWritingMode(
const CPDF_TextObject* pTextObj) {
int32_t nChars = pTextObj->CountChars();