Chromium Code Reviews| 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 "../../../include/fpdfapi/fpdf_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 8 #include "../../../include/fxcrt/fx_string.h" | 8 #include "../../../include/fxcrt/fx_string.h" |
| 9 | 9 |
| 10 // static | 10 // static |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 731 CPDF_Array* pArray = GetArray(key); | 731 CPDF_Array* pArray = GetArray(key); |
| 732 if (pArray) { | 732 if (pArray) { |
| 733 matrix = pArray->GetMatrix(); | 733 matrix = pArray->GetMatrix(); |
| 734 } | 734 } |
| 735 return matrix; | 735 return matrix; |
| 736 } | 736 } |
| 737 FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const { | 737 FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const { |
| 738 void* value; | 738 void* value; |
| 739 return m_Map.Lookup(key, value); | 739 return m_Map.Lookup(key, value); |
| 740 } | 740 } |
| 741 void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, | 741 |
| 742 CPDF_Object* pObj, | 742 void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) { |
| 743 CPDF_IndirectObjects* pObjs) { | 743 SetAtWithIndirect(key, pObj, nullptr); |
| 744 ASSERT(m_Type == PDFOBJ_DICTIONARY); | 744 } |
| 745 CPDF_Object* p = NULL; | 745 |
| 746 m_Map.Lookup(key, (void*&)p); | 746 void CPDF_Dictionary::SetAtWithIndirect(const CFX_ByteStringC& key, |
| 747 if (p == pObj) { | 747 CPDF_Object* pObj, |
| 748 CPDF_IndirectObjects* pObjs) { | |
| 749 ASSERT(IsDictionary()); | |
| 750 CPDF_Object* pExisting = nullptr; | |
| 751 m_Map.Lookup(key, (void*&)pExisting); | |
|
Tom Sepez
2015/10/24 16:50:01
nit: you know this cast is my favorite pet peeve .
Lei Zhang
2015/10/26 21:58:22
Done.
| |
| 752 if (pExisting == pObj) | |
| 753 return; | |
| 754 | |
| 755 if (pExisting) | |
| 756 pExisting->Release(); | |
| 757 | |
| 758 if (!pObj) { | |
| 759 m_Map.RemoveKey(key); | |
| 748 return; | 760 return; |
| 749 } | 761 } |
| 750 if (p) | 762 |
| 751 p->Release(); | 763 FX_DWORD dwObjNum = pObj->GetObjNum(); |
| 752 if (pObj) { | 764 if (dwObjNum) { |
| 753 if (pObj->GetObjNum()) { | 765 ASSERT(pObjs); |
| 754 ASSERT(pObjs != NULL); | 766 m_Map.SetAt(key, new CPDF_Reference(pObjs, dwObjNum)); |
| 755 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 767 pObj->Release(); |
| 756 } | 768 } else { |
| 757 m_Map.SetAt(key, pObj); | 769 m_Map.SetAt(key, pObj); |
| 758 } else { | |
| 759 m_Map.RemoveKey(key); | |
| 760 } | 770 } |
| 761 } | 771 } |
| 772 | |
| 762 void CPDF_Dictionary::AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj) { | 773 void CPDF_Dictionary::AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj) { |
| 763 ASSERT(m_Type == PDFOBJ_DICTIONARY); | 774 ASSERT(m_Type == PDFOBJ_DICTIONARY); |
| 764 m_Map.AddValue(key, pObj); | 775 m_Map.AddValue(key, pObj); |
| 765 } | 776 } |
| 766 void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) { | 777 void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) { |
| 767 ASSERT(m_Type == PDFOBJ_DICTIONARY); | 778 ASSERT(m_Type == PDFOBJ_DICTIONARY); |
| 768 CPDF_Object* p = NULL; | 779 CPDF_Object* p = NULL; |
| 769 m_Map.Lookup(key, (void*&)p); | 780 m_Map.Lookup(key, (void*&)p); |
| 770 if (p == NULL) { | 781 if (p == NULL) { |
| 771 return; | 782 return; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 } | 1241 } |
| 1231 pObj->m_ObjNum = objnum; | 1242 pObj->m_ObjNum = objnum; |
| 1232 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); | 1243 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
| 1233 if (m_LastObjNum < objnum) { | 1244 if (m_LastObjNum < objnum) { |
| 1234 m_LastObjNum = objnum; | 1245 m_LastObjNum = objnum; |
| 1235 } | 1246 } |
| 1236 } | 1247 } |
| 1237 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { | 1248 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { |
| 1238 return m_LastObjNum; | 1249 return m_LastObjNum; |
| 1239 } | 1250 } |
| OLD | NEW |