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/include/fpdfapi/fpdf_page.h" | 7 #include "core/include/fpdfapi/fpdf_page.h" |
8 #include "core/include/fpdfapi/fpdf_pageobj.h" | 8 #include "core/include/fpdfapi/fpdf_pageobj.h" |
9 #include "core/include/fpdfapi/fpdf_resource.h" | 9 #include "core/include/fpdfapi/fpdf_resource.h" |
10 #include "core/include/fpdftext/fpdf_text.h" | 10 #include "core/include/fpdftext/fpdf_text.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 FX_DWORD space_charcode = pFont->CharCodeFromUnicode(' '); | 62 FX_DWORD space_charcode = pFont->CharCodeFromUnicode(' '); |
63 FX_FLOAT spacew = 0; | 63 FX_FLOAT spacew = 0; |
64 if (space_charcode != -1) { | 64 if (space_charcode != -1) { |
65 spacew = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; | 65 spacew = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; |
66 } | 66 } |
67 if (spacew == 0) { | 67 if (spacew == 0) { |
68 spacew = fontsize_h / 4; | 68 spacew = fontsize_h / 4; |
69 } | 69 } |
70 if (pText->m_TextState.GetBaselineAngle() != 0) { | 70 if (pText->m_TextState.GetBaselineAngle() != 0) { |
71 int cc = 0; | 71 int cc = 0; |
72 CFX_AffineMatrix matrix; | 72 CFX_Matrix matrix; |
73 pText->GetTextMatrix(&matrix); | 73 pText->GetTextMatrix(&matrix); |
74 for (int i = 0; i < pText->m_nChars; i++) { | 74 for (int i = 0; i < pText->m_nChars; i++) { |
75 FX_DWORD charcode = pText->m_nChars == 1 | 75 FX_DWORD charcode = pText->m_nChars == 1 |
76 ? (FX_DWORD)(uintptr_t)pText->m_pCharCodes | 76 ? (FX_DWORD)(uintptr_t)pText->m_pCharCodes |
77 : pText->m_pCharCodes[i]; | 77 : pText->m_pCharCodes[i]; |
78 if (charcode == (FX_DWORD)-1) { | 78 if (charcode == (FX_DWORD)-1) { |
79 continue; | 79 continue; |
80 } | 80 } |
81 FX_RECT char_box; | 81 FX_RECT char_box; |
82 pFont->GetCharBBox(charcode, char_box); | 82 pFont->GetCharBBox(charcode, char_box); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 } | 700 } |
701 int index = degree / 90 % 3 - 1; | 701 int index = degree / 90 % 3 - 1; |
702 if (index < 0) { | 702 if (index < 0) { |
703 continue; | 703 continue; |
704 } | 704 } |
705 rotated_count[index]++; | 705 rotated_count[index]++; |
706 } | 706 } |
707 if (total_count == 0) { | 707 if (total_count == 0) { |
708 return; | 708 return; |
709 } | 709 } |
710 CFX_AffineMatrix matrix; | 710 CFX_Matrix matrix; |
711 if (rotated_count[0] > total_count * 2 / 3) { | 711 if (rotated_count[0] > total_count * 2 / 3) { |
712 matrix.Set(0, -1, 1, 0, 0, page.GetPageHeight()); | 712 matrix.Set(0, -1, 1, 0, 0, page.GetPageHeight()); |
713 } else if (rotated_count[1] > total_count * 2 / 3) { | 713 } else if (rotated_count[1] > total_count * 2 / 3) { |
714 matrix.Set(-1, 0, 0, -1, page.GetPageWidth(), page.GetPageHeight()); | 714 matrix.Set(-1, 0, 0, -1, page.GetPageWidth(), page.GetPageHeight()); |
715 } else if (rotated_count[2] > total_count * 2 / 3) { | 715 } else if (rotated_count[2] > total_count * 2 / 3) { |
716 matrix.Set(0, 1, -1, 0, page.GetPageWidth(), 0); | 716 matrix.Set(0, 1, -1, 0, page.GetPageWidth(), 0); |
717 } else { | 717 } else { |
718 return; | 718 return; |
719 } | 719 } |
720 page.Transform(matrix); | 720 page.Transform(matrix); |
(...skipping 59 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 |