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

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

Issue 1841173002: Rename GetElementValue() to GetDirectObject{By,At}(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix test name 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; 577 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
578 if (dwObjNum) 578 if (dwObjNum)
579 pDict->SetAtReference(key, m_pDocument, dwObjNum); 579 pDict->SetAtReference(key, m_pDocument, dwObjNum);
580 else 580 else
581 pDict->SetAt(key, pObj.release()); 581 pDict->SetAt(key, pObj.release());
582 } 582 }
583 } 583 }
584 PDF_ReplaceAbbr(pDict); 584 PDF_ReplaceAbbr(pDict);
585 CPDF_Object* pCSObj = NULL; 585 CPDF_Object* pCSObj = NULL;
586 if (pDict->KeyExist("ColorSpace")) { 586 if (pDict->KeyExist("ColorSpace")) {
587 pCSObj = pDict->GetElementValue("ColorSpace"); 587 pCSObj = pDict->GetDirectObjectBy("ColorSpace");
588 if (pCSObj->IsName()) { 588 if (pCSObj->IsName()) {
589 CFX_ByteString name = pCSObj->GetString(); 589 CFX_ByteString name = pCSObj->GetString();
590 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") { 590 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") {
591 pCSObj = FindResourceObj("ColorSpace", name); 591 pCSObj = FindResourceObj("ColorSpace", name);
592 if (pCSObj && !pCSObj->GetObjNum()) { 592 if (pCSObj && !pCSObj->GetObjNum()) {
593 pCSObj = pCSObj->Clone(); 593 pCSObj = pCSObj->Clone();
594 pDict->SetAt("ColorSpace", pCSObj); 594 pDict->SetAt("ColorSpace", pCSObj);
595 } 595 }
596 } 596 }
597 } 597 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 724
725 if (m_Options.m_bTextOnly) { 725 if (m_Options.m_bTextOnly) {
726 if (!m_pResources) 726 if (!m_pResources)
727 return; 727 return;
728 728
729 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject"); 729 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject");
730 if (!pList && m_pPageResources && m_pResources != m_pPageResources) 730 if (!pList && m_pPageResources && m_pResources != m_pPageResources)
731 pList = m_pPageResources->GetDictBy("XObject"); 731 pList = m_pPageResources->GetDictBy("XObject");
732 if (!pList) 732 if (!pList)
733 return; 733 return;
734 CPDF_Reference* pRes = ToReference(pList->GetElement(name)); 734 CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name));
735 if (!pRes) 735 if (!pRes)
736 return; 736 return;
737 737
738 FX_BOOL bForm; 738 FX_BOOL bForm;
739 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm) 739 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm)
740 return; 740 return;
741 } 741 }
742 742
743 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name)); 743 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name));
744 if (!pXObject) { 744 if (!pXObject) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 const CFX_ByteStringC& type, 1261 const CFX_ByteStringC& type,
1262 const CFX_ByteString& name) { 1262 const CFX_ByteString& name) {
1263 if (!m_pResources) { 1263 if (!m_pResources) {
1264 return NULL; 1264 return NULL;
1265 } 1265 }
1266 if (m_pResources == m_pPageResources) { 1266 if (m_pResources == m_pPageResources) {
1267 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); 1267 CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
1268 if (!pList) { 1268 if (!pList) {
1269 return NULL; 1269 return NULL;
1270 } 1270 }
1271 CPDF_Object* pRes = pList->GetElementValue(name); 1271 CPDF_Object* pRes = pList->GetDirectObjectBy(name);
1272 return pRes; 1272 return pRes;
1273 } 1273 }
1274 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); 1274 CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
1275 if (!pList) { 1275 if (!pList) {
1276 if (!m_pPageResources) { 1276 if (!m_pPageResources) {
1277 return NULL; 1277 return NULL;
1278 } 1278 }
1279 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); 1279 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type);
1280 if (!pList) { 1280 if (!pList) {
1281 return NULL; 1281 return NULL;
1282 } 1282 }
1283 CPDF_Object* pRes = pList->GetElementValue(name); 1283 CPDF_Object* pRes = pList->GetDirectObjectBy(name);
1284 return pRes; 1284 return pRes;
1285 } 1285 }
1286 CPDF_Object* pRes = pList->GetElementValue(name); 1286 CPDF_Object* pRes = pList->GetDirectObjectBy(name);
1287 return pRes; 1287 return pRes;
1288 } 1288 }
1289 1289
1290 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { 1290 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
1291 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); 1291 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
1292 if (!pFontDict) { 1292 if (!pFontDict) {
1293 m_bResourceMissing = TRUE; 1293 m_bResourceMissing = TRUE;
1294 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); 1294 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica");
1295 } 1295 }
1296 1296
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } 1425 }
1426 1426
1427 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 1427 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
1428 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; 1428 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
1429 if (!pArray) { 1429 if (!pArray) {
1430 return; 1430 return;
1431 } 1431 }
1432 int n = pArray->GetCount(); 1432 int n = pArray->GetCount();
1433 int nsegs = 0; 1433 int nsegs = 0;
1434 for (int i = 0; i < n; i++) { 1434 for (int i = 0; i < n; i++) {
1435 if (pArray->GetElementValue(i)->IsString()) 1435 if (pArray->GetDirectObjectAt(i)->IsString())
1436 nsegs++; 1436 nsegs++;
1437 } 1437 }
1438 if (nsegs == 0) { 1438 if (nsegs == 0) {
1439 for (int i = 0; i < n; i++) { 1439 for (int i = 0; i < n; i++) {
1440 m_pCurStates->m_TextX -= 1440 m_pCurStates->m_TextX -=
1441 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) / 1441 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) /
1442 1000; 1442 1000;
1443 } 1443 }
1444 return; 1444 return;
1445 } 1445 }
1446 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; 1446 CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
1447 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); 1447 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
1448 int iSegment = 0; 1448 int iSegment = 0;
1449 FX_FLOAT fInitKerning = 0; 1449 FX_FLOAT fInitKerning = 0;
1450 for (int i = 0; i < n; i++) { 1450 for (int i = 0; i < n; i++) {
1451 CPDF_Object* pObj = pArray->GetElementValue(i); 1451 CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
1452 if (pObj->IsString()) { 1452 if (pObj->IsString()) {
1453 CFX_ByteString str = pObj->GetString(); 1453 CFX_ByteString str = pObj->GetString();
1454 if (str.IsEmpty()) { 1454 if (str.IsEmpty()) {
1455 continue; 1455 continue;
1456 } 1456 }
1457 pStrs[iSegment] = str; 1457 pStrs[iSegment] = str;
1458 pKerning[iSegment++] = 0; 1458 pKerning[iSegment++] = 0;
1459 } else { 1459 } else {
1460 FX_FLOAT num = pObj ? pObj->GetNumber() : 0; 1460 FX_FLOAT num = pObj ? pObj->GetNumber() : 0;
1461 if (iSegment == 0) { 1461 if (iSegment == 0) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 if (op.is_replace_key) 1804 if (op.is_replace_key)
1805 pDict->ReplaceKey(op.key, op.replacement); 1805 pDict->ReplaceKey(op.key, op.replacement);
1806 else 1806 else
1807 pDict->SetAtName(op.key, op.replacement); 1807 pDict->SetAtName(op.key, op.replacement);
1808 } 1808 }
1809 break; 1809 break;
1810 } 1810 }
1811 case CPDF_Object::ARRAY: { 1811 case CPDF_Object::ARRAY: {
1812 CPDF_Array* pArray = pObj->AsArray(); 1812 CPDF_Array* pArray = pObj->AsArray();
1813 for (uint32_t i = 0; i < pArray->GetCount(); i++) { 1813 for (uint32_t i = 0; i < pArray->GetCount(); i++) {
1814 CPDF_Object* pElement = pArray->GetElement(i); 1814 CPDF_Object* pElement = pArray->GetObjectAt(i);
1815 if (pElement->IsName()) { 1815 if (pElement->IsName()) {
1816 CFX_ByteString name = pElement->GetString(); 1816 CFX_ByteString name = pElement->GetString();
1817 CFX_ByteStringC fullname = PDF_FindFullName( 1817 CFX_ByteStringC fullname = PDF_FindFullName(
1818 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name); 1818 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
1819 if (!fullname.IsEmpty()) { 1819 if (!fullname.IsEmpty()) {
1820 pArray->SetAt(i, new CPDF_Name(fullname)); 1820 pArray->SetAt(i, new CPDF_Name(fullname));
1821 } 1821 }
1822 } else { 1822 } else {
1823 PDF_ReplaceAbbr(pElement); 1823 PDF_ReplaceAbbr(pElement);
1824 } 1824 }
1825 } 1825 }
1826 break; 1826 break;
1827 } 1827 }
1828 default: 1828 default:
1829 break; 1829 break;
1830 } 1830 }
1831 } 1831 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_func.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698