1/*	$NetBSD: html-table.h,v 1.1.1.1 2016/01/13 18:41:49 christos Exp $	*/
2
3// -*- C++ -*-
4/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 *
6 *  Gaius Mulley (gaius@glam.ac.uk) wrote html-table.h
7 *
8 *  html-table.h
9 *
10 *  provides the methods necessary to handle indentation and tab
11 *  positions using html tables.
12 */
13
14/*
15This file is part of groff.
16
17groff is free software; you can redistribute it and/or modify it under
18the terms of the GNU General Public License as published by the Free
19Software Foundation; either version 2, or (at your option) any later
20version.
21
22groff is distributed in the hope that it will be useful, but WITHOUT ANY
23WARRANTY; without even the implied warranty of MERCHANTABILITY or
24FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25for more details.
26
27You should have received a copy of the GNU General Public License along
28with groff; see the file COPYING.  If not, write to the Free Software
29Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
30
31#include "html.h"
32
33#if !defined(HTML_TABLE_H)
34#define HTML_TABLE_H
35
36typedef struct tab_position {
37  char alignment;
38  int  position;
39  struct tab_position *next;
40} tab_position;
41
42
43class tabs {
44public:
45         tabs         ();
46        ~tabs         ();
47  void  clear         (void);
48  int   compatible    (const char *s);
49  void  init          (const char *s);
50  void  check_init    (const char *s);
51  int   find_tab      (int pos);
52  int   get_tab_pos   (int n);
53  char  get_tab_align (int n);
54  void  dump_tabs     (void);
55
56private:
57  void  delete_list (void);
58  tab_position *tab;
59};
60
61/*
62 *  define a column
63 */
64
65typedef struct cols {
66  int          left, right;
67  int          no;
68  char         alignment;
69  struct cols *next;
70} cols;
71
72class html_table {
73public:
74      html_table          (simple_output *op, int linelen);
75     ~html_table          (void);
76  int   add_column        (int coln, int hstart, int hend, char align);
77  cols *get_column        (int coln);
78  int   insert_column     (int coln, int hstart, int hend, char align);
79  int   modify_column     (cols *c, int hstart, int hend, char align);
80  int   find_tab_column   (int pos);
81  int   find_column       (int pos);
82  int   get_tab_pos       (int n);
83  char  get_tab_align     (int n);
84  void  set_linelength    (int linelen);
85  int   no_columns        (void);
86  int   no_gaps           (void);
87  int   is_gap            (cols *c);
88  void  dump_table        (void);
89  void  emit_table_header (int space);
90  void  emit_col          (int n);
91  void  emit_new_row      (void);
92  void  emit_finish_table (void);
93  int   get_right         (cols *c);
94  void  add_indent        (int indent);
95  void  finish_row        (void);
96  int   get_effective_linelength (void);
97  void  set_space         (int space);
98
99  tabs          *tab_stops;    /* tab stop positions */
100  simple_output *out;
101private:
102  cols          *columns;      /* column entries */
103  int            linelength;
104  cols          *last_col;     /* last column started */
105  int            start_space;  /* have we seen a `.sp' tag? */
106
107  void  remove_cols (cols *c);
108};
109
110/*
111 *  the indentation wrapper.
112 *  Builds an indentation from a html-table.
113 *  This table is only emitted if the paragraph is emitted.
114 */
115
116class html_indent {
117public:
118  html_indent  (simple_output *op, int ind, int pageoffset, int linelength);
119  ~html_indent (void);
120  void begin   (int space);   // called if we need to use the indent
121  void get_reg (int *ind, int *pageoffset, int *linelength);
122
123  // the indent is shutdown when it is deleted
124
125private:
126  void end     (void);
127  int         is_used;
128  int         pg;        // values of the registers as passed via initialization
129  int         ll;
130  int         in;
131  html_table *table;
132};
133
134#endif
135