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 "../../include/fpdfapi/fpdf_resource.h" | 7 #include "../../include/fpdfapi/fpdf_resource.h" |
8 #include "../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../include/fpdftext/fpdf_text.h" | 9 #include "../../include/fpdftext/fpdf_text.h" |
10 #include "../../include/fpdfapi/fpdf_page.h" | 10 #include "../../include/fpdfapi/fpdf_page.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 #define TEXT_BLANK_CHAR L' ' | 62 #define TEXT_BLANK_CHAR L' ' |
63 #define TEXT_LINEFEED_CHAR L'\n' | 63 #define TEXT_LINEFEED_CHAR L'\n' |
64 #define TEXT_RETURN_CHAR L'\r' | 64 #define TEXT_RETURN_CHAR L'\r' |
65 #define TEXT_EMPTY L"" | 65 #define TEXT_EMPTY L"" |
66 #define TEXT_BLANK L" " | 66 #define TEXT_BLANK L" " |
67 #define TEXT_RETURN_LINEFEED L"\r\n" | 67 #define TEXT_RETURN_LINEFEED L"\r\n" |
68 #define TEXT_LINEFEED L"\n" | 68 #define TEXT_LINEFEED L"\n" |
69 #define TEXT_CHARRATIO_GAPDELTA 0.070 | 69 #define TEXT_CHARRATIO_GAPDELTA 0.070 |
70 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) | 70 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) |
71 : m_pPreTextObj(NULL), | 71 : m_charList(512), |
| 72 m_TempCharList(50), |
| 73 m_pPreTextObj(NULL), |
72 m_IsParsered(FALSE), | 74 m_IsParsered(FALSE), |
73 m_charList(512), | |
74 m_TempCharList(50), | |
75 m_TextlineDir(-1), | 75 m_TextlineDir(-1), |
76 m_CurlineRect(0, 0, 0, 0) | 76 m_CurlineRect(0, 0, 0, 0) |
77 { | 77 { |
78 m_pPage = pPage; | 78 m_pPage = pPage; |
79 m_parserflag = flags; | 79 m_parserflag = flags; |
80 m_TextBuf.EstimateSize(0, 10240); | 80 m_TextBuf.EstimateSize(0, 10240); |
81 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); | 81 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); |
82 } | 82 } |
83 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions Parse
rOptions) | 83 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions Parse
rOptions) |
84 : m_pPreTextObj(NULL) | 84 : m_ParseOptions(ParserOptions) |
85 , m_IsParsered(FALSE) | |
86 , m_charList(512) | 85 , m_charList(512) |
87 , m_TempCharList(50) | 86 , m_TempCharList(50) |
| 87 , m_pPreTextObj(NULL) |
| 88 , m_IsParsered(FALSE) |
88 , m_TextlineDir(-1) | 89 , m_TextlineDir(-1) |
89 , m_CurlineRect(0, 0, 0, 0) | 90 , m_CurlineRect(0, 0, 0, 0) |
90 , m_ParseOptions(ParserOptions) | |
91 { | 91 { |
92 m_pPage = pPage; | 92 m_pPage = pPage; |
93 m_parserflag = 0; | 93 m_parserflag = 0; |
94 m_TextBuf.EstimateSize(0, 10240); | 94 m_TextBuf.EstimateSize(0, 10240); |
95 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); | 95 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); |
96 } | 96 } |
97 CPDF_TextPage::CPDF_TextPage(const CPDF_PageObjects* pPage, int flags) | 97 CPDF_TextPage::CPDF_TextPage(const CPDF_PageObjects* pPage, int flags) |
98 : m_pPreTextObj(NULL), | 98 : m_charList(512), |
| 99 m_TempCharList(50), |
| 100 m_pPreTextObj(NULL), |
99 m_IsParsered(FALSE), | 101 m_IsParsered(FALSE), |
100 m_charList(512), | |
101 m_TempCharList(50), | |
102 m_TextlineDir(-1), | 102 m_TextlineDir(-1), |
103 m_CurlineRect(0, 0, 0, 0) | 103 m_CurlineRect(0, 0, 0, 0) |
104 { | 104 { |
105 m_pPage = pPage; | 105 m_pPage = pPage; |
106 m_parserflag = flags; | 106 m_parserflag = flags; |
107 m_TextBuf.EstimateSize(0, 10240); | 107 m_TextBuf.EstimateSize(0, 10240); |
108 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); | 108 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); |
109 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top
); | 109 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top
); |
110 } | 110 } |
111 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) | 111 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 pos = m_pPage->GetFirstObjectPosition(); | 1029 pos = m_pPage->GetFirstObjectPosition(); |
1030 if (!pos) { | 1030 if (!pos) { |
1031 return; | 1031 return; |
1032 } | 1032 } |
1033 m_TextlineDir = FindTextlineFlowDirection(); | 1033 m_TextlineDir = FindTextlineFlowDirection(); |
1034 int nCount = 0; | 1034 int nCount = 0; |
1035 while (pos) { | 1035 while (pos) { |
1036 pPageObj = m_pPage->GetNextObject(pos); | 1036 pPageObj = m_pPage->GetNextObject(pos); |
1037 if(pPageObj) { | 1037 if(pPageObj) { |
1038 if(pPageObj->m_Type == PDFPAGE_TEXT) { | 1038 if(pPageObj->m_Type == PDFPAGE_TEXT) { |
1039 if (nCount == 3) { | |
1040 nCount = nCount; | |
1041 } | |
1042 CFX_AffineMatrix matrix; | 1039 CFX_AffineMatrix matrix; |
1043 ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos); | 1040 ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos); |
1044 nCount++; | 1041 nCount++; |
1045 } else if (pPageObj->m_Type == PDFPAGE_FORM) { | 1042 } else if (pPageObj->m_Type == PDFPAGE_FORM) { |
1046 CFX_AffineMatrix formMatrix(1, 0, 0, 1, 0, 0); | 1043 CFX_AffineMatrix formMatrix(1, 0, 0, 1, 0, 0); |
1047 ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix); | 1044 ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix); |
1048 } | 1045 } |
1049 } | 1046 } |
1050 pPageObj = NULL; | 1047 pPageObj = NULL; |
1051 } | 1048 } |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 } | 2159 } |
2163 if (unicode > L'Z' && unicode < L'a') { | 2160 if (unicode > L'Z' && unicode < L'a') { |
2164 return FALSE; | 2161 return FALSE; |
2165 } | 2162 } |
2166 if (unicode > L'z') { | 2163 if (unicode > L'z') { |
2167 return FALSE; | 2164 return FALSE; |
2168 } | 2165 } |
2169 return TRUE; | 2166 return TRUE; |
2170 } | 2167 } |
2171 CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage) | 2168 CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage) |
2172 : m_IsFind(FALSE), | 2169 : m_pTextPage(NULL), |
2173 m_pTextPage(NULL) | 2170 m_IsFind(FALSE) |
2174 { | 2171 { |
2175 if (!pTextPage) { | 2172 if (!pTextPage) { |
2176 return; | 2173 return; |
2177 } | 2174 } |
2178 m_pTextPage = pTextPage; | 2175 m_pTextPage = pTextPage; |
2179 m_strText = m_pTextPage->GetPageText(); | 2176 m_strText = m_pTextPage->GetPageText(); |
2180 int nCount = pTextPage->CountChars(); | 2177 int nCount = pTextPage->CountChars(); |
2181 if(nCount) { | 2178 if(nCount) { |
2182 m_CharIndex.Add(0); | 2179 m_CharIndex.Add(0); |
2183 } | 2180 } |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2777 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
2781 return; | 2778 return; |
2782 } | 2779 } |
2783 CPDF_LinkExt* link = NULL; | 2780 CPDF_LinkExt* link = NULL; |
2784 link = m_LinkList.GetAt(index); | 2781 link = m_LinkList.GetAt(index); |
2785 if (!link) { | 2782 if (!link) { |
2786 return ; | 2783 return ; |
2787 } | 2784 } |
2788 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2785 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
2789 } | 2786 } |
OLD | NEW |