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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1417933002: Add type cast definitions for CPDF_String. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 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
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_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_serial.h" 9 #include "../../../include/fpdfapi/fpdf_serial.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 if (str.IsEmpty()) { 1350 if (str.IsEmpty()) {
1351 return; 1351 return;
1352 } 1352 }
1353 AddTextObject(&str, 0, NULL, 1); 1353 AddTextObject(&str, 0, NULL, 1);
1354 } 1354 }
1355 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 1355 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
1356 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; 1356 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
1357 if (pArray == NULL) { 1357 if (pArray == NULL) {
1358 return; 1358 return;
1359 } 1359 }
1360 int n = pArray->GetCount(), nsegs = 0, i; 1360 int n = pArray->GetCount(), nsegs = 0, i;
Tom Sepez 2015/10/21 17:12:50 nit: one per line, also make i local to |for (int
dsinclair 2015/10/21 17:40:01 Done.
1361 for (i = 0; i < n; i++) { 1361 for (i = 0; i < n; i++) {
1362 CPDF_Object* pObj = pArray->GetElementValue(i); 1362 if (pArray->GetElementValue(i)->AsString())
Lei Zhang 2015/10/21 16:55:56 IsString ?
dsinclair 2015/10/21 17:08:05 Done.
1363 if (pObj->GetType() == PDFOBJ_STRING) {
1364 nsegs++; 1363 nsegs++;
1365 }
1366 } 1364 }
1367 if (nsegs == 0) { 1365 if (nsegs == 0) {
1368 for (i = 0; i < n; i++) { 1366 for (i = 0; i < n; i++) {
1369 m_pCurStates->m_TextX -= 1367 m_pCurStates->m_TextX -=
1370 FXSYS_Mul(pArray->GetNumber(i), 1368 FXSYS_Mul(pArray->GetNumber(i),
1371 m_pCurStates->m_TextState.GetFontSize()) / 1369 m_pCurStates->m_TextState.GetFontSize()) /
1372 1000; 1370 1000;
1373 }; 1371 };
1374 return; 1372 return;
1375 } 1373 }
1376 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; 1374 CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
1377 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); 1375 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
1378 int iSegment = 0; 1376 int iSegment = 0;
1379 FX_FLOAT fInitKerning = 0; 1377 FX_FLOAT fInitKerning = 0;
1380 for (i = 0; i < n; i++) { 1378 for (i = 0; i < n; i++) {
1381 CPDF_Object* pObj = pArray->GetElementValue(i); 1379 CPDF_Object* pObj = pArray->GetElementValue(i);
1382 if (pObj->GetType() == PDFOBJ_STRING) { 1380 if (pObj->IsString()) {
1383 CFX_ByteString str = pObj->GetString(); 1381 CFX_ByteString str = pObj->GetString();
1384 if (str.IsEmpty()) { 1382 if (str.IsEmpty()) {
1385 continue; 1383 continue;
1386 } 1384 }
1387 pStrs[iSegment] = str; 1385 pStrs[iSegment] = str;
1388 pKerning[iSegment++] = 0; 1386 pKerning[iSegment++] = 0;
1389 } else { 1387 } else {
1390 FX_FLOAT num = pObj ? pObj->GetNumber() : 0; 1388 FX_FLOAT num = pObj ? pObj->GetNumber() : 0;
1391 if (iSegment == 0) { 1389 if (iSegment == 0) {
1392 fInitKerning += num; 1390 fInitKerning += num;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 buf.AppendChar((char)code); 1586 buf.AppendChar((char)code);
1589 } 1587 }
1590 bFirst = !bFirst; 1588 bFirst = !bFirst;
1591 } 1589 }
1592 } 1590 }
1593 if (!bFirst) { 1591 if (!bFirst) {
1594 buf.AppendChar((char)code); 1592 buf.AppendChar((char)code);
1595 } 1593 }
1596 return buf.GetByteString(); 1594 return buf.GetByteString();
1597 } 1595 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698