summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-10-30 20:19:33 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 20:19:33 +0000
commit341ec6256457c53d50f2d0a0667e61041d4d89be (patch)
tree0bf442a0d2fb91ad2189550d68421f22d480eb75 /fpdfsdk
parenta759dcedcb9b95492b4d2a388d98019f994f59bd (diff)
downloadpdfium-341ec6256457c53d50f2d0a0667e61041d4d89be.tar.xz
Combine common code in fpdf_transformpage.cpp.
Change-Id: I50311794b6fb4ef3c38420838ec6c3bb157b06a7 Reviewed-on: https://pdfium-review.googlesource.com/17071 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 94807718e1..7ba3a3f67b 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -54,6 +54,16 @@ bool GetBoundingBox(CPDF_Page* page,
return true;
}
+CPDF_Object* GetPageContent(CPDF_Dictionary* pPageDict) {
+ if (!pPageDict)
+ return nullptr;
+
+ CPDF_Object* pContentObj = pPageDict->GetObjectFor("Contents");
+ if (!pContentObj)
+ pContentObj = pPageDict->GetArrayFor("Contents");
+ return pContentObj;
+}
+
} // namespace
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page,
@@ -121,11 +131,8 @@ FPDFPage_TransFormWithClip(FPDF_PAGE page,
matrix->d, matrix->e, matrix->f);
textBuf << bsMatix;
- CPDF_Dictionary* pPageDic = pPage->m_pFormDict.Get();
- CPDF_Object* pContentObj =
- pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
- if (!pContentObj)
- pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
+ CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get();
+ CPDF_Object* pContentObj = GetPageContent(pPageDict);
if (!pContentObj)
return false;
@@ -163,14 +170,14 @@ FPDFPage_TransFormWithClip(FPDF_PAGE page,
pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pDirectObj->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
- pPageDic->SetNewFor<CPDF_Reference>("Contents", pDoc,
- pContentArray->GetObjNum());
+ pPageDict->SetNewFor<CPDF_Reference>("Contents", pDoc,
+ pContentArray->GetObjNum());
}
}
}
// Need to transform the patterns as well.
- CPDF_Dictionary* pRes = pPageDic->GetDictFor("Resources");
+ CPDF_Dictionary* pRes = pPageDict->GetDictFor("Resources");
if (pRes) {
CPDF_Dictionary* pPattenDict = pRes->GetDictFor("Pattern");
if (pPattenDict) {
@@ -278,11 +285,8 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
if (!pPage)
return;
- CPDF_Dictionary* pPageDic = pPage->m_pFormDict.Get();
- CPDF_Object* pContentObj =
- pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
- if (!pContentObj)
- pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
+ CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get();
+ CPDF_Object* pContentObj = GetPageContent(pPageDict);
if (!pContentObj)
return;
@@ -334,7 +338,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pDirectObj->GetObjNum());
- pPageDic->SetNewFor<CPDF_Reference>("Contents", pDoc,
- pContentArray->GetObjNum());
+ pPageDict->SetNewFor<CPDF_Reference>("Contents", pDoc,
+ pContentArray->GetObjNum());
}
}