コード例 #1
0
ファイル: pcpage.c プロジェクト: hackqiang/gs
/*
 * ESC & l <psize_enum> A
 *
 * Select paper size
 */
static int
set_page_size(pcl_args_t * pargs, pcl_state_t * pcs)
{
    /* Note: not all values are implemented on all printers.  If -g
       has been given on the command line we use the "Custom" page
       tag, the height and width are set to the device media values
       which were filled in when the -g option was processed. */

    uint tag = (pcs->page_set_on_command_line ? 101 : uint_arg(pargs));
    int i;
    int code = 0;
    const pcl_paper_size_t *psize = 0;

    /* oddly the command goes to the next page irrespective of
       arguments */
    code = pcl_end_page_if_marked(pcs);
    if (code < 0)
        return code;
    pcl_home_cursor(pcs);

    for (i = 0; i < pcl_paper_type_count; i++) {
        if (tag == PAPER_SIZES[i].tag) {
            psize = &(PAPER_SIZES[i].psize);
            break;
        }
    }
    if ((psize != 0) && ((code = pcl_end_page_if_marked(pcs)) >= 0)) {
        pcs->xfm_state.print_dir = 0;
        new_page_size(pcs, psize, false, false);
    }
    return code;
}
コード例 #2
0
ファイル: pcpage.c プロジェクト: hackqiang/gs
/*
 * ESC & l <feed_enum> H
 *
 * Set paper source
 */
static int
set_paper_source(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint i = uint_arg(pargs);
    /* oddly the command goes to the next page irrespective of
       arguments */
    int code = pcl_end_page_if_marked(pcs);

    if (code < 0)
        return code;
    pcl_home_cursor(pcs);
    /* Do not change the page side if the wanted paper source is the same as the actual one */
    if (pcs->paper_source != i) {
        pcs->back_side = false;
        put_param1_bool(pcs, "FirstSide", !pcs->back_side);
    }
    pcs->paper_source = i;
    /* Note: not all printers support all possible values. */
    if (i <= 6) {
        code = 0;
        if (i > 0)
            code = put_param1_int(pcs, "%MediaSource", i);
        return (code < 0 ? code : 0);
    } else
        return e_Range;
}
コード例 #3
0
ファイル: pcursor.c プロジェクト: computersforpeace/ghostpdl
static int
set_vert_motion_index(pcl_args_t * pargs, pcl_state_t * pcs)
{
    /* LMI :== 48.0 / lpi;  ie 0.16 = 48/300;
     * convert to pcl_coord_scale (7200), roundup the float prior to truncation.
     */
    coord vcp = (coord) ((fabs(float_arg(pargs)) * 7200.0 / 48.0) + 0.5);
    bool cursor_at_home = pcl_cursor_at_home_pos(pcs);

#ifdef HP_VERT_MOTION_NEW
    if (vcp <= pcs->xfm_state.pd_size.y)
#endif
        pcs->vmi_cp = vcp;

    /* If the cursor has not been set, the new default position should
       reflect the change in vmi.  This behavior is quite unusual and
       probably is not the way HP intended PCL devices to behave.  In
       the spec it is reported the VMI should take effect if the
       printer is on the first line but we've found moving the x
       coordinate (horizontal position) cause the command to not take
       effect. */
    if (cursor_at_home)
        pcl_home_cursor(pcs);
    return 0;
}
コード例 #4
0
ファイル: pcjob.c プロジェクト: ststeiger/ghostsvg
static int /* ESC & l <sd_enum> S */
pcl_simplex_duplex_print(pcl_args_t *pargs, pcl_state_t *pcs)
{	int code;
	bool reopen = false;

	/* oddly the command goes to the next page irrespective of
           arguments */
	code = pcl_end_page_if_marked(pcs);
	if ( code < 0 )
	    return code;
	pcl_home_cursor(pcs);
	switch ( int_arg(pargs) )
	  {
	  case 0:
	    pcs->duplex = false;
	    break;
	  case 1:
	    pcs->duplex = true;
	    pcs->bind_short_edge = false;
	    break;
	  case 2:
	    pcs->duplex = true;
	    pcs->bind_short_edge = true;
	    break;
	  default:
	    return 0;
	  }
	code = put_param1_bool(pcs, "Duplex", pcs->duplex);
	switch ( code )
	  {
	  case 1:		/* reopen device */
	    reopen = true;
	  case 0:
	    break;
	  case gs_error_undefined:
	    return 0;
	  default:		/* error */
	    if ( code < 0 )
	      return code;
	  }
	code = put_param1_bool(pcs, "BindShortEdge", pcs->bind_short_edge);
	switch ( code )
	  {
	  case 1:		/* reopen device */
	    reopen = true;
	  case 0:
	  case gs_error_undefined:
	    break;
	  default:		/* error */
	    if ( code < 0 )
	      return code;
	  }
	return (reopen ? gs_setdevice_no_erase(pcs->pgs,
					       gs_currentdevice(pcs->pgs)) :
		0);
}
コード例 #5
0
ファイル: pcpage.c プロジェクト: hackqiang/gs
/*
 * (From PCL5 Comparison Guide, p. 1-98)
 *
 * ESC & l <type> M
 *
 * Set media type.
 */
