* external/libhpdf/Makefile
+ Enabled for all dos platforms (dos/watcom currently and
probably all dos builds done on MS-DOS hosts).
+ external/libhpdf/ori_dst
+ external/libhpdf/ori_src
+ external/libhpdf/cnv_hb2o.bat
+ external/libhpdf/cnv_o2hb.bat
- external/libhpdf/hpdf_annotation.c
- external/libhpdf/hpdf_annotation.h
- external/libhpdf/hpdf_array.c
- external/libhpdf/hpdf_binary.c
- external/libhpdf/hpdf_boolean.c
- external/libhpdf/hpdf_catalog.c
- external/libhpdf/hpdf_catalog.h
- external/libhpdf/hpdf_conf.h
- external/libhpdf/hpdf_config.h
- external/libhpdf/hpdf_consts.h
- external/libhpdf/hpdf_destination.c
- external/libhpdf/hpdf_destination.h
- external/libhpdf/hpdf_dict.c
- external/libhpdf/hpdf_doc.c
- external/libhpdf/hpdf_doc.h
- external/libhpdf/hpdf_doc_png.c
- external/libhpdf/hpdf_encoder.c
- external/libhpdf/hpdf_encoder.h
- external/libhpdf/hpdf_encoder_cns.c
- external/libhpdf/hpdf_encoder_cnt.c
- external/libhpdf/hpdf_encoder_jp.c
- external/libhpdf/hpdf_encoder_kr.c
- external/libhpdf/hpdf_encrypt.c
- external/libhpdf/hpdf_encrypt.h
- external/libhpdf/hpdf_encryptdict.c
- external/libhpdf/hpdf_encryptdict.h
- external/libhpdf/hpdf_error.c
- external/libhpdf/hpdf_error.h
- external/libhpdf/hpdf_ext_gstate.c
- external/libhpdf/hpdf_ext_gstate.h
- external/libhpdf/hpdf_font.c
- external/libhpdf/hpdf_font.h
- external/libhpdf/hpdf_font_cid.c
- external/libhpdf/hpdf_font_tt.c
- external/libhpdf/hpdf_font_type1.c
- external/libhpdf/hpdf_fontdef.c
- external/libhpdf/hpdf_fontdef.h
- external/libhpdf/hpdf_fontdef_base14.c
- external/libhpdf/hpdf_fontdef_cid.c
- external/libhpdf/hpdf_fontdef_cns.c
- external/libhpdf/hpdf_fontdef_cnt.c
- external/libhpdf/hpdf_fontdef_jp.c
- external/libhpdf/hpdf_fontdef_kr.c
- external/libhpdf/hpdf_fontdef_tt.c
- external/libhpdf/hpdf_fontdef_type1.c
- external/libhpdf/hpdf_gstate.c
- external/libhpdf/hpdf_gstate.h
- external/libhpdf/hpdf_image.c
- external/libhpdf/hpdf_image.h
- external/libhpdf/hpdf_image_png.c
- external/libhpdf/hpdf_info.c
- external/libhpdf/hpdf_info.h
- external/libhpdf/hpdf_list.c
- external/libhpdf/hpdf_list.h
- external/libhpdf/hpdf_mmgr.c
- external/libhpdf/hpdf_mmgr.h
- external/libhpdf/hpdf_name.c
- external/libhpdf/hpdf_null.c
- external/libhpdf/hpdf_number.c
- external/libhpdf/hpdf_objects.c
- external/libhpdf/hpdf_objects.h
- external/libhpdf/hpdf_outline.c
- external/libhpdf/hpdf_outline.h
- external/libhpdf/hpdf_page_label.c
- external/libhpdf/hpdf_page_label.h
- external/libhpdf/hpdf_page_operator.c
- external/libhpdf/hpdf_pages.c
- external/libhpdf/hpdf_pages.h
- external/libhpdf/hpdf_real.c
- external/libhpdf/hpdf_streams.c
- external/libhpdf/hpdf_streams.h
- external/libhpdf/hpdf_string.c
- external/libhpdf/hpdf_types.h
- external/libhpdf/hpdf_u3d.c
- external/libhpdf/hpdf_u3d.h
- external/libhpdf/hpdf_utils.c
- external/libhpdf/hpdf_utils.h
- external/libhpdf/hpdf_version.h
- external/libhpdf/hpdf_xref.c
+ external/libhpdf/hpdfanno.c
+ external/libhpdf/hpdfanno.h
+ external/libhpdf/hpdfarra.c
+ external/libhpdf/hpdfbina.c
+ external/libhpdf/hpdfbool.c
+ external/libhpdf/hpdfcata.c
+ external/libhpdf/hpdfcata.h
+ external/libhpdf/hpdfcfg.h
+ external/libhpdf/hpdfconf.h
+ external/libhpdf/hpdfcons.h
+ external/libhpdf/hpdfdest.c
+ external/libhpdf/hpdfdest.h
+ external/libhpdf/hpdfdict.c
+ external/libhpdf/hpdfdoc.c
+ external/libhpdf/hpdfdoc.h
+ external/libhpdf/hpdfdocp.c
+ external/libhpdf/hpdfecy.c
+ external/libhpdf/hpdfecyd.c
+ external/libhpdf/hpdfencc.c
+ external/libhpdf/hpdfencj.c
+ external/libhpdf/hpdfenck.c
+ external/libhpdf/hpdfencn.c
+ external/libhpdf/hpdfenco.c
+ external/libhpdf/hpdfenco.h
+ external/libhpdf/hpdfencr.h
+ external/libhpdf/hpdfency.h
+ external/libhpdf/hpdferro.c
+ external/libhpdf/hpdferro.h
+ external/libhpdf/hpdfextg.c
+ external/libhpdf/hpdfextg.h
+ external/libhpdf/hpdffdf.c
+ external/libhpdf/hpdffdf1.c
+ external/libhpdf/hpdffdfb.c
+ external/libhpdf/hpdffdfc.c
+ external/libhpdf/hpdffdfi.c
+ external/libhpdf/hpdffdfj.c
+ external/libhpdf/hpdffdfk.c
+ external/libhpdf/hpdffdfn.c
+ external/libhpdf/hpdffdft.c
+ external/libhpdf/hpdffon1.c
+ external/libhpdf/hpdffonc.c
+ external/libhpdf/hpdffond.h
+ external/libhpdf/hpdffont.c
+ external/libhpdf/hpdffont.h
+ external/libhpdf/hpdffott.c
+ external/libhpdf/hpdfgsta.c
+ external/libhpdf/hpdfgsta.h
+ external/libhpdf/hpdfimag.c
+ external/libhpdf/hpdfimag.h
+ external/libhpdf/hpdfimap.c
+ external/libhpdf/hpdfinfo.c
+ external/libhpdf/hpdfinfo.h
+ external/libhpdf/hpdflist.c
+ external/libhpdf/hpdflist.h
+ external/libhpdf/hpdfmmgr.c
+ external/libhpdf/hpdfmmgr.h
+ external/libhpdf/hpdfname.c
+ external/libhpdf/hpdfnull.c
+ external/libhpdf/hpdfnumb.c
+ external/libhpdf/hpdfobje.c
+ external/libhpdf/hpdfobje.h
+ external/libhpdf/hpdfoutl.c
+ external/libhpdf/hpdfoutl.h
+ external/libhpdf/hpdfpage.c
+ external/libhpdf/hpdfpage.h
+ external/libhpdf/hpdfpago.c
+ external/libhpdf/hpdfpags.c
+ external/libhpdf/hpdfpags.h
+ external/libhpdf/hpdfreal.c
+ external/libhpdf/hpdfstre.c
+ external/libhpdf/hpdfstre.h
+ external/libhpdf/hpdfstri.c
+ external/libhpdf/hpdftype.h
+ external/libhpdf/hpdfu3d.c
+ external/libhpdf/hpdfu3d.h
+ external/libhpdf/hpdfutil.c
+ external/libhpdf/hpdfutil.h
+ external/libhpdf/hpdfvers.h
+ external/libhpdf/hpdfxref.c
* external/libhpdf/hpdf.h
* external/libhpdf/Makefile
* Converted to short filenames. Added converted scripts.
* source/hbpcre/cnv_hb2o.bat
* source/hbpcre/cnv_o2hb.bat
! Fixed typo in prev.
* Removed PCRE references from comment texts.
501 lines
13 KiB
C
501 lines
13 KiB
C
/*
|
|
* << Haru Free PDF Library >> -- hpdf_annotation.c
|
|
*
|
|
* URL: http://libharu.org
|
|
*
|
|
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
|
|
* Copyright (c) 2007-2008 Antony Dovgal <tony@daylessday.org>
|
|
*
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
* provided that the above copyright notice appear in all copies and
|
|
* that both that copyright notice and this permission notice appear
|
|
* in supporting documentation.
|
|
* It is provided "as is" without express or implied warranty.
|
|
*
|
|
*/
|
|
|
|
#include "hpdfconf.h"
|
|
#include "hpdfutil.h"
|
|
#include "hpdfanno.h"
|
|
#include "hpdf.h"
|
|
|
|
const static char *HPDF_ANNOT_TYPE_NAMES[] = {
|
|
"Text",
|
|
"Link",
|
|
"Sound",
|
|
"FreeText",
|
|
"Stamp",
|
|
"Square",
|
|
"Circle",
|
|
"StrikeOut",
|
|
"Highlight",
|
|
"Underline",
|
|
"Ink",
|
|
"FileAttachment",
|
|
"Popup",
|
|
"3D"
|
|
};
|
|
|
|
const static char *HPDF_ANNOT_ICON_NAMES_NAMES[] = {
|
|
"Comment",
|
|
"Key",
|
|
"Note",
|
|
"Help",
|
|
"NewParagraph",
|
|
"Paragraph",
|
|
"Insert"
|
|
};
|
|
|
|
|
|
static HPDF_BOOL
|
|
CheckSubType (HPDF_Annotation annot,
|
|
HPDF_AnnotType type);
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/*------ HPDF_Annotation -----------------------------------------------------*/
|
|
|
|
|
|
HPDF_Annotation
|
|
HPDF_Annotation_New (HPDF_MMgr mmgr,
|
|
HPDF_Xref xref,
|
|
HPDF_AnnotType type,
|
|
HPDF_Rect rect)
|
|
{
|
|
HPDF_Annotation annot;
|
|
HPDF_Array array;
|
|
HPDF_STATUS ret = HPDF_OK;
|
|
HPDF_REAL tmp;
|
|
|
|
HPDF_PTRACE((" HPDF_Annotation_New\n"));
|
|
|
|
annot = HPDF_Dict_New (mmgr);
|
|
if (!annot)
|
|
return NULL;
|
|
|
|
if (HPDF_Xref_Add (xref, annot) != HPDF_OK)
|
|
return NULL;
|
|
|
|
array = HPDF_Array_New (mmgr);
|
|
if (!array)
|
|
return NULL;
|
|
|
|
if (HPDF_Dict_Add (annot, "Rect", array) != HPDF_OK)
|
|
return NULL;
|
|
|
|
if (rect.top < rect.bottom) {
|
|
tmp = rect.top;
|
|
rect.top = rect.bottom;
|
|
rect.bottom = tmp;
|
|
}
|
|
|
|
ret += HPDF_Array_AddReal (array, rect.left);
|
|
ret += HPDF_Array_AddReal (array, rect.bottom);
|
|
ret += HPDF_Array_AddReal (array, rect.right);
|
|
ret += HPDF_Array_AddReal (array, rect.top);
|
|
|
|
ret += HPDF_Dict_AddName (annot, "Type", "Annot");
|
|
ret += HPDF_Dict_AddName (annot, "Subtype",
|
|
HPDF_ANNOT_TYPE_NAMES[(HPDF_INT)type]);
|
|
|
|
if (ret != HPDF_OK)
|
|
return NULL;
|
|
|
|
annot->header.obj_class |= HPDF_OSUBCLASS_ANNOTATION;
|
|
|
|
return annot;
|
|
}
|
|
|
|
|
|
HPDF_STATUS
|
|
HPDF_Annotation_SetBorderStyle (HPDF_Annotation annot,
|
|
HPDF_BSSubtype subtype,
|
|
HPDF_REAL width,
|
|
HPDF_UINT16 dash_on,
|
|
HPDF_UINT16 dash_off,
|
|
HPDF_UINT16 dash_phase)
|
|
{
|
|
HPDF_Dict bs;
|
|
HPDF_Array dash;
|
|
HPDF_STATUS ret;
|
|
|
|
HPDF_PTRACE((" HPDF_Annotation_SetBoderStyle\n"));
|
|
|
|
bs = HPDF_Dict_New (annot->mmgr);
|
|
if (!bs)
|
|
return HPDF_Error_GetCode (annot->error);
|
|
|
|
if ((ret = HPDF_Dict_Add (annot, "BS", bs)) != HPDF_OK)
|
|
return ret;
|
|
|
|
if (subtype == HPDF_BS_DASHED) {
|
|
dash = HPDF_Array_New (annot->mmgr);
|
|
if (!dash)
|
|
return HPDF_Error_GetCode (annot->error);
|
|
|
|
if ((ret = HPDF_Dict_Add (bs, "D", dash)) != HPDF_OK)
|
|
return ret;
|
|
|
|
ret += HPDF_Dict_AddName (bs, "Type", "Border");
|
|
ret += HPDF_Array_AddReal (dash, dash_on);
|
|
ret += HPDF_Array_AddReal (dash, dash_off);
|
|
|
|
if (dash_phase != 0)
|
|
ret += HPDF_Array_AddReal (dash, dash_off);
|
|
}
|
|
|
|
switch (subtype) {
|
|
case HPDF_BS_SOLID:
|
|
ret += HPDF_Dict_AddName (bs, "S", "S");
|
|
break;
|
|
case HPDF_BS_DASHED:
|
|
ret += HPDF_Dict_AddName (bs, "S", "D");
|
|
break;
|
|
case HPDF_BS_BEVELED:
|
|
ret += HPDF_Dict_AddName (bs, "S", "B");
|
|
break;
|
|
case HPDF_BS_INSET:
|
|
ret += HPDF_Dict_AddName (bs, "S", "I");
|
|
break;
|
|
case HPDF_BS_UNDERLINED:
|
|
ret += HPDF_Dict_AddName (bs, "S", "U");
|
|
break;
|
|
default:
|
|
return HPDF_SetError (annot->error, HPDF_ANNOT_INVALID_BORDER_STYLE, 0);
|
|
}
|
|
|
|
if (width != HPDF_BS_DEF_WIDTH)
|
|
ret += HPDF_Dict_AddReal (bs, "W", width);
|
|
|
|
if (ret != HPDF_OK)
|
|
return HPDF_Error_GetCode (annot->error);
|
|
|
|
return HPDF_OK;
|
|
}
|
|
|
|
|
|
HPDF_Annotation
|
|
HPDF_LinkAnnot_New (HPDF_MMgr mmgr,
|
|
HPDF_Xref xref,
|
|
HPDF_Rect rect,
|
|
HPDF_Destination dst)
|
|
{
|
|
HPDF_Annotation annot;
|
|
|
|
HPDF_PTRACE((" HPDF_LinkAnnot_New\n"));
|
|
|
|
annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_LINK, rect);
|
|
if (!annot)
|
|
return NULL;
|
|
|
|
if (HPDF_Dict_Add (annot, "Dest", dst) != HPDF_OK)
|
|
return NULL;
|
|
|
|
return annot;
|
|
}
|
|
|
|
|
|
HPDF_Annotation
|
|
HPDF_URILinkAnnot_New (HPDF_MMgr mmgr,
|
|
HPDF_Xref xref,
|
|
HPDF_Rect rect,
|
|
const char *uri)
|
|
{
|
|
HPDF_Annotation annot;
|
|
HPDF_Dict action;
|
|
HPDF_STATUS ret;
|
|
|
|
HPDF_PTRACE((" HPDF_URILinkAnnot_New\n"));
|
|
|
|
annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_LINK, rect);
|
|
if (!annot)
|
|
return NULL;
|
|
|
|
/* create action dictionary */
|
|
action = HPDF_Dict_New (mmgr);
|
|
if (!action)
|
|
return NULL;
|
|
|
|
ret = HPDF_Dict_Add (annot, "A", action);
|
|
if (ret != HPDF_OK)
|
|
return NULL;
|
|
|
|
ret += HPDF_Dict_AddName (action, "Type", "Action");
|
|
ret += HPDF_Dict_AddName (action, "S", "URI");
|
|
ret += HPDF_Dict_Add (action, "URI", HPDF_String_New (mmgr, uri, NULL));
|
|
|
|
if (ret != HPDF_OK)
|
|
return NULL;
|
|
|
|
return annot;
|
|
}
|
|
|
|
HPDF_EXPORT(HPDF_STATUS)
|
|
HPDF_LinkAnnot_SetBorderStyle (HPDF_Annotation annot,
|
|
HPDF_REAL width,
|
|
HPDF_UINT16 dash_on,
|
|
HPDF_UINT16 dash_off)
|
|
{
|
|
HPDF_Array array;
|
|
HPDF_STATUS ret;
|
|
|
|
HPDF_PTRACE((" HPDF_LinkAnnot_SetBorderStyle\n"));
|
|
|
|
if (!CheckSubType (annot, HPDF_ANNOT_LINK))
|
|
return HPDF_INVALID_ANNOTATION;
|
|
|
|
if (width < 0)
|
|
return HPDF_RaiseError (annot->error, HPDF_INVALID_PARAMETER, 0);
|
|
|
|
array = HPDF_Array_New (annot->mmgr);
|
|
if (!array)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
if ((ret = HPDF_Dict_Add (annot, "Border", array)) != HPDF_OK)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
ret += HPDF_Array_AddNumber (array, 0);
|
|
ret += HPDF_Array_AddNumber (array, 0);
|
|
ret += HPDF_Array_AddReal (array, width);
|
|
|
|
if (ret != HPDF_OK)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
if (dash_on && dash_off) {
|
|
HPDF_Array dash = HPDF_Array_New (annot->mmgr);
|
|
if (!dash)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
if ((ret = HPDF_Array_Add (array, dash)) != HPDF_OK)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
ret += HPDF_Array_AddNumber (dash, dash_on);
|
|
ret += HPDF_Array_AddNumber (dash, dash_off);
|
|
}
|
|
|
|
if (ret != HPDF_OK)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
return ret;
|
|
}
|
|
|
|
HPDF_EXPORT(HPDF_STATUS)
|
|
HPDF_LinkAnnot_SetHighlightMode (HPDF_Annotation annot,
|
|
HPDF_AnnotHighlightMode mode)
|
|
{
|
|
HPDF_STATUS ret;
|
|
|
|
HPDF_PTRACE((" HPDF_LinkAnnot_SetHighlightMode\n"));
|
|
|
|
if (!CheckSubType (annot, HPDF_ANNOT_LINK))
|
|
return HPDF_INVALID_ANNOTATION;
|
|
|
|
switch (mode) {
|
|
case HPDF_ANNOT_NO_HIGHTLIGHT:
|
|
ret = HPDF_Dict_AddName (annot, "H", "N");
|
|
break;
|
|
case HPDF_ANNOT_INVERT_BORDER:
|
|
ret = HPDF_Dict_AddName (annot, "H", "O");
|
|
break;
|
|
case HPDF_ANNOT_DOWN_APPEARANCE:
|
|
ret = HPDF_Dict_AddName (annot, "H", "P");
|
|
break;
|
|
default: /* HPDF_ANNOT_INVERT_BOX */
|
|
/* default value */
|
|
HPDF_Dict_RemoveElement (annot, "H");
|
|
ret = HPDF_OK;
|
|
}
|
|
|
|
if (ret != HPDF_OK)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
HPDF_Annotation
|
|
HPDF_3DAnnot_New (HPDF_MMgr mmgr,
|
|
HPDF_Xref xref,
|
|
HPDF_Rect rect,
|
|
HPDF_U3D u3d)
|
|
{
|
|
HPDF_Annotation annot;
|
|
HPDF_Dict action, appearance, stream;
|
|
HPDF_STATUS ret;
|
|
|
|
HPDF_PTRACE((" HPDF_3DAnnot_New\n"));
|
|
|
|
annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_3D, rect);
|
|
if (!annot) {
|
|
return NULL;
|
|
}
|
|
|
|
HPDF_Dict_AddName (annot, "Contents", "3D Model");
|
|
|
|
action = HPDF_Dict_New (mmgr);
|
|
if (!action) {
|
|
return NULL;
|
|
}
|
|
|
|
ret = HPDF_Dict_Add (annot, "3DA", action);
|
|
if (ret != HPDF_OK) {
|
|
return NULL;
|
|
}
|
|
|
|
ret += HPDF_Dict_AddName (action, "A", "PV");
|
|
|
|
ret += HPDF_Dict_AddBoolean(action, "TB", HPDF_FALSE);
|
|
|
|
if (ret != HPDF_OK) {
|
|
return NULL;
|
|
}
|
|
|
|
if (HPDF_Dict_Add (annot, "3DD", u3d) != HPDF_OK) {
|
|
return NULL;
|
|
}
|
|
|
|
appearance = HPDF_Dict_New (mmgr);
|
|
if (!appearance) {
|
|
return NULL;
|
|
}
|
|
|
|
ret = HPDF_Dict_Add (annot, "AP", appearance);
|
|
if (ret != HPDF_OK) {
|
|
return NULL;
|
|
}
|
|
|
|
stream = HPDF_Dict_New (mmgr);
|
|
if (!stream) {
|
|
return NULL;
|
|
}
|
|
ret = HPDF_Dict_Add (appearance, "N", stream);
|
|
if (ret != HPDF_OK) {
|
|
return NULL;
|
|
}
|
|
|
|
return annot;
|
|
}
|
|
|
|
HPDF_EXPORT(HPDF_STATUS)
|
|
HPDF_3DAnnot_Set3DView (HPDF_Annotation annot)
|
|
{
|
|
HPDF_Boolean b;
|
|
|
|
HPDF_PTRACE((" HPDF_3DAnnot_Set3DView\n"));
|
|
|
|
if (!CheckSubType (annot, HPDF_ANNOT_3D))
|
|
return HPDF_INVALID_ANNOTATION;
|
|
|
|
b = HPDF_Boolean_New (annot->mmgr, 0);
|
|
if (!b)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
return HPDF_Dict_Add (annot, "3DD", b);
|
|
}
|
|
|
|
HPDF_Annotation
|
|
HPDF_TextAnnot_New (HPDF_MMgr mmgr,
|
|
HPDF_Xref xref,
|
|
HPDF_Rect rect,
|
|
const char *text,
|
|
HPDF_Encoder encoder)
|
|
{
|
|
HPDF_Annotation annot;
|
|
HPDF_String s;
|
|
|
|
HPDF_PTRACE((" HPDF_TextAnnot_New\n"));
|
|
|
|
annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_TEXT_NOTES, rect);
|
|
if (!annot)
|
|
return NULL;
|
|
|
|
s = HPDF_String_New (mmgr, text, encoder);
|
|
if (!s)
|
|
return NULL;
|
|
|
|
if (HPDF_Dict_Add (annot, "Contents", s) != HPDF_OK)
|
|
return NULL;
|
|
|
|
return annot;
|
|
}
|
|
|
|
|
|
HPDF_EXPORT(HPDF_STATUS)
|
|
HPDF_TextAnnot_SetIcon (HPDF_Annotation annot,
|
|
HPDF_AnnotIcon icon)
|
|
{
|
|
HPDF_PTRACE((" HPDF_TextAnnot_SetIcon\n"));
|
|
|
|
if (!CheckSubType (annot, HPDF_ANNOT_TEXT_NOTES))
|
|
return HPDF_INVALID_ANNOTATION;
|
|
|
|
if (icon < 0 || icon >= HPDF_ANNOT_ICON_EOF)
|
|
return HPDF_RaiseError (annot->error, HPDF_ANNOT_INVALID_ICON,
|
|
(HPDF_STATUS)icon);
|
|
|
|
if (HPDF_Dict_AddName (annot, "Name",
|
|
HPDF_ANNOT_ICON_NAMES_NAMES[(HPDF_INT)icon]) != HPDF_OK)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
return HPDF_OK;
|
|
}
|
|
|
|
|
|
HPDF_EXPORT(HPDF_STATUS)
|
|
HPDF_TextAnnot_SetOpened (HPDF_Annotation annot,
|
|
HPDF_BOOL opened)
|
|
{
|
|
HPDF_Boolean b;
|
|
|
|
HPDF_PTRACE((" HPDF_TextAnnot_SetOpend\n"));
|
|
|
|
if (!CheckSubType (annot, HPDF_ANNOT_TEXT_NOTES))
|
|
return HPDF_INVALID_ANNOTATION;
|
|
|
|
b = HPDF_Boolean_New (annot->mmgr, opened);
|
|
if (!b)
|
|
return HPDF_CheckError (annot->error);
|
|
|
|
return HPDF_Dict_Add (annot, "Open", b);
|
|
}
|
|
|
|
|
|
HPDF_BOOL
|
|
HPDF_Annotation_Validate (HPDF_Annotation annot)
|
|
{
|
|
HPDF_PTRACE((" HPDF_Annotation_Validate\n"));
|
|
|
|
if (!annot)
|
|
return HPDF_FALSE;
|
|
|
|
if (annot->header.obj_class !=
|
|
(HPDF_OSUBCLASS_ANNOTATION | HPDF_OCLASS_DICT))
|
|
return HPDF_FALSE;
|
|
|
|
return HPDF_TRUE;
|
|
}
|
|
|
|
static HPDF_BOOL
|
|
CheckSubType (HPDF_Annotation annot,
|
|
HPDF_AnnotType type)
|
|
{
|
|
HPDF_Name subtype;
|
|
|
|
HPDF_PTRACE((" HPDF_Annotation_CheckSubType\n"));
|
|
|
|
if (!HPDF_Annotation_Validate (annot))
|
|
return HPDF_FALSE;
|
|
|
|
subtype = HPDF_Dict_GetItem (annot, "Subtype", HPDF_OCLASS_NAME);
|
|
|
|
if (!subtype || HPDF_StrCmp (subtype->value,
|
|
HPDF_ANNOT_TYPE_NAMES[(HPDF_INT)type]) != 0) {
|
|
HPDF_RaiseError (annot->error, HPDF_INVALID_ANNOTATION, 0);
|
|
return HPDF_FALSE;
|
|
}
|
|
|
|
return HPDF_TRUE;
|
|
}
|
|
|