OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../include/fpdfapi/fpdf_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 | 9 |
10 CPDF_Document::CPDF_Document(CPDF_Parser* pParser) | 10 CPDF_Document::CPDF_Document(CPDF_Parser* pParser) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 } else { | 129 } else { |
130 int nPages = pKid->GetInteger(FX_BSTRC("Count")); | 130 int nPages = pKid->GetInteger(FX_BSTRC("Count")); |
131 if (nPagesToGo < nPages) { | 131 if (nPagesToGo < nPages) { |
132 return _FindPDFPage(pKid, iPage, nPagesToGo, level + 1); | 132 return _FindPDFPage(pKid, iPage, nPagesToGo, level + 1); |
133 } | 133 } |
134 nPagesToGo -= nPages; | 134 nPagesToGo -= nPages; |
135 } | 135 } |
136 } | 136 } |
137 return NULL; | 137 return NULL; |
138 } | 138 } |
139 | |
139 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { | 140 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { |
140 if (iPage < 0 || iPage >= m_PageList.GetSize()) { | 141 if (iPage < 0 || iPage >= m_PageList.GetSize()) |
141 return NULL; | 142 return nullptr; |
142 } | 143 |
143 if (m_bLinearized && (iPage == (int)m_dwFirstPageNo)) { | 144 if (m_bLinearized && (iPage == (int)m_dwFirstPageNo)) { |
144 CPDF_Object* pObj = GetIndirectObject(m_dwFirstPageObjNum); | 145 CPDF_Object* pObj = GetIndirectObject(m_dwFirstPageObjNum); |
145 if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) { | 146 if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) { |
146 return (CPDF_Dictionary*)pObj; | 147 return (CPDF_Dictionary*)pObj; |
147 } | 148 } |
148 } | 149 } |
150 | |
149 int objnum = m_PageList.GetAt(iPage); | 151 int objnum = m_PageList.GetAt(iPage); |
150 if (objnum) { | 152 if (objnum) { |
151 CPDF_Object* pObj = GetIndirectObject(objnum); | 153 CPDF_Object* pObj = GetIndirectObject(objnum); |
152 ASSERT(pObj->GetType() == PDFOBJ_DICTIONARY); | 154 if (pObj->GetType() != PDFOBJ_DICTIONARY) |
155 return nullptr; | |
Tom Sepez
2015/09/03 17:00:56
Do we want to continue with the alternate paths at
Lei Zhang
2015/09/03 20:58:34
That's probably better. Done. I made this block th
| |
153 return (CPDF_Dictionary*)pObj; | 156 return (CPDF_Dictionary*)pObj; |
154 } | 157 } |
158 | |
155 CPDF_Dictionary* pRoot = GetRoot(); | 159 CPDF_Dictionary* pRoot = GetRoot(); |
156 if (pRoot == NULL) { | 160 if (!pRoot) |
157 return NULL; | 161 return nullptr; |
158 } | 162 |
159 CPDF_Dictionary* pPages = pRoot->GetDict(FX_BSTRC("Pages")); | 163 CPDF_Dictionary* pPages = pRoot->GetDict(FX_BSTRC("Pages")); |
160 if (pPages == NULL) { | 164 if (!pPages) |
161 return NULL; | 165 return nullptr; |
162 } | 166 |
163 CPDF_Dictionary* pPage = _FindPDFPage(pPages, iPage, iPage, 0); | 167 CPDF_Dictionary* pPage = _FindPDFPage(pPages, iPage, iPage, 0); |
164 if (pPage == NULL) { | 168 if (!pPage) |
165 return NULL; | 169 return nullptr; |
166 } | 170 |
167 m_PageList.SetAt(iPage, pPage->GetObjNum()); | 171 m_PageList.SetAt(iPage, pPage->GetObjNum()); |
168 return pPage; | 172 return pPage; |
169 } | 173 } |
174 | |
170 int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode, | 175 int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode, |
171 FX_DWORD& skip_count, | 176 FX_DWORD& skip_count, |
172 FX_DWORD objnum, | 177 FX_DWORD objnum, |
173 int& index, | 178 int& index, |
174 int level) { | 179 int level) { |
175 if (pNode->KeyExist(FX_BSTRC("Kids"))) { | 180 if (pNode->KeyExist(FX_BSTRC("Kids"))) { |
176 CPDF_Array* pKidList = pNode->GetArray(FX_BSTRC("Kids")); | 181 CPDF_Array* pKidList = pNode->GetArray(FX_BSTRC("Kids")); |
177 if (pKidList == NULL) { | 182 if (pKidList == NULL) { |
178 return -1; | 183 return -1; |
179 } | 184 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 void CPDF_Document::ClearPageData() { | 356 void CPDF_Document::ClearPageData() { |
352 if (m_pDocPage) { | 357 if (m_pDocPage) { |
353 CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this); | 358 CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this); |
354 } | 359 } |
355 } | 360 } |
356 void CPDF_Document::ClearRenderData() { | 361 void CPDF_Document::ClearRenderData() { |
357 if (m_pDocRender) { | 362 if (m_pDocRender) { |
358 CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender); | 363 CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender); |
359 } | 364 } |
360 } | 365 } |
OLD | NEW |