Ejemplo n.º 1
0
/* DL [Character Code, Coords] */
int
hpgl_DL(hpgl_args_t * pargs, hpgl_state_t * pgls)
{
    int code;
    hpgl_dl_cdata_t *cdata;

    /* first call */
    if (pargs->phase == 0) {
        int32 cc;

        /* double byte characters are not yet supported */
        if (pgls->g.label.double_byte)
            return e_Unimplemented;
        /* parse the character code, no arguments clears all defined
           characters */
        if (!hpgl_arg_c_int(pgls->memory, pargs, &cc)) {
            hpgl_clear_dl_chars(pgls);
            return 0;
        }

        if (cc < 0 || cc > 255)
            return e_Range;

        cdata =
            (hpgl_dl_cdata_t *) gs_alloc_bytes(pgls->memory,
                                               sizeof(hpgl_dl_cdata_t),
                                               "DL header");
        if (cdata == 0)
            return e_Memory;
        cdata->index = -1;
        cdata->data = NULL;
        id_set_value(pgls->g.current_dl_char_id, (ushort) cc);
        pl_dict_put(&pgls->g.dl_531_fontdict,
                    id_key(pgls->g.current_dl_char_id), 2, cdata);
        hpgl_args_init(pargs);
        pargs->phase = 1;
    }

    if (!pl_dict_find
        (&pgls->g.dl_531_fontdict, id_key(pgls->g.current_dl_char_id), 2,
         (void **)&cdata))
        /* this should be a failed assertion */
        return -1;
    do {
        int c;

        if (!hpgl_arg_c_int(pgls->memory, pargs, &c))
            break;
        code = hpgl_add_dl_char_data(pgls, cdata, c);
        if (code < 0) {
            pl_dict_undef(&pgls->g.dl_531_fontdict,
                          id_key(pgls->g.current_dl_char_id), 2);
            return code;
        }
        hpgl_args_init(pargs);
    } while (1);
    return 0;
}
Ejemplo n.º 2
0
/*
 * End a page, either unconditionally or only if there are marks on it.
 * Return 1 if the page was actually printed and erased.
 */
  int
pcl_end_page(
    pcl_state_t *           pcs,
    pcl_print_condition_t   condition
)
{
    int                     code = 0;

    pcl_break_underline(pcs);   /* (could mark page) */

    /* If we are conditionally printing (normal case) check if the
       page is marked */
    if (condition != pcl_print_always) {
        if ( !pcl_page_marked(pcs) )
            return 0;
    }

    /* If there's an overlay macro, execute it now. */
    if (pcs->overlay_enabled) {
        void *  value;

        if ( pl_dict_find( &pcs->macros,
                           id_key(pcs->overlay_macro_id),
                           2,
                           &value
                           ) ) {
            pcs->overlay_enabled = false;   /**** IN reset_overlay ****/
            code = pcl_execute_macro( (const pcl_macro_t *)value,
                                      pcs,
                                      pcl_copy_before_overlay,
                                      pcl_reset_overlay,
                                      pcl_copy_after_overlay
                                      );
            pcs->overlay_enabled = true; /**** IN copy_after ****/
        }
    }
    /* output the page */
    code = (*pcs->end_page)(pcs, pcs->num_copies, true);
    if ( code < 0 )
        return code;
    /* allow the logical orientation command to be used again */
    pcs->orientation_set = false;

    if ( pcs->end_page == pcl_end_page_top )
        code = gs_erasepage(pcs->pgs);
    pcs->page_marked = false;
    /* force new logical page, allows external resolution changes.
     * see -dFirstPage -dLastPage
     * NB would be faster if we didn't do this every page.
     *
     * NB setting a new logical page defaults settings
     * that should carry over from the previous page
     * this error occurs only on documents that don't do any initilizations per page
     * hence only the viewer applications will see the speedup and the error
     */
    if (!pjl_proc_compare(pcs->pjls, pjl_proc_get_envvar(pcs->pjls, "viewer"), "on")) {
        new_logical_page(pcs, pcs->xfm_state.lp_orient,
                         pcs->xfm_state.paper_size, false, false);
    }

    /*
     * Advance of a page may move from a page front to a page back. This may
     * change the applicable transformations.
     */
    update_xfm_state(pcs, 0);

    pcl_continue_underline(pcs);
    return (code < 0 ? code : 1);
}
Ejemplo n.º 3
0
/*
 * End a page, either unconditionally or only if there are marks on it.
 * Return 1 if the page was actually printed and erased.
 */
int
pcl_end_page(pcl_state_t * pcs, pcl_print_condition_t condition)
{
    int code = 0;

    pcl_break_underline(pcs);   /* (could mark page) */

    /* If we are conditionally printing (normal case) check if the
       page is marked */
    if (condition != pcl_print_always) {
        if (!pcl_page_marked(pcs))
            return 0;
    }

    /* finish up graphics mode in case we finished the page in the
       middle of a raster stream */
    if (pcs->raster_state.graphics_mode)
        pcl_end_graphics_mode(pcs);

    /* If there's an overlay macro, execute it now. */
    if (pcs->overlay_enabled) {
        void *value;

        if (pl_dict_find(&pcs->macros,
                         id_key(pcs->overlay_macro_id), 2, &value)) {
            pcs->overlay_enabled = false;   /**** IN reset_overlay ****/
            code = pcl_execute_macro((const pcl_macro_t *)value,
                                     pcs,
                                     pcl_copy_before_overlay,
                                     pcl_reset_overlay,
                                     pcl_copy_after_overlay);
            if (code < 0)
                return code;

            pcs->overlay_enabled = true; /**** IN copy_after ****/
        }
    }
    /* output the page */
    code = (*pcs->end_page) (pcs, pcs->num_copies, true);
    if (code < 0)
        return code;

    if (pcs->end_page == pcl_end_page_top)
        code = gs_erasepage(pcs->pgs);

    pcs->page_marked = false;

    /*
     * Advance of a page may move from a page front to a page back. This may
     * change the applicable transformations.
     */
    /*
     * Keep track of the side you are on
     */
    if (pcs->duplex) {
        pcs->back_side = ! pcs->back_side;
    } else {
        pcs->back_side = false;
    }
    put_param1_bool(pcs,"FirstSide", !pcs->back_side);
    update_xfm_state(pcs, 0);

    pcl_continue_underline(pcs);
    return (code < 0 ? code : 1);
}