1 2 #ifndef EL__DOCUMENT_HTML_PARSER_TABLE_H 3 #define EL__DOCUMENT_HTML_PARSER_TABLE_H 4 5 #include "util/color.h" 6 7 struct html_context; 8 struct part; 9 10 /* Fix namespace clash on MacOS. */ 11 #define table table_elinks 12 13 #define ALIGN_TR -1 14 15 #define VALIGN_TR -1 16 #define VALIGN_TOP 0 17 #define VALIGN_MIDDLE 1 18 #define VALIGN_BOTTOM 2 19 #define VALIGN_BASELINE VALIGN_TOP /* Not implemented. */ 20 21 #define WIDTH_AUTO -1 22 #define WIDTH_RELATIVE -2 23 24 #define TABLE_FRAME_VOID 0 25 #define TABLE_FRAME_ABOVE 1 26 #define TABLE_FRAME_BELOW 2 27 #define TABLE_FRAME_HSIDES (TABLE_FRAME_ABOVE | TABLE_FRAME_BELOW) 28 #define TABLE_FRAME_LHS 4 29 #define TABLE_FRAME_RHS 8 30 #define TABLE_FRAME_VSIDES (TABLE_FRAME_LHS | TABLE_FRAME_RHS) 31 #define TABLE_FRAME_BOX (TABLE_FRAME_HSIDES | TABLE_FRAME_VSIDES) 32 33 #define TABLE_RULE_NONE 0 34 #define TABLE_RULE_ROWS 1 35 #define TABLE_RULE_COLS 2 36 #define TABLE_RULE_ALL 3 37 #define TABLE_RULE_GROUPS 4 38 39 struct html_start_end { 40 unsigned char *start, *end; 41 }; 42 43 struct table_cell { 44 unsigned char *start; 45 unsigned char *end; 46 unsigned char *fragment_id; 47 color_T bgcolor; 48 int col, row; 49 int align; 50 int valign; 51 int colspan; 52 int rowspan; 53 int min_width; 54 int max_width; 55 int width, height; 56 int link_num; 57 58 unsigned int is_used:1; 59 unsigned int is_spanned:1; 60 unsigned int is_header:1; 61 unsigned int is_group:1; 62 }; 63 64 struct table_column { 65 int group; 66 int align; 67 int valign; 68 int width; 69 }; 70 71 struct table { 72 struct part *part; 73 struct table_cell *cells; 74 unsigned char *fragment_id; 75 color_T bgcolor; 76 color_T bordercolor; 77 int align; 78 79 struct table_column *columns; 80 int columns_count; /* Number of columns used. */ 81 int real_columns_count; /* Number of columns really allocated. */ 82 83 int *min_cols_widths; 84 int *max_cols_widths; 85 int *cols_widths; 86 int *cols_x; 87 int cols_x_count; 88 89 int *rows_heights; 90 91 int cols, rows; /* For number of cells used. */ 92 int real_cols, real_rows; /* For number of cells really allocated. */ 93 int border; 94 int cellpadding; 95 int vcellpadding; 96 int cellspacing; 97 int frame, rules, width; 98 int real_width; 99 int real_height; 100 int min_width; 101 int max_width; 102 103 int link_num; 104 105 unsigned int full_width:1; 106 107 struct html_start_end caption; 108 int caption_height; 109 struct html_start_end *bad_html; 110 int bad_html_size; 111 }; 112 113 #define CELL(table, col, row) (&(table)->cells[(row) * (table)->real_cols + (col)]) 114 115 struct table * 116 parse_table(unsigned char *html, unsigned char *eof, unsigned char **end, 117 unsigned char *attr, int sh, struct html_context *html_context); 118 119 void free_table(struct table *table); 120 121 #endif 122