| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |