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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1630973002: Remove struct PARSE_OPTIONS. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebase, prior merge suspect. Created 4 years, 10 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/include/fpdfapi/fpdf_objects.h" 7 #include "core/include/fpdfapi/fpdf_objects.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 const CPDF_Object* CPDF_Object::GetBasicObject() const { 49 const CPDF_Object* CPDF_Object::GetBasicObject() const {
50 const CPDF_Reference* pRef = AsReference(); 50 const CPDF_Reference* pRef = AsReference();
51 if (!pRef) { 51 if (!pRef) {
52 // This is not an indirect reference. 52 // This is not an indirect reference.
53 return this; 53 return this;
54 } 54 }
55 if (!pRef->m_pObjList) 55 if (!pRef->m_pObjList)
56 return nullptr; 56 return nullptr;
57 return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum(), nullptr); 57 return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum());
58 } 58 }
59 59
60 CFX_ByteString CPDF_Object::GetString() const { 60 CFX_ByteString CPDF_Object::GetString() const {
61 const CPDF_Object* obj = GetBasicObject(); 61 const CPDF_Object* obj = GetBasicObject();
62 if (obj) { 62 if (obj) {
63 switch (obj->GetType()) { 63 switch (obj->GetType()) {
64 case PDFOBJ_BOOLEAN: 64 case PDFOBJ_BOOLEAN:
65 return obj->AsBoolean()->GetString(); 65 return obj->AsBoolean()->GetString();
66 case PDFOBJ_NUMBER: 66 case PDFOBJ_NUMBER:
67 return obj->AsNumber()->GetString(); 67 return obj->AsNumber()->GetString();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 return FALSE; 186 return FALSE;
187 } 187 }
188 188
189 CPDF_Object* CPDF_Object::GetDirect() const { 189 CPDF_Object* CPDF_Object::GetDirect() const {
190 const CPDF_Reference* pRef = AsReference(); 190 const CPDF_Reference* pRef = AsReference();
191 if (!pRef) 191 if (!pRef)
192 return const_cast<CPDF_Object*>(this); 192 return const_cast<CPDF_Object*>(this);
193 if (!pRef->m_pObjList) 193 if (!pRef->m_pObjList)
194 return nullptr; 194 return nullptr;
195 return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum(), nullptr); 195 return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum());
196 } 196 }
197 197
198 CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const { 198 CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const {
199 std::set<FX_DWORD> visited; 199 std::set<FX_DWORD> visited;
200 return CloneInternal(bDirect, &visited); 200 return CloneInternal(bDirect, &visited);
201 } 201 }
202 CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, 202 CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
203 std::set<FX_DWORD>* visited) const { 203 std::set<FX_DWORD>* visited) const {
204 switch (m_Type) { 204 switch (m_Type) {
205 case PDFOBJ_BOOLEAN: 205 case PDFOBJ_BOOLEAN:
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder(CPDF_Parser* pParser) 1021 CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder(CPDF_Parser* pParser)
1022 : m_pParser(pParser), m_LastObjNum(0) { 1022 : m_pParser(pParser), m_LastObjNum(0) {
1023 if (pParser) 1023 if (pParser)
1024 m_LastObjNum = m_pParser->GetLastObjNum(); 1024 m_LastObjNum = m_pParser->GetLastObjNum();
1025 } 1025 }
1026 CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() { 1026 CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {
1027 for (const auto& pair : m_IndirectObjs) { 1027 for (const auto& pair : m_IndirectObjs) {
1028 pair.second->Destroy(); 1028 pair.second->Destroy();
1029 } 1029 }
1030 } 1030 }
1031 CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject( 1031 CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject(FX_DWORD objnum) {
1032 FX_DWORD objnum,
1033 PARSE_CONTEXT* pContext) {
1034 if (objnum == 0) 1032 if (objnum == 0)
1035 return nullptr; 1033 return nullptr;
1036 1034
1037 auto it = m_IndirectObjs.find(objnum); 1035 auto it = m_IndirectObjs.find(objnum);
1038 if (it != m_IndirectObjs.end()) 1036 if (it != m_IndirectObjs.end())
1039 return it->second->GetObjNum() != -1 ? it->second : nullptr; 1037 return it->second->GetObjNum() != -1 ? it->second : nullptr;
1040 1038
1041 if (!m_pParser) 1039 if (!m_pParser)
1042 return nullptr; 1040 return nullptr;
1043 1041
1044 CPDF_Object* pObj = m_pParser->ParseIndirectObject(this, objnum, pContext); 1042 CPDF_Object* pObj = m_pParser->ParseIndirectObject(this, objnum);
1045 if (!pObj) 1043 if (!pObj)
1046 return nullptr; 1044 return nullptr;
1047 1045
1048 pObj->m_ObjNum = objnum; 1046 pObj->m_ObjNum = objnum;
1049 m_LastObjNum = std::max(m_LastObjNum, objnum); 1047 m_LastObjNum = std::max(m_LastObjNum, objnum);
1050 if (m_IndirectObjs[objnum]) 1048 if (m_IndirectObjs[objnum])
1051 m_IndirectObjs[objnum]->Destroy(); 1049 m_IndirectObjs[objnum]->Destroy();
1052 1050
1053 m_IndirectObjs[objnum] = pObj; 1051 m_IndirectObjs[objnum] = pObj;
1054 return pObj; 1052 return pObj;
(...skipping 24 matching lines...) Expand all
1079 pObj->Destroy(); 1077 pObj->Destroy();
1080 return FALSE; 1078 return FALSE;
1081 } 1079 }
1082 it->second->Destroy(); 1080 it->second->Destroy();
1083 } 1081 }
1084 pObj->m_ObjNum = objnum; 1082 pObj->m_ObjNum = objnum;
1085 m_IndirectObjs[objnum] = pObj; 1083 m_IndirectObjs[objnum] = pObj;
1086 m_LastObjNum = std::max(m_LastObjNum, objnum); 1084 m_LastObjNum = std::max(m_LastObjNum, objnum);
1087 return TRUE; 1085 return TRUE;
1088 } 1086 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698