summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfeditpage.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-11-04 18:04:03 -0800
committerLei Zhang <thestig@chromium.org>2015-11-04 18:04:03 -0800
commitff5adbc0dfa71270a9979f0c3e1d27923c16218a (patch)
treec68169974c3d747d30f925c1ace74d7bc9fb774c /fpdfsdk/src/fpdfeditpage.cpp
parent4544797e8998a31e7bc3f5439a5982f7f66dff26 (diff)
downloadpdfium-ff5adbc0dfa71270a9979f0c3e1d27923c16218a.tar.xz
Cleanup: Remove some NULL checks in fpdfsdk.
And simplify code. R=ochang@chromium.org Review URL: https://codereview.chromium.org/1411663013 .
Diffstat (limited to 'fpdfsdk/src/fpdfeditpage.cpp')
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index c0576ae59c..ff175d6c14 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -93,37 +93,21 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
return -1;
}
CPDF_Dictionary* pDict = pPage->m_pFormDict;
+ if (!pDict)
+ return -1;
- int rotate = 0;
- if (pDict != NULL) {
- if (pDict->KeyExist("Rotate"))
- rotate = pDict->GetElement("Rotate")->GetDirect()
- ? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90
- : 0;
- else {
- if (pDict->KeyExist("Parent")) {
- CPDF_Dictionary* pPages =
- ToDictionary(pDict->GetElement("Parent")->GetDirect());
- while (pPages) {
- if (pPages->KeyExist("Rotate")) {
- rotate =
- pPages->GetElement("Rotate")->GetDirect()
- ? pPages->GetElement("Rotate")->GetDirect()->GetInteger() /
- 90
- : 0;
- break;
- } else if (pPages->KeyExist("Parent"))
- pPages = ToDictionary(pPages->GetElement("Parent")->GetDirect());
- else
- break;
- }
- }
+ while (pDict) {
+ if (pDict->KeyExist("Rotate")) {
+ CPDF_Object* pRotateObj = pDict->GetElement("Rotate")->GetDirect();
+ return pRotateObj ? pRotateObj->GetInteger() / 90 : 0;
}
- } else {
- return -1;
+ if (!pDict->KeyExist("Parent"))
+ break;
+
+ pDict = ToDictionary(pDict->GetElement("Parent")->GetDirect());
}
- return rotate;
+ return 0;
}
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
@@ -136,7 +120,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
return;
}
CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj;
- if (pPageObj == NULL)
+ if (!pPageObj)
return;
FX_POSITION LastPersition = pPage->GetLastObjectPosition();
@@ -259,7 +243,7 @@ DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
double e,
double f) {
CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
- if (pPageObj == NULL)
+ if (!pPageObj)
return;
CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,