本文整理汇总了C++中HPDF_SetError函数的典型用法代码示例。如果您正苦于以下问题:C++ HPDF_SetError函数的具体用法?C++ HPDF_SetError怎么用?C++ HPDF_SetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HPDF_SetError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HPDF_Page_SetBoxValue
HPDF_STATUS
HPDF_Page_SetBoxValue (HPDF_Page page,
const char *name,
HPDF_UINT index,
HPDF_REAL value)
{
HPDF_Real r;
HPDF_Array array;
HPDF_PTRACE((" HPDF_Page_SetBoxValue\n"));
if (!HPDF_Page_Validate (page))
return HPDF_INVALID_PAGE;
array = HPDF_Page_GetInheritableItem (page, name, HPDF_OCLASS_ARRAY);
if (!array)
return HPDF_SetError (page->error, HPDF_PAGE_CANNOT_FIND_OBJECT, 0);
r = HPDF_Array_GetItem (array, index, HPDF_OCLASS_REAL);
if (!r)
return HPDF_SetError (page->error, HPDF_PAGE_INVALID_INDEX, 0);
r->value = value;
return HPDF_OK;
}
示例2: HPDF_Array_GetItem
void*
HPDF_Array_GetItem (HPDF_Array array,
HPDF_UINT index,
HPDF_UINT16 obj_class)
{
void *obj;
HPDF_Obj_Header *header;
HPDF_PTRACE((" HPDF_Array_GetItem\n"));
obj = HPDF_List_ItemAt (array->list, index);
if (!obj) {
HPDF_SetError (array->error, HPDF_ARRAY_ITEM_NOT_FOUND, 0);
return NULL;
}
header = (HPDF_Obj_Header *)obj;
if (header->obj_class == HPDF_OCLASS_PROXY) {
obj = ((HPDF_Proxy)obj)->obj;
header = (HPDF_Obj_Header *)obj;
}
if ((header->obj_class & HPDF_OCLASS_ANY) != obj_class) {
HPDF_SetError (array->error, HPDF_ARRAY_ITEM_UNEXPECTED_TYPE, 0);
return NULL;
}
return obj;
}
示例3: HPDF_Array_Insert
HPDF_STATUS
HPDF_Array_Insert (HPDF_Array array,
void *target,
void *obj)
{
HPDF_Obj_Header *header;
HPDF_STATUS ret;
HPDF_UINT i;
HPDF_PTRACE (" HPDF_Array_Insert\n");
if (!obj) {
if (HPDF_Error_GetCode (array->error) == HPDF_OK)
return HPDF_SetError (array->error, HPDF_INVALID_OBJECT, 0);
else
return HPDF_INVALID_OBJECT;
}
header = (HPDF_Obj_Header *)obj;
if (header->obj_id & HPDF_OTYPE_DIRECT) {
HPDF_PTRACE (" HPDF_Array_Add this object cannot owned by array "
#ifdef __ANDROID64__
"obj=0x%08X\n", (HPDF_UINT)(HPDF_UINTPTR)array);
#else
"obj=0x%08X\n", (HPDF_UINT)array);
#endif
return HPDF_SetError (array->error, HPDF_INVALID_OBJECT, 0);
}
示例4: HPDF_Pages_AddKids
HPDF_STATUS
HPDF_Pages_AddKids (HPDF_Pages parent,
HPDF_Dict kid)
{
HPDF_Array kids;
HPDF_STATUS ret;
HPDF_PTRACE((" HPDF_Pages_AddKids\n"));
if (HPDF_Dict_GetItem (kid, "Parent", HPDF_OCLASS_DICT))
return HPDF_SetError (parent->error, HPDF_PAGE_CANNOT_SET_PARENT, 0);
if ((ret = HPDF_Dict_Add (kid, "Parent", parent)) != HPDF_OK)
return ret;
kids = (HPDF_Array )HPDF_Dict_GetItem (parent, "Kids", HPDF_OCLASS_ARRAY);
if (!kids)
return HPDF_SetError (parent->error, HPDF_PAGES_MISSING_KIDS_ENTRY, 0);
if (kid->header.obj_class == (HPDF_OCLASS_DICT | HPDF_OSUBCLASS_PAGE)) {
HPDF_PageAttr attr = (HPDF_PageAttr)kid->attr;
attr->parent = parent;
}
return HPDF_Array_Add (kids, kid);
}
示例5: HPDF_Page_InsertBefore
HPDF_STATUS
HPDF_Page_InsertBefore (HPDF_Page page,
HPDF_Page target)
{
HPDF_Page parent;
HPDF_Array kids;
HPDF_STATUS ret;
HPDF_PageAttr attr;
HPDF_PTRACE((" HPDF_Page_InsertBefore\n"));
if (!target)
return HPDF_INVALID_PARAMETER;
attr = (HPDF_PageAttr )target->attr;
parent = attr->parent;
if (!parent)
return HPDF_PAGE_CANNOT_SET_PARENT;
if (HPDF_Dict_GetItem (page, "Parent", HPDF_OCLASS_DICT))
return HPDF_SetError (parent->error, HPDF_PAGE_CANNOT_SET_PARENT, 0);
if ((ret = HPDF_Dict_Add (page, "Parent", parent)) != HPDF_OK)
return ret;
kids = (HPDF_Array )HPDF_Dict_GetItem (parent, "Kids", HPDF_OCLASS_ARRAY);
if (!kids)
return HPDF_SetError (parent->error, HPDF_PAGES_MISSING_KIDS_ENTRY, 0);
attr = (HPDF_PageAttr)page->attr;
attr->parent = parent;
return HPDF_Array_Insert (kids, target, page);
}
示例6: HPDF_Xref_Add
HPDF_STATUS
HPDF_Xref_Add (HPDF_Xref xref,
void *obj)
{
HPDF_XrefEntry entry;
HPDF_Obj_Header *header;
HPDF_PTRACE((" HPDF_Xref_Add\n"));
if (!obj) {
if (HPDF_Error_GetCode (xref->error) == HPDF_OK)
return HPDF_SetError (xref->error, HPDF_INVALID_OBJECT, 0);
else
return HPDF_INVALID_OBJECT;
}
header = (HPDF_Obj_Header *)obj;
if (header->obj_id & HPDF_OTYPE_DIRECT ||
header->obj_id & HPDF_OTYPE_INDIRECT)
return HPDF_SetError(xref->error, HPDF_INVALID_OBJECT, 0);
if (xref->entries->count >= HPDF_LIMIT_MAX_XREF_ELEMENT) {
HPDF_SetError(xref->error, HPDF_XREF_COUNT_ERR, 0);
goto Fail;
}
/* in the following, we have to dispose the object when an error is
* occured.
*/
entry = (HPDF_XrefEntry)HPDF_GetMem (xref->mmgr,
sizeof(HPDF_XrefEntry_Rec));
if (entry == NULL)
goto Fail;
if (HPDF_List_Add(xref->entries, entry) != HPDF_OK) {
HPDF_FreeMem (xref->mmgr, entry);
goto Fail;
}
entry->entry_typ = HPDF_IN_USE_ENTRY;
entry->byte_offset = 0;
entry->gen_no = 0;
entry->obj = obj;
header->obj_id = xref->start_offset + xref->entries->count - 1 +
HPDF_OTYPE_INDIRECT;
header->gen_no = entry->gen_no;
return HPDF_OK;
Fail:
HPDF_Obj_ForceFree(xref->mmgr, obj);
return HPDF_Error_GetCode (xref->error);
}
示例7: HPDF_GetMem
void*
HPDF_GetMem (HPDF_MMgr mmgr,
HPDF_UINT size)
{
void * ptr;
if (mmgr->mpool) {
HPDF_MPool_Node node = mmgr->mpool;
#ifdef HPDF_ALINMENT_SIZ
size = (size + (HPDF_ALINMENT_SIZ - 1)) / HPDF_ALINMENT_SIZ;
size *= HPDF_ALINMENT_SIZ;
#endif
if (node->size - node->used_size >= size) {
ptr = (HPDF_BYTE*)node->buf + node->used_size;
node->used_size += size;
return ptr;
} else {
HPDF_UINT tmp_buf_siz = (mmgr->buf_size < size) ? size :
mmgr->buf_size;
node = (HPDF_MPool_Node)mmgr->alloc_fn (sizeof(HPDF_MPool_Node_Rec)
+ tmp_buf_siz);
HPDF_PTRACE(("+%p mmgr-new-node\n", node));
if (!node) {
HPDF_SetError (mmgr->error, HPDF_FAILD_TO_ALLOC_MEM,
HPDF_NOERROR);
return NULL;
}
node->size = tmp_buf_siz;
}
node->next_node = mmgr->mpool;
mmgr->mpool = node;
node->used_size = size;
node->buf = (HPDF_BYTE*)node + sizeof(HPDF_MPool_Node_Rec);
ptr = node->buf;
} else {
ptr = mmgr->alloc_fn (size);
HPDF_PTRACE(("+%p mmgr-alloc_fn size=%u\n", ptr, size));
if (ptr == NULL)
HPDF_SetError (mmgr->error, HPDF_FAILD_TO_ALLOC_MEM, HPDF_NOERROR);
}
#ifdef HPDF_MEM_DEBUG
if (ptr)
mmgr->alloc_cnt++;
#endif
return ptr;
}
示例8: HPDF_Array_Add
HPDF_STATUS
HPDF_Array_Add (HPDF_Array array,
void *obj)
{
HPDF_Obj_Header *header;
HPDF_STATUS ret;
HPDF_PTRACE((" HPDF_Array_Add\n"));
if (!obj) {
if (HPDF_Error_GetCode (array->error) == HPDF_OK)
return HPDF_SetError (array->error, HPDF_INVALID_OBJECT, 0);
else
return HPDF_INVALID_OBJECT;
}
header = (HPDF_Obj_Header *)obj;
if (header->obj_id & HPDF_OTYPE_DIRECT)
return HPDF_SetError (array->error, HPDF_INVALID_OBJECT, 0);
if (array->list->count >= HPDF_LIMIT_MAX_ARRAY) {
HPDF_PTRACE((" HPDF_Array_Add exceed limitatin of array count(%d)\n",
HPDF_LIMIT_MAX_ARRAY));
HPDF_Obj_Free (array->mmgr, obj);
return HPDF_SetError (array->error, HPDF_ARRAY_COUNT_ERR, 0);
}
if (header->obj_id & HPDF_OTYPE_INDIRECT) {
HPDF_Proxy proxy = HPDF_Proxy_New (array->mmgr, obj);
if (!proxy) {
HPDF_Obj_Free (array->mmgr, obj);
return HPDF_Error_GetCode (array->error);
}
proxy->header.obj_id |= HPDF_OTYPE_DIRECT;
obj = proxy;
} else
header->obj_id |= HPDF_OTYPE_DIRECT;
ret = HPDF_List_Add (array->list, obj);
if (ret != HPDF_OK)
HPDF_Obj_Free (array->mmgr, obj);
return ret;
}
示例9: LoadType1FontFromStream
static const char*
LoadType1FontFromStream (HPDF_Doc pdf,
HPDF_Stream afmdata,
HPDF_Stream pfmdata)
{
HPDF_FontDef def;
HPDF_PTRACE ((" HPDF_LoadType1FontFromStream\n"));
if (!HPDF_HasDoc (pdf))
return NULL;
def = HPDF_Type1FontDef_Load (pdf->mmgr, afmdata, pfmdata);
if (def) {
HPDF_FontDef tmpdef = HPDF_Doc_FindFontDef (pdf, def->base_font);
if (tmpdef) {
HPDF_FontDef_Free (def);
HPDF_SetError (&pdf->error, HPDF_FONT_EXISTS, 0);
return NULL;
}
if (HPDF_List_Add (pdf->fontdef_list, def) != HPDF_OK) {
HPDF_FontDef_Free (def);
return NULL;
}
return def->base_font;
}
return NULL;
}
示例10: HPDF_Real_SetValue
HPDF_STATUS
HPDF_Real_SetValue (HPDF_Real obj,
HPDF_REAL value)
{
HPDF_STATUS ret = HPDF_OK;
if (value > HPDF_LIMIT_MAX_REAL)
return HPDF_SetError (obj->error, HPDF_REAL_OUT_OF_RANGE, 0);
if (value < HPDF_LIMIT_MIN_REAL)
return HPDF_SetError (obj->error, HPDF_REAL_OUT_OF_RANGE, 0);
obj->value =value;
return ret;
}
示例11: HPDF_Font_TextWidth
HPDF_Font_TextWidth (HPDF_Font font,
const HPDF_BYTE *text,
HPDF_UINT len)
{
HPDF_TextWidth tw = {0, 0, 0, 0};
HPDF_FontAttr attr;
HPDF_PTRACE ((" HPDF_Font_TextWidth\n"));
if (!HPDF_Font_Validate(font))
return tw;
if (len > HPDF_LIMIT_MAX_STRING_LEN) {
HPDF_RaiseError (font->error, HPDF_STRING_OUT_OF_RANGE, 0);
return tw;
}
attr = (HPDF_FontAttr)font->attr;
if (!attr->text_width_fn) {
HPDF_SetError (font->error, HPDF_INVALID_OBJECT, 0);
return tw;
}
tw = attr->text_width_fn (font, text, len);
return tw;
}
示例12: HPDF_Xref_GetEntryByObjectId
HPDF_XrefEntry
HPDF_Xref_GetEntryByObjectId (HPDF_Xref xref,
HPDF_UINT obj_id)
{
HPDF_Xref tmp_xref = xref;
HPDF_PTRACE((" HPDF_Xref_GetEntryByObjectId\n"));
while (tmp_xref) {
HPDF_UINT i;
if (tmp_xref->entries->count + tmp_xref->start_offset > obj_id) {
HPDF_SetError (xref->error, HPDF_INVALID_OBJ_ID, 0);
return NULL;
}
if (tmp_xref->start_offset < obj_id) {
for (i = 0; i < tmp_xref->entries->count; i++) {
if (tmp_xref->start_offset + i == obj_id) {
HPDF_XrefEntry entry = HPDF_Xref_GetEntry(tmp_xref, i);
return entry;
}
}
}
tmp_xref = tmp_xref->prev;
}
return NULL;
}
示例13: TextWidth
static HPDF_TextWidth
TextWidth (HPDF_Font font,
const HPDF_BYTE *text,
HPDF_UINT len)
{
HPDF_FontAttr attr = (HPDF_FontAttr)font->attr;
HPDF_TextWidth ret = {0, 0, 0, 0};
HPDF_UINT i;
HPDF_BYTE b = 0;
HPDF_PTRACE ((" HPDF_TTFont_TextWidth\n"));
if (attr->widths) {
for (i = 0; i < len; i++) {
b = text[i];
ret.numchars++;
ret.width += CharWidth (font, b);
if (HPDF_IS_WHITE_SPACE(b)) {
ret.numspace++;
ret.numwords++;
}
}
} else
HPDF_SetError (font->error, HPDF_FONT_INVALID_WIDTHS_TABLE, 0);
/* 2006.08.19 add. */
if (HPDF_IS_WHITE_SPACE(b))
; /* do nothing. */
else
ret.numwords++;
return ret;
}
示例14: HPDF_Page_SetSize
HPDF_Page_SetSize (HPDF_Page page,
HPDF_PageSizes size,
HPDF_PageDirection direction)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_PTRACE((" HPDF_Page_SetSize\n"));
if (!HPDF_Page_Validate (page))
return HPDF_INVALID_PAGE;
if ((int)size < 0 || size > HPDF_PAGE_SIZE_EOF) //CAL:Supress "comparison of unsigned expression < 0 is always false" warning
return HPDF_RaiseError (page->error, HPDF_PAGE_INVALID_SIZE,
(HPDF_STATUS)direction);
if (direction == HPDF_PAGE_LANDSCAPE) {
ret += HPDF_Page_SetHeight (page,
HPDF_PREDEFINED_PAGE_SIZES[(HPDF_UINT)size].x);
ret += HPDF_Page_SetWidth (page,
HPDF_PREDEFINED_PAGE_SIZES[(HPDF_UINT)size].y);
} else if (direction == HPDF_PAGE_PORTRAIT) {
ret += HPDF_Page_SetHeight (page,
HPDF_PREDEFINED_PAGE_SIZES[(HPDF_UINT)size].y);
ret += HPDF_Page_SetWidth (page,
HPDF_PREDEFINED_PAGE_SIZES[(HPDF_UINT)size].x);
} else
ret = HPDF_SetError (page->error, HPDF_PAGE_INVALID_DIRECTION,
(HPDF_STATUS)direction);
if (ret != HPDF_OK)
return HPDF_CheckError (page->error);
return HPDF_OK;
}
示例15: HPDF_Image_SetMask
HPDF_STATUS
HPDF_Image_SetMask (HPDF_Image image,
HPDF_BOOL mask)
{
HPDF_Boolean image_mask;
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
if (mask && HPDF_Image_GetBitsPerComponent (image) != 1)
return HPDF_SetError (image->error, HPDF_INVALID_BIT_PER_COMPONENT,
0);
image_mask = HPDF_Dict_GetItem (image, "ImageMask", HPDF_OCLASS_BOOLEAN);
if (!image_mask) {
HPDF_STATUS ret;
image_mask = HPDF_Boolean_New (image->mmgr, HPDF_FALSE);
if ((ret = HPDF_Dict_Add (image, "ImageMask", image_mask)) != HPDF_OK)
return ret;
}
image_mask->value = mask;
return HPDF_OK;
}