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

Unified Diff: core/fpdfapi/parser/cpdf_hint_tables.cpp

Issue 2474283005: Revert of Unify some code (Closed)
Patch Set: Created 4 years, 1 month 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/parser/cpdf_hint_tables.h ('k') | core/fpdfapi/parser/cpdf_linearized.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_hint_tables.cpp
diff --git a/core/fpdfapi/parser/cpdf_hint_tables.cpp b/core/fpdfapi/parser/cpdf_hint_tables.cpp
index bbc57dace915abfa17aeb8848a86aa4f027ca31e..045b94cac5dda7fe7982ad729c3a2662f1a30da7 100644
--- a/core/fpdfapi/parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/parser/cpdf_hint_tables.cpp
@@ -12,7 +12,6 @@
#include "core/fpdfapi/parser/cpdf_data_avail.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
-#include "core/fpdfapi/parser/cpdf_linearized.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
@@ -35,12 +34,12 @@
} // namespace
CPDF_HintTables::CPDF_HintTables(CPDF_DataAvail* pDataAvail,
- CPDF_Linearized* pLinearized)
+ CPDF_Dictionary* pLinearized)
: m_pDataAvail(pDataAvail),
- m_pLinearized(pLinearized),
+ m_pLinearizedDict(pLinearized),
m_nFirstPageSharedObjs(0),
m_szFirstPageObjOffset(0) {
- ASSERT(m_pLinearized);
+ ASSERT(m_pLinearizedDict);
}
CPDF_HintTables::~CPDF_HintTables() {}
@@ -488,25 +487,38 @@
}
int CPDF_HintTables::GetEndOfFirstPageOffset() const {
- return static_cast<int>(m_pLinearized->GetFirstPageEndOffset());
+ CPDF_Object* pOffsetE = m_pLinearizedDict->GetDirectObjectFor("E");
+ return pOffsetE ? pOffsetE->GetInteger() : -1;
}
int CPDF_HintTables::GetNumberOfPages() const {
- return static_cast<int>(m_pLinearized->GetPageCount());
+ CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectFor("N");
+ return pPageNum ? pPageNum->GetInteger() : 0;
}
int CPDF_HintTables::GetFirstPageObjectNumber() const {
- return static_cast<int>(m_pLinearized->GetFirstPageObjNum());
+ CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectFor("O");
+ return pFirstPageObj ? pFirstPageObj->GetInteger() : -1;
}
int CPDF_HintTables::GetFirstPageNumber() const {
- return static_cast<int>(m_pLinearized->GetFirstPageNo());
+ CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectFor("P");
+ return pFirstPageNum ? pFirstPageNum->GetInteger() : 0;
}
int CPDF_HintTables::ReadPrimaryHintStreamOffset() const {
- return static_cast<int>(m_pLinearized->GetHintStart());
+ return ReadPrimaryHintStream(0);
}
int CPDF_HintTables::ReadPrimaryHintStreamLength() const {
- return static_cast<int>(m_pLinearized->GetHintLength());
-}
+ return ReadPrimaryHintStream(1);
+}
+
+int CPDF_HintTables::ReadPrimaryHintStream(int index) const {
+ CPDF_Array* pRange = m_pLinearizedDict->GetArrayFor("H");
+ if (!pRange)
+ return -1;
+
+ CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(index);
+ return pStreamLen ? pStreamLen->GetInteger() : -1;
+}
« no previous file with comments | « core/fpdfapi/parser/cpdf_hint_tables.h ('k') | core/fpdfapi/parser/cpdf_linearized.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698