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

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

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (type != CPDF_StreamParser::Name) { 559 if (type != CPDF_StreamParser::Name) {
560 break; 560 break;
561 } 561 }
562 CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, 562 CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1,
563 m_pSyntax->GetWordSize() - 1); 563 m_pSyntax->GetWordSize() - 1);
564 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( 564 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
565 m_pSyntax->ReadNextObject()); 565 m_pSyntax->ReadNextObject());
566 if (!key.IsEmpty()) { 566 if (!key.IsEmpty()) {
567 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; 567 uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
568 if (dwObjNum) 568 if (dwObjNum)
569 pDict->SetAtReference(key.AsByteStringC(), m_pDocument, dwObjNum); 569 pDict->SetAtReference(key.AsStringC(), m_pDocument, dwObjNum);
570 else 570 else
571 pDict->SetAt(key.AsByteStringC(), pObj.release()); 571 pDict->SetAt(key.AsStringC(), pObj.release());
572 } 572 }
573 } 573 }
574 PDF_ReplaceAbbr(pDict); 574 PDF_ReplaceAbbr(pDict);
575 CPDF_Object* pCSObj = NULL; 575 CPDF_Object* pCSObj = NULL;
576 if (pDict->KeyExist("ColorSpace")) { 576 if (pDict->KeyExist("ColorSpace")) {
577 pCSObj = pDict->GetDirectObjectBy("ColorSpace"); 577 pCSObj = pDict->GetDirectObjectBy("ColorSpace");
578 if (pCSObj->IsName()) { 578 if (pCSObj->IsName()) {
579 CFX_ByteString name = pCSObj->GetString(); 579 CFX_ByteString name = pCSObj->GetString();
580 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") { 580 if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") {
581 pCSObj = FindResourceObj("ColorSpace", name); 581 pCSObj = FindResourceObj("ColorSpace", name);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 714
715 if (m_Options.m_bTextOnly) { 715 if (m_Options.m_bTextOnly) {
716 if (!m_pResources) 716 if (!m_pResources)
717 return; 717 return;
718 718
719 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject"); 719 CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject");
720 if (!pList && m_pPageResources && m_pResources != m_pPageResources) 720 if (!pList && m_pPageResources && m_pResources != m_pPageResources)
721 pList = m_pPageResources->GetDictBy("XObject"); 721 pList = m_pPageResources->GetDictBy("XObject");
722 if (!pList) 722 if (!pList)
723 return; 723 return;
724 CPDF_Reference* pRes = 724 CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name.AsStringC()));
725 ToReference(pList->GetObjectBy(name.AsByteStringC()));
726 if (!pRes) 725 if (!pRes)
727 return; 726 return;
728 727
729 FX_BOOL bForm; 728 FX_BOOL bForm;
730 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm) 729 if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm)
731 return; 730 return;
732 } 731 }
733 732
734 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name)); 733 CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name));
735 if (!pXObject) { 734 if (!pXObject) {
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 const CFX_ByteStringC& type, 1250 const CFX_ByteStringC& type,
1252 const CFX_ByteString& name) { 1251 const CFX_ByteString& name) {
1253 if (!m_pResources) { 1252 if (!m_pResources) {
1254 return NULL; 1253 return NULL;
1255 } 1254 }
1256 if (m_pResources == m_pPageResources) { 1255 if (m_pResources == m_pPageResources) {
1257 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); 1256 CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
1258 if (!pList) { 1257 if (!pList) {
1259 return NULL; 1258 return NULL;
1260 } 1259 }
1261 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC()); 1260 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC());
1262 return pRes; 1261 return pRes;
1263 } 1262 }
1264 CPDF_Dictionary* pList = m_pResources->GetDictBy(type); 1263 CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
1265 if (!pList) { 1264 if (!pList) {
1266 if (!m_pPageResources) { 1265 if (!m_pPageResources) {
1267 return NULL; 1266 return NULL;
1268 } 1267 }
1269 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); 1268 CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type);
1270 if (!pList) { 1269 if (!pList) {
1271 return NULL; 1270 return NULL;
1272 } 1271 }
1273 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC()); 1272 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC());
1274 return pRes; 1273 return pRes;
1275 } 1274 }
1276 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC()); 1275 CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC());
1277 return pRes; 1276 return pRes;
1278 } 1277 }
1279 1278
1280 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { 1279 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
1281 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name)); 1280 CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
1282 if (!pFontDict) { 1281 if (!pFontDict) {
1283 m_bResourceMissing = TRUE; 1282 m_bResourceMissing = TRUE;
1284 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica"); 1283 return CPDF_Font::GetStockFont(m_pDocument, "Helvetica");
1285 } 1284 }
1286 1285
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 void PDF_ReplaceAbbr(CPDF_Object* pObj) { 1758 void PDF_ReplaceAbbr(CPDF_Object* pObj) {
1760 switch (pObj->GetType()) { 1759 switch (pObj->GetType()) {
1761 case CPDF_Object::DICTIONARY: { 1760 case CPDF_Object::DICTIONARY: {
1762 CPDF_Dictionary* pDict = pObj->AsDictionary(); 1761 CPDF_Dictionary* pDict = pObj->AsDictionary();
1763 std::vector<AbbrReplacementOp> replacements; 1762 std::vector<AbbrReplacementOp> replacements;
1764 for (const auto& it : *pDict) { 1763 for (const auto& it : *pDict) {
1765 CFX_ByteString key = it.first; 1764 CFX_ByteString key = it.first;
1766 CPDF_Object* value = it.second; 1765 CPDF_Object* value = it.second;
1767 CFX_ByteStringC fullname = 1766 CFX_ByteStringC fullname =
1768 PDF_FindFullName(PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), 1767 PDF_FindFullName(PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr),
1769 key.AsByteStringC()); 1768 key.AsStringC());
1770 if (!fullname.IsEmpty()) { 1769 if (!fullname.IsEmpty()) {
1771 AbbrReplacementOp op; 1770 AbbrReplacementOp op;
1772 op.is_replace_key = true; 1771 op.is_replace_key = true;
1773 op.key = key; 1772 op.key = key;
1774 op.replacement = fullname; 1773 op.replacement = fullname;
1775 replacements.push_back(op); 1774 replacements.push_back(op);
1776 key = fullname; 1775 key = fullname;
1777 } 1776 }
1778 1777
1779 if (value->IsName()) { 1778 if (value->IsName()) {
1780 CFX_ByteString name = value->GetString(); 1779 CFX_ByteString name = value->GetString();
1781 fullname = PDF_FindFullName(PDF_InlineValueAbbr, 1780 fullname = PDF_FindFullName(PDF_InlineValueAbbr,
1782 FX_ArraySize(PDF_InlineValueAbbr), 1781 FX_ArraySize(PDF_InlineValueAbbr),
1783 name.AsByteStringC()); 1782 name.AsStringC());
1784 if (!fullname.IsEmpty()) { 1783 if (!fullname.IsEmpty()) {
1785 AbbrReplacementOp op; 1784 AbbrReplacementOp op;
1786 op.is_replace_key = false; 1785 op.is_replace_key = false;
1787 op.key = key; 1786 op.key = key;
1788 op.replacement = fullname; 1787 op.replacement = fullname;
1789 replacements.push_back(op); 1788 replacements.push_back(op);
1790 } 1789 }
1791 } else { 1790 } else {
1792 PDF_ReplaceAbbr(value); 1791 PDF_ReplaceAbbr(value);
1793 } 1792 }
1794 } 1793 }
1795 for (const auto& op : replacements) { 1794 for (const auto& op : replacements) {
1796 if (op.is_replace_key) 1795 if (op.is_replace_key)
1797 pDict->ReplaceKey(op.key.AsByteStringC(), op.replacement); 1796 pDict->ReplaceKey(op.key.AsStringC(), op.replacement);
1798 else 1797 else
1799 pDict->SetAtName(op.key.AsByteStringC(), op.replacement); 1798 pDict->SetAtName(op.key.AsStringC(), op.replacement);
1800 } 1799 }
1801 break; 1800 break;
1802 } 1801 }
1803 case CPDF_Object::ARRAY: { 1802 case CPDF_Object::ARRAY: {
1804 CPDF_Array* pArray = pObj->AsArray(); 1803 CPDF_Array* pArray = pObj->AsArray();
1805 for (uint32_t i = 0; i < pArray->GetCount(); i++) { 1804 for (uint32_t i = 0; i < pArray->GetCount(); i++) {
1806 CPDF_Object* pElement = pArray->GetObjectAt(i); 1805 CPDF_Object* pElement = pArray->GetObjectAt(i);
1807 if (pElement->IsName()) { 1806 if (pElement->IsName()) {
1808 CFX_ByteString name = pElement->GetString(); 1807 CFX_ByteString name = pElement->GetString();
1809 CFX_ByteStringC fullname = PDF_FindFullName( 1808 CFX_ByteStringC fullname = PDF_FindFullName(
1810 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), 1809 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr),
1811 name.AsByteStringC()); 1810 name.AsStringC());
1812 if (!fullname.IsEmpty()) { 1811 if (!fullname.IsEmpty()) {
1813 pArray->SetAt(i, new CPDF_Name(fullname)); 1812 pArray->SetAt(i, new CPDF_Name(fullname));
1814 } 1813 }
1815 } else { 1814 } else {
1816 PDF_ReplaceAbbr(pElement); 1815 PDF_ReplaceAbbr(pElement);
1817 } 1816 }
1818 } 1817 }
1819 break; 1818 break;
1820 } 1819 }
1821 default: 1820 default:
1822 break; 1821 break;
1823 } 1822 }
1824 } 1823 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_doc.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