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_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
8 | 8 |
9 #include "core/include/fxcrt/fx_string.h" | 9 #include "core/include/fxcrt/fx_string.h" |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 return nullptr; | 154 return nullptr; |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 CPDF_Array* CPDF_Object::GetArray() const { | 158 CPDF_Array* CPDF_Object::GetArray() const { |
159 // The method should be made non-const if we want to not be const. | 159 // The method should be made non-const if we want to not be const. |
160 // See bug #234. | 160 // See bug #234. |
161 return const_cast<CPDF_Array*>(AsArray()); | 161 return const_cast<CPDF_Array*>(AsArray()); |
162 } | 162 } |
163 void CPDF_Object::SetString(const CFX_ByteString& str) { | 163 void CPDF_Object::SetString(const CFX_ByteString& str) { |
164 ASSERT(this != NULL); | 164 ASSERT(this); |
Tom Sepez
2015/12/14 19:14:07
Uh, no.
Lei Zhang
2015/12/15 01:38:32
Done.
| |
165 switch (m_Type) { | 165 switch (m_Type) { |
166 case PDFOBJ_BOOLEAN: | 166 case PDFOBJ_BOOLEAN: |
167 AsBoolean()->m_bValue = (str == "true"); | 167 AsBoolean()->m_bValue = (str == "true"); |
168 return; | 168 return; |
169 case PDFOBJ_NUMBER: | 169 case PDFOBJ_NUMBER: |
170 AsNumber()->SetString(str); | 170 AsNumber()->SetString(str); |
171 return; | 171 return; |
172 case PDFOBJ_STRING: | 172 case PDFOBJ_STRING: |
173 AsString()->m_String = str; | 173 AsString()->m_String = str; |
174 return; | 174 return; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 pOld->Release(); | 519 pOld->Release(); |
520 if (pObj->GetObjNum()) { | 520 if (pObj->GetObjNum()) { |
521 ASSERT(pObjs); | 521 ASSERT(pObjs); |
522 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 522 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); |
523 } | 523 } |
524 m_Objects.SetAt(i, pObj); | 524 m_Objects.SetAt(i, pObj); |
525 } | 525 } |
526 void CPDF_Array::InsertAt(FX_DWORD index, | 526 void CPDF_Array::InsertAt(FX_DWORD index, |
527 CPDF_Object* pObj, | 527 CPDF_Object* pObj, |
528 CPDF_IndirectObjects* pObjs) { | 528 CPDF_IndirectObjects* pObjs) { |
529 ASSERT(pObj != NULL); | |
530 if (pObj->GetObjNum()) { | 529 if (pObj->GetObjNum()) { |
531 ASSERT(pObjs != NULL); | 530 ASSERT(pObjs); |
Tom Sepez
2015/12/14 19:14:08
Probably segvs under next line? Or is it special
Lei Zhang
2015/12/15 01:38:32
The next line dereferences |pObj| but not |pObjs|.
| |
532 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 531 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); |
533 } | 532 } |
534 m_Objects.InsertAt(index, pObj); | 533 m_Objects.InsertAt(index, pObj); |
535 } | 534 } |
536 void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) { | 535 void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) { |
537 ASSERT(pObj != NULL); | |
538 if (pObj->GetObjNum()) { | 536 if (pObj->GetObjNum()) { |
539 ASSERT(pObjs != NULL); | 537 ASSERT(pObjs); |
Tom Sepez
2015/12/14 19:14:07
and here.
Lei Zhang
2015/12/15 01:38:32
Same as above.
| |
540 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 538 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); |
541 } | 539 } |
542 m_Objects.Add(pObj); | 540 m_Objects.Add(pObj); |
543 } | 541 } |
544 void CPDF_Array::AddName(const CFX_ByteString& str) { | 542 void CPDF_Array::AddName(const CFX_ByteString& str) { |
545 ASSERT(IsArray()); | 543 ASSERT(IsArray()); |
546 Add(new CPDF_Name(str)); | 544 Add(new CPDF_Name(str)); |
547 } | 545 } |
548 void CPDF_Array::AddString(const CFX_ByteString& str) { | 546 void CPDF_Array::AddString(const CFX_ByteString& str) { |
549 ASSERT(IsArray()); | 547 ASSERT(IsArray()); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 } | 1170 } |
1173 pObj->m_ObjNum = objnum; | 1171 pObj->m_ObjNum = objnum; |
1174 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); | 1172 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
1175 if (m_LastObjNum < objnum) { | 1173 if (m_LastObjNum < objnum) { |
1176 m_LastObjNum = objnum; | 1174 m_LastObjNum = objnum; |
1177 } | 1175 } |
1178 } | 1176 } |
1179 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { | 1177 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { |
1180 return m_LastObjNum; | 1178 return m_LastObjNum; |
1181 } | 1179 } |
OLD | NEW |