Sync-to-go: update copyright for 2015
[s-roff.git] / src / pre-tbl / table.h
blob781a28dcdd4cbdf7468b8b5c20e070424a45f4ae
1 /*
2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2001 - 2004, 2007, 2008
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
11 * version.
13 * This is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef _TABLE_H
23 #define _TABLE_H
25 #include "config.h"
26 #include "tbl-config.h"
28 #include <assert.h>
29 #include <ctype.h>
30 #include <errno.h>
31 #include <stdlib.h>
33 #include "cmap.h"
34 #include "cset.h"
35 #include "errarg.h"
36 #include "error.h"
37 #include "lib.h"
38 #include "stringclass.h"
40 struct inc_number {
41 short inc;
42 short val;
45 class entry_modifier
47 public:
48 inc_number point_size;
49 inc_number vertical_spacing;
50 string font;
51 string macro;
52 enum { CENTER, TOP, BOTTOM } vertical_alignment;
53 char zero_width;
54 char stagger;
56 entry_modifier();
57 ~entry_modifier();
60 enum format_type {
61 FORMAT_LEFT,
62 FORMAT_CENTER,
63 FORMAT_RIGHT,
64 FORMAT_NUMERIC,
65 FORMAT_ALPHABETIC,
66 FORMAT_SPAN,
67 FORMAT_VSPAN,
68 FORMAT_HLINE,
69 FORMAT_DOUBLE_HLINE
72 class entry_format
73 : public entry_modifier
75 public:
76 format_type type;
78 entry_format(format_type);
79 entry_format();
80 void debug_print() const;
83 class table_entry;
84 struct horizontal_span;
85 struct stuff;
86 struct vertical_rule;
88 class table
90 int nrows;
91 int ncolumns;
92 int linesize;
93 char delim[2];
94 char decimal_point_char;
95 vertical_rule *vrule_list;
96 stuff *stuff_list;
97 horizontal_span *span_list;
98 table_entry *entry_list;
99 table_entry **entry_list_tailp;
100 table_entry ***entry;
101 char **vline;
102 char *row_is_all_lines;
103 string *minimum_width;
104 int *column_separation;
105 char *equal;
106 int left_separation;
107 int right_separation;
108 int total_separation;
109 int allocated_rows;
111 void build_span_list();
112 void compute_expand_width();
113 void do_hspan(int r, int c);
114 void do_vspan(int r, int c);
115 void allocate(int r);
116 void compute_widths();
117 void divide_span(int, int);
118 void sum_columns(int, int, int);
119 void compute_total_separation();
120 void compute_separation_factor();
121 void compute_column_positions();
122 void do_row(int);
123 void init_output();
124 void add_stuff(stuff *);
125 void do_top();
126 void do_bottom();
127 void do_vertical_rules();
128 void build_vrule_list();
129 void add_vertical_rule(int, int, int, int);
130 void define_bottom_macro();
131 int vline_spanned(int r, int c);
132 int row_begins_section(int);
133 int row_ends_section(int);
134 void make_columns_equal();
135 void compute_vrule_top_adjust(int, int, string &);
136 void compute_vrule_bot_adjust(int, int, string &);
137 void determine_row_type();
138 int count_expand_columns();
140 public:
141 unsigned flags;
142 enum {
143 CENTER = 0x00000001,
144 EXPAND = 0x00000002,
145 BOX = 0x00000004,
146 ALLBOX = 0x00000008,
147 DOUBLEBOX = 0x00000010,
148 NOKEEP = 0x00000020,
149 NOSPACES = 0x00000040,
150 EXPERIMENTAL = 0x80000000 // undocumented; use as a hook for experiments
152 char *expand;
154 table(int nc, unsigned flags, int linesize, char decimal_point_char);
155 ~table();
157 void add_text_line(int r, const string &, const char *, int);
158 void add_single_hline(int r);
159 void add_double_hline(int r);
160 void add_entry(int r, int c, const string &, const entry_format *,
161 const char *, int lineno);
162 void add_vlines(int r, const char *);
163 void check();
164 void print();
165 void set_minimum_width(int c, const string &w);
166 void set_column_separation(int c, int n);
167 void set_equal_column(int c);
168 void set_expand_column(int c);
169 void set_delim(char c1, char c2);
170 void print_single_hline(int r);
171 void print_double_hline(int r);
172 int get_nrows();
175 void set_troff_location(const char *, int);
177 extern int compatible_flag;
179 #endif // _TABLE_H
180 // s-it2-mode