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