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 <cctype> | 7 #include <cctype> |
8 #include <cwctype> | 8 #include <cwctype> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 CTextPage::~CTextPage() { | 41 CTextPage::~CTextPage() { |
42 int i; | 42 int i; |
43 for (i = 0; i < m_BaseLines.GetSize(); i++) { | 43 for (i = 0; i < m_BaseLines.GetSize(); i++) { |
44 delete m_BaseLines.GetAt(i); | 44 delete m_BaseLines.GetAt(i); |
45 } | 45 } |
46 for (i = 0; i < m_TextColumns.GetSize(); i++) { | 46 for (i = 0; i < m_TextColumns.GetSize(); i++) { |
47 delete m_TextColumns.GetAt(i); | 47 delete m_TextColumns.GetAt(i); |
48 } | 48 } |
49 } | 49 } |
50 void CTextPage::ProcessObject(CPDF_PageObject* pObject) { | 50 void CTextPage::ProcessObject(CPDF_PageObject* pObject) { |
51 if (pObject->m_Type != PDFPAGE_TEXT) { | 51 if (pObject->m_Type != CPDF_PageObject::TEXT) { |
52 return; | 52 return; |
53 } | 53 } |
54 CPDF_TextObject* pText = (CPDF_TextObject*)pObject; | 54 CPDF_TextObject* pText = (CPDF_TextObject*)pObject; |
55 CPDF_Font* pFont = pText->m_TextState.GetFont(); | 55 CPDF_Font* pFont = pText->m_TextState.GetFont(); |
56 int count = pText->CountItems(); | 56 int count = pText->CountItems(); |
57 FX_FLOAT* pPosArray = FX_Alloc2D(FX_FLOAT, count, 2); | 57 FX_FLOAT* pPosArray = FX_Alloc2D(FX_FLOAT, count, 2); |
58 pText->CalcCharPos(pPosArray); | 58 pText->CalcCharPos(pPosArray); |
59 | 59 |
60 FX_FLOAT fontsize_h = pText->m_TextState.GetFontSizeH(); | 60 FX_FLOAT fontsize_h = pText->m_TextState.GetFontSizeH(); |
61 FX_FLOAT fontsize_v = pText->m_TextState.GetFontSizeV(); | 61 FX_FLOAT fontsize_v = pText->m_TextState.GetFontSizeV(); |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 width += pText->m_Right - pText->m_Left; | 675 width += pText->m_Right - pText->m_Left; |
676 minchars += pText->m_Text.GetLength() + 1; | 676 minchars += pText->m_Text.GetLength() + 1; |
677 } | 677 } |
678 } | 678 } |
679 #define PI 3.1415926535897932384626433832795 | 679 #define PI 3.1415926535897932384626433832795 |
680 static void CheckRotate(CPDF_Page& page, CFX_FloatRect& page_bbox) { | 680 static void CheckRotate(CPDF_Page& page, CFX_FloatRect& page_bbox) { |
681 int total_count = 0, rotated_count[3] = {0, 0, 0}; | 681 int total_count = 0, rotated_count[3] = {0, 0, 0}; |
682 FX_POSITION pos = page.GetFirstObjectPosition(); | 682 FX_POSITION pos = page.GetFirstObjectPosition(); |
683 while (pos) { | 683 while (pos) { |
684 CPDF_PageObject* pObj = page.GetNextObject(pos); | 684 CPDF_PageObject* pObj = page.GetNextObject(pos); |
685 if (pObj->m_Type != PDFPAGE_TEXT) { | 685 if (pObj->m_Type != CPDF_PageObject::TEXT) { |
686 continue; | 686 continue; |
687 } | 687 } |
688 total_count++; | 688 total_count++; |
689 CPDF_TextObject* pText = (CPDF_TextObject*)pObj; | 689 CPDF_TextObject* pText = (CPDF_TextObject*)pObj; |
690 FX_FLOAT angle = pText->m_TextState.GetBaselineAngle(); | 690 FX_FLOAT angle = pText->m_TextState.GetBaselineAngle(); |
691 if (angle == 0.0) { | 691 if (angle == 0.0) { |
692 continue; | 692 continue; |
693 } | 693 } |
694 int degree = (int)(angle * 180 / PI + 0.5); | 694 int degree = (int)(angle * 180 / PI + 0.5); |
695 if (degree % 90) { | 695 if (degree % 90) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 FX_DWORD flags) { | 780 FX_DWORD flags) { |
781 buffer.EstimateSize(0, 10240); | 781 buffer.EstimateSize(0, 10240); |
782 CPDF_Page page; | 782 CPDF_Page page; |
783 page.Load(pDoc, pPage); | 783 page.Load(pDoc, pPage); |
784 CPDF_ParseOptions options; | 784 CPDF_ParseOptions options; |
785 options.m_bTextOnly = TRUE; | 785 options.m_bTextOnly = TRUE; |
786 options.m_bSeparateForm = FALSE; | 786 options.m_bSeparateForm = FALSE; |
787 page.ParseContent(&options); | 787 page.ParseContent(&options); |
788 GetTextStream_Unicode(buffer, &page, TRUE, NULL); | 788 GetTextStream_Unicode(buffer, &page, TRUE, NULL); |
789 } | 789 } |
OLD | NEW |