Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2359)

Unified Diff: core/fpdfapi/fpdf_parser/cpdf_array.cpp

Issue 2355083002: Make CPDF_Array not do indirect object creation. (Closed)
Patch Set: Missed two references Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_parser/cpdf_array.cpp
diff --git a/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
index 5e103fa423ccd7cdba685bb8c6ad61fca0696258..da935af47ddbdfe912445d283932605a3223a2c0 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_array.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
+#include "third_party/base/logging.h"
#include "third_party/base/stl_util.h"
CPDF_Array::CPDF_Array() {}
@@ -145,30 +146,22 @@ void CPDF_Array::RemoveAt(size_t i, size_t nCount) {
m_Objects.erase(m_Objects.begin() + i, m_Objects.begin() + i + nCount);
}
-void CPDF_Array::SetAt(size_t i,
- CPDF_Object* pObj,
- CPDF_IndirectObjectHolder* pObjs) {
+void CPDF_Array::SetAt(size_t i, CPDF_Object* pObj) {
ASSERT(IsArray());
+ CHECK(!pObj || pObj->GetObjNum() == 0);
if (i >= m_Objects.size()) {
ASSERT(false);
return;
}
if (CPDF_Object* pOld = m_Objects[i])
pOld->Release();
- if (pObj->GetObjNum()) {
- ASSERT(pObjs);
- pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
- }
+
m_Objects[i] = pObj;
}
-void CPDF_Array::InsertAt(size_t index,
- CPDF_Object* pObj,
- CPDF_IndirectObjectHolder* pObjs) {
- if (pObj->GetObjNum()) {
- ASSERT(pObjs);
- pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
- }
+void CPDF_Array::InsertAt(size_t index, CPDF_Object* pObj) {
+ ASSERT(IsArray());
+ CHECK(!pObj || pObj->GetObjNum() == 0);
if (index >= m_Objects.size()) {
// Allocate space first.
m_Objects.resize(index + 1, nullptr);
@@ -179,37 +172,29 @@ void CPDF_Array::InsertAt(size_t index,
}
}
-void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs) {
- if (pObj->GetObjNum()) {
- ASSERT(pObjs);
- pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
- }
+void CPDF_Array::Add(CPDF_Object* pObj) {
+ ASSERT(IsArray());
+ CHECK(!pObj || pObj->GetObjNum() == 0);
m_Objects.push_back(pObj);
}
void CPDF_Array::AddName(const CFX_ByteString& str) {
- ASSERT(IsArray());
Add(new CPDF_Name(str));
}
void CPDF_Array::AddString(const CFX_ByteString& str) {
- ASSERT(IsArray());
Add(new CPDF_String(str, FALSE));
}
void CPDF_Array::AddInteger(int i) {
- ASSERT(IsArray());
Add(new CPDF_Number(i));
}
void CPDF_Array::AddNumber(FX_FLOAT f) {
- ASSERT(IsArray());
- CPDF_Number* pNumber = new CPDF_Number(f);
- Add(pNumber);
+ Add(new CPDF_Number(f));
}
void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc,
uint32_t objnum) {
- ASSERT(IsArray());
Add(new CPDF_Reference(pDoc, objnum));
}
« no previous file with comments | « core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698