5#include "public/fpdf_annot.h"
13#include "constants/annotation_common.h"
14#include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h"
15#include "core/fpdfapi/page/cpdf_annotcontext.h"
16#include "core/fpdfapi/page/cpdf_form.h"
17#include "core/fpdfapi/page/cpdf_page.h"
18#include "core/fpdfapi/page/cpdf_pageobject.h"
19#include "core/fpdfapi/parser/cpdf_array.h"
20#include "core/fpdfapi/parser/cpdf_boolean.h"
21#include "core/fpdfapi/parser/cpdf_dictionary.h"
22#include "core/fpdfapi/parser/cpdf_document.h"
23#include "core/fpdfapi/parser/cpdf_name.h"
24#include "core/fpdfapi/parser/cpdf_number.h"
25#include "core/fpdfapi/parser/cpdf_reference.h"
26#include "core/fpdfapi/parser/cpdf_stream.h"
27#include "core/fpdfapi/parser/cpdf_string.h"
28#include "core/fpdfapi/parser/fpdf_parser_utility.h"
29#include "core/fpdfdoc/cpdf_annot.h"
30#include "core/fpdfdoc/cpdf_color_utils.h"
31#include "core/fpdfdoc/cpdf_formfield.h"
32#include "core/fpdfdoc/cpdf_generateap.h"
33#include "core/fpdfdoc/cpdf_interactiveform.h"
34#include "core/fxcrt/check.h"
35#include "core/fxcrt/containers/contains.h"
36#include "core/fxcrt/fx_safe_types.h"
37#include "core/fxcrt/fx_string_wrappers.h"
38#include "core/fxcrt/numerics/safe_conversions.h"
39#include "core/fxcrt/ptr_util.h"
40#include "core/fxcrt/stl_util.h"
41#include "core/fxge/cfx_color.h"
42#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
43#include "fpdfsdk/cpdfsdk_helpers.h"
44#include "fpdfsdk/cpdfsdk_interactiveform.h"
52 "CPDF_Annot::UNKNOWN value mismatch");
54 "CPDF_Annot::TEXT value mismatch");
56 "CPDF_Annot::LINK value mismatch");
59 "CPDF_Annot::FREETEXT value mismatch");
61 "CPDF_Annot::LINE value mismatch");
64 "CPDF_Annot::SQUARE value mismatch");
67 "CPDF_Annot::CIRCLE value mismatch");
70 "CPDF_Annot::POLYGON value mismatch");
73 "CPDF_Annot::POLYLINE value mismatch");
76 "CPDF_Annot::HIGHLIGHT value mismatch");
79 "CPDF_Annot::UNDERLINE value mismatch");
82 "CPDF_Annot::SQUIGGLY value mismatch");
85 "CPDF_Annot::STRIKEOUT value mismatch");
87 "CPDF_Annot::STAMP value mismatch");
89 "CPDF_Annot::CARET value mismatch");
91 "CPDF_Annot::INK value mismatch");
93 "CPDF_Annot::POPUP value mismatch");
96 "CPDF_Annot::FILEATTACHMENT value mismatch");
98 "CPDF_Annot::SOUND value mismatch");
100 "CPDF_Annot::MOVIE value mismatch");
103 "CPDF_Annot::WIDGET value mismatch");
106 "CPDF_Annot::SCREEN value mismatch");
109 "CPDF_Annot::PRINTERMARK value mismatch");
112 "CPDF_Annot::TRAPNET value mismatch");
115 "CPDF_Annot::WATERMARK value mismatch");
118 "CPDF_Annot::THREED value mismatch");
121 "CPDF_Annot::RICHMEDIA value mismatch");
124 "CPDF_Annot::XFAWIDGET value mismatch");
127 "CPDF_Annot::REDACT value mismatch");
133 "CPDF_Annot::AppearanceMode::Normal value mismatch");
136 "CPDF_Annot::AppearanceMode::Rollover value mismatch");
139 "CPDF_Annot::AppearanceMode::Down value mismatch");
145 "CPDF_Object::kBoolean value mismatch");
148 "CPDF_Object::kNumber value mismatch");
151 "CPDF_Object::kString value mismatch");
153 "CPDF_Object::kName value mismatch");
155 "CPDF_Object::kArray value mismatch");
158 "CPDF_Object::kDictionary value mismatch");
161 "CPDF_Object::kStream value mismatch");
164 "CPDF_Object::kNullobj value mismatch");
167 "CPDF_Object::kReference value mismatch");
173 "CPDF_AAction::kKeyStroke value mismatch");
176 "CPDF_AAction::kFormat value mismatch");
179 "CPDF_AAction::kValidate value mismatch");
182 "CPDF_AAction::kCalculate value mismatch");
188void UpdateContentStream(CPDF_Form* pForm, CPDF_Stream* pStream) {
193 fxcrt::ostringstream buf;
194 generator.ProcessPageObjects(&buf);
195 pStream->SetDataFromStringstreamAndRemoveFilter(&buf);
200 const FS_QUADPOINTSF* quad_points) {
203 DCHECK(IsValidQuadPointsIndex(array, quad_index));
205 size_t nIndex = quad_index * 8;
206 array->SetNewAt<CPDF_Number>(nIndex, quad_points->x1);
207 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y1);
208 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->x2);
209 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y2);
210 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->x3);
211 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y3);
212 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->x4);
213 array->SetNewAt<CPDF_Number>(++nIndex, quad_points->y4);
216void AppendQuadPoints(
CPDF_Array* array,
const FS_QUADPOINTSF* quad_points) {
220 array->AppendNew<CPDF_Number>(quad_points->x1);
221 array->AppendNew<CPDF_Number>(quad_points->y1);
222 array->AppendNew<CPDF_Number>(quad_points->x2);
223 array->AppendNew<CPDF_Number>(quad_points->y2);
224 array->AppendNew<CPDF_Number>(quad_points->x3);
225 array->AppendNew<CPDF_Number>(quad_points->y3);
226 array->AppendNew<CPDF_Number>(quad_points->x4);
227 array->AppendNew<CPDF_Number>(quad_points->y4);
235 GetAnnotAP(annot_dict, CPDF_Annot::AppearanceMode::kNormal);
239 if (boundingRect.Contains(pStream->GetDict()->GetRectFor(
"BBox")))
240 pStream->GetMutableDict()->SetRectFor(
"BBox", boundingRect);
245 const FPDF_ANNOTATION annot) {
251 FPDF_ANNOTATION annot) {
253 return context ? context->GetMutableAnnotDict() :
nullptr;
264 pGSDict->SetNewFor<CPDF_Name>(
"Type",
"ExtGState");
270 pGSDict->SetNewFor<CPDF_Number>(
"CA", fOpacity);
274 pGSDict->SetNewFor<CPDF_Number>(
"ca", fOpacity);
279 pGSDict->SetNewFor<CPDF_Boolean>(
"AIS",
false);
282 pGSDict->SetNewFor<CPDF_Name>(
"BM", sBlendMode);
284 auto pExtGStateDict =
287 pExtGStateDict->SetFor(
"GS", pGSDict);
290 pResourceDict->SetFor(
"ExtGState", pExtGStateDict);
291 return pResourceDict;
294CPDF_FormField* GetFormField(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot) {
295 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
308const CPDFSDK_Widget* GetWidgetOfTypes(
309 FPDF_FORMHANDLE hHandle,
310 FPDF_ANNOTATION annot,
311 pdfium::span<
const CPDF_FormField::Type> allowed_types) {
312 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
328 if (!allowed_types.empty()) {
335 return form_control ? form
->GetWidget(form_control
) :
nullptr;
338const CPDFSDK_Widget* GetRadioButtonOrCheckBoxWidget(FPDF_FORMHANDLE handle,
339 FPDF_ANNOTATION annot) {
342 return GetWidgetOfTypes(handle, annot, kAllowedTypes);
350 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
395 pAnnotList->Append(pDict);
398 return FPDFAnnotationFromCPDFAnnotContext(pNewAnnot.release());
407 return pAnnots ?
fxcrt::CollectionSize<
int>(*pAnnots) : 0;
413 if (!pPage || index < 0)
417 if (!pAnnots ||
static_cast<size_t>(index) >= pAnnots->size())
421 ToDictionary(pAnnots->GetMutableDirectObjectAt(index));
429 return FPDFAnnotationFromCPDFAnnotContext(pNewAnnot.release());
433 FPDF_ANNOTATION annot) {
438 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
447 auto it =
std::find_if(locker.begin(), locker.end(),
449 return candidate->GetDirect() == pAnnotDict;
452 if (it == locker.end())
455 return pdfium::checked_cast<
int>(it - locker.begin());
465 if (!pPage || index < 0)
469 if (!pAnnots ||
static_cast<size_t>(index) >= pAnnots->size())
472 pAnnots->RemoveAt(index);
478 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
507 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
513 if (!
pdfium::Contains(*pForm,
fxcrt::MakeFakeUniquePtr(pObj)))
517 UpdateContentStream(pForm, pStream.Get());
522 const FS_POINTF* points,
523 size_t point_count) {
526 !
pdfium::IsValueInRangeForNumericType<int32_t>(point_count)) {
531 GetMutableAnnotDictFromFPDFAnnotation(annot);
533 FX_SAFE_SIZE_T safe_ink_size = inklist->size();
535 if (!safe_ink_size.IsValid<int32_t>())
540 auto ink_coord_list = inklist->AppendNew<
CPDF_Array>();
541 for (
const auto& point : points_span) {
542 ink_coord_list->AppendNew<CPDF_Number>(point.x);
543 ink_coord_list->AppendNew<CPDF_Number>(point.y);
545 return static_cast<
int>(inklist->size() - 1);
554 CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict();
555 annot_dict->RemoveFor(
"InkList");
563 if (!pAnnot || !pObj)
573 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
592 if (
pdfium::Contains(*pForm,
fxcrt::MakeFakeUniquePtr(pObj)))
596 pForm->AppendPageObject(
pdfium::WrapUnique(pObj));
599 UpdateContentStream(pForm, pStream.Get());
611 GetAnnotAP(pDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
623 if (!pAnnot || index < 0)
629 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
636 return FPDFPageObjectFromCPDFPageObject(
654 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
658 if (!pAnnot
->GetForm()->ErasePageObjectAtIndex(index))
661 UpdateContentStream(pAnnot
->GetForm(), pStream.Get());
666 FPDFANNOT_COLORTYPE type,
672 GetMutableAnnotDictFromFPDFAnnotation(annot);
674 if (!pAnnotDict || R > 255 || G > 255 || B > 255 || A > 255)
680 if (HasAPStream(pAnnotDict.Get()))
684 pAnnotDict->SetNewFor<CPDF_Number>(
"CA", A / 255.f);
692 pColor = pAnnotDict->SetNewFor<
CPDF_Array>(key);
694 pColor->AppendNew<CPDF_Number>(R / 255.f);
695 pColor->AppendNew<CPDF_Number>(G / 255.f);
696 pColor->AppendNew<CPDF_Number>(B / 255.f);
702 FPDFANNOT_COLORTYPE type,
708 GetMutableAnnotDictFromFPDFAnnotation(annot);
710 if (!pAnnotDict || !R || !G || !B || !A)
716 if (HasAPStream(pAnnotDict.Get()))
720 type == FPDFANNOT_COLORTYPE_InteriorColor ?
"IC" :
"C");
721 *A = (pAnnotDict->KeyExist(
"CA") ? pAnnotDict->GetFloatFor(
"CA") : 1) * 255.f;
778 const FS_QUADPOINTSF* quad_points) {
783 CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict();
785 GetMutableQuadPointsArrayFromDictionary(pAnnotDict.Get());
786 if (!IsValidQuadPointsIndex(pQuadPointsArray.Get(), quad_index))
789 SetQuadPointsAtIndex(pQuadPointsArray.Get(), quad_index, quad_points);
790 UpdateBBox(pAnnotDict.Get());
796 const FS_QUADPOINTSF* quad_points) {
801 CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict();
803 GetMutableQuadPointsArrayFromDictionary(pAnnotDict.Get());
804 if (!pQuadPointsArray)
805 pQuadPointsArray = AddQuadPointsArrayToDictionary(pAnnotDict.Get());
806 AppendQuadPoints(pQuadPointsArray.Get(), quad_points);
807 UpdateBBox(pAnnotDict.Get());
819 GetQuadPointsArrayFromDictionary(pAnnotDict);
820 return pArray ? pArray->size() / 8 : 0;
826 FS_QUADPOINTSF* quad_points) {
833 GetQuadPointsArrayFromDictionary(pAnnotDict);
837 return GetQuadPointsAtIndex(std::move(pArray), quad_index, quad_points);
841 const FS_RECTF* rect) {
843 GetMutableAnnotDictFromFPDFAnnotation(annot);
844 if (!pAnnotDict || !rect)
861 GetAnnotAP(pAnnotDict.Get(), CPDF_Annot::AppearanceMode::kNormal);
862 if (pStream && newRect.Contains(pStream->GetDict()->GetRectFor(
"BBox")))
863 pStream->GetMutableDict()->SetRectFor(
"BBox", newRect);
869 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
870 if (!pAnnotDict || !rect)
881 unsigned long length) {
886 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
891 annot_dict->GetArrayFor(pdfium::annotation::kVertices);
896 const unsigned long points_len =
897 fxcrt::CollectionSize<
unsigned long>(*vertices) / 2;
898 if (buffer && length >= points_len) {
901 for (
unsigned long i = 0; i < points_len; ++i) {
902 buffer_span[i].x = vertices->GetFloatAt(i * 2);
903 buffer_span[i].y = vertices->GetFloatAt(i * 2 + 1);
912 return ink_list ?
fxcrt::CollectionSize<
unsigned long>(*ink_list) : 0;
917 unsigned long path_index,
919 unsigned long length) {
929 const unsigned long points_len =
930 fxcrt::CollectionSize<
unsigned long>(*path) / 2;
931 if (buffer && length >= points_len) {
934 for (
unsigned long i = 0; i < points_len; ++i) {
935 buffer_span[i].x = path->GetFloatAt(i * 2);
936 buffer_span[i].y = path->GetFloatAt(i * 2 + 1);
952 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
957 annot_dict->GetArrayFor(pdfium::annotation::kL);
958 if (!line || line->size() < 4)
961 start->x = line->GetFloatAt(0);
962 start->y = line->GetFloatAt(1);
963 end->x = line->GetFloatAt(2);
964 end->y = line->GetFloatAt(3);
969 float horizontal_radius,
970 float vertical_radius,
971 float border_width) {
973 GetMutableAnnotDictFromFPDFAnnotation(annot);
982 border->AppendNew<CPDF_Number>(horizontal_radius);
983 border->AppendNew<CPDF_Number>(vertical_radius);
984 border->AppendNew<CPDF_Number>(border_width);
990 float* horizontal_radius,
991 float* vertical_radius,
992 float* border_width) {
993 if (!horizontal_radius || !vertical_radius || !border_width)
996 const CPDF_Dictionary* annot_dict = GetAnnotDictFromFPDFAnnotation(annot);
1001 annot_dict->GetArrayFor(pdfium::annotation::kBorder);
1002 if (!border || border->size() < 3)
1005 *horizontal_radius = border->GetFloatAt(0);
1006 *vertical_radius = border->GetFloatAt(1);
1007 *border_width = border->GetFloatAt(2);
1012 FPDF_BYTESTRING key) {
1013 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1029 FPDF_BYTESTRING key,
1030 FPDF_WIDESTRING value) {
1032 GetMutableAnnotDictFromFPDFAnnotation(annot);
1037 pAnnotDict->SetNewFor<CPDF_String>(
1044 FPDF_BYTESTRING key,
1046 unsigned long buflen) {
1047 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1052 return Utf16EncodeMaybeCopyAndReturnLength(
1053 pAnnotDict->GetUnicodeTextFor(key),
1059 FPDF_BYTESTRING key,
1064 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1072 *value = p->GetNumber();
1078 FPDF_ANNOT_APPEARANCEMODE appearanceMode,
1079 FPDF_WIDESTRING value) {
1081 GetMutableAnnotDictFromFPDFAnnotation(annot);
1088 static constexpr auto kModeKeyForMode =
1089 fxcrt::ToArray<
const char*>({
"N",
"R",
"D"});
1091 "length of kModeKeyForMode should be equal to "
1092 "FPDF_ANNOT_APPEARANCEMODE_COUNT");
1094 const char* mode_key = kModeKeyForMode[appearanceMode];
1097 pAnnotDict->GetMutableDictFor(pdfium::annotation::kAP);
1105 pApDict->RemoveFor(mode_key);
1116 constexpr float kMinSize = 0.000001f;
1131 stream_dict->SetRectFor(
"BBox", rect);
1136 if (pAnnotDict->KeyExist(
"CA") && pAnnotDict->GetFloatFor(
"CA") < 1.0f) {
1137 stream_dict->SetFor(
"Resources", SetExtGStateInResourceDict(
1138 pDoc, pAnnotDict.Get(),
"Normal"));
1143 auto new_stream = pDoc->NewIndirect<CPDF_Stream>(
std::move(stream_dict));
1144 new_stream->SetData(new_stream_data.unsigned_span());
1150 pApDict->SetNewFor<CPDF_Reference>(mode_key, pDoc, new_stream->GetObjNum());
1157 FPDF_ANNOT_APPEARANCEMODE appearanceMode,
1159 unsigned long buflen) {
1161 GetMutableAnnotDictFromFPDFAnnotation(annot);
1171 RetainPtr<CPDF_Stream> pStream = GetAnnotAPNoFallback(pAnnotDict.Get(), mode);
1173 return Utf16EncodeMaybeCopyAndReturnLength(
1174 pStream ? pStream->GetUnicodeText() : WideString(),
1185 pAnnot->GetMutableAnnotDict()->GetMutableDictFor(key);
1186 if (!pLinkedDict || pLinkedDict->GetNameFor(
"Type") !=
"Annot")
1193 return FPDFAnnotationFromCPDFAnnotContext(pLinkedAnnot.release());
1197 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1205 GetMutableAnnotDictFromFPDFAnnotation(annot);
1222 const FS_POINTF* point) {
1235 int annot_index = -1;
1237 pPage
, CFXPointFFromFSPointF(*point)
, &annot_index
);
1238 if (!pFormCtrl || annot_index == -1)
1245 FPDF_ANNOTATION annot,
1247 unsigned long buflen) {
1253 return Utf16EncodeMaybeCopyAndReturnLength(
1254 pFormField->GetFullName(),
1266 FPDF_ANNOTATION annot,
1269 unsigned long buflen) {
1283 return Utf16EncodeMaybeCopyAndReturnLength(
1284 action.GetJavaScript(),
1290 FPDF_ANNOTATION annot,
1292 unsigned long buflen) {
1298 return Utf16EncodeMaybeCopyAndReturnLength(
1299 pFormField->GetAlternateName(),
1305 FPDF_ANNOTATION annot,
1307 unsigned long buflen) {
1313 return Utf16EncodeMaybeCopyAndReturnLength(
1314 pFormField->GetValue(),
1319 FPDF_ANNOTATION annot) {
1326 FPDF_ANNOTATION annot,
1329 unsigned long buflen) {
1338 return Utf16EncodeMaybeCopyAndReturnLength(
1339 pFormField->GetOptionLabel(index),
1345 FPDF_ANNOTATION annot,
1367 FPDF_ANNOTATION annot,
1373 const CPDFSDK_Widget* widget = GetWidgetOfTypes(hHandle, annot, {});
1384 FPDF_ANNOTATION annot,
1388 if (!R || !G || !B) {
1392 const CPDFSDK_Widget* widget = GetWidgetOfTypes(hHandle, annot, {});
1402 *R = FXSYS_GetRValue(*text_color);
1403 *G = FXSYS_GetGValue(*text_color);
1404 *B = FXSYS_GetBValue(*text_color);
1409 FPDF_ANNOTATION annot) {
1410 const CPDFSDK_Widget* pWidget =
1411 GetRadioButtonOrCheckBoxWidget(hHandle, annot);
1417 const FPDF_ANNOTATION_SUBTYPE* subtypes,
1419 CPDFSDK_FormFillEnvironment* pFormFillEnv =
1424 if (count > 0 && !subtypes)
1429 std::vector<CPDF_Annot::Subtype> focusable_annot_types;
1430 focusable_annot_types.reserve(count);
1431 for (size_t i = 0; i < count; ++i) {
1432 focusable_annot_types.push_back(
1436 pFormFillEnv->SetFocusableAnnotSubtypes(focusable_annot_types);
1442 CPDFSDK_FormFillEnvironment* pFormFillEnv =
1447 return fxcrt::CollectionSize<
int>(pFormFillEnv->GetFocusableAnnotSubtypes());
1452 FPDF_ANNOTATION_SUBTYPE* subtypes,
1454 CPDFSDK_FormFillEnvironment* pFormFillEnv =
1462 const std::vector<CPDF_Annot::Subtype>& focusable_annot_types =
1463 pFormFillEnv->GetFocusableAnnotSubtypes();
1467 if (count < focusable_annot_types.size())
1472 for (size_t i = 0; i < focusable_annot_types.size(); ++i) {
1474 static_cast<FPDF_ANNOTATION_SUBTYPE>(focusable_annot_types[i]);
1484 return FPDFLinkFromCPDFDictionary(
1496 const CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
1512 FPDF_ANNOTATION annot,
1514 unsigned long buflen) {
1515 const CPDFSDK_Widget* pWidget =
1516 GetRadioButtonOrCheckBoxWidget(hHandle, annot);
1521 return Utf16EncodeMaybeCopyAndReturnLength(
1522 pWidget->GetExportValue(),
1523 UNSAFE_TODO(SpanFromFPDFApiArgs(buffer, buflen)));
1532 GetMutableAnnotDictFromFPDFAnnotation(annot);
1534 action->SetNewFor<CPDF_Name>(
"Type",
"Action");
1535 action->SetNewFor<CPDF_Name>(
"S",
"URI");
1536 action->SetNewFor<CPDF_String>(
"URI", uri);
1547 GetMutableAnnotDictFromFPDFAnnotation(annot);
1552 return FPDFAttachmentFromCPDFObject(
1553 annot_dict->GetMutableDirectObjectFor(
"FS"));
1574 if (ws_name.IsEmpty()) {
1581 fs_obj->SetNewFor<CPDF_Name>(
"Type",
"Filespec");
1582 fs_obj->SetNewFor<CPDF_String>(
"UF", ws_name.AsStringView());
1583 fs_obj->SetNewFor<CPDF_String>(
"F", ws_name.AsStringView());
1585 annot_dict->SetNewFor<CPDF_Reference>(
"FS", doc, fs_obj->GetObjNum());
1586 return FPDFAttachmentFromCPDFObject(fs_obj);
fxcrt::ByteString ByteString
CPDF_Action GetAction(AActionType eType) 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)
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
bool KeyExist(const ByteString &key) const
int GetIntegerFor(const ByteString &key) const
float GetFloatFor(const ByteString &key) const
RetainPtr< const CPDF_Array > GetArrayFor(const ByteString &key) const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
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
#define UNSAFE_BUFFERS(...)
UNSAFE_BUFFER_USAGE WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string)
IPDF_Page * IPDFPageFromFPDFPage(FPDF_PAGE page)
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 FPDF_ATTACHMENT FPDF_CALLCONV FPDFAnnot_AddFileAttachment(FPDF_ANNOTATION annot, FPDF_WIDESTRING name)
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_GetFontColor(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, unsigned int *R, unsigned int *G, unsigned int *B)
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_ATTACHMENT FPDF_CALLCONV FPDFAnnot_GetFileAttachment(FPDF_ANNOTATION annot)
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)
fxcrt::WideString WideString