Example #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 );
    }
}
Example #2
0
void    gml_date( gml_tag gtag )
{
    char        *   p;
    doc_element *   cur_el;
    text_line   *   p_line;
    spacing_line    spacing_ln;
    font_number     font_save;

    if( !((ProcFlags.doc_sect == doc_sect_titlep) ||
          (ProcFlags.doc_sect_nxt == doc_sect_titlep)) ) {
        g_err( err_tag_wrong_sect, gml_tagname( gtag ), ":TITLEP section" );
        err_count++;
        show_include_stack();
    }

    if( ProcFlags.date_tag_seen ) {     // only one DATE tag allowed
        xx_line_err( err_2nd_date, buff2 );
    }

    ProcFlags.date_tag_seen = true;
    p = scan_start;
    if( *p && *p == '.' ) p++;          // over . to docnum

    while( *p == ' ' ) {                // over WS to attribute
        p++;
    }

    if( *p ) {                                              // date specified
        add_symvar( &global_dict, "date", p, no_subscript, 0 );
    }

    start_doc_sect();                   // if not already done

    p_line = alloc_text_line();
    p_line->line_height = wgml_fonts[layout_work.docnum.font].line_height;

    prep_date_line( p_line, p );

    spacing_ln = layout_work.titlep.spacing;
    font_save = g_curr_font;
    g_curr_font = layout_work.date.font;

    /************************************************************/
    /*  pre_skip is treated as pre_top_skip because it is       */
    /*  always used at the top of the page, despite the docs    */
    /************************************************************/
    set_skip_vars( NULL, &layout_work.date.pre_skip, NULL, spacing_ln, g_curr_font );

    cur_el = alloc_doc_el( el_text );
    cur_el->depth = p_line->line_height + g_spacing;
    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 = p_line;
    ProcFlags.skips_valid = false;
    p_line = NULL;
    insert_col_main( cur_el );

    g_curr_font = font_save;
    scan_start = scan_stop;
}
Example #3
0
void    gml_binclude( gml_tag gtag )
{
    bool            depth_found             = false;
    bool            file_found              = false;
    bool            has_rec_type            = false;
    bool            reposition;
    bool            reposition_found        = false;
    char            file[FILENAME_MAX];
    char            rt_buff[MAX_FILE_ATTR];
    char        *   p;
    doc_element *   cur_el;
    su              depth_su;
    uint32_t        depth;
    size_t          len;

    if( (ProcFlags.doc_sect < doc_sect_gdoc) ) {
        if( (ProcFlags.doc_sect_nxt < doc_sect_gdoc) ) {
            xx_tag_err( err_tag_before_gdoc, gml_tagname( gtag ) );
            scan_start = scan_stop;
            return;
        }
    }
    len = 0;
    file[0] = '\0';
    rt_buff[0] = '\0';
    p = scan_start;
    for( ;; ) {
        while( *p == ' ' ) {            // over WS to attribute
            p++;
        }
        if( *p == '\0' ) {              // end of line: get new line
            if( !(input_cbs->fmflags & II_eof) ) {
                if( get_line( true ) ) {      // next line for missing attribute
                    process_line();
                    if( (*scan_start == SCR_char) ||    // cw found: end-of-tag
                        (*scan_start == GML_char) ) {   // tag found: end-of-tag
                        ProcFlags.tag_end_found = true;
                        break;
                    } else {
                        p = scan_start; // new line is part of current tag
                        continue;
                    }
                }
            }
        }
        if( !strnicmp( "file", p, 4 ) ) {
            p += 4;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            file_found = true;
            len = val_len;
            if( len >= FILENAME_MAX )
                len = FILENAME_MAX - 1;
            memcpy( file, val_start, len );
            file[len] = '\0';
            split_attr_file( file, rt_buff, MAX_FILE_ATTR );
            if( (rt_buff[0] != '\0') ) {
                has_rec_type = true;
                if( rt_buff[0] != 't' ) {
                    xx_warn( wng_rec_type_binclude );
                }
            }
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "depth", p, 5 ) ) {
            p += 5;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            depth_found = true;
            if( att_val_to_su( &depth_su, true ) ) {
                return;
            }
            depth = conv_vert_unit( &depth_su, g_spacing_ln );
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "reposition", p, 10 ) ) {
            p += 10;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            reposition_found = true;
            if( !strnicmp( "start", val_start, 5 ) ) {
                reposition = true;  // moving following text down by depth
            } else if( !strnicmp( "end", val_start, 3 ) ) {
                reposition = false; // device at proper position after insertion
            } else {
                xx_line_err( err_inv_att_val, val_start );
                scan_start = scan_stop;
                return;
            }
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else {    // no match = end-of-tag in wgml 4.0
            ProcFlags.tag_end_found = true;
            break;
        }
    }
    // detect missing required attributes
    if( !depth_found || !file_found || !reposition_found ) {
        xx_err( err_att_missing );
        scan_start = scan_stop;
        return;
    }

    scr_process_break();                // flush existing text
    start_doc_sect();                   // if not already done

    cur_el = alloc_doc_el(  el_binc );
    if( reposition && depth ) {
        cur_el->depth = depth;          // otherwise, it will be "0"
    }
    if( depth > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
        cur_el->blank_lines = g_blank_lines;
        g_blank_lines = 0;
        cur_el->subs_skip = g_subs_skip;
        cur_el->top_skip = g_top_skip;
    }
    cur_el->element.binc.depth = depth;
    cur_el->element.binc.cur_left = g_cur_h_start;
    cur_el->element.binc.has_rec_type = has_rec_type;
    ProcFlags.skips_valid = false;
    memcpy( cur_el->element.binc.file, file, len + 1 );
    insert_col_main( cur_el );

    scan_start = scan_stop;         // skip following text
}
Example #4
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;
    }
}
Example #5
0
void    gml_docnum( const gmltag * entry )
{
    char        *   p;
    doc_element *   cur_el;
    text_line   *   p_line;
    int8_t          d_spacing;
    font_number     font_save;
    int32_t         rc;
    symsub      *   docnumval;
 
 
    if( !((ProcFlags.doc_sect == doc_sect_titlep) ||
          (ProcFlags.doc_sect_nxt == doc_sect_titlep)) ) {
        g_err( err_tag_wrong_sect, entry->tagname, ":TITLEP section" );
        err_count++;
        show_include_stack();
    }

    if( ProcFlags.docnum_tag_seen ) {   // only one DOCNUM tag allowed
        xx_line_err( err_2nd_docnum, buff2 );
    }

    ProcFlags.docnum_tag_seen = true;
    p = scan_start;
    if( *p && *p == '.' ) p++;          // over . to docnum

    while( *p == ' ' ) {                // over WS to attribute
        p++;
    }
    rc = find_symvar( &sys_dict, "$docnum", no_subscript, &docnumval );
    if( *p ) {                          // docnum specified
        strcpy_s( docnumval->value, 60, p );
    } else {
        *(docnumval->value) = 0;
    }
 
    start_doc_sect();                   // if not already done

    p_line = alloc_text_line();
    p_line->line_height = wgml_fonts[layout_work.docnum.font].line_height;
    prep_docnum_line( p_line, docnumval->value );
 
    d_spacing = layout_work.titlep.spacing;
    font_save = g_curr_font;
    g_curr_font = layout_work.docnum.font;

    /************************************************************/
    /*  pre_skip is treated as pre_top_skip because it is       */
    /*  always used at the top of the page, despite the docs    */
    /************************************************************/

    set_skip_vars( NULL, &layout_work.docnum.pre_skip, NULL, d_spacing, g_curr_font );
 
    cur_el = alloc_doc_el( el_text );
    cur_el->blank_lines = g_blank_lines;
    g_blank_lines = 0;
    cur_el->depth = p_line->line_height + g_spacing;
    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 = p_line;
    ProcFlags.skips_valid = false;
    p_line = NULL;
    insert_col_main( cur_el );

    g_curr_font = font_save;
    scan_start = scan_stop + 1;
}
Example #6
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 );
    }
}
Example #7
0
bool split_element( doc_element * a_element, uint32_t req_depth )
{
    bool            splittable;
    doc_element *   split_el;
    text_line   *   cur_line;
    text_line   *   last;
    uint32_t        count;
    uint32_t        cur_depth;

    count = 0;
    cur_depth = 0;
    last = NULL;
    splittable = true;

    switch( a_element->type ) {
    // add code for other element types; FIGs are documented to split only
    // when they will not fit by themselves on a page
    case el_binc :  // given how BINCLUDE/GRAPHIC work, this seems reasonable 
    case el_dbox :  // splitting boxes/lines is probably best done elsewhere
    case el_graph :
    case el_hline :
    case el_vline :
        splittable = false;     
        break;
    case el_text :
        for( cur_line = a_element->element.text.first; cur_line != NULL;
                                cur_line = cur_line->next ) {
            if( (cur_depth + cur_line->line_height) > req_depth ) {
                break;
            }
            count++;
            cur_depth += cur_line->line_height;
            last = cur_line;
        }

        if( cur_line != NULL ) {    // at least one more line
            if( count < g_cur_threshold ) {
                splittable = false;     // widow criteria failed
                a_element->blank_lines = 0;
                break;
            }
        }

        if( last == NULL ) {        // all lines fit; unlikely, but seen
            break;
        }

        /*  if we get here, a_element is splittable, cur_line is    */
        /*  the first line of the new element, and last is the last */
        /*  line that can be left in the original element           */

        split_el = alloc_doc_el( el_text ); // most defaults are correct

        split_el->depth = a_element->depth - cur_depth;
        split_el->element.text.first = cur_line;
        last->next = NULL;
        a_element->depth = cur_depth;
        if( a_element->next == NULL ) {
            a_element->next = split_el;
        } else {
            split_el->next = a_element->next;
            a_element->next = split_el;
        }
        
        break;
    default :
        internal_err( __FILE__, __LINE__ );
    }
    return( splittable );
}
Example #8
0
void    gml_graphic( gml_tag gtag )
{
    bool            depth_found             = false;
    bool            file_found              = false;
    char            file[FILENAME_MAX];
    char            rt_buff[MAX_FILE_ATTR];
    char        *   p;
    char        *   pa;
    doc_element *   cur_el;
    su              cur_su;
    uint32_t        depth;
    uint32_t        scale                   = 100;
    // the initial value of width is only correct for one-column pages.
    uint32_t        width                   = g_net_page_width;
    int32_t         xoff                    = 0;
    int32_t         yoff                    = 0;
    size_t          len;

    if( (ProcFlags.doc_sect < doc_sect_gdoc) ) {
        if( (ProcFlags.doc_sect_nxt < doc_sect_gdoc) ) {
            xx_tag_err( err_tag_before_gdoc, gml_tagname( gtag ) );
            scan_start = scan_stop;
            return;
        }
    }
    len = 0;
    file[0] = '\0';
    rt_buff[0] = '\0';
    p = scan_start;
    for( ;; ) {
        while( *p == ' ' ) {            // over WS to attribute
            p++;
        }
        if( *p == '\0' ) {              // end of line: get new line
            if( !(input_cbs->fmflags & II_eof) ) {
                if( get_line( true ) ) {      // next line for missing attribute
                    process_line();
                    if( (*scan_start == SCR_char) ||    // cw found: end-of-tag
                        (*scan_start == GML_char) ) {   // tag found: end-of-tag
                        ProcFlags.tag_end_found = true;
                        break;
                    } else {
                        p = scan_start; // new line is part of current tag
                        continue;
                    }
                }
            }
        }
        if( !strnicmp( "file", p, 4 ) ) {
            p += 4;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            file_found = true;
            len = val_len;
            if( len >= FILENAME_MAX )
                len = FILENAME_MAX - 1;
            memcpy( file, val_start, len );
            file[len] = '\0';
            split_attr_file( file, rt_buff, sizeof( rt_buff ) );
            if( (rt_buff[0] != '\0') ) {
                xx_warn( wng_rec_type_graphic );
            }
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "depth", p, 5 ) ) {
            p += 5;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            depth_found = true;
            pa = val_start;
            if( att_val_to_su( &cur_su, true ) ) {
                return;
            }
            depth = conv_vert_unit( &cur_su, g_spacing_ln );
            if( depth == 0 ) {
                xx_line_err( err_inv_depth_graphic, pa );
                scan_start = scan_stop;
                return;
            }
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "width", p, 5 ) ) {
            p += 5;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            if( !strnicmp( "page", val_start, 4 ) ) {
                // default value is the correct value to use
            } else if( !strnicmp( "column", val_start, 6 ) ) {
                // default value is the correct value to use
            } else {    // value actually specifies the width
                pa = val_start;
                if( att_val_to_su( &cur_su, true ) ) {
                    return;
                }
                width = conv_hor_unit( &cur_su );
                if( width == 0 ) {
                    xx_line_err( err_inv_width_graphic, pa );
                    scan_start = scan_stop;
                    return;
                }
                /* there should be a check somewhere for width > page width */
            }
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "scale", p, 5 ) ) {
            p += 5;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            pa = val_start;
            if( (*pa == '+') || (*pa == '-') ) {  // signs not allowed
                xx_line_err( err_num_too_large, pa );
                scan_start = scan_stop;
                return;
            }
            scale = 0;
            while( (*pa >= '0') && (*pa <= '9') ) { // convert to number
                scale = (10 * scale) + (*pa - '0');
                pa++;
                if( (pa - val_start) > val_len ) {  // value end reached
                    break;
                }
            }
            if( scale > 0x7fffffff ) {              // wgml 4.0 limit
                xx_line_err( err_num_too_large, val_start );
                scan_start = scan_stop;
                return;
            }
            if( (pa - val_start) < val_len ) {      // value continues on
                xx_line_err( err_num_too_large, val_start );
                scan_start = scan_stop;
                return;
            }
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "xoff", p, 4 ) ) {
            p += 4;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            if( att_val_to_su( &cur_su, false ) ) {
                return;
            }
            xoff = conv_hor_unit( &cur_su );
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else if( !strnicmp( "yoff", p, 4 ) ) {
            p += 4;
            p = get_att_value( p );
            if( val_start == NULL ) {
                break;
            }
            if( att_val_to_su( &cur_su, false ) ) {
                return;
            }
            yoff = conv_vert_unit( &cur_su, g_spacing_ln );
            if( ProcFlags.tag_end_found ) {
                break;
            }
        } else {    // no match = end-of-tag in wgml 4.0
            ProcFlags.tag_end_found = true;
            break;
        }
    }
    if( !depth_found || !file_found ) { // detect missing required attributes
        xx_err( err_att_missing );
        scan_start = scan_stop;
        return;
    }

    scr_process_break();                // flush existing text
    start_doc_sect();                   // if not already done

    cur_el = alloc_doc_el( el_graph );
    cur_el->depth = depth;              // always used with GRAPHIC
    if( !ProcFlags.ps_device ) {        // character devices ignore SK & post_skip
        g_skip = 0;
        g_post_skip = 0;
    }
    set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
    cur_el->blank_lines = g_blank_lines;
    g_blank_lines = 0;
    cur_el->subs_skip = g_subs_skip;
    g_subs_skip = 0;
    cur_el->top_skip = g_top_skip;
    g_top_skip = 0;
    cur_el->element.graph.cur_left = g_cur_h_start;
    cur_el->element.graph.depth = depth;
    cur_el->element.graph.scale = scale;
    cur_el->element.graph.width = width;
    cur_el->element.graph.xoff = xoff;
    cur_el->element.graph.yoff = yoff;
    ProcFlags.skips_valid = false;
    memcpy( cur_el->element.graph.file, file, len + 1 );
    insert_col_main( cur_el );

    if( *p == '.' ) {
        p++;
    }
    scan_start = p;                 // process following text
}
Example #9
0
void    gml_title( gml_tag gtag )
{
    char        *   p;
    doc_element *   cur_el;
    text_line   *   p_line      = NULL;
    spacing_line    spacing_ln;
    font_number     font_save;

    if( !((ProcFlags.doc_sect == doc_sect_titlep) ||
          (ProcFlags.doc_sect_nxt == doc_sect_titlep)) ) {
        g_err( err_tag_wrong_sect, gml_tagname( gtag ), ":TITLEP section" );
        err_count++;
        show_include_stack();
    }
    p = scan_start;
    if( *p && *p != '.' ) p++;

    while( *p == ' ' ) {                // over WS to attribute
        p++;
    }
    if( *p &&
        ! (strnicmp( "stitle ", p, 7 ) &&   // look for stitle
           strnicmp( "stitle=", p, 7 )) ) {
        char        quote;
        char    *   valstart;

        p += 6;
        while( *p == ' ' ) {
            p++;
        }
        if( *p == '=' ) {
            p++;
            while( *p == ' ' ) {
                p++;
            }
        }
        if( *p == '"' || *p == '\'' ) {
            quote = *p;
            ++p;
        } else {
            quote = ' ';
        }
        valstart = p;
        while( *p && *p != quote ) {
            ++p;
        }
        *p = '\0';
        if( !ProcFlags.stitle_seen ) {  // first stitle goes into dictionary
            add_symvar( &global_dict, "$stitle", valstart, no_subscript, 0 );
            ProcFlags.stitle_seen = true;
        }
        p++;
    }

    if( *p == '.' ) p++;                // over '.'
    if( !ProcFlags.title_text_seen ) {
        if( *p ) {                      // first title goes into dictionary
            add_symvar( &global_dict, "$title", p, no_subscript, 0 );
        }
    }

    start_doc_sect();                   // if not already done

    font_save = g_curr_font;
    g_curr_font = layout_work.title.font;
    spacing_ln = layout_work.titlep.spacing;
    if( !ProcFlags.title_tag_top ) {
        set_skip_vars( NULL, &layout_work.title.pre_top_skip, NULL, spacing_ln, g_curr_font );
        ProcFlags.title_tag_top = true;
    } else {
        set_skip_vars( &layout_work.title.skip, NULL, NULL, spacing_ln, g_curr_font );
    }

    p_line = alloc_text_line();
    p_line->line_height = wgml_fonts[g_curr_font].line_height;
    if( *p ) {
        prep_title_line( p_line, p );
    }
    cur_el = alloc_doc_el( el_text );
    cur_el->blank_lines = g_blank_lines;
    g_blank_lines = 0;
    cur_el->depth = p_line->line_height + g_spacing;
    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 = p_line;
    ProcFlags.skips_valid = false;
    p_line = NULL;
    insert_col_main( cur_el );

    g_curr_font = font_save;
    scan_start = scan_stop;
}