summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp132
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp24
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_hint_tables.h7
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h (renamed from core/fpdfapi/fpdf_parser/cpdf_data_avail.h)155
-rw-r--r--core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h80
5 files changed, 165 insertions, 233 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
index 6f8f9ee1a6..5a7a7be544 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
@@ -4,9 +4,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h"
#include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
@@ -20,29 +20,17 @@
#include "core/fxcrt/include/fx_safe_types.h"
#include "third_party/base/stl_util.h"
-IPDF_DataAvail::IPDF_DataAvail(IPDF_DataAvail::FileAvail* pFileAvail,
- IFX_FileRead* pFileRead)
- : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {}
+CPDF_DataAvail::FileAvail::~FileAvail() {}
-IPDF_DataAvail::~IPDF_DataAvail() {}
-
-IPDF_DataAvail::FileAvail::~FileAvail() {}
-
-IPDF_DataAvail::DownloadHints::~DownloadHints() {}
-
-// static
-IPDF_DataAvail* IPDF_DataAvail::Create(IPDF_DataAvail::FileAvail* pFileAvail,
- IFX_FileRead* pFileRead) {
- return new CPDF_DataAvail(pFileAvail, pFileRead, TRUE);
-}
+CPDF_DataAvail::DownloadHints::~DownloadHints() {}
// static
int CPDF_DataAvail::s_CurrentDataAvailRecursionDepth = 0;
-CPDF_DataAvail::CPDF_DataAvail(IPDF_DataAvail::FileAvail* pFileAvail,
+CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail,
IFX_FileRead* pFileRead,
FX_BOOL bSupportHintTable)
- : IPDF_DataAvail(pFileAvail, pFileRead) {
+ : m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {
m_Pos = 0;
m_dwFileLen = 0;
if (m_pFileRead) {
@@ -136,7 +124,7 @@ uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) {
FX_BOOL CPDF_DataAvail::IsObjectsAvail(
CFX_ArrayTemplate<CPDF_Object*>& obj_array,
FX_BOOL bParsePage,
- IPDF_DataAvail::DownloadHints* pHints,
+ DownloadHints* pHints,
CFX_ArrayTemplate<CPDF_Object*>& ret_array) {
if (!obj_array.GetSize())
return TRUE;
@@ -211,8 +199,8 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
return IsObjectsAvail(obj_array, FALSE, pHints, ret_array);
}
-IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
- IPDF_DataAvail::DownloadHints* pHints) {
+CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
+ DownloadHints* pHints) {
if (!m_dwFileLen && m_pFileRead) {
m_dwFileLen = (uint32_t)m_pFileRead->GetSize();
if (!m_dwFileLen)
@@ -227,8 +215,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
return DataAvailable;
}
-FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
m_objs_array.RemoveAll();
m_ObjectSet.clear();
@@ -255,7 +242,7 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(
return bRet;
}
-FX_BOOL CPDF_DataAvail::CheckAcroForm(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist);
if (!bExist) {
@@ -276,7 +263,7 @@ FX_BOOL CPDF_DataAvail::CheckAcroForm(IPDF_DataAvail::DownloadHints* pHints) {
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckDocStatus(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) {
switch (m_docStatus) {
case PDF_DATAAVAIL_HEADER:
return CheckHeader(pHints);
@@ -326,7 +313,7 @@ FX_BOOL CPDF_DataAvail::CheckDocStatus(IPDF_DataAvail::DownloadHints* pHints) {
}
}
-FX_BOOL CPDF_DataAvail::CheckPageStatus(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckPageStatus(DownloadHints* pHints) {
switch (m_docStatus) {
case PDF_DATAAVAIL_PAGETREE:
return CheckPages(pHints);
@@ -341,7 +328,7 @@ FX_BOOL CPDF_DataAvail::CheckPageStatus(IPDF_DataAvail::DownloadHints* pHints) {
}
}
-FX_BOOL CPDF_DataAvail::LoadAllFile(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::LoadAllFile(DownloadHints* pHints) {
if (m_pFileAvail->IsDataAvail(0, (uint32_t)m_dwFileLen)) {
m_docStatus = PDF_DATAAVAIL_DONE;
return TRUE;
@@ -351,7 +338,7 @@ FX_BOOL CPDF_DataAvail::LoadAllFile(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-FX_BOOL CPDF_DataAvail::LoadAllXref(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::LoadAllXref(DownloadHints* pHints) {
m_parser.m_pSyntax->InitParser(m_pFileRead, (uint32_t)m_dwHeaderOffset);
m_parser.m_bOwnFileRead = false;
if (!m_parser.LoadAllCrossRefV4(m_dwLastXRefOffset) &&
@@ -368,7 +355,7 @@ FX_BOOL CPDF_DataAvail::LoadAllXref(IPDF_DataAvail::DownloadHints* pHints) {
}
CPDF_Object* CPDF_DataAvail::GetObject(uint32_t objnum,
- IPDF_DataAvail::DownloadHints* pHints,
+ DownloadHints* pHints,
FX_BOOL* pExistInFile) {
CPDF_Object* pRet = nullptr;
uint32_t size = 0;
@@ -399,7 +386,7 @@ CPDF_Object* CPDF_DataAvail::GetObject(uint32_t objnum,
return pRet;
}
-FX_BOOL CPDF_DataAvail::CheckInfo(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckInfo(DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
CPDF_Object* pInfo = GetObject(m_dwInfoObjNum, pHints, &bExist);
if (!bExist) {
@@ -428,7 +415,7 @@ FX_BOOL CPDF_DataAvail::CheckInfo(IPDF_DataAvail::DownloadHints* pHints) {
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckRoot(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist);
if (!bExist) {
@@ -496,7 +483,7 @@ void CPDF_DataAvail::ResetFirstCheck(int iPage) {
m_pageMapCheckState.erase(iPage);
}
-FX_BOOL CPDF_DataAvail::CheckPage(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
uint32_t iPageObjs = m_PageObjList.GetSize();
CFX_ArrayTemplate<uint32_t> UnavailObjList;
for (uint32_t i = 0; i < iPageObjs; ++i) {
@@ -591,7 +578,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckPages(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckPages(DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist);
if (!bExist) {
@@ -618,7 +605,7 @@ FX_BOOL CPDF_DataAvail::CheckPages(IPDF_DataAvail::DownloadHints* pHints) {
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckHeader(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckHeader(DownloadHints* pHints) {
ASSERT(m_dwFileLen >= 0);
const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U);
@@ -640,7 +627,7 @@ FX_BOOL CPDF_DataAvail::CheckHeader(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) {
CPDF_Dictionary* pDict = m_pLinearized->GetDict();
CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : nullptr;
if (!pEndOffSet) {
@@ -710,7 +697,7 @@ FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) {
FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset,
uint32_t size,
- IPDF_DataAvail::DownloadHints* pHints) {
+ DownloadHints* pHints) {
if (offset < 0 || offset > m_dwFileLen)
return TRUE;
@@ -729,7 +716,7 @@ FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset,
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckHintTables(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) {
CPDF_Dictionary* pDict = m_pLinearized->GetDict();
if (!pDict) {
m_docStatus = PDF_DATAAVAIL_ERROR;
@@ -815,7 +802,7 @@ CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
return pObj;
}
-IPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() {
+CPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() {
const uint32_t kReqSize = 1024;
if (!m_pFileAvail->IsDataAvail(0, kReqSize))
return LinearizationUnknown;
@@ -885,7 +872,7 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckEnd(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckEnd(DownloadHints* pHints) {
uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0);
uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos);
@@ -927,9 +914,8 @@ FX_BOOL CPDF_DataAvail::CheckEnd(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-int32_t CPDF_DataAvail::CheckCrossRefStream(
- IPDF_DataAvail::DownloadHints* pHints,
- FX_FILESIZE& xref_offset) {
+int32_t CPDF_DataAvail::CheckCrossRefStream(DownloadHints* pHints,
+ FX_FILESIZE& xref_offset) {
xref_offset = 0;
uint32_t req_size =
(uint32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512);
@@ -1084,8 +1070,7 @@ FX_BOOL CPDF_DataAvail::GetNextChar(uint8_t& ch) {
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckCrossRefItem(
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckCrossRefItem(DownloadHints* pHints) {
int32_t iSize = 0;
CFX_ByteString token;
while (1) {
@@ -1103,8 +1088,7 @@ FX_BOOL CPDF_DataAvail::CheckCrossRefItem(
}
}
-FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(DownloadHints* pHints) {
FX_FILESIZE xref_offset = 0;
int32_t nRet = CheckCrossRefStream(pHints, xref_offset);
@@ -1123,7 +1107,7 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(
return FALSE;
}
-FX_BOOL CPDF_DataAvail::CheckCrossRef(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) {
int32_t iSize = 0;
CFX_ByteString token;
if (!GetNextToken(token)) {
@@ -1155,8 +1139,7 @@ FX_BOOL CPDF_DataAvail::CheckCrossRef(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-FX_BOOL CPDF_DataAvail::CheckTrailerAppend(
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckTrailerAppend(DownloadHints* pHints) {
if (m_Pos < m_dwFileLen) {
FX_FILESIZE dwAppendPos = m_Pos + m_syntaxParser.SavePos();
int32_t iSize = (int32_t)(
@@ -1177,7 +1160,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailerAppend(
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckTrailer(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) {
int32_t iTrailerSize =
(int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512);
if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) {
@@ -1237,8 +1220,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage,
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, DownloadHints* pHints) {
while (TRUE) {
switch (m_docStatus) {
case PDF_DATAAVAIL_PAGETREE:
@@ -1261,10 +1243,9 @@ FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage,
}
}
-FX_BOOL CPDF_DataAvail::CheckArrayPageNode(
- uint32_t dwPageNo,
- CPDF_DataAvail::PageNode* pPageNode,
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo,
+ PageNode* pPageNode,
+ DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
CPDF_Object* pPages = GetObject(dwPageNo, pHints, &bExist);
if (!bExist) {
@@ -1301,10 +1282,9 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode(
return TRUE;
}
-FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(
- uint32_t dwPageNo,
- CPDF_DataAvail::PageNode* pPageNode,
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
+ PageNode* pPageNode,
+ DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
CPDF_Object* pPage = GetObject(dwPageNo, pHints, &bExist);
if (!bExist) {
@@ -1378,7 +1358,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(
FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
int32_t iPage,
int32_t& iCount,
- IPDF_DataAvail::DownloadHints* pHints,
+ DownloadHints* pHints,
int level) {
if (level >= kMaxPageRecursionDepth)
return FALSE;
@@ -1425,8 +1405,7 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
return TRUE;
}
-FX_BOOL CPDF_DataAvail::LoadDocPage(int32_t iPage,
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::LoadDocPage(int32_t iPage, DownloadHints* pHints) {
if (m_pDocument->GetPageCount() <= iPage ||
m_pDocument->m_PageList.GetAt(iPage)) {
m_docStatus = PDF_DATAAVAIL_DONE;
@@ -1445,7 +1424,7 @@ FX_BOOL CPDF_DataAvail::LoadDocPage(int32_t iPage,
return CheckPageNode(m_pageNodes, iPage, iCount, pHints, 0);
}
-FX_BOOL CPDF_DataAvail::CheckPageCount(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) {
FX_BOOL bExist = FALSE;
CPDF_Object* pPages = GetObject(m_PagesObjNum, pHints, &bExist);
if (!bExist) {
@@ -1478,7 +1457,7 @@ FX_BOOL CPDF_DataAvail::CheckPageCount(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-FX_BOOL CPDF_DataAvail::LoadDocPages(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) {
if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints))
return FALSE;
@@ -1491,7 +1470,7 @@ FX_BOOL CPDF_DataAvail::LoadDocPages(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-FX_BOOL CPDF_DataAvail::LoadPages(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::LoadPages(DownloadHints* pHints) {
while (!m_bPagesTreeLoad) {
if (!CheckPageStatus(pHints))
return FALSE;
@@ -1504,8 +1483,8 @@ FX_BOOL CPDF_DataAvail::LoadPages(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
-IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData(
- IPDF_DataAvail::DownloadHints* pHints) {
+CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData(
+ DownloadHints* pHints) {
if (m_bLinearedDataOK)
return DataAvailable;
@@ -1537,8 +1516,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData(
return m_bLinearedDataOK ? DataAvailable : DataNotAvailable;
}
-FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage,
- IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
m_objs_array.RemoveAll();
m_ObjectSet.clear();
@@ -1570,9 +1548,9 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage,
return bRet;
}
-IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage(
+CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage(
int32_t iPage,
- IPDF_DataAvail::DownloadHints* pHints) {
+ DownloadHints* pHints) {
if (!m_bAnnotsLoad) {
if (!CheckPageAnnots(iPage, pHints))
return DataNotAvailable;
@@ -1607,9 +1585,9 @@ FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) {
return HaveResourceAncestor(pParentDict);
}
-IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
+CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
int32_t iPage,
- IPDF_DataAvail::DownloadHints* pHints) {
+ DownloadHints* pHints) {
if (!m_pDocument)
return DataError;
@@ -1735,7 +1713,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
return DataAvailable;
}
-FX_BOOL CPDF_DataAvail::CheckResources(IPDF_DataAvail::DownloadHints* pHints) {
+FX_BOOL CPDF_DataAvail::CheckResources(DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
m_objs_array.RemoveAll();
CFX_ArrayTemplate<CPDF_Object*> obj_array;
@@ -1803,8 +1781,8 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) {
return m_pDocument->GetPage(index);
}
-IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
- IPDF_DataAvail::DownloadHints* pHints) {
+CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
+ DownloadHints* pHints) {
if (!m_pDocument)
return FormAvailable;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
index 8f810aa888..dfb34cbd58 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
@@ -6,7 +6,7 @@
#include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
@@ -362,24 +362,24 @@ FX_BOOL CPDF_HintTables::GetPagePos(int index,
return TRUE;
}
-IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage(
+CPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage(
int index,
- IPDF_DataAvail::DownloadHints* pHints) {
+ CPDF_DataAvail::DownloadHints* pHints) {
if (!m_pLinearizedDict || !pHints)
- return IPDF_DataAvail::DataError;
+ return CPDF_DataAvail::DataError;
CPDF_Object* pFirstAvailPage = m_pLinearizedDict->GetDirectObjectBy("P");
int nFirstAvailPage = pFirstAvailPage ? pFirstAvailPage->GetInteger() : 0;
if (index == nFirstAvailPage)
- return IPDF_DataAvail::DataAvailable;
+ return CPDF_DataAvail::DataAvailable;
uint32_t dwLength = GetItemLength(index, m_szPageOffsetArray);
// If two pages have the same offset, it should be treated as an error.
if (!dwLength)
- return IPDF_DataAvail::DataError;
+ return CPDF_DataAvail::DataError;
if (!m_pDataAvail->IsDataAvail(m_szPageOffsetArray[index], dwLength, pHints))
- return IPDF_DataAvail::DataNotAvailable;
+ return CPDF_DataAvail::DataNotAvailable;
// Download data of shared objects in the page.
uint32_t offset = 0;
@@ -389,14 +389,14 @@ IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage(
CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectBy("O");
int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1;
if (nFirstPageObjNum < 0)
- return IPDF_DataAvail::DataError;
+ return CPDF_DataAvail::DataError;
uint32_t dwIndex = 0;
uint32_t dwObjNum = 0;
for (uint32_t j = 0; j < m_dwNSharedObjsArray[index]; ++j) {
dwIndex = m_dwIdentifierArray[offset + j];
if (dwIndex >= static_cast<uint32_t>(m_dwSharedObjNumArray.GetSize()))
- return IPDF_DataAvail::DataNotAvailable;
+ return CPDF_DataAvail::DataNotAvailable;
dwObjNum = m_dwSharedObjNumArray[dwIndex];
if (dwObjNum >= static_cast<uint32_t>(nFirstPageObjNum) &&
@@ -408,14 +408,14 @@ IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage(
dwLength = GetItemLength(dwIndex, m_szSharedObjOffsetArray);
// If two objects have the same offset, it should be treated as an error.
if (!dwLength)
- return IPDF_DataAvail::DataError;
+ return CPDF_DataAvail::DataError;
if (!m_pDataAvail->IsDataAvail(m_szSharedObjOffsetArray[dwIndex], dwLength,
pHints)) {
- return IPDF_DataAvail::DataNotAvailable;
+ return CPDF_DataAvail::DataNotAvailable;
}
}
- return IPDF_DataAvail::DataAvailable;
+ return CPDF_DataAvail::DataAvailable;
}
FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h
index 4436339e82..1eb072367a 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h
@@ -9,12 +9,11 @@
#include <vector>
-#include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_stream.h"
class CFX_BitStream;
-class CPDF_DataAvail;
class CPDF_Dictionary;
class CPDF_Stream;
@@ -28,9 +27,9 @@ class CPDF_HintTables {
FX_FILESIZE& szPageLength,
uint32_t& dwObjNum);
- IPDF_DataAvail::DocAvailStatus CheckPage(
+ CPDF_DataAvail::DocAvailStatus CheckPage(
int index,
- IPDF_DataAvail::DownloadHints* pHints);
+ CPDF_DataAvail::DownloadHints* pHints);
FX_BOOL LoadHintStream(CPDF_Stream* pHintStream);
diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.h b/core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h
index 553489a267..4adedba36c 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h
@@ -4,16 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_DATA_AVAIL_H_
-#define CORE_FPDFAPI_FPDF_PARSER_CPDF_DATA_AVAIL_H_
+#ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DATA_AVAIL_H_
+#define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DATA_AVAIL_H_
-#include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h"
#include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
-#include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h"
#include "core/fxcrt/include/fx_basic.h"
class CPDF_Dictionary;
+class CPDF_HintTables;
class CPDF_IndirectObjectHolder;
class CPDF_Parser;
@@ -49,22 +48,61 @@ enum PDF_PAGENODE_TYPE {
PDF_PAGENODE_ARRAY,
};
-class CPDF_DataAvail final : public IPDF_DataAvail {
+class CPDF_DataAvail final {
public:
+ // Must match PDF_DATA_* definitions in public/fpdf_dataavail.h, but cannot
+ // #include that header. fpdfsdk/fpdf_dataavail.cpp has static_asserts
+ // to make sure the two sets of values match.
+ enum DocAvailStatus {
+ DataError = -1, // PDF_DATA_ERROR
+ DataNotAvailable = 0, // PDF_DATA_NOTAVAIL
+ DataAvailable = 1, // PDF_DATA_AVAIL
+ };
+
+ // Must match PDF_*LINEAR* definitions in public/fpdf_dataavail.h, but cannot
+ // #include that header. fpdfsdk/fpdf_dataavail.cpp has static_asserts
+ // to make sure the two sets of values match.
+ enum DocLinearizationStatus {
+ LinearizationUnknown = -1, // PDF_LINEARIZATION_UNKNOWN
+ NotLinearized = 0, // PDF_NOT_LINEARIZED
+ Linearized = 1, // PDF_LINEARIZED
+ };
+
+ // Must match PDF_FORM_* definitions in public/fpdf_dataavail.h, but cannot
+ // #include that header. fpdfsdk/fpdf_dataavail.cpp has static_asserts
+ // to make sure the two sets of values match.
+ enum DocFormStatus {
+ FormError = -1, // PDF_FORM_ERROR
+ FormNotAvailable = 0, // PDF_FORM_NOTAVAIL
+ FormAvailable = 1, // PDF_FORM_AVAIL
+ FormNotExist = 2, // PDF_FORM_NOTEXIST
+ };
+
+ class FileAvail {
+ public:
+ virtual ~FileAvail();
+ virtual FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) = 0;
+ };
+
+ class DownloadHints {
+ public:
+ virtual ~DownloadHints();
+ virtual void AddSegment(FX_FILESIZE offset, uint32_t size) = 0;
+ };
+
CPDF_DataAvail(FileAvail* pFileAvail,
IFX_FileRead* pFileRead,
FX_BOOL bSupportHintTable);
- ~CPDF_DataAvail() override;
-
- // IPDF_DataAvail
- DocAvailStatus IsDocAvail(DownloadHints* pHints) override;
- void SetDocument(CPDF_Document* pDoc) override;
- DocAvailStatus IsPageAvail(int iPage, DownloadHints* pHints) override;
- DocFormStatus IsFormAvail(DownloadHints* pHints) override;
- DocLinearizationStatus IsLinearizedPDF() override;
- FX_BOOL IsLinearized() override;
- void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, uint32_t* pSize) override;
-
+ ~CPDF_DataAvail();
+
+ DocAvailStatus IsDocAvail(DownloadHints* pHints);
+ void SetDocument(CPDF_Document* pDoc);
+ DocAvailStatus IsPageAvail(int iPage, DownloadHints* pHints);
+ DocFormStatus IsFormAvail(DownloadHints* pHints);
+ DocLinearizationStatus IsLinearizedPDF();
+ FX_BOOL IsLinearized();
+ void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, uint32_t* pSize);
+ IFX_FileRead* GetFileRead() const { return m_pFileRead; }
int GetPageCount() const;
CPDF_Dictionary* GetPage(int index);
@@ -88,30 +126,29 @@ class CPDF_DataAvail final : public IPDF_DataAvail {
uint32_t GetObjectSize(uint32_t objnum, FX_FILESIZE& offset);
FX_BOOL IsObjectsAvail(CFX_ArrayTemplate<CPDF_Object*>& obj_array,
FX_BOOL bParsePage,
- IPDF_DataAvail::DownloadHints* pHints,
+ DownloadHints* pHints,
CFX_ArrayTemplate<CPDF_Object*>& ret_array);
- FX_BOOL CheckDocStatus(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckHeader(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckHintTables(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckEnd(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckCrossRef(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckCrossRefItem(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckTrailer(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckRoot(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckInfo(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckPages(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckPage(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckResources(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckAnnots(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckAcroForm(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckAcroFormSubObject(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckTrailerAppend(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckPageStatus(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckAllCrossRefStream(IPDF_DataAvail::DownloadHints* pHints);
-
- int32_t CheckCrossRefStream(IPDF_DataAvail::DownloadHints* pHints,
- FX_FILESIZE& xref_offset);
+ FX_BOOL CheckDocStatus(DownloadHints* pHints);
+ FX_BOOL CheckHeader(DownloadHints* pHints);
+ FX_BOOL CheckFirstPage(DownloadHints* pHints);
+ FX_BOOL CheckHintTables(DownloadHints* pHints);
+ FX_BOOL CheckEnd(DownloadHints* pHints);
+ FX_BOOL CheckCrossRef(DownloadHints* pHints);
+ FX_BOOL CheckCrossRefItem(DownloadHints* pHints);
+ FX_BOOL CheckTrailer(DownloadHints* pHints);
+ FX_BOOL CheckRoot(DownloadHints* pHints);
+ FX_BOOL CheckInfo(DownloadHints* pHints);
+ FX_BOOL CheckPages(DownloadHints* pHints);
+ FX_BOOL CheckPage(DownloadHints* pHints);
+ FX_BOOL CheckResources(DownloadHints* pHints);
+ FX_BOOL CheckAnnots(DownloadHints* pHints);
+ FX_BOOL CheckAcroForm(DownloadHints* pHints);
+ FX_BOOL CheckAcroFormSubObject(DownloadHints* pHints);
+ FX_BOOL CheckTrailerAppend(DownloadHints* pHints);
+ FX_BOOL CheckPageStatus(DownloadHints* pHints);
+ FX_BOOL CheckAllCrossRefStream(DownloadHints* pHints);
+
+ int32_t CheckCrossRefStream(DownloadHints* pHints, FX_FILESIZE& xref_offset);
FX_BOOL IsLinearizedFile(uint8_t* pData, uint32_t dwLen);
void SetStartOffset(FX_FILESIZE dwOffset);
FX_BOOL GetNextToken(CFX_ByteString& token);
@@ -121,41 +158,39 @@ class CPDF_DataAvail final : public IPDF_DataAvail {
uint32_t objnum,
CPDF_IndirectObjectHolder* pObjList = nullptr);
CPDF_Object* GetObject(uint32_t objnum,
- IPDF_DataAvail::DownloadHints* pHints,
+ DownloadHints* pHints,
FX_BOOL* pExistInFile);
FX_BOOL GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages);
FX_BOOL PreparePageItem();
- FX_BOOL LoadPages(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL LoadAllXref(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL LoadAllFile(IPDF_DataAvail::DownloadHints* pHints);
- DocAvailStatus CheckLinearizedData(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckPageAnnots(int iPage, IPDF_DataAvail::DownloadHints* pHints);
-
- DocAvailStatus CheckLinearizedFirstPage(
- int iPage,
- IPDF_DataAvail::DownloadHints* pHints);
+ FX_BOOL LoadPages(DownloadHints* pHints);
+ FX_BOOL LoadAllXref(DownloadHints* pHints);
+ FX_BOOL LoadAllFile(DownloadHints* pHints);
+ DocAvailStatus CheckLinearizedData(DownloadHints* pHints);
+ FX_BOOL CheckPageAnnots(int iPage, DownloadHints* pHints);
+
+ DocAvailStatus CheckLinearizedFirstPage(int iPage, DownloadHints* pHints);
FX_BOOL HaveResourceAncestor(CPDF_Dictionary* pDict);
- FX_BOOL CheckPage(int32_t iPage, IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL LoadDocPages(IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL LoadDocPage(int32_t iPage, IPDF_DataAvail::DownloadHints* pHints);
+ FX_BOOL CheckPage(int32_t iPage, DownloadHints* pHints);
+ FX_BOOL LoadDocPages(DownloadHints* pHints);
+ FX_BOOL LoadDocPage(int32_t iPage, DownloadHints* pHints);
FX_BOOL CheckPageNode(PageNode& pageNodes,
int32_t iPage,
int32_t& iCount,
- IPDF_DataAvail::DownloadHints* pHints,
+ DownloadHints* pHints,
int level);
FX_BOOL CheckUnkownPageNode(uint32_t dwPageNo,
PageNode* pPageNode,
- IPDF_DataAvail::DownloadHints* pHints);
+ DownloadHints* pHints);
FX_BOOL CheckArrayPageNode(uint32_t dwPageNo,
PageNode* pPageNode,
- IPDF_DataAvail::DownloadHints* pHints);
- FX_BOOL CheckPageCount(IPDF_DataAvail::DownloadHints* pHints);
+ DownloadHints* pHints);
+ FX_BOOL CheckPageCount(DownloadHints* pHints);
bool IsFirstCheck(int iPage);
void ResetFirstCheck(int iPage);
- FX_BOOL IsDataAvail(FX_FILESIZE offset,
- uint32_t size,
- IPDF_DataAvail::DownloadHints* pHints);
+ FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size, DownloadHints* pHints);
+ FileAvail* const m_pFileAvail;
+ IFX_FileRead* const m_pFileRead;
CPDF_Parser m_parser;
CPDF_SyntaxParser m_syntaxParser;
CPDF_Object* m_pRoot;
@@ -214,4 +249,4 @@ class CPDF_DataAvail final : public IPDF_DataAvail {
FX_BOOL m_bSupportHintTable;
};
-#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_DATA_AVAIL_H_
+#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DATA_AVAIL_H_
diff --git a/core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h b/core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h
deleted file mode 100644
index e34761ae78..0000000000
--- a/core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_IPDF_DATA_AVAIL_H_
-#define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_IPDF_DATA_AVAIL_H_
-
-#include "core/fxcrt/include/fx_stream.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_Document;
-class CPDF_Object;
-
-class IPDF_DataAvail {
- public:
- // Must match PDF_DATA_* definitions in public/fpdf_dataavail.h, but cannot
- // #include that header. fpdfsdk/fpdf_dataavail.cpp has static_asserts
- // to make sure the two sets of values match.
- enum DocAvailStatus {
- DataError = -1, // PDF_DATA_ERROR
- DataNotAvailable = 0, // PDF_DATA_NOTAVAIL
- DataAvailable = 1, // PDF_DATA_AVAIL
- };
-
- // Must match PDF_*LINEAR* definitions in public/fpdf_dataavail.h, but cannot
- // #include that header. fpdfsdk/fpdf_dataavail.cpp has static_asserts
- // to make sure the two sets of values match.
- enum DocLinearizationStatus {
- LinearizationUnknown = -1, // PDF_LINEARIZATION_UNKNOWN
- NotLinearized = 0, // PDF_NOT_LINEARIZED
- Linearized = 1, // PDF_LINEARIZED
- };
-
- // Must match PDF_FORM_* definitions in public/fpdf_dataavail.h, but cannot
- // #include that header. fpdfsdk/fpdf_dataavail.cpp has static_asserts
- // to make sure the two sets of values match.
- enum DocFormStatus {
- FormError = -1, // PDF_FORM_ERROR
- FormNotAvailable = 0, // PDF_FORM_NOTAVAIL
- FormAvailable = 1, // PDF_FORM_AVAIL
- FormNotExist = 2, // PDF_FORM_NOTEXIST
- };
-
- class FileAvail {
- public:
- virtual ~FileAvail();
- virtual FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) = 0;
- };
-
- class DownloadHints {
- public:
- virtual ~DownloadHints();
- virtual void AddSegment(FX_FILESIZE offset, uint32_t size) = 0;
- };
-
- static IPDF_DataAvail* Create(FileAvail* pFileAvail, IFX_FileRead* pFileRead);
- virtual ~IPDF_DataAvail();
-
- FileAvail* GetFileAvail() const { return m_pFileAvail; }
- IFX_FileRead* GetFileRead() const { return m_pFileRead; }
-
- virtual DocAvailStatus IsDocAvail(DownloadHints* pHints) = 0;
- virtual void SetDocument(CPDF_Document* pDoc) = 0;
- virtual DocAvailStatus IsPageAvail(int iPage, DownloadHints* pHints) = 0;
- virtual FX_BOOL IsLinearized() = 0;
- virtual DocFormStatus IsFormAvail(DownloadHints* pHints) = 0;
- virtual DocLinearizationStatus IsLinearizedPDF() = 0;
- virtual void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos,
- uint32_t* pSize) = 0;
-
- protected:
- IPDF_DataAvail(FileAvail* pFileAvail, IFX_FileRead* pFileRead);
-
- FileAvail* m_pFileAvail;
- IFX_FileRead* m_pFileRead;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_IPDF_DATA_AVAIL_H_