summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_annot.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-01-10 18:06:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 18:06:55 +0000
commita74e75d69594e469906e2a95b5f2394c88acbe7a (patch)
tree3c77b9358876819d50baa7f43a98e15dd33c2bbf /core/fpdfdoc/cpdf_annot.cpp
parent7d36c3e835bc32898f0064226d79a8f0f89e15ec (diff)
downloadpdfium-a74e75d69594e469906e2a95b5f2394c88acbe7a.tar.xz
Add FPDFAnnot_GetAP to public API.
The matching FPDFAnnot_SetAP will be added in a subsequent CL. Change-Id: If567e02c6c56138d218498879cb4a8ee91dff080 Reviewed-on: https://pdfium-review.googlesource.com/22450 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_annot.cpp')
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp75
1 files changed, 43 insertions, 32 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index d1baef5052..02df3cff60 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -60,6 +60,43 @@ CPDF_Form* AnnotGetMatrix(const CPDF_Page* pPage,
return pForm;
}
+CPDF_Stream* FPDFDOC_GetAnnotAPInternal(const CPDF_Dictionary* pAnnotDict,
+ CPDF_Annot::AppearanceMode eMode,
+ bool bFallbackToNormal) {
+ CPDF_Dictionary* pAP = pAnnotDict->GetDictFor("AP");
+ if (!pAP)
+ return nullptr;
+
+ const char* ap_entry = "N";
+ if (eMode == CPDF_Annot::Down)
+ ap_entry = "D";
+ else if (eMode == CPDF_Annot::Rollover)
+ ap_entry = "R";
+ if (bFallbackToNormal && !pAP->KeyExist(ap_entry))
+ ap_entry = "N";
+
+ CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry);
+ if (!psub)
+ return nullptr;
+ if (CPDF_Stream* pStream = psub->AsStream())
+ return pStream;
+
+ 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();
+ }
+ as = (!value.IsEmpty() && pDict->KeyExist(value)) ? value : "Off";
+ }
+ return pDict->GetStreamFor(as);
+}
+
} // namespace
CPDF_Annot::CPDF_Annot(std::unique_ptr<CPDF_Dictionary> pDict,
@@ -140,39 +177,13 @@ 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)
- return nullptr;
-
- const char* ap_entry = "N";
- if (mode == CPDF_Annot::Down)
- ap_entry = "D";
- else if (mode == CPDF_Annot::Rollover)
- ap_entry = "R";
- if (!pAP->KeyExist(ap_entry))
- ap_entry = "N";
-
- CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry);
- if (!psub)
- return nullptr;
- if (CPDF_Stream* pStream = psub->AsStream())
- return pStream;
-
- CPDF_Dictionary* pDict = psub->AsDictionary();
- if (!pDict)
- return nullptr;
+ CPDF_Annot::AppearanceMode eMode) {
+ return FPDFDOC_GetAnnotAPInternal(pAnnotDict, eMode, true);
+}
- 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();
- }
- as = (!value.IsEmpty() && pDict->KeyExist(value)) ? value : "Off";
- }
- return pDict->GetStreamFor(as);
+CPDF_Stream* FPDFDOC_GetAnnotAPNoFallback(const CPDF_Dictionary* pAnnotDict,
+ CPDF_Annot::AppearanceMode eMode) {
+ return FPDFDOC_GetAnnotAPInternal(pAnnotDict, eMode, false);
}
CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {