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

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

Issue 1477663003: Manual fixups to PDF_ENABLE_XFA in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Consolidate 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
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 #ifndef PDF_ENABLE_XFA
Lei Zhang 2015/11/25 21:49:01 Can we flip these to #ifdef PDF_ENABLE_XFA instead
Tom Sepez 2015/11/25 22:05:07 I made a new version of this file by importing the
1529 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); 1529 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems);
1530 const FX_BOOL bIsBidiAndMirrorInverse = 1530 const FX_BOOL bIsBidiAndMirrorInverse =
1531 #else 1531 #else // PDF_ENABLE_XFA
1532 FX_BOOL bIsBidiAndMirrosInverse = FALSE; 1532 FX_BOOL bIsBidiAndMirrosInverse = FALSE;
1533 CFX_BidiChar* BidiChar = new CFX_BidiChar; 1533 CFX_BidiChar* BidiChar = new CFX_BidiChar;
1534 int32_t nR2L = 0; 1534 int32_t nR2L = 0;
1535 int32_t nL2R = 0; 1535 int32_t nL2R = 0;
1536 int32_t start = 0, count = 0; 1536 int32_t start = 0, count = 0;
1537 CPDF_TextObjectItem item; 1537 CPDF_TextObjectItem item;
1538 for (int32_t i = 0; i < nItems; i++) { 1538 for (int32_t i = 0; i < nItems; i++) {
1539 pTextObj->GetItemInfo(i, &item); 1539 pTextObj->GetItemInfo(i, &item);
1540 if (item.m_CharCode == (FX_DWORD)-1) { 1540 if (item.m_CharCode == (FX_DWORD)-1) {
1541 continue; 1541 continue;
(...skipping 21 matching lines...) Expand all
1563 nR2L++; 1563 nR2L++;
1564 } else if (ret == CFX_BidiChar::LEFT) { 1564 } else if (ret == CFX_BidiChar::LEFT) {
1565 nL2R++; 1565 nL2R++;
1566 } 1566 }
1567 } 1567 }
1568 FX_BOOL bR2L = FALSE; 1568 FX_BOOL bR2L = FALSE;
1569 if (nR2L > 0 && nR2L >= nL2R) { 1569 if (nR2L > 0 && nR2L >= nL2R) {
1570 bR2L = TRUE; 1570 bR2L = TRUE;
1571 } 1571 }
1572 bIsBidiAndMirrosInverse = 1572 bIsBidiAndMirrosInverse =
1573 #endif 1573 #endif // PDF_ENABLE_XFA
1574 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; 1574 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0;
1575 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); 1575 int32_t iBufStartAppend = m_TempTextBuf.GetLength();
1576 int32_t iCharListStartAppend = m_TempCharList.GetSize(); 1576 int32_t iCharListStartAppend = m_TempCharList.GetSize();
1577 1577
1578 FX_FLOAT spacing = 0; 1578 FX_FLOAT spacing = 0;
1579 for (int i = 0; i < nItems; i++) { 1579 for (int i = 0; i < nItems; i++) {
1580 CPDF_TextObjectItem item; 1580 CPDF_TextObjectItem item;
1581 PAGECHAR_INFO charinfo; 1581 PAGECHAR_INFO charinfo;
1582 charinfo.m_OriginX = 0; 1582 charinfo.m_OriginX = 0;
1583 charinfo.m_OriginY = 0; 1583 charinfo.m_OriginY = 0;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { 1768 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
1769 wChar = (FX_WCHAR)item.m_CharCode; 1769 wChar = (FX_WCHAR)item.m_CharCode;
1770 #else 1770 #else
1771 if (bIsBidiAndMirrosInverse) { 1771 if (bIsBidiAndMirrosInverse) {
1772 int32_t i, j; 1772 int32_t i, j;
1773 i = iCharListStartAppend; 1773 i = iCharListStartAppend;
1774 j = m_TempCharList.GetSize() - 1; 1774 j = m_TempCharList.GetSize() - 1;
1775 for (; i < j; i++, j--) { 1775 for (; i < j; i++, j--) {
1776 std::swap(m_TempCharList[i], m_TempCharList[j]); 1776 std::swap(m_TempCharList[i], m_TempCharList[j]);
1777 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); 1777 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index);
1778 #endif 1778 #endif // PDF_ENABLE_XFA
1779 } 1779 }
1780 #ifndef PDF_ENABLE_XFA 1780 #ifndef PDF_ENABLE_XFA
1781 if (!wChar) { 1781 if (!wChar) {
1782 continue; 1782 continue;
1783 } 1783 }
1784 if (pBidiChar->AppendChar(wChar)) { 1784 if (pBidiChar->AppendChar(wChar)) {
1785 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count); 1785 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1786 if (ret == CFX_BidiChar::RIGHT) { 1786 if (ret == CFX_BidiChar::RIGHT) {
1787 nR2L++; 1787 nR2L++;
1788 } else if (ret == CFX_BidiChar::LEFT) { 1788 } else if (ret == CFX_BidiChar::LEFT) {
1789 nL2R++; 1789 nL2R++;
1790 } 1790 }
1791 } 1791 }
1792 } 1792 }
1793 if (pBidiChar->EndChar()) { 1793 if (pBidiChar->EndChar()) {
1794 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count); 1794 CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count);
1795 if (ret == CFX_BidiChar::RIGHT) { 1795 if (ret == CFX_BidiChar::RIGHT) {
1796 nR2L++; 1796 nR2L++;
1797 } else if (ret == CFX_BidiChar::LEFT) { 1797 } else if (ret == CFX_BidiChar::LEFT) {
1798 nL2R++; 1798 nL2R++;
1799 #else 1799 #else
1800 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer(); 1800 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
1801 i = iBufStartAppend; 1801 i = iBufStartAppend;
1802 j = m_TempTextBuf.GetLength() - 1; 1802 j = m_TempTextBuf.GetLength() - 1;
1803 for (; i < j; i++, j--) { 1803 for (; i < j; i++, j--) {
1804 std::swap(pTempBuffer[i], pTempBuffer[j]); 1804 std::swap(pTempBuffer[i], pTempBuffer[j]);
1805 #endif 1805 #endif // PDF_ENABLE_XFA
1806 } 1806 }
1807 } 1807 }
1808 #ifndef PDF_ENABLE_XFA 1808 #ifndef PDF_ENABLE_XFA
1809 return (nR2L > 0 && nR2L >= nL2R); 1809 return (nR2L > 0 && nR2L >= nL2R);
1810 #endif 1810 #endif // PDF_ENABLE_XFA
1811 } 1811 }
1812 int32_t CPDF_TextPage::GetTextObjectWritingMode( 1812 int32_t CPDF_TextPage::GetTextObjectWritingMode(
1813 const CPDF_TextObject* pTextObj) { 1813 const CPDF_TextObject* pTextObj) {
1814 int32_t nChars = pTextObj->CountChars(); 1814 int32_t nChars = pTextObj->CountChars();
1815 if (nChars == 1) { 1815 if (nChars == 1) {
1816 return m_TextlineDir; 1816 return m_TextlineDir;
1817 } 1817 }
1818 CPDF_TextObjectItem first, last; 1818 CPDF_TextObjectItem first, last;
1819 pTextObj->GetCharInfo(0, &first); 1819 pTextObj->GetCharInfo(0, &first);
1820 pTextObj->GetCharInfo(nChars - 1, &last); 1820 pTextObj->GetCharInfo(nChars - 1, &last);
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2790 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2791 return; 2791 return;
2792 } 2792 }
2793 CPDF_LinkExt* link = NULL; 2793 CPDF_LinkExt* link = NULL;
2794 link = m_LinkList.GetAt(index); 2794 link = m_LinkList.GetAt(index);
2795 if (!link) { 2795 if (!link) {
2796 return; 2796 return;
2797 } 2797 }
2798 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2798 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2799 } 2799 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698