예제 #1
0
파일: pcpage.c 프로젝트: ststeiger/ghostsvg
/*
 * ESC & l <line> E
 *
 * Set top margin. This will also reset the page length.
 */
  static int
set_top_margin(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    coord           hgt = pcs->xfm_state.pd_size.y;
    coord           tmarg = uint_arg(pargs) * pcs->vmi_cp;

    if ((pcs->vmi_cp != 0) && (tmarg <= hgt)) {
        bool was_default = (pcs->margins.top == TOP_MARGIN(hgt, DFLT_TOP_MARGIN) &&
                            pcs->margins.left == DFLT_LEFT_MARGIN);

        pcs->margins.top = tmarg;
        pcs->margins.length = PAGE_LENGTH(hgt - tmarg, DFLT_BOTTOM_MARGIN);

        /* If the cursor has been moved then we have a fixed cap and the
           top margin only affects the next page. If the cap is floating,
           unmarked and unmoved, then the cap moves to the first line of text.
           More restrictive than implementor's guide:
           iff a default margin is changed on an unmarked unmoved page to the new margin.
           margin_set(A) ^L margin_set(B)  --> use (A)
           escE margin_set(B) --> use (B)
         */
        if (was_default && pcl_page_marked(pcs) == 0 )
            return pcl_set_cap_y(pcs, 0L, false, false, true, false);
    }
    return 0;
}
예제 #2
0
/* PG; */
int
hpgl_PG(hpgl_args_t *pargs, hpgl_state_t *pgls)
{	
    if ( pgls->personality == rtl ) {
	int dummy;
	hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
	/* with parameter always feed, without parameter feed if marked */
	if ( pcl_page_marked(pgls) || hpgl_arg_c_int(pgls->memory, pargs, &dummy) )
	    hpgl_call(pcl_do_FF(pgls));
    }
    return 0;
}
예제 #3
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <line> E
 *
 * Set top margin. This will also reset the page length.
 */
static int
set_top_margin(pcl_args_t * pargs, pcl_state_t * pcs)
{
    coord hgt = pcs->xfm_state.pd_size.y;
    coord tmarg = uint_arg(pargs) * pcs->vmi_cp;

    if ((pcs->vmi_cp != 0) && (tmarg <= hgt)) {
        pcs->margins.top = tmarg;
        pcs->margins.length = PAGE_LENGTH(hgt - tmarg, DFLT_BOTTOM_MARGIN);
        /* See the discussion in the Implementor's guide concerning
           "fixed" and "floating" cap.  If the page is not dirty we
           home the cursor - the guide talks about tracking the cursor
           for any movement and checking for data on the page */
        if (!pcl_page_marked(pcs) && !pcl_cursor_moved(pcs))
            return pcl_set_cap_y(pcs, 0L, false, false, true, false);
    }
    return 0;
}
예제 #4
0
/* PS;  NB this is only a partial implementation. */
int
hpgl_PS(hpgl_args_t *pargs, hpgl_state_t *pgls)
{
    hpgl_real_t page_dims[2];
    /* we use the pcl paper handling machinery to set the plot size */
    pcl_paper_size_t paper;
    int i;

    if ( pgls->personality != rtl )
	return 0;

    /* PS return an error if the page is dirty */
    if ( pcl_page_marked(pgls) )
        return e_Range;
    
    /* check for pjl override of the arguments - this is custom code
       for a customer and is not the normal interaction between PCL &
       PJL */
    if (!pjl_proc_compare(pgls->pjls, pjl_proc_get_envvar(pgls->pjls, "plotsizeoverride"), "on")) {
        page_dims[0] = pjl_proc_vartof(pgls->pjls, pjl_proc_get_envvar(pgls->pjls, "plotsize1"));
        page_dims[1] = pjl_proc_vartof(pgls->pjls, pjl_proc_get_envvar(pgls->pjls, "plotsize2"));
    } else {
        for ( i = 0; i < 2 && hpgl_arg_real(pgls->memory, pargs, &page_dims[i]); ++i )
            ; /* NOTHING */
        if ( i == 1 )
            page_dims[1] = page_dims[0];
        else if ( i != 2 )
            return e_Range;
    }
    paper.height = plu_2_coord(page_dims[0]);
    paper.width = plu_2_coord(page_dims[1]);
    paper.offset_portrait = 0; 
    paper.offset_landscape = 0;
    new_logical_page(pgls, 0, &paper, false, false);
    return 0;
}
예제 #5
0
파일: pcpage.c 프로젝트: ststeiger/ghostsvg
/*
 * 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);
}
예제 #6
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * 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);
}