PageRenderTime 27ms CodeModel.GetById 11ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/groff/src/devices/grohtml/html-table.h

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