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

Side by Side 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 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 | « core/src/fpdfdoc/doc_formfield.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | 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 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 ProcessMarkedContent(Obj); 1518 ProcessMarkedContent(Obj);
1519 m_pPreTextObj = pTextObj; 1519 m_pPreTextObj = pTextObj;
1520 m_perMatrix.Copy(formMatrix); 1520 m_perMatrix.Copy(formMatrix);
1521 return; 1521 return;
1522 } 1522 }
1523 m_pPreTextObj = pTextObj; 1523 m_pPreTextObj = pTextObj;
1524 m_perMatrix.Copy(formMatrix); 1524 m_perMatrix.Copy(formMatrix);
1525 int nItems = pTextObj->CountItems(); 1525 int nItems = pTextObj->CountItems();
1526 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); 1526 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix);
1527 1527
1528 #ifndef PDF_ENABLE_XFA
1528 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); 1529 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems);
1529 const FX_BOOL bIsBidiAndMirrorInverse = 1530 const FX_BOOL bIsBidiAndMirrorInverse =
1531 #else
1532 FX_BOOL bIsBidiAndMirrosInverse = FALSE;
1533 CFX_BidiChar* BidiChar = new CFX_BidiChar;
1534 int32_t nR2L = 0;
1535 int32_t nL2R = 0;
1536 int32_t start = 0, count = 0;
1537 CPDF_TextObjectItem item;
1538 for (int32_t i = 0; i < nItems; i++) {
1539 pTextObj->GetItemInfo(i, &item);
1540 if (item.m_CharCode == (FX_DWORD)-1) {
1541 continue;
1542 }
1543 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
1544 FX_WCHAR wChar = wstrItem.GetAt(0);
1545 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
1546 wChar = (FX_WCHAR)item.m_CharCode;
1547 }
1548 if (!wChar) {
1549 continue;
1550 }
1551 if (BidiChar && BidiChar->AppendChar(wChar)) {
1552 CFX_BidiChar::Direction ret = BidiChar->GetBidiInfo(&start, &count);
1553 if (ret == CFX_BidiChar::RIGHT) {
1554 nR2L++;
1555 } else if (ret == CFX_BidiChar::LEFT) {
1556 nL2R++;
1557 }
1558 }
1559 }
1560 if (BidiChar && BidiChar->EndChar()) {
1561 CFX_BidiChar::Direction ret = BidiChar->GetBidiInfo(&start, &count);
1562 if (ret == CFX_BidiChar::RIGHT) {
1563 nR2L++;
1564 } else if (ret == CFX_BidiChar::LEFT) {
1565 nL2R++;
1566 }
1567 }
1568 FX_BOOL bR2L = FALSE;
1569 if (nR2L > 0 && nR2L >= nL2R) {
1570 bR2L = TRUE;
1571 }
1572 bIsBidiAndMirrosInverse =
1573 #endif
1530 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; 1574 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0;
1531 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); 1575 int32_t iBufStartAppend = m_TempTextBuf.GetLength();
1532 int32_t iCharListStartAppend = m_TempCharList.GetSize(); 1576 int32_t iCharListStartAppend = m_TempCharList.GetSize();
1533 1577
1534 FX_FLOAT spacing = 0; 1578 FX_FLOAT spacing = 0;
1535 for (int i = 0; i < nItems; i++) { 1579 for (int i = 0; i < nItems; i++) {
1536 CPDF_TextObjectItem item; 1580 CPDF_TextObjectItem item;
1537 PAGECHAR_INFO charinfo; 1581 PAGECHAR_INFO charinfo;
1538 charinfo.m_OriginX = 0; 1582 charinfo.m_OriginX = 0;
1539 charinfo.m_OriginY = 0; 1583 charinfo.m_OriginY = 0;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 } else if (i == 0) { 1722 } else if (i == 0) {
1679 CFX_WideString str = m_TempTextBuf.GetWideString(); 1723 CFX_WideString str = m_TempTextBuf.GetWideString();
1680 if (!str.IsEmpty() && 1724 if (!str.IsEmpty() &&
1681 str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) { 1725 str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) {
1682 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); 1726 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
1683 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); 1727 m_TempCharList.Delete(m_TempCharList.GetSize() - 1);
1684 } 1728 }
1685 } 1729 }
1686 } 1730 }
1687 } 1731 }
1732 #ifndef PDF_ENABLE_XFA
1688 if (bIsBidiAndMirrorInverse) { 1733 if (bIsBidiAndMirrorInverse) {
1689 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend); 1734 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend);
1690 } 1735 }
1691 } 1736 }
1692 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, 1737 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
1693 int32_t iBufStartAppend) { 1738 int32_t iBufStartAppend) {
1694 int32_t i, j; 1739 int32_t i, j;
1695 i = iCharListStartAppend; 1740 i = iCharListStartAppend;
1696 j = m_TempCharList.GetSize() - 1; 1741 j = m_TempCharList.GetSize() - 1;
1697 for (; i < j; i++, j--) { 1742 for (; i < j; i++, j--) {
(...skipping 17 matching lines...) Expand all
1715 CPDF_TextObjectItem item; 1760 CPDF_TextObjectItem item;
1716 for (int32_t i = 0; i < nItems; i++) { 1761 for (int32_t i = 0; i < nItems; i++) {
1717 pTextObj->GetItemInfo(i, &item); 1762 pTextObj->GetItemInfo(i, &item);
1718 if (item.m_CharCode == (FX_DWORD)-1) { 1763 if (item.m_CharCode == (FX_DWORD)-1) {
1719 continue; 1764 continue;
1720 } 1765 }
1721 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); 1766 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
1722 FX_WCHAR wChar = wstrItem.GetAt(0); 1767 FX_WCHAR wChar = wstrItem.GetAt(0);
1723 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { 1768 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
1724 wChar = (FX_WCHAR)item.m_CharCode; 1769 wChar = (FX_WCHAR)item.m_CharCode;
1770 #else
1771 if (bIsBidiAndMirrosInverse) {
1772 int32_t i, j;
1773 i = iCharListStartAppend;
1774 j = m_TempCharList.GetSize() - 1;
1775 for (; i < j; i++, j--) {
1776 std::swap(m_TempCharList[i], m_TempCharList[j]);
1777 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index);
1778 #endif
1725 } 1779 }
1780 #ifndef PDF_ENABLE_XFA
1726 if (!wChar) { 1781 if (!wChar) {
1727 continue; 1782 continue;
1728 } 1783 }
1729 if (pBidiChar->AppendChar(wChar)) { 1784 if (pBidiChar->AppendChar(wChar)) {
1730 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count); 1785 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1731 if (ret == CFX_BidiChar::RIGHT) { 1786 if (ret == CFX_BidiChar::RIGHT) {
1732 nR2L++; 1787 nR2L++;
1733 } else if (ret == CFX_BidiChar::LEFT) { 1788 } else if (ret == CFX_BidiChar::LEFT) {
1734 nL2R++; 1789 nL2R++;
1735 } 1790 }
1736 } 1791 }
1737 } 1792 }
1738 if (pBidiChar->EndChar()) { 1793 if (pBidiChar->EndChar()) {
1739 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count); 1794 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1740 if (ret == CFX_BidiChar::RIGHT) { 1795 if (ret == CFX_BidiChar::RIGHT) {
1741 nR2L++; 1796 nR2L++;
1742 } else if (ret == CFX_BidiChar::LEFT) { 1797 } else if (ret == CFX_BidiChar::LEFT) {
1743 nL2R++; 1798 nL2R++;
1799 #else
1800 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
1801 i = iBufStartAppend;
1802 j = m_TempTextBuf.GetLength() - 1;
1803 for (; i < j; i++, j--) {
1804 std::swap(pTempBuffer[i], pTempBuffer[j]);
1805 #endif
1744 } 1806 }
1745 } 1807 }
1808 #ifndef PDF_ENABLE_XFA
1746 return (nR2L > 0 && nR2L >= nL2R); 1809 return (nR2L > 0 && nR2L >= nL2R);
1810 #endif
1747 } 1811 }
1748 int32_t CPDF_TextPage::GetTextObjectWritingMode( 1812 int32_t CPDF_TextPage::GetTextObjectWritingMode(
1749 const CPDF_TextObject* pTextObj) { 1813 const CPDF_TextObject* pTextObj) {
1750 int32_t nChars = pTextObj->CountChars(); 1814 int32_t nChars = pTextObj->CountChars();
1751 if (nChars == 1) { 1815 if (nChars == 1) {
1752 return m_TextlineDir; 1816 return m_TextlineDir;
1753 } 1817 }
1754 CPDF_TextObjectItem first, last; 1818 CPDF_TextObjectItem first, last;
1755 pTextObj->GetCharInfo(0, &first); 1819 pTextObj->GetCharInfo(0, &first);
1756 pTextObj->GetCharInfo(nChars - 1, &last); 1820 pTextObj->GetCharInfo(nChars - 1, &last);
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2790 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2727 return; 2791 return;
2728 } 2792 }
2729 CPDF_LinkExt* link = NULL; 2793 CPDF_LinkExt* link = NULL;
2730 link = m_LinkList.GetAt(index); 2794 link = m_LinkList.GetAt(index);
2731 if (!link) { 2795 if (!link) {
2732 return; 2796 return;
2733 } 2797 }
2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2798 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2735 } 2799 }
OLDNEW
« 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