1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
// -*- C++ -*-
/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
groff is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
groff is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include "cset.h"
#include "cmap.h"
#include "stringclass.h"
#include "errarg.h"
#include "error.h"
#include "lib.h"
struct inc_number {
short inc;
short val;
};
struct entry_modifier {
inc_number point_size;
inc_number vertical_spacing;
string font;
enum { CENTER, TOP, BOTTOM } vertical_alignment;
char zero_width;
char stagger;
entry_modifier();
~entry_modifier();
};
enum format_type {
FORMAT_LEFT,
FORMAT_CENTER,
FORMAT_RIGHT,
FORMAT_NUMERIC,
FORMAT_ALPHABETIC,
FORMAT_SPAN,
FORMAT_VSPAN,
FORMAT_HLINE,
FORMAT_DOUBLE_HLINE
};
struct entry_format : public entry_modifier {
format_type type;
entry_format(format_type);
entry_format();
void debug_print() const;
};
struct table_entry;
struct horizontal_span;
struct stuff;
struct vertical_rule;
class table {
unsigned flags;
int nrows;
int ncolumns;
int linesize;
char delim[2];
char decimal_point_char;
vertical_rule *vrule_list;
stuff *stuff_list;
horizontal_span *span_list;
table_entry *entry_list;
table_entry **entry_list_tailp;
table_entry ***entry;
char **vline;
char *row_is_all_lines;
string *minimum_width;
int *column_separation;
char *equal;
int left_separation;
int right_separation;
int allocated_rows;
void build_span_list();
void do_hspan(int r, int c);
void do_vspan(int r, int c);
void allocate(int r);
void compute_widths();
void divide_span(int, int);
void sum_columns(int, int);
void compute_separation_factor();
void compute_column_positions();
void do_row(int);
void init_output();
void add_stuff(stuff *);
void do_top();
void do_bottom();
void do_vertical_rules();
void build_vrule_list();
void add_vertical_rule(int, int, int, int);
void define_bottom_macro();
int vline_spanned(int r, int c);
int row_begins_section(int);
int row_ends_section(int);
void make_columns_equal();
void compute_vrule_top_adjust(int, int, string &);
void compute_vrule_bot_adjust(int, int, string &);
void determine_row_type();
public:
/* used by flags */
enum {
CENTER = 01,
EXPAND = 02,
BOX = 04,
ALLBOX = 010,
DOUBLEBOX = 020,
NOKEEP = 040
};
table(int nc, unsigned flags, int linesize, char decimal_point_char);
~table();
void add_text_line(int r, const string &, const char *, int);
void add_single_hline(int r);
void add_double_hline(int r);
void add_entry(int r, int c, const string &, const entry_format *,
const char *, int lineno);
void add_vlines(int r, const char *);
void check();
void print();
void set_minimum_width(int c, const string &w);
void set_column_separation(int c, int n);
void set_equal_column(int c);
void set_delim(char c1, char c2);
void print_single_hline(int r);
void print_double_hline(int r);
int get_nrows();
};
void set_troff_location(const char *, int);
|