summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-25 12:15:28 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-25 12:15:28 -0800
commit02056fae83c8136195c8eb2a00c3606f600a8b6a (patch)
treed821b227fc58812888958c83afedbcd3210f8bb1 /core
parent33ea6308c45f1ea8ee7dd1f77852a255ef176301 (diff)
downloadpdfium-02056fae83c8136195c8eb2a00c3606f600a8b6a.tar.xz
Remove unused IsContentUsedElsewhere()
Then CPDF_Object::GetDirectType() becomes unused. Then GetIndirectType() becomes unused. Then PDFPARSE_TYPEONLY becomes unused. Then we can remove hideous casts of ints to ptrs. Also, PDFPARSE_NOSTREAM is unused. Then we can remove m_Flags from PARSE_CONTEXT. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1638493002 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_objects.h2
-rw-r--r--core/include/fpdfapi/fpdf_parser.h4
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp35
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp19
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp66
5 files changed, 10 insertions, 116 deletions
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index a53907b1f0..83b39e2986 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -53,7 +53,6 @@ class CPDF_Object {
CPDF_Object* CloneRef(CPDF_IndirectObjectHolder* pObjs) const;
CPDF_Object* GetDirect() const;
- int GetDirectType() const;
FX_BOOL IsModified() const { return FALSE; }
void Release();
@@ -568,7 +567,6 @@ class CPDF_IndirectObjectHolder {
explicit CPDF_IndirectObjectHolder(CPDF_Parser* pParser);
~CPDF_IndirectObjectHolder();
- int GetIndirectType(FX_DWORD objnum);
CPDF_Object* GetIndirectObject(FX_DWORD objnum, PARSE_CONTEXT* pContext);
FX_DWORD AddIndirectObject(CPDF_Object* pObj);
void ReleaseIndirectObject(FX_DWORD objnum);
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index ad4f1f9a9a..8b4472eb5d 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -194,7 +194,6 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
FX_DWORD objnum,
int& index,
int level = 0);
- FX_BOOL IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* pPageDict);
FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);
CPDF_DocPageData* GetValidatePageData();
CPDF_DocRenderData* GetValidateRenderData();
@@ -364,10 +363,7 @@ class CPDF_SyntaxParser {
FX_FILESIZE m_dwWordPos;
};
-#define PDFPARSE_TYPEONLY 1
-#define PDFPARSE_NOSTREAM 2
struct PARSE_CONTEXT {
- uint32_t m_Flags;
FX_FILESIZE m_DictStart;
FX_FILESIZE m_DictEnd;
FX_FILESIZE m_DataStart;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
index 6fc3440482..fa69d6e556 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
@@ -310,40 +310,17 @@ int CPDF_Document::RetrievePageCount() const {
return CountPages(pPages, &visited_pages);
}
-FX_BOOL CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum,
- CPDF_Dictionary* pThisPageDict) {
- for (int i = 0; i < m_PageList.GetSize(); i++) {
- CPDF_Dictionary* pPageDict = GetPage(i);
- if (pPageDict == pThisPageDict) {
- continue;
- }
- CPDF_Object* pContents =
- pPageDict ? pPageDict->GetElement("Contents") : NULL;
- if (!pContents) {
- continue;
- }
- if (pContents->GetDirectType() == PDFOBJ_ARRAY) {
- CPDF_Array* pArray = pContents->GetDirect()->AsArray();
- for (FX_DWORD j = 0; j < pArray->GetCount(); j++) {
- CPDF_Reference* pRef = ToReference(pArray->GetElement(j));
- if (pRef && pRef->GetRefObjNum() == objnum)
- return TRUE;
- }
- } else if (pContents->GetObjNum() == objnum) {
- return TRUE;
- }
- }
- return FALSE;
-}
FX_DWORD CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const {
if (!m_pParser) {
return (FX_DWORD)-1;
}
return m_pParser->GetPermissions(bCheckRevision);
}
+
FX_BOOL CPDF_Document::IsOwner() const {
return !m_pParser || m_pParser->IsOwner();
}
+
FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
auto it = m_IndirectObjs.find(objnum);
if (it != m_IndirectObjs.end()) {
@@ -357,13 +334,13 @@ FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
}
return m_pParser->IsFormStream(objnum, bForm);
}
+
void CPDF_Document::ClearPageData() {
- if (m_pDocPage) {
+ if (m_pDocPage)
CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this);
- }
}
+
void CPDF_Document::ClearRenderData() {
- if (m_pDocRender) {
+ if (m_pDocRender)
CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender);
- }
}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 681b6bae91..b925cf34e5 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -151,12 +151,6 @@ void CPDF_Object::SetString(const CFX_ByteString& str) {
}
ASSERT(FALSE);
}
-int CPDF_Object::GetDirectType() const {
- const CPDF_Reference* pRef = AsReference();
- if (!pRef)
- return m_Type;
- return pRef->m_pObjList->GetIndirectType(pRef->GetRefObjNum());
-}
FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const {
if (this == pOther)
return TRUE;
@@ -1059,19 +1053,6 @@ CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject(
m_IndirectObjs[objnum] = pObj;
return pObj;
}
-int CPDF_IndirectObjectHolder::GetIndirectType(FX_DWORD objnum) {
- auto it = m_IndirectObjs.find(objnum);
- if (it != m_IndirectObjs.end())
- return it->second->GetType();
-
- if (!m_pParser)
- return 0;
-
- PARSE_CONTEXT context;
- FXSYS_memset(&context, 0, sizeof(PARSE_CONTEXT));
- context.m_Flags = PDFPARSE_TYPEONLY;
- return (int)(uintptr_t)m_pParser->ParseIndirectObject(this, objnum, &context);
-}
FX_DWORD CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) {
if (pObj->m_ObjNum) {
return pObj->m_ObjNum;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 97c5a75082..0b93107e62 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2040,16 +2040,13 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
FX_BOOL bDecrypt) {
CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) {
- return NULL;
+ return nullptr;
}
FX_FILESIZE SavedPos = m_Pos;
- FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY);
bool bIsNumber;
CFX_ByteString word = GetNextWord(&bIsNumber);
if (word.GetLength() == 0) {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_INVALID;
- return NULL;
+ return nullptr;
}
if (bIsNumber) {
FX_FILESIZE SavedPos = m_Pos;
@@ -2058,29 +2055,19 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
CFX_ByteString nextword2 = GetNextWord(nullptr);
if (nextword2 == "R") {
FX_DWORD objnum = FXSYS_atoi(word);
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_REFERENCE;
return new CPDF_Reference(pObjList, objnum);
}
}
m_Pos = SavedPos;
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_NUMBER;
return new CPDF_Number(word);
}
if (word == "true" || word == "false") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_BOOLEAN;
return new CPDF_Boolean(word == "true");
}
if (word == "null") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_NULL;
return new CPDF_Null;
}
if (word == "(") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_STRING;
CFX_ByteString str = ReadString();
if (m_pCryptoHandler && bDecrypt) {
m_pCryptoHandler->Decrypt(objnum, gennum, str);
@@ -2088,8 +2075,6 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
return new CPDF_String(str, FALSE);
}
if (word == "<") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_STRING;
CFX_ByteString str = ReadHexString();
if (m_pCryptoHandler && bDecrypt) {
m_pCryptoHandler->Decrypt(objnum, gennum, str);
@@ -2097,8 +2082,6 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
return new CPDF_String(str, TRUE);
}
if (word == "[") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_ARRAY;
CPDF_Array* pArray = new CPDF_Array;
while (CPDF_Object* pObj =
GetObject(pObjList, objnum, gennum, nullptr, true)) {
@@ -2107,15 +2090,10 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
return pArray;
}
if (word[0] == '/') {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_NAME;
return new CPDF_Name(
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
}
if (word == "<<") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_DICTIONARY;
-
if (pContext)
pContext->m_DictStart = SavedPos;
@@ -2165,9 +2143,6 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
}
if (pContext) {
pContext->m_DictEnd = m_Pos;
- if (pContext->m_Flags & PDFPARSE_NOSTREAM) {
- return pDict.release();
- }
}
FX_FILESIZE SavedPos = m_Pos;
CFX_ByteString nextword = GetNextWord(nullptr);
@@ -2175,16 +2150,11 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
m_Pos = SavedPos;
return pDict.release();
}
-
return ReadStream(pDict.release(), pContext, objnum, gennum);
}
if (word == ">>") {
m_Pos = SavedPos;
- return nullptr;
}
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_INVALID;
-
return nullptr;
}
@@ -2195,15 +2165,12 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
PARSE_CONTEXT* pContext) {
CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) {
- return NULL;
+ return nullptr;
}
FX_FILESIZE SavedPos = m_Pos;
- FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY);
bool bIsNumber;
CFX_ByteString word = GetNextWord(&bIsNumber);
if (word.GetLength() == 0) {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_INVALID;
return nullptr;
}
if (bIsNumber) {
@@ -2212,46 +2179,31 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
if (bIsNumber) {
CFX_ByteString nextword2 = GetNextWord(nullptr);
if (nextword2 == "R") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_REFERENCE;
- FX_DWORD objnum = FXSYS_atoi(word);
- return new CPDF_Reference(pObjList, objnum);
+ return new CPDF_Reference(pObjList, FXSYS_atoi(word));
}
}
m_Pos = SavedPos;
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_NUMBER;
return new CPDF_Number(word);
}
if (word == "true" || word == "false") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_BOOLEAN;
return new CPDF_Boolean(word == "true");
}
if (word == "null") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_NULL;
return new CPDF_Null;
}
if (word == "(") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_STRING;
CFX_ByteString str = ReadString();
if (m_pCryptoHandler)
m_pCryptoHandler->Decrypt(objnum, gennum, str);
return new CPDF_String(str, FALSE);
}
if (word == "<") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_STRING;
CFX_ByteString str = ReadHexString();
if (m_pCryptoHandler)
m_pCryptoHandler->Decrypt(objnum, gennum, str);
return new CPDF_String(str, TRUE);
}
if (word == "[") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_ARRAY;
std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray(
new CPDF_Array);
while (CPDF_Object* pObj =
@@ -2261,14 +2213,10 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
return m_WordBuffer[0] == ']' ? pArray.release() : nullptr;
}
if (word[0] == '/') {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_NAME;
return new CPDF_Name(
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
}
if (word == "<<") {
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_DICTIONARY;
if (pContext)
pContext->m_DictStart = SavedPos;
@@ -2306,9 +2254,6 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
}
if (pContext) {
pContext->m_DictEnd = m_Pos;
- if (pContext->m_Flags & PDFPARSE_NOSTREAM) {
- return pDict.release();
- }
}
FX_FILESIZE SavedPos = m_Pos;
CFX_ByteString nextword = GetNextWord(nullptr);
@@ -2321,10 +2266,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
}
if (word == ">>") {
m_Pos = SavedPos;
- return nullptr;
}
- if (bTypeOnly)
- return (CPDF_Object*)PDFOBJ_INVALID;
return nullptr;
}