summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp31
-rw-r--r--core/src/fpdfdoc/doc_basic.cpp12
-rw-r--r--core/src/fpdfdoc/doc_tagged.cpp9
3 files changed, 23 insertions, 29 deletions
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index ca05d783b8..dc5ccb811c 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -190,22 +190,20 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
return NULL;
}
const FX_CHAR* ap_entry = "N";
- if (mode == CPDF_Annot::Down) {
+ if (mode == CPDF_Annot::Down)
ap_entry = "D";
- } else if (mode == CPDF_Annot::Rollover) {
+ else if (mode == CPDF_Annot::Rollover)
ap_entry = "R";
- }
- if (!pAP->KeyExist(ap_entry)) {
+ if (!pAP->KeyExist(ap_entry))
ap_entry = "N";
- }
+
CPDF_Object* psub = pAP->GetElementValue(ap_entry);
- if (psub == NULL) {
- return NULL;
- }
- CPDF_Stream* pStream = NULL;
- if (psub->GetType() == PDFOBJ_STREAM) {
- pStream = (CPDF_Stream*)psub;
- } else if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
+ if (!psub)
+ return nullptr;
+ if (CPDF_Stream* pStream = psub->AsStream())
+ return pStream;
+
+ if (CPDF_Dictionary* pDict = psub->AsDictionary()) {
CFX_ByteString as = pAnnotDict->GetString("AS");
if (as.IsEmpty()) {
CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V"));
@@ -213,15 +211,14 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent"));
value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString();
}
- if (value.IsEmpty() || !pDict->KeyExist(value)) {
+ if (value.IsEmpty() || !pDict->KeyExist(value))
as = FX_BSTRC("Off");
- } else {
+ else
as = value;
- }
}
- pStream = pDict->GetStream(as);
+ return pDict->GetStream(as);
}
- return pStream;
+ return nullptr;
}
CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pAnnotDict, mode);
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp
index b32e34bb4c..414f5749d0 100644
--- a/core/src/fpdfdoc/doc_basic.cpp
+++ b/core/src/fpdfdoc/doc_basic.cpp
@@ -380,15 +380,13 @@ CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath) {
#endif
}
CPDF_Stream* CPDF_FileSpec::GetFileStream() const {
- if (m_pObj == NULL) {
- return NULL;
- }
- int32_t iType = m_pObj->GetType();
- if (iType == PDFOBJ_STREAM)
- return (CPDF_Stream*)m_pObj;
+ if (!m_pObj)
+ return nullptr;
+ if (CPDF_Stream* pStream = m_pObj->AsStream())
+ return pStream;
if (CPDF_Dictionary* pEF = m_pObj->AsDictionary()->GetDict(FX_BSTRC("EF")))
return pEF->GetStream(FX_BSTRC("F"));
- return NULL;
+ return nullptr;
}
static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj,
const CFX_WideStringC& wsFileName,
diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp
index 2b20e07bb8..f74aa7f6f5 100644
--- a/core/src/fpdfdoc/doc_tagged.cpp
+++ b/core/src/fpdfdoc/doc_tagged.cpp
@@ -317,8 +317,8 @@ static CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs,
CPDF_Dictionary* pDict = nullptr;
if (pAttrs->IsDictionary()) {
pDict = pAttrs->AsDictionary();
- } else if (pAttrs->GetType() == PDFOBJ_STREAM) {
- pDict = ((CPDF_Stream*)pAttrs)->GetDict();
+ } else if (CPDF_Stream* pStream = pAttrs->AsStream()) {
+ pDict = pStream->GetDict();
} else if (CPDF_Array* pArray = pAttrs->AsArray()) {
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetElementValue(i);
@@ -327,10 +327,9 @@ static CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs,
return pDict;
}
}
- if (pDict && pDict->GetString(FX_BSTRC("O")) == owner) {
+ if (pDict && pDict->GetString(FX_BSTRC("O")) == owner)
return pDict;
- }
- return NULL;
+ return nullptr;
}
CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner,
const CFX_ByteStringC& name,