summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-11-04 14:16:22 -0800
committerLei Zhang <thestig@chromium.org>2015-11-04 14:16:22 -0800
commit79f5a32175293620abe456554e10efb7c3f4e7c6 (patch)
treea6d9de63ae975548dacf1620a91f92ee9a6fb0a0 /core
parent14e83759abec5eca9c4da0b4e8cd5969375a00f4 (diff)
downloadpdfium-79f5a32175293620abe456554e10efb7c3f4e7c6.tar.xz
Make checkdeps --resolve-dotdot succeed.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1419373005 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_parser.h35
-rw-r--r--core/include/fpdfapi/fpdf_render.h14
-rw-r--r--core/include/fxcodec/DEPS3
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp1
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp110
5 files changed, 97 insertions, 66 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index b7684e530a..d1f50038a7 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -7,7 +7,6 @@
#ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_
#define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_
-#include "../../../public/fpdf_dataavail.h"
#include "../../../third_party/base/nonstd_unique_ptr.h"
#include "../fxcrt/fx_system.h"
#include "fpdf_objects.h"
@@ -871,6 +870,34 @@ class IFX_DownloadHints {
class IPDF_DataAvail {
public:
+ // Must match PDF_DATA_* definitions in public/fpdf_dataavail.h, but cannot
+ // #include that header. fpdfsdk/src/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/src/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/src/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
+ };
+
static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail,
IFX_FileRead* pFileRead);
virtual ~IPDF_DataAvail() {}
@@ -878,12 +905,12 @@ class IPDF_DataAvail {
IFX_FileAvail* GetFileAvail() const { return m_pFileAvail; }
IFX_FileRead* GetFileRead() const { return m_pFileRead; }
- virtual int IsDocAvail(IFX_DownloadHints* pHints) = 0;
+ virtual DocAvailStatus IsDocAvail(IFX_DownloadHints* pHints) = 0;
virtual void SetDocument(CPDF_Document* pDoc) = 0;
virtual int IsPageAvail(int iPage, IFX_DownloadHints* pHints) = 0;
virtual FX_BOOL IsLinearized() = 0;
- virtual int IsFormAvail(IFX_DownloadHints* pHints) = 0;
- virtual int IsLinearizedPDF() = 0;
+ virtual DocFormStatus IsFormAvail(IFX_DownloadHints* pHints) = 0;
+ virtual DocLinearizationStatus IsLinearizedPDF() = 0;
virtual void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos,
FX_DWORD* pSize) = 0;
diff --git a/core/include/fpdfapi/fpdf_render.h b/core/include/fpdfapi/fpdf_render.h
index 3c1d95aa8a..7a5251e86e 100644
--- a/core/include/fpdfapi/fpdf_render.h
+++ b/core/include/fpdfapi/fpdf_render.h
@@ -8,7 +8,6 @@
#define CORE_INCLUDE_FPDFAPI_FPDF_RENDER_H_
#include "../../../third_party/base/nonstd_unique_ptr.h"
-#include "../../../public/fpdf_progressive.h"
#include "../fxge/fx_ge.h"
#include "fpdf_page.h"
@@ -134,13 +133,16 @@ class CPDF_RenderContext {
class CPDF_ProgressiveRenderer {
public:
- // Must match FDF_RENDER_* definitions in fpdf_progressive.h.
+ // Must match FDF_RENDER_* definitions in public/fpdf_progressive.h, but
+ // cannot #include that header. fpdfsdk/src/fpdf_progressive.cpp has
+ // static_asserts to make sure the two sets of values match.
enum Status {
- Ready = FPDF_RENDER_READER,
- ToBeContinued = FPDF_RENDER_TOBECOUNTINUED,
- Done = FPDF_RENDER_DONE,
- Failed = FPDF_RENDER_FAILED
+ Ready, // FPDF_RENDER_READER
+ ToBeContinued, // FPDF_RENDER_TOBECOUNTINUED
+ Done, // FPDF_RENDER_DONE
+ Failed // FPDF_RENDER_FAILED
};
+
static int ToFPDFStatus(Status status) { return static_cast<int>(status); }
CPDF_ProgressiveRenderer(CPDF_RenderContext* pContext,
diff --git a/core/include/fxcodec/DEPS b/core/include/fxcodec/DEPS
new file mode 100644
index 0000000000..548eb61a3b
--- /dev/null
+++ b/core/include/fxcodec/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ '+third_party/zlib_v128/zlib.h',
+]
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp
index 3da522da4e..bcade63831 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp
@@ -5,7 +5,6 @@
#include <cstring>
#include <string>
-#include "../../../../public/fpdfview.h"
#include "../../../../testing/fx_string_testhelpers.h"
#include "../../../include/fpdfapi/fpdf_parser.h"
#include "../../../include/fxcrt/fx_basic.h"
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index db0e8b19e1..7db97d25b3 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2678,19 +2678,15 @@ class CPDF_DataAvail final : public IPDF_DataAvail {
FX_BOOL bSupportHintTable);
~CPDF_DataAvail() override;
- int IsDocAvail(IFX_DownloadHints* pHints) override;
-
+ // IPDF_DataAvail:
+ DocAvailStatus IsDocAvail(IFX_DownloadHints* pHints) override;
void SetDocument(CPDF_Document* pDoc) override;
-
int IsPageAvail(int iPage, IFX_DownloadHints* pHints) override;
-
- int IsFormAvail(IFX_DownloadHints* pHints) override;
-
- int IsLinearizedPDF() override;
-
+ DocFormStatus IsFormAvail(IFX_DownloadHints* pHints) override;
+ DocLinearizationStatus IsLinearizedPDF() override;
FX_BOOL IsLinearized() override { return m_bLinearized; }
-
void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, FX_DWORD* pSize) override;
+
int GetPageCount() const;
CPDF_Dictionary* GetPage(int index);
@@ -3080,20 +3076,23 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array,
obj_array.Append(new_obj_array);
return IsObjectsAvail(obj_array, FALSE, pHints, ret_array);
}
-int CPDF_DataAvail::IsDocAvail(IFX_DownloadHints* pHints) {
+
+IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
+ IFX_DownloadHints* pHints) {
if (!m_dwFileLen && m_pFileRead) {
m_dwFileLen = (FX_DWORD)m_pFileRead->GetSize();
if (!m_dwFileLen) {
- return PDF_DATA_ERROR;
+ return DataError;
}
}
while (!m_bDocAvail) {
if (!CheckDocStatus(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
+
FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
m_objs_array.RemoveAll();
@@ -3644,24 +3643,24 @@ CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
m_syntaxParser.RestorePos(SavedPos);
return pObj;
}
-int CPDF_DataAvail::IsLinearizedPDF() {
+IPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() {
FX_DWORD req_size = 1024;
if (!m_pFileAvail->IsDataAvail(0, req_size)) {
- return PDF_LINEARIZATION_UNKNOWN;
+ return LinearizationUnknown;
}
if (!m_pFileRead) {
- return PDF_NOT_LINEARIZED;
+ return NotLinearized;
}
FX_FILESIZE dwSize = m_pFileRead->GetSize();
if (dwSize < (FX_FILESIZE)req_size) {
- return PDF_LINEARIZATION_UNKNOWN;
+ return LinearizationUnknown;
}
uint8_t buffer[1024];
m_pFileRead->ReadBlock(buffer, 0, req_size);
if (IsLinearizedFile(buffer, req_size)) {
- return PDF_LINEARIZED;
+ return Linearized;
}
- return PDF_NOT_LINEARIZED;
+ return NotLinearized;
}
FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) {
ScopedFileStream file(FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE));
@@ -4278,33 +4277,33 @@ FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) {
}
int CPDF_DataAvail::CheckLinearizedData(IFX_DownloadHints* pHints) {
if (m_bLinearedDataOK) {
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
if (!m_bMainXRefLoadTried) {
FX_SAFE_DWORD data_size = m_dwFileLen;
data_size -= m_dwLastXRefOffset;
if (!data_size.IsValid()) {
- return PDF_DATA_ERROR;
+ return DataError;
}
if (!m_pFileAvail->IsDataAvail(m_dwLastXRefOffset,
data_size.ValueOrDie())) {
pHints->AddSegment(m_dwLastXRefOffset, data_size.ValueOrDie());
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
FX_DWORD dwRet = (m_pDocument->GetParser())->LoadLinearizedMainXRefTable();
m_bMainXRefLoadTried = TRUE;
if (dwRet != PDFPARSE_ERROR_SUCCESS) {
- return PDF_DATA_ERROR;
+ return DataError;
}
if (!PreparePageItem()) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bMainXRefLoadedOK = TRUE;
m_bLinearedDataOK = TRUE;
}
- return m_bLinearedDataOK ? PDF_DATA_AVAIL : PDF_DATA_NOTAVAIL;
+ return m_bLinearedDataOK ? DataAvailable : DataNotAvailable;
}
FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage,
IFX_DownloadHints* pHints) {
@@ -4372,7 +4371,7 @@ FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) {
}
int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
if (!m_pDocument) {
- return PDF_DATA_ERROR;
+ return DataError;
}
if (IsFirstCheck(iPage)) {
m_bCurPageDictLoadOK = FALSE;
@@ -4383,52 +4382,52 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_objnum_array.RemoveAll();
}
if (m_pagesLoadState.find(iPage) != m_pagesLoadState.end()) {
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
if (m_bLinearized) {
if ((FX_DWORD)iPage == m_dwFirstPageNo) {
m_pagesLoadState.insert(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
int32_t nResult = CheckLinearizedData(pHints);
- if (nResult != PDF_DATA_AVAIL) {
+ if (nResult != DataAvailable) {
return nResult;
}
if (m_pHintTables) {
nResult = m_pHintTables->CheckPage(iPage, pHints);
- if (nResult != PDF_DATA_AVAIL)
+ if (nResult != DataAvailable)
return nResult;
m_pagesLoadState.insert(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
if (m_bMainXRefLoadedOK) {
if (m_bTotalLoadPageTree) {
if (!LoadPages(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
} else {
if (!m_bCurPageDictLoadOK && !CheckPage(iPage, pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
} else {
if (!LoadAllFile(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
((CPDF_Parser*)m_pDocument->GetParser())->RebuildCrossRef();
ResetFirstCheck(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
} else {
if (!m_bTotalLoadPageTree) {
if (!m_bCurPageDictLoadOK && !CheckPage(iPage, pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
}
if (m_bHaveAcroForm && !m_bAcroFormLoad) {
if (!CheckAcroFormSubObject(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bAcroFormLoad = TRUE;
}
@@ -4439,7 +4438,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_pPageDict = m_pDocument->GetPage(iPage);
if (!m_pPageDict) {
ResetFirstCheck(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
CFX_PtrArray obj_array;
obj_array.Add(m_pPageDict);
@@ -4459,14 +4458,14 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_bPageLoadedOK = TRUE;
} else {
m_objs_array.Append(new_objs_array);
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
}
if (m_bPageLoadedOK) {
if (!m_bAnnotsLoad) {
if (!CheckPageAnnots(iPage, pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bAnnotsLoad = TRUE;
}
@@ -4482,7 +4481,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
if (m_bNeedDownLoadResource) {
FX_BOOL bRet = CheckResources(pHints);
if (!bRet) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bNeedDownLoadResource = FALSE;
}
@@ -4491,7 +4490,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_bCurPageDictLoadOK = FALSE;
ResetFirstCheck(iPage);
m_pagesLoadState.insert(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
@@ -4557,21 +4556,22 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) {
}
return m_pDocument->GetPage(index);
}
-int CPDF_DataAvail::IsFormAvail(IFX_DownloadHints* pHints) {
+IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
+ IFX_DownloadHints* pHints) {
if (!m_pDocument) {
- return PDF_FORM_AVAIL;
+ return FormAvailable;
}
if (!m_bLinearizedFormParamLoad) {
CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
if (!pRoot) {
- return PDF_FORM_AVAIL;
+ return FormAvailable;
}
CPDF_Object* pAcroForm = pRoot->GetElement(FX_BSTRC("AcroForm"));
if (!pAcroForm) {
- return PDF_FORM_NOTEXIST;
+ return FormNotExist;
}
if (!CheckLinearizedData(pHints)) {
- return PDF_FORM_NOTAVAIL;
+ return FormNotAvailable;
}
if (!m_objs_array.GetSize()) {
m_objs_array.Add(pAcroForm->GetDict());
@@ -4583,9 +4583,9 @@ int CPDF_DataAvail::IsFormAvail(IFX_DownloadHints* pHints) {
m_objs_array.RemoveAll();
if (!bRet) {
m_objs_array.Append(new_objs_array);
- return PDF_FORM_NOTAVAIL;
+ return FormNotAvailable;
}
- return PDF_FORM_AVAIL;
+ return FormAvailable;
}
void CPDF_SortObjNumArray::AddObjNum(FX_DWORD dwObjNum) {
int32_t iNext = 0;
@@ -4869,17 +4869,17 @@ FX_BOOL CPDF_HintTables::GetPagePos(int index,
}
int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) {
if (!m_pLinearizedDict || !pHints)
- return PDF_DATA_ERROR;
+ return IPDF_DataAvail::DataError;
CPDF_Object* pFirstAvailPage =
m_pLinearizedDict->GetElementValue(FX_BSTRC("P"));
int nFirstAvailPage = pFirstAvailPage ? pFirstAvailPage->GetInteger() : 0;
if (index == nFirstAvailPage)
- return PDF_DATA_AVAIL;
+ return IPDF_DataAvail::DataAvailable;
FX_DWORD dwLength = GetItemLength(index, m_szPageOffsetArray);
if (!dwLength ||
!m_pDataAvail->IsDataAvail(m_szPageOffsetArray[index], dwLength,
pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return IPDF_DataAvail::DataNotAvailable;
}
// Download data of shared objects in the page.
FX_DWORD offset = 0;
@@ -4890,7 +4890,7 @@ int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) {
m_pLinearizedDict->GetElementValue(FX_BSTRC("O"));
int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1;
if (nFirstPageObjNum < 0)
- return FALSE;
+ return FALSE; // TODO(thestig): Fix this and the return type.
FX_DWORD dwIndex = 0;
FX_DWORD dwObjNum = 0;
for (int j = 0; j < m_dwNSharedObjsArray[index]; ++j) {
@@ -4904,10 +4904,10 @@ int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) {
if (!dwLength ||
!m_pDataAvail->IsDataAvail(m_szSharedObjOffsetArray[dwIndex], dwLength,
pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return IPDF_DataAvail::DataNotAvailable;
}
}
- return PDF_DATA_AVAIL;
+ return IPDF_DataAvail::DataAvailable;
}
FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
if (!pHintStream || !m_pLinearizedDict)