summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_document.cpp46
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_parser.cpp6
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_document.h5
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_parser.h4
4 files changed, 28 insertions, 33 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index 7f69295675..bf1f93f887 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -496,54 +496,46 @@ CPDF_Document::~CPDF_Document() {
CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
}
-void CPDF_Document::LoadDoc() {
+void CPDF_Document::LoadDocInternal() {
m_LastObjNum = m_pParser->GetLastObjNum();
+
CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum());
- if (!pRootObj) {
+ if (!pRootObj)
return;
- }
+
m_pRootDict = pRootObj->GetDict();
- if (!m_pRootDict) {
+ if (!m_pRootDict)
return;
- }
+
CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum());
- if (pInfoObj) {
+ if (pInfoObj)
m_pInfoDict = pInfoObj->GetDict();
- }
- CPDF_Array* pIDArray = m_pParser->GetIDArray();
- if (pIDArray) {
+ if (CPDF_Array* pIDArray = m_pParser->GetIDArray()) {
m_ID1 = pIDArray->GetStringAt(0);
m_ID2 = pIDArray->GetStringAt(1);
}
+}
+
+void CPDF_Document::LoadDoc() {
+ LoadDocInternal();
m_PageList.SetSize(RetrievePageCount());
}
-void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) {
+void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) {
m_bLinearized = true;
- m_LastObjNum = m_pParser->GetLastObjNum();
- CPDF_Object* pIndirectObj = GetIndirectObject(m_pParser->GetRootObjNum());
- m_pRootDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
- if (!m_pRootDict) {
- return;
- }
- pIndirectObj = GetIndirectObject(m_pParser->GetInfoObjNum());
- m_pInfoDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
- CPDF_Array* pIDArray = m_pParser->GetIDArray();
- if (pIDArray) {
- m_ID1 = pIDArray->GetStringAt(0);
- m_ID2 = pIDArray->GetStringAt(1);
- }
+ LoadDocInternal();
+
uint32_t dwPageCount = 0;
- CPDF_Object* pCount = pLinearized->GetObjectBy("N");
+ CPDF_Object* pCount = pLinearizationParams->GetObjectBy("N");
if (ToNumber(pCount))
dwPageCount = pCount->GetInteger();
-
m_PageList.SetSize(dwPageCount);
- CPDF_Object* pNo = pLinearized->GetObjectBy("P");
+
+ CPDF_Object* pNo = pLinearizationParams->GetObjectBy("P");
if (ToNumber(pNo))
m_iFirstPageNo = pNo->GetInteger();
- CPDF_Object* pObjNum = pLinearized->GetObjectBy("O");
+ CPDF_Object* pObjNum = pLinearizationParams->GetObjectBy("O");
if (ToNumber(pObjNum))
m_dwFirstPageObjNum = pObjNum->GetInteger();
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index 7bcbf392d6..b2f1a4be3f 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -1545,7 +1545,7 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess,
return FALSE;
}
-CPDF_Parser::Error CPDF_Parser::StartAsyncParse(
+CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
IFX_FileRead* pFileAccess,
std::unique_ptr<CPDF_Document> pDocument) {
CloseParser();
@@ -1589,7 +1589,7 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(
if (eRet != SUCCESS)
return eRet;
- m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
+ m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict());
if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) {
if (bXRefRebuilt)
return FORMAT_ERROR;
@@ -1602,7 +1602,7 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(
if (eRet != SUCCESS)
return eRet;
- m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
+ m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict());
if (!m_pDocument->GetRoot())
return FORMAT_ERROR;
}
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index 3cece1c0a8..4a12ea97dc 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -84,7 +84,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream);
void LoadDoc();
- void LoadAsynDoc(CPDF_Dictionary* pLinearized);
+ void LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams);
void LoadPages();
// Editing methods.
@@ -139,6 +139,9 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
std::unique_ptr<JBig2_DocumentContext> m_pCodecContext;
std::unique_ptr<CPDF_LinkList> m_pLinksContext;
+
+ private:
+ void LoadDocInternal();
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
index 3ad3b867df..29807b9060 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
@@ -40,8 +40,8 @@ class CPDF_Parser {
Error StartParse(IFX_FileRead* pFile,
std::unique_ptr<CPDF_Document> pDocument);
- Error StartAsyncParse(IFX_FileRead* pFile,
- std::unique_ptr<CPDF_Document> pDocument);
+ Error StartLinearizedParse(IFX_FileRead* pFile,
+ std::unique_ptr<CPDF_Document> pDocument);
void SetPassword(const FX_CHAR* password) { m_Password = password; }
CFX_ByteString GetPassword() { return m_Password; }