xref: /netbsd-src/external/gpl2/groff/dist/src/devices/grohtml/html-table.h (revision 89a07cf815a29524268025a1139fac4c5190f765)
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 /*
15 This file is part of groff.
16 
17 groff is free software; you can redistribute it and/or modify it under
18 the terms of the GNU General Public License as published by the Free
19 Software Foundation; either version 2, or (at your option) any later
20 version.
21 
22 groff is distributed in the hope that it will be useful, but WITHOUT ANY
23 WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 for more details.
26 
27 You should have received a copy of the GNU General Public License along
28 with groff; see the file COPYING.  If not, write to the Free Software
29 Foundation, 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 
36 typedef struct tab_position {
37   char alignment;
38   int  position;
39   struct tab_position *next;
40 } tab_position;
41 
42 
43 class tabs {
44 public:
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 
56 private:
57   void  delete_list (void);
58   tab_position *tab;
59 };
60 
61 /*
62  *  define a column
63  */
64 
65 typedef struct cols {
66   int          left, right;
67   int          no;
68   char         alignment;
69   struct cols *next;
70 } cols;
71 
72 class html_table {
73 public:
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;
101 private:
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 
116 class html_indent {
117 public:
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 
125 private:
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