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" |
(...skipping 24 matching lines...) Expand all Loading... |
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 } |
| 46 if (threshold < 500) { |
46 return threshold / 4.0f; | 47 return threshold / 4.0f; |
47 } else if (threshold < 700) { | 48 } |
| 49 if (threshold < 700) { |
48 return threshold / 5.0f; | 50 return threshold / 5.0f; |
49 } | 51 } |
50 return threshold / 6.0f; | 52 return threshold / 6.0f; |
51 } | 53 } |
52 | 54 |
53 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj, | 55 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj, |
54 const CFX_AffineMatrix& matrix) | 56 const CFX_AffineMatrix& matrix) |
55 { | 57 { |
56 FX_FLOAT baseSpace = 0.0; | 58 FX_FLOAT baseSpace = 0.0; |
57 const int nItems = pTextObj->CountItems(); | 59 const int nItems = pTextObj->CountItems(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 m_pPage = pPage; | 157 m_pPage = pPage; |
156 m_parserflag = flags; | 158 m_parserflag = flags; |
157 m_TextBuf.EstimateSize(0, 10240); | 159 m_TextBuf.EstimateSize(0, 10240); |
158 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); | 160 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); |
159 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top
); | 161 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top
); |
160 } | 162 } |
161 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) | 163 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) |
162 { | 164 { |
163 m_ParseOptions.m_bNormalizeObjs = bNormalize; | 165 m_ParseOptions.m_bNormalizeObjs = bNormalize; |
164 } | 166 } |
165 FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) | 167 bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo) |
166 { | 168 { |
167 if(!pCharInfo) { | 169 switch (charInfo.m_Unicode) { |
168 return FALSE; | |
169 } | |
170 switch(pCharInfo->m_Unicode) { | |
171 case 0x2: | 170 case 0x2: |
172 case 0x3: | 171 case 0x3: |
173 case 0x93: | 172 case 0x93: |
174 case 0x94: | 173 case 0x94: |
175 case 0x96: | 174 case 0x96: |
176 case 0x97: | 175 case 0x97: |
177 case 0x98: | 176 case 0x98: |
178 case 0xfffe: | 177 case 0xfffe: |
179 if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) { | 178 return charInfo.m_Flag != FPDFTEXT_CHAR_HYPHEN; |
180 return FALSE; | |
181 } else { | |
182 return TRUE; | |
183 } | |
184 default: | 179 default: |
185 return FALSE; | 180 return false; |
186 } | 181 } |
187 } | 182 } |
188 FX_BOOL CPDF_TextPage::ParseTextPage() | 183 FX_BOOL CPDF_TextPage::ParseTextPage() |
189 { | 184 { |
190 if (!m_pPage) { | 185 if (!m_pPage) { |
191 m_IsParsered = FALSE; | 186 m_IsParsered = FALSE; |
192 return FALSE; | 187 return FALSE; |
193 } | 188 } |
194 m_IsParsered = FALSE; | 189 m_IsParsered = FALSE; |
195 m_TextBuf.Clear(); | 190 m_TextBuf.Clear(); |
196 m_charList.RemoveAll(); | 191 m_charList.RemoveAll(); |
197 m_pPreTextObj = NULL; | 192 m_pPreTextObj = NULL; |
198 ProcessObject(); | 193 ProcessObject(); |
199 m_IsParsered = TRUE; | 194 m_IsParsered = TRUE; |
200 if(!m_ParseOptions.m_bGetCharCodeOnly) { | 195 if(!m_ParseOptions.m_bGetCharCodeOnly) { |
201 m_CharIndex.RemoveAll(); | 196 m_CharIndex.RemoveAll(); |
202 int nCount = m_charList.GetSize(); | 197 int nCount = m_charList.GetSize(); |
203 if(nCount) { | 198 if(nCount) { |
204 m_CharIndex.Add(0); | 199 m_CharIndex.Add(0); |
205 } | 200 } |
206 for(int i = 0; i < nCount; i++) { | 201 for(int i = 0; i < nCount; i++) { |
207 int indexSize = m_CharIndex.GetSize(); | 202 int indexSize = m_CharIndex.GetSize(); |
208 FX_BOOL bNormal = FALSE; | 203 FX_BOOL bNormal = FALSE; |
209 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); | 204 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); |
210 if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { | 205 if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
211 bNormal = TRUE; | 206 bNormal = TRUE; |
212 } | 207 } |
213 else if(charinfo.m_Unicode == 0 || IsControlChar(&charinfo)) | 208 else if(charinfo.m_Unicode == 0 || IsControlChar(charinfo)) |
214 bNormal = FALSE; | 209 bNormal = FALSE; |
215 else { | 210 else { |
216 bNormal = TRUE; | 211 bNormal = TRUE; |
217 } | 212 } |
218 if(bNormal) { | 213 if(bNormal) { |
219 if(indexSize % 2) { | 214 if(indexSize % 2) { |
220 m_CharIndex.Add(1); | 215 m_CharIndex.Add(1); |
221 } else { | 216 } else { |
222 if(indexSize <= 0) { | 217 if(indexSize <= 0) { |
223 continue; | 218 continue; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 return; | 483 return; |
489 } | 484 } |
490 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance
, FX_FLOAT yTorelance) const | 485 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance
, FX_FLOAT yTorelance) const |
491 { | 486 { |
492 if(m_ParseOptions.m_bGetCharCodeOnly) { | 487 if(m_ParseOptions.m_bGetCharCodeOnly) { |
493 return -3; | 488 return -3; |
494 } | 489 } |
495 CPDF_Point point(x, y); | 490 CPDF_Point point(x, y); |
496 return GetIndexAtPos(point, xTorelance, yTorelance); | 491 return GetIndexAtPos(point, xTorelance, yTorelance); |
497 } | 492 } |
498 int CPDF_TextPage::GetOrderByDirection(int order, int direction) const | |
499 { | |
500 if(m_ParseOptions.m_bGetCharCodeOnly) { | |
501 return -3; | |
502 } | |
503 if (!m_IsParsered) { | |
504 return -3; | |
505 } | |
506 if (direction == FPDFTEXT_RIGHT || direction == FPDFTEXT_LEFT) { | |
507 order += direction; | |
508 while(order >= 0 && order < m_charList.GetSize()) { | |
509 PAGECHAR_INFO cinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order); | |
510 if (cinfo.m_Flag != FPDFTEXT_CHAR_GENERATED) { | |
511 break; | |
512 } else { | |
513 if (cinfo.m_Unicode == TEXT_LINEFEED_CHAR || cinfo.m_Unicode ==
TEXT_RETURN_CHAR) { | |
514 order += direction; | |
515 } else { | |
516 break; | |
517 } | |
518 } | |
519 } | |
520 if (order >= m_charList.GetSize()) { | |
521 order = -2; | |
522 } | |
523 return order; | |
524 } | |
525 PAGECHAR_INFO charinfo; | |
526 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order); | |
527 CPDF_Point curPos(charinfo.m_OriginX, charinfo.m_OriginY); | |
528 FX_FLOAT difPosY = 0.0, minXdif = 1000; | |
529 int minIndex = -2; | |
530 int index = order; | |
531 FX_FLOAT height = charinfo.m_CharBox.Height(); | |
532 if (direction == FPDFTEXT_UP) { | |
533 minIndex = -1; | |
534 while (1) { | |
535 if (--index < 0) { | |
536 return -1; | |
537 } | |
538 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); | |
539 if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, chari
nfo.m_CharBox.Height()) / 2) { | |
540 difPosY = charinfo.m_OriginY; | |
541 minIndex = index; | |
542 break; | |
543 } | |
544 } | |
545 FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x; | |
546 minXdif = PreXdif; | |
547 if (PreXdif == 0) { | |
548 return index; | |
549 } | |
550 FX_FLOAT curXdif = 0; | |
551 while (--index >= 0) { | |
552 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); | |
553 if (difPosY != charinfo.m_OriginY) { | |
554 break; | |
555 } | |
556 curXdif = charinfo.m_OriginX - curPos.x; | |
557 if (curXdif == 0) { | |
558 return index; | |
559 } | |
560 int signflag = 0; | |
561 if (curXdif > 0) { | |
562 signflag = 1; | |
563 } else { | |
564 signflag = -1; | |
565 } | |
566 if (signflag * PreXdif < 0) { | |
567 if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) { | |
568 return index + 1; | |
569 } else { | |
570 return index; | |
571 } | |
572 } | |
573 if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) { | |
574 minIndex = index; | |
575 minXdif = curXdif; | |
576 } | |
577 PreXdif = curXdif; | |
578 if (difPosY != charinfo.m_OriginY) { | |
579 break; | |
580 } | |
581 } | |
582 return minIndex; | |
583 } else if(FPDFTEXT_DOWN) { | |
584 minIndex = -2; | |
585 while (1) { | |
586 if (++index > m_charList.GetSize() - 1) { | |
587 return minIndex; | |
588 } | |
589 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); | |
590 if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, chari
nfo.m_CharBox.Height()) / 2) { | |
591 difPosY = charinfo.m_OriginY; | |
592 minIndex = index; | |
593 break; | |
594 } | |
595 } | |
596 FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x; | |
597 minXdif = PreXdif; | |
598 if (PreXdif == 0) { | |
599 return index; | |
600 } | |
601 FX_FLOAT curXdif = 0; | |
602 while (++index < m_charList.GetSize()) { | |
603 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); | |
604 if (difPosY != charinfo.m_OriginY) { | |
605 break; | |
606 } | |
607 curXdif = charinfo.m_OriginX - curPos.x; | |
608 if (curXdif == 0) { | |
609 return index; | |
610 } | |
611 int signflag = 0; | |
612 if (curXdif > 0) { | |
613 signflag = 1; | |
614 } else { | |
615 signflag = -1; | |
616 } | |
617 if (signflag * PreXdif < 0) { | |
618 if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) { | |
619 return index - 1; | |
620 } else { | |
621 return index; | |
622 } | |
623 } | |
624 if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) { | |
625 minXdif = curXdif; | |
626 minIndex = index; | |
627 } | |
628 PreXdif = curXdif; | |
629 } | |
630 return minIndex; | |
631 } | |
632 } | |
633 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const | 493 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const |
634 { | 494 { |
635 if(m_ParseOptions.m_bGetCharCodeOnly) { | 495 if(m_ParseOptions.m_bGetCharCodeOnly) { |
636 return; | 496 return; |
637 } | 497 } |
638 if (!m_IsParsered) { | 498 if (!m_IsParsered) { |
639 return; | 499 return; |
640 } | 500 } |
641 if (index < 0 || index >= m_charList.GetSize()) { | 501 if (index < 0 || index >= m_charList.GetSize()) { |
642 return; | 502 return; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 return index; | 808 return index; |
949 } | 809 } |
950 int breakPos = index; | 810 int breakPos = index; |
951 if (direction == FPDFTEXT_LEFT) { | 811 if (direction == FPDFTEXT_LEFT) { |
952 while (--breakPos > 0) { | 812 while (--breakPos > 0) { |
953 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); | 813 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
954 if (!IsLetter(charinfo.m_Unicode)) { | 814 if (!IsLetter(charinfo.m_Unicode)) { |
955 return breakPos; | 815 return breakPos; |
956 } | 816 } |
957 } | 817 } |
958 return breakPos; | |
959 } else if (direction == FPDFTEXT_RIGHT) { | 818 } else if (direction == FPDFTEXT_RIGHT) { |
960 while (++breakPos < m_charList.GetSize()) { | 819 while (++breakPos < m_charList.GetSize()) { |
961 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); | 820 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
962 if (!IsLetter(charinfo.m_Unicode)) { | 821 if (!IsLetter(charinfo.m_Unicode)) { |
963 return breakPos; | 822 return breakPos; |
964 } | 823 } |
965 } | 824 } |
966 return breakPos; | |
967 } | 825 } |
968 return breakPos; | 826 return breakPos; |
969 } | 827 } |
970 int32_t CPDF_TextPage::FindTextlineFlowDirection() | 828 int32_t CPDF_TextPage::FindTextlineFlowDirection() |
971 { | 829 { |
972 if (!m_pPage) { | 830 if (!m_pPage) { |
973 return -1; | 831 return -1; |
974 } | 832 } |
975 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); | 833 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); |
976 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); | 834 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 for(int i = start; i < end; i++) { | 1015 for(int i = start; i < end; i++) { |
1158 m_TextBuf.AppendChar(str.GetAt(i)); | 1016 m_TextBuf.AppendChar(str.GetAt(i)); |
1159 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); | 1017 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
1160 } | 1018 } |
1161 } | 1019 } |
1162 } | 1020 } |
1163 void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) | 1021 void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) |
1164 { | 1022 { |
1165 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); | 1023 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); |
1166 FX_WCHAR wChar = str.GetAt(i); | 1024 FX_WCHAR wChar = str.GetAt(i); |
1167 if(!IsControlChar(&Info)) { | 1025 if(!IsControlChar(Info)) { |
1168 Info.m_Index = m_TextBuf.GetLength(); | 1026 Info.m_Index = m_TextBuf.GetLength(); |
1169 if (wChar >= 0xFB00 && wChar <= 0xFB06) { | 1027 if (wChar >= 0xFB00 && wChar <= 0xFB06) { |
1170 FX_WCHAR* pDst = NULL; | 1028 FX_WCHAR* pDst = NULL; |
1171 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); | 1029 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); |
1172 if (nCount >= 1) { | 1030 if (nCount >= 1) { |
1173 pDst = FX_Alloc(FX_WCHAR, nCount); | 1031 pDst = FX_Alloc(FX_WCHAR, nCount); |
1174 FX_Unicode_GetNormalization(wChar, pDst); | 1032 FX_Unicode_GetNormalization(wChar, pDst); |
1175 for (int nIndex = 0; nIndex < nCount; nIndex++) { | 1033 for (int nIndex = 0; nIndex < nCount; nIndex++) { |
1176 PAGECHAR_INFO Info2 = Info; | 1034 PAGECHAR_INFO Info2 = Info; |
1177 Info2.m_Unicode = pDst[nIndex]; | 1035 Info2.m_Unicode = pDst[nIndex]; |
(...skipping 11 matching lines...) Expand all Loading... |
1189 } else { | 1047 } else { |
1190 Info.m_Index = -1; | 1048 Info.m_Index = -1; |
1191 } | 1049 } |
1192 if( !m_ParseOptions.m_bGetCharCodeOnly) { | 1050 if( !m_ParseOptions.m_bGetCharCodeOnly) { |
1193 m_charList.Add(Info); | 1051 m_charList.Add(Info); |
1194 } | 1052 } |
1195 } | 1053 } |
1196 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) | 1054 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) |
1197 { | 1055 { |
1198 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); | 1056 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); |
1199 if(!IsControlChar(&Info)) { | 1057 if(!IsControlChar(Info)) { |
1200 Info.m_Index = m_TextBuf.GetLength(); | 1058 Info.m_Index = m_TextBuf.GetLength(); |
1201 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); | 1059 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); |
1202 FX_WCHAR* pDst = NULL; | 1060 FX_WCHAR* pDst = NULL; |
1203 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); | 1061 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); |
1204 if (nCount >= 1) { | 1062 if (nCount >= 1) { |
1205 pDst = FX_Alloc(FX_WCHAR, nCount); | 1063 pDst = FX_Alloc(FX_WCHAR, nCount); |
1206 FX_Unicode_GetNormalization(wChar, pDst); | 1064 FX_Unicode_GetNormalization(wChar, pDst); |
1207 for (int nIndex = 0; nIndex < nCount; nIndex++) { | 1065 for (int nIndex = 0; nIndex < nCount; nIndex++) { |
1208 PAGECHAR_INFO Info2 = Info; | 1066 PAGECHAR_INFO Info2 = Info; |
1209 Info2.m_Unicode = pDst[nIndex]; | 1067 Info2.m_Unicode = pDst[nIndex]; |
1210 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; | 1068 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; |
1211 m_TextBuf.AppendChar(Info2.m_Unicode); | 1069 m_TextBuf.AppendChar(Info2.m_Unicode); |
1212 if( !m_ParseOptions.m_bGetCharCodeOnly) { | 1070 if( !m_ParseOptions.m_bGetCharCodeOnly) { |
1213 m_charList.Add(Info2); | 1071 m_charList.Add(Info2); |
1214 } | 1072 } |
1215 } | 1073 } |
1216 FX_Free(pDst); | 1074 FX_Free(pDst); |
1217 return; | 1075 return; |
1218 } else { | |
1219 Info.m_Unicode = wChar; | |
1220 } | 1076 } |
| 1077 Info.m_Unicode = wChar; |
1221 m_TextBuf.AppendChar(Info.m_Unicode); | 1078 m_TextBuf.AppendChar(Info.m_Unicode); |
1222 } else { | 1079 } else { |
1223 Info.m_Index = -1; | 1080 Info.m_Index = -1; |
1224 } | 1081 } |
1225 if( !m_ParseOptions.m_bGetCharCodeOnly) { | 1082 if( !m_ParseOptions.m_bGetCharCodeOnly) { |
1226 m_charList.Add(Info); | 1083 m_charList.Add(Info); |
1227 } | 1084 } |
1228 } | 1085 } |
1229 void CPDF_TextPage::CloseTempLine() | 1086 void CPDF_TextPage::CloseTempLine() |
1230 { | 1087 { |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); | 1760 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); |
1904 FX_FLOAT dX = FXSYS_fabs(last.m_OriginX - first.m_OriginX); | 1761 FX_FLOAT dX = FXSYS_fabs(last.m_OriginX - first.m_OriginX); |
1905 FX_FLOAT dY = FXSYS_fabs(last.m_OriginY - first.m_OriginY); | 1762 FX_FLOAT dY = FXSYS_fabs(last.m_OriginY - first.m_OriginY); |
1906 if (dX <= 0.0001f && dY <= 0.0001f) { | 1763 if (dX <= 0.0001f && dY <= 0.0001f) { |
1907 return -1; | 1764 return -1; |
1908 } | 1765 } |
1909 CFX_VectorF v; | 1766 CFX_VectorF v; |
1910 v.Set(dX, dY); | 1767 v.Set(dX, dY); |
1911 v.Normalize(); | 1768 v.Normalize(); |
1912 if (v.y <= 0.0872f) { | 1769 if (v.y <= 0.0872f) { |
1913 if (v.x <= 0.0872f) { | 1770 return v.x <= 0.0872f ? m_TextlineDir : 0; |
1914 return m_TextlineDir; | 1771 } |
1915 } | 1772 if (v.x <= 0.0872f) { |
1916 return 0; | |
1917 } else if (v.x <= 0.0872f) { | |
1918 return 1; | 1773 return 1; |
1919 } | 1774 } |
1920 return m_TextlineDir; | 1775 return m_TextlineDir; |
1921 } | 1776 } |
1922 FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) | 1777 FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) |
1923 { | 1778 { |
1924 CFX_WideString strCurText = m_TempTextBuf.GetWideString(); | 1779 CFX_WideString strCurText = m_TempTextBuf.GetWideString(); |
1925 if(strCurText.GetLength() == 0) { | 1780 if(strCurText.GetLength() == 0) { |
1926 strCurText = m_TextBuf.GetWideString(); | 1781 strCurText = m_TextBuf.GetWideString(); |
1927 } | 1782 } |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 } | 2541 } |
2687 } | 2542 } |
2688 } | 2543 } |
2689 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) | 2544 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) |
2690 { | 2545 { |
2691 CFX_WideString str = strBeCheck; | 2546 CFX_WideString str = strBeCheck; |
2692 str.MakeLower(); | 2547 str.MakeLower(); |
2693 if (str.Find(L"http://www.") != -1) { | 2548 if (str.Find(L"http://www.") != -1) { |
2694 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.")
); | 2549 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.")
); |
2695 return TRUE; | 2550 return TRUE; |
2696 } else if (str.Find(L"http://") != -1) { | 2551 } |
| 2552 if (str.Find(L"http://") != -1) { |
2697 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); | 2553 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); |
2698 return TRUE; | 2554 return TRUE; |
2699 } else if (str.Find(L"https://www.") != -1) { | 2555 } |
| 2556 if (str.Find(L"https://www.") != -1) { |
2700 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www."
)); | 2557 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www."
)); |
2701 return TRUE; | 2558 return TRUE; |
2702 } else if (str.Find(L"https://") != -1) { | 2559 } |
| 2560 if (str.Find(L"https://") != -1) { |
2703 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); | 2561 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); |
2704 return TRUE; | 2562 return TRUE; |
2705 } else if (str.Find(L"www.") != -1) { | 2563 } |
| 2564 if (str.Find(L"www.") != -1) { |
2706 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); | 2565 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); |
2707 strBeCheck = L"http://" + strBeCheck; | 2566 strBeCheck = L"http://" + strBeCheck; |
2708 return TRUE; | 2567 return TRUE; |
2709 } else { | |
2710 return FALSE; | |
2711 } | 2568 } |
| 2569 return FALSE; |
2712 } | 2570 } |
2713 FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) | 2571 FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) |
2714 { | 2572 { |
2715 str.MakeLower(); | 2573 str.MakeLower(); |
2716 int aPos = str.Find(L'@'); | 2574 int aPos = str.Find(L'@'); |
2717 if (aPos < 1) { | 2575 if (aPos < 1) { |
2718 return FALSE; | 2576 return FALSE; |
2719 } | 2577 } |
2720 if (str.GetAt(aPos - 1) == L'.' || str.GetAt(aPos - 1) == L'_') { | 2578 if (str.GetAt(aPos - 1) == L'.' || str.GetAt(aPos - 1) == L'_') { |
2721 return FALSE; | 2579 return FALSE; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2831 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2689 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
2832 return; | 2690 return; |
2833 } | 2691 } |
2834 CPDF_LinkExt* link = NULL; | 2692 CPDF_LinkExt* link = NULL; |
2835 link = m_LinkList.GetAt(index); | 2693 link = m_LinkList.GetAt(index); |
2836 if (!link) { | 2694 if (!link) { |
2837 return ; | 2695 return ; |
2838 } | 2696 } |
2839 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2697 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
2840 } | 2698 } |
OLD | NEW |