summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc/doc_annot.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-22 16:45:48 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-22 16:45:48 -0400
commitaa435ba7fe0aacd9102e8c73311c5382ca112439 (patch)
treed37573646c6135126d3971358024a70ee222fb21 /core/src/fpdfdoc/doc_annot.cpp
parent2b11dc1220746d2f6f97a940fc9e4235c8ed4975 (diff)
downloadpdfium-aa435ba7fe0aacd9102e8c73311c5382ca112439.tar.xz
Merge to XFA: Add type cast definitions for CPDF_Stream.
This Cl adds ToStream, CPDF_Object::AsStream and CPDF_Object::IsStream and updates the src to use them as needed. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1402413004 . (cherry picked from commit 338805f1366dcdf9a5b48cf591541cf98d7490f1) Review URL: https://codereview.chromium.org/1422513004 .
Diffstat (limited to 'core/src/fpdfdoc/doc_annot.cpp')
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp31
1 files changed, 14 insertions, 17 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);