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

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

Issue 1867183002: Use std::vector as internal storage for CPDF_Array (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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 "core/fpdfapi/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 return; 1412 return;
1413 } 1413 }
1414 AddTextObject(&str, 0, NULL, 1); 1414 AddTextObject(&str, 0, NULL, 1);
1415 } 1415 }
1416 1416
1417 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 1417 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
1418 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; 1418 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
1419 if (!pArray) { 1419 if (!pArray) {
1420 return; 1420 return;
1421 } 1421 }
1422 int n = pArray->GetCount(); 1422 size_t n = pArray->GetCount();
1423 int nsegs = 0; 1423 size_t nsegs = 0;
1424 for (int i = 0; i < n; i++) { 1424 for (size_t i = 0; i < n; i++) {
1425 if (pArray->GetDirectObjectAt(i)->IsString()) 1425 if (pArray->GetDirectObjectAt(i)->IsString())
1426 nsegs++; 1426 nsegs++;
1427 } 1427 }
1428 if (nsegs == 0) { 1428 if (nsegs == 0) {
1429 for (int i = 0; i < n; i++) { 1429 for (size_t i = 0; i < n; i++) {
1430 m_pCurStates->m_TextX -= 1430 m_pCurStates->m_TextX -=
1431 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) / 1431 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) /
1432 1000; 1432 1000;
1433 } 1433 }
1434 return; 1434 return;
1435 } 1435 }
1436 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; 1436 CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
1437 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); 1437 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
1438 int iSegment = 0; 1438 size_t iSegment = 0;
1439 FX_FLOAT fInitKerning = 0; 1439 FX_FLOAT fInitKerning = 0;
1440 for (int i = 0; i < n; i++) { 1440 for (size_t i = 0; i < n; i++) {
1441 CPDF_Object* pObj = pArray->GetDirectObjectAt(i); 1441 CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
1442 if (pObj->IsString()) { 1442 if (pObj->IsString()) {
1443 CFX_ByteString str = pObj->GetString(); 1443 CFX_ByteString str = pObj->GetString();
1444 if (str.IsEmpty()) { 1444 if (str.IsEmpty()) {
1445 continue; 1445 continue;
1446 } 1446 }
1447 pStrs[iSegment] = str; 1447 pStrs[iSegment] = str;
1448 pKerning[iSegment++] = 0; 1448 pKerning[iSegment++] = 0;
1449 } else { 1449 } else {
1450 FX_FLOAT num = pObj ? pObj->GetNumber() : 0; 1450 FX_FLOAT num = pObj ? pObj->GetNumber() : 0;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 for (const auto& op : replacements) { 1795 for (const auto& op : replacements) {
1796 if (op.is_replace_key) 1796 if (op.is_replace_key)
1797 pDict->ReplaceKey(op.key.AsByteStringC(), op.replacement); 1797 pDict->ReplaceKey(op.key.AsByteStringC(), op.replacement);
1798 else 1798 else
1799 pDict->SetAtName(op.key.AsByteStringC(), op.replacement); 1799 pDict->SetAtName(op.key.AsByteStringC(), op.replacement);
1800 } 1800 }
1801 break; 1801 break;
1802 } 1802 }
1803 case CPDF_Object::ARRAY: { 1803 case CPDF_Object::ARRAY: {
1804 CPDF_Array* pArray = pObj->AsArray(); 1804 CPDF_Array* pArray = pObj->AsArray();
1805 for (uint32_t i = 0; i < pArray->GetCount(); i++) { 1805 for (size_t i = 0; i < pArray->GetCount(); i++) {
1806 CPDF_Object* pElement = pArray->GetObjectAt(i); 1806 CPDF_Object* pElement = pArray->GetObjectAt(i);
1807 if (pElement->IsName()) { 1807 if (pElement->IsName()) {
1808 CFX_ByteString name = pElement->GetString(); 1808 CFX_ByteString name = pElement->GetString();
1809 CFX_ByteStringC fullname = PDF_FindFullName( 1809 CFX_ByteStringC fullname = PDF_FindFullName(
1810 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), 1810 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr),
1811 name.AsByteStringC()); 1811 name.AsByteStringC());
1812 if (!fullname.IsEmpty()) { 1812 if (!fullname.IsEmpty()) {
1813 pArray->SetAt(i, new CPDF_Name(fullname)); 1813 pArray->SetAt(i, new CPDF_Name(fullname));
1814 } 1814 }
1815 } else { 1815 } else {
1816 PDF_ReplaceAbbr(pElement); 1816 PDF_ReplaceAbbr(pElement);
1817 } 1817 }
1818 } 1818 }
1819 break; 1819 break;
1820 } 1820 }
1821 default: 1821 default:
1822 break; 1822 break;
1823 } 1823 }
1824 } 1824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698