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

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

Issue 1422513004: Merge to XFA: Add type cast definitions for CPDF_Stream. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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 ca05d783b8fd5c70b3955a36d89abd9255b42cc3..dc5ccb811c036e5f3d9bddc149aa44dfe7f7c3ed 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);

Powered by Google App Engine
This is Rietveld 408576698