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 <ctype.h> | 7 #include <ctype.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "../../../third_party/base/nonstd_unique_ptr.h" | 10 #include "../../../third_party/base/nonstd_unique_ptr.h" |
11 #include "../../include/fpdfapi/fpdf_module.h" | 11 #include "../../include/fpdfapi/fpdf_module.h" |
12 #include "../../include/fpdfapi/fpdf_page.h" | 12 #include "../../include/fpdfapi/fpdf_page.h" |
13 #include "../../include/fpdfapi/fpdf_pageobj.h" | 13 #include "../../include/fpdfapi/fpdf_pageobj.h" |
14 #include "../../include/fpdfapi/fpdf_resource.h" | 14 #include "../../include/fpdfapi/fpdf_resource.h" |
15 #include "../../include/fpdftext/fpdf_text.h" | 15 #include "../../include/fpdftext/fpdf_text.h" |
16 #include "../../include/fxcrt/fx_arb.h" | 16 #include "../../include/fxcrt/fx_arb.h" |
17 #include "../../include/fxcrt/fx_ucd.h" | 17 #include "../../include/fxcrt/fx_ucd.h" |
18 #include "text_int.h" | 18 #include "text_int.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 FX_BOOL _IsIgnoreSpaceCharacter(FX_WCHAR curChar) | 22 bool _IsIgnoreSpaceCharacter(FX_WCHAR curChar) |
23 { | 23 { |
24 if(curChar < 255 ) { | 24 if(curChar < 255 ) { |
25 return FALSE; | 25 return false; |
26 } | 26 } |
27 if ( (curChar >= 0x0600 && curChar <= 0x06FF) | 27 if ( (curChar >= 0x0600 && curChar <= 0x06FF) |
28 || (curChar >= 0xFE70 && curChar <= 0xFEFF) | 28 || (curChar >= 0xFE70 && curChar <= 0xFEFF) |
29 || (curChar >= 0xFB50 && curChar <= 0xFDFF) | 29 || (curChar >= 0xFB50 && curChar <= 0xFDFF) |
30 || (curChar >= 0x0400 && curChar <= 0x04FF) | 30 || (curChar >= 0x0400 && curChar <= 0x04FF) |
31 || (curChar >= 0x0500 && curChar <= 0x052F) | 31 || (curChar >= 0x0500 && curChar <= 0x052F) |
32 || (curChar >= 0xA640 && curChar <= 0xA69F) | 32 || (curChar >= 0xA640 && curChar <= 0xA69F) |
33 || (curChar >= 0x2DE0 && curChar <= 0x2DFF) | 33 || (curChar >= 0x2DE0 && curChar <= 0x2DFF) |
34 || curChar == 8467 | 34 || curChar == 8467 |
35 || (curChar >= 0x2000 && curChar <= 0x206F)) { | 35 || (curChar >= 0x2000 && curChar <= 0x206F)) { |
36 return FALSE; | 36 return false; |
37 } | 37 } |
38 return TRUE; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold) | 41 FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold) |
42 { | 42 { |
43 if (threshold < 300) { | 43 if (threshold < 300) { |
44 return threshold / 2.0f; | 44 return threshold / 2.0f; |
45 } else if (threshold < 500) { | 45 } else if (threshold < 500) { |
46 return threshold / 4.0f; | 46 return threshold / 4.0f; |
47 } else if (threshold < 700) { | 47 } else if (threshold < 700) { |
48 return threshold / 5.0f; | 48 return threshold / 5.0f; |
49 } | 49 } |
50 return threshold / 6.0f; | 50 return threshold / 6.0f; |
51 } | 51 } |
52 | 52 |
53 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj, | 53 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj, |
54 const CFX_AffineMatrix& matrix) | 54 const CFX_AffineMatrix& matrix) |
55 { | 55 { |
56 FX_FLOAT baseSpace = 0.0; | 56 FX_FLOAT baseSpace = 0.0; |
57 const int nItems = pTextObj->CountItems(); | 57 const int nItems = pTextObj->CountItems(); |
58 if (pTextObj->m_TextState.GetObject()->m_CharSpace && nItems >= 3) { | 58 if (pTextObj->m_TextState.GetObject()->m_CharSpace && nItems >= 3) { |
59 FX_BOOL bAllChar = TRUE; | 59 bool bAllChar = true; |
60 FX_FLOAT spacing = matrix.TransformDistance( | 60 FX_FLOAT spacing = matrix.TransformDistance( |
61 pTextObj->m_TextState.GetObject()->m_CharSpace); | 61 pTextObj->m_TextState.GetObject()->m_CharSpace); |
62 baseSpace = spacing; | 62 baseSpace = spacing; |
63 for (int i = 0; i < nItems; i++) { | 63 for (int i = 0; i < nItems; i++) { |
64 CPDF_TextObjectItem item; | 64 CPDF_TextObjectItem item; |
65 pTextObj->GetItemInfo(i, &item); | 65 pTextObj->GetItemInfo(i, &item); |
66 if (item.m_CharCode == (FX_DWORD) - 1) { | 66 if (item.m_CharCode == (FX_DWORD) - 1) { |
67 FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); | 67 FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); |
68 FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000; | 68 FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000; |
69 baseSpace = std::min(baseSpace, kerning + spacing); | 69 baseSpace = std::min(baseSpace, kerning + spacing); |
70 bAllChar = FALSE; | 70 bAllChar = false; |
71 } | 71 } |
72 } | 72 } |
73 if (baseSpace < 0.0 || (nItems == 3 && !bAllChar)) { | 73 if (baseSpace < 0.0 || (nItems == 3 && !bAllChar)) { |
74 baseSpace = 0.0; | 74 baseSpace = 0.0; |
75 } | 75 } |
76 } | 76 } |
77 return baseSpace; | 77 return baseSpace; |
78 } | 78 } |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 CPDFText_ParseOptions::CPDFText_ParseOptions() | 82 CPDFText_ParseOptions::CPDFText_ParseOptions() |
83 : m_bGetCharCodeOnly(FALSE), m_bNormalizeObjs(TRUE), m_bOutputHyphen(FALSE) | 83 : m_bGetCharCodeOnly(false), m_bNormalizeObjs(true), m_bOutputHyphen(false) |
84 { | 84 { |
85 } | 85 } |
86 IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage, CPDFText_Pa
rseOptions ParserOptions) | 86 IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage, CPDFText_Pa
rseOptions ParserOptions) |
87 { | 87 { |
88 return new CPDF_TextPage(pPage, ParserOptions); | 88 return new CPDF_TextPage(pPage, ParserOptions); |
89 } | 89 } |
90 IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage, int flags) | 90 IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage, int flags) |
91 { | 91 { |
92 return new CPDF_TextPage(pPage, flags); | 92 return new CPDF_TextPage(pPage, flags); |
93 } | 93 } |
(...skipping 17 matching lines...) Expand all Loading... |
111 #define TEXT_RETURN_CHAR L'\r' | 111 #define TEXT_RETURN_CHAR L'\r' |
112 #define TEXT_EMPTY L"" | 112 #define TEXT_EMPTY L"" |
113 #define TEXT_BLANK L" " | 113 #define TEXT_BLANK L" " |
114 #define TEXT_RETURN_LINEFEED L"\r\n" | 114 #define TEXT_RETURN_LINEFEED L"\r\n" |
115 #define TEXT_LINEFEED L"\n" | 115 #define TEXT_LINEFEED L"\n" |
116 #define TEXT_CHARRATIO_GAPDELTA 0.070 | 116 #define TEXT_CHARRATIO_GAPDELTA 0.070 |
117 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) | 117 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) |
118 : m_charList(512), | 118 : m_charList(512), |
119 m_TempCharList(50), | 119 m_TempCharList(50), |
120 m_pPreTextObj(NULL), | 120 m_pPreTextObj(NULL), |
121 m_IsParsered(FALSE), | 121 m_IsParsered(false), |
122 m_TextlineDir(-1), | 122 m_TextlineDir(-1), |
123 m_CurlineRect(0, 0, 0, 0) | 123 m_CurlineRect(0, 0, 0, 0) |
124 { | 124 { |
125 m_pPage = pPage; | 125 m_pPage = pPage; |
126 m_parserflag = flags; | 126 m_parserflag = flags; |
127 m_TextBuf.EstimateSize(0, 10240); | 127 m_TextBuf.EstimateSize(0, 10240); |
128 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); | 128 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); |
129 } | 129 } |
130 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions Parse
rOptions) | 130 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions Parse
rOptions) |
131 : m_ParseOptions(ParserOptions) | 131 : m_ParseOptions(ParserOptions) |
132 , m_charList(512) | 132 , m_charList(512) |
133 , m_TempCharList(50) | 133 , m_TempCharList(50) |
134 , m_pPreTextObj(NULL) | 134 , m_pPreTextObj(NULL) |
135 , m_IsParsered(FALSE) | 135 , m_IsParsered(false) |
136 , m_TextlineDir(-1) | 136 , m_TextlineDir(-1) |
137 , m_CurlineRect(0, 0, 0, 0) | 137 , m_CurlineRect(0, 0, 0, 0) |
138 { | 138 { |
139 m_pPage = pPage; | 139 m_pPage = pPage; |
140 m_parserflag = 0; | 140 m_parserflag = 0; |
141 m_TextBuf.EstimateSize(0, 10240); | 141 m_TextBuf.EstimateSize(0, 10240); |
142 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); | 142 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int) pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0); |
143 } | 143 } |
144 CPDF_TextPage::CPDF_TextPage(const CPDF_PageObjects* pPage, int flags) | 144 CPDF_TextPage::CPDF_TextPage(const CPDF_PageObjects* pPage, int flags) |
145 : m_charList(512), | 145 : m_charList(512), |
146 m_TempCharList(50), | 146 m_TempCharList(50), |
147 m_pPreTextObj(NULL), | 147 m_pPreTextObj(NULL), |
148 m_IsParsered(FALSE), | 148 m_IsParsered(false), |
149 m_TextlineDir(-1), | 149 m_TextlineDir(-1), |
150 m_CurlineRect(0, 0, 0, 0) | 150 m_CurlineRect(0, 0, 0, 0) |
151 { | 151 { |
152 m_pPage = pPage; | 152 m_pPage = pPage; |
153 m_parserflag = flags; | 153 m_parserflag = flags; |
154 m_TextBuf.EstimateSize(0, 10240); | 154 m_TextBuf.EstimateSize(0, 10240); |
155 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); | 155 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); |
156 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top
); | 156 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top
); |
157 } | 157 } |
158 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) | 158 void CPDF_TextPage::NormalizeObjects(bool bNormalize) |
159 { | 159 { |
160 m_ParseOptions.m_bNormalizeObjs = bNormalize; | 160 m_ParseOptions.m_bNormalizeObjs = bNormalize; |
161 } | 161 } |
162 FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) | 162 bool CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) |
163 { | 163 { |
164 if(!pCharInfo) { | 164 if(!pCharInfo) { |
165 return FALSE; | 165 return false; |
166 } | 166 } |
167 switch(pCharInfo->m_Unicode) { | 167 switch(pCharInfo->m_Unicode) { |
168 case 0x2: | 168 case 0x2: |
169 case 0x3: | 169 case 0x3: |
170 case 0x93: | 170 case 0x93: |
171 case 0x94: | 171 case 0x94: |
172 case 0x96: | 172 case 0x96: |
173 case 0x97: | 173 case 0x97: |
174 case 0x98: | 174 case 0x98: |
175 case 0xfffe: | 175 case 0xfffe: |
176 if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) { | 176 if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) { |
177 return FALSE; | 177 return false; |
178 } else { | 178 } else { |
179 return TRUE; | 179 return true; |
180 } | 180 } |
181 default: | 181 default: |
182 return FALSE; | 182 return false; |
183 } | 183 } |
184 } | 184 } |
185 FX_BOOL CPDF_TextPage::ParseTextPage() | 185 bool CPDF_TextPage::ParseTextPage() |
186 { | 186 { |
187 if (!m_pPage) { | 187 if (!m_pPage) { |
188 m_IsParsered = FALSE; | 188 m_IsParsered = false; |
189 return FALSE; | 189 return false; |
190 } | 190 } |
191 m_IsParsered = FALSE; | 191 m_IsParsered = false; |
192 m_TextBuf.Clear(); | 192 m_TextBuf.Clear(); |
193 m_charList.RemoveAll(); | 193 m_charList.RemoveAll(); |
194 m_pPreTextObj = NULL; | 194 m_pPreTextObj = NULL; |
195 ProcessObject(); | 195 ProcessObject(); |
196 m_IsParsered = TRUE; | 196 m_IsParsered = true; |
197 if(!m_ParseOptions.m_bGetCharCodeOnly) { | 197 if(!m_ParseOptions.m_bGetCharCodeOnly) { |
198 m_CharIndex.RemoveAll(); | 198 m_CharIndex.RemoveAll(); |
199 int nCount = m_charList.GetSize(); | 199 int nCount = m_charList.GetSize(); |
200 if(nCount) { | 200 if(nCount) { |
201 m_CharIndex.Add(0); | 201 m_CharIndex.Add(0); |
202 } | 202 } |
203 for(int i = 0; i < nCount; i++) { | 203 for(int i = 0; i < nCount; i++) { |
204 int indexSize = m_CharIndex.GetSize(); | 204 int indexSize = m_CharIndex.GetSize(); |
205 FX_BOOL bNormal = FALSE; | 205 bool bNormal = false; |
206 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); | 206 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); |
207 if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { | 207 if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
208 bNormal = TRUE; | 208 bNormal = true; |
209 } | 209 } |
210 else if(charinfo.m_Unicode == 0 || IsControlChar(&charinfo)) | 210 else if(charinfo.m_Unicode == 0 || IsControlChar(&charinfo)) |
211 bNormal = FALSE; | 211 bNormal = false; |
212 else { | 212 else { |
213 bNormal = TRUE; | 213 bNormal = true; |
214 } | 214 } |
215 if(bNormal) { | 215 if(bNormal) { |
216 if(indexSize % 2) { | 216 if(indexSize % 2) { |
217 m_CharIndex.Add(1); | 217 m_CharIndex.Add(1); |
218 } else { | 218 } else { |
219 if(indexSize <= 0) { | 219 if(indexSize <= 0) { |
220 continue; | 220 continue; |
221 } | 221 } |
222 m_CharIndex.SetAt(indexSize - 1, m_CharIndex.GetAt(indexSize
- 1) + 1); | 222 m_CharIndex.SetAt(indexSize - 1, m_CharIndex.GetAt(indexSize
- 1) + 1); |
223 } | 223 } |
224 } else { | 224 } else { |
225 if(indexSize % 2) { | 225 if(indexSize % 2) { |
226 if(indexSize <= 0) { | 226 if(indexSize <= 0) { |
227 continue; | 227 continue; |
228 } | 228 } |
229 m_CharIndex.SetAt(indexSize - 1, i + 1); | 229 m_CharIndex.SetAt(indexSize - 1, i + 1); |
230 } else { | 230 } else { |
231 m_CharIndex.Add(i + 1); | 231 m_CharIndex.Add(i + 1); |
232 } | 232 } |
233 } | 233 } |
234 } | 234 } |
235 int indexSize = m_CharIndex.GetSize(); | 235 int indexSize = m_CharIndex.GetSize(); |
236 if(indexSize % 2) { | 236 if(indexSize % 2) { |
237 m_CharIndex.RemoveAt(indexSize - 1); | 237 m_CharIndex.RemoveAt(indexSize - 1); |
238 } | 238 } |
239 } | 239 } |
240 return TRUE; | 240 return true; |
241 } | 241 } |
242 int CPDF_TextPage::CountChars() const | 242 int CPDF_TextPage::CountChars() const |
243 { | 243 { |
244 if(m_ParseOptions.m_bGetCharCodeOnly) { | 244 if(m_ParseOptions.m_bGetCharCodeOnly) { |
245 return m_TextBuf.GetSize(); | 245 return m_TextBuf.GetSize(); |
246 } | 246 } |
247 return m_charList.GetSize(); | 247 return m_charList.GetSize(); |
248 } | 248 } |
249 int CPDF_TextPage::CharIndexFromTextIndex(int TextIndex) const | 249 int CPDF_TextPage::CharIndexFromTextIndex(int TextIndex) const |
250 { | 250 { |
(...skipping 30 matching lines...) Expand all Loading... |
281 if(start < 0 || nCount == 0) { | 281 if(start < 0 || nCount == 0) { |
282 return; | 282 return; |
283 } | 283 } |
284 if (!m_IsParsered) { | 284 if (!m_IsParsered) { |
285 return; | 285 return; |
286 } | 286 } |
287 PAGECHAR_INFO info_curchar; | 287 PAGECHAR_INFO info_curchar; |
288 CPDF_TextObject* pCurObj = NULL; | 288 CPDF_TextObject* pCurObj = NULL; |
289 CFX_FloatRect rect; | 289 CFX_FloatRect rect; |
290 int curPos = start; | 290 int curPos = start; |
291 FX_BOOL» » » » flagNewRect = TRUE; | 291 bool» » » » flagNewRect = true; |
292 if (nCount + start > m_charList.GetSize() || nCount == -1) { | 292 if (nCount + start > m_charList.GetSize() || nCount == -1) { |
293 nCount = m_charList.GetSize() - start; | 293 nCount = m_charList.GetSize() - start; |
294 } | 294 } |
295 while (nCount--) { | 295 while (nCount--) { |
296 info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(curPos++); | 296 info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(curPos++); |
297 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { | 297 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
298 continue; | 298 continue; |
299 } | 299 } |
300 if(info_curchar.m_CharBox.Width() < 0.01 || info_curchar.m_CharBox.Heigh
t() < 0.01) { | 300 if(info_curchar.m_CharBox.Width() < 0.01 || info_curchar.m_CharBox.Heigh
t() < 0.01) { |
301 continue; | 301 continue; |
302 } | 302 } |
303 if(!pCurObj) { | 303 if(!pCurObj) { |
304 pCurObj = info_curchar.m_pTextObj; | 304 pCurObj = info_curchar.m_pTextObj; |
305 } | 305 } |
306 if (pCurObj != info_curchar.m_pTextObj) { | 306 if (pCurObj != info_curchar.m_pTextObj) { |
307 rectArray.Add(rect); | 307 rectArray.Add(rect); |
308 pCurObj = info_curchar.m_pTextObj; | 308 pCurObj = info_curchar.m_pTextObj; |
309 flagNewRect = TRUE; | 309 flagNewRect = true; |
310 } | 310 } |
311 if (flagNewRect) { | 311 if (flagNewRect) { |
312 FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_Origin
Y; | 312 FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_Origin
Y; |
313 CFX_AffineMatrix matrix, matrix_reverse; | 313 CFX_AffineMatrix matrix, matrix_reverse; |
314 info_curchar.m_pTextObj->GetTextMatrix(&matrix); | 314 info_curchar.m_pTextObj->GetTextMatrix(&matrix); |
315 matrix.Concat(info_curchar.m_Matrix); | 315 matrix.Concat(info_curchar.m_Matrix); |
316 matrix_reverse.SetReverse(matrix); | 316 matrix_reverse.SetReverse(matrix); |
317 matrix_reverse.Transform(orgX, orgY); | 317 matrix_reverse.Transform(orgX, orgY); |
318 rect.left = info_curchar.m_CharBox.left; | 318 rect.left = info_curchar.m_CharBox.left; |
319 rect.right = info_curchar.m_CharBox.right; | 319 rect.right = info_curchar.m_CharBox.right; |
320 if (pCurObj->GetFont()->GetTypeDescent()) { | 320 if (pCurObj->GetFont()->GetTypeDescent()) { |
321 rect.bottom = orgY + pCurObj->GetFont()->GetTypeDescent() * pCur
Obj->GetFontSize() / 1000; | 321 rect.bottom = orgY + pCurObj->GetFont()->GetTypeDescent() * pCur
Obj->GetFontSize() / 1000; |
322 FX_FLOAT xPosTemp = orgX; | 322 FX_FLOAT xPosTemp = orgX; |
323 matrix.Transform(xPosTemp, rect.bottom); | 323 matrix.Transform(xPosTemp, rect.bottom); |
324 } else { | 324 } else { |
325 rect.bottom = info_curchar.m_CharBox.bottom; | 325 rect.bottom = info_curchar.m_CharBox.bottom; |
326 } | 326 } |
327 if (pCurObj->GetFont()->GetTypeAscent()) { | 327 if (pCurObj->GetFont()->GetTypeAscent()) { |
328 rect.top = orgY + pCurObj->GetFont()->GetTypeAscent() * pCurObj-
>GetFontSize() / 1000; | 328 rect.top = orgY + pCurObj->GetFont()->GetTypeAscent() * pCurObj-
>GetFontSize() / 1000; |
329 FX_FLOAT xPosTemp = orgX + GetCharWidth(info_curchar.m_CharCode,
pCurObj->GetFont()) * pCurObj->GetFontSize() / 1000; | 329 FX_FLOAT xPosTemp = orgX + GetCharWidth(info_curchar.m_CharCode,
pCurObj->GetFont()) * pCurObj->GetFontSize() / 1000; |
330 matrix.Transform(xPosTemp, rect.top); | 330 matrix.Transform(xPosTemp, rect.top); |
331 } else { | 331 } else { |
332 rect.top = info_curchar.m_CharBox.top; | 332 rect.top = info_curchar.m_CharBox.top; |
333 } | 333 } |
334 flagNewRect = FALSE; | 334 flagNewRect = false; |
335 rect = info_curchar.m_CharBox; | 335 rect = info_curchar.m_CharBox; |
336 rect.Normalize(); | 336 rect.Normalize(); |
337 } else { | 337 } else { |
338 info_curchar.m_CharBox.Normalize(); | 338 info_curchar.m_CharBox.Normalize(); |
339 if (rect.left > info_curchar.m_CharBox.left) { | 339 if (rect.left > info_curchar.m_CharBox.left) { |
340 rect.left = info_curchar.m_CharBox.left; | 340 rect.left = info_curchar.m_CharBox.left; |
341 } | 341 } |
342 if (rect.right < info_curchar.m_CharBox.right) { | 342 if (rect.right < info_curchar.m_CharBox.right) { |
343 rect.right = info_curchar.m_CharBox.right; | 343 rect.right = info_curchar.m_CharBox.right; |
344 } | 344 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 397 } |
398 CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const | 398 CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const |
399 { | 399 { |
400 CFX_WideString strText; | 400 CFX_WideString strText; |
401 if(m_ParseOptions.m_bGetCharCodeOnly || !m_IsParsered) { | 401 if(m_ParseOptions.m_bGetCharCodeOnly || !m_IsParsered) { |
402 return strText; | 402 return strText; |
403 } | 403 } |
404 int nCount = m_charList.GetSize(); | 404 int nCount = m_charList.GetSize(); |
405 int pos = 0; | 405 int pos = 0; |
406 FX_FLOAT posy = 0; | 406 FX_FLOAT posy = 0; |
407 FX_BOOL IsContainPreChar = FALSE; | 407 bool IsContainPreChar = false; |
408 FX_BOOL» ISAddLineFeed = FALSE; | 408 bool» ISAddLineFeed = false; |
409 while (pos < nCount) { | 409 while (pos < nCount) { |
410 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); | 410 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); |
411 if (IsRectIntersect(rect, charinfo.m_CharBox)) { | 411 if (IsRectIntersect(rect, charinfo.m_CharBox)) { |
412 if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar &
& ISAddLineFeed) { | 412 if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar &
& ISAddLineFeed) { |
413 posy = charinfo.m_OriginY; | 413 posy = charinfo.m_OriginY; |
414 if (strText.GetLength() > 0) { | 414 if (strText.GetLength() > 0) { |
415 strText += L"\r\n"; | 415 strText += L"\r\n"; |
416 } | 416 } |
417 } | 417 } |
418 IsContainPreChar = TRUE; | 418 IsContainPreChar = true; |
419 ISAddLineFeed = FALSE; | 419 ISAddLineFeed = false; |
420 if (charinfo.m_Unicode) { | 420 if (charinfo.m_Unicode) { |
421 strText += charinfo.m_Unicode; | 421 strText += charinfo.m_Unicode; |
422 } | 422 } |
423 } else if (charinfo.m_Unicode == 32) { | 423 } else if (charinfo.m_Unicode == 32) { |
424 if (IsContainPreChar && charinfo.m_Unicode) { | 424 if (IsContainPreChar && charinfo.m_Unicode) { |
425 strText += charinfo.m_Unicode; | 425 strText += charinfo.m_Unicode; |
426 IsContainPreChar = FALSE; | 426 IsContainPreChar = false; |
427 ISAddLineFeed = FALSE; | 427 ISAddLineFeed = false; |
428 } | 428 } |
429 } else { | 429 } else { |
430 IsContainPreChar = FALSE; | 430 IsContainPreChar = false; |
431 ISAddLineFeed = TRUE; | 431 ISAddLineFeed = true; |
432 } | 432 } |
433 } | 433 } |
434 return strText; | 434 return strText; |
435 } | 435 } |
436 void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect, CFX_RectArray
& resRectArray) const | 436 void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect, CFX_RectArray
& resRectArray) const |
437 { | 437 { |
438 if(m_ParseOptions.m_bGetCharCodeOnly) { | 438 if(m_ParseOptions.m_bGetCharCodeOnly) { |
439 return; | 439 return; |
440 } | 440 } |
441 if (!m_IsParsered) { | 441 if (!m_IsParsered) { |
442 return; | 442 return; |
443 } | 443 } |
444 CFX_FloatRect curRect; | 444 CFX_FloatRect curRect; |
445 FX_BOOL» » » » flagNewRect = TRUE; | 445 bool» » » » flagNewRect = true; |
446 CPDF_TextObject* pCurObj = NULL; | 446 CPDF_TextObject* pCurObj = NULL; |
447 int nCount = m_charList.GetSize(); | 447 int nCount = m_charList.GetSize(); |
448 int pos = 0; | 448 int pos = 0; |
449 while (pos < nCount) { | 449 while (pos < nCount) { |
450 PAGECHAR_INFO info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); | 450 PAGECHAR_INFO info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); |
451 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { | 451 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
452 continue; | 452 continue; |
453 } | 453 } |
454 if (IsRectIntersect(rect, info_curchar.m_CharBox)) { | 454 if (IsRectIntersect(rect, info_curchar.m_CharBox)) { |
455 if(!pCurObj) { | 455 if(!pCurObj) { |
456 pCurObj = info_curchar.m_pTextObj; | 456 pCurObj = info_curchar.m_pTextObj; |
457 } | 457 } |
458 if (pCurObj != info_curchar.m_pTextObj) { | 458 if (pCurObj != info_curchar.m_pTextObj) { |
459 resRectArray.Add(curRect); | 459 resRectArray.Add(curRect); |
460 pCurObj = info_curchar.m_pTextObj; | 460 pCurObj = info_curchar.m_pTextObj; |
461 flagNewRect = TRUE; | 461 flagNewRect = true; |
462 } | 462 } |
463 if (flagNewRect) { | 463 if (flagNewRect) { |
464 curRect = info_curchar.m_CharBox; | 464 curRect = info_curchar.m_CharBox; |
465 flagNewRect = FALSE; | 465 flagNewRect = false; |
466 curRect.Normalize(); | 466 curRect.Normalize(); |
467 } else { | 467 } else { |
468 info_curchar.m_CharBox.Normalize(); | 468 info_curchar.m_CharBox.Normalize(); |
469 if (curRect.left > info_curchar.m_CharBox.left) { | 469 if (curRect.left > info_curchar.m_CharBox.left) { |
470 curRect.left = info_curchar.m_CharBox.left; | 470 curRect.left = info_curchar.m_CharBox.left; |
471 } | 471 } |
472 if (curRect.right < info_curchar.m_CharBox.right) { | 472 if (curRect.right < info_curchar.m_CharBox.right) { |
473 curRect.right = info_curchar.m_CharBox.right; | 473 curRect.right = info_curchar.m_CharBox.right; |
474 } | 474 } |
475 if ( curRect.top < info_curchar.m_CharBox.top) { | 475 if ( curRect.top < info_curchar.m_CharBox.top) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 return ; | 759 return ; |
760 } | 760 } |
761 if (!m_IsParsered || rectIndex < 0 || rectIndex >= m_SelRects.GetSize()) { | 761 if (!m_IsParsered || rectIndex < 0 || rectIndex >= m_SelRects.GetSize()) { |
762 return; | 762 return; |
763 } | 763 } |
764 left = m_SelRects.GetAt(rectIndex).left; | 764 left = m_SelRects.GetAt(rectIndex).left; |
765 top = m_SelRects.GetAt(rectIndex).top; | 765 top = m_SelRects.GetAt(rectIndex).top; |
766 right = m_SelRects.GetAt(rectIndex).right; | 766 right = m_SelRects.GetAt(rectIndex).right; |
767 bottom = m_SelRects.GetAt(rectIndex).bottom; | 767 bottom = m_SelRects.GetAt(rectIndex).bottom; |
768 } | 768 } |
769 FX_BOOL CPDF_TextPage::GetBaselineRotate(int start, int end, int& Rotate) | 769 bool CPDF_TextPage::GetBaselineRotate(int start, int end, int& Rotate) |
770 { | 770 { |
771 if(m_ParseOptions.m_bGetCharCodeOnly) { | 771 if(m_ParseOptions.m_bGetCharCodeOnly) { |
772 return FALSE; | 772 return false; |
773 } | 773 } |
774 if(end == start) { | 774 if(end == start) { |
775 return FALSE; | 775 return false; |
776 } | 776 } |
777 FX_FLOAT dx, dy; | 777 FX_FLOAT dx, dy; |
778 FPDF_CHAR_INFO info1, info2; | 778 FPDF_CHAR_INFO info1, info2; |
779 GetCharInfo(start, info1); | 779 GetCharInfo(start, info1); |
780 GetCharInfo(end, info2); | 780 GetCharInfo(end, info2); |
781 while(info2.m_CharBox.Width() == 0 || info2.m_CharBox.Height() == 0) { | 781 while(info2.m_CharBox.Width() == 0 || info2.m_CharBox.Height() == 0) { |
782 end--; | 782 end--; |
783 if(end <= start) { | 783 if(end <= start) { |
784 return FALSE; | 784 return false; |
785 } | 785 } |
786 GetCharInfo(end, info2); | 786 GetCharInfo(end, info2); |
787 } | 787 } |
788 dx = (info2.m_OriginX - info1.m_OriginX); | 788 dx = (info2.m_OriginX - info1.m_OriginX); |
789 dy = (info2.m_OriginY - info1.m_OriginY); | 789 dy = (info2.m_OriginY - info1.m_OriginY); |
790 if(dx == 0) { | 790 if(dx == 0) { |
791 if(dy > 0) { | 791 if(dy > 0) { |
792 Rotate = 90; | 792 Rotate = 90; |
793 } else if (dy < 0) { | 793 } else if (dy < 0) { |
794 Rotate = 270; | 794 Rotate = 270; |
795 } else { | 795 } else { |
796 Rotate = 0; | 796 Rotate = 0; |
797 } | 797 } |
798 } else { | 798 } else { |
799 float a = FXSYS_atan2(dy, dx); | 799 float a = FXSYS_atan2(dy, dx); |
800 Rotate = (int)(a * 180 / FX_PI + 0.5); | 800 Rotate = (int)(a * 180 / FX_PI + 0.5); |
801 } | 801 } |
802 if(Rotate < 0) { | 802 if(Rotate < 0) { |
803 Rotate = -Rotate; | 803 Rotate = -Rotate; |
804 } else if(Rotate > 0) { | 804 } else if(Rotate > 0) { |
805 Rotate = 360 - Rotate; | 805 Rotate = 360 - Rotate; |
806 } | 806 } |
807 return TRUE; | 807 return true; |
808 } | 808 } |
809 FX_BOOL»CPDF_TextPage::GetBaselineRotate(const CFX_FloatRect& rect , int& Rotate
) | 809 bool» CPDF_TextPage::GetBaselineRotate(const CFX_FloatRect& rect , int& Rotate
) |
810 { | 810 { |
811 if(m_ParseOptions.m_bGetCharCodeOnly) { | 811 if(m_ParseOptions.m_bGetCharCodeOnly) { |
812 return FALSE; | 812 return false; |
813 } | 813 } |
814 int start, end, count, n = CountBoundedSegments(rect.left, rect.top, rect.ri
ght, rect.bottom, TRUE); | 814 int start, end, count, n = CountBoundedSegments(rect.left, rect.top, rect.ri
ght, rect.bottom, true); |
815 if(n < 1) { | 815 if(n < 1) { |
816 return FALSE; | 816 return false; |
817 } | 817 } |
818 if(n > 1) { | 818 if(n > 1) { |
819 GetBoundedSegment(n - 1, start, count); | 819 GetBoundedSegment(n - 1, start, count); |
820 end = start + count - 1; | 820 end = start + count - 1; |
821 GetBoundedSegment(0, start, count); | 821 GetBoundedSegment(0, start, count); |
822 } else { | 822 } else { |
823 GetBoundedSegment(0, start, count); | 823 GetBoundedSegment(0, start, count); |
824 end = start + count - 1; | 824 end = start + count - 1; |
825 } | 825 } |
826 return GetBaselineRotate(start, end, Rotate); | 826 return GetBaselineRotate(start, end, Rotate); |
827 } | 827 } |
828 FX_BOOL»CPDF_TextPage::GetBaselineRotate(int rectIndex, int& Rotate) | 828 bool» CPDF_TextPage::GetBaselineRotate(int rectIndex, int& Rotate) |
829 { | 829 { |
830 if(m_ParseOptions.m_bGetCharCodeOnly) { | 830 if(m_ParseOptions.m_bGetCharCodeOnly) { |
831 return FALSE; | 831 return false; |
832 } | 832 } |
833 if (!m_IsParsered || rectIndex < 0 || rectIndex > m_SelRects.GetSize()) { | 833 if (!m_IsParsered || rectIndex < 0 || rectIndex > m_SelRects.GetSize()) { |
834 return FALSE; | 834 return false; |
835 } | 835 } |
836 CFX_FloatRect rect = m_SelRects.GetAt(rectIndex); | 836 CFX_FloatRect rect = m_SelRects.GetAt(rectIndex); |
837 return GetBaselineRotate(rect , Rotate); | 837 return GetBaselineRotate(rect , Rotate); |
838 } | 838 } |
839 int» CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOA
T right, FX_FLOAT bottom, FX_BOOL bContains ) | 839 int» CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOA
T right, FX_FLOAT bottom, bool bContains ) |
840 { | 840 { |
841 if(m_ParseOptions.m_bGetCharCodeOnly) { | 841 if(m_ParseOptions.m_bGetCharCodeOnly) { |
842 return -1; | 842 return -1; |
843 } | 843 } |
844 m_Segment.RemoveAll(); | 844 m_Segment.RemoveAll(); |
845 if (!m_IsParsered) { | 845 if (!m_IsParsered) { |
846 return -1; | 846 return -1; |
847 } | 847 } |
848 CFX_FloatRect rect(left, bottom, right, top); | 848 CFX_FloatRect rect(left, bottom, right, top); |
849 rect.Normalize(); | 849 rect.Normalize(); |
850 int nCount = m_charList.GetSize(); | 850 int nCount = m_charList.GetSize(); |
851 int pos = 0; | 851 int pos = 0; |
852 FPDF_SEGMENT segment; | 852 FPDF_SEGMENT segment; |
853 segment.m_Start = 0; | 853 segment.m_Start = 0; |
854 segment.m_nCount = 0; | 854 segment.m_nCount = 0; |
855 FX_BOOL» » segmentStatus = 0; | 855 bool» » segmentStatus = 0; |
856 FX_BOOL» » IsContainPreChar = FALSE; | 856 bool» » IsContainPreChar = false; |
857 while (pos < nCount) { | 857 while (pos < nCount) { |
858 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos); | 858 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos); |
859 if(bContains && rect.Contains(charinfo.m_CharBox)) { | 859 if(bContains && rect.Contains(charinfo.m_CharBox)) { |
860 if (segmentStatus == 0 || segmentStatus == 2) { | 860 if (segmentStatus == 0 || segmentStatus == 2) { |
861 segment.m_Start = pos; | 861 segment.m_Start = pos; |
862 segment.m_nCount = 1; | 862 segment.m_nCount = 1; |
863 segmentStatus = 1; | 863 segmentStatus = 1; |
864 } else if (segmentStatus == 1) { | 864 } else if (segmentStatus == 1) { |
865 segment.m_nCount++; | 865 segment.m_nCount++; |
866 } | 866 } |
867 IsContainPreChar = TRUE; | 867 IsContainPreChar = true; |
868 } else if (!bContains && (IsRectIntersect(rect, charinfo.m_CharBox) || r
ect.Contains(charinfo.m_OriginX, charinfo.m_OriginY))) { | 868 } else if (!bContains && (IsRectIntersect(rect, charinfo.m_CharBox) || r
ect.Contains(charinfo.m_OriginX, charinfo.m_OriginY))) { |
869 if (segmentStatus == 0 || segmentStatus == 2) { | 869 if (segmentStatus == 0 || segmentStatus == 2) { |
870 segment.m_Start = pos; | 870 segment.m_Start = pos; |
871 segment.m_nCount = 1; | 871 segment.m_nCount = 1; |
872 segmentStatus = 1; | 872 segmentStatus = 1; |
873 } else if (segmentStatus == 1) { | 873 } else if (segmentStatus == 1) { |
874 segment.m_nCount++; | 874 segment.m_nCount++; |
875 } | 875 } |
876 IsContainPreChar = TRUE; | 876 IsContainPreChar = true; |
877 } else if (charinfo.m_Unicode == 32) { | 877 } else if (charinfo.m_Unicode == 32) { |
878 if (IsContainPreChar == TRUE) { | 878 if (IsContainPreChar == true) { |
879 if (segmentStatus == 0 || segmentStatus == 2) { | 879 if (segmentStatus == 0 || segmentStatus == 2) { |
880 segment.m_Start = pos; | 880 segment.m_Start = pos; |
881 segment.m_nCount = 1; | 881 segment.m_nCount = 1; |
882 segmentStatus = 1; | 882 segmentStatus = 1; |
883 } else if (segmentStatus == 1) { | 883 } else if (segmentStatus == 1) { |
884 segment.m_nCount++; | 884 segment.m_nCount++; |
885 } | 885 } |
886 IsContainPreChar = FALSE; | 886 IsContainPreChar = false; |
887 } else { | 887 } else { |
888 if (segmentStatus == 1) { | 888 if (segmentStatus == 1) { |
889 segmentStatus = 2; | 889 segmentStatus = 2; |
890 m_Segment.Add(segment); | 890 m_Segment.Add(segment); |
891 segment.m_Start = 0; | 891 segment.m_Start = 0; |
892 segment.m_nCount = 0; | 892 segment.m_nCount = 0; |
893 } | 893 } |
894 } | 894 } |
895 } else { | 895 } else { |
896 if (segmentStatus == 1) { | 896 if (segmentStatus == 1) { |
897 segmentStatus = 2; | 897 segmentStatus = 2; |
898 m_Segment.Add(segment); | 898 m_Segment.Add(segment); |
899 segment.m_Start = 0; | 899 segment.m_Start = 0; |
900 segment.m_nCount = 0; | 900 segment.m_nCount = 0; |
901 } | 901 } |
902 IsContainPreChar = FALSE; | 902 IsContainPreChar = false; |
903 } | 903 } |
904 pos++; | 904 pos++; |
905 } | 905 } |
906 if (segmentStatus == 1) { | 906 if (segmentStatus == 1) { |
907 segmentStatus = 2; | 907 segmentStatus = 2; |
908 m_Segment.Add(segment); | 908 m_Segment.Add(segment); |
909 segment.m_Start = 0; | 909 segment.m_Start = 0; |
910 segment.m_nCount = 0; | 910 segment.m_nCount = 0; |
911 } | 911 } |
912 return m_Segment.GetSize(); | 912 return m_Segment.GetSize(); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 } | 1188 } |
1189 if( !m_ParseOptions.m_bGetCharCodeOnly) { | 1189 if( !m_ParseOptions.m_bGetCharCodeOnly) { |
1190 m_charList.Add(Info); | 1190 m_charList.Add(Info); |
1191 } | 1191 } |
1192 } | 1192 } |
1193 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) | 1193 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) |
1194 { | 1194 { |
1195 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); | 1195 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); |
1196 if(!IsControlChar(&Info)) { | 1196 if(!IsControlChar(&Info)) { |
1197 Info.m_Index = m_TextBuf.GetLength(); | 1197 Info.m_Index = m_TextBuf.GetLength(); |
1198 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); | 1198 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), true, false); |
1199 FX_WCHAR* pDst = NULL; | 1199 FX_WCHAR* pDst = NULL; |
1200 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); | 1200 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); |
1201 if (nCount >= 1) { | 1201 if (nCount >= 1) { |
1202 pDst = FX_Alloc(FX_WCHAR, nCount); | 1202 pDst = FX_Alloc(FX_WCHAR, nCount); |
1203 FX_Unicode_GetNormalization(wChar, pDst); | 1203 FX_Unicode_GetNormalization(wChar, pDst); |
1204 for (int nIndex = 0; nIndex < nCount; nIndex++) { | 1204 for (int nIndex = 0; nIndex < nCount; nIndex++) { |
1205 PAGECHAR_INFO Info2 = Info; | 1205 PAGECHAR_INFO Info2 = Info; |
1206 Info2.m_Unicode = pDst[nIndex]; | 1206 Info2.m_Unicode = pDst[nIndex]; |
1207 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; | 1207 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; |
1208 m_TextBuf.AppendChar(Info2.m_Unicode); | 1208 m_TextBuf.AppendChar(Info2.m_Unicode); |
(...skipping 16 matching lines...) Expand all Loading... |
1225 } | 1225 } |
1226 void CPDF_TextPage::CloseTempLine() | 1226 void CPDF_TextPage::CloseTempLine() |
1227 { | 1227 { |
1228 int count1 = m_TempCharList.GetSize(); | 1228 int count1 = m_TempCharList.GetSize(); |
1229 if (count1 <= 0) { | 1229 if (count1 <= 0) { |
1230 return; | 1230 return; |
1231 } | 1231 } |
1232 nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create()); | 1232 nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create()); |
1233 CFX_WideString str = m_TempTextBuf.GetWideString(); | 1233 CFX_WideString str = m_TempTextBuf.GetWideString(); |
1234 CFX_WordArray order; | 1234 CFX_WordArray order; |
1235 FX_BOOL bR2L = FALSE; | 1235 bool bR2L = false; |
1236 int32_t start = 0, count = 0; | 1236 int32_t start = 0, count = 0; |
1237 int nR2L = 0, nL2R = 0; | 1237 int nR2L = 0, nL2R = 0; |
1238 FX_BOOL bPrevSpace = FALSE; | 1238 bool bPrevSpace = false; |
1239 for (int i = 0; i < str.GetLength(); i++) { | 1239 for (int i = 0; i < str.GetLength(); i++) { |
1240 if(str.GetAt(i) == 32) { | 1240 if(str.GetAt(i) == 32) { |
1241 if(bPrevSpace) { | 1241 if(bPrevSpace) { |
1242 m_TempTextBuf.Delete(i, 1); | 1242 m_TempTextBuf.Delete(i, 1); |
1243 m_TempCharList.Delete(i); | 1243 m_TempCharList.Delete(i); |
1244 str.Delete(i); | 1244 str.Delete(i); |
1245 count1--; | 1245 count1--; |
1246 i--; | 1246 i--; |
1247 continue; | 1247 continue; |
1248 } | 1248 } |
1249 bPrevSpace = TRUE; | 1249 bPrevSpace = true; |
1250 } else { | 1250 } else { |
1251 bPrevSpace = FALSE; | 1251 bPrevSpace = false; |
1252 } | 1252 } |
1253 if(pBidiChar->AppendChar(str.GetAt(i))) { | 1253 if(pBidiChar->AppendChar(str.GetAt(i))) { |
1254 int32_t ret = pBidiChar->GetBidiInfo(start, count); | 1254 int32_t ret = pBidiChar->GetBidiInfo(start, count); |
1255 order.Add(start); | 1255 order.Add(start); |
1256 order.Add(count); | 1256 order.Add(count); |
1257 order.Add(ret); | 1257 order.Add(ret); |
1258 if(!bR2L) { | 1258 if(!bR2L) { |
1259 if(ret == 2) { | 1259 if(ret == 2) { |
1260 nR2L++; | 1260 nR2L++; |
1261 } else if (ret == 1) { | 1261 } else if (ret == 1) { |
1262 nL2R++; | 1262 nL2R++; |
1263 } | 1263 } |
1264 } | 1264 } |
1265 } | 1265 } |
1266 } | 1266 } |
1267 if(pBidiChar->EndChar()) { | 1267 if(pBidiChar->EndChar()) { |
1268 int32_t ret = pBidiChar->GetBidiInfo(start, count); | 1268 int32_t ret = pBidiChar->GetBidiInfo(start, count); |
1269 order.Add(start); | 1269 order.Add(start); |
1270 order.Add(count); | 1270 order.Add(count); |
1271 order.Add(ret); | 1271 order.Add(ret); |
1272 if(!bR2L) { | 1272 if(!bR2L) { |
1273 if(ret == 2) { | 1273 if(ret == 2) { |
1274 nR2L++; | 1274 nR2L++; |
1275 } else if(ret == 1) { | 1275 } else if(ret == 1) { |
1276 nL2R++; | 1276 nL2R++; |
1277 } | 1277 } |
1278 } | 1278 } |
1279 } | 1279 } |
1280 if(nR2L > 0 && nR2L >= nL2R) { | 1280 if(nR2L > 0 && nR2L >= nL2R) { |
1281 bR2L = TRUE; | 1281 bR2L = true; |
1282 } | 1282 } |
1283 if (m_parserflag == FPDFTEXT_RLTB || bR2L) { | 1283 if (m_parserflag == FPDFTEXT_RLTB || bR2L) { |
1284 int count = order.GetSize(); | 1284 int count = order.GetSize(); |
1285 for(int i = count - 1; i > 0; i -= 3) { | 1285 for(int i = count - 1; i > 0; i -= 3) { |
1286 int ret = order.GetAt(i); | 1286 int ret = order.GetAt(i); |
1287 int start = order.GetAt(i - 2); | 1287 int start = order.GetAt(i - 2); |
1288 int count1 = order.GetAt(i - 1); | 1288 int count1 = order.GetAt(i - 1); |
1289 if(ret == 2 || ret == 0) { | 1289 if(ret == 2 || ret == 0) { |
1290 for(int j = start + count1 - 1; j >= start; j--) { | 1290 for(int j = start + count1 - 1; j >= start; j--) { |
1291 AddCharInfoByRLDirection(str, j); | 1291 AddCharInfoByRLDirection(str, j); |
1292 } | 1292 } |
1293 } else { | 1293 } else { |
1294 int j = i; | 1294 int j = i; |
1295 FX_BOOL bSymbol = FALSE; | 1295 bool bSymbol = false; |
1296 while(j > 0 && order.GetAt(j) != 2) { | 1296 while(j > 0 && order.GetAt(j) != 2) { |
1297 bSymbol = !order.GetAt(j); | 1297 bSymbol = !order.GetAt(j); |
1298 j -= 3; | 1298 j -= 3; |
1299 } | 1299 } |
1300 int end = start + count1 ; | 1300 int end = start + count1 ; |
1301 int n = 0; | 1301 int n = 0; |
1302 if(bSymbol) { | 1302 if(bSymbol) { |
1303 n = j + 6; | 1303 n = j + 6; |
1304 } else { | 1304 } else { |
1305 n = j + 3; | 1305 n = j + 3; |
(...skipping 11 matching lines...) Expand all Loading... |
1317 int end = start + count1 ; | 1317 int end = start + count1 ; |
1318 for(int m = start; m < end; m++) { | 1318 for(int m = start; m < end; m++) { |
1319 AddCharInfoByLRDirection(str, m); | 1319 AddCharInfoByLRDirection(str, m); |
1320 } | 1320 } |
1321 } | 1321 } |
1322 } | 1322 } |
1323 } | 1323 } |
1324 } | 1324 } |
1325 } else { | 1325 } else { |
1326 int count = order.GetSize(); | 1326 int count = order.GetSize(); |
1327 FX_BOOL bL2R = FALSE; | 1327 bool bL2R = false; |
1328 for(int i = 0; i < count; i += 3) { | 1328 for(int i = 0; i < count; i += 3) { |
1329 int ret = order.GetAt(i + 2); | 1329 int ret = order.GetAt(i + 2); |
1330 int start = order.GetAt(i); | 1330 int start = order.GetAt(i); |
1331 int count1 = order.GetAt(i + 1); | 1331 int count1 = order.GetAt(i + 1); |
1332 if(ret == 2 || (i == 0 && ret == 0 && !bL2R)) { | 1332 if(ret == 2 || (i == 0 && ret == 0 && !bL2R)) { |
1333 int j = i + 3; | 1333 int j = i + 3; |
1334 while(bR2L && j < count) { | 1334 while(bR2L && j < count) { |
1335 if(order.GetAt(j + 2) == 1) { | 1335 if(order.GetAt(j + 2) == 1) { |
1336 break; | 1336 break; |
1337 } else { | 1337 } else { |
1338 j += 3; | 1338 j += 3; |
1339 } | 1339 } |
1340 } | 1340 } |
1341 if(j == 3) { | 1341 if(j == 3) { |
1342 i = -3; | 1342 i = -3; |
1343 bL2R = TRUE; | 1343 bL2R = true; |
1344 continue; | 1344 continue; |
1345 } | 1345 } |
1346 int end = m_TempCharList.GetSize() - 1; | 1346 int end = m_TempCharList.GetSize() - 1; |
1347 if(j < count) { | 1347 if(j < count) { |
1348 end = order.GetAt(j) - 1; | 1348 end = order.GetAt(j) - 1; |
1349 } | 1349 } |
1350 i = j - 3; | 1350 i = j - 3; |
1351 for(int n = end; n >= start; n--) { | 1351 for(int n = end; n >= start; n--) { |
1352 AddCharInfoByRLDirection(str, n); | 1352 AddCharInfoByRLDirection(str, n); |
1353 } | 1353 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1443 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
1444 CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_Content
Mark.GetObject(); | 1444 CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_Content
Mark.GetObject(); |
1445 if(!pMarkData) { | 1445 if(!pMarkData) { |
1446 return FPDFTEXT_MC_PASS; | 1446 return FPDFTEXT_MC_PASS; |
1447 } | 1447 } |
1448 int nContentMark = pMarkData->CountItems(); | 1448 int nContentMark = pMarkData->CountItems(); |
1449 if (nContentMark < 1) { | 1449 if (nContentMark < 1) { |
1450 return FPDFTEXT_MC_PASS; | 1450 return FPDFTEXT_MC_PASS; |
1451 } | 1451 } |
1452 CFX_WideString actText; | 1452 CFX_WideString actText; |
1453 FX_BOOL bExist = FALSE; | 1453 bool bExist = false; |
1454 CPDF_Dictionary* pDict = NULL; | 1454 CPDF_Dictionary* pDict = NULL; |
1455 int n = 0; | 1455 int n = 0; |
1456 for (n = 0; n < nContentMark; n++) { | 1456 for (n = 0; n < nContentMark; n++) { |
1457 CPDF_ContentMarkItem& item = pMarkData->GetItem(n); | 1457 CPDF_ContentMarkItem& item = pMarkData->GetItem(n); |
1458 CFX_ByteString tagStr = (CFX_ByteString)item.GetName(); | 1458 CFX_ByteString tagStr = (CFX_ByteString)item.GetName(); |
1459 pDict = (CPDF_Dictionary*)item.GetParam(); | 1459 pDict = (CPDF_Dictionary*)item.GetParam(); |
1460 CPDF_String* temp = (CPDF_String*)(pDict ? pDict->GetElement(FX_BSTRC("A
ctualText")) : NULL); | 1460 CPDF_String* temp = (CPDF_String*)(pDict ? pDict->GetElement(FX_BSTRC("A
ctualText")) : NULL); |
1461 if (temp) { | 1461 if (temp) { |
1462 bExist = TRUE; | 1462 bExist = true; |
1463 actText = temp->GetUnicodeText(); | 1463 actText = temp->GetUnicodeText(); |
1464 } | 1464 } |
1465 } | 1465 } |
1466 if (!bExist) { | 1466 if (!bExist) { |
1467 return FPDFTEXT_MC_PASS; | 1467 return FPDFTEXT_MC_PASS; |
1468 } | 1468 } |
1469 if (m_pPreTextObj) { | 1469 if (m_pPreTextObj) { |
1470 if (CPDF_ContentMarkData* pPreMarkData = (CPDF_ContentMarkData*)m_pPreTe
xtObj->m_ContentMark.GetObject()) { | 1470 if (CPDF_ContentMarkData* pPreMarkData = (CPDF_ContentMarkData*)m_pPreTe
xtObj->m_ContentMark.GetObject()) { |
1471 if (pPreMarkData->CountItems() == n) { | 1471 if (pPreMarkData->CountItems() == n) { |
1472 CPDF_ContentMarkItem& item = pPreMarkData->GetItem(n - 1); | 1472 CPDF_ContentMarkItem& item = pPreMarkData->GetItem(n - 1); |
1473 if (pDict == item.GetParam()) { | 1473 if (pDict == item.GetParam()) { |
1474 return FPDFTEXT_MC_DONE; | 1474 return FPDFTEXT_MC_DONE; |
1475 } | 1475 } |
1476 } | 1476 } |
1477 } | 1477 } |
1478 } | 1478 } |
1479 CPDF_Font* pFont = pTextObj->GetFont(); | 1479 CPDF_Font* pFont = pTextObj->GetFont(); |
1480 FX_STRSIZE nItems = actText.GetLength(); | 1480 FX_STRSIZE nItems = actText.GetLength(); |
1481 if (nItems < 1) { | 1481 if (nItems < 1) { |
1482 return FPDFTEXT_MC_PASS; | 1482 return FPDFTEXT_MC_PASS; |
1483 } | 1483 } |
1484 bExist = FALSE; | 1484 bExist = false; |
1485 for (FX_STRSIZE i = 0; i < nItems; i++) { | 1485 for (FX_STRSIZE i = 0; i < nItems; i++) { |
1486 FX_WCHAR wChar = actText.GetAt(i); | 1486 FX_WCHAR wChar = actText.GetAt(i); |
1487 if (-1 == pFont->CharCodeFromUnicode(wChar)) { | 1487 if (-1 == pFont->CharCodeFromUnicode(wChar)) { |
1488 continue; | 1488 continue; |
1489 } else { | 1489 } else { |
1490 bExist = TRUE; | 1490 bExist = true; |
1491 break; | 1491 break; |
1492 } | 1492 } |
1493 } | 1493 } |
1494 if (!bExist) { | 1494 if (!bExist) { |
1495 return FPDFTEXT_MC_PASS; | 1495 return FPDFTEXT_MC_PASS; |
1496 } | 1496 } |
1497 bExist = FALSE; | 1497 bExist = false; |
1498 for (FX_STRSIZE i = 0; i < nItems; i++) { | 1498 for (FX_STRSIZE i = 0; i < nItems; i++) { |
1499 FX_WCHAR wChar = actText.GetAt(i); | 1499 FX_WCHAR wChar = actText.GetAt(i); |
1500 if ((wChar > 0x80 && wChar < 0xFFFD) || (wChar <= 0x80 && isprint(wChar)
)) { | 1500 if ((wChar > 0x80 && wChar < 0xFFFD) || (wChar <= 0x80 && isprint(wChar)
)) { |
1501 bExist = TRUE; | 1501 bExist = true; |
1502 break; | 1502 break; |
1503 } | 1503 } |
1504 } | 1504 } |
1505 if (!bExist) { | 1505 if (!bExist) { |
1506 return FPDFTEXT_MC_DONE; | 1506 return FPDFTEXT_MC_DONE; |
1507 } | 1507 } |
1508 return FPDFTEXT_MC_DELAY; | 1508 return FPDFTEXT_MC_DELAY; |
1509 } | 1509 } |
1510 void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) | 1510 void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) |
1511 { | 1511 { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 ProcessMarkedContent(Obj); | 1675 ProcessMarkedContent(Obj); |
1676 m_pPreTextObj = pTextObj; | 1676 m_pPreTextObj = pTextObj; |
1677 m_perMatrix.Copy(formMatrix); | 1677 m_perMatrix.Copy(formMatrix); |
1678 return; | 1678 return; |
1679 } | 1679 } |
1680 m_pPreTextObj = pTextObj; | 1680 m_pPreTextObj = pTextObj; |
1681 m_perMatrix.Copy(formMatrix); | 1681 m_perMatrix.Copy(formMatrix); |
1682 int nItems = pTextObj->CountItems(); | 1682 int nItems = pTextObj->CountItems(); |
1683 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); | 1683 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); |
1684 | 1684 |
1685 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); | 1685 const bool bR2L = IsRightToLeft(pTextObj, pFont, nItems); |
1686 const FX_BOOL bIsBidiAndMirrorInverse = | 1686 const bool bIsBidiAndMirrorInverse = |
1687 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; | 1687 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; |
1688 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); | 1688 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); |
1689 int32_t iCharListStartAppend = m_TempCharList.GetSize(); | 1689 int32_t iCharListStartAppend = m_TempCharList.GetSize(); |
1690 | 1690 |
1691 FX_FLOAT spacing = 0; | 1691 FX_FLOAT spacing = 0; |
1692 for (int i = 0; i < nItems; i++) { | 1692 for (int i = 0; i < nItems; i++) { |
1693 CPDF_TextObjectItem item; | 1693 CPDF_TextObjectItem item; |
1694 PAGECHAR_INFO charinfo; | 1694 PAGECHAR_INFO charinfo; |
1695 charinfo.m_OriginX = 0; | 1695 charinfo.m_OriginX = 0; |
1696 charinfo.m_OriginY = 0; | 1696 charinfo.m_OriginY = 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_Orig
inX, charinfo.m_OriginY); | 1745 matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_Orig
inX, charinfo.m_OriginY); |
1746 charinfo.m_CharBox = CFX_FloatRect(charinfo.m_OriginX, charinfo.
m_OriginY, charinfo.m_OriginX, charinfo.m_OriginY); | 1746 charinfo.m_CharBox = CFX_FloatRect(charinfo.m_OriginX, charinfo.
m_OriginY, charinfo.m_OriginX, charinfo.m_OriginY); |
1747 m_TempCharList.Add(charinfo); | 1747 m_TempCharList.Add(charinfo); |
1748 } | 1748 } |
1749 if (item.m_CharCode == (FX_DWORD) - 1) { | 1749 if (item.m_CharCode == (FX_DWORD) - 1) { |
1750 continue; | 1750 continue; |
1751 } | 1751 } |
1752 } | 1752 } |
1753 spacing = 0; | 1753 spacing = 0; |
1754 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); | 1754 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); |
1755 FX_BOOL bNoUnicode = FALSE; | 1755 bool bNoUnicode = false; |
1756 FX_WCHAR wChar = wstrItem.GetAt(0); | 1756 FX_WCHAR wChar = wstrItem.GetAt(0); |
1757 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { | 1757 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { |
1758 if(wstrItem.IsEmpty()) { | 1758 if(wstrItem.IsEmpty()) { |
1759 wstrItem += (FX_WCHAR)item.m_CharCode; | 1759 wstrItem += (FX_WCHAR)item.m_CharCode; |
1760 } else { | 1760 } else { |
1761 wstrItem.SetAt(0, (FX_WCHAR)item.m_CharCode); | 1761 wstrItem.SetAt(0, (FX_WCHAR)item.m_CharCode); |
1762 } | 1762 } |
1763 bNoUnicode = TRUE; | 1763 bNoUnicode = true; |
1764 } | 1764 } |
1765 charinfo.m_Index = -1; | 1765 charinfo.m_Index = -1; |
1766 charinfo.m_CharCode = item.m_CharCode; | 1766 charinfo.m_CharCode = item.m_CharCode; |
1767 if(bNoUnicode) { | 1767 if(bNoUnicode) { |
1768 charinfo.m_Flag = FPDFTEXT_CHAR_UNUNICODE; | 1768 charinfo.m_Flag = FPDFTEXT_CHAR_UNUNICODE; |
1769 } else { | 1769 } else { |
1770 charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL; | 1770 charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL; |
1771 } | 1771 } |
1772 charinfo.m_pTextObj = pTextObj; | 1772 charinfo.m_pTextObj = pTextObj; |
1773 charinfo.m_OriginX = 0, charinfo.m_OriginY = 0; | 1773 charinfo.m_OriginX = 0, charinfo.m_OriginY = 0; |
(...skipping 13 matching lines...) Expand all Loading... |
1787 } | 1787 } |
1788 matrix.TransformRect(charinfo.m_CharBox); | 1788 matrix.TransformRect(charinfo.m_CharBox); |
1789 charinfo.m_Matrix.Copy(matrix); | 1789 charinfo.m_Matrix.Copy(matrix); |
1790 if (wstrItem.IsEmpty()) { | 1790 if (wstrItem.IsEmpty()) { |
1791 charinfo.m_Unicode = 0; | 1791 charinfo.m_Unicode = 0; |
1792 m_TempCharList.Add(charinfo); | 1792 m_TempCharList.Add(charinfo); |
1793 m_TempTextBuf.AppendChar(0xfffe); | 1793 m_TempTextBuf.AppendChar(0xfffe); |
1794 continue; | 1794 continue; |
1795 } else { | 1795 } else { |
1796 int nTotal = wstrItem.GetLength(); | 1796 int nTotal = wstrItem.GetLength(); |
1797 FX_BOOL bDel = FALSE; | 1797 bool bDel = false; |
1798 const int count = std::min(m_TempCharList.GetSize(), 7); | 1798 const int count = std::min(m_TempCharList.GetSize(), 7); |
1799 FX_FLOAT threshold = charinfo.m_Matrix.TransformXDistance((FX_FLOAT)
TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); | 1799 FX_FLOAT threshold = charinfo.m_Matrix.TransformXDistance((FX_FLOAT)
TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); |
1800 for (int n = m_TempCharList.GetSize(); | 1800 for (int n = m_TempCharList.GetSize(); |
1801 n > m_TempCharList.GetSize() - count; | 1801 n > m_TempCharList.GetSize() - count; |
1802 n--) { | 1802 n--) { |
1803 PAGECHAR_INFO* charinfo1 = (PAGECHAR_INFO*)m_TempCharList.GetAt(
n - 1); | 1803 PAGECHAR_INFO* charinfo1 = (PAGECHAR_INFO*)m_TempCharList.GetAt(
n - 1); |
1804 if(charinfo1->m_CharCode == charinfo.m_CharCode && | 1804 if(charinfo1->m_CharCode == charinfo.m_CharCode && |
1805 charinfo1->m_pTextObj->GetFont() == charinfo.m_pTextObj-
>GetFont() && | 1805 charinfo1->m_pTextObj->GetFont() == charinfo.m_pTextObj-
>GetFont() && |
1806 FXSYS_fabs(charinfo1->m_OriginX - charinfo.m_OriginX) <
threshold && | 1806 FXSYS_fabs(charinfo1->m_OriginX - charinfo.m_OriginX) <
threshold && |
1807 FXSYS_fabs(charinfo1->m_OriginY - charinfo.m_OriginY) <
threshold) { | 1807 FXSYS_fabs(charinfo1->m_OriginY - charinfo.m_OriginY) <
threshold) { |
1808 bDel = TRUE; | 1808 bDel = true; |
1809 break; | 1809 break; |
1810 } | 1810 } |
1811 } | 1811 } |
1812 if(!bDel) { | 1812 if(!bDel) { |
1813 for (int nIndex = 0; nIndex < nTotal; nIndex++) { | 1813 for (int nIndex = 0; nIndex < nTotal; nIndex++) { |
1814 charinfo.m_Unicode = wstrItem.GetAt(nIndex); | 1814 charinfo.m_Unicode = wstrItem.GetAt(nIndex); |
1815 if (charinfo.m_Unicode) { | 1815 if (charinfo.m_Unicode) { |
1816 charinfo.m_Index = m_TextBuf.GetLength(); | 1816 charinfo.m_Index = m_TextBuf.GetLength(); |
1817 m_TempTextBuf.AppendChar(charinfo.m_Unicode); | 1817 m_TempTextBuf.AppendChar(charinfo.m_Unicode); |
1818 } else { | 1818 } else { |
(...skipping 24 matching lines...) Expand all Loading... |
1843 std::swap(m_TempCharList[i], m_TempCharList[j]); | 1843 std::swap(m_TempCharList[i], m_TempCharList[j]); |
1844 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); | 1844 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); |
1845 } | 1845 } |
1846 FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer(); | 1846 FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer(); |
1847 i = iBufStartAppend; | 1847 i = iBufStartAppend; |
1848 j = m_TempTextBuf.GetLength() - 1; | 1848 j = m_TempTextBuf.GetLength() - 1; |
1849 for (; i < j; i++, j--) { | 1849 for (; i < j; i++, j--) { |
1850 std::swap(pTempBuffer[i], pTempBuffer[j]); | 1850 std::swap(pTempBuffer[i], pTempBuffer[j]); |
1851 } | 1851 } |
1852 } | 1852 } |
1853 FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, | 1853 bool CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, |
1854 const CPDF_Font* pFont, | 1854 const CPDF_Font* pFont, |
1855 int nItems) const | 1855 int nItems) const |
1856 { | 1856 { |
1857 nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create()); | 1857 nonstd::unique_ptr<IFX_BidiChar> pBidiChar(IFX_BidiChar::Create()); |
1858 int32_t nR2L = 0; | 1858 int32_t nR2L = 0; |
1859 int32_t nL2R = 0; | 1859 int32_t nL2R = 0; |
1860 int32_t start = 0, count = 0; | 1860 int32_t start = 0, count = 0; |
1861 CPDF_TextObjectItem item; | 1861 CPDF_TextObjectItem item; |
1862 for (int32_t i = 0; i < nItems; i++) { | 1862 for (int32_t i = 0; i < nItems; i++) { |
1863 pTextObj->GetItemInfo(i, &item); | 1863 pTextObj->GetItemInfo(i, &item); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 if (v.y <= 0.0872f) { | 1917 if (v.y <= 0.0872f) { |
1918 if (v.x <= 0.0872f) { | 1918 if (v.x <= 0.0872f) { |
1919 return m_TextlineDir; | 1919 return m_TextlineDir; |
1920 } | 1920 } |
1921 return 0; | 1921 return 0; |
1922 } else if (v.x <= 0.0872f) { | 1922 } else if (v.x <= 0.0872f) { |
1923 return 1; | 1923 return 1; |
1924 } | 1924 } |
1925 return m_TextlineDir; | 1925 return m_TextlineDir; |
1926 } | 1926 } |
1927 FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) | 1927 bool CPDF_TextPage::IsHyphen(FX_WCHAR curChar) |
1928 { | 1928 { |
1929 CFX_WideString strCurText = m_TempTextBuf.GetWideString(); | 1929 CFX_WideString strCurText = m_TempTextBuf.GetWideString(); |
1930 if(strCurText.GetLength() == 0) { | 1930 if(strCurText.GetLength() == 0) { |
1931 strCurText = m_TextBuf.GetWideString(); | 1931 strCurText = m_TextBuf.GetWideString(); |
1932 } | 1932 } |
1933 FX_STRSIZE nCount = strCurText.GetLength(); | 1933 FX_STRSIZE nCount = strCurText.GetLength(); |
1934 int nIndex = nCount - 1; | 1934 int nIndex = nCount - 1; |
1935 FX_WCHAR wcTmp = strCurText.GetAt(nIndex); | 1935 FX_WCHAR wcTmp = strCurText.GetAt(nIndex); |
1936 while(wcTmp == 0x20 && nIndex <= nCount - 1 && nIndex >= 0) { | 1936 while(wcTmp == 0x20 && nIndex <= nCount - 1 && nIndex >= 0) { |
1937 wcTmp = strCurText.GetAt(--nIndex); | 1937 wcTmp = strCurText.GetAt(--nIndex); |
1938 } | 1938 } |
1939 if (0x2D == wcTmp || 0xAD == wcTmp) { | 1939 if (0x2D == wcTmp || 0xAD == wcTmp) { |
1940 if (--nIndex > 0) { | 1940 if (--nIndex > 0) { |
1941 FX_WCHAR preChar = strCurText.GetAt((nIndex)); | 1941 FX_WCHAR preChar = strCurText.GetAt((nIndex)); |
1942 if (((preChar >= L'A' && preChar <= L'Z') || (preChar >= L'a' && pre
Char <= L'z')) | 1942 if (((preChar >= L'A' && preChar <= L'Z') || (preChar >= L'a' && pre
Char <= L'z')) |
1943 && ((curChar >= L'A' && curChar <= L'Z') || (curChar >= L'a'
&& curChar <= L'z'))) { | 1943 && ((curChar >= L'A' && curChar <= L'Z') || (curChar >= L'a'
&& curChar <= L'z'))) { |
1944 return TRUE; | 1944 return true; |
1945 } | 1945 } |
1946 } | 1946 } |
1947 int size = m_TempCharList.GetSize(); | 1947 int size = m_TempCharList.GetSize(); |
1948 PAGECHAR_INFO preChar; | 1948 PAGECHAR_INFO preChar; |
1949 if (size) { | 1949 if (size) { |
1950 preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; | 1950 preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; |
1951 } else { | 1951 } else { |
1952 size = m_charList.GetSize(); | 1952 size = m_charList.GetSize(); |
1953 if(size == 0) { | 1953 if(size == 0) { |
1954 return FALSE; | 1954 return false; |
1955 } | 1955 } |
1956 preChar = (PAGECHAR_INFO)m_charList[size - 1]; | 1956 preChar = (PAGECHAR_INFO)m_charList[size - 1]; |
1957 } | 1957 } |
1958 if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag) | 1958 if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag) |
1959 if (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode) { | 1959 if (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode) { |
1960 return TRUE; | 1960 return true; |
1961 } | 1961 } |
1962 } | 1962 } |
1963 return FALSE; | 1963 return false; |
1964 } | 1964 } |
1965 int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, const CFX_Af
fineMatrix& formMatrix) | 1965 int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, const CFX_Af
fineMatrix& formMatrix) |
1966 { | 1966 { |
1967 FindPreviousTextObject(); | 1967 FindPreviousTextObject(); |
1968 FX_BOOL bNewline = FALSE; | 1968 bool bNewline = false; |
1969 int WritingMode = GetTextObjectWritingMode(pObj); | 1969 int WritingMode = GetTextObjectWritingMode(pObj); |
1970 if(WritingMode == -1) { | 1970 if(WritingMode == -1) { |
1971 WritingMode = GetTextObjectWritingMode(m_pPreTextObj); | 1971 WritingMode = GetTextObjectWritingMode(m_pPreTextObj); |
1972 } | 1972 } |
1973 CFX_FloatRect this_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pObj->m
_Top); | 1973 CFX_FloatRect this_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pObj->m
_Top); |
1974 CFX_FloatRect prev_rect(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, m_pP
reTextObj->m_Right, m_pPreTextObj->m_Top); | 1974 CFX_FloatRect prev_rect(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, m_pP
reTextObj->m_Right, m_pPreTextObj->m_Top); |
1975 CPDF_TextObjectItem PrevItem, item; | 1975 CPDF_TextObjectItem PrevItem, item; |
1976 int nItem = m_pPreTextObj->CountItems(); | 1976 int nItem = m_pPreTextObj->CountItems(); |
1977 m_pPreTextObj->GetItemInfo(nItem - 1, &PrevItem); | 1977 m_pPreTextObj->GetItemInfo(nItem - 1, &PrevItem); |
1978 pObj->GetItemInfo(0, &item); | 1978 pObj->GetItemInfo(0, &item); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 prev_reverse.Transform(x, y); | 2022 prev_reverse.Transform(x, y); |
2023 if(last_width < this_width) { | 2023 if(last_width < this_width) { |
2024 threshold = prev_reverse.TransformDistance(threshold); | 2024 threshold = prev_reverse.TransformDistance(threshold); |
2025 } | 2025 } |
2026 CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom, m_pPreTextObj->m_
Right, pObj->m_Top); | 2026 CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom, m_pPreTextObj->m_
Right, pObj->m_Top); |
2027 CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, m_pPreTe
xtObj->m_Right, m_pPreTextObj->m_Top); | 2027 CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, m_pPreTe
xtObj->m_Right, m_pPreTextObj->m_Top); |
2028 CFX_FloatRect rect3 = rect1; | 2028 CFX_FloatRect rect3 = rect1; |
2029 rect1.Intersect(rect2); | 2029 rect1.Intersect(rect2); |
2030 if (WritingMode == 0) { | 2030 if (WritingMode == 0) { |
2031 if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) | 2031 if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) |
2032 || ((y > threshold * 2 || y < threshold * -3) && (FXSYS_fabs(y)
< 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : TRUE))) { | 2032 || ((y > threshold * 2 || y < threshold * -3) && (FXSYS_fabs(y)
< 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : true))) { |
2033 bNewline = TRUE; | 2033 bNewline = true; |
2034 if(nItem > 1 ) { | 2034 if(nItem > 1 ) { |
2035 CPDF_TextObjectItem tempItem; | 2035 CPDF_TextObjectItem tempItem; |
2036 m_pPreTextObj->GetItemInfo(0, &tempItem); | 2036 m_pPreTextObj->GetItemInfo(0, &tempItem); |
2037 CFX_AffineMatrix m; | 2037 CFX_AffineMatrix m; |
2038 m_pPreTextObj->GetTextMatrix(&m); | 2038 m_pPreTextObj->GetTextMatrix(&m); |
2039 if(PrevItem.m_OriginX > tempItem.m_OriginX && | 2039 if(PrevItem.m_OriginX > tempItem.m_OriginX && |
2040 m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && | 2040 m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && |
2041 m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 | 2041 m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 |
2042 && m.b < 0.1 && m.c < 0.1 ) { | 2042 && m.b < 0.1 && m.c < 0.1 ) { |
2043 CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000, m_pPreTex
tObj->m_Top); | 2043 CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000, m_pPreTex
tObj->m_Top); |
2044 if(re.Contains(pObj->GetPosX(), pObj->GetPosY())) { | 2044 if(re.Contains(pObj->GetPosX(), pObj->GetPosY())) { |
2045 bNewline = FALSE; | 2045 bNewline = false; |
2046 } else { | 2046 } else { |
2047 CFX_FloatRect re(0, pObj->m_Bottom, 1000, pObj->m_Top); | 2047 CFX_FloatRect re(0, pObj->m_Bottom, 1000, pObj->m_Top); |
2048 if(re.Contains(m_pPreTextObj->GetPosX(), m_pPreTextObj->
GetPosY())) { | 2048 if(re.Contains(m_pPreTextObj->GetPosX(), m_pPreTextObj->
GetPosY())) { |
2049 bNewline = FALSE; | 2049 bNewline = false; |
2050 } | 2050 } |
2051 } | 2051 } |
2052 } | 2052 } |
2053 } | 2053 } |
2054 } | 2054 } |
2055 } | 2055 } |
2056 if(bNewline) { | 2056 if(bNewline) { |
2057 if(IsHyphen(curChar)) { | 2057 if(IsHyphen(curChar)) { |
2058 return 3; | 2058 return 3; |
2059 } | 2059 } |
(...skipping 30 matching lines...) Expand all Loading... |
2090 } | 2090 } |
2091 if(x < 0 && (last_pos - x - last_width) > threshold) { | 2091 if(x < 0 && (last_pos - x - last_width) > threshold) { |
2092 return 1; | 2092 return 1; |
2093 } | 2093 } |
2094 if((x - last_pos - last_width) > this_width || (x - last_pos - this_
width) > last_width ) { | 2094 if((x - last_pos - last_width) > this_width || (x - last_pos - this_
width) > last_width ) { |
2095 return 1; | 2095 return 1; |
2096 } | 2096 } |
2097 } | 2097 } |
2098 return 0; | 2098 return 0; |
2099 } | 2099 } |
2100 FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, CPDF_TextObj
ect* pTextObj2) | 2100 bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, CPDF_TextObject
* pTextObj2) |
2101 { | 2101 { |
2102 if (!pTextObj1 || !pTextObj2) { | 2102 if (!pTextObj1 || !pTextObj2) { |
2103 return FALSE; | 2103 return false; |
2104 } | 2104 } |
2105 CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom, pTextObj2->m_
Right, pTextObj2->m_Top); | 2105 CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom, pTextObj2->m_
Right, pTextObj2->m_Top); |
2106 CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom, pTextObj1->m_
Right, pTextObj1->m_Top); | 2106 CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom, pTextObj1->m_
Right, pTextObj1->m_Top); |
2107 if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty() && !m_ParseOptions.m_bGetCharCo
deOnly) { | 2107 if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty() && !m_ParseOptions.m_bGetCharCo
deOnly) { |
2108 FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); | 2108 FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); |
2109 int nCount = m_charList.GetSize(); | 2109 int nCount = m_charList.GetSize(); |
2110 if (nCount >= 2) { | 2110 if (nCount >= 2) { |
2111 PAGECHAR_INFO perCharTemp = (PAGECHAR_INFO)m_charList[nCount - 2]; | 2111 PAGECHAR_INFO perCharTemp = (PAGECHAR_INFO)m_charList[nCount - 2]; |
2112 FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); | 2112 FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); |
2113 if (dbXdif > dbSpace) { | 2113 if (dbXdif > dbSpace) { |
2114 return FALSE; | 2114 return false; |
2115 } | 2115 } |
2116 } | 2116 } |
2117 } | 2117 } |
2118 if (!rcPreObj.IsEmpty() || !rcCurObj.IsEmpty()) { | 2118 if (!rcPreObj.IsEmpty() || !rcCurObj.IsEmpty()) { |
2119 rcPreObj.Intersect(rcCurObj); | 2119 rcPreObj.Intersect(rcCurObj); |
2120 if (rcPreObj.IsEmpty()) { | 2120 if (rcPreObj.IsEmpty()) { |
2121 return FALSE; | 2121 return false; |
2122 } | 2122 } |
2123 if (FXSYS_fabs(rcPreObj.Width() - rcCurObj.Width()) > rcCurObj.Width() /
2) { | 2123 if (FXSYS_fabs(rcPreObj.Width() - rcCurObj.Width()) > rcCurObj.Width() /
2) { |
2124 return FALSE; | 2124 return false; |
2125 } | 2125 } |
2126 if (pTextObj2->GetFontSize() != pTextObj1->GetFontSize()) { | 2126 if (pTextObj2->GetFontSize() != pTextObj1->GetFontSize()) { |
2127 return FALSE; | 2127 return false; |
2128 } | 2128 } |
2129 } | 2129 } |
2130 int nPreCount = pTextObj2->CountItems(); | 2130 int nPreCount = pTextObj2->CountItems(); |
2131 int nCurCount = pTextObj1->CountItems(); | 2131 int nCurCount = pTextObj1->CountItems(); |
2132 if (nPreCount != nCurCount) { | 2132 if (nPreCount != nCurCount) { |
2133 return FALSE; | 2133 return false; |
2134 } | 2134 } |
2135 CPDF_TextObjectItem itemPer, itemCur; | 2135 CPDF_TextObjectItem itemPer, itemCur; |
2136 for (int i = 0; i < nPreCount; i++) { | 2136 for (int i = 0; i < nPreCount; i++) { |
2137 pTextObj2->GetItemInfo(i, &itemPer); | 2137 pTextObj2->GetItemInfo(i, &itemPer); |
2138 pTextObj1->GetItemInfo(i, &itemCur); | 2138 pTextObj1->GetItemInfo(i, &itemCur); |
2139 if (itemCur.m_CharCode != itemPer.m_CharCode) { | 2139 if (itemCur.m_CharCode != itemPer.m_CharCode) { |
2140 return FALSE; | 2140 return false; |
2141 } | 2141 } |
2142 } | 2142 } |
2143 if(FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) > GetCharWidth(it
emPer.m_CharCode, pTextObj2->GetFont())*pTextObj2->GetFontSize() / 1000 * 0.9 || | 2143 if(FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) > GetCharWidth(it
emPer.m_CharCode, pTextObj2->GetFont())*pTextObj2->GetFontSize() / 1000 * 0.9 || |
2144 FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > | 2144 FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > |
2145 FX_MAX(FX_MAX(rcPreObj.Height() , rcPreObj.Width()), pTextObj2->GetF
ontSize()) / 8) { | 2145 FX_MAX(FX_MAX(rcPreObj.Height() , rcPreObj.Width()), pTextObj2->GetF
ontSize()) / 8) { |
2146 return FALSE; | 2146 return false; |
2147 } | 2147 } |
2148 return TRUE; | 2148 return true; |
2149 } | 2149 } |
2150 FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(CPDF_TextObject* pTextObj, FX_POSIT
ION ObjPos) | 2150 bool CPDF_TextPage::IsSameAsPreTextObject(CPDF_TextObject* pTextObj, FX_POSITION
ObjPos) |
2151 { | 2151 { |
2152 if (!pTextObj) { | 2152 if (!pTextObj) { |
2153 return FALSE; | 2153 return false; |
2154 } | 2154 } |
2155 int i = 0; | 2155 int i = 0; |
2156 if (!ObjPos) { | 2156 if (!ObjPos) { |
2157 ObjPos = m_pPage->GetLastObjectPosition(); | 2157 ObjPos = m_pPage->GetLastObjectPosition(); |
2158 } | 2158 } |
2159 CPDF_PageObject* pObj = m_pPage->GetPrevObject(ObjPos); | 2159 CPDF_PageObject* pObj = m_pPage->GetPrevObject(ObjPos); |
2160 while (i < 5 && ObjPos) { | 2160 while (i < 5 && ObjPos) { |
2161 pObj = m_pPage->GetPrevObject(ObjPos); | 2161 pObj = m_pPage->GetPrevObject(ObjPos); |
2162 if(pObj == pTextObj) { | 2162 if(pObj == pTextObj) { |
2163 continue; | 2163 continue; |
2164 } | 2164 } |
2165 if(pObj->m_Type != PDFPAGE_TEXT) { | 2165 if(pObj->m_Type != PDFPAGE_TEXT) { |
2166 continue; | 2166 continue; |
2167 } | 2167 } |
2168 if(IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) { | 2168 if(IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) { |
2169 return TRUE; | 2169 return true; |
2170 } | 2170 } |
2171 i++; | 2171 i++; |
2172 } | 2172 } |
2173 return FALSE; | 2173 return false; |
2174 } | 2174 } |
2175 FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) | 2175 bool CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) |
2176 { | 2176 { |
2177 int size = m_TempCharList.GetSize(); | 2177 int size = m_TempCharList.GetSize(); |
2178 PAGECHAR_INFO preChar; | 2178 PAGECHAR_INFO preChar; |
2179 if (size) { | 2179 if (size) { |
2180 preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; | 2180 preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; |
2181 } else { | 2181 } else { |
2182 size = m_charList.GetSize(); | 2182 size = m_charList.GetSize(); |
2183 if(size == 0) { | 2183 if(size == 0) { |
2184 return FALSE; | 2184 return false; |
2185 } | 2185 } |
2186 preChar = (PAGECHAR_INFO)m_charList[size - 1]; | 2186 preChar = (PAGECHAR_INFO)m_charList[size - 1]; |
2187 } | 2187 } |
2188 info.m_Index = m_TextBuf.GetLength(); | 2188 info.m_Index = m_TextBuf.GetLength(); |
2189 info.m_Unicode = unicode; | 2189 info.m_Unicode = unicode; |
2190 info.m_pTextObj = NULL; | 2190 info.m_pTextObj = NULL; |
2191 info.m_CharCode = -1; | 2191 info.m_CharCode = -1; |
2192 info.m_Flag = FPDFTEXT_CHAR_GENERATED; | 2192 info.m_Flag = FPDFTEXT_CHAR_GENERATED; |
2193 int preWidth = 0; | 2193 int preWidth = 0; |
2194 if (preChar.m_pTextObj && preChar.m_CharCode != (FX_DWORD) - 1) { | 2194 if (preChar.m_pTextObj && preChar.m_CharCode != (FX_DWORD) - 1) { |
2195 preWidth = GetCharWidth(preChar.m_CharCode, preChar.m_pTextObj->GetFont(
)); | 2195 preWidth = GetCharWidth(preChar.m_CharCode, preChar.m_pTextObj->GetFont(
)); |
2196 } | 2196 } |
2197 FX_FLOAT fs = 0; | 2197 FX_FLOAT fs = 0; |
2198 if(preChar.m_pTextObj) { | 2198 if(preChar.m_pTextObj) { |
2199 fs = preChar.m_pTextObj->GetFontSize(); | 2199 fs = preChar.m_pTextObj->GetFontSize(); |
2200 } else { | 2200 } else { |
2201 fs = preChar.m_CharBox.Height(); | 2201 fs = preChar.m_CharBox.Height(); |
2202 } | 2202 } |
2203 if(!fs) { | 2203 if(!fs) { |
2204 fs = 1; | 2204 fs = 1; |
2205 } | 2205 } |
2206 info.m_OriginX = preChar.m_OriginX + preWidth * (fs) / 1000; | 2206 info.m_OriginX = preChar.m_OriginX + preWidth * (fs) / 1000; |
2207 info.m_OriginY = preChar.m_OriginY; | 2207 info.m_OriginY = preChar.m_OriginY; |
2208 info.m_CharBox = CFX_FloatRect(info.m_OriginX, info.m_OriginY, info.m_Origin
X, info.m_OriginY); | 2208 info.m_CharBox = CFX_FloatRect(info.m_OriginX, info.m_OriginY, info.m_Origin
X, info.m_OriginY); |
2209 return TRUE; | 2209 return true; |
2210 } | 2210 } |
2211 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, const CFX_Flo
atRect& rect2) | 2211 bool CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, const CFX_FloatR
ect& rect2) |
2212 { | 2212 { |
2213 CFX_FloatRect rect = rect1; | 2213 CFX_FloatRect rect = rect1; |
2214 rect.Intersect(rect2); | 2214 rect.Intersect(rect2); |
2215 return !rect.IsEmpty(); | 2215 return !rect.IsEmpty(); |
2216 } | 2216 } |
2217 FX_BOOL»CPDF_TextPage::IsLetter(FX_WCHAR unicode) | 2217 bool» CPDF_TextPage::IsLetter(FX_WCHAR unicode) |
2218 { | 2218 { |
2219 if (unicode < L'A') { | 2219 if (unicode < L'A') { |
2220 return FALSE; | 2220 return false; |
2221 } | 2221 } |
2222 if (unicode > L'Z' && unicode < L'a') { | 2222 if (unicode > L'Z' && unicode < L'a') { |
2223 return FALSE; | 2223 return false; |
2224 } | 2224 } |
2225 if (unicode > L'z') { | 2225 if (unicode > L'z') { |
2226 return FALSE; | 2226 return false; |
2227 } | 2227 } |
2228 return TRUE; | 2228 return true; |
2229 } | 2229 } |
2230 CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage) | 2230 CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage) |
2231 : m_pTextPage(pTextPage), | 2231 : m_pTextPage(pTextPage), |
2232 m_flags(0), | 2232 m_flags(0), |
2233 m_findNextStart(-1), | 2233 m_findNextStart(-1), |
2234 m_findPreStart(-1), | 2234 m_findPreStart(-1), |
2235 m_bMatchCase(FALSE), | 2235 m_bMatchCase(false), |
2236 m_bMatchWholeWord(FALSE), | 2236 m_bMatchWholeWord(false), |
2237 m_resStart(0), | 2237 m_resStart(0), |
2238 m_resEnd(-1), | 2238 m_resEnd(-1), |
2239 m_IsFind(FALSE) | 2239 m_IsFind(false) |
2240 { | 2240 { |
2241 m_strText = m_pTextPage->GetPageText(); | 2241 m_strText = m_pTextPage->GetPageText(); |
2242 int nCount = pTextPage->CountChars(); | 2242 int nCount = pTextPage->CountChars(); |
2243 if(nCount) { | 2243 if(nCount) { |
2244 m_CharIndex.Add(0); | 2244 m_CharIndex.Add(0); |
2245 } | 2245 } |
2246 for(int i = 0; i < nCount; i++) { | 2246 for(int i = 0; i < nCount; i++) { |
2247 FPDF_CHAR_INFO info; | 2247 FPDF_CHAR_INFO info; |
2248 pTextPage->GetCharInfo(i, info); | 2248 pTextPage->GetCharInfo(i, info); |
2249 int indexSize = m_CharIndex.GetSize(); | 2249 int indexSize = m_CharIndex.GetSize(); |
(...skipping 28 matching lines...) Expand all Loading... |
2278 int indexSize = m_CharIndex.GetSize(); | 2278 int indexSize = m_CharIndex.GetSize(); |
2279 int count = 0; | 2279 int count = 0; |
2280 for(int i = 0; i < indexSize; i += 2) { | 2280 for(int i = 0; i < indexSize; i += 2) { |
2281 count += m_CharIndex.GetAt(i + 1); | 2281 count += m_CharIndex.GetAt(i + 1); |
2282 if(count > index) { | 2282 if(count > index) { |
2283 return index - count + m_CharIndex.GetAt(i + 1) + m_CharIndex.G
etAt(i); | 2283 return index - count + m_CharIndex.GetAt(i + 1) + m_CharIndex.G
etAt(i); |
2284 } | 2284 } |
2285 } | 2285 } |
2286 return -1; | 2286 return -1; |
2287 } | 2287 } |
2288 FX_BOOL»CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat, int flags,
int startPos) | 2288 bool» CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat, int flags,
int startPos) |
2289 { | 2289 { |
2290 if (!m_pTextPage) { | 2290 if (!m_pTextPage) { |
2291 return FALSE; | 2291 return false; |
2292 } | 2292 } |
2293 if (m_strText.IsEmpty() || m_bMatchCase != (flags & FPDFTEXT_MATCHCASE)) { | 2293 if (m_strText.IsEmpty() || m_bMatchCase != (flags & FPDFTEXT_MATCHCASE)) { |
2294 m_strText = m_pTextPage->GetPageText(); | 2294 m_strText = m_pTextPage->GetPageText(); |
2295 } | 2295 } |
2296 CFX_WideString findwhatStr = findwhat; | 2296 CFX_WideString findwhatStr = findwhat; |
2297 m_findWhat = findwhatStr; | 2297 m_findWhat = findwhatStr; |
2298 m_flags = flags; | 2298 m_flags = flags; |
2299 m_bMatchCase = flags & FPDFTEXT_MATCHCASE; | 2299 m_bMatchCase = flags & FPDFTEXT_MATCHCASE; |
2300 if (m_strText.IsEmpty()) { | 2300 if (m_strText.IsEmpty()) { |
2301 m_IsFind = FALSE; | 2301 m_IsFind = false; |
2302 return TRUE; | 2302 return true; |
2303 } | 2303 } |
2304 FX_STRSIZE len = findwhatStr.GetLength(); | 2304 FX_STRSIZE len = findwhatStr.GetLength(); |
2305 if (!m_bMatchCase) { | 2305 if (!m_bMatchCase) { |
2306 findwhatStr.MakeLower(); | 2306 findwhatStr.MakeLower(); |
2307 m_strText.MakeLower(); | 2307 m_strText.MakeLower(); |
2308 } | 2308 } |
2309 m_bMatchWholeWord = flags & FPDFTEXT_MATCHWHOLEWORD; | 2309 m_bMatchWholeWord = flags & FPDFTEXT_MATCHWHOLEWORD; |
2310 m_findNextStart = startPos; | 2310 m_findNextStart = startPos; |
2311 if (startPos == -1) { | 2311 if (startPos == -1) { |
2312 m_findPreStart = m_strText.GetLength() - 1; | 2312 m_findPreStart = m_strText.GetLength() - 1; |
2313 } else { | 2313 } else { |
2314 m_findPreStart = startPos; | 2314 m_findPreStart = startPos; |
2315 } | 2315 } |
2316 m_csFindWhatArray.RemoveAll(); | 2316 m_csFindWhatArray.RemoveAll(); |
2317 int i = 0; | 2317 int i = 0; |
2318 while(i < len) { | 2318 while(i < len) { |
2319 if(findwhatStr.GetAt(i) != ' ') { | 2319 if(findwhatStr.GetAt(i) != ' ') { |
2320 break; | 2320 break; |
2321 } | 2321 } |
2322 i++; | 2322 i++; |
2323 } | 2323 } |
2324 if(i < len) { | 2324 if(i < len) { |
2325 ExtractFindWhat(findwhatStr); | 2325 ExtractFindWhat(findwhatStr); |
2326 } else { | 2326 } else { |
2327 m_csFindWhatArray.Add(findwhatStr); | 2327 m_csFindWhatArray.Add(findwhatStr); |
2328 } | 2328 } |
2329 if(m_csFindWhatArray.GetSize() <= 0) { | 2329 if(m_csFindWhatArray.GetSize() <= 0) { |
2330 return FALSE; | 2330 return false; |
2331 } | 2331 } |
2332 m_IsFind = TRUE; | 2332 m_IsFind = true; |
2333 m_resStart = 0; | 2333 m_resStart = 0; |
2334 m_resEnd = -1; | 2334 m_resEnd = -1; |
2335 return TRUE; | 2335 return true; |
2336 } | 2336 } |
2337 FX_BOOL CPDF_TextPageFind::FindNext() | 2337 bool CPDF_TextPageFind::FindNext() |
2338 { | 2338 { |
2339 if (!m_pTextPage) { | 2339 if (!m_pTextPage) { |
2340 return FALSE; | 2340 return false; |
2341 } | 2341 } |
2342 m_resArray.RemoveAll(); | 2342 m_resArray.RemoveAll(); |
2343 if(m_findNextStart == -1) { | 2343 if(m_findNextStart == -1) { |
2344 return FALSE; | 2344 return false; |
2345 } | 2345 } |
2346 if(m_strText.IsEmpty()) { | 2346 if(m_strText.IsEmpty()) { |
2347 m_IsFind = FALSE; | 2347 m_IsFind = false; |
2348 return m_IsFind; | 2348 return m_IsFind; |
2349 } | 2349 } |
2350 int strLen = m_strText.GetLength(); | 2350 int strLen = m_strText.GetLength(); |
2351 if (m_findNextStart > strLen - 1) { | 2351 if (m_findNextStart > strLen - 1) { |
2352 m_IsFind = FALSE; | 2352 m_IsFind = false; |
2353 return m_IsFind; | 2353 return m_IsFind; |
2354 } | 2354 } |
2355 int nCount = m_csFindWhatArray.GetSize(); | 2355 int nCount = m_csFindWhatArray.GetSize(); |
2356 int nResultPos = 0; | 2356 int nResultPos = 0; |
2357 int nStartPos = 0; | 2357 int nStartPos = 0; |
2358 nStartPos = m_findNextStart; | 2358 nStartPos = m_findNextStart; |
2359 FX_BOOL bSpaceStart = FALSE; | 2359 bool bSpaceStart = false; |
2360 for(int iWord = 0; iWord < nCount; iWord++) { | 2360 for(int iWord = 0; iWord < nCount; iWord++) { |
2361 CFX_WideString csWord = m_csFindWhatArray[iWord]; | 2361 CFX_WideString csWord = m_csFindWhatArray[iWord]; |
2362 if(csWord.IsEmpty()) { | 2362 if(csWord.IsEmpty()) { |
2363 if(iWord == nCount - 1) { | 2363 if(iWord == nCount - 1) { |
2364 FX_WCHAR strInsert = m_strText.GetAt(nStartPos); | 2364 FX_WCHAR strInsert = m_strText.GetAt(nStartPos); |
2365 if(strInsert == TEXT_LINEFEED_CHAR || strInsert == TEXT_BLANK_CH
AR || strInsert == TEXT_RETURN_CHAR || strInsert == 160) { | 2365 if(strInsert == TEXT_LINEFEED_CHAR || strInsert == TEXT_BLANK_CH
AR || strInsert == TEXT_RETURN_CHAR || strInsert == 160) { |
2366 nResultPos = nStartPos + 1; | 2366 nResultPos = nStartPos + 1; |
2367 break; | 2367 break; |
2368 } | 2368 } |
2369 iWord = -1; | 2369 iWord = -1; |
2370 } else if(iWord == 0) { | 2370 } else if(iWord == 0) { |
2371 bSpaceStart = TRUE; | 2371 bSpaceStart = true; |
2372 } | 2372 } |
2373 continue; | 2373 continue; |
2374 } | 2374 } |
2375 int endIndex; | 2375 int endIndex; |
2376 nResultPos = m_strText.Find(csWord.c_str(), nStartPos); | 2376 nResultPos = m_strText.Find(csWord.c_str(), nStartPos); |
2377 if (nResultPos == -1) { | 2377 if (nResultPos == -1) { |
2378 m_IsFind = FALSE; | 2378 m_IsFind = false; |
2379 return m_IsFind; | 2379 return m_IsFind; |
2380 } | 2380 } |
2381 endIndex = nResultPos + csWord.GetLength() - 1; | 2381 endIndex = nResultPos + csWord.GetLength() - 1; |
2382 if(iWord == 0) { | 2382 if(iWord == 0) { |
2383 m_resStart = nResultPos; | 2383 m_resStart = nResultPos; |
2384 } | 2384 } |
2385 FX_BOOL bMatch = TRUE; | 2385 bool bMatch = true; |
2386 if(iWord != 0 && !bSpaceStart) { | 2386 if(iWord != 0 && !bSpaceStart) { |
2387 int PreResEndPos = nStartPos; | 2387 int PreResEndPos = nStartPos; |
2388 int curChar = csWord.GetAt(0); | 2388 int curChar = csWord.GetAt(0); |
2389 CFX_WideString lastWord = m_csFindWhatArray[iWord - 1]; | 2389 CFX_WideString lastWord = m_csFindWhatArray[iWord - 1]; |
2390 int lastChar = lastWord.GetAt(lastWord.GetLength() - 1); | 2390 int lastChar = lastWord.GetAt(lastWord.GetLength() - 1); |
2391 if(nStartPos == nResultPos && !(_IsIgnoreSpaceCharacter(lastChar) ||
_IsIgnoreSpaceCharacter(curChar))) { | 2391 if(nStartPos == nResultPos && !(_IsIgnoreSpaceCharacter(lastChar) ||
_IsIgnoreSpaceCharacter(curChar))) { |
2392 bMatch = FALSE; | 2392 bMatch = false; |
2393 } | 2393 } |
2394 for(int d = PreResEndPos; d < nResultPos; d++) { | 2394 for(int d = PreResEndPos; d < nResultPos; d++) { |
2395 FX_WCHAR strInsert = m_strText.GetAt(d); | 2395 FX_WCHAR strInsert = m_strText.GetAt(d); |
2396 if(strInsert != TEXT_LINEFEED_CHAR && strInsert != TEXT_BLANK_CH
AR && strInsert != TEXT_RETURN_CHAR && strInsert != 160) { | 2396 if(strInsert != TEXT_LINEFEED_CHAR && strInsert != TEXT_BLANK_CH
AR && strInsert != TEXT_RETURN_CHAR && strInsert != 160) { |
2397 bMatch = FALSE; | 2397 bMatch = false; |
2398 break; | 2398 break; |
2399 } | 2399 } |
2400 } | 2400 } |
2401 } else if(bSpaceStart) { | 2401 } else if(bSpaceStart) { |
2402 if(nResultPos > 0) { | 2402 if(nResultPos > 0) { |
2403 FX_WCHAR strInsert = m_strText.GetAt(nResultPos - 1); | 2403 FX_WCHAR strInsert = m_strText.GetAt(nResultPos - 1); |
2404 if(strInsert != TEXT_LINEFEED_CHAR && strInsert != TEXT_BLANK_CH
AR && strInsert != TEXT_RETURN_CHAR && strInsert != 160) { | 2404 if(strInsert != TEXT_LINEFEED_CHAR && strInsert != TEXT_BLANK_CH
AR && strInsert != TEXT_RETURN_CHAR && strInsert != 160) { |
2405 bMatch = FALSE; | 2405 bMatch = false; |
2406 m_resStart = nResultPos; | 2406 m_resStart = nResultPos; |
2407 } else { | 2407 } else { |
2408 m_resStart = nResultPos - 1; | 2408 m_resStart = nResultPos - 1; |
2409 } | 2409 } |
2410 } | 2410 } |
2411 } | 2411 } |
2412 if(m_bMatchWholeWord && bMatch) { | 2412 if(m_bMatchWholeWord && bMatch) { |
2413 bMatch = IsMatchWholeWord(m_strText, nResultPos, endIndex); | 2413 bMatch = IsMatchWholeWord(m_strText, nResultPos, endIndex); |
2414 } | 2414 } |
2415 nStartPos = endIndex + 1; | 2415 nStartPos = endIndex + 1; |
2416 if(!bMatch) { | 2416 if(!bMatch) { |
2417 iWord = -1; | 2417 iWord = -1; |
2418 if(bSpaceStart) { | 2418 if(bSpaceStart) { |
2419 nStartPos = m_resStart + m_csFindWhatArray[1].GetLength(); | 2419 nStartPos = m_resStart + m_csFindWhatArray[1].GetLength(); |
2420 } else { | 2420 } else { |
2421 nStartPos = m_resStart + m_csFindWhatArray[0].GetLength(); | 2421 nStartPos = m_resStart + m_csFindWhatArray[0].GetLength(); |
2422 } | 2422 } |
2423 } | 2423 } |
2424 } | 2424 } |
2425 m_resEnd = nResultPos + m_csFindWhatArray[m_csFindWhatArray.GetSize() - 1].G
etLength() - 1; | 2425 m_resEnd = nResultPos + m_csFindWhatArray[m_csFindWhatArray.GetSize() - 1].G
etLength() - 1; |
2426 m_IsFind = TRUE; | 2426 m_IsFind = true; |
2427 int resStart = GetCharIndex(m_resStart); | 2427 int resStart = GetCharIndex(m_resStart); |
2428 int resEnd = GetCharIndex(m_resEnd); | 2428 int resEnd = GetCharIndex(m_resEnd); |
2429 m_pTextPage->GetRectArray(resStart, resEnd - resStart + 1, m_resArray); | 2429 m_pTextPage->GetRectArray(resStart, resEnd - resStart + 1, m_resArray); |
2430 if(m_flags & FPDFTEXT_CONSECUTIVE) { | 2430 if(m_flags & FPDFTEXT_CONSECUTIVE) { |
2431 m_findNextStart = m_resStart + 1; | 2431 m_findNextStart = m_resStart + 1; |
2432 m_findPreStart = m_resEnd - 1; | 2432 m_findPreStart = m_resEnd - 1; |
2433 } else { | 2433 } else { |
2434 m_findNextStart = m_resEnd + 1; | 2434 m_findNextStart = m_resEnd + 1; |
2435 m_findPreStart = m_resStart - 1; | 2435 m_findPreStart = m_resStart - 1; |
2436 } | 2436 } |
2437 return m_IsFind; | 2437 return m_IsFind; |
2438 } | 2438 } |
2439 FX_BOOL CPDF_TextPageFind::FindPrev() | 2439 bool CPDF_TextPageFind::FindPrev() |
2440 { | 2440 { |
2441 if (!m_pTextPage) { | 2441 if (!m_pTextPage) { |
2442 return FALSE; | 2442 return false; |
2443 } | 2443 } |
2444 m_resArray.RemoveAll(); | 2444 m_resArray.RemoveAll(); |
2445 if(m_strText.IsEmpty() || m_findPreStart < 0) { | 2445 if(m_strText.IsEmpty() || m_findPreStart < 0) { |
2446 m_IsFind = FALSE; | 2446 m_IsFind = false; |
2447 return m_IsFind; | 2447 return m_IsFind; |
2448 } | 2448 } |
2449 CPDF_TextPageFind findEngine(m_pTextPage); | 2449 CPDF_TextPageFind findEngine(m_pTextPage); |
2450 FX_BOOL ret = findEngine.FindFirst(m_findWhat, m_flags); | 2450 bool ret = findEngine.FindFirst(m_findWhat, m_flags); |
2451 if(!ret) { | 2451 if(!ret) { |
2452 m_IsFind = FALSE; | 2452 m_IsFind = false; |
2453 return m_IsFind; | 2453 return m_IsFind; |
2454 } | 2454 } |
2455 int order = -1, MatchedCount = 0; | 2455 int order = -1, MatchedCount = 0; |
2456 while(ret) { | 2456 while(ret) { |
2457 ret = findEngine.FindNext(); | 2457 ret = findEngine.FindNext(); |
2458 if(ret) { | 2458 if(ret) { |
2459 int order1 = findEngine.GetCurOrder() ; | 2459 int order1 = findEngine.GetCurOrder() ; |
2460 int MatchedCount1 = findEngine.GetMatchedCount(); | 2460 int MatchedCount1 = findEngine.GetMatchedCount(); |
2461 if(((order1 + MatchedCount1) - 1) > m_findPreStart) { | 2461 if(((order1 + MatchedCount1) - 1) > m_findPreStart) { |
2462 break; | 2462 break; |
2463 } | 2463 } |
2464 order = order1; | 2464 order = order1; |
2465 MatchedCount = MatchedCount1; | 2465 MatchedCount = MatchedCount1; |
2466 } | 2466 } |
2467 } | 2467 } |
2468 if(order == -1) { | 2468 if(order == -1) { |
2469 m_IsFind = FALSE; | 2469 m_IsFind = false; |
2470 return m_IsFind; | 2470 return m_IsFind; |
2471 } | 2471 } |
2472 m_resStart = m_pTextPage->TextIndexFromCharIndex(order); | 2472 m_resStart = m_pTextPage->TextIndexFromCharIndex(order); |
2473 m_resEnd = m_pTextPage->TextIndexFromCharIndex(order + MatchedCount - 1); | 2473 m_resEnd = m_pTextPage->TextIndexFromCharIndex(order + MatchedCount - 1); |
2474 m_IsFind = TRUE; | 2474 m_IsFind = true; |
2475 m_pTextPage->GetRectArray(order, MatchedCount, m_resArray); | 2475 m_pTextPage->GetRectArray(order, MatchedCount, m_resArray); |
2476 if(m_flags & FPDFTEXT_CONSECUTIVE) { | 2476 if(m_flags & FPDFTEXT_CONSECUTIVE) { |
2477 m_findNextStart = m_resStart + 1; | 2477 m_findNextStart = m_resStart + 1; |
2478 m_findPreStart = m_resEnd - 1; | 2478 m_findPreStart = m_resEnd - 1; |
2479 } else { | 2479 } else { |
2480 m_findNextStart = m_resEnd + 1; | 2480 m_findNextStart = m_resEnd + 1; |
2481 m_findPreStart = m_resStart - 1; | 2481 m_findPreStart = m_resStart - 1; |
2482 } | 2482 } |
2483 return m_IsFind; | 2483 return m_IsFind; |
2484 } | 2484 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 continue; | 2523 continue; |
2524 } | 2524 } |
2525 pos++; | 2525 pos++; |
2526 } | 2526 } |
2527 if (!csWord.IsEmpty()) { | 2527 if (!csWord.IsEmpty()) { |
2528 m_csFindWhatArray.Add(csWord); | 2528 m_csFindWhatArray.Add(csWord); |
2529 } | 2529 } |
2530 index++; | 2530 index++; |
2531 } | 2531 } |
2532 } | 2532 } |
2533 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, in
t startPos, int endPos) | 2533 bool CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, int s
tartPos, int endPos) |
2534 { | 2534 { |
2535 int char_left = 0; | 2535 int char_left = 0; |
2536 int char_right = 0; | 2536 int char_right = 0; |
2537 int char_count = endPos - startPos + 1; | 2537 int char_count = endPos - startPos + 1; |
2538 if(char_count < 1) { | 2538 if(char_count < 1) { |
2539 return FALSE; | 2539 return false; |
2540 } | 2540 } |
2541 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { | 2541 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { |
2542 return TRUE; | 2542 return true; |
2543 } | 2543 } |
2544 if(startPos - 1 >= 0 ) { | 2544 if(startPos - 1 >= 0 ) { |
2545 char_left = csPageText.GetAt(startPos - 1); | 2545 char_left = csPageText.GetAt(startPos - 1); |
2546 } | 2546 } |
2547 if(startPos + char_count < csPageText.GetLength()) { | 2547 if(startPos + char_count < csPageText.GetLength()) { |
2548 char_right = csPageText.GetAt(startPos + char_count); | 2548 char_right = csPageText.GetAt(startPos + char_count); |
2549 } | 2549 } |
2550 if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left <
'z') || (char_left > 0xfb00 && char_left < 0xfb06) || (char_left >= '0' && char_
left <= '9') || | 2550 if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left <
'z') || (char_left > 0xfb00 && char_left < 0xfb06) || (char_left >= '0' && char_
left <= '9') || |
2551 (char_right > 'A' && char_right < 'a') || (char_right > 'a' && char_
right < 'z') || (char_right > 0xfb00 && char_right < 0xfb06) || (char_right >= '
0' && char_right <= '9')) { | 2551 (char_right > 'A' && char_right < 'a') || (char_right > 'a' && char_
right < 'z') || (char_right > 0xfb00 && char_right < 0xfb06) || (char_right >= '
0' && char_right <= '9')) { |
2552 return FALSE; | 2552 return false; |
2553 } | 2553 } |
2554 if(!(('A' > char_left || char_left > 'Z') && ('a' > char_left || char_left
> 'z') | 2554 if(!(('A' > char_left || char_left > 'Z') && ('a' > char_left || char_left
> 'z') |
2555 && ('A' > char_right || char_right > 'Z') && ('a' > char_right || c
har_right > 'z'))) { | 2555 && ('A' > char_right || char_right > 'Z') && ('a' > char_right || c
har_right > 'z'))) { |
2556 return FALSE; | 2556 return false; |
2557 } | 2557 } |
2558 if (char_count > 0) { | 2558 if (char_count > 0) { |
2559 if (csPageText.GetAt(startPos) >= L'0' && csPageText.GetAt(startPos) <=
L'9' && char_left >= L'0' && char_left <= L'9') { | 2559 if (csPageText.GetAt(startPos) >= L'0' && csPageText.GetAt(startPos) <=
L'9' && char_left >= L'0' && char_left <= L'9') { |
2560 return FALSE; | 2560 return false; |
2561 } | 2561 } |
2562 if (csPageText.GetAt(endPos) >= L'0' && csPageText.GetAt(endPos) <= L'9'
&& char_right >= L'0' && char_right <= L'9') { | 2562 if (csPageText.GetAt(endPos) >= L'0' && csPageText.GetAt(endPos) <= L'9'
&& char_right >= L'0' && char_right <= L'9') { |
2563 return FALSE; | 2563 return false; |
2564 } | 2564 } |
2565 } | 2565 } |
2566 return TRUE; | 2566 return true; |
2567 } | 2567 } |
2568 FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString, const FX_WC
HAR* lpszFullString, | 2568 bool CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString, const FX_WCHAR
* lpszFullString, |
2569 int iSubString, FX_WCHAR chSep) | 2569 int iSubString, FX_WCHAR chSep) |
2570 { | 2570 { |
2571 if (lpszFullString == NULL) { | 2571 if (lpszFullString == NULL) { |
2572 return FALSE; | 2572 return false; |
2573 } | 2573 } |
2574 while (iSubString--) { | 2574 while (iSubString--) { |
2575 lpszFullString = FXSYS_wcschr(lpszFullString, chSep); | 2575 lpszFullString = FXSYS_wcschr(lpszFullString, chSep); |
2576 if (lpszFullString == NULL) { | 2576 if (lpszFullString == NULL) { |
2577 rString.Empty(); | 2577 rString.Empty(); |
2578 return FALSE; | 2578 return false; |
2579 } | 2579 } |
2580 lpszFullString++; | 2580 lpszFullString++; |
2581 while(*lpszFullString == chSep) { | 2581 while(*lpszFullString == chSep) { |
2582 lpszFullString++; | 2582 lpszFullString++; |
2583 } | 2583 } |
2584 } | 2584 } |
2585 const FX_WCHAR* lpchEnd = FXSYS_wcschr(lpszFullString, chSep); | 2585 const FX_WCHAR* lpchEnd = FXSYS_wcschr(lpszFullString, chSep); |
2586 int nLen = (lpchEnd == NULL) ? | 2586 int nLen = (lpchEnd == NULL) ? |
2587 (int)FXSYS_wcslen(lpszFullString) : (int)(lpchEnd - lpszFullStrin
g); | 2587 (int)FXSYS_wcslen(lpszFullString) : (int)(lpchEnd - lpszFullStrin
g); |
2588 ASSERT(nLen >= 0); | 2588 ASSERT(nLen >= 0); |
2589 FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString, nLen * sizeof(FX_WCHAR
)); | 2589 FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString, nLen * sizeof(FX_WCHAR
)); |
2590 rString.ReleaseBuffer(); | 2590 rString.ReleaseBuffer(); |
2591 return TRUE; | 2591 return true; |
2592 } | 2592 } |
2593 CFX_WideString CPDF_TextPageFind::MakeReverse(const CFX_WideString& str) | 2593 CFX_WideString CPDF_TextPageFind::MakeReverse(const CFX_WideString& str) |
2594 { | 2594 { |
2595 CFX_WideString str2; | 2595 CFX_WideString str2; |
2596 str2.Empty(); | 2596 str2.Empty(); |
2597 int nlen = str.GetLength(); | 2597 int nlen = str.GetLength(); |
2598 for(int i = nlen - 1; i >= 0; i--) { | 2598 for(int i = nlen - 1; i >= 0; i--) { |
2599 str2 += str.GetAt(i); | 2599 str2 += str.GetAt(i); |
2600 } | 2600 } |
2601 return str2; | 2601 return str2; |
2602 } | 2602 } |
2603 void CPDF_TextPageFind::GetRectArray(CFX_RectArray& rects) const | 2603 void CPDF_TextPageFind::GetRectArray(CFX_RectArray& rects) const |
2604 { | 2604 { |
2605 rects.Copy(m_resArray); | 2605 rects.Copy(m_resArray); |
2606 } | 2606 } |
2607 int CPDF_TextPageFind::GetCurOrder() const | 2607 int CPDF_TextPageFind::GetCurOrder() const |
2608 { | 2608 { |
2609 return GetCharIndex(m_resStart); | 2609 return GetCharIndex(m_resStart); |
2610 } | 2610 } |
2611 int CPDF_TextPageFind::GetMatchedCount()const | 2611 int CPDF_TextPageFind::GetMatchedCount()const |
2612 { | 2612 { |
2613 int resStart = GetCharIndex(m_resStart); | 2613 int resStart = GetCharIndex(m_resStart); |
2614 int resEnd = GetCharIndex(m_resEnd); | 2614 int resEnd = GetCharIndex(m_resEnd); |
2615 return resEnd - resStart + 1; | 2615 return resEnd - resStart + 1; |
2616 } | 2616 } |
2617 CPDF_LinkExtract::CPDF_LinkExtract() | 2617 CPDF_LinkExtract::CPDF_LinkExtract() |
2618 : m_pTextPage(NULL), | 2618 : m_pTextPage(NULL), |
2619 m_IsParserd(FALSE) | 2619 m_IsParserd(false) |
2620 { | 2620 { |
2621 } | 2621 } |
2622 CPDF_LinkExtract::~CPDF_LinkExtract() | 2622 CPDF_LinkExtract::~CPDF_LinkExtract() |
2623 { | 2623 { |
2624 DeleteLinkList(); | 2624 DeleteLinkList(); |
2625 } | 2625 } |
2626 FX_BOOL CPDF_LinkExtract::ExtractLinks(const IPDF_TextPage* pTextPage) | 2626 bool CPDF_LinkExtract::ExtractLinks(const IPDF_TextPage* pTextPage) |
2627 { | 2627 { |
2628 if (!pTextPage || !pTextPage->IsParsered()) { | 2628 if (!pTextPage || !pTextPage->IsParsered()) { |
2629 return FALSE; | 2629 return false; |
2630 } | 2630 } |
2631 m_pTextPage = (const CPDF_TextPage*)pTextPage; | 2631 m_pTextPage = (const CPDF_TextPage*)pTextPage; |
2632 m_strPageText = m_pTextPage->GetPageText(0, -1); | 2632 m_strPageText = m_pTextPage->GetPageText(0, -1); |
2633 DeleteLinkList(); | 2633 DeleteLinkList(); |
2634 if (m_strPageText.IsEmpty()) { | 2634 if (m_strPageText.IsEmpty()) { |
2635 return FALSE; | 2635 return false; |
2636 } | 2636 } |
2637 parserLink(); | 2637 parserLink(); |
2638 m_IsParserd = TRUE; | 2638 m_IsParserd = true; |
2639 return TRUE; | 2639 return true; |
2640 } | 2640 } |
2641 void CPDF_LinkExtract::DeleteLinkList() | 2641 void CPDF_LinkExtract::DeleteLinkList() |
2642 { | 2642 { |
2643 while (m_LinkList.GetSize()) { | 2643 while (m_LinkList.GetSize()) { |
2644 CPDF_LinkExt* linkinfo = NULL; | 2644 CPDF_LinkExt* linkinfo = NULL; |
2645 linkinfo = m_LinkList.GetAt(0); | 2645 linkinfo = m_LinkList.GetAt(0); |
2646 m_LinkList.RemoveAt(0); | 2646 m_LinkList.RemoveAt(0); |
2647 delete linkinfo; | 2647 delete linkinfo; |
2648 } | 2648 } |
2649 m_LinkList.RemoveAll(); | 2649 m_LinkList.RemoveAll(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 break; | 2684 break; |
2685 } | 2685 } |
2686 } | 2686 } |
2687 } | 2687 } |
2688 start = ++pos; | 2688 start = ++pos; |
2689 } else { | 2689 } else { |
2690 pos++; | 2690 pos++; |
2691 } | 2691 } |
2692 } | 2692 } |
2693 } | 2693 } |
2694 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) | 2694 bool CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) |
2695 { | 2695 { |
2696 CFX_WideString str = strBeCheck; | 2696 CFX_WideString str = strBeCheck; |
2697 str.MakeLower(); | 2697 str.MakeLower(); |
2698 if (str.Find(L"http://www.") != -1) { | 2698 if (str.Find(L"http://www.") != -1) { |
2699 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.")
); | 2699 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.")
); |
2700 return TRUE; | 2700 return true; |
2701 } else if (str.Find(L"http://") != -1) { | 2701 } else if (str.Find(L"http://") != -1) { |
2702 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); | 2702 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); |
2703 return TRUE; | 2703 return true; |
2704 } else if (str.Find(L"https://www.") != -1) { | 2704 } else if (str.Find(L"https://www.") != -1) { |
2705 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www."
)); | 2705 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www."
)); |
2706 return TRUE; | 2706 return true; |
2707 } else if (str.Find(L"https://") != -1) { | 2707 } else if (str.Find(L"https://") != -1) { |
2708 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); | 2708 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); |
2709 return TRUE; | 2709 return true; |
2710 } else if (str.Find(L"www.") != -1) { | 2710 } else if (str.Find(L"www.") != -1) { |
2711 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); | 2711 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); |
2712 strBeCheck = L"http://" + strBeCheck; | 2712 strBeCheck = L"http://" + strBeCheck; |
2713 return TRUE; | 2713 return true; |
2714 } else { | 2714 } else { |
2715 return FALSE; | 2715 return false; |
2716 } | 2716 } |
2717 } | 2717 } |
2718 FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) | 2718 bool CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) |
2719 { | 2719 { |
2720 str.MakeLower(); | 2720 str.MakeLower(); |
2721 int aPos = str.Find(L'@'); | 2721 int aPos = str.Find(L'@'); |
2722 if (aPos < 1) { | 2722 if (aPos < 1) { |
2723 return FALSE; | 2723 return false; |
2724 } | 2724 } |
2725 if (str.GetAt(aPos - 1) == L'.' || str.GetAt(aPos - 1) == L'_') { | 2725 if (str.GetAt(aPos - 1) == L'.' || str.GetAt(aPos - 1) == L'_') { |
2726 return FALSE; | 2726 return false; |
2727 } | 2727 } |
2728 int i; | 2728 int i; |
2729 for (i = aPos - 1; i >= 0; i--) { | 2729 for (i = aPos - 1; i >= 0; i--) { |
2730 FX_WCHAR ch = str.GetAt(i); | 2730 FX_WCHAR ch = str.GetAt(i); |
2731 if (ch == L'_' || ch == L'.' || (ch >= L'a' && ch <= L'z') || (ch >= L'0
' && ch <= L'9')) { | 2731 if (ch == L'_' || ch == L'.' || (ch >= L'a' && ch <= L'z') || (ch >= L'0
' && ch <= L'9')) { |
2732 continue; | 2732 continue; |
2733 } else { | 2733 } else { |
2734 if (i == aPos - 1) { | 2734 if (i == aPos - 1) { |
2735 return FALSE; | 2735 return false; |
2736 } | 2736 } |
2737 str = str.Right(str.GetLength() - i - 1); | 2737 str = str.Right(str.GetLength() - i - 1); |
2738 break; | 2738 break; |
2739 } | 2739 } |
2740 } | 2740 } |
2741 aPos = str.Find(L'@'); | 2741 aPos = str.Find(L'@'); |
2742 if (aPos < 1) { | 2742 if (aPos < 1) { |
2743 return FALSE; | 2743 return false; |
2744 } | 2744 } |
2745 CFX_WideString strtemp = L""; | 2745 CFX_WideString strtemp = L""; |
2746 for (i = 0; i < aPos; i++) { | 2746 for (i = 0; i < aPos; i++) { |
2747 FX_WCHAR wch = str.GetAt(i); | 2747 FX_WCHAR wch = str.GetAt(i); |
2748 if (wch >= L'a' && wch <= L'z') { | 2748 if (wch >= L'a' && wch <= L'z') { |
2749 break; | 2749 break; |
2750 } else { | 2750 } else { |
2751 strtemp = str.Right(str.GetLength() - i + 1); | 2751 strtemp = str.Right(str.GetLength() - i + 1); |
2752 } | 2752 } |
2753 } | 2753 } |
2754 if (strtemp != L"") { | 2754 if (strtemp != L"") { |
2755 str = strtemp; | 2755 str = strtemp; |
2756 } | 2756 } |
2757 aPos = str.Find(L'@'); | 2757 aPos = str.Find(L'@'); |
2758 if (aPos < 1) { | 2758 if (aPos < 1) { |
2759 return FALSE; | 2759 return false; |
2760 } | 2760 } |
2761 str.TrimRight(L'.'); | 2761 str.TrimRight(L'.'); |
2762 strtemp = str; | 2762 strtemp = str; |
2763 int ePos = str.Find(L'.'); | 2763 int ePos = str.Find(L'.'); |
2764 if (ePos == -1) { | 2764 if (ePos == -1) { |
2765 return FALSE; | 2765 return false; |
2766 } | 2766 } |
2767 while (ePos != -1) { | 2767 while (ePos != -1) { |
2768 strtemp = strtemp.Right(strtemp.GetLength() - ePos - 1); | 2768 strtemp = strtemp.Right(strtemp.GetLength() - ePos - 1); |
2769 ePos = strtemp.Find('.'); | 2769 ePos = strtemp.Find('.'); |
2770 } | 2770 } |
2771 ePos = strtemp.GetLength(); | 2771 ePos = strtemp.GetLength(); |
2772 for (i = 0; i < ePos; i++) { | 2772 for (i = 0; i < ePos; i++) { |
2773 FX_WCHAR wch = str.GetAt(i); | 2773 FX_WCHAR wch = str.GetAt(i); |
2774 if ((wch >= L'a' && wch <= L'z') || (wch >= L'0' && wch <= L'9')) { | 2774 if ((wch >= L'a' && wch <= L'z') || (wch >= L'0' && wch <= L'9')) { |
2775 continue; | 2775 continue; |
2776 } else { | 2776 } else { |
2777 str = str.Left(str.GetLength() - ePos + i + 1); | 2777 str = str.Left(str.GetLength() - ePos + i + 1); |
2778 ePos = ePos - i - 1; | 2778 ePos = ePos - i - 1; |
2779 break; | 2779 break; |
2780 } | 2780 } |
2781 } | 2781 } |
2782 int nLen = str.GetLength(); | 2782 int nLen = str.GetLength(); |
2783 for (i = aPos + 1; i < nLen - ePos; i++) { | 2783 for (i = aPos + 1; i < nLen - ePos; i++) { |
2784 FX_WCHAR wch = str.GetAt(i); | 2784 FX_WCHAR wch = str.GetAt(i); |
2785 if (wch == L'-' || wch == L'.' || (wch >= L'a' && wch <= L'z') || (wch >
= L'0' && wch <= L'9')) { | 2785 if (wch == L'-' || wch == L'.' || (wch >= L'a' && wch <= L'z') || (wch >
= L'0' && wch <= L'9')) { |
2786 continue; | 2786 continue; |
2787 } else { | 2787 } else { |
2788 return FALSE; | 2788 return false; |
2789 } | 2789 } |
2790 } | 2790 } |
2791 if (str.Find(L"mailto:") == -1) { | 2791 if (str.Find(L"mailto:") == -1) { |
2792 str = L"mailto:" + str; | 2792 str = L"mailto:" + str; |
2793 } | 2793 } |
2794 return TRUE; | 2794 return true; |
2795 } | 2795 } |
2796 FX_BOOL CPDF_LinkExtract::AppendToLinkList(int start, int count, const CFX_WideS
tring& strUrl) | 2796 bool CPDF_LinkExtract::AppendToLinkList(int start, int count, const CFX_WideStri
ng& strUrl) |
2797 { | 2797 { |
2798 CPDF_LinkExt* linkInfo = new CPDF_LinkExt; | 2798 CPDF_LinkExt* linkInfo = new CPDF_LinkExt; |
2799 linkInfo->m_strUrl = strUrl; | 2799 linkInfo->m_strUrl = strUrl; |
2800 linkInfo->m_Start = start; | 2800 linkInfo->m_Start = start; |
2801 linkInfo->m_Count = count; | 2801 linkInfo->m_Count = count; |
2802 m_LinkList.Add(linkInfo); | 2802 m_LinkList.Add(linkInfo); |
2803 return TRUE; | 2803 return true; |
2804 } | 2804 } |
2805 CFX_WideString CPDF_LinkExtract::GetURL(int index) const | 2805 CFX_WideString CPDF_LinkExtract::GetURL(int index) const |
2806 { | 2806 { |
2807 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2807 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
2808 return L""; | 2808 return L""; |
2809 } | 2809 } |
2810 CPDF_LinkExt* link = NULL; | 2810 CPDF_LinkExt* link = NULL; |
2811 link = m_LinkList.GetAt(index); | 2811 link = m_LinkList.GetAt(index); |
2812 if (!link) { | 2812 if (!link) { |
2813 return L""; | 2813 return L""; |
(...skipping 18 matching lines...) Expand all Loading... |
2832 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2832 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
2833 return; | 2833 return; |
2834 } | 2834 } |
2835 CPDF_LinkExt* link = NULL; | 2835 CPDF_LinkExt* link = NULL; |
2836 link = m_LinkList.GetAt(index); | 2836 link = m_LinkList.GetAt(index); |
2837 if (!link) { | 2837 if (!link) { |
2838 return ; | 2838 return ; |
2839 } | 2839 } |
2840 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2840 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
2841 } | 2841 } |
OLD | NEW |