~ubuntu-branches/ubuntu/dapper/groff/dapper

« back to all changes in this revision

Viewing changes to src/preproc/tbl/table.h

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2002-03-17 04:11:50 UTC
  • Revision ID: james.westby@ubuntu.com-20020317041150-wkgfawjc3gxlk0o5
Tags: upstream-1.17.2
ImportĀ upstreamĀ versionĀ 1.17.2

Show diffs side-by-side

added added

removed removed

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