summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfannot.cpp
diff options
context:
space:
mode:
authorDiana Gage <drgage@google.com>2017-07-19 17:33:33 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-20 00:49:52 +0000
commit7e0c05d7a3329fd0a262d13b8aea74eaf33ba997 (patch)
tree7f3084e167c76ed22cfebae7cd50d456884ca521 /fpdfsdk/fpdfannot.cpp
parent33b42e4ab56d56ff02cd08a47c5f590875d886bf (diff)
downloadpdfium-7e0c05d7a3329fd0a262d13b8aea74eaf33ba997.tar.xz
Add FPDFAnnot_GetFormFieldFlags() and associated embedder tests.
Given an interactive form annotation, this method returns its annotation flags. The flags returned are dependent upon the "Ff" field, and are specific to interactive form annotations, such as FPDF_FORMFLAG_MULTILINE, FPDF_FORMFLAG_COMBO, FPDF_FORMFLAG_EDIT, and others. To test this method more thoroughly, text_form_multiple.pdf has been added, which is similar to text_form.pdf, but includes a read-only text field. BUG=chromium:59266 Change-Id: Ie66046de273f69a1be6f04a433351ebaa271f60c Reviewed-on: https://pdfium-review.googlesource.com/7851 Commit-Queue: Diana Gage <drgage@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfannot.cpp')
-rw-r--r--fpdfsdk/fpdfannot.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp
index 1c4345ab52..f3a9ea1b72 100644
--- a/fpdfsdk/fpdfannot.cpp
+++ b/fpdfsdk/fpdfannot.cpp
@@ -18,6 +18,8 @@
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfdoc/cpdf_annot.h"
+#include "core/fpdfdoc/cpdf_formfield.h"
+#include "core/fpdfdoc/cpdf_interform.h"
#include "core/fpdfdoc/cpvt_color.h"
#include "core/fpdfdoc/cpvt_generateap.h"
#include "fpdfsdk/fsdk_define.h"
@@ -786,3 +788,19 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetFlags(FPDF_ANNOTATION annot,
pAnnotDict->SetNewFor<CPDF_Number>("F", flags);
return true;
}
+
+DLLEXPORT int STDCALL FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page,
+ FPDF_ANNOTATION annot) {
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage || !annot)
+ return FPDF_FORMFLAG_NONE;
+
+ CPDF_Dictionary* pAnnotDict =
+ CPDFAnnotContextFromFPDFAnnotation(annot)->GetAnnotDict();
+ if (!pAnnotDict)
+ return FPDF_FORMFLAG_NONE;
+
+ CPDF_InterForm interform(pPage->m_pDocument.Get());
+ CPDF_FormField* pFormField = interform.GetFieldByDict(pAnnotDict);
+ return pFormField ? pFormField->GetFieldFlags() : FPDF_FORMFLAG_NONE;
+}