| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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_parser/include/cpdf_dictionary.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" | 12 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
| 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
| 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" |
| 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
| 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" | 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" |
| 19 #include "third_party/base/stl_util.h" | 19 #include "third_party/base/stl_util.h" |
| 20 #include "third_party/base/logging.h" |
| 20 | 21 |
| 21 CPDF_Dictionary::CPDF_Dictionary() {} | 22 CPDF_Dictionary::CPDF_Dictionary() {} |
| 22 | 23 |
| 23 CPDF_Dictionary::~CPDF_Dictionary() { | 24 CPDF_Dictionary::~CPDF_Dictionary() { |
| 24 // Mark the object as deleted so that it will not be deleted again | 25 // Mark the object as deleted so that it will not be deleted again |
| 25 // in case of cyclic references. | 26 // in case of cyclic references. |
| 26 m_ObjNum = kInvalidObjNum; | 27 m_ObjNum = kInvalidObjNum; |
| 27 for (const auto& it : m_Map) { | 28 for (const auto& it : m_Map) { |
| 28 if (it.second) | 29 if (it.second) |
| 29 it.second->Release(); | 30 it.second->Release(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 163 } |
| 163 | 164 |
| 164 bool CPDF_Dictionary::IsSignatureDict() const { | 165 bool CPDF_Dictionary::IsSignatureDict() const { |
| 165 CPDF_Object* pType = GetDirectObjectFor("Type"); | 166 CPDF_Object* pType = GetDirectObjectFor("Type"); |
| 166 if (!pType) | 167 if (!pType) |
| 167 pType = GetDirectObjectFor("FT"); | 168 pType = GetDirectObjectFor("FT"); |
| 168 return pType && pType->GetString() == "Sig"; | 169 return pType && pType->GetString() == "Sig"; |
| 169 } | 170 } |
| 170 | 171 |
| 171 void CPDF_Dictionary::SetFor(const CFX_ByteString& key, CPDF_Object* pObj) { | 172 void CPDF_Dictionary::SetFor(const CFX_ByteString& key, CPDF_Object* pObj) { |
| 172 ASSERT(!pObj || pObj->GetObjNum() == 0); | 173 CHECK(!pObj || pObj->GetObjNum() == 0); |
| 173 auto it = m_Map.find(key); | 174 auto it = m_Map.find(key); |
| 174 if (it == m_Map.end()) { | 175 if (it == m_Map.end()) { |
| 175 if (pObj) | 176 if (pObj) |
| 176 m_Map.insert(std::make_pair(key, pObj)); | 177 m_Map.insert(std::make_pair(key, pObj)); |
| 177 return; | 178 return; |
| 178 } | 179 } |
| 179 | 180 |
| 180 if (it->second == pObj) | 181 if (it->second == pObj) |
| 181 return; | 182 return; |
| 182 it->second->Release(); | 183 it->second->Release(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 const CFX_Matrix& matrix) { | 258 const CFX_Matrix& matrix) { |
| 258 CPDF_Array* pArray = new CPDF_Array; | 259 CPDF_Array* pArray = new CPDF_Array; |
| 259 pArray->AddNumber(matrix.a); | 260 pArray->AddNumber(matrix.a); |
| 260 pArray->AddNumber(matrix.b); | 261 pArray->AddNumber(matrix.b); |
| 261 pArray->AddNumber(matrix.c); | 262 pArray->AddNumber(matrix.c); |
| 262 pArray->AddNumber(matrix.d); | 263 pArray->AddNumber(matrix.d); |
| 263 pArray->AddNumber(matrix.e); | 264 pArray->AddNumber(matrix.e); |
| 264 pArray->AddNumber(matrix.f); | 265 pArray->AddNumber(matrix.f); |
| 265 SetFor(key, pArray); | 266 SetFor(key, pArray); |
| 266 } | 267 } |
| OLD | NEW |