static int
pcl_media_type(pcl_args_t * pargs, pcl_state_t * pcs)
{
    int type = uint_arg(pargs);

    if (type <= 4) {
        int code = pcl_end_page_if_marked(pcs);

        if (code >= 0)
            pcl_home_cursor(pcs);
        return (code < 0 ? code : e_Unimplemented);
    } else
        return e_Range;
}
コード例 #6
0
ファイル: pcpage.c プロジェクト: hackqiang/gs
/*
 * (From PCL5 Comparison Guide, p. 1-99)
 *
 * ESC * o <quality> Q
 *
 * Set print quality.
 */
static int
pcl_print_quality(pcl_args_t * pargs, pcl_state_t * pcs)
{
    int quality = int_arg(pargs);

    if ((quality >= -1) && (quality <= 1)) {
        int code = pcl_end_page_if_marked(pcs);

        if (code >= 0)
            pcl_home_cursor(pcs);
        return (code < 0 ? code : 0);
    } else
        return e_Range;
}
コード例 #7
0
ファイル: pcursor.c プロジェクト: computersforpeace/ghostpdl
/*
 * ESC & l <lpi> D
 *
 * Set line spacing. Though it is not documented anywhere, various HP devices
 * agree that a zero operand specifies 12 lines per inch (NOT the default).
 */
static int
set_line_spacing(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint lpi = uint_arg(pargs);
    bool cursor_at_home = pcl_cursor_at_home_pos(pcs);

    if (lpi == 0)               /* 0 ==> 12 lines per inch */
        lpi = 12;
    if ((48 % lpi) == 0)        /* lpi must divide 48 */
        pcs->vmi_cp = inch2coord(1.0 / lpi);
    if (cursor_at_home)
        pcl_home_cursor(pcs);
    return 0;
}
コード例 #8
0
ファイル: pcjob.c プロジェクト: ststeiger/ghostsvg
static int /* ESC & a <side_enum> G */
pcl_duplex_page_side_select(pcl_args_t *pargs, pcl_state_t *pcs)
{	uint i = uint_arg(pargs);
	int code;

	/* oddly the command goes to the next page irrespective of
           arguments */
	code = pcl_end_page_if_marked(pcs);
	if ( code < 0 )
	    return code;
	pcl_home_cursor(pcs);

	if ( i > 2 )
	  return 0;

	if ( i > 0 && pcs->duplex )
	  put_param1_bool(pcs, "FirstSide", i == 1);
	return 0;
}
コード例 #9
0
ファイル: pcpage.c プロジェクト: ststeiger/ghostsvg
/*
 * ESC & l <feed_enum> H
 *
 * Set paper source
 */
  static int
set_paper_source(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    uint            i = uint_arg(pargs);

    /* oddly the command goes to the next page irrespective of
       arguments */
    int code = pcl_end_page_if_marked(pcs);
    if ( code < 0 )
        return code;
    pcl_home_cursor(pcs);

    /* Note: not all printers support all possible values. */
    if (i <= 6) {
        code = 0;
        if (i > 0)
            code = put_param1_int(pcs, "%MediaSource", i);
        return (code < 0 ? code : 0);
    } else
        return e_Range;
}
コード例 #10
0
ファイル: pcpage.c プロジェクト: ststeiger/ghostsvg
/*
 * ESC & l <psize_enum> A
 *
 * Select paper size
 */
  static int
set_page_size(
    pcl_args_t *                pargs,
    pcl_state_t *               pcs
)
{
    /* Note: not all values are implemented on all printers. */
    uint                        tag = uint_arg(pargs);
    int                         i;
    int                         code = 0;
    const pcl_paper_size_t *    psize = 0;

    /* oddly the command goes to the next page irrespective of
       arguments */
    code = pcl_end_page_if_marked(pcs);
    if ( code < 0 )
        return code;
    pcl_home_cursor(pcs);

    for (i = 0; i < countof(paper_sizes); i++) {
        if (tag == paper_sizes[i].tag) {
            psize = &(paper_sizes[i].psize);
            break;
        }
    }
    if ((psize != 0) && ((code = pcl_end_page_if_marked(pcs)) >= 0)) {
        /* if the orientation flag is not set for this page we select
           a portrait page using the set paper size.  Otherwise select
           the paper using the current orientation. */
        if ( pcs->orientation_set == false )
            new_logical_page(pcs, 0, psize, false, false);
        else
            new_page_size(pcs, psize, false, false);
    }
    return code;
}
コード例 #11
0
ファイル: pcpage.c プロジェクト: ststeiger/ghostsvg
/*
 * Reset all parameters which must be reset whenever the page size changes.
 *
 * The third operand indicates if this routine is being called as part of
 * an initial reset. In that case, done't call HPGL's reset - the reset
 * will do that later.
 */
  static void
new_page_size(
    pcl_state_t *               pcs,
    const pcl_paper_size_t *    psize,
    bool                        reset_initial,
    bool                        for_passthrough
)
{
    floatp                      width_pts = psize->width * 0.01;
    floatp                      height_pts = psize->height * 0.01;
    float                       page_size[2];
    static float                old_page_size[2] = { 0, 0 };
    gs_state *                  pgs = pcs->pgs;
    gs_matrix                   mat;
    bool                        changed_page_size;

    page_size[0] = width_pts;
    page_size[1] = height_pts;

    old_page_size[0] = pcs->xfm_state.paper_size ? pcs->xfm_state.paper_size->width : 0;
    old_page_size[1] = pcs->xfm_state.paper_size ? pcs->xfm_state.paper_size->height : 0;

    put_param1_float_array(pcs, "PageSize", page_size);

    /*
     * Reset the default transformation.
     *
     * The graphic library provides a coordinate system in points, with the
     * origin at the lower left corner of the page. The PCL code uses a
     * coordinate system in centi-points, with the origin at the upper left
     * corner of the page.
     */
    gs_setdefaultmatrix(pgs, NULL);
    gs_initmatrix(pgs);
    gs_currentmatrix(pgs, &mat);
    gs_matrix_translate(&mat, 0.0, height_pts, &mat);
    gs_matrix_scale(&mat, 0.01, -0.01, &mat);
    gs_setdefaultmatrix(pgs, &mat);

    pcs->xfm_state.paper_size = psize;
    pcs->overlay_enabled = false;
    update_xfm_state(pcs, reset_initial);
    reset_margins(pcs, for_passthrough);

    /* check if update_xfm_state changed the page size */
    changed_page_size = !(old_page_size[0] == pcs->xfm_state.paper_size->width &&
                          old_page_size[1] == pcs->xfm_state.paper_size->height);


    /*
     * make sure underlining is disabled (homing the cursor may cause
     * an underline to be put out.
     */
    pcs->underline_enabled = false;
    pcl_home_cursor(pcs);

    pcl_xfm_reset_pcl_pat_ref_pt(pcs);

    if (!reset_initial)
        hpgl_do_reset(pcs, pcl_reset_page_params);

    if ( pcs->end_page == pcl_end_page_top ) {  /* don't erase in snippet mode */
        if (pcs->page_marked || changed_page_size) {
            gs_erasepage(pcs->pgs);
            pcs->page_marked = false;
        }
    }
}