summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-14 10:44:01 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-14 10:44:01 -0700
commit979070b3ef34aa36ef14e2a09260b057e0265916 (patch)
tree2d7869510851c420ca6d846506bf7cff7f20be19
parent756d37943415ca15d491b79ba78012225a06db76 (diff)
downloadpdfium-979070b3ef34aa36ef14e2a09260b057e0265916.tar.xz
Get rid of IPDF_DataAvail.
BUG=pdfium:520 Review-Url: https://codereview.chromium.org/2061973002
-rw-r--r--BUILD.gn3
-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
-rw-r--r--fpdfsdk/fpdf_dataavail.cpp85
-rw-r--r--pdfium.gyp15
8 files changed, 220 insertions, 281 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 59215c1dd2..98027d0492 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -413,7 +413,6 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp",
"core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h",
"core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp",
- "core/fpdfapi/fpdf_parser/cpdf_data_avail.h",
"core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp",
"core/fpdfapi/fpdf_parser/cpdf_document.cpp",
"core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp",
@@ -439,6 +438,7 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_parser/fpdf_parser_utility.h",
"core/fpdfapi/fpdf_parser/include/cfdf_document.h",
"core/fpdfapi/fpdf_parser/include/cpdf_array.h",
+ "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h",
"core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h",
"core/fpdfapi/fpdf_parser/include/cpdf_document.h",
"core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h",
@@ -452,7 +452,6 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h",
"core/fpdfapi/fpdf_parser/include/cpdf_string.h",
"core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h",
- "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h",
"core/fpdfapi/fpdf_render/cpdf_pagerendercache.h",
"core/fpdfapi/fpdf_render/fpdf_render.cpp",
"core/fpdfapi/fpdf_render/fpdf_render_cache.cpp",
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_
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index 878271efc9..b7b47f86a1 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -6,43 +6,45 @@
#include "public/fpdf_dataavail.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "public/fpdf_formfill.h"
// These checks are here because core/ and public/ cannot depend on each other.
-static_assert(IPDF_DataAvail::DataError == PDF_DATA_ERROR,
- "IPDF_DataAvail::DataError value mismatch");
-static_assert(IPDF_DataAvail::DataNotAvailable == PDF_DATA_NOTAVAIL,
- "IPDF_DataAvail::DataNotAvailable value mismatch");
-static_assert(IPDF_DataAvail::DataAvailable == PDF_DATA_AVAIL,
- "IPDF_DataAvail::DataAvailable value mismatch");
-
-static_assert(IPDF_DataAvail::LinearizationUnknown == PDF_LINEARIZATION_UNKNOWN,
- "IPDF_DataAvail::LinearizationUnknown value mismatch");
-static_assert(IPDF_DataAvail::NotLinearized == PDF_NOT_LINEARIZED,
- "IPDF_DataAvail::NotLinearized value mismatch");
-static_assert(IPDF_DataAvail::Linearized == PDF_LINEARIZED,
- "IPDF_DataAvail::Linearized value mismatch");
-
-static_assert(IPDF_DataAvail::FormError == PDF_FORM_ERROR,
- "IPDF_DataAvail::FormError value mismatch");
-static_assert(IPDF_DataAvail::FormNotAvailable == PDF_FORM_NOTAVAIL,
- "IPDF_DataAvail::FormNotAvailable value mismatch");
-static_assert(IPDF_DataAvail::FormAvailable == PDF_FORM_AVAIL,
- "IPDF_DataAvail::FormAvailable value mismatch");
-static_assert(IPDF_DataAvail::FormNotExist == PDF_FORM_NOTEXIST,
- "IPDF_DataAvail::FormNotExist value mismatch");
-
-class CFPDF_FileAvailWrap : public IPDF_DataAvail::FileAvail {
+static_assert(CPDF_DataAvail::DataError == PDF_DATA_ERROR,
+ "CPDF_DataAvail::DataError value mismatch");
+static_assert(CPDF_DataAvail::DataNotAvailable == PDF_DATA_NOTAVAIL,
+ "CPDF_DataAvail::DataNotAvailable value mismatch");
+static_assert(CPDF_DataAvail::DataAvailable == PDF_DATA_AVAIL,
+ "CPDF_DataAvail::DataAvailable value mismatch");
+
+static_assert(CPDF_DataAvail::LinearizationUnknown == PDF_LINEARIZATION_UNKNOWN,
+ "CPDF_DataAvail::LinearizationUnknown value mismatch");
+static_assert(CPDF_DataAvail::NotLinearized == PDF_NOT_LINEARIZED,
+ "CPDF_DataAvail::NotLinearized value mismatch");
+static_assert(CPDF_DataAvail::Linearized == PDF_LINEARIZED,
+ "CPDF_DataAvail::Linearized value mismatch");
+
+static_assert(CPDF_DataAvail::FormError == PDF_FORM_ERROR,
+ "CPDF_DataAvail::FormError value mismatch");
+static_assert(CPDF_DataAvail::FormNotAvailable == PDF_FORM_NOTAVAIL,
+ "CPDF_DataAvail::FormNotAvailable value mismatch");
+static_assert(CPDF_DataAvail::FormAvailable == PDF_FORM_AVAIL,
+ "CPDF_DataAvail::FormAvailable value mismatch");
+static_assert(CPDF_DataAvail::FormNotExist == PDF_FORM_NOTEXIST,
+ "CPDF_DataAvail::FormNotExist value mismatch");
+
+namespace {
+
+class CFPDF_FileAvailWrap : public CPDF_DataAvail::FileAvail {
public:
CFPDF_FileAvailWrap() { m_pfileAvail = nullptr; }
~CFPDF_FileAvailWrap() override {}
void Set(FX_FILEAVAIL* pfileAvail) { m_pfileAvail = pfileAvail; }
- // IPDF_DataAvail::FileAvail:
+ // CPDF_DataAvail::FileAvail:
FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) override {
return m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size);
}
@@ -72,7 +74,7 @@ class CFPDF_FileAccessWrap : public IFX_FileRead {
FPDF_FILEACCESS* m_pFileAccess;
};
-class CFPDF_DownloadHintsWrap : public IPDF_DataAvail::DownloadHints {
+class CFPDF_DownloadHintsWrap : public CPDF_DataAvail::DownloadHints {
public:
explicit CFPDF_DownloadHintsWrap(FX_DOWNLOADHINTS* pDownloadHints) {
m_pDownloadHints = pDownloadHints;
@@ -91,22 +93,27 @@ class CFPDF_DownloadHintsWrap : public IPDF_DataAvail::DownloadHints {
class CFPDF_DataAvail {
public:
- CFPDF_DataAvail() { m_pDataAvail = nullptr; }
+ CFPDF_DataAvail() {}
+ ~CFPDF_DataAvail() {}
- ~CFPDF_DataAvail() { delete m_pDataAvail; }
-
- IPDF_DataAvail* m_pDataAvail;
+ std::unique_ptr<CPDF_DataAvail> m_pDataAvail;
CFPDF_FileAvailWrap m_FileAvail;
CFPDF_FileAccessWrap m_FileRead;
};
+CFPDF_DataAvail* CFPDFDataAvailFromFPDFAvail(FPDF_AVAIL avail) {
+ return static_cast<CFPDF_DataAvail*>(avail);
+}
+
+} // namespace
+
DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail,
FPDF_FILEACCESS* file) {
CFPDF_DataAvail* pAvail = new CFPDF_DataAvail;
pAvail->m_FileAvail.Set(file_avail);
pAvail->m_FileRead.Set(file);
- pAvail->m_pDataAvail =
- IPDF_DataAvail::Create(&pAvail->m_FileAvail, &pAvail->m_FileRead);
+ pAvail->m_pDataAvail.reset(
+ new CPDF_DataAvail(&pAvail->m_FileAvail, &pAvail->m_FileRead, TRUE));
return pAvail;
}
@@ -119,7 +126,8 @@ DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail,
if (!avail || !hints)
return PDF_DATA_ERROR;
CFPDF_DownloadHintsWrap hints_wrap(hints);
- return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap);
+ return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsDocAvail(
+ &hints_wrap);
}
DLLEXPORT FPDF_DOCUMENT STDCALL
@@ -153,8 +161,8 @@ DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail,
if (!avail || !hints)
return PDF_DATA_ERROR;
CFPDF_DownloadHintsWrap hints_wrap(hints);
- return ((CFPDF_DataAvail*)avail)
- ->m_pDataAvail->IsPageAvail(page_index, &hints_wrap);
+ return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsPageAvail(
+ page_index, &hints_wrap);
}
DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail,
@@ -162,11 +170,12 @@ DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail,
if (!avail || !hints)
return PDF_FORM_ERROR;
CFPDF_DownloadHintsWrap hints_wrap(hints);
- return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap);
+ return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail(
+ &hints_wrap);
}
DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) {
if (!avail)
return PDF_LINEARIZATION_UNKNOWN;
- return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF();
+ return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF();
}
diff --git a/pdfium.gyp b/pdfium.gyp
index d561b9de41..cebeb73ce4 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -263,11 +263,9 @@
'type': 'static_library',
'sources': [
'core/fpdfapi/cpdf_modulemgr.cpp',
- 'core/fpdfapi/fpdf_cmaps/cmap_int.h',
'core/fpdfapi/fpdf_cmaps/CNS1/Adobe-CNS1-UCS2_5.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/B5pc-H_0.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/B5pc-V_0.cpp',
- 'core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/CNS-EUC-H_0.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/CNS-EUC-V_0.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/ETen-B5-H_0.cpp',
@@ -279,9 +277,8 @@
'core/fpdfapi/fpdf_cmaps/CNS1/UniCNS-UCS2-H_3.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/UniCNS-UCS2-V_3.cpp',
'core/fpdfapi/fpdf_cmaps/CNS1/UniCNS-UTF16-H_0.cpp',
- 'core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp',
+ 'core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp',
'core/fpdfapi/fpdf_cmaps/GB1/Adobe-GB1-UCS2_5.cpp',
- 'core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp',
'core/fpdfapi/fpdf_cmaps/GB1/GB-EUC-H_0.cpp',
'core/fpdfapi/fpdf_cmaps/GB1/GB-EUC-V_0.cpp',
'core/fpdfapi/fpdf_cmaps/GB1/GBK-EUC-H_2.cpp',
@@ -294,6 +291,7 @@
'core/fpdfapi/fpdf_cmaps/GB1/GBpc-EUC-V_0.cpp',
'core/fpdfapi/fpdf_cmaps/GB1/UniGB-UCS2-H_4.cpp',
'core/fpdfapi/fpdf_cmaps/GB1/UniGB-UCS2-V_4.cpp',
+ 'core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/83pv-RKSJ-H_1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/90ms-RKSJ-H_2.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/90ms-RKSJ-V_2.cpp',
@@ -303,7 +301,6 @@
'core/fpdfapi/fpdf_cmaps/Japan1/Add-RKSJ-H_1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/Add-RKSJ-V_1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/Adobe-Japan1-UCS2_4.cpp',
- 'core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/EUC-H_1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/EUC-V_1.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/Ext-RKSJ-H_2.cpp',
@@ -314,8 +311,8 @@
'core/fpdfapi/fpdf_cmaps/Japan1/UniJIS-UCS2-H_4.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/UniJIS-UCS2-V_4.cpp',
'core/fpdfapi/fpdf_cmaps/Japan1/V_1.cpp',
+ 'core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp',
'core/fpdfapi/fpdf_cmaps/Korea1/Adobe-Korea1-UCS2_2.cpp',
- 'core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp',
'core/fpdfapi/fpdf_cmaps/Korea1/KSC-EUC-H_0.cpp',
'core/fpdfapi/fpdf_cmaps/Korea1/KSC-EUC-V_0.cpp',
'core/fpdfapi/fpdf_cmaps/Korea1/KSCms-UHC-HW-H_1.cpp',
@@ -326,6 +323,9 @@
'core/fpdfapi/fpdf_cmaps/Korea1/UniKS-UCS2-H_1.cpp',
'core/fpdfapi/fpdf_cmaps/Korea1/UniKS-UCS2-V_1.cpp',
'core/fpdfapi/fpdf_cmaps/Korea1/UniKS-UTF16-H_0.cpp',
+ 'core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp',
+ 'core/fpdfapi/fpdf_cmaps/cmap_int.h',
+ 'core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp',
'core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp',
'core/fpdfapi/fpdf_edit/editint.h',
'core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp',
@@ -429,7 +429,6 @@
'core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp',
'core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h',
'core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp',
- 'core/fpdfapi/fpdf_parser/cpdf_data_avail.h',
'core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp',
'core/fpdfapi/fpdf_parser/cpdf_document.cpp',
'core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp',
@@ -455,6 +454,7 @@
'core/fpdfapi/fpdf_parser/fpdf_parser_utility.h',
'core/fpdfapi/fpdf_parser/include/cfdf_document.h',
'core/fpdfapi/fpdf_parser/include/cpdf_array.h',
+ 'core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h',
'core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h',
'core/fpdfapi/fpdf_parser/include/cpdf_document.h',
'core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h',
@@ -468,7 +468,6 @@
'core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h',
'core/fpdfapi/fpdf_parser/include/cpdf_string.h',
'core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h',
- 'core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h',
'core/fpdfapi/fpdf_render/cpdf_pagerendercache.h',
'core/fpdfapi/fpdf_render/fpdf_render.cpp',
'core/fpdfapi/fpdf_render/fpdf_render_cache.cpp',