Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3367)

Unified Diff: core/src/fpdfdoc/doc_annot.cpp

Issue 1402413004: Add type cast definitions for CPDF_Stream. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfdoc/doc_annot.cpp
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 4d0b703036234995ccb95d56a763f985d58487d6..d37b1aaadba3b6239508d7385ff7c9e2bf4a42d5 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -187,22 +187,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"));
@@ -210,15 +208,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);

Powered by Google App Engine
This is Rietveld 408576698