| OLD | NEW |
| 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 <algorithm> |
| 7 #include <cctype> | 8 #include <cctype> |
| 8 #include <cwctype> | 9 #include <cwctype> |
| 9 #include <algorithm> | 10 #include <memory> |
| 10 | 11 |
| 11 #include "core/include/fpdfapi/fpdf_module.h" | 12 #include "core/include/fpdfapi/fpdf_module.h" |
| 12 #include "core/include/fpdfapi/fpdf_page.h" | 13 #include "core/include/fpdfapi/fpdf_page.h" |
| 13 #include "core/include/fpdfapi/fpdf_pageobj.h" | 14 #include "core/include/fpdfapi/fpdf_pageobj.h" |
| 14 #include "core/include/fpdfapi/fpdf_resource.h" | 15 #include "core/include/fpdfapi/fpdf_resource.h" |
| 15 #include "core/include/fpdftext/fpdf_text.h" | 16 #include "core/include/fpdftext/fpdf_text.h" |
| 16 #include "core/include/fxcrt/fx_bidi.h" | 17 #include "core/include/fxcrt/fx_bidi.h" |
| 17 #include "core/include/fxcrt/fx_ext.h" | 18 #include "core/include/fxcrt/fx_ext.h" |
| 18 #include "core/include/fxcrt/fx_ucd.h" | 19 #include "core/include/fxcrt/fx_ucd.h" |
| 19 #include "text_int.h" | 20 #include "text_int.h" |
| 20 #include "third_party/base/nonstd_unique_ptr.h" | |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 FX_BOOL _IsIgnoreSpaceCharacter(FX_WCHAR curChar) { | 24 FX_BOOL _IsIgnoreSpaceCharacter(FX_WCHAR curChar) { |
| 25 if (curChar < 255) { | 25 if (curChar < 255) { |
| 26 return FALSE; | 26 return FALSE; |
| 27 } | 27 } |
| 28 if ((curChar >= 0x0600 && curChar <= 0x06FF) || | 28 if ((curChar >= 0x0600 && curChar <= 0x06FF) || |
| 29 (curChar >= 0xFE70 && curChar <= 0xFEFF) || | 29 (curChar >= 0xFE70 && curChar <= 0xFEFF) || |
| 30 (curChar >= 0xFB50 && curChar <= 0xFDFF) || | 30 (curChar >= 0xFB50 && curChar <= 0xFDFF) || |
| (...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 } | 1046 } |
| 1047 if (!m_ParseOptions.m_bGetCharCodeOnly) { | 1047 if (!m_ParseOptions.m_bGetCharCodeOnly) { |
| 1048 m_charList.Add(Info); | 1048 m_charList.Add(Info); |
| 1049 } | 1049 } |
| 1050 } | 1050 } |
| 1051 void CPDF_TextPage::CloseTempLine() { | 1051 void CPDF_TextPage::CloseTempLine() { |
| 1052 int count1 = m_TempCharList.GetSize(); | 1052 int count1 = m_TempCharList.GetSize(); |
| 1053 if (count1 <= 0) { | 1053 if (count1 <= 0) { |
| 1054 return; | 1054 return; |
| 1055 } | 1055 } |
| 1056 nonstd::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar); | 1056 std::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar); |
| 1057 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1057 CFX_WideString str = m_TempTextBuf.GetWideString(); |
| 1058 CFX_WordArray order; | 1058 CFX_WordArray order; |
| 1059 FX_BOOL bR2L = FALSE; | 1059 FX_BOOL bR2L = FALSE; |
| 1060 int32_t start = 0, count = 0; | 1060 int32_t start = 0, count = 0; |
| 1061 int nR2L = 0, nL2R = 0; | 1061 int nR2L = 0, nL2R = 0; |
| 1062 FX_BOOL bPrevSpace = FALSE; | 1062 FX_BOOL bPrevSpace = FALSE; |
| 1063 for (int i = 0; i < str.GetLength(); i++) { | 1063 for (int i = 0; i < str.GetLength(); i++) { |
| 1064 if (str.GetAt(i) == 32) { | 1064 if (str.GetAt(i) == 32) { |
| 1065 if (bPrevSpace) { | 1065 if (bPrevSpace) { |
| 1066 m_TempTextBuf.Delete(i, 1); | 1066 m_TempTextBuf.Delete(i, 1); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer(); | 1434 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer(); |
| 1435 i = iBufStartAppend; | 1435 i = iBufStartAppend; |
| 1436 j = m_TempTextBuf.GetLength() - 1; | 1436 j = m_TempTextBuf.GetLength() - 1; |
| 1437 for (; i < j; i++, j--) { | 1437 for (; i < j; i++, j--) { |
| 1438 std::swap(pTempBuffer[i], pTempBuffer[j]); | 1438 std::swap(pTempBuffer[i], pTempBuffer[j]); |
| 1439 } | 1439 } |
| 1440 } | 1440 } |
| 1441 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, | 1441 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, |
| 1442 const CPDF_Font* pFont, | 1442 const CPDF_Font* pFont, |
| 1443 int nItems) const { | 1443 int nItems) const { |
| 1444 nonstd::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar); | 1444 std::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar); |
| 1445 int32_t nR2L = 0; | 1445 int32_t nR2L = 0; |
| 1446 int32_t nL2R = 0; | 1446 int32_t nL2R = 0; |
| 1447 int32_t start = 0, count = 0; | 1447 int32_t start = 0, count = 0; |
| 1448 CPDF_TextObjectItem item; | 1448 CPDF_TextObjectItem item; |
| 1449 for (int32_t i = 0; i < nItems; i++) { | 1449 for (int32_t i = 0; i < nItems; i++) { |
| 1450 pTextObj->GetItemInfo(i, &item); | 1450 pTextObj->GetItemInfo(i, &item); |
| 1451 if (item.m_CharCode == (FX_DWORD)-1) { | 1451 if (item.m_CharCode == (FX_DWORD)-1) { |
| 1452 continue; | 1452 continue; |
| 1453 } | 1453 } |
| 1454 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); | 1454 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); |
| (...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 2716 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |
| 2717 return; | 2717 return; |
| 2718 } | 2718 } |
| 2719 CPDF_LinkExt* link = NULL; | 2719 CPDF_LinkExt* link = NULL; |
| 2720 link = m_LinkList.GetAt(index); | 2720 link = m_LinkList.GetAt(index); |
| 2721 if (!link) { | 2721 if (!link) { |
| 2722 return; | 2722 return; |
| 2723 } | 2723 } |
| 2724 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2724 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2725 } | 2725 } |
| OLD | NEW |