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

Side by Side Diff: core/src/fpdftext/fpdf_text_int.cpp

Issue 1477433006: Re-order methods to make xfa diff saner (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <cctype> 7 #include <cctype>
8 #include <cwctype> 8 #include <cwctype>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 if (m_TempCharList.GetSize() >= 1) { 1414 if (m_TempCharList.GetSize() >= 1) {
1415 preChar = 1415 preChar =
1416 *(PAGECHAR_INFO*)m_TempCharList.GetAt(m_TempCharList.GetSize() - 1); 1416 *(PAGECHAR_INFO*)m_TempCharList.GetAt(m_TempCharList.GetSize() - 1);
1417 } else { 1417 } else {
1418 preChar = *(PAGECHAR_INFO*)m_charList.GetAt(m_charList.GetSize() - 1); 1418 preChar = *(PAGECHAR_INFO*)m_charList.GetAt(m_charList.GetSize() - 1);
1419 } 1419 }
1420 if (preChar.m_pTextObj) { 1420 if (preChar.m_pTextObj) {
1421 m_pPreTextObj = preChar.m_pTextObj; 1421 m_pPreTextObj = preChar.m_pTextObj;
1422 } 1422 }
1423 } 1423 }
1424 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
1425 int32_t iBufStartAppend) {
1426 int32_t i, j;
1427 i = iCharListStartAppend;
1428 j = m_TempCharList.GetSize() - 1;
1429 for (; i < j; i++, j--) {
1430 std::swap(m_TempCharList[i], m_TempCharList[j]);
1431 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index);
1432 }
1433 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
1434 i = iBufStartAppend;
1435 j = m_TempTextBuf.GetLength() - 1;
1436 for (; i < j; i++, j--) {
1437 std::swap(pTempBuffer[i], pTempBuffer[j]);
1438 }
1439 }
1440 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
1441 const CPDF_Font* pFont,
1442 int nItems) const {
1443 nonstd::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar);
1444 int32_t nR2L = 0;
1445 int32_t nL2R = 0;
1446 int32_t start = 0, count = 0;
1447 CPDF_TextObjectItem item;
1448 for (int32_t i = 0; i < nItems; i++) {
1449 pTextObj->GetItemInfo(i, &item);
1450 if (item.m_CharCode == (FX_DWORD)-1) {
1451 continue;
1452 }
1453 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
1454 FX_WCHAR wChar = wstrItem.GetAt(0);
1455 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
1456 wChar = (FX_WCHAR)item.m_CharCode;
1457 }
1458 if (!wChar) {
1459 continue;
1460 }
1461 if (pBidiChar->AppendChar(wChar)) {
1462 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1463 if (ret == CFX_BidiChar::RIGHT) {
1464 nR2L++;
1465 } else if (ret == CFX_BidiChar::LEFT) {
1466 nL2R++;
1467 }
1468 }
1469 }
1470 if (pBidiChar->EndChar()) {
1471 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1472 if (ret == CFX_BidiChar::RIGHT) {
1473 nR2L++;
1474 } else if (ret == CFX_BidiChar::LEFT) {
1475 nL2R++;
1476 }
1477 }
1478 return (nR2L > 0 && nR2L >= nL2R);
1479 }
1424 void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { 1480 void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
1425 CPDF_TextObject* pTextObj = Obj.m_pTextObj; 1481 CPDF_TextObject* pTextObj = Obj.m_pTextObj;
1426 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) { 1482 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) {
1427 return; 1483 return;
1428 } 1484 }
1429 CFX_AffineMatrix formMatrix = Obj.m_formMatrix; 1485 CFX_AffineMatrix formMatrix = Obj.m_formMatrix;
1430 CPDF_Font* pFont = pTextObj->GetFont(); 1486 CPDF_Font* pFont = pTextObj->GetFont();
1431 CFX_AffineMatrix matrix; 1487 CFX_AffineMatrix matrix;
1432 pTextObj->GetTextMatrix(&matrix); 1488 pTextObj->GetTextMatrix(&matrix);
1433 matrix.Concat(formMatrix); 1489 matrix.Concat(formMatrix);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); 1738 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
1683 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); 1739 m_TempCharList.Delete(m_TempCharList.GetSize() - 1);
1684 } 1740 }
1685 } 1741 }
1686 } 1742 }
1687 } 1743 }
1688 if (bIsBidiAndMirrorInverse) { 1744 if (bIsBidiAndMirrorInverse) {
1689 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend); 1745 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend);
1690 } 1746 }
1691 } 1747 }
1692 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
1693 int32_t iBufStartAppend) {
1694 int32_t i, j;
1695 i = iCharListStartAppend;
1696 j = m_TempCharList.GetSize() - 1;
1697 for (; i < j; i++, j--) {
1698 std::swap(m_TempCharList[i], m_TempCharList[j]);
1699 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index);
1700 }
1701 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
1702 i = iBufStartAppend;
1703 j = m_TempTextBuf.GetLength() - 1;
1704 for (; i < j; i++, j--) {
1705 std::swap(pTempBuffer[i], pTempBuffer[j]);
1706 }
1707 }
1708 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
1709 const CPDF_Font* pFont,
1710 int nItems) const {
1711 nonstd::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar);
1712 int32_t nR2L = 0;
1713 int32_t nL2R = 0;
1714 int32_t start = 0, count = 0;
1715 CPDF_TextObjectItem item;
1716 for (int32_t i = 0; i < nItems; i++) {
1717 pTextObj->GetItemInfo(i, &item);
1718 if (item.m_CharCode == (FX_DWORD)-1) {
1719 continue;
1720 }
1721 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
1722 FX_WCHAR wChar = wstrItem.GetAt(0);
1723 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
1724 wChar = (FX_WCHAR)item.m_CharCode;
1725 }
1726 if (!wChar) {
1727 continue;
1728 }
1729 if (pBidiChar->AppendChar(wChar)) {
1730 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1731 if (ret == CFX_BidiChar::RIGHT) {
1732 nR2L++;
1733 } else if (ret == CFX_BidiChar::LEFT) {
1734 nL2R++;
1735 }
1736 }
1737 }
1738 if (pBidiChar->EndChar()) {
1739 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1740 if (ret == CFX_BidiChar::RIGHT) {
1741 nR2L++;
1742 } else if (ret == CFX_BidiChar::LEFT) {
1743 nL2R++;
1744 }
1745 }
1746 return (nR2L > 0 && nR2L >= nL2R);
1747 }
1748 int32_t CPDF_TextPage::GetTextObjectWritingMode( 1748 int32_t CPDF_TextPage::GetTextObjectWritingMode(
1749 const CPDF_TextObject* pTextObj) { 1749 const CPDF_TextObject* pTextObj) {
1750 int32_t nChars = pTextObj->CountChars(); 1750 int32_t nChars = pTextObj->CountChars();
1751 if (nChars == 1) { 1751 if (nChars == 1) {
1752 return m_TextlineDir; 1752 return m_TextlineDir;
1753 } 1753 }
1754 CPDF_TextObjectItem first, last; 1754 CPDF_TextObjectItem first, last;
1755 pTextObj->GetCharInfo(0, &first); 1755 pTextObj->GetCharInfo(0, &first);
1756 pTextObj->GetCharInfo(nChars - 1, &last); 1756 pTextObj->GetCharInfo(nChars - 1, &last);
1757 CFX_Matrix textMatrix; 1757 CFX_Matrix textMatrix;
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2727 return; 2727 return;
2728 } 2728 }
2729 CPDF_LinkExt* link = NULL; 2729 CPDF_LinkExt* link = NULL;
2730 link = m_LinkList.GetAt(index); 2730 link = m_LinkList.GetAt(index);
2731 if (!link) { 2731 if (!link) {
2732 return; 2732 return;
2733 } 2733 }
2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2735 } 2735 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698