| 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 "core/src/fpdftext/text_int.h" |     7 #include "core/src/fpdftext/text_int.h" | 
|     8  |     8  | 
|     9 #include <algorithm> |     9 #include <algorithm> | 
|    10 #include <cctype> |    10 #include <cctype> | 
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   758   std::vector<uint8_t> nHorizontalMask(nPageWidth); |   758   std::vector<uint8_t> nHorizontalMask(nPageWidth); | 
|   759   std::vector<uint8_t> nVerticalMask(nPageHeight); |   759   std::vector<uint8_t> nVerticalMask(nPageHeight); | 
|   760   uint8_t* pDataH = nHorizontalMask.data(); |   760   uint8_t* pDataH = nHorizontalMask.data(); | 
|   761   uint8_t* pDataV = nVerticalMask.data(); |   761   uint8_t* pDataV = nVerticalMask.data(); | 
|   762   int32_t index = 0; |   762   int32_t index = 0; | 
|   763   FX_FLOAT fLineHeight = 0.0f; |   763   FX_FLOAT fLineHeight = 0.0f; | 
|   764   if (m_pPage->GetPageObjectList()->empty()) |   764   if (m_pPage->GetPageObjectList()->empty()) | 
|   765     return -1; |   765     return -1; | 
|   766  |   766  | 
|   767   for (auto& pPageObj : *m_pPage->GetPageObjectList()) { |   767   for (auto& pPageObj : *m_pPage->GetPageObjectList()) { | 
|   768     if (!pPageObj || pPageObj->m_Type != CPDF_PageObject::TEXT) |   768     if (!pPageObj || !pPageObj->IsText()) | 
|   769       continue; |   769       continue; | 
|   770  |   770  | 
|   771     int32_t minH = |   771     int32_t minH = | 
|   772         (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_Left; |   772         (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_Left; | 
|   773     int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth |   773     int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth | 
|   774                        ? nPageWidth |   774                        ? nPageWidth | 
|   775                        : (int32_t)pPageObj->m_Right; |   775                        : (int32_t)pPageObj->m_Right; | 
|   776     int32_t minV = |   776     int32_t minV = | 
|   777         (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->m_Bottom; |   777         (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->m_Bottom; | 
|   778     int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight |   778     int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   839 } |   839 } | 
|   840  |   840  | 
|   841 void CPDF_TextPage::ProcessObject() { |   841 void CPDF_TextPage::ProcessObject() { | 
|   842   if (m_pPage->GetPageObjectList()->empty()) |   842   if (m_pPage->GetPageObjectList()->empty()) | 
|   843     return; |   843     return; | 
|   844  |   844  | 
|   845   m_TextlineDir = FindTextlineFlowDirection(); |   845   m_TextlineDir = FindTextlineFlowDirection(); | 
|   846   const CPDF_PageObjectList* pObjList = m_pPage->GetPageObjectList(); |   846   const CPDF_PageObjectList* pObjList = m_pPage->GetPageObjectList(); | 
|   847   for (auto it = pObjList->begin(); it != pObjList->end(); ++it) { |   847   for (auto it = pObjList->begin(); it != pObjList->end(); ++it) { | 
|   848     if (CPDF_PageObject* pObj = it->get()) { |   848     if (CPDF_PageObject* pObj = it->get()) { | 
|   849       if (pObj->m_Type == CPDF_PageObject::TEXT) { |   849       if (pObj->IsText()) { | 
|   850         CFX_Matrix matrix; |   850         CFX_Matrix matrix; | 
|   851         ProcessTextObject(static_cast<CPDF_TextObject*>(pObj), matrix, pObjList, |   851         ProcessTextObject(pObj->AsText(), matrix, pObjList, it); | 
|   852                           it); |   852       } else if (pObj->IsForm()) { | 
|   853       } else if (pObj->m_Type == CPDF_PageObject::FORM) { |  | 
|   854         CFX_Matrix formMatrix(1, 0, 0, 1, 0, 0); |   853         CFX_Matrix formMatrix(1, 0, 0, 1, 0, 0); | 
|   855         ProcessFormObject(static_cast<CPDF_FormObject*>(pObj), formMatrix); |   854         ProcessFormObject(pObj->AsForm(), formMatrix); | 
|   856       } |   855       } | 
|   857     } |   856     } | 
|   858   } |   857   } | 
|   859   for (int i = 0; i < m_LineObj.GetSize(); i++) |   858   for (int i = 0; i < m_LineObj.GetSize(); i++) | 
|   860     ProcessTextObject(m_LineObj.GetAt(i)); |   859     ProcessTextObject(m_LineObj.GetAt(i)); | 
|   861  |   860  | 
|   862   m_LineObj.RemoveAll(); |   861   m_LineObj.RemoveAll(); | 
|   863   CloseTempLine(); |   862   CloseTempLine(); | 
|   864 } |   863 } | 
|   865  |   864  | 
|   866 void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj, |   865 void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj, | 
|   867                                       const CFX_Matrix& formMatrix) { |   866                                       const CFX_Matrix& formMatrix) { | 
|   868   CPDF_PageObjectList* pObjectList = pFormObj->m_pForm->GetPageObjectList(); |   867   CPDF_PageObjectList* pObjectList = pFormObj->m_pForm->GetPageObjectList(); | 
|   869   if (pObjectList->empty()) |   868   if (pObjectList->empty()) | 
|   870     return; |   869     return; | 
|   871  |   870  | 
|   872   CFX_Matrix curFormMatrix; |   871   CFX_Matrix curFormMatrix; | 
|   873   curFormMatrix.Copy(pFormObj->m_FormMatrix); |   872   curFormMatrix.Copy(pFormObj->m_FormMatrix); | 
|   874   curFormMatrix.Concat(formMatrix); |   873   curFormMatrix.Concat(formMatrix); | 
|   875  |   874  | 
|   876   for (auto it = pObjectList->begin(); it != pObjectList->end(); ++it) { |   875   for (auto it = pObjectList->begin(); it != pObjectList->end(); ++it) { | 
|   877     if (CPDF_PageObject* pPageObj = it->get()) { |   876     if (CPDF_PageObject* pPageObj = it->get()) { | 
|   878       if (pPageObj->m_Type == CPDF_PageObject::TEXT) { |   877       if (pPageObj->IsText()) { | 
|   879         ProcessTextObject(static_cast<CPDF_TextObject*>(pPageObj), |   878         ProcessTextObject(pPageObj->AsText(), curFormMatrix, pObjectList, it); | 
|   880                           curFormMatrix, pObjectList, it); |   879       } else if (pPageObj->IsForm()) { | 
|   881       } else if (pPageObj->m_Type == CPDF_PageObject::FORM) { |   880         ProcessFormObject(pPageObj->AsForm(), curFormMatrix); | 
|   882         ProcessFormObject(static_cast<CPDF_FormObject*>(pPageObj), |  | 
|   883                           curFormMatrix); |  | 
|   884       } |   881       } | 
|   885     } |   882     } | 
|   886   } |   883   } | 
|   887 } |   884 } | 
|   888  |   885  | 
|   889 int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const { |   886 int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const { | 
|   890   if (charCode == -1) { |   887   if (charCode == -1) { | 
|   891     return 0; |   888     return 0; | 
|   892   } |   889   } | 
|   893   int w = pFont->GetCharWidthF(charCode); |   890   int w = pFont->GetCharWidthF(charCode); | 
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1818   return TRUE; |  1815   return TRUE; | 
|  1819 } |  1816 } | 
|  1820 FX_BOOL CPDF_TextPage::IsSameAsPreTextObject( |  1817 FX_BOOL CPDF_TextPage::IsSameAsPreTextObject( | 
|  1821     CPDF_TextObject* pTextObj, |  1818     CPDF_TextObject* pTextObj, | 
|  1822     const CPDF_PageObjectList* pObjList, |  1819     const CPDF_PageObjectList* pObjList, | 
|  1823     CPDF_PageObjectList::const_iterator iter) { |  1820     CPDF_PageObjectList::const_iterator iter) { | 
|  1824   int i = 0; |  1821   int i = 0; | 
|  1825   while (i < 5 && iter != pObjList->begin()) { |  1822   while (i < 5 && iter != pObjList->begin()) { | 
|  1826     --iter; |  1823     --iter; | 
|  1827     CPDF_PageObject* pOtherObj = iter->get(); |  1824     CPDF_PageObject* pOtherObj = iter->get(); | 
|  1828     if (pOtherObj == pTextObj || pOtherObj->m_Type != CPDF_PageObject::TEXT) |  1825     if (pOtherObj == pTextObj || !pOtherObj->IsText()) | 
|  1829       continue; |  1826       continue; | 
|  1830     if (IsSameTextObject(static_cast<CPDF_TextObject*>(pOtherObj), pTextObj)) |  1827     if (IsSameTextObject(pOtherObj->AsText(), pTextObj)) | 
|  1831       return TRUE; |  1828       return TRUE; | 
|  1832     ++i; |  1829     ++i; | 
|  1833   } |  1830   } | 
|  1834   return FALSE; |  1831   return FALSE; | 
|  1835 } |  1832 } | 
|  1836  |  1833  | 
|  1837 FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { |  1834 FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { | 
|  1838   const PAGECHAR_INFO* preChar; |  1835   const PAGECHAR_INFO* preChar; | 
|  1839   if (!m_TempCharList.empty()) { |  1836   if (!m_TempCharList.empty()) { | 
|  1840     preChar = &m_TempCharList.back(); |  1837     preChar = &m_TempCharList.back(); | 
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2497   if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |  2494   if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 
|  2498     return; |  2495     return; | 
|  2499   } |  2496   } | 
|  2500   CPDF_LinkExt* link = NULL; |  2497   CPDF_LinkExt* link = NULL; | 
|  2501   link = m_LinkList.GetAt(index); |  2498   link = m_LinkList.GetAt(index); | 
|  2502   if (!link) { |  2499   if (!link) { | 
|  2503     return; |  2500     return; | 
|  2504   } |  2501   } | 
|  2505   m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |  2502   m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 
|  2506 } |  2503 } | 
| OLD | NEW |