summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdf_flatten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/fpdf_flatten.cpp')
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index 36b8319dca..9aee35f760 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -35,17 +35,14 @@ FX_BOOL IsValiableRect(CPDF_Rect rect, CPDF_Rect rcPage) {
return TRUE;
}
-FX_BOOL GetContentsRect(CPDF_Document* pDoc,
- CPDF_Dictionary* pDict,
- CPDF_RectArray* pRectArray) {
- CPDF_Page* pPDFPage = new CPDF_Page;
+void GetContentsRect(CPDF_Document* pDoc,
+ CPDF_Dictionary* pDict,
+ CPDF_RectArray* pRectArray) {
+ std::unique_ptr<CPDF_Page> pPDFPage(new CPDF_Page);
pPDFPage->Load(pDoc, pDict, FALSE);
pPDFPage->ParseContent(nullptr);
- FX_POSITION pos = pPDFPage->GetPageObjectList()->GetHeadPosition();
- while (pos) {
- CPDF_PageObject* pPageObject =
- pPDFPage->GetPageObjectList()->GetNextObject(pos);
+ for (auto& pPageObject : *pPDFPage->GetPageObjectList()) {
if (!pPageObject)
continue;
@@ -54,14 +51,9 @@ FX_BOOL GetContentsRect(CPDF_Document* pDoc,
rc.right = pPageObject->m_Right;
rc.bottom = pPageObject->m_Bottom;
rc.top = pPageObject->m_Top;
-
- if (IsValiableRect(rc, pDict->GetRectBy("MediaBox"))) {
+ if (IsValiableRect(rc, pDict->GetRectBy("MediaBox")))
pRectArray->Add(rc);
- }
}
-
- delete pPDFPage;
- return TRUE;
}
void ParserStream(CPDF_Dictionary* pPageDic,