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

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

Issue 1617043004: Fixed object references in CPDF_Object (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: style Created 4 years, 11 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
« no previous file with comments | « BUILD.gn ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 CFX_ByteString name = obj->AsName()->GetString(); 86 CFX_ByteString name = obj->AsName()->GetString();
87 return CFX_ByteStringC(name); 87 return CFX_ByteStringC(name);
88 } 88 }
89 } 89 }
90 return CFX_ByteStringC(); 90 return CFX_ByteStringC();
91 } 91 }
92 92
93 FX_FLOAT CPDF_Object::GetNumber() const { 93 FX_FLOAT CPDF_Object::GetNumber() const {
94 const CPDF_Object* obj = GetBasicObject(); 94 const CPDF_Object* obj = GetBasicObject();
95 if (obj && obj->GetType() == PDFOBJ_NUMBER) 95 if (obj && obj->GetType() == PDFOBJ_NUMBER)
96 return AsNumber()->GetNumber(); 96 return obj->AsNumber()->GetNumber();
97 return 0; 97 return 0;
98 } 98 }
99 99
100 FX_FLOAT CPDF_Object::GetNumber16() const { 100 FX_FLOAT CPDF_Object::GetNumber16() const {
101 return GetNumber(); 101 return GetNumber();
102 } 102 }
103 103
104 int CPDF_Object::GetInteger() const { 104 int CPDF_Object::GetInteger() const {
105 const CPDF_Object* obj = GetBasicObject(); 105 const CPDF_Object* obj = GetBasicObject();
106 if (obj) { 106 if (obj) {
107 FX_DWORD type = obj->GetType(); 107 FX_DWORD type = obj->GetType();
108 if (type == PDFOBJ_BOOLEAN) 108 if (type == PDFOBJ_BOOLEAN)
109 return obj->AsBoolean()->GetValue(); 109 return obj->AsBoolean()->GetValue();
110 if (type == PDFOBJ_NUMBER) 110 if (type == PDFOBJ_NUMBER)
111 return obj->AsNumber()->GetInteger(); 111 return obj->AsNumber()->GetInteger();
112 } 112 }
113 return 0; 113 return 0;
114 } 114 }
115 115
116 CPDF_Dictionary* CPDF_Object::GetDict() const { 116 CPDF_Dictionary* CPDF_Object::GetDict() const {
117 const CPDF_Object* obj = GetBasicObject(); 117 const CPDF_Object* obj = GetBasicObject();
118 if (obj) { 118 if (obj) {
119 FX_DWORD type = obj->GetType(); 119 FX_DWORD type = obj->GetType();
120 if (type == PDFOBJ_DICTIONARY) { 120 if (type == PDFOBJ_DICTIONARY) {
121 // The method should be made non-const if we want to not be const. 121 // The method should be made non-const if we want to not be const.
122 // See bug #234. 122 // See bug #234.
123 return const_cast<CPDF_Dictionary*>(AsDictionary()); 123 return const_cast<CPDF_Dictionary*>(obj->AsDictionary());
124 } 124 }
125 if (type == PDFOBJ_STREAM) 125 if (type == PDFOBJ_STREAM)
126 return AsStream()->GetDict(); 126 return obj->AsStream()->GetDict();
127 } 127 }
128 return nullptr; 128 return nullptr;
129 } 129 }
130 130
131 CPDF_Array* CPDF_Object::GetArray() const { 131 CPDF_Array* CPDF_Object::GetArray() const {
132 // The method should be made non-const if we want to not be const. 132 // The method should be made non-const if we want to not be const.
133 // See bug #234. 133 // See bug #234.
134 return const_cast<CPDF_Array*>(AsArray()); 134 return const_cast<CPDF_Array*>(AsArray());
135 } 135 }
136 136
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 pObj->Destroy(); 1098 pObj->Destroy();
1099 return FALSE; 1099 return FALSE;
1100 } 1100 }
1101 it->second->Destroy(); 1101 it->second->Destroy();
1102 } 1102 }
1103 pObj->m_ObjNum = objnum; 1103 pObj->m_ObjNum = objnum;
1104 m_IndirectObjs[objnum] = pObj; 1104 m_IndirectObjs[objnum] = pObj;
1105 m_LastObjNum = std::max(m_LastObjNum, objnum); 1105 m_LastObjNum = std::max(m_LastObjNum, objnum);
1106 return TRUE; 1106 return TRUE;
1107 } 1107 }
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698