diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-01-10 18:06:55 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-10 18:06:55 +0000 |
commit | a74e75d69594e469906e2a95b5f2394c88acbe7a (patch) | |
tree | 3c77b9358876819d50baa7f43a98e15dd33c2bbf /fpdfsdk/fpdfannot.cpp | |
parent | 7d36c3e835bc32898f0064226d79a8f0f89e15ec (diff) | |
download | pdfium-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 'fpdfsdk/fpdfannot.cpp')
-rw-r--r-- | fpdfsdk/fpdfannot.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index ec541f55d0..c7433d03d8 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -104,6 +104,18 @@ static_assert(static_cast<int>(CPDF_Annot::Subtype::XFAWIDGET) == FPDF_ANNOT_XFAWIDGET, "CPDF_Annot::XFAWIDGET value mismatch"); +// These checks ensure the consistency of annotation appearance mode values +// across core/ and public. +static_assert(static_cast<int>(CPDF_Annot::AppearanceMode::Normal) == + FPDF_ANNOT_APPEARANCEMODE_NORMAL, + "CPDF_Annot::AppearanceMode::Normal value mismatch"); +static_assert(static_cast<int>(CPDF_Annot::AppearanceMode::Rollover) == + FPDF_ANNOT_APPEARANCEMODE_ROLLOVER, + "CPDF_Annot::AppearanceMode::Rollover value mismatch"); +static_assert(static_cast<int>(CPDF_Annot::AppearanceMode::Down) == + FPDF_ANNOT_APPEARANCEMODE_DOWN, + "CPDF_Annot::AppearanceMode::Down value mismatch"); + // These checks ensure the consistency of dictionary value types across core/ // and public/. static_assert(static_cast<int>(CPDF_Object::Type::BOOLEAN) == @@ -735,6 +747,33 @@ FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, buffer, buflen); } +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetAP(FPDF_ANNOTATION annot, + FPDF_ANNOT_APPEARANCEMODE appearanceMode, + void* buffer, + unsigned long buflen) { + if (appearanceMode < 0 || appearanceMode >= FPDF_ANNOT_APPEARANCEMODE_COUNT) + return 0; + + if (!annot) + return 0; + + CPDF_Dictionary* pAnnotDict = + CPDFAnnotContextFromFPDFAnnotation(annot)->GetAnnotDict(); + if (!pAnnotDict) + return 0; + + CPDF_Annot::AppearanceMode mode = + static_cast<CPDF_Annot::AppearanceMode>(appearanceMode); + + CPDF_Stream* pStream = FPDFDOC_GetAnnotAPNoFallback(pAnnotDict, mode); + if (!pStream) + return Utf16EncodeMaybeCopyAndReturnLength(L"", buffer, buflen); + + return Utf16EncodeMaybeCopyAndReturnLength(pStream->GetUnicodeText(), buffer, + buflen); +} + FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_BYTESTRING key) { CPDF_AnnotContext* pAnnot = CPDFAnnotContextFromFPDFAnnotation(annot); |