Exemplo n.º 1
0
static  void    doc_header( su *p_sk, su *top_sk, xx_str *h_string,
                            font_number font, spacing_line spacing_ln, bool no_eject )
{
    doc_element     *   cur_el;
    font_number         font_save;
    int32_t             h_left;
    text_chars      *   curr_t;
    text_line       *   hd_line;

    font_save = g_curr_font;
    g_curr_font = font;
    g_curr_font = font_save;
    set_skip_vars( NULL, top_sk, p_sk, spacing_ln, g_curr_font );

    if( (h_string == NULL) || (*h_string == '\0') ||
        (*h_string == ' ') || (*h_string == '\t')  ) {

        /********************************************************/
        /*  header contained "yes" but the string was empty:    */
        /*  the OW docs do this with APPENDIX for PS/PDF output */
        /********************************************************/

        hd_line = alloc_text_line();    // defaults work
    } else {
        curr_t = alloc_text_chars( h_string, strlen( h_string ), font );
        curr_t->width = cop_text_width( curr_t->text, curr_t->count, font );
        h_left = g_page_left +(g_page_right - g_page_left - curr_t->width) / 2;
        curr_t->x_address = h_left;

        hd_line = alloc_text_line();
        hd_line->first = curr_t;
        hd_line->line_height = wgml_fonts[font].line_height;
    }

    if( input_cbs->fmflags & II_research ) {
        test_out_t_line( hd_line );
    }
    cur_el = alloc_doc_el( el_text );
    cur_el->blank_lines = g_blank_lines;
    g_blank_lines = 0;
    cur_el->depth = hd_line->line_height;
    cur_el->subs_skip = g_subs_skip;
    cur_el->top_skip = g_top_skip;
    cur_el->element.text.overprint = ProcFlags.overprint;
    ProcFlags.overprint = false;
    cur_el->element.text.spacing = g_spacing;
    cur_el->element.text.first = hd_line;
    ProcFlags.skips_valid = false;
    hd_line = NULL;

    if( no_eject ) {
        insert_col_main( cur_el );
    } else {
        insert_page_width( cur_el );
    }
}
Exemplo n.º 2
0
static  void    out_ban_common( banner_lay_tag * ban, bool top )
{
    ban_column      *   last;
    text_chars      *   curr_t;
    text_chars      *   curr_p;
    uint32_t            ban_left;
    uint32_t            h_left;
    uint32_t            ban_right;
    uint32_t            h_right;
    uint32_t            reg_indent;
    uint32_t            curr_x;
    int                 k;

    reg_text[0] = NULL;
    reg_text[1] = NULL;
    reg_text[2] = NULL;

    ban_line.first = NULL;

    /* calc banner horizontal margins */
    ban_left  = g_page_left_org + ban->ban_left_adjust;
    ban_right = g_page_right_org - ban->ban_right_adjust;

    content_reg( ban );
    curr_x = 0;

    for( k = 0; k < 3; ++k ) {          // for all region parts
        if( reg_text[k] == NULL ) {
            continue;                   // skip empty part
        }
        if( top ) {
            g_prev_font = reg_text[k]->font;
        }
        if( ban_line.first == NULL ) {
            ban_line.first = reg_text[k];
            ban_line.line_height = wgml_fonts[reg_text[k]->font].line_height;
        } else {
            ban_line.last->next = reg_text[k];
            reg_text[k]->prev = ban_line.last;
        }
        if( ban_line.line_height < wgml_fonts[reg_text[k]->font].line_height ) {
            ban_line.line_height = wgml_fonts[reg_text[k]->font].line_height;
        }
        curr_t = reg_text[k];
        ban_line.last  = reg_text[k];

        h_left  = ban_left;
        h_right = ban_right;
        reg_indent = ban->region->reg_indent;
        if( ban->region->hoffset.su_u >= SU_lay_left  ) {   // symbolic
            if( ban->region->hoffset.su_u == SU_lay_left ) {
                h_left += reg_indent;
            } else if( ban->region->hoffset.su_u == SU_lay_right ) {
                h_right -= reg_indent;
            } else if( ban->region->hoffset.su_u == SU_lay_centre ) {
                h_left += reg_indent;
            }
        } else {                            // in horiz space units
            h_left += reg_indent + ban->region->reg_hoffset;
        }

        if( ban->region->region_position == pos_center || k == 1) {
            if( h_left + curr_t->width < h_right ) {
                h_left += (h_right - h_left - curr_t->width) / 2;
                curr_x = h_left;
            }
        } else if( ban->region->region_position == pos_right || k == 2) {
            h_left = h_right - curr_t->width;
            curr_x = h_left;
        }
        if( curr_x == 0 ) {
            curr_x = h_left;
        }
        curr_t->x_address = curr_x;
        curr_x += curr_t->width;

    }
    if( ban_line.first != NULL) {
        if( input_cbs->fmflags & II_research ) {
            test_out_t_line( &ban_line );
        }

        /*******************************************************************/
        /*  truncate the left part(s) in case of overlap                   */
        /*******************************************************************/
        curr_p = ban_line.first;

        for( curr_t = curr_p->next; curr_t != NULL; curr_t = curr_t->next ) {
            while( (curr_p->x_address + curr_p->width) > curr_t->x_address ) {
                if( curr_p->count < 2) {// sanity check
                   break;
                }
                curr_p->count -= 1;     // truncate text, adjust width
                curr_p->width -= wgml_fonts[curr_p->font].width_table[(unsigned char)curr_p->text[curr_p->count]];
            }
            curr_p = curr_t;
        }

        /*  insert ban_line into t_page                                 */
        /*  this will do multiple columns, but not in sorted order      */
        /*  ban_line is taken to be a linked list of text_lines when    */
        /*  a banregion has depth > 1 and enough text to fill the       */
        /*  first line                                                  */
        /*  this will need adjustment as banner output is enhanced      */

        if( top ) {
            if( t_page.top_ban == NULL ) {
                t_page.top_ban = alloc_ban_col();
                last = t_page.top_ban;
            } else {
                for( ; last->next != NULL; last = last->next );
                last->next = alloc_ban_col();
                last = last->next;
            }
        } else {
            if( t_page.bot_ban == NULL ) {
                t_page.bot_ban = alloc_ban_col();
                last = t_page.bot_ban;
            } else {
                for( ; last->next != NULL; last = last->next );
                last->next = alloc_ban_col();
                last = last->next;
            }
        }
        last->first = alloc_doc_el( el_text );
        last->first->top_skip = ban->top_line->reg_voffset;
        last->first->subs_skip = ban->top_line->reg_voffset;
        last->first->element.text.first = alloc_text_line();

        last->first->element.text.first->next = ban_line.next;
        last->first->element.text.first->line_height = ban_line.line_height;
        last->first->element.text.first->spacing = 0;   // hbus; banners are always single-spaced
        last->first->element.text.first->y_address = ban_line.y_address;
        last->first->element.text.first->first = ban_line.first;
        last->first->element.text.first->last = ban_line.last;
        ban_line.first = NULL;
    }
}
Exemplo n.º 3
0
static  void    hx_header( int hx_lvl, const char *hnumstr, const char *txt )
{
    doc_element     *   cur_el;
    font_number         font_save;
    font_number         font;
    int32_t             width;
    int32_t             widthn;
    text_chars      *   curr_t;
    text_chars      *   curr_tn;
    text_line       *   hd_line;

    hd_line = NULL;
    font_save = g_curr_font;
    g_spacing_ln = layout_work.hx[hx_lvl].spacing;

    if( layout_work.hx[hx_lvl].line_break ) {
        set_skip_vars( &layout_work.hx[hx_lvl].pre_skip,
                       &layout_work.hx[hx_lvl].pre_top_skip,
                       &layout_work.hx[hx_lvl].post_skip,
                       g_spacing_ln,
                       layout_work.hx[hx_lvl].number_font );
    } else {
        set_skip_vars( &layout_work.hx[hx_lvl].pre_skip,
                       &layout_work.hx[hx_lvl].pre_top_skip,
                       NULL,
                       g_spacing_ln,
                       layout_work.hx[hx_lvl].number_font );
    }

    post_space = 0;

    curr_t  = NULL;
    curr_tn = NULL;
    width   = 0;
    widthn  = 0;
    hd_line = alloc_text_line();

    if( layout_work.hx[hx_lvl].number_form != num_none ) {
        font = layout_work.hx[hx_lvl].number_font;
        curr_tn = alloc_text_chars( hnumstr, strlen( hnumstr ), font );
        curr_tn->width = cop_text_width( curr_tn->text, curr_tn->count, font );
        widthn = curr_tn->width + wgml_fonts[font].spc_width;;

        hd_line->first = curr_tn;
        hd_line->line_height = wgml_fonts[font].line_height;
        hd_line->last = curr_tn;
    }

    if( (txt != NULL) && (*txt != '\0') ) {
        font = layout_work.hx[hx_lvl].font;

        curr_t = alloc_text_chars( txt, strlen( txt ), font );
        curr_t->width = cop_text_width( curr_t->text, curr_t->count, font );
        width = curr_t->width;

        if( hd_line->first == NULL ) {
            hd_line->first = curr_t;
        } else {
            curr_tn->next = curr_t;
            curr_t->prev  = curr_tn;
        }
        hd_line->last = curr_t;
        if( hd_line->line_height < wgml_fonts[font].line_height ) {
            hd_line->line_height = wgml_fonts[font].line_height;
        }
    }
    if( curr_t == NULL ) {
        curr_t = curr_tn;
        curr_tn = NULL;
        width = widthn;
        widthn = 0;
    }
    g_cur_left = g_page_left + conv_hor_unit( &layout_work.hx[hx_lvl].indent )
                             + conv_hor_unit( &layout_work.hx[hx_lvl].align );

    if( layout_work.hx[hx_lvl].page_position == pos_left ) {
        if( curr_tn != NULL ) {
            curr_tn->x_address = g_cur_left;
        }
        curr_t->x_address = g_cur_left + widthn;
    } else {
        if( layout_work.hx[hx_lvl].page_position == pos_center ) {
            curr_t->x_address = g_cur_left + widthn
                             + (g_page_right - g_cur_left - widthn - width) / 2;
        } else {
            curr_t->x_address = g_page_right - width;
        }
        if( curr_tn != NULL ) {
            curr_tn->x_address = curr_t->x_address - widthn;
        }
    }
    if( input_cbs->fmflags & II_research ) {
        test_out_t_line( hd_line );
    }
    cur_el = alloc_doc_el( el_text );
    cur_el->blank_lines = g_blank_lines;
    g_blank_lines = 0;
    cur_el->depth = hd_line->line_height;
    cur_el->subs_skip = g_subs_skip;
    cur_el->top_skip = g_top_skip;
    cur_el->element.text.overprint = ProcFlags.overprint;
    ProcFlags.overprint = false;
    cur_el->element.text.spacing = g_spacing;
    cur_el->element.text.first = hd_line;
    ProcFlags.skips_valid = false;
    hd_line = NULL;

    if( layout_work.hx[hx_lvl].page_eject == ej_no ) {
        insert_col_main( cur_el );
    } else {
        insert_page_width( cur_el );
    }
}