Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: core/src/fpdftext/fpdf_text_int.cpp

Issue 1243953004: Re-land else-after-returns (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_vt.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 m_pPage = pPage; 154 m_pPage = pPage;
153 m_parserflag = flags; 155 m_parserflag = flags;
154 m_TextBuf.EstimateSize(0, 10240); 156 m_TextBuf.EstimateSize(0, 10240);
155 CFX_FloatRect pageRect = pPage->CalcBoundingBox(); 157 CFX_FloatRect pageRect = pPage->CalcBoundingBox();
156 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top ); 158 m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top );
157 } 159 }
158 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) 160 void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize)
159 { 161 {
160 m_ParseOptions.m_bNormalizeObjs = bNormalize; 162 m_ParseOptions.m_bNormalizeObjs = bNormalize;
161 } 163 }
162 FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) 164 bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo)
163 { 165 {
164 if(!pCharInfo) { 166 switch (charInfo.m_Unicode) {
165 return FALSE;
166 }
167 switch(pCharInfo->m_Unicode) {
168 case 0x2: 167 case 0x2:
169 case 0x3: 168 case 0x3:
170 case 0x93: 169 case 0x93:
171 case 0x94: 170 case 0x94:
172 case 0x96: 171 case 0x96:
173 case 0x97: 172 case 0x97:
174 case 0x98: 173 case 0x98:
175 case 0xfffe: 174 case 0xfffe:
176 if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) { 175 return charInfo.m_Flag != FPDFTEXT_CHAR_HYPHEN;
177 return FALSE;
178 } else {
179 return TRUE;
180 }
181 default: 176 default:
182 return FALSE; 177 return false;
183 } 178 }
184 } 179 }
185 FX_BOOL CPDF_TextPage::ParseTextPage() 180 FX_BOOL CPDF_TextPage::ParseTextPage()
186 { 181 {
187 if (!m_pPage) { 182 if (!m_pPage) {
188 m_IsParsered = FALSE; 183 m_IsParsered = FALSE;
189 return FALSE; 184 return FALSE;
190 } 185 }
191 m_IsParsered = FALSE; 186 m_IsParsered = FALSE;
192 m_TextBuf.Clear(); 187 m_TextBuf.Clear();
193 m_charList.RemoveAll(); 188 m_charList.RemoveAll();
194 m_pPreTextObj = NULL; 189 m_pPreTextObj = NULL;
195 ProcessObject(); 190 ProcessObject();
196 m_IsParsered = TRUE; 191 m_IsParsered = TRUE;
197 if(!m_ParseOptions.m_bGetCharCodeOnly) { 192 if(!m_ParseOptions.m_bGetCharCodeOnly) {
198 m_CharIndex.RemoveAll(); 193 m_CharIndex.RemoveAll();
199 int nCount = m_charList.GetSize(); 194 int nCount = m_charList.GetSize();
200 if(nCount) { 195 if(nCount) {
201 m_CharIndex.Add(0); 196 m_CharIndex.Add(0);
202 } 197 }
203 for(int i = 0; i < nCount; i++) { 198 for(int i = 0; i < nCount; i++) {
204 int indexSize = m_CharIndex.GetSize(); 199 int indexSize = m_CharIndex.GetSize();
205 FX_BOOL bNormal = FALSE; 200 FX_BOOL bNormal = FALSE;
206 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); 201 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i);
207 if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { 202 if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
208 bNormal = TRUE; 203 bNormal = TRUE;
209 } 204 }
210 else if(charinfo.m_Unicode == 0 || IsControlChar(&charinfo)) 205 else if(charinfo.m_Unicode == 0 || IsControlChar(charinfo))
211 bNormal = FALSE; 206 bNormal = FALSE;
212 else { 207 else {
213 bNormal = TRUE; 208 bNormal = TRUE;
214 } 209 }
215 if(bNormal) { 210 if(bNormal) {
216 if(indexSize % 2) { 211 if(indexSize % 2) {
217 m_CharIndex.Add(1); 212 m_CharIndex.Add(1);
218 } else { 213 } else {
219 if(indexSize <= 0) { 214 if(indexSize <= 0) {
220 continue; 215 continue;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 return; 480 return;
486 } 481 }
487 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance , FX_FLOAT yTorelance) const 482 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance , FX_FLOAT yTorelance) const
488 { 483 {
489 if(m_ParseOptions.m_bGetCharCodeOnly) { 484 if(m_ParseOptions.m_bGetCharCodeOnly) {
490 return -3; 485 return -3;
491 } 486 }
492 CPDF_Point point(x, y); 487 CPDF_Point point(x, y);
493 return GetIndexAtPos(point, xTorelance, yTorelance); 488 return GetIndexAtPos(point, xTorelance, yTorelance);
494 } 489 }
495 int CPDF_TextPage::GetOrderByDirection(int order, int direction) const
496 {
497 if(m_ParseOptions.m_bGetCharCodeOnly) {
498 return -3;
499 }
500 if (!m_IsParsered) {
501 return -3;
502 }
503 if (direction == FPDFTEXT_RIGHT || direction == FPDFTEXT_LEFT) {
504 order += direction;
505 while(order >= 0 && order < m_charList.GetSize()) {
506 PAGECHAR_INFO cinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order);
507 if (cinfo.m_Flag != FPDFTEXT_CHAR_GENERATED) {
508 break;
509 } else {
510 if (cinfo.m_Unicode == TEXT_LINEFEED_CHAR || cinfo.m_Unicode == TEXT_RETURN_CHAR) {
511 order += direction;
512 } else {
513 break;
514 }
515 }
516 }
517 if (order >= m_charList.GetSize()) {
518 order = -2;
519 }
520 return order;
521 }
522 PAGECHAR_INFO charinfo;
523 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order);
524 CPDF_Point curPos(charinfo.m_OriginX, charinfo.m_OriginY);
525 FX_FLOAT difPosY = 0.0, minXdif = 1000;
526 int minIndex = -2;
527 int index = order;
528 FX_FLOAT height = charinfo.m_CharBox.Height();
529 if (direction == FPDFTEXT_UP) {
530 minIndex = -1;
531 while (1) {
532 if (--index < 0) {
533 return -1;
534 }
535 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
536 if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, chari nfo.m_CharBox.Height()) / 2) {
537 difPosY = charinfo.m_OriginY;
538 minIndex = index;
539 break;
540 }
541 }
542 FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x;
543 minXdif = PreXdif;
544 if (PreXdif == 0) {
545 return index;
546 }
547 FX_FLOAT curXdif = 0;
548 while (--index >= 0) {
549 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
550 if (difPosY != charinfo.m_OriginY) {
551 break;
552 }
553 curXdif = charinfo.m_OriginX - curPos.x;
554 if (curXdif == 0) {
555 return index;
556 }
557 int signflag = 0;
558 if (curXdif > 0) {
559 signflag = 1;
560 } else {
561 signflag = -1;
562 }
563 if (signflag * PreXdif < 0) {
564 if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) {
565 return index + 1;
566 } else {
567 return index;
568 }
569 }
570 if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) {
571 minIndex = index;
572 minXdif = curXdif;
573 }
574 PreXdif = curXdif;
575 if (difPosY != charinfo.m_OriginY) {
576 break;
577 }
578 }
579 return minIndex;
580 } else if(FPDFTEXT_DOWN) {
581 minIndex = -2;
582 while (1) {
583 if (++index > m_charList.GetSize() - 1) {
584 return minIndex;
585 }
586 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
587 if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, chari nfo.m_CharBox.Height()) / 2) {
588 difPosY = charinfo.m_OriginY;
589 minIndex = index;
590 break;
591 }
592 }
593 FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x;
594 minXdif = PreXdif;
595 if (PreXdif == 0) {
596 return index;
597 }
598 FX_FLOAT curXdif = 0;
599 while (++index < m_charList.GetSize()) {
600 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
601 if (difPosY != charinfo.m_OriginY) {
602 break;
603 }
604 curXdif = charinfo.m_OriginX - curPos.x;
605 if (curXdif == 0) {
606 return index;
607 }
608 int signflag = 0;
609 if (curXdif > 0) {
610 signflag = 1;
611 } else {
612 signflag = -1;
613 }
614 if (signflag * PreXdif < 0) {
615 if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) {
616 return index - 1;
617 } else {
618 return index;
619 }
620 }
621 if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) {
622 minXdif = curXdif;
623 minIndex = index;
624 }
625 PreXdif = curXdif;
626 }
627 return minIndex;
628 }
629 }
630 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const 490 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const
631 { 491 {
632 if(m_ParseOptions.m_bGetCharCodeOnly) { 492 if(m_ParseOptions.m_bGetCharCodeOnly) {
633 return; 493 return;
634 } 494 }
635 if (!m_IsParsered) { 495 if (!m_IsParsered) {
636 return; 496 return;
637 } 497 }
638 if (index < 0 || index >= m_charList.GetSize()) { 498 if (index < 0 || index >= m_charList.GetSize()) {
639 return; 499 return;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 return index; 805 return index;
946 } 806 }
947 int breakPos = index; 807 int breakPos = index;
948 if (direction == FPDFTEXT_LEFT) { 808 if (direction == FPDFTEXT_LEFT) {
949 while (--breakPos > 0) { 809 while (--breakPos > 0) {
950 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); 810 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos);
951 if (!IsLetter(charinfo.m_Unicode)) { 811 if (!IsLetter(charinfo.m_Unicode)) {
952 return breakPos; 812 return breakPos;
953 } 813 }
954 } 814 }
955 return breakPos;
956 } else if (direction == FPDFTEXT_RIGHT) { 815 } else if (direction == FPDFTEXT_RIGHT) {
957 while (++breakPos < m_charList.GetSize()) { 816 while (++breakPos < m_charList.GetSize()) {
958 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); 817 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos);
959 if (!IsLetter(charinfo.m_Unicode)) { 818 if (!IsLetter(charinfo.m_Unicode)) {
960 return breakPos; 819 return breakPos;
961 } 820 }
962 } 821 }
963 return breakPos;
964 } 822 }
965 return breakPos; 823 return breakPos;
966 } 824 }
967 int32_t CPDF_TextPage::FindTextlineFlowDirection() 825 int32_t CPDF_TextPage::FindTextlineFlowDirection()
968 { 826 {
969 if (!m_pPage) { 827 if (!m_pPage) {
970 return -1; 828 return -1;
971 } 829 }
972 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); 830 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth();
973 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); 831 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 for(int i = start; i < end; i++) { 1012 for(int i = start; i < end; i++) {
1155 m_TextBuf.AppendChar(str.GetAt(i)); 1013 m_TextBuf.AppendChar(str.GetAt(i));
1156 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); 1014 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i));
1157 } 1015 }
1158 } 1016 }
1159 } 1017 }
1160 void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) 1018 void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i)
1161 { 1019 {
1162 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 1020 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
1163 FX_WCHAR wChar = str.GetAt(i); 1021 FX_WCHAR wChar = str.GetAt(i);
1164 if(!IsControlChar(&Info)) { 1022 if(!IsControlChar(Info)) {
1165 Info.m_Index = m_TextBuf.GetLength(); 1023 Info.m_Index = m_TextBuf.GetLength();
1166 if (wChar >= 0xFB00 && wChar <= 0xFB06) { 1024 if (wChar >= 0xFB00 && wChar <= 0xFB06) {
1167 FX_WCHAR* pDst = NULL; 1025 FX_WCHAR* pDst = NULL;
1168 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 1026 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1169 if (nCount >= 1) { 1027 if (nCount >= 1) {
1170 pDst = FX_Alloc(FX_WCHAR, nCount); 1028 pDst = FX_Alloc(FX_WCHAR, nCount);
1171 FX_Unicode_GetNormalization(wChar, pDst); 1029 FX_Unicode_GetNormalization(wChar, pDst);
1172 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1030 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1173 PAGECHAR_INFO Info2 = Info; 1031 PAGECHAR_INFO Info2 = Info;
1174 Info2.m_Unicode = pDst[nIndex]; 1032 Info2.m_Unicode = pDst[nIndex];
(...skipping 11 matching lines...) Expand all
1186 } else { 1044 } else {
1187 Info.m_Index = -1; 1045 Info.m_Index = -1;
1188 } 1046 }
1189 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1047 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1190 m_charList.Add(Info); 1048 m_charList.Add(Info);
1191 } 1049 }
1192 } 1050 }
1193 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) 1051 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i)
1194 { 1052 {
1195 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 1053 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
1196 if(!IsControlChar(&Info)) { 1054 if(!IsControlChar(Info)) {
1197 Info.m_Index = m_TextBuf.GetLength(); 1055 Info.m_Index = m_TextBuf.GetLength();
1198 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); 1056 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE);
1199 FX_WCHAR* pDst = NULL; 1057 FX_WCHAR* pDst = NULL;
1200 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 1058 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1201 if (nCount >= 1) { 1059 if (nCount >= 1) {
1202 pDst = FX_Alloc(FX_WCHAR, nCount); 1060 pDst = FX_Alloc(FX_WCHAR, nCount);
1203 FX_Unicode_GetNormalization(wChar, pDst); 1061 FX_Unicode_GetNormalization(wChar, pDst);
1204 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1062 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1205 PAGECHAR_INFO Info2 = Info; 1063 PAGECHAR_INFO Info2 = Info;
1206 Info2.m_Unicode = pDst[nIndex]; 1064 Info2.m_Unicode = pDst[nIndex];
1207 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 1065 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1208 m_TextBuf.AppendChar(Info2.m_Unicode); 1066 m_TextBuf.AppendChar(Info2.m_Unicode);
1209 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1067 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1210 m_charList.Add(Info2); 1068 m_charList.Add(Info2);
1211 } 1069 }
1212 } 1070 }
1213 FX_Free(pDst); 1071 FX_Free(pDst);
1214 return; 1072 return;
1215 } else {
1216 Info.m_Unicode = wChar;
1217 } 1073 }
1074 Info.m_Unicode = wChar;
1218 m_TextBuf.AppendChar(Info.m_Unicode); 1075 m_TextBuf.AppendChar(Info.m_Unicode);
1219 } else { 1076 } else {
1220 Info.m_Index = -1; 1077 Info.m_Index = -1;
1221 } 1078 }
1222 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1079 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1223 m_charList.Add(Info); 1080 m_charList.Add(Info);
1224 } 1081 }
1225 } 1082 }
1226 void CPDF_TextPage::CloseTempLine() 1083 void CPDF_TextPage::CloseTempLine()
1227 { 1084 {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); 1765 textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY);
1909 FX_FLOAT dX = FXSYS_fabs(last.m_OriginX - first.m_OriginX); 1766 FX_FLOAT dX = FXSYS_fabs(last.m_OriginX - first.m_OriginX);
1910 FX_FLOAT dY = FXSYS_fabs(last.m_OriginY - first.m_OriginY); 1767 FX_FLOAT dY = FXSYS_fabs(last.m_OriginY - first.m_OriginY);
1911 if (dX <= 0.0001f && dY <= 0.0001f) { 1768 if (dX <= 0.0001f && dY <= 0.0001f) {
1912 return -1; 1769 return -1;
1913 } 1770 }
1914 CFX_VectorF v; 1771 CFX_VectorF v;
1915 v.Set(dX, dY); 1772 v.Set(dX, dY);
1916 v.Normalize(); 1773 v.Normalize();
1917 if (v.y <= 0.0872f) { 1774 if (v.y <= 0.0872f) {
1918 if (v.x <= 0.0872f) { 1775 return v.x <= 0.0872f ? m_TextlineDir : 0;
1919 return m_TextlineDir; 1776 }
1920 } 1777 if (v.x <= 0.0872f) {
1921 return 0;
1922 } else if (v.x <= 0.0872f) {
1923 return 1; 1778 return 1;
1924 } 1779 }
1925 return m_TextlineDir; 1780 return m_TextlineDir;
1926 } 1781 }
1927 FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) 1782 FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar)
1928 { 1783 {
1929 CFX_WideString strCurText = m_TempTextBuf.GetWideString(); 1784 CFX_WideString strCurText = m_TempTextBuf.GetWideString();
1930 if(strCurText.GetLength() == 0) { 1785 if(strCurText.GetLength() == 0) {
1931 strCurText = m_TextBuf.GetWideString(); 1786 strCurText = m_TextBuf.GetWideString();
1932 } 1787 }
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 } 2546 }
2692 } 2547 }
2693 } 2548 }
2694 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) 2549 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck)
2695 { 2550 {
2696 CFX_WideString str = strBeCheck; 2551 CFX_WideString str = strBeCheck;
2697 str.MakeLower(); 2552 str.MakeLower();
2698 if (str.Find(L"http://www.") != -1) { 2553 if (str.Find(L"http://www.") != -1) {
2699 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.") ); 2554 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.") );
2700 return TRUE; 2555 return TRUE;
2701 } else if (str.Find(L"http://") != -1) { 2556 }
2557 if (str.Find(L"http://") != -1) {
2702 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); 2558 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://"));
2703 return TRUE; 2559 return TRUE;
2704 } else if (str.Find(L"https://www.") != -1) { 2560 }
2561 if (str.Find(L"https://www.") != -1) {
2705 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www." )); 2562 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www." ));
2706 return TRUE; 2563 return TRUE;
2707 } else if (str.Find(L"https://") != -1) { 2564 }
2565 if (str.Find(L"https://") != -1) {
2708 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); 2566 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://"));
2709 return TRUE; 2567 return TRUE;
2710 } else if (str.Find(L"www.") != -1) { 2568 }
2569 if (str.Find(L"www.") != -1) {
2711 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); 2570 strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www."));
2712 strBeCheck = L"http://" + strBeCheck; 2571 strBeCheck = L"http://" + strBeCheck;
2713 return TRUE; 2572 return TRUE;
2714 } else {
2715 return FALSE;
2716 } 2573 }
2574 return FALSE;
2717 } 2575 }
2718 FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) 2576 FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str)
2719 { 2577 {
2720 str.MakeLower(); 2578 str.MakeLower();
2721 int aPos = str.Find(L'@'); 2579 int aPos = str.Find(L'@');
2722 if (aPos < 1) { 2580 if (aPos < 1) {
2723 return FALSE; 2581 return FALSE;
2724 } 2582 }
2725 if (str.GetAt(aPos - 1) == L'.' || str.GetAt(aPos - 1) == L'_') { 2583 if (str.GetAt(aPos - 1) == L'.' || str.GetAt(aPos - 1) == L'_') {
2726 return FALSE; 2584 return FALSE;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { 2690 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) {
2833 return; 2691 return;
2834 } 2692 }
2835 CPDF_LinkExt* link = NULL; 2693 CPDF_LinkExt* link = NULL;
2836 link = m_LinkList.GetAt(index); 2694 link = m_LinkList.GetAt(index);
2837 if (!link) { 2695 if (!link) {
2838 return ; 2696 return ;
2839 } 2697 }
2840 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2698 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2841 } 2699 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_vt.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698