/* * Finish writing the data stream for an ICCBased color space object. */ static int pdf_finish_iccbased(cos_stream_t *pcstrm) { /* * The stream must be an indirect object. Assign an ID, and write the * object out now. */ gx_device_pdf *pdev = pcstrm->pdev; pcstrm->id = pdf_obj_ref(pdev); return cos_write_object(COS_OBJECT(pcstrm), pdev); }
/* * Look up a named object as for pdf_refer_named. If the object already * exists and is not simply a forward reference, return e_rangecheck; * if it exists as a forward reference, set its type and return 0; * otherwise, create the object with the given type and return 1. */ int pdf_make_named(gx_device_pdf * pdev, const gs_param_string * pname, cos_type_t cotype, cos_object_t **ppco, bool assign_id) { if (pname) { int code = pdf_refer_named(pdev, pname, ppco); cos_object_t *pco = *ppco; if (code < 0) return code; if (cos_type(pco) != cos_type_generic) return_error(gs_error_rangecheck); if (assign_id && pco->id == 0) pco->id = pdf_obj_ref(pdev); cos_become(pco, cotype); return code; } else { int code = pdf_create_named(pdev, pname, cotype, ppco, (assign_id ? 0L : -1L)); return (code < 0 ? code : 1); } }
/* * Create a (local) named object. id = -1L means do not assign an id. * pname = 0 means just create the object, do not name it. Note that * during initialization, local_named_objects == global_named_objects. */ int pdf_create_named(gx_device_pdf *pdev, const gs_param_string *pname, cos_type_t cotype, cos_object_t **ppco, long id) { cos_object_t *pco; cos_value_t value; *ppco = pco = cos_object_alloc(pdev, "pdf_create_named"); if (pco == 0) return_error(gs_error_VMerror); pco->id = (id == -1 ? 0L : id == 0 ? pdf_obj_ref(pdev) : id); if (pname) { int code = cos_dict_put(pdev->local_named_objects, pname->data, pname->size, cos_object_value(&value, pco)); if (code < 0) return code; } if (cotype != cos_type_generic) cos_become(pco, cotype); *ppco = pco; return 0; }