summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-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
3 files changed, 10 insertions, 110 deletions
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;
}