From 1f2211e9c3d0c2c3a448280b58c85d021cb3ee4b Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Mon, 8 Jan 2018 17:11:43 -0500 Subject: Style fixes in FPDFDOC_GetAnnotAP Change-Id: Iac18632ab1da7e30958278fd7769d5d7090e4242 Reviewed-on: https://pdfium-review.googlesource.com/22490 Commit-Queue: Henrique Nakashima Reviewed-by: dsinclair --- core/fpdfdoc/cpdf_annot.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 9f8ab7878f..d1baef5052 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -142,9 +142,9 @@ uint32_t CPDF_Annot::GetFlags() const { CPDF_Stream* FPDFDOC_GetAnnotAP(const CPDF_Dictionary* pAnnotDict, CPDF_Annot::AppearanceMode mode) { CPDF_Dictionary* pAP = pAnnotDict->GetDictFor("AP"); - if (!pAP) { + if (!pAP) return nullptr; - } + const char* ap_entry = "N"; if (mode == CPDF_Annot::Down) ap_entry = "D"; @@ -159,22 +159,20 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(const CPDF_Dictionary* pAnnotDict, if (CPDF_Stream* pStream = psub->AsStream()) return pStream; - if (CPDF_Dictionary* pDict = psub->AsDictionary()) { - ByteString as = pAnnotDict->GetStringFor("AS"); - if (as.IsEmpty()) { - ByteString value = pAnnotDict->GetStringFor("V"); - if (value.IsEmpty()) { - CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent"); - value = pParentDict ? pParentDict->GetStringFor("V") : ByteString(); - } - if (value.IsEmpty() || !pDict->KeyExist(value)) - as = "Off"; - else - as = value; + CPDF_Dictionary* pDict = psub->AsDictionary(); + if (!pDict) + return nullptr; + + ByteString as = pAnnotDict->GetStringFor("AS"); + if (as.IsEmpty()) { + ByteString value = pAnnotDict->GetStringFor("V"); + if (value.IsEmpty()) { + CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent"); + value = pParentDict ? pParentDict->GetStringFor("V") : ByteString(); } - return pDict->GetStreamFor(as); + as = (!value.IsEmpty() && pDict->KeyExist(value)) ? value : "Off"; } - return nullptr; + return pDict->GetStreamFor(as); } CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { -- cgit v1.2.3