Exemple #1
0
static  void    gml_li_sl( const gmltag * entry )
{
    char        *   p;
    int32_t         t_left_indent_1 = 0;
    int32_t         t_left_indent_2 = 0;
    int32_t         t_right_indent  = 0;

    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    scr_process_break();

    if( ProcFlags.need_li_lp ) {        // first :li for this list
        set_skip_vars( &nest_cb->xl_pre_skip, NULL, NULL, 1, g_curr_font );
    } else if( !nest_cb->compact ) {
        set_skip_vars( &((sl_lay_level *)(nest_cb->lay_tag))->skip, NULL,
                       NULL, 1, g_curr_font );
    } else {                            // compact
        set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
    }

    ProcFlags.keep_left_margin = true;  // keep special Note indent

    /* Use original indents, not values possibly modified by IN */

    t_left_indent_1 = conv_hor_unit( &((sl_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font )
                            + nest_cb->prev->left_indent + nest_cb->prev->align;
    t_left_indent_2 = conv_hor_unit( &((sl_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font );
    t_right_indent = -1 * conv_hor_unit( &((sl_lay_level *)(nest_cb->lay_tag))->right_indent, g_curr_font )
                            + nest_cb->prev->right_indent;
    g_cur_left = nest_cb->lm + t_left_indent_2;
    g_page_right = nest_cb->rm + t_right_indent;

    g_cur_h_start = g_cur_left;
    post_space = 0;
    ju_x_start = g_cur_h_start;

    g_curr_font = ((sl_lay_level *)(nest_cb->lay_tag))->font;
    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial spaces
    ProcFlags.need_li_lp = false;
    if( *p ) {
        process_text( p, g_curr_font ); // if text follows
    }

    /* Set indents to their original values for the next LI */

    nest_cb->left_indent  = t_left_indent_1;
    nest_cb->right_indent = t_right_indent;

    scan_start = scan_stop + 1;
    return;
}
Exemple #2
0
void    proc_p_pc( p_lay_tag * p_pc )
{
    char        *   p;

    scan_err = false;
    p = scan_start;

    ProcFlags.keep_left_margin = true;  //    special Note indent
    start_doc_sect();                   // if not already done

    scr_process_break();
    if( nest_cb->c_tag == t_NONE ) {
        g_cur_left = g_page_left + g_indent;// left start    TBD
    } else {
        g_cur_left = g_cur_left;
    }
                                        // possibly indent first line
    g_cur_h_start = g_cur_left + conv_hor_unit( &(p_pc->line_indent) );

    g_cur_threshold = layout_work.widow.threshold; // standard threshold

    if( *p == '.' ) p++;                // over '.'

    set_skip_vars( &(p_pc->pre_skip), NULL, &(p_pc->post_skip), spacing, g_curr_font );

    post_space = 0;

    process_text( p, g_curr_font );

    scan_start = scan_stop + 1;
    return;
}
Exemple #3
0
extern void gml_abstract( const gmltag * entry )
{
    if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) {
        xx_line_err( err_eof_expected, tok_start );
        return;
    }
    if( !ProcFlags.frontm_seen ) {
        xx_line_err( err_doc_sec_expected_1, tok_start );
        return;
    }
    if( blank_lines > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_abstract );
    g_cur_left = g_page_left;
    g_cur_h_start = g_page_left;

    if( layout_work.hx.hx_sect[hds_abstract].header ) {
        start_doc_sect();                           // a header is enough
    }
    g_indent = 0;
    g_indentr = 0;
    set_h_start();
}
Exemple #4
0
static  void    gml_li_sl( const gmltag * entry )
{
    char        *   p;

    entry = entry;
    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    scr_process_break();

    if( ProcFlags.need_li_lp ) {        // first :li for this list
        set_skip_vars( &((sl_lay_tag *)(nest_cb->lay_tag))->pre_skip, NULL, NULL, 1, g_curr_font );
    } else if( !nest_cb->compact ) {
        set_skip_vars( &((sl_lay_tag *)(nest_cb->lay_tag))->skip, NULL, NULL, 1, g_curr_font );
    } else {                            // compact
        set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
    }

    ProcFlags.keep_left_margin = true;  // keep special Note indent

    g_cur_left = nest_cb->lm + nest_cb->left_indent;
    g_cur_h_start = g_cur_left;
    g_page_right = nest_cb->rm - nest_cb->right_indent;

    post_space = 0;
    g_cur_h_start = g_cur_left;
    ju_x_start = g_cur_h_start;

    spacing = ((sl_lay_tag *)(nest_cb->lay_tag))->spacing;
    g_curr_font = ((sl_lay_tag *)(nest_cb->lay_tag))->font;
    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial spaces
    ProcFlags.need_li_lp = false;
    if( *p ) {
        process_text( p, g_curr_font ); // if text follows
    }

    scan_start = scan_stop + 1;
    return;
}
Exemple #5
0
void    gml_eul( const gmltag * entry )
{
    scr_process_break();
    if( nest_cb->c_tag == t_UL ) {
        set_skip_vars( NULL, NULL,
            &((ul_lay_tag *)(nest_cb->lay_tag))->post_skip, 1, g_curr_font );
    }
    gml_exl_common( entry, t_UL );
}
Exemple #6
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 );
    }
}
Exemple #7
0
void    gml_egdoc( gml_tag gtag )
{
    gtag = gtag;
    if( g_blank_lines_ln > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();                // outputs last element in file
    if( !ProcFlags.start_section ) {
        start_doc_sect();               // if not already done
    }
    gml_doc_xxx( doc_sect_egdoc );
}
Exemple #8
0
void    gml_backm( gml_tag gtag )
{
    gtag = gtag;
    if( g_blank_lines_ln > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_backm );
    ProcFlags.frontm_seen = false;  // no longer in FRONTM section
    if( !ProcFlags.fb_document_done ) { // the very first section/page
        do_layout_end_processing();
    }
}
Exemple #9
0
void    gml_eul( const gmltag * entry )
{
    if( g_line_indent == 0 ) {
        ProcFlags.para_starting = false;    // clear for this tag's break
    }
    scr_process_break();
    set_skip_vars( NULL, NULL, &((ul_lay_level *)(nest_cb->lay_tag))->post_skip, 1, g_curr_font );
    gml_exl_common( entry, t_UL );
    if( ul_cur_level == 1 ) {
        ul_cur_level = layout_work.ul.max_level;
    } else {
        ul_cur_level++;
    }
}
Exemple #10
0
extern void gml_appendix( const gmltag * entry )
{
    if( blank_lines > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_appendix );
    ProcFlags.frontm_seen = false;  // no longer in FRONTM section
    if( !ProcFlags.fb_document_done ) { // the very first section/page
        do_layout_end_processing();
    }
    g_indent = 0;
    g_indentr = 0;
    set_h_start();
}
Exemple #11
0
void    gml_preface( gml_tag gtag )
{
    gtag = gtag;
    if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) {
        xx_line_err( err_eof_expected, tok_start );
        return;
    }
    if( !ProcFlags.frontm_seen ) {
        xx_line_err( err_doc_sec_expected_1, tok_start );
        return;
    }
    if( g_blank_lines_ln > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_preface );
    g_spacing_ln = layout_work.preface.spacing;
}
Exemple #12
0
void    gml_body( gml_tag gtag )
{
    gtag = gtag;
    if( g_blank_lines_ln > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_body );

    ProcFlags.just_override = true;     // justify for first line ?? TBD
    g_cur_left = g_page_left;
    g_cur_h_start = g_page_left
                    + conv_hor_unit( &layout_work.p.line_indent );

    ProcFlags.frontm_seen = false;      // no longer in FRONTM section
    if( !ProcFlags.fb_document_done ) { // the very first section/page
        do_layout_end_processing();
    }
}
Exemple #13
0
extern void gml_backm( const gmltag * entry )
{
    if( !ProcFlags.fb_document_done ) { // the very first section/page
        do_layout_end_processing();
    }

    if( blank_lines > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_backm );
    ProcFlags.frontm_seen = false;  // no longer in FRONTM section
    g_cur_left = g_page_left;
    g_cur_h_start = g_page_left;

    if( layout_work.hx.hx_sect[hds_backm].header ) {
        start_doc_sect();                           // a header is enough
    }
    g_indent = 0;
    g_indentr = 0;
}
Exemple #14
0
void    proc_p_pc( p_lay_tag * p_pc )
{
    char        *   p;

    scan_err = false;
    p = scan_start;

    ProcFlags.keep_left_margin = true;  // special Note indent
    start_doc_sect();                   // if not already done

    if( g_line_indent == 0 ) {
        ProcFlags.para_starting = false;    // clear for this tag's break
    }
    scr_process_break();
    g_line_indent = conv_hor_unit( &(p_pc->line_indent), g_curr_font );
    g_cur_left = g_page_left + g_indent + nest_cb->left_indent + nest_cb->align;// left start    TBD
    // possibly indent first line
    g_cur_h_start = g_cur_left + g_line_indent;

    g_cur_threshold = layout_work.widow.threshold; // standard threshold

    if( *p == '.' ) p++;                // over '.'

    set_skip_vars( &(p_pc->pre_skip), NULL, &(p_pc->post_skip), spacing,
                   g_curr_font );

    ProcFlags.para_starting = true;     // for next break, not this tag's break

    post_space = 0;

    if( *p ) {
        process_text( p, g_curr_font );
    }

    scan_start = scan_stop + 1;
    return;
}
Exemple #15
0
extern void gml_body( const gmltag * entry )
{
    if( blank_lines > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();
    gml_doc_xxx( doc_sect_body );

    ProcFlags.just_override = true;     // justify for first line ?? TBD
    g_cur_left = g_page_left;
    g_cur_h_start = g_page_left
                    + conv_hor_unit( &layout_work.p.line_indent, g_curr_font );

    ProcFlags.frontm_seen = false;      // no longer in FRONTM section
    if( !ProcFlags.fb_document_done ) { // the very first section/page
        do_layout_end_processing();
    }
    if( layout_work.hx.hx_sect[hds_body].header ) {
        start_doc_sect();                           // a header is enough
    }
    g_indent = 0;
    g_indentr = 0;
    set_h_start();
}
Exemple #16
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;
}
Exemple #17
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;
}
Exemple #18
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 );
    }
}
Exemple #19
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
}
Exemple #20
0
void    gml_lp( const gmltag * entry )
{
    char        *   p;
    su          *   list_skip_su;
    su          *   lp_skip_su;
    su          *   pre_skip_su;

    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    switch( nest_cb->c_tag ) {
    case t_OL :
        list_skip_su = &((ol_lay_tag *)(nest_cb->lay_tag))->pre_skip;
        break;
    case t_SL :
        list_skip_su = &((sl_lay_tag *)(nest_cb->lay_tag))->pre_skip;
        break;
    case t_UL :
        list_skip_su = &((ul_lay_tag *)(nest_cb->lay_tag))->pre_skip;
        break;
    case t_DL :             // TBD
        list_skip_su = &((dl_lay_tag *)(nest_cb->lay_tag))->pre_skip;
        break;
    case t_GL :             // TBD
        list_skip_su = &((gl_lay_tag *)(nest_cb->lay_tag))->pre_skip;
        break;
    default:
        break;
    }
    lp_skip_su = &layout_work.lp.pre_skip;

    gml_xl_lp_common( entry, t_LP );

    nest_cb->compact = false;

    nest_cb->li_number    = 0;
    nest_cb->left_indent  = conv_hor_unit( &layout_work.lp.left_indent );
    nest_cb->right_indent = conv_hor_unit( &layout_work.lp.right_indent );
    nest_cb->lay_tag      = &layout_work.lp;

    nest_cb->lm = nest_cb->prev->lm + nest_cb->prev->left_indent;
    nest_cb->rm = nest_cb->prev->rm - nest_cb->prev->right_indent;

    scr_process_break();

    spacing = ((lp_lay_tag *)(nest_cb->lay_tag))->spacing;

    ProcFlags.keep_left_margin = true;  // keep special Note indent
    post_space = 0;

    if( ProcFlags.need_li_lp ) {        // :LP first tag in list
        pre_skip_su = greater_su( lp_skip_su, list_skip_su, spacing );
    } else {
        pre_skip_su = &((lp_lay_tag *)(nest_cb->lay_tag))->pre_skip;
    }
    set_skip_vars( NULL, pre_skip_su,
                   &((ol_lay_tag *)(nest_cb->lay_tag))->post_skip,
                   1, g_curr_font );

    g_cur_left = nest_cb->lm + nest_cb->left_indent;// left start
                                        // possibly indent first line
    g_cur_h_start = g_cur_left + conv_hor_unit( &(layout_work.lp.line_indent) );

    g_page_right = nest_cb->rm - nest_cb->right_indent;

    ju_x_start = g_cur_h_start;

    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial spaces
    ProcFlags.need_li_lp = false;       // :LI or :LP seen
    if( *p ) {
        process_text( p, g_curr_font ); // if text follows
    }

    scan_start = scan_stop + 1;
    return;
}
Exemple #21
0
static  void    gml_li_ul( const gmltag * entry )
{
    char        *   p;
    char            bullet[3];

    entry = entry;
    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    if( ((ul_lay_tag *)(nest_cb->lay_tag))->bullet_translate ) {
        bullet[0] = cop_in_trans( ((ul_lay_tag *)(nest_cb->lay_tag))->bullet,
                            ((ul_lay_tag *)(nest_cb->lay_tag))->bullet_font );
    } else {
        bullet[0] = ((ul_lay_tag *)(nest_cb->lay_tag))->bullet;
    }
    bullet[1] = ' ';                    // 1 trailing space as wgml4 does
    bullet[2] = 0;

    scr_process_break();

    if( ProcFlags.need_li_lp ) {        // first :li for this list
        set_skip_vars( &((ul_lay_tag *)(nest_cb->lay_tag))->pre_skip, NULL, NULL, 1, g_curr_font );
    } else if( !nest_cb->compact ) {
        set_skip_vars( &((ul_lay_tag *)(nest_cb->lay_tag))->skip, NULL, NULL, 1, g_curr_font );
    } else {                            // compact
        set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
    }


    spacing = ((ul_lay_tag *)(nest_cb->lay_tag))->spacing;
    g_curr_font = ((ul_lay_tag *)(nest_cb->lay_tag))->bullet_font;
    post_space = 0;

    g_cur_left = nest_cb->lm + nest_cb->left_indent;
    g_cur_h_start = g_cur_left;
    g_page_right = nest_cb->rm - nest_cb->right_indent;

    ProcFlags.keep_left_margin = true;  // keep special Note indent

    start_line_with_string( bullet, g_curr_font, true );
    g_cur_h_start = g_cur_left +
        conv_hor_unit( &(((ul_lay_tag *)(nest_cb->lay_tag))->align) );

    if( t_line != NULL ) {
        if( t_line->last != NULL ) {
            g_cur_left += t_line->last->width + post_space;
        }
    }
    post_space = 0;
    if( g_cur_h_start > g_cur_left ) {
        g_cur_left = g_cur_h_start;
    }
    g_cur_h_start = g_cur_left;
    ju_x_start = g_cur_h_start;

    spacing = ((ul_lay_tag *)(nest_cb->lay_tag))->spacing;
    g_curr_font = ((ul_lay_tag *)(nest_cb->lay_tag))->font;
    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial spaces
    ProcFlags.need_li_lp = false;
    if( *p ) {
        process_text( p, g_curr_font ); // if text fullows
    }

    scan_start = scan_stop + 1;
    return;
}
Exemple #22
0
void    gml_lp( const gmltag * entry )
{
    char        *   p;
    su          *   list_skip_su;
    su          *   lp_skip_su;
    su          *   pre_skip_su;

    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    list_skip_su = &nest_cb->xl_pre_skip;   // nest_cb on entry, not LP nest_cb
    lp_skip_su = &layout_work.lp.pre_skip;

    gml_xl_lp_common( t_LP );

    if( g_line_indent == 0 ) {
        ProcFlags.para_starting = false;    // clear for this tag's first break
    }
    scr_process_break();

    nest_cb->compact = false;

    nest_cb->li_number    = 0;
    nest_cb->left_indent  = conv_hor_unit( &layout_work.lp.left_indent, g_curr_font );
    nest_cb->right_indent = -1 * conv_hor_unit( &layout_work.lp.right_indent, g_curr_font );
    nest_cb->lay_tag      = &layout_work.lp;

    nest_cb->lm = nest_cb->prev->lm + nest_cb->prev->left_indent;
    nest_cb->rm = nest_cb->prev->rm + nest_cb->prev->right_indent;

    spacing = (int8_t) layout_work.lp.spacing;

    ProcFlags.keep_left_margin = true;  // keep special Note indent
    post_space = 0;

    if( ProcFlags.need_li_lp ) {        // :LP first tag in list
        pre_skip_su = greater_su( lp_skip_su, list_skip_su, spacing );
    } else {
        pre_skip_su = lp_skip_su;
    }
    set_skip_vars( pre_skip_su, NULL, &layout_work.lp.post_skip, 1, g_curr_font );

    g_cur_left = nest_cb->lm + nest_cb->left_indent;// left start
                                        // possibly indent first line
    g_line_indent = conv_hor_unit( &(layout_work.lp.line_indent), g_curr_font );
    g_cur_h_start = g_cur_left + g_line_indent;

    g_page_right = nest_cb->rm + nest_cb->right_indent;

    nest_cb->left_indent += nest_cb->prev->left_indent;
    nest_cb->right_indent += nest_cb->prev->right_indent;

    ju_x_start = g_cur_h_start;

    ProcFlags.need_li_lp = false;       // :LI or :LP seen
    ProcFlags.para_starting = true;     // for next break, not this tag's break

    if( *p == '.' ) p++;                // possible tag end
    while( *p == ' ' ) p++;             // skip initial spaces
    if( *p ) {
        process_text( p, g_curr_font ); // if text follows
    }

    scan_start = scan_stop + 1;
    return;
}
Exemple #23
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
}
Exemple #24
0
static  void    gml_li_ul( const gmltag * entry )
{
    char        *   p;
    char            bullet[3];
    int32_t         t_align         = 0;
    int32_t         t_left_indent_1 = 0;
    int32_t         t_left_indent_2 = 0;
    int32_t         t_right_indent  = 0;

    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    if( ((ul_lay_level *)(nest_cb->lay_tag))->bullet_translate ) {
        bullet[0] = cop_in_trans( ((ul_lay_level *)(nest_cb->lay_tag))->bullet,
                            ((ul_lay_level *)(nest_cb->lay_tag))->bullet_font );
    } else {
        bullet[0] = ((ul_lay_level *)(nest_cb->lay_tag))->bullet;
    }
    bullet[1] = ' ';                    // 1 trailing space as wgml4 does
    bullet[2] = 0;

    scr_process_break();

    if( ProcFlags.need_li_lp ) {        // first :li for this list
        set_skip_vars( &nest_cb->xl_pre_skip, NULL, NULL, 1, g_curr_font );
    } else if( !nest_cb->compact ) {
        set_skip_vars( &((ul_lay_level *)(nest_cb->lay_tag))->skip, NULL,
                       NULL, 1, g_curr_font );
    } else {                            // compact
        set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
    }

    g_curr_font = ((ul_lay_level *)(nest_cb->lay_tag))->bullet_font;
    post_space = 0;

    /* Use original indents, not values possibly modified by IN */

    if( g_indent > 0 ) {
        t_left_indent_1  = conv_hor_unit( &((ul_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font )
                            + nest_cb->prev->left_indent + nest_cb->prev->align;
    } else {
        t_left_indent_1  = conv_hor_unit( &((ul_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font )
                            + nest_cb->prev->left_indent;
    }
    t_left_indent_2  = conv_hor_unit( &((ul_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font );
    t_right_indent = -1 * conv_hor_unit( &((ul_lay_level *)(nest_cb->lay_tag))->right_indent, g_curr_font )
                            + nest_cb->prev->right_indent;
    g_cur_left = nest_cb->lm + t_left_indent_2;
    g_page_right = nest_cb->rm + t_right_indent;

    g_cur_h_start = g_cur_left;
    ProcFlags.keep_left_margin = true;  // keep special Note indent
    start_line_with_string( bullet, g_curr_font, true );

    t_align = conv_hor_unit( &((ul_lay_level *)(nest_cb->lay_tag))->align, g_curr_font );
    g_cur_h_start = g_cur_left + t_align;

    if( t_line != NULL ) {
        if( t_line->last != NULL ) {
            g_cur_left += t_line->last->width + post_space;
        }
    }
    post_space = 0;
    if( g_cur_h_start > g_cur_left ) {
        g_cur_left = g_cur_h_start;
    }
    g_cur_h_start = g_cur_left;
    ju_x_start = g_cur_h_start;

    g_curr_font = ((ul_lay_level *)(nest_cb->lay_tag))->font;
    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial spaces
    ProcFlags.need_li_lp = false;
    if( *p ) {
        process_text( p, g_curr_font ); // if text fullows
    }
    nest_cb->align = t_align;

    g_cur_left = nest_cb->lm + t_left_indent_2 + nest_cb->align;

    /* Set indents to their original values for the next LI */

    if( g_indent > 0 ) {
        nest_cb->left_indent = t_left_indent_1;
    } else {
        nest_cb->left_indent = t_left_indent_1 + nest_cb->prev->align;
    }
    nest_cb->right_indent = t_right_indent;

    scan_start = scan_stop + 1;
    return;
}
Exemple #25
0
extern  void    gml_xmp( const gmltag * entry )
{
    char    *   p;

    entry = entry;

    start_doc_sect();
    scr_process_break();
    scan_err = false;
    p = scan_start;
    if( *p == '.' ) {
        /* already at tag end */
    } else {
        p++;
        while( *p == ' ' ) {
            p++;
        }

        if( !strnicmp( "depth=", p, 6 ) ) {
            p += 6;
           /***************************************************************/
           /*  Although unsupported, scan depth='xxx'                     */
           /***************************************************************/
           g_warn( wng_unsupp_att, "depth" );
           wng_count++;
           file_mac_info();

           while( *p && *p != '.' ) {   // ignore all up to tag end
               p++;
           }
        }
    }
    if( ProcFlags.xmp_active ) {        // nested :XMP tag not supported
        g_err_tag_nest( "eXMP" );
        scan_start = scan_stop + 1;
        return;
    }

    /******************************************************************/
    /*  test for XMP within  :ADDRESS, :FIG , :FN                     */
    /******************************************************************/
    if( ProcFlags.address_active ) {
        g_err_tag_x_in_y( "XMP", "ADDRESS" );
        scan_start = scan_stop + 1;
        return;
    } else {
        if( ProcFlags.fig_active ) {
            g_err_tag_x_in_y( "XMP", "FIG" );
            scan_start = scan_stop + 1;
            return;
        } else {
            if( ProcFlags.fn_active ) {
                g_err_tag_x_in_y( "XMP", "FN" );
                scan_start = scan_stop + 1;
                return;
            }
        }
    }

    ProcFlags.xmp_active = true;
    first_xline = true;
    font_save = g_curr_font;
    g_curr_font = layout_work.xmp.font;

    if( nest_cb->c_tag == t_NONE ) {
        g_cur_left = g_page_left + conv_hor_unit( &layout_work.xmp.left_indent );
    } else {
        g_cur_left += conv_hor_unit( &layout_work.xmp.left_indent );
    }
    g_cur_h_start = g_cur_left;
    ProcFlags.keep_left_margin = true;  // keep special indent


    init_nest_cb();
    nest_cb->p_stack = copy_to_nest_stack();
    nest_cb->c_tag = t_XMP;

    spacing = layout_work.xmp.spacing;

    set_skip_vars( NULL, &layout_work.xmp.pre_skip, NULL, spacing, g_curr_font );

    ProcFlags.group_elements = true;

    justify_save = ProcFlags.justify;
    ProcFlags.justify = ju_off;         // TBD

    if( *p == '.' ) p++;                // possible tag end
    if( *p ) {
        process_text( p, g_curr_font ); // if text follows
    }
    scan_start = scan_stop + 1;
    return;
}
Exemple #26
0
static  void    gml_li_ol( const gmltag * entry )
{
    char            charnumber[MAX_L_AS_STR];
    char        *   p;
    char        *   pn;
    int32_t         t_align         = 0;
    int32_t         t_left_indent_1 = 0;
    int32_t         t_left_indent_2 = 0;
    int32_t         t_right_indent  = 0;
    uint32_t        num_len;

    scan_err = false;
    p = scan_start;

    if( nest_cb == NULL ) {
        xx_nest_err( err_li_lp_no_list );   // tag must be in a list
        scan_start = scan_stop + 1;
        return;
    }

    t_align = conv_hor_unit( &((ol_lay_level *)(nest_cb->lay_tag))->align, g_curr_font );

    nest_cb->li_number++;
    pn = format_num( nest_cb->li_number, charnumber, MAX_L_AS_STR,
                     ((ol_lay_level *)(nest_cb->lay_tag))->number_style );
    if( pn != NULL ) {
        num_len = strlen( pn );
        *(pn + num_len) = ' ';          // trailing space like wgml4 does
        *(pn + num_len + 1) = '\0';
        num_len++;
    } else {
        pn = charnumber;
        *pn = '?';
        *(pn + 1) = 0;
        num_len = 1;
    }

    scr_process_break();

    g_curr_font = ((ol_lay_level *)(nest_cb->lay_tag))->number_font;

    if( ProcFlags.need_li_lp ) {        // first :li for this list
        set_skip_vars( &nest_cb->xl_pre_skip, NULL, NULL, 1, g_curr_font );
    } else if( !nest_cb->compact ) {
        set_skip_vars( &((ol_lay_level *)(nest_cb->lay_tag))->skip, NULL,
                       NULL, 1, g_curr_font );
    } else {                            // compact
        set_skip_vars( NULL, NULL, NULL, 1, g_curr_font );
    }

    post_space = 0;

    /* Use original indents, not values possibly modified by IN */

    if( g_indent > 0 ) {
        t_left_indent_1 = conv_hor_unit( &((ol_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font )
                            + nest_cb->prev->left_indent + nest_cb->prev->align;
    } else {
        t_left_indent_1 = conv_hor_unit( &((ol_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font )
                            + nest_cb->prev->left_indent;
    }
    t_left_indent_2 = conv_hor_unit( &((ol_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font );
    t_right_indent = -1 * conv_hor_unit( &((ol_lay_level *)(nest_cb->lay_tag))->right_indent, g_curr_font )
                            + nest_cb->prev->right_indent;
    g_cur_left = nest_cb->lm + t_left_indent_2;
    g_page_right = nest_cb->rm + t_right_indent;

    g_cur_h_start = g_cur_left;
    ProcFlags.keep_left_margin = true;  // keep special Note indent
    start_line_with_string( charnumber, g_curr_font, true );

    g_cur_h_start = g_cur_left + t_align;

    if( t_line != NULL ) {
        if( t_line->last != NULL ) {
            g_cur_left += t_line->last->width + post_space;
        }
    }
    post_space = 0;
    if( g_cur_h_start > g_cur_left ) {
        g_cur_left = g_cur_h_start;
    }
    g_cur_h_start = g_cur_left;
    ju_x_start = g_cur_h_start;

    g_curr_font = ((ol_lay_level *)(nest_cb->lay_tag))->font;
    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial spaces
    ProcFlags.need_li_lp = false;       // 1. item in list processed
    if( *p ) {
        process_text( p, g_curr_font ); // if text follows
    }

    nest_cb->align = t_align;

    /* Set indents to their original values for the next LI */

    if( g_indent > 0 ) {
        nest_cb->left_indent = t_left_indent_1;
    } else {
        nest_cb->left_indent = t_left_indent_1 + nest_cb->prev->align;
    }
    nest_cb->right_indent = t_right_indent;
    scan_start = scan_stop + 1;
    return;
}
Exemple #27
0
static void gen_toc( void )
{
    bool            levels[7];              // track levels
    char            buffer[11];
    char            postfix[12];
    ffh_entry   *   curr;
    int             i;
    int             j;
    uint32_t        cur_level;
    uint32_t        indent[7];
    uint32_t        size;

    if( hd_list == NULL ) return;       // no hd_list, no TOC

    /* Insert TOC into current section */

    last_page_out();                // ensure are on new page
    g_skip = 0;                     // ignore remaining skip value
    set_section_banners( doc_sect_toc );
    reset_t_page();

    /* Set TOC margins and other values */
    
    g_page_left = g_page_left_org + 2 *
                  conv_hor_unit( &layout_work.toc.left_adjust, g_curr_font );    // matches wgml 4.0
    g_page_right = g_page_right_org -
                   conv_hor_unit( &layout_work.toc.right_adjust, g_curr_font );
    size = conv_hor_unit( &layout_work.tocpgnum.size, g_curr_font );     // space from fill to right edge
    figlist_toc_tabs( layout_work.toc.fill_string, size );

    /* Initialize levels and indent values */

    for( i = 0; i < 7; i++ ) {
        levels[i] = false;
        indent[i] = 0;
    }

    /* Get converted indent values, which are cumulative */

    for( i = 0; i < 7; i++ ) {
        for( j = i; j < 7; j++ ) {
            indent[j] += conv_hor_unit( &layout_work.tochx[i].indent, g_curr_font );
        }
    }

    /* Output TOC */

    concat_save = ProcFlags.concat;
    ProcFlags.concat = true;
    justify_save = ProcFlags.justify;
    ProcFlags.justify = ju_off;
    ProcFlags.keep_left_margin = true;  // keep all indents while outputting text
    curr = hd_list;
    while( curr != NULL ) {
        cur_level = curr->number;
        for( i = 0; i < 7; i++ ) {
            if( i > cur_level ) {       // all lower levels are inactive
                levels[i] = false;
            }                
        }
        if( cur_level < layout_work.toc.toc_levels ) {
            g_curr_font = layout_work.tochx[cur_level].font;
            if( levels[cur_level] ) {
                spacing = layout_work.toc.spacing;
                set_skip_vars( &layout_work.tochx[cur_level].skip, NULL, NULL,
                               spacing, g_curr_font );
            } else {
                spacing = 1;
                set_skip_vars( &layout_work.tochx[cur_level].pre_skip, NULL,
                               &layout_work.tochx[cur_level].post_skip,
                               spacing, g_curr_font );
            }
            g_cur_left = g_page_left + indent[cur_level];
            g_cur_h_start = g_cur_left;

            if( curr->prefix != NULL ) {
                process_text( curr->prefix, g_curr_font );
                g_cur_left = t_line->last->x_address + t_line->last->width +
                             wgml_fonts[g_curr_font].spc_width;
                g_cur_h_start = g_cur_left;
                ProcFlags.ct = true;                // emulate CT
                post_space = 0;
            } else {
                t_line = alloc_text_line();         // capture spacing if no prefix
            }
            if( !levels[cur_level] ) {
                spacing = layout_work.toc.spacing;
                set_skip_vars( NULL, NULL, NULL, spacing, g_curr_font );
            }
            if( curr->text != NULL ) {
                g_page_right -= size;
                if( ProcFlags.has_aa_block ) {      // matches wgml 4.0
                    g_page_right -= tab_col;
                } else {
                    g_page_right -= 3 * tab_col;
                }
                ProcFlags.stop_xspc = true;         // suppress 2nd space after stop
                process_text( curr->text, g_curr_font );
                if( ProcFlags.has_aa_block ) {      // matches wgml 4.0
                    g_page_right += tab_col;
                } else {
                    g_page_right += 3 * tab_col;
                }
                g_page_right += size;
            }
            ProcFlags.ct = true;                    // emulate CT
            g_curr_font = FONT0;
            process_text( "$", g_curr_font );
            format_num( curr->pageno, &buffer, sizeof( buffer ), curr->style );
            strcpy_s( postfix, 12, "$" );           // insert tab characters
            strcat_s( postfix, 12, buffer );        // append page number
            g_curr_font = layout_work.tocpgnum.font;
            process_text( postfix, g_curr_font );
        }
        scr_process_break();                        // ensure line break
        levels[cur_level] = true;                   // first entry of level done
        curr = curr->next;
    }

    ProcFlags.concat = concat_save;
    ProcFlags.justify = justify_save;

    /* Re-establish current section */

    last_page_out();                // ensure all pages output
    set_section_banners( ProcFlags.doc_sect );
    reset_t_page();

    return;
}
Exemple #28
0
extern  void    gml_note( const gmltag * entry )
{
    char        *   p;
    font_number     font_save;
    text_chars  *   marker;
    uint32_t        spc_cnt;

    scan_err = false;
    p = scan_start;

    start_doc_sect();                   // if not already done

    scr_process_break();

    font_save = g_curr_font;
    g_curr_font = layout_work.note.font;
    set_skip_vars( &layout_work.note.pre_skip, NULL, &layout_work.note.post_skip,
                   spacing, g_curr_font );
    post_space = 0;

    if( nest_cb->c_tag == t_NONE ) {
        g_cur_left = g_page_left + conv_hor_unit( &layout_work.note.left_indent, g_curr_font );
    } else {
        g_cur_left += conv_hor_unit( &layout_work.note.left_indent, g_curr_font );
    }
    g_cur_h_start = g_cur_left;
    ProcFlags.keep_left_margin = true;  // keep special Note indent

    start_line_with_string( layout_work.note.string, layout_work.note.font, false );

    /* the value of post_space after start_line_with_string() is wrong for  */
    /* two reasons: 1) it uses the wrong font; 2) it is at most "1" even if */
    /* more than one space appears at the end of the note_string.           */

    spc_cnt = post_space / wgml_fonts[g_curr_font].spc_width;
    post_space = spc_cnt * wgml_fonts[font_save].spc_width;
    if( (t_line != NULL)  && (t_line->last != NULL) ) {
        g_cur_left += t_line->last->width + post_space;
    }
    g_cur_h_start = g_cur_left;
    ju_x_start = g_cur_h_start;

    spacing = layout_work.note.spacing;
    g_curr_font = layout_work.defaults.font;

    set_skip_vars( NULL, NULL, NULL, spacing, g_curr_font );
    if( *p == '.' ) p++;                // over '.'
    while( *p == ' ' ) p++;             // skip initial space
    if( *p ) {                          // if text follows
        post_space = 0;
        process_text( p, g_curr_font );
    } else if( !ProcFlags.concat && ProcFlags.has_aa_block &&
               (t_line != NULL) && (post_space > 0) ) {

        /* only create marker if line not empty,                            */
        /* :NOTE note_string is not nullstring and ends in at least 1 space */

        marker = alloc_text_chars( NULL, 0, font_save );
        marker->x_address = g_cur_h_start;
        if( t_line->first == NULL ) {
            t_line->first = marker;
            t_line->last = t_line->first;
        } else {
            marker->prev = t_line->last;
            t_line->last->next = marker;
            t_line->last = t_line->last->next;
        }
        post_space = 0;
    }

    g_curr_font = font_save;
    scan_start = scan_stop + 1;
    return;
}
Exemple #29
0
void    gml_title( const gmltag * entry )
{
    char        *   p;
    doc_element *   cur_el;
    text_line   *   p_line      = NULL;
    int8_t          t_spacing;
    font_number     font_save;

    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();
    }
    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;
    t_spacing = layout_work.titlep.spacing;
    if( !ProcFlags.title_tag_top ) {
        set_skip_vars( NULL, &layout_work.title.pre_top_skip, NULL, t_spacing, 
                       g_curr_font );
        ProcFlags.title_tag_top = true;
    } else {
        set_skip_vars( &layout_work.title.skip, NULL, NULL, t_spacing, 
                       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 = init_doc_el( el_text, p_line->line_height );
    cur_el->element.text.first = p_line;
    p_line = NULL;
    insert_col_main( cur_el );

    g_curr_font = font_save;
    scan_start = scan_stop + 1;
}
Exemple #30
0
static void gen_figlist( void )
{
    char            buffer[11];
    char            postfix[12];
    ffh_entry   *   curr;
    uint32_t        size;

    if( fig_list == NULL ) return;  // no fig_list, no FIGLIST

    /* Insert FIGLIST into current section */

    last_page_out();                // ensure are on new page
    g_skip = 0;                     // ignore remaining skip value
    set_section_banners( doc_sect_figlist );
    reset_t_page();

    /* Set FIGLIST margins and other values */

    g_page_left = g_page_left_org + 2 *
                  conv_hor_unit( &layout_work.figlist.left_adjust, g_curr_font );    // matches wgml 4.0
    g_page_right = g_page_right_org -
                   conv_hor_unit( &layout_work.figlist.right_adjust, g_curr_font );
    size = conv_hor_unit( &layout_work.flpgnum.size, g_curr_font );  // space from fill to right edge
    figlist_toc_tabs( layout_work.figlist.fill_string, size );

    /* Output FIGLIST */

    concat_save = ProcFlags.concat;
    ProcFlags.concat = true;
    justify_save = ProcFlags.justify;
    ProcFlags.justify = ju_off;
    ProcFlags.keep_left_margin = true;  // keep all indents while outputting text
    curr = fig_list;
    while( curr != NULL ) {
        if( curr->flags & ffh_figcap ) {    // no FIGCAP used, no FIGLIST output
            g_curr_font = FONT0;            // wgml 4.0 uses font 0
            if( ProcFlags.page_started ) {  // not on first entry
                spacing = layout_work.figlist.spacing;
                set_skip_vars( NULL, NULL, NULL, spacing, g_curr_font );
            }
            g_cur_left = g_page_left;
            g_cur_h_start = g_cur_left;
            process_text( curr->prefix, g_curr_font );  // caption prefix

            if( curr->text != NULL ) {
                g_cur_left = t_line->last->x_address + t_line->last->width +
                             wgml_fonts[g_curr_font].spc_width;
                g_cur_h_start = g_cur_left;
                ProcFlags.ct = true;                // emulate CT
                ProcFlags.stop_xspc = true;         // suppress 2nd space after stops
                post_space = 0;
                g_page_right -= size;
                if( ProcFlags.has_aa_block ) {      // matches wgml 4.0
                    g_page_right -= tab_col;
                } else {
                    g_page_right -= 3 * tab_col;
                }
                if( !ProcFlags.page_started ) {     // first entry wrapping
                    spacing = layout_work.figlist.spacing;
                }
                set_skip_vars( &layout_work.figlist.skip, NULL, NULL,
                               spacing, g_curr_font );
                process_text( curr->text, g_curr_font );// caption text
                if( ProcFlags.has_aa_block ) {       // matches wgml 4.0
                    g_page_right += tab_col;
                } else {
                    g_page_right += 3 * tab_col;
                }
                g_page_right += size;
            }
            ProcFlags.ct = true;                    // emulate CT
            g_curr_font = FONT0;
            process_text( "$", g_curr_font );
            format_num( curr->pageno, &buffer, sizeof( buffer ), curr->style );
            strcpy_s( postfix, 12, "$" );           // insert tab characters
            strcat_s( postfix, 12, buffer );        // append page number
            g_curr_font = layout_work.flpgnum.font;
            process_text( postfix, g_curr_font );
        }
        scr_process_break();                // ensure line break
        curr = curr->next;
    }

    ProcFlags.concat = concat_save;
    ProcFlags.justify = justify_save;

    /* Re-establish current section */

    last_page_out();                // ensure all pages output
    set_section_banners( ProcFlags.doc_sect );
    reset_t_page();

    return;
}