| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 const CPDF_String* pString = AsString(); | 237 const CPDF_String* pString = AsString(); |
| 238 return new CPDF_String(pString->m_String, pString->IsHex()); | 238 return new CPDF_String(pString->m_String, pString->IsHex()); |
| 239 } | 239 } |
| 240 case PDFOBJ_NAME: | 240 case PDFOBJ_NAME: |
| 241 return new CPDF_Name(AsName()->m_Name); | 241 return new CPDF_Name(AsName()->m_Name); |
| 242 case PDFOBJ_ARRAY: { | 242 case PDFOBJ_ARRAY: { |
| 243 CPDF_Array* pCopy = new CPDF_Array(); | 243 CPDF_Array* pCopy = new CPDF_Array(); |
| 244 const CPDF_Array* pThis = AsArray(); | 244 const CPDF_Array* pThis = AsArray(); |
| 245 int n = pThis->GetCount(); | 245 int n = pThis->GetCount(); |
| 246 for (int i = 0; i < n; i++) { | 246 for (int i = 0; i < n; i++) { |
| 247 CPDF_Object* value = (CPDF_Object*)pThis->m_Objects.GetAt(i); | 247 CPDF_Object* value = |
| 248 static_cast<CPDF_Object*>(pThis->m_Objects.GetAt(i)); |
| 248 pCopy->m_Objects.Add(value->CloneInternal(bDirect, visited)); | 249 pCopy->m_Objects.Add(value->CloneInternal(bDirect, visited)); |
| 249 } | 250 } |
| 250 return pCopy; | 251 return pCopy; |
| 251 } | 252 } |
| 252 case PDFOBJ_DICTIONARY: { | 253 case PDFOBJ_DICTIONARY: { |
| 253 CPDF_Dictionary* pCopy = new CPDF_Dictionary(); | 254 CPDF_Dictionary* pCopy = new CPDF_Dictionary(); |
| 254 const CPDF_Dictionary* pThis = AsDictionary(); | 255 const CPDF_Dictionary* pThis = AsDictionary(); |
| 255 FX_POSITION pos = pThis->m_Map.GetStartPosition(); | 256 FX_POSITION pos = pThis->m_Map.GetStartPosition(); |
| 256 while (pos) { | 257 while (pos) { |
| 257 CFX_ByteString key; | 258 CFX_ByteString key; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 CFX_AffineMatrix CPDF_Array::GetMatrix() { | 437 CFX_AffineMatrix CPDF_Array::GetMatrix() { |
| 437 CFX_AffineMatrix matrix; | 438 CFX_AffineMatrix matrix; |
| 438 if (!IsArray() || m_Objects.GetSize() != 6) | 439 if (!IsArray() || m_Objects.GetSize() != 6) |
| 439 return matrix; | 440 return matrix; |
| 440 | 441 |
| 441 matrix.Set(GetNumber(0), GetNumber(1), GetNumber(2), GetNumber(3), | 442 matrix.Set(GetNumber(0), GetNumber(1), GetNumber(2), GetNumber(3), |
| 442 GetNumber(4), GetNumber(5)); | 443 GetNumber(4), GetNumber(5)); |
| 443 return matrix; | 444 return matrix; |
| 444 } | 445 } |
| 445 CPDF_Object* CPDF_Array::GetElement(FX_DWORD i) const { | 446 CPDF_Object* CPDF_Array::GetElement(FX_DWORD i) const { |
| 446 if (i >= (FX_DWORD)m_Objects.GetSize()) { | 447 if (i >= (FX_DWORD)m_Objects.GetSize()) |
| 447 return NULL; | 448 return nullptr; |
| 448 } | 449 return static_cast<CPDF_Object*>(m_Objects.GetAt(i)); |
| 449 return (CPDF_Object*)m_Objects.GetAt(i); | |
| 450 } | 450 } |
| 451 CPDF_Object* CPDF_Array::GetElementValue(FX_DWORD i) const { | 451 CPDF_Object* CPDF_Array::GetElementValue(FX_DWORD i) const { |
| 452 if (i >= (FX_DWORD)m_Objects.GetSize()) { | 452 if (i >= (FX_DWORD)m_Objects.GetSize()) |
| 453 return NULL; | 453 return nullptr; |
| 454 } | 454 return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetDirect(); |
| 455 return ((CPDF_Object*)m_Objects.GetAt(i))->GetDirect(); | |
| 456 } | 455 } |
| 457 CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const { | 456 CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const { |
| 458 if (i < (FX_DWORD)m_Objects.GetSize()) { | 457 if (i < (FX_DWORD)m_Objects.GetSize()) |
| 459 CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); | 458 return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetString(); |
| 460 return p->GetString(); | |
| 461 } | |
| 462 return CFX_ByteString(); | 459 return CFX_ByteString(); |
| 463 } | 460 } |
| 464 CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const { | 461 CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const { |
| 465 if (i < (FX_DWORD)m_Objects.GetSize()) { | 462 if (i < (FX_DWORD)m_Objects.GetSize()) |
| 466 CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); | 463 return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetConstString(); |
| 467 return p->GetConstString(); | |
| 468 } | |
| 469 return CFX_ByteStringC(); | 464 return CFX_ByteStringC(); |
| 470 } | 465 } |
| 471 int CPDF_Array::GetInteger(FX_DWORD i) const { | 466 int CPDF_Array::GetInteger(FX_DWORD i) const { |
| 472 if (i >= (FX_DWORD)m_Objects.GetSize()) { | 467 if (i >= (FX_DWORD)m_Objects.GetSize()) |
| 473 return 0; | 468 return 0; |
| 474 } | 469 return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetInteger(); |
| 475 CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); | |
| 476 return p->GetInteger(); | |
| 477 } | 470 } |
| 478 FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const { | 471 FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const { |
| 479 if (i >= (FX_DWORD)m_Objects.GetSize()) { | 472 if (i >= (FX_DWORD)m_Objects.GetSize()) |
| 480 return 0; | 473 return 0; |
| 481 } | 474 return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetNumber(); |
| 482 CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); | |
| 483 return p->GetNumber(); | |
| 484 } | 475 } |
| 485 CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { | 476 CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { |
| 486 CPDF_Object* p = GetElementValue(i); | 477 CPDF_Object* p = GetElementValue(i); |
| 487 if (!p) | 478 if (!p) |
| 488 return NULL; | 479 return NULL; |
| 489 if (CPDF_Dictionary* pDict = p->AsDictionary()) | 480 if (CPDF_Dictionary* pDict = p->AsDictionary()) |
| 490 return pDict; | 481 return pDict; |
| 491 if (CPDF_Stream* pStream = p->AsStream()) | 482 if (CPDF_Stream* pStream = p->AsStream()) |
| 492 return pStream->GetDict(); | 483 return pStream->GetDict(); |
| 493 return NULL; | 484 return NULL; |
| 494 } | 485 } |
| 495 CPDF_Stream* CPDF_Array::GetStream(FX_DWORD i) const { | 486 CPDF_Stream* CPDF_Array::GetStream(FX_DWORD i) const { |
| 496 return ToStream(GetElementValue(i)); | 487 return ToStream(GetElementValue(i)); |
| 497 } | 488 } |
| 498 CPDF_Array* CPDF_Array::GetArray(FX_DWORD i) const { | 489 CPDF_Array* CPDF_Array::GetArray(FX_DWORD i) const { |
| 499 return ToArray(GetElementValue(i)); | 490 return ToArray(GetElementValue(i)); |
| 500 } | 491 } |
| 501 void CPDF_Array::RemoveAt(FX_DWORD i) { | 492 void CPDF_Array::RemoveAt(FX_DWORD i) { |
| 502 ASSERT(IsArray()); | 493 ASSERT(IsArray()); |
| 503 if (i >= (FX_DWORD)m_Objects.GetSize()) { | 494 if (i >= (FX_DWORD)m_Objects.GetSize()) |
| 504 return; | 495 return; |
| 505 } | 496 if (CPDF_Object* p = static_cast<CPDF_Object*>(m_Objects.GetAt(i))) |
| 506 CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); | |
| 507 if (p) | |
| 508 p->Release(); | 497 p->Release(); |
| 509 m_Objects.RemoveAt(i); | 498 m_Objects.RemoveAt(i); |
| 510 } | 499 } |
| 511 void CPDF_Array::SetAt(FX_DWORD i, | 500 void CPDF_Array::SetAt(FX_DWORD i, |
| 512 CPDF_Object* pObj, | 501 CPDF_Object* pObj, |
| 513 CPDF_IndirectObjects* pObjs) { | 502 CPDF_IndirectObjects* pObjs) { |
| 514 ASSERT(IsArray()); | 503 ASSERT(IsArray()); |
| 515 ASSERT(i < (FX_DWORD)m_Objects.GetSize()); | 504 ASSERT(i < (FX_DWORD)m_Objects.GetSize()); |
| 516 if (i >= (FX_DWORD)m_Objects.GetSize()) { | 505 if (i >= (FX_DWORD)m_Objects.GetSize()) |
| 517 return; | 506 return; |
| 518 } | 507 if (CPDF_Object* pOld = static_cast<CPDF_Object*>(m_Objects.GetAt(i))) |
| 519 CPDF_Object* pOld = (CPDF_Object*)m_Objects.GetAt(i); | |
| 520 if (pOld) | |
| 521 pOld->Release(); | 508 pOld->Release(); |
| 522 if (pObj->GetObjNum()) { | 509 if (pObj->GetObjNum()) { |
| 523 ASSERT(pObjs != NULL); | 510 ASSERT(pObjs); |
| 524 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 511 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); |
| 525 } | 512 } |
| 526 m_Objects.SetAt(i, pObj); | 513 m_Objects.SetAt(i, pObj); |
| 527 } | 514 } |
| 528 void CPDF_Array::InsertAt(FX_DWORD index, | 515 void CPDF_Array::InsertAt(FX_DWORD index, |
| 529 CPDF_Object* pObj, | 516 CPDF_Object* pObj, |
| 530 CPDF_IndirectObjects* pObjs) { | 517 CPDF_IndirectObjects* pObjs) { |
| 531 ASSERT(pObj != NULL); | 518 ASSERT(pObj != NULL); |
| 532 if (pObj->GetObjNum()) { | 519 if (pObj->GetObjNum()) { |
| 533 ASSERT(pObjs != NULL); | 520 ASSERT(pObjs != NULL); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 563 } | 550 } |
| 564 void CPDF_Array::AddReference(CPDF_IndirectObjects* pDoc, FX_DWORD objnum) { | 551 void CPDF_Array::AddReference(CPDF_IndirectObjects* pDoc, FX_DWORD objnum) { |
| 565 ASSERT(IsArray()); | 552 ASSERT(IsArray()); |
| 566 Add(new CPDF_Reference(pDoc, objnum)); | 553 Add(new CPDF_Reference(pDoc, objnum)); |
| 567 } | 554 } |
| 568 FX_BOOL CPDF_Array::Identical(CPDF_Array* pOther) const { | 555 FX_BOOL CPDF_Array::Identical(CPDF_Array* pOther) const { |
| 569 if (m_Objects.GetSize() != pOther->m_Objects.GetSize()) { | 556 if (m_Objects.GetSize() != pOther->m_Objects.GetSize()) { |
| 570 return FALSE; | 557 return FALSE; |
| 571 } | 558 } |
| 572 for (int i = 0; i < m_Objects.GetSize(); i++) | 559 for (int i = 0; i < m_Objects.GetSize(); i++) |
| 573 if (!((CPDF_Object*)m_Objects[i]) | 560 if (!static_cast<CPDF_Object*>(m_Objects[i]) |
| 574 ->IsIdentical((CPDF_Object*)pOther->m_Objects[i])) { | 561 ->IsIdentical(static_cast<CPDF_Object*>(pOther->m_Objects[i]))) { |
| 575 return FALSE; | 562 return FALSE; |
| 576 } | 563 } |
| 577 return TRUE; | 564 return TRUE; |
| 578 } | 565 } |
| 579 CPDF_Dictionary::~CPDF_Dictionary() { | 566 CPDF_Dictionary::~CPDF_Dictionary() { |
| 580 FX_POSITION pos = m_Map.GetStartPosition(); | 567 FX_POSITION pos = m_Map.GetStartPosition(); |
| 581 while (pos) { | 568 while (pos) { |
| 582 void* value = m_Map.GetNextValue(pos); | 569 if (CPDF_Object* value = static_cast<CPDF_Object*>(m_Map.GetNextValue(pos))) |
| 583 if (value) | 570 value->Release(); |
| 584 ((CPDF_Object*)value)->Release(); | |
| 585 } | 571 } |
| 586 } | 572 } |
| 587 FX_POSITION CPDF_Dictionary::GetStartPos() const { | 573 FX_POSITION CPDF_Dictionary::GetStartPos() const { |
| 588 return m_Map.GetStartPosition(); | 574 return m_Map.GetStartPosition(); |
| 589 } | 575 } |
| 590 CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos, | 576 CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos, |
| 591 CFX_ByteString& key) const { | 577 CFX_ByteString& key) const { |
| 592 if (pos == NULL) { | 578 if (pos == NULL) { |
| 593 return NULL; | 579 return NULL; |
| 594 } | 580 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 if (m_Map.GetCount() != pOther->m_Map.GetCount()) { | 753 if (m_Map.GetCount() != pOther->m_Map.GetCount()) { |
| 768 return FALSE; | 754 return FALSE; |
| 769 } | 755 } |
| 770 FX_POSITION pos = m_Map.GetStartPosition(); | 756 FX_POSITION pos = m_Map.GetStartPosition(); |
| 771 while (pos) { | 757 while (pos) { |
| 772 CFX_ByteString key; | 758 CFX_ByteString key; |
| 773 void* value; | 759 void* value; |
| 774 m_Map.GetNextAssoc(pos, key, value); | 760 m_Map.GetNextAssoc(pos, key, value); |
| 775 if (!value) | 761 if (!value) |
| 776 return FALSE; | 762 return FALSE; |
| 777 if (!((CPDF_Object*)value)->IsIdentical(pOther->GetElement(key))) { | 763 if (!static_cast<CPDF_Object*>(value)->IsIdentical(pOther->GetElement(key))) |
| 778 return FALSE; | 764 return FALSE; |
| 779 } | |
| 780 } | 765 } |
| 781 return TRUE; | 766 return TRUE; |
| 782 } | 767 } |
| 783 void CPDF_Dictionary::SetAtInteger(const CFX_ByteStringC& key, int i) { | 768 void CPDF_Dictionary::SetAtInteger(const CFX_ByteStringC& key, int i) { |
| 784 SetAt(key, new CPDF_Number(i)); | 769 SetAt(key, new CPDF_Number(i)); |
| 785 } | 770 } |
| 786 void CPDF_Dictionary::SetAtName(const CFX_ByteStringC& key, | 771 void CPDF_Dictionary::SetAtName(const CFX_ByteStringC& key, |
| 787 const CFX_ByteString& name) { | 772 const CFX_ByteString& name) { |
| 788 SetAt(key, new CPDF_Name(name)); | 773 SetAt(key, new CPDF_Name(name)); |
| 789 } | 774 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 } else { | 1097 } else { |
| 1113 m_LastObjNum = 0; | 1098 m_LastObjNum = 0; |
| 1114 } | 1099 } |
| 1115 } | 1100 } |
| 1116 CPDF_IndirectObjects::~CPDF_IndirectObjects() { | 1101 CPDF_IndirectObjects::~CPDF_IndirectObjects() { |
| 1117 FX_POSITION pos = m_IndirectObjs.GetStartPosition(); | 1102 FX_POSITION pos = m_IndirectObjs.GetStartPosition(); |
| 1118 while (pos) { | 1103 while (pos) { |
| 1119 void* key; | 1104 void* key; |
| 1120 void* value; | 1105 void* value; |
| 1121 m_IndirectObjs.GetNextAssoc(pos, key, value); | 1106 m_IndirectObjs.GetNextAssoc(pos, key, value); |
| 1122 ((CPDF_Object*)value)->Destroy(); | 1107 static_cast<CPDF_Object*>(value)->Destroy(); |
| 1123 } | 1108 } |
| 1124 } | 1109 } |
| 1125 CPDF_Object* CPDF_IndirectObjects::GetIndirectObject( | 1110 CPDF_Object* CPDF_IndirectObjects::GetIndirectObject( |
| 1126 FX_DWORD objnum, | 1111 FX_DWORD objnum, |
| 1127 struct PARSE_CONTEXT* pContext) { | 1112 struct PARSE_CONTEXT* pContext) { |
| 1128 if (objnum == 0) { | 1113 if (objnum == 0) |
| 1129 return NULL; | 1114 return nullptr; |
| 1115 void* value; |
| 1116 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { |
| 1117 CPDF_Object* pValue = static_cast<CPDF_Object*>(value); |
| 1118 if (pValue->GetObjNum() == -1) |
| 1119 return nullptr; |
| 1120 return pValue; |
| 1130 } | 1121 } |
| 1131 void* value; | 1122 |
| 1132 { | 1123 CPDF_Object* pObj = nullptr; |
| 1133 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { | 1124 if (m_pParser) |
| 1134 if (((CPDF_Object*)value)->GetObjNum() == -1) { | |
| 1135 return NULL; | |
| 1136 } | |
| 1137 return (CPDF_Object*)value; | |
| 1138 } | |
| 1139 } | |
| 1140 CPDF_Object* pObj = NULL; | |
| 1141 if (m_pParser) { | |
| 1142 pObj = m_pParser->ParseIndirectObject(this, objnum, pContext); | 1125 pObj = m_pParser->ParseIndirectObject(this, objnum, pContext); |
| 1143 } | 1126 if (!pObj) |
| 1144 if (pObj == NULL) { | 1127 return nullptr; |
| 1145 return NULL; | 1128 |
| 1146 } | |
| 1147 pObj->m_ObjNum = objnum; | 1129 pObj->m_ObjNum = objnum; |
| 1148 if (m_LastObjNum < objnum) { | 1130 if (m_LastObjNum < objnum) { |
| 1149 m_LastObjNum = objnum; | 1131 m_LastObjNum = objnum; |
| 1150 } | 1132 } |
| 1151 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { | 1133 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { |
| 1152 if (value) { | 1134 if (value) |
| 1153 ((CPDF_Object*)value)->Destroy(); | 1135 static_cast<CPDF_Object*>(value)->Destroy(); |
| 1154 } | |
| 1155 } | 1136 } |
| 1156 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); | 1137 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
| 1157 return pObj; | 1138 return pObj; |
| 1158 } | 1139 } |
| 1159 int CPDF_IndirectObjects::GetIndirectType(FX_DWORD objnum) { | 1140 int CPDF_IndirectObjects::GetIndirectType(FX_DWORD objnum) { |
| 1160 void* value; | 1141 void* value; |
| 1161 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { | 1142 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) |
| 1162 return ((CPDF_Object*)value)->GetType(); | 1143 return static_cast<CPDF_Object*>(value)->GetType(); |
| 1163 } | 1144 |
| 1164 if (m_pParser) { | 1145 if (m_pParser) { |
| 1165 PARSE_CONTEXT context; | 1146 PARSE_CONTEXT context; |
| 1166 FXSYS_memset(&context, 0, sizeof(PARSE_CONTEXT)); | 1147 FXSYS_memset(&context, 0, sizeof(PARSE_CONTEXT)); |
| 1167 context.m_Flags = PDFPARSE_TYPEONLY; | 1148 context.m_Flags = PDFPARSE_TYPEONLY; |
| 1168 return (int)(uintptr_t)m_pParser->ParseIndirectObject(this, objnum, | 1149 return (int)(uintptr_t)m_pParser->ParseIndirectObject(this, objnum, |
| 1169 &context); | 1150 &context); |
| 1170 } | 1151 } |
| 1171 return 0; | 1152 return 0; |
| 1172 } | 1153 } |
| 1173 FX_DWORD CPDF_IndirectObjects::AddIndirectObject(CPDF_Object* pObj) { | 1154 FX_DWORD CPDF_IndirectObjects::AddIndirectObject(CPDF_Object* pObj) { |
| 1174 if (pObj->m_ObjNum) { | 1155 if (pObj->m_ObjNum) { |
| 1175 return pObj->m_ObjNum; | 1156 return pObj->m_ObjNum; |
| 1176 } | 1157 } |
| 1177 m_LastObjNum++; | 1158 m_LastObjNum++; |
| 1178 m_IndirectObjs.SetAt((void*)(uintptr_t)m_LastObjNum, pObj); | 1159 m_IndirectObjs.SetAt((void*)(uintptr_t)m_LastObjNum, pObj); |
| 1179 pObj->m_ObjNum = m_LastObjNum; | 1160 pObj->m_ObjNum = m_LastObjNum; |
| 1180 return m_LastObjNum; | 1161 return m_LastObjNum; |
| 1181 } | 1162 } |
| 1182 void CPDF_IndirectObjects::ReleaseIndirectObject(FX_DWORD objnum) { | 1163 void CPDF_IndirectObjects::ReleaseIndirectObject(FX_DWORD objnum) { |
| 1183 void* value; | 1164 void* value; |
| 1184 if (!m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { | 1165 if (!m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) |
| 1185 return; | 1166 return; |
| 1186 } | 1167 CPDF_Object* pValue = static_cast<CPDF_Object*>(value); |
| 1187 if (((CPDF_Object*)value)->GetObjNum() == -1) { | 1168 if (pValue->GetObjNum() == -1) |
| 1188 return; | 1169 return; |
| 1189 } | 1170 pValue->Destroy(); |
| 1190 ((CPDF_Object*)value)->Destroy(); | |
| 1191 m_IndirectObjs.RemoveKey((void*)(uintptr_t)objnum); | 1171 m_IndirectObjs.RemoveKey((void*)(uintptr_t)objnum); |
| 1192 } | 1172 } |
| 1193 void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, | 1173 void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, |
| 1194 CPDF_Object* pObj) { | 1174 CPDF_Object* pObj) { |
| 1195 if (objnum == 0 || pObj == NULL) { | 1175 if (objnum == 0 || pObj == NULL) { |
| 1196 return; | 1176 return; |
| 1197 } | 1177 } |
| 1198 void* value = NULL; | 1178 void* value = NULL; |
| 1199 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { | 1179 if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { |
| 1200 if (value) { | 1180 if (value) { |
| 1201 if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) { | 1181 CPDF_Object* pValue = static_cast<CPDF_Object*>(value); |
| 1182 if (pObj->GetGenNum() <= pValue->GetGenNum()) |
| 1202 return; | 1183 return; |
| 1203 } | 1184 pValue->Destroy(); |
| 1204 ((CPDF_Object*)value)->Destroy(); | |
| 1205 } | 1185 } |
| 1206 } | 1186 } |
| 1207 pObj->m_ObjNum = objnum; | 1187 pObj->m_ObjNum = objnum; |
| 1208 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); | 1188 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
| 1209 if (m_LastObjNum < objnum) { | 1189 if (m_LastObjNum < objnum) { |
| 1210 m_LastObjNum = objnum; | 1190 m_LastObjNum = objnum; |
| 1211 } | 1191 } |
| 1212 } | 1192 } |
| 1213 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { | 1193 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { |
| 1214 return m_LastObjNum; | 1194 return m_LastObjNum; |
| 1215 } | 1195 } |
| OLD | NEW |