5#include "public/fpdf_annot.h"
12#include "constants/annotation_common.h"
13#include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h"
14#include "core/fpdfapi/page/cpdf_annotcontext.h"
15#include "core/fpdfapi/page/cpdf_form.h"
16#include "core/fpdfapi/page/cpdf_page.h"
17#include "core/fpdfapi/page/cpdf_pageobject.h"
18#include "core/fpdfapi/parser/cpdf_array.h"
19#include "core/fpdfapi/parser/cpdf_boolean.h"
20#include "core/fpdfapi/parser/cpdf_dictionary.h"
21#include "core/fpdfapi/parser/cpdf_document.h"
22#include "core/fpdfapi/parser/cpdf_name.h"
23#include "core/fpdfapi/parser/cpdf_number.h"
24#include "core/fpdfapi/parser/cpdf_reference.h"
25#include "core/fpdfapi/parser/cpdf_stream.h"
26#include "core/fpdfapi/parser/cpdf_string.h"
27#include "core/fpdfapi/parser/fpdf_parser_utility.h"
28#include "core/fpdfdoc/cpdf_annot.h"
29#include "core/fpdfdoc/cpdf_color_utils.h"
30#include "core/fpdfdoc/cpdf_formfield.h"
31#include "core/fpdfdoc/cpdf_generateap.h"
32#include "core/fpdfdoc/cpdf_interactiveform.h"
33#include "core/fxcrt/fx_safe_types.h"
34#include "core/fxcrt/fx_string_wrappers.h"
35#include "core/fxcrt/stl_util.h"
36#include "core/fxge/cfx_color.h"
37#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
38#include "fpdfsdk/cpdfsdk_helpers.h"
39#include "fpdfsdk/cpdfsdk_interactiveform.h"
40#include "third_party/base/check.h"
41#include "third_party/base/containers/contains.h"
42#include "third_party/base/memory/ptr_util.h"
43#include "third_party/base/numerics/safe_conversions.h"
51 "CPDF_Annot::UNKNOWN value mismatch");
53 "CPDF_Annot::TEXT value mismatch");
55 "CPDF_Annot::LINK value mismatch");
58 "CPDF_Annot::FREETEXT value mismatch");
60 "CPDF_Annot::LINE value mismatch");
63 "CPDF_Annot::SQUARE value mismatch");
66 "CPDF_Annot::CIRCLE value mismatch");
69 "CPDF_Annot::POLYGON value mismatch");
72 "CPDF_Annot::POLYLINE value mismatch");
75 "CPDF_Annot::HIGHLIGHT value mismatch");
78 "CPDF_Annot::UNDERLINE value mismatch");
81 "CPDF_Annot::SQUIGGLY value mismatch");
84 "CPDF_Annot::STRIKEOUT value mismatch");
86 "CPDF_Annot::STAMP value mismatch");
88 "CPDF_Annot::CARET value mismatch");
90 "CPDF_Annot::INK value mismatch");
92 "CPDF_Annot::POPUP value mismatch");
95 "CPDF_Annot::FILEATTACHMENT value mismatch");
97 "CPDF_Annot::SOUND value mismatch");
99 "CPDF_Annot::MOVIE value mismatch");
102 "CPDF_Annot::WIDGET value mismatch");
105 "CPDF_Annot::SCREEN value mismatch");
108 "CPDF_Annot::PRINTERMARK value mismatch");
111 "CPDF_Annot::TRAPNET value mismatch");
114 "CPDF_Annot::WATERMARK value mismatch");
117 "CPDF_Annot::THREED value mismatch");
120 "CPDF_Annot::RICHMEDIA value mismatch");
123 "CPDF_Annot::XFAWIDGET value mismatch");
126 "CPDF_Annot::REDACT value mismatch");
132 "CPDF_Annot::AppearanceMode::Normal value mismatch");
135 "CPDF_Annot::AppearanceMode::Rollover value mismatch");
138 "CPDF_Annot::AppearanceMode::Down value mismatch");
144 "CPDF_Object::kBoolean value mismatch");
147 "CPDF_Object::kNumber value mismatch");
150 "CPDF_Object::kString value mismatch");
152 "CPDF_Object::kName value mismatch");
154 "CPDF_Object::kArray value mismatch");
157 "CPDF_Object::kDictionary value mismatch");
160 "CPDF_Object::kStream value mismatch");
163 "CPDF_Object::kNullobj value mismatch");
166 "CPDF_Object::kReference value mismatch");
172 "CPDF_AAction::kKeyStroke value mismatch");
175 "CPDF_AAction::kFormat value mismatch");
178 "CPDF_AAction::kValidate value mismatch");
181 "CPDF_AAction::kCalculate value mismatch");
183bool HasAPStream(CPDF_Dictionary* pAnnotDict) {
187void UpdateContentStream(CPDF_Form* pForm, CPDF_Stream* pStream) {
192 fxcrt::ostringstream buf;
193 generator.ProcessPageObjects(&buf);
194 pStream->SetDataFromStringstreamAndRemoveFilter(&buf);
197void SetQuadPointsAtIndex(CPDF_Array* array,
199 const FS_QUADPOINTSF* quad_points) {
202 DCHECK(IsValidQuadPointsIndex(array, quad_index));
204 size_t nIndex = quad_index * 8;
205 array->SetNewAt<CPDF_Number>(nIndex, quad_points->x1);
206 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y1);
207 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->x2);
208 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y2);
209 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->x3);
210 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y3);
211 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->x4);
212 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y4);
215void AppendQuadPoints(CPDF_Array* array,
const FS_QUADPOINTSF* quad_points) {
219 array->AppendNew<CPDF_Number>(quad_points->x1);
220 array->AppendNew<CPDF_Number>(quad_points->y1);
221 array->AppendNew<CPDF_Number>(quad_points->x2);
222 array->AppendNew<CPDF_Number>(quad_points->y2);
223 array->AppendNew<CPDF_Number>(quad_points->x3);
224 array->AppendNew<CPDF_Number>(quad_points->y3);
225 array->AppendNew<CPDF_Number>(quad_points->x4);
226 array->AppendNew<CPDF_Number>(quad_points->y4);
229void UpdateBBox(CPDF_Dictionary* annot_dict) {
234 GetAnnotAP(annot_dict, CPDF_Annot::AppearanceMode::kNormal);
238 if (boundingRect.Contains(pStream->GetDict()->GetRectFor(
"BBox")))
239 pStream->GetMutableDict()->SetRectFor(
"BBox", boundingRect);
243const CPDF_Dictionary* GetAnnotDictFromFPDFAnnotation(
244 const FPDF_ANNOTATION annot) {
249RetainPtr<CPDF_Dictionary> GetMutableAnnotDictFromFPDFAnnotation(
250 FPDF_ANNOTATION annot) {
252 return context ? context->GetMutableAnnotDict() :
nullptr;
255RetainPtr<CPDF_Dictionary> SetExtGStateInResourceDict(
257 const CPDF_Dictionary* pAnnotDict,
258 const ByteString& sBlendMode) {
260 pdfium::MakeRetain<CPDF_Dictionary>(pAnnotDict->GetByteStringPool());
263 pGSDict->SetNewFor<CPDF_Name>(
"Type",
"ExtGState");
269 pGSDict->SetNewFor<CPDF_Number>(
"CA", fOpacity);
273 pGSDict->SetNewFor<CPDF_Number>(
"ca", fOpacity);
278 pGSDict->SetNewFor<CPDF_Boolean>(
"AIS",
false);
281 pGSDict->SetNewFor<CPDF_Name>(
"BM", sBlendMode);
283 auto pExtGStateDict =
284 pdfium::MakeRetain<CPDF_Dictionary>(pAnnotDict->GetByteStringPool());
286 pExtGStateDict->SetFor(
"GS", pGSDict);
288 auto pResourceDict = pDoc->New<CPDF_Dictionary>();
289 pResourceDict->SetFor(
"ExtGState", pExtGStateDict);
290 return pResourceDict;
293CPDF_FormField* GetFormField(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot) {
294 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
306const CPDFSDK_Widget* GetRadioButtonOrCheckBoxWidget(FPDF_FORMHANDLE hHandle,
307 FPDF_ANNOTATION annot) {
308 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
324 return pFormControl ? pForm
->GetWidget(pFormControl
) :
nullptr;
327RetainPtr<
const CPDF_Array> GetInkList(FPDF_ANNOTATION annot) {
332 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
375 RetainPtr<CPDF_Array> pAnnotList = pPage->GetOrCreateAnnotsArray();
376 pAnnotList->Append(pDict);
379 return FPDFAnnotationFromCPDFAnnotContext(pNewAnnot.release());
387 RetainPtr<
const CPDF_Array> pAnnots = pPage->GetAnnotsArray();
388 return pAnnots ?
fxcrt::CollectionSize<
int>(*pAnnots) : 0;
394 if (!pPage || index < 0)
397 RetainPtr<CPDF_Array> pAnnots = pPage->GetMutableAnnotsArray();
398 if (!pAnnots ||
static_cast<size_t>(index) >= pAnnots->size())
402 ToDictionary(pAnnots->GetMutableDirectObjectAt(index));
410 return FPDFAnnotationFromCPDFAnnotContext(pNewAnnot.release());
414 FPDF_ANNOTATION annot) {
419 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
423 RetainPtr<
const CPDF_Array> pAnnots = pPage->GetAnnotsArray();
428 auto it =
std::find_if(locker.begin(), locker.end(),
430 return candidate->GetDirect() == pAnnotDict;
433 if (it == locker.end())
436 return pdfium::base::checked_cast<
int>(it - locker.begin());
446 if (!pPage || index < 0)
449 RetainPtr<CPDF_Array> pAnnots = pPage->GetMutableAnnotsArray();
450 if (!pAnnots ||
static_cast<size_t>(index) >= pAnnots->size())
453 pAnnots->RemoveAt(index);
459 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
486 RetainPtr<CPDF_Dictionary> pAnnotDict = pAnnot->GetMutableAnnotDict();
488 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
494 if (!pdfium::Contains(*pForm,
fxcrt::MakeFakeUniquePtr(pObj)))
498 UpdateContentStream(pForm, pStream.Get());
503 const FS_POINTF* points,
504 size_t point_count) {
507 !pdfium::base::IsValueInRangeForNumericType<int32_t>(point_count)) {
512 GetMutableAnnotDictFromFPDFAnnotation(annot);
513 RetainPtr<CPDF_Array> inklist = annot_dict->GetOrCreateArrayFor(
"InkList");
514 FX_SAFE_SIZE_T safe_ink_size = inklist->size();
516 if (!safe_ink_size.IsValid<int32_t>())
519 auto ink_coord_list = inklist->AppendNew<CPDF_Array>();
520 for (size_t i = 0; i < point_count; i++) {
521 ink_coord_list->AppendNew<CPDF_Number>(points[i].x);
522 ink_coord_list->AppendNew<CPDF_Number>(points[i].y);
524 return static_cast<
int>(inklist->size() - 1);
533 CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict();
534 annot_dict->RemoveFor(
"InkList");
542 if (!pAnnot || !pObj)
550 RetainPtr<CPDF_Dictionary> pAnnotDict = pAnnot->GetMutableAnnotDict();
552 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
571 if (pdfium::Contains(*pForm,
fxcrt::MakeFakeUniquePtr(pObj)))
575 pForm->AppendPageObject(pdfium::WrapUnique(pObj));
578 UpdateContentStream(pForm, pStream.Get());
588 RetainPtr<CPDF_Dictionary> pDict = pAnnot->GetMutableAnnotDict();
590 GetAnnotAP(pDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
596 return pdfium::base::checked_cast<
int>(
603 if (!pAnnot || index < 0)
607 RetainPtr<CPDF_Dictionary> pAnnotDict = pAnnot->GetMutableAnnotDict();
609 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
616 return FPDFPageObjectFromCPDFPageObject(
632 RetainPtr<CPDF_Dictionary> pAnnotDict = pAnnot->GetMutableAnnotDict();
634 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
638 if (!pAnnot
->GetForm()->ErasePageObjectAtIndex(index))
641 UpdateContentStream(pAnnot
->GetForm(), pStream.Get());
646 FPDFANNOT_COLORTYPE type,
652 GetMutableAnnotDictFromFPDFAnnotation(annot);
654 if (!pAnnotDict || R > 255 || G > 255 || B > 255 || A > 255)
660 if (HasAPStream(pAnnotDict.Get()))
664 pAnnotDict->SetNewFor<CPDF_Number>(
"CA", A / 255.f);
668 RetainPtr<CPDF_Array> pColor = pAnnotDict->GetMutableArrayFor(key);
672 pColor = pAnnotDict->SetNewFor<CPDF_Array>(key);
674 pColor->AppendNew<CPDF_Number>(R / 255.f);
675 pColor->AppendNew<CPDF_Number>(G / 255.f);
676 pColor->AppendNew<CPDF_Number>(B / 255.f);
682 FPDFANNOT_COLORTYPE type,
688 GetMutableAnnotDictFromFPDFAnnotation(annot);
690 if (!pAnnotDict || !R || !G || !B || !A)
696 if (HasAPStream(pAnnotDict.Get()))
699 RetainPtr<
const CPDF_Array> pColor = pAnnotDict->GetArrayFor(
700 type == FPDFANNOT_COLORTYPE_InteriorColor ?
"IC" :
"C");
701 *A = (pAnnotDict->KeyExist(
"CA") ? pAnnotDict->GetFloatFor(
"CA") : 1) * 255.f;
758 const FS_QUADPOINTSF* quad_points) {
763 CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict();
765 GetMutableQuadPointsArrayFromDictionary(pAnnotDict.Get());
766 if (!IsValidQuadPointsIndex(pQuadPointsArray.Get(), quad_index))
769 SetQuadPointsAtIndex(pQuadPointsArray.Get(), quad_index, quad_points);
770 UpdateBBox(pAnnotDict.Get());
776 const FS_QUADPOINTSF* quad_points) {
781 CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict();
783 GetMutableQuadPointsArrayFromDictionary(pAnnotDict.Get());
784 if (!pQuadPointsArray)
785 pQuadPointsArray = AddQuadPointsArrayToDictionary(pAnnotDict.Get());
786 AppendQuadPoints(pQuadPointsArray.Get(), quad_points);
787 UpdateBBox(pAnnotDict.Get());
796 const CPDF_Dictionary* pAnnotDict =
799 GetQuadPointsArrayFromDictionary(pAnnotDict);
800 return pArray ? pArray->size() / 8 : 0;
806 FS_QUADPOINTSF* quad_points) {
810 const CPDF_Dictionary* pAnnotDict =
813 GetQuadPointsArrayFromDictionary(pAnnotDict);
817 return GetQuadPointsAtIndex(std::move(pArray), quad_index, quad_points);
821 const FS_RECTF* rect) {
823 GetMutableAnnotDictFromFPDFAnnotation(annot);
824 if (!pAnnotDict || !rect)
841 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
842 if (pStream && newRect.Contains(pStream->GetDict()->GetRectFor(
"BBox")))
843 pStream->GetMutableDict()->SetRectFor(
"BBox", newRect);
849 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
850 if (!pAnnotDict || !rect)
861 unsigned long length) {
866 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
871 annot_dict->GetArrayFor(pdfium::annotation::kVertices);
876 const unsigned long points_len =
877 fxcrt::CollectionSize<
unsigned long>(*vertices) / 2;
878 if (buffer && length >= points_len) {
879 for (
unsigned long i = 0; i < points_len; ++i) {
880 buffer[i].x = vertices->GetFloatAt(i * 2);
881 buffer[i].y = vertices->GetFloatAt(i * 2 + 1);
889 RetainPtr<
const CPDF_Array> ink_list = GetInkList(annot);
890 return ink_list ?
fxcrt::CollectionSize<
unsigned long>(*ink_list) : 0;
895 unsigned long path_index,
897 unsigned long length) {
898 RetainPtr<
const CPDF_Array> ink_list = GetInkList(annot);
902 RetainPtr<
const CPDF_Array> path = ink_list->GetArrayAt(path_index);
907 const unsigned long points_len =
908 fxcrt::CollectionSize<
unsigned long>(*path) / 2;
909 if (buffer && length >= points_len) {
910 for (
unsigned long i = 0; i < points_len; ++i) {
911 buffer[i].x = path->GetFloatAt(i * 2);
912 buffer[i].y = path->GetFloatAt(i * 2 + 1);
928 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
933 annot_dict->GetArrayFor(pdfium::annotation::kL);
934 if (!line || line->size() < 4)
937 start->x = line->GetFloatAt(0);
938 start->y = line->GetFloatAt(1);
939 end->x = line->GetFloatAt(2);
940 end->y = line->GetFloatAt(3);
945 float horizontal_radius,
946 float vertical_radius,
947 float border_width) {
949 GetMutableAnnotDictFromFPDFAnnotation(annot);
958 border->AppendNew<CPDF_Number>(horizontal_radius);
959 border->AppendNew<CPDF_Number>(vertical_radius);
960 border->AppendNew<CPDF_Number>(border_width);
966 float* horizontal_radius,
967 float* vertical_radius,
968 float* border_width) {
969 if (!horizontal_radius || !vertical_radius || !border_width)
972 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
977 annot_dict->GetArrayFor(pdfium::annotation::kBorder);
978 if (!border || border->size() < 3)
981 *horizontal_radius = border->GetFloatAt(0);
982 *vertical_radius = border->GetFloatAt(1);
983 *border_width = border->GetFloatAt(2);
988 FPDF_BYTESTRING key) {
989 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1005 FPDF_BYTESTRING key,
1006 FPDF_WIDESTRING value) {
1008 GetMutableAnnotDictFromFPDFAnnotation(annot);
1012 pAnnotDict->SetNewFor<CPDF_String>(
1019 FPDF_BYTESTRING key,
1021 unsigned long buflen) {
1022 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1032 FPDF_BYTESTRING key,
1037 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1045 *value = p->GetNumber();
1051 FPDF_ANNOT_APPEARANCEMODE appearanceMode,
1052 FPDF_WIDESTRING value) {
1054 GetMutableAnnotDictFromFPDFAnnotation(annot);
1061 static constexpr const char* kModeKeyForMode[] = {
"N",
"R",
"D"};
1063 "length of kModeKeyForMode should be equal to "
1064 "FPDF_ANNOT_APPEARANCEMODE_COUNT");
1065 const char* modeKey = kModeKeyForMode[appearanceMode];
1068 pAnnotDict->GetMutableDictFor(pdfium::annotation::kAP);
1076 constexpr float kMinSize = 0.000001f;
1087 auto pNewIndirectStream = pDoc->NewIndirect<CPDF_Stream>();
1088 ByteString newAPStream =
1090 pNewIndirectStream->SetData(newAPStream.raw_span());
1092 RetainPtr<CPDF_Dictionary> pStreamDict =
1093 pNewIndirectStream->GetMutableDict();
1096 pStreamDict->SetRectFor(
"BBox", rect);
1101 if (pAnnotDict->KeyExist(
"CA") && pAnnotDict->GetFloatFor(
"CA") < 1.0f) {
1102 RetainPtr<CPDF_Dictionary> pResourceDict =
1103 SetExtGStateInResourceDict(pDoc, pAnnotDict.Get(),
"Normal");
1104 pStreamDict->SetFor(
"Resources", pResourceDict);
1111 pApDict->SetNewFor<CPDF_Reference>(modeKey, pDoc,
1112 pNewIndirectStream->GetObjNum());
1118 pApDict->RemoveFor(modeKey);
1127 FPDF_ANNOT_APPEARANCEMODE appearanceMode,
1129 unsigned long buflen) {
1131 GetMutableAnnotDictFromFPDFAnnotation(annot);
1141 RetainPtr<CPDF_Stream> pStream = GetAnnotAPNoFallback(pAnnotDict.Get(), mode);
1142 return Utf16EncodeMaybeCopyAndReturnLength(
1143 pStream ? pStream->GetUnicodeText() : WideString
(), buffer, buflen);
1152 RetainPtr<CPDF_Dictionary> pLinkedDict =
1153 pAnnot->GetMutableAnnotDict()->GetMutableDictFor(key);
1154 if (!pLinkedDict || pLinkedDict->GetNameFor(
"Type") !=
"Annot")
1161 return FPDFAnnotationFromCPDFAnnotContext(pLinkedAnnot.release());
1165 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1173 GetMutableAnnotDictFromFPDFAnnotation(annot);
1190 const FS_POINTF* point) {
1203 int annot_index = -1;
1205 pPage
, CFXPointFFromFSPointF(*point)
, &annot_index
);
1206 if (!pFormCtrl || annot_index == -1)
1213 FPDF_ANNOTATION annot,
1215 unsigned long buflen) {
1231 FPDF_ANNOTATION annot,
1234 unsigned long buflen) {
1253 FPDF_ANNOTATION annot,
1255 unsigned long buflen) {
1266 FPDF_ANNOTATION annot,
1268 unsigned long buflen) {
1277 FPDF_ANNOTATION annot) {
1284 FPDF_ANNOTATION annot,
1287 unsigned long buflen) {
1301 FPDF_ANNOTATION annot,
1323 FPDF_ANNOTATION annot,
1332 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1350 FPDF_ANNOTATION annot) {
1351 const CPDFSDK_Widget* pWidget =
1352 GetRadioButtonOrCheckBoxWidget(hHandle, annot);
1358 const FPDF_ANNOTATION_SUBTYPE* subtypes,
1360 CPDFSDK_FormFillEnvironment* pFormFillEnv =
1365 if (count > 0 && !subtypes)
1368 std::vector<CPDF_Annot::Subtype> focusable_annot_types;
1369 focusable_annot_types.reserve(count);
1370 for (size_t i = 0; i < count; ++i) {
1371 focusable_annot_types.push_back(
1375 pFormFillEnv->SetFocusableAnnotSubtypes(focusable_annot_types);
1381 CPDFSDK_FormFillEnvironment* pFormFillEnv =
1386 return fxcrt::CollectionSize<
int>(pFormFillEnv->GetFocusableAnnotSubtypes());
1391 FPDF_ANNOTATION_SUBTYPE* subtypes,
1393 CPDFSDK_FormFillEnvironment* pFormFillEnv =
1401 const std::vector<CPDF_Annot::Subtype>& focusable_annot_types =
1402 pFormFillEnv->GetFocusableAnnotSubtypes();
1406 if (count < focusable_annot_types.size())
1409 for (size_t i = 0; i < focusable_annot_types.size(); ++i) {
1411 static_cast<FPDF_ANNOTATION_SUBTYPE>(focusable_annot_types[i]);
1422 return FPDFLinkFromCPDFDictionary(
1434 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1450 FPDF_ANNOTATION annot,
1452 unsigned long buflen) {
1453 const CPDFSDK_Widget* pWidget =
1454 GetRadioButtonOrCheckBoxWidget(hHandle, annot);
1468 GetMutableAnnotDictFromFPDFAnnotation(annot);
1469 auto action = annot_dict->SetNewFor<CPDF_Dictionary>(
"A");
1470 action->SetNewFor<CPDF_Name>(
"Type",
"Action");
1471 action->SetNewFor<CPDF_Name>(
"S",
"URI");
1472 action->SetNewFor<CPDF_String>(
"URI", uri,
false);
CPDF_Action GetAction(AActionType eType) const
WideString GetJavaScript() const
void SetForm(RetainPtr< CPDF_Stream > pStream)
CPDF_Form * GetForm() const
IPDF_Page * GetPage() const
const CPDF_Dictionary * GetAnnotDict() const
static ByteString AnnotSubtypeToString(Subtype nSubtype)
static Subtype StringToAnnotSubtype(const ByteString &sSubtype)
static CFX_FloatRect BoundingRectFromQuadPoints(const CPDF_Dictionary *pAnnotDict)
bool KeyExist(const ByteString &key) const
int GetIntegerFor(const ByteString &key) const
float GetFloatFor(const ByteString &key) const
WideString GetUnicodeTextFor(const ByteString &key) const
RetainPtr< const CPDF_Array > GetArrayFor(const ByteString &key) const
CFX_FloatRect GetRectFor(const ByteString &key) const
ByteString GetNameFor(const ByteString &key) const
static void GenerateEmptyAP(CPDF_Document *pDoc, CPDF_Dictionary *pAnnotDict)
CPDF_Document * GetDocument() const override
virtual CPDF_Document * GetDocument() const =0
WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string)
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)
unsigned long Utf16EncodeMaybeCopyAndReturnLength(const WideString &text, void *buffer, unsigned long buflen)
CPDFSDK_FormFillEnvironment * CPDFSDKFormFillEnvironmentFromFPDFFormHandle(FPDF_FORMHANDLE handle)
CPDF_AnnotContext * CPDFAnnotContextFromFPDFAnnotation(FPDF_ANNOTATION annot)
FS_RECTF FSRectFFromCFXFloatRect(const CFX_FloatRect &rect)
CFX_FloatRect CFXFloatRectFromFSRectF(const FS_RECTF &rect)
CPDF_Page * CPDFPageFromFPDFPage(FPDF_PAGE page)
CPDF_PageObject * CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object)
CPDFSDK_InteractiveForm * FormHandleToInteractiveForm(FPDF_FORMHANDLE hHandle)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFocusableSubtypes(FPDF_FORMHANDLE hHandle, const FPDF_ANNOTATION_SUBTYPE *subtypes, size_t count)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, size_t quad_index, FS_QUADPOINTSF *quad_points)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_AddInkStroke(FPDF_ANNOTATION annot, const FS_POINTF *points, size_t point_count)
FPDF_EXPORT size_t FPDF_CALLCONV FPDFAnnot_CountAttachmentPoints(FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetFocusableSubtypes(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION_SUBTYPE *subtypes, size_t count)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, size_t quad_index, const FS_QUADPOINTSF *quad_points)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFormControlCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetFontSize(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, float *value)
#define FPDF_ANNOT_FILEATTACHMENT
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot, const FS_RECTF *rect)
#define FPDF_ANNOT_RICHMEDIA
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page, int index)
#define FPDF_ANNOT_THREED
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetBorder(FPDF_ANNOTATION annot, float *horizontal_radius, float *vertical_radius, float *border_width)
#define FPDF_ANNOT_APPEARANCEMODE_COUNT
#define FPDF_ANNOT_APPEARANCEMODE_ROLLOVER
#define FPDF_ANNOT_STRIKEOUT
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFocusableSubtypesCount(FPDF_FORMHANDLE hHandle)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetOptionCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetVertices(FPDF_ANNOTATION annot, FS_POINTF *buffer, unsigned long length)
#define FPDF_ANNOT_UNDERLINE
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot, int flags)
#define FPDF_ANNOT_UNKNOWN
#define FPDF_ANNOT_SCREEN
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, FPDF_BYTESTRING key)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_BYTESTRING key)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index)
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotCount(FPDF_PAGE page)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype)
#define FPDF_ANNOT_WATERMARK
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsChecked(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFAnnot_GetLink(FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetAP(FPDF_ANNOTATION annot, FPDF_ANNOT_APPEARANCEMODE appearanceMode, FPDF_WIDESTRING value)
FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot)
#define FPDF_ANNOT_XFAWIDGET
#define FPDF_ANNOT_WIDGET
FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_BYTESTRING key)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_AppendAttachmentPoints(FPDF_ANNOTATION annot, const FS_QUADPOINTSF *quad_points)
#define FPDF_ANNOT_HIGHLIGHT
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot)
#define FPDF_ANNOT_TRAPNET
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot, FPDFANNOT_COLORTYPE type, unsigned int *R, unsigned int *G, unsigned int *B, unsigned int *A)
#define FPDF_ANNOT_SQUIGGLY
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFormFieldFlags(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, FPDF_BYTESTRING key, FPDF_WIDESTRING value)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetOptionLabel(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, int index, FPDF_WCHAR *buffer, unsigned long buflen)
#define FPDF_ANNOT_APPEARANCEMODE_NORMAL
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot, unsigned long path_index, FS_POINTF *buffer, unsigned long length)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsOptionSelected(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot, int index)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page, int index)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetFormFieldExportValue(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot)
#define FPDF_ANNOT_SQUARE
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, FPDF_BYTESTRING key, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFormControlIndex(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
#define FPDF_ANNOT_FREETEXT
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetNumberValue(FPDF_ANNOTATION annot, FPDF_BYTESTRING key, float *value)
#define FPDF_ANNOT_AACTION_FORMAT
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
#define FPDF_ANNOT_AACTION_VALIDATE
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetURI(FPDF_ANNOTATION annot, const char *uri)
#define FPDF_ANNOT_AACTION_CALCULATE
#define FPDF_ANNOT_APPEARANCEMODE_DOWN
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, FPDF_WCHAR *buffer, unsigned long buflen)
#define FPDF_ANNOT_FLAG_NONE
#define FPDF_FORMFLAG_NONE
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, FS_RECTF *rect)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetAP(FPDF_ANNOTATION annot, FPDF_ANNOT_APPEARANCEMODE appearanceMode, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype)
#define FPDF_ANNOT_REDACT
#define FPDF_ANNOT_POLYGON
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot, FS_POINTF *start, FS_POINTF *end)
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page, FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, const FS_POINTF *point)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot)
@ FPDFANNOT_COLORTYPE_InteriorColor
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetBorder(FPDF_ANNOTATION annot, float horizontal_radius, float vertical_radius, float border_width)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj)
#define FPDF_ANNOT_AACTION_KEY_STROKE
#define FPDF_ANNOT_CIRCLE
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetColor(FPDF_ANNOTATION annot, FPDFANNOT_COLORTYPE type, unsigned int R, unsigned int G, unsigned int B, unsigned int A)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj)
#define FPDF_ANNOT_PRINTERMARK
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, int event, FPDF_WCHAR *buffer, unsigned long buflen)
#define FPDF_ANNOT_POLYLINE
#define FPDF_OBJECT_STREAM
#define FPDF_OBJECT_REFERENCE
#define FPDF_OBJECT_NUMBER
#define FPDF_OBJECT_NULLOBJ
#define FPDF_OBJECT_BOOLEAN
#define FPDF_OBJECT_UNKNOWN
#define FPDF_OBJECT_STRING
#define FPDF_OBJECT_ARRAY
#define FPDF_OBJECT_DICTIONARY
CFX_Color CFXColorFromArray(const CPDF_Array &array)