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 ); } }
void gml_exmp( const gmltag * entry ) { tag_cb * wk; entry = entry; scr_process_break(); if( !ProcFlags.xmp_active ) { // no preceding :XMP tag g_err_tag_prec( "XMP" ); scan_start = scan_stop + 1; return; } g_curr_font = font_save; ProcFlags.xmp_active = false; ProcFlags.justify = justify_save; wk = nest_cb; nest_cb = nest_cb->prev; add_tag_cb_to_pool( wk ); /* place the accumulated xlines on the proper page */ ProcFlags.group_elements = false; if( t_doc_el_group.first != NULL ) { t_doc_el_group.depth += (t_doc_el_group.first->blank_lines + t_doc_el_group.first->subs_skip); } if( (t_doc_el_group.depth + t_page.cur_depth) > t_page.max_depth ) { /* the block won't fit on this page */ if( t_doc_el_group.depth <= t_page.max_depth ) { /* the block will be on the next page */ do_page_out(); reset_t_page(); } } while( t_doc_el_group.first != NULL ) { insert_col_main( t_doc_el_group.first ); t_doc_el_group.first = t_doc_el_group.first->next; } t_doc_el_group.depth = 0; t_doc_el_group.last = NULL; scan_start = scan_stop + 1; return; }
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; }
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; }
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 }
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; }
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 ); } }
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 }