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

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

Issue 816593002: Cleanup: Remove a shadow variable in CPDF_TextPage::CloseTempLine(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: nits Created 6 years 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 | « no previous file | no next file » | 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 "../../include/fpdfapi/fpdf_resource.h" 7 #include "../../include/fpdfapi/fpdf_resource.h"
8 #include "../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../include/fpdftext/fpdf_text.h" 9 #include "../../include/fpdftext/fpdf_text.h"
10 #include "../../include/fpdfapi/fpdf_page.h" 10 #include "../../include/fpdfapi/fpdf_page.h"
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 void CPDF_TextPage::CloseTempLine() 1185 void CPDF_TextPage::CloseTempLine()
1186 { 1186 {
1187 int count1 = m_TempCharList.GetSize(); 1187 int count1 = m_TempCharList.GetSize();
1188 if (count1 <= 0) { 1188 if (count1 <= 0) {
1189 return; 1189 return;
1190 } 1190 }
1191 IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); 1191 IFX_BidiChar* BidiChar = IFX_BidiChar::Create();
1192 CFX_WideString str = m_TempTextBuf.GetWideString(); 1192 CFX_WideString str = m_TempTextBuf.GetWideString();
1193 CFX_WordArray order; 1193 CFX_WordArray order;
1194 FX_BOOL bR2L = FALSE; 1194 FX_BOOL bR2L = FALSE;
1195 FX_INT32 start = 0, count = 0, i = 0; 1195 FX_INT32 start = 0, count = 0;
1196 int nR2L = 0, nL2R = 0; 1196 int nR2L = 0, nL2R = 0;
1197 FX_BOOL bPrevSpace = FALSE; 1197 FX_BOOL bPrevSpace = FALSE;
1198 for (i = 0; i < str.GetLength(); i++) { 1198 for (int i = 0; i < str.GetLength(); i++) {
1199 if(str.GetAt(i) == 32) { 1199 if(str.GetAt(i) == 32) {
1200 if(bPrevSpace) { 1200 if(bPrevSpace) {
1201 m_TempTextBuf.Delete(i, 1); 1201 m_TempTextBuf.Delete(i, 1);
1202 m_TempCharList.Delete(i); 1202 m_TempCharList.Delete(i);
1203 str.Delete(i); 1203 str.Delete(i);
1204 count1 --; 1204 count1--;
1205 i--; 1205 i--;
1206 continue; 1206 continue;
1207 } 1207 }
1208 bPrevSpace = TRUE; 1208 bPrevSpace = TRUE;
1209 } else { 1209 } else {
1210 bPrevSpace = FALSE; 1210 bPrevSpace = FALSE;
1211 } 1211 }
1212 if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) { 1212 if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) {
1213 FX_INT32 ret = BidiChar->GetBidiInfo(start, count); 1213 FX_INT32 ret = BidiChar->GetBidiInfo(start, count);
1214 order.Add(start); 1214 order.Add(start);
(...skipping 19 matching lines...) Expand all
1234 } else if(ret == 1) { 1234 } else if(ret == 1) {
1235 nL2R++; 1235 nL2R++;
1236 } 1236 }
1237 } 1237 }
1238 } 1238 }
1239 if(nR2L > 0 && nR2L >= nL2R) { 1239 if(nR2L > 0 && nR2L >= nL2R) {
1240 bR2L = TRUE; 1240 bR2L = TRUE;
1241 } 1241 }
1242 if(this->m_parserflag == FPDFTEXT_RLTB || bR2L) { 1242 if(this->m_parserflag == FPDFTEXT_RLTB || bR2L) {
1243 int count = order.GetSize(); 1243 int count = order.GetSize();
1244 for(int j = count - 1; j > 0; j -= 3) { 1244 for(int i = count - 1; i > 0; i -= 3) {
1245 int ret = order.GetAt(j); 1245 int ret = order.GetAt(i);
1246 int start = order.GetAt(j - 2); 1246 int start = order.GetAt(i - 2);
1247 int count1 = order.GetAt(j - 1); 1247 int count1 = order.GetAt(i - 1);
1248 if(ret == 2 || ret == 0) { 1248 if(ret == 2 || ret == 0) {
1249 for(int i = start + count1 - 1; i >= start; i--) { 1249 for(int j = start + count1 - 1; j >= start; j--) {
1250 AddCharInfoByRLDirection(str, i); 1250 AddCharInfoByRLDirection(str, j);
1251 } 1251 }
1252 } else { 1252 } else {
1253 i = j; 1253 int j = i;
1254 FX_BOOL bSymbol = FALSE; 1254 FX_BOOL bSymbol = FALSE;
1255 while(i > 0 && order.GetAt(i) != 2) { 1255 while(j > 0 && order.GetAt(j) != 2) {
1256 bSymbol = !order.GetAt(i); 1256 bSymbol = !order.GetAt(j);
1257 i -= 3; 1257 j -= 3;
1258 } 1258 }
1259 int end = start + count1 ; 1259 int end = start + count1 ;
1260 int n = 0; 1260 int n = 0;
1261 if(bSymbol) { 1261 if(bSymbol) {
1262 n = i + 6; 1262 n = j + 6;
1263 } else { 1263 } else {
1264 n = i + 3; 1264 n = j + 3;
1265 } 1265 }
1266 if(n >= j) { 1266 if(n >= i) {
1267 for(int m = start; m < end; m++) { 1267 for(int m = start; m < end; m++) {
1268 AddCharInfoByLRDirection(str, m); 1268 AddCharInfoByLRDirection(str, m);
1269 } 1269 }
1270 } else { 1270 } else {
1271 i = j; 1271 j = i;
1272 j = n; 1272 i = n;
1273 for(; n <= i; n += 3) { 1273 for(; n <= j; n += 3) {
1274 int start = order.GetAt(n - 2); 1274 int start = order.GetAt(n - 2);
1275 int count1 = order.GetAt(n - 1); 1275 int count1 = order.GetAt(n - 1);
1276 int end = start + count1 ; 1276 int end = start + count1 ;
1277 for(int m = start; m < end; m++) { 1277 for(int m = start; m < end; m++) {
1278 AddCharInfoByLRDirection(str, m); 1278 AddCharInfoByLRDirection(str, m);
1279 } 1279 }
1280 } 1280 }
1281 } 1281 }
1282 } 1282 }
1283 } 1283 }
1284 } else { 1284 } else {
1285 int count = order.GetSize(); 1285 int count = order.GetSize();
1286 FX_BOOL bL2R = FALSE; 1286 FX_BOOL bL2R = FALSE;
1287 for(int j = 0; j < count; j += 3) { 1287 for(int i = 0; i < count; i += 3) {
1288 int ret = order.GetAt(j + 2); 1288 int ret = order.GetAt(i + 2);
1289 int start = order.GetAt(j); 1289 int start = order.GetAt(i);
1290 int count1 = order.GetAt(j + 1); 1290 int count1 = order.GetAt(i + 1);
1291 if(ret == 2 || (j == 0 && ret == 0 && !bL2R)) { 1291 if(ret == 2 || (i == 0 && ret == 0 && !bL2R)) {
1292 int i = j + 3; 1292 int j = i + 3;
1293 while(bR2L && i < count) { 1293 while(bR2L && j < count) {
1294 if(order.GetAt(i + 2) == 1) { 1294 if(order.GetAt(j + 2) == 1) {
1295 break; 1295 break;
1296 } else { 1296 } else {
1297 i += 3; 1297 j += 3;
1298 } 1298 }
1299 } 1299 }
1300 if(i == 3) { 1300 if(j == 3) {
1301 j = -3; 1301 i = -3;
1302 bL2R = TRUE; 1302 bL2R = TRUE;
1303 continue; 1303 continue;
1304 } 1304 }
1305 int end = m_TempCharList.GetSize() - 1; 1305 int end = m_TempCharList.GetSize() - 1;
1306 if(i < count) { 1306 if(j < count) {
1307 end = order.GetAt(i) - 1; 1307 end = order.GetAt(j) - 1;
1308 } 1308 }
1309 j = i - 3; 1309 i = j - 3;
1310 for(int n = end; n >= start; n--) { 1310 for(int n = end; n >= start; n--) {
1311 AddCharInfoByRLDirection(str, n); 1311 AddCharInfoByRLDirection(str, n);
1312 } 1312 }
1313 } else { 1313 } else {
1314 int end = start + count1 ; 1314 int end = start + count1 ;
1315 for(int i = start; i < end; i++) { 1315 for(int n = start; n < end; n++) {
1316 AddCharInfoByLRDirection(str, i); 1316 AddCharInfoByLRDirection(str, n);
1317 } 1317 }
1318 } 1318 }
1319 } 1319 }
1320 } 1320 }
1321 int ntext = m_TextBuf.GetSize(); 1321 int ntext = m_TextBuf.GetSize();
1322 ntext = m_charList.GetSize(); 1322 ntext = m_charList.GetSize();
1323 order.RemoveAll(); 1323 order.RemoveAll();
1324 m_TempCharList.RemoveAll(); 1324 m_TempCharList.RemoveAll();
1325 m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength()); 1325 m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength());
1326 BidiChar->Release(); 1326 BidiChar->Release();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 continue; 1450 continue;
1451 } else { 1451 } else {
1452 bExist = TRUE; 1452 bExist = TRUE;
1453 break; 1453 break;
1454 } 1454 }
1455 } 1455 }
1456 if (!bExist) { 1456 if (!bExist) {
1457 return FPDFTEXT_MC_PASS; 1457 return FPDFTEXT_MC_PASS;
1458 } 1458 }
1459 bExist = FALSE; 1459 bExist = FALSE;
1460 for (FX_STRSIZE j = 0; j < nItems; j++) { 1460 for (FX_STRSIZE i = 0; i < nItems; i++) {
1461 FX_WCHAR wChar = actText.GetAt(j); 1461 FX_WCHAR wChar = actText.GetAt(i);
1462 if ((wChar > 0x80 && wChar < 0xFFFD) || (wChar <= 0x80 && isprint(wChar) )) { 1462 if ((wChar > 0x80 && wChar < 0xFFFD) || (wChar <= 0x80 && isprint(wChar) )) {
1463 bExist = TRUE; 1463 bExist = TRUE;
1464 break; 1464 break;
1465 } 1465 }
1466 } 1466 }
1467 if (!bExist) { 1467 if (!bExist) {
1468 return FPDFTEXT_MC_DONE; 1468 return FPDFTEXT_MC_DONE;
1469 } 1469 }
1470 return FPDFTEXT_MC_DELAY; 1470 return FPDFTEXT_MC_DELAY;
1471 } 1471 }
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { 2830 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) {
2831 return; 2831 return;
2832 } 2832 }
2833 CPDF_LinkExt* link = NULL; 2833 CPDF_LinkExt* link = NULL;
2834 link = m_LinkList.GetAt(index); 2834 link = m_LinkList.GetAt(index);
2835 if (!link) { 2835 if (!link) {
2836 return ; 2836 return ;
2837 } 2837 }
2838 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2838 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2839 } 2839 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698