Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
htmltable.h
Go to the documentation of this file.
1
3/*************************************************************************
4 * Copyright (c) 2011 AT&T Intellectual Property
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * https://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors: Details at https://graphviz.org
11 *************************************************************************/
12
13#pragma once
14
15#include <cgraph/list.h>
16#include <stdbool.h>
17#include <stdint.h>
18#include <stdlib.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#define FIXED_FLAG 1
25#define HALIGN_RIGHT (1 << 1)
26#define HALIGN_LEFT (1 << 2)
27#define HALIGN_MASK (HALIGN_RIGHT | HALIGN_LEFT)
28#define HALIGN_TEXT HALIGN_MASK
29#define VALIGN_TOP (1 << 3)
30#define VALIGN_BOTTOM (1 << 4)
31#define VALIGN_MASK (VALIGN_TOP | VALIGN_BOTTOM)
32#define BORDER_SET (1 << 5)
33#define PAD_SET (1 << 6)
34#define SPACE_SET (1 << 7)
35#define BALIGN_RIGHT (1 << 8)
36#define BALIGN_LEFT (1 << 9)
37#define BALIGN_MASK (BALIGN_RIGHT | BALIGN_LEFT)
38#define BORDER_LEFT (1 << 10)
39#define BORDER_TOP (1 << 11)
40#define BORDER_RIGHT (1 << 12)
41#define BORDER_BOTTOM (1 << 13)
42#define BORDER_MASK (BORDER_LEFT|BORDER_TOP|BORDER_RIGHT|BORDER_BOTTOM)
43
44#define UNSET_ALIGN 0
45
46 /* spans of text within a cell
47 * NOTE: As required, the str field in span is utf-8.
48 * This translation is done when libexpat scans the input.
49 */
50
51 /* line of textspan_t's */
52 typedef struct {
54 size_t nitems;
55 char just;
56 double size; /* width of span */
57 double lfsize; /* offset from previous baseline to current one */
59
60 typedef struct {
62 size_t nspans;
63 char simple;
65 } htmltxt_t;
66
67 typedef struct {
69 char *src;
70 char *scale;
71 } htmlimg_t;
72
73 typedef struct {
74 bool radial: 1;
75 bool rounded: 1;
76 bool invisible: 1;
77 bool dotted: 1;
78 bool dashed: 1;
80
81 typedef struct {
82 char *href; /* pointer to an external resource */
83 char *port;
84 char *target;
85 char *title;
86 char *id;
87 char *bgcolor;
88 char *pencolor;
90 signed char space;
91 unsigned char border;
92 unsigned char pad;
93 unsigned char sides; /* set of sides exposed to field */
94 unsigned short flags;
95 unsigned short width;
96 unsigned short height;
98 boxf box; /* its geometric placement in points */
99 } htmldata_t;
100
102
103 typedef struct htmlcell_t htmlcell_t;
104 typedef struct htmltbl_t htmltbl_t;
105
106/* During parsing, table contents are stored as rows of cells.
107 * A row is a list of cells
108 * Rows is a list of rows.
109 */
110
112
113typedef struct {
114 cells_t rp;
115 bool ruled;
116} row_t;
117
119static inline void free_ritem(row_t *p) {
120 cells_free(&p->rp);
121 free (p);
122}
123
125
126 struct htmltbl_t {
128 union {
129 struct {
130 htmlcell_t *parent; /* enclosing cell */
131 htmlcell_t **cells; /* cells */
132 } n;
133 struct {
134 htmltbl_t *prev; /* stack */
135 rows_t rows;
136 } p;
137 } u;
139 double *heights;
140 double *widths;
141 size_t row_count;
143 textfont_t *font; /* font info */
144 bool hrule:1;
145 bool vrule:1;
146 };
147
156
157 struct htmlcell_t {
159 uint16_t colspan;
160 uint16_t rowspan;
161 uint16_t col;
162 uint16_t row;
165 bool vruled: 1;
166 bool hruled: 1;
167 };
168
169 typedef struct {
172 void *obj;
174 char *imgscale;
175 char *objid;
177 } htmlenv_t;
178
179 extern htmllabel_t *parseHTML(char *, int *, htmlenv_t *);
180
181 extern int make_html_label(void *obj, textlabel_t * lp);
182 extern void emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t *);
183
184 extern void free_html_label(htmllabel_t *, int);
185 extern void free_html_data(htmldata_t *);
186 extern void free_html_text(htmltxt_t *);
187
188 extern boxf *html_port(node_t *n, char *pname, unsigned char *sides);
189
190#ifdef __cplusplus
191}
192#endif
void free(void *)
$2 u p rows
Definition htmlparse.y:298
void free_html_label(htmllabel_t *, int)
Definition htmltable.c:864
void emit_html_label(GVJ_t *job, htmllabel_t *lp, textlabel_t *)
Definition htmltable.c:745
void free_html_data(htmldata_t *)
Definition htmltable.c:792
boxf * html_port(node_t *n, char *pname, unsigned char *sides)
Definition htmltable.c:919
int make_html_label(void *obj, textlabel_t *lp)
Return non-zero if problem parsing HTML. In this case, use object name.
Definition htmltable.c:1853
void free_html_text(htmltxt_t *)
Definition htmltable.c:803
htmllabel_t * parseHTML(char *, int *, htmlenv_t *)
Definition htmlparse.c:2379
static void free_ritem(row_t *p)
Free row. This closes and frees row’s list, then the item itself is freed.
Definition htmltable.h:119
label_type_t
Definition htmltable.h:101
@ HTML_TBL
Definition htmltable.h:101
@ HTML_UNSET
Definition htmltable.h:101
@ HTML_TEXT
Definition htmltable.h:101
@ HTML_IMAGE
Definition htmltable.h:101
#define DEFINE_LIST_WITH_DTOR(name, type, dtor)
Definition list.h:34
#define DEFINE_LIST(name, type)
Definition list.h:26
graph or subgraph
Definition cgraph.h:425
Definition geom.h:41
double lfsize
Definition htmltable.h:57
size_t nitems
Definition htmltable.h:54
textspan_t * items
Definition htmltable.h:53
double size
Definition htmltable.h:56
uint16_t rowspan
Definition htmltable.h:160
htmllabel_t child
Definition htmltable.h:163
uint16_t colspan
Definition htmltable.h:159
htmltbl_t * parent
Definition htmltable.h:164
bool vruled
vertically ruled?
Definition htmltable.h:165
bool hruled
horizontally ruled?
Definition htmltable.h:166
uint16_t col
Definition htmltable.h:161
uint16_t row
Definition htmltable.h:162
htmldata_t data
Definition htmltable.h:158
char * bgcolor
Definition htmltable.h:87
unsigned char border
Definition htmltable.h:91
char * target
Definition htmltable.h:84
char * id
Definition htmltable.h:86
signed char space
Definition htmltable.h:90
unsigned short width
Definition htmltable.h:95
unsigned short height
Definition htmltable.h:96
int gradientangle
Definition htmltable.h:89
char * port
Definition htmltable.h:83
unsigned short flags
Definition htmltable.h:94
unsigned char sides
Definition htmltable.h:93
char * href
Definition htmltable.h:82
unsigned char pad
Definition htmltable.h:92
char * pencolor
Definition htmltable.h:88
htmlstyle_t style
Definition htmltable.h:97
char * title
Definition htmltable.h:85
graph_t * g
Definition htmltable.h:173
textfont_t finfo
Definition htmltable.h:171
pointf pos
Definition htmltable.h:170
bool objid_set
Definition htmltable.h:176
char * objid
Definition htmltable.h:175
char * imgscale
Definition htmltable.h:174
void * obj
Definition htmltable.h:172
char * scale
Definition htmltable.h:70
char * src
Definition htmltable.h:69
boxf box
Definition htmltable.h:68
htmltxt_t * txt
Definition htmltable.h:151
union htmllabel_t::@76 u
htmltbl_t * tbl
Definition htmltable.h:150
htmlimg_t * img
Definition htmltable.h:152
label_type_t kind
Definition htmltable.h:154
bool dashed
Definition htmltable.h:78
bool dotted
Definition htmltable.h:77
bool rounded
Definition htmltable.h:75
bool radial
Definition htmltable.h:74
bool invisible
Definition htmltable.h:76
bool vrule
vertical rule
Definition htmltable.h:145
textfont_t * font
Definition htmltable.h:143
size_t row_count
number of rows
Definition htmltable.h:141
struct htmltbl_t::@73::@75 p
bool hrule
horizontal rule
Definition htmltable.h:144
double * widths
widths of the columns
Definition htmltable.h:140
htmltbl_t * prev
Definition htmltable.h:134
htmlcell_t ** cells
Definition htmltable.h:131
htmldata_t data
Definition htmltable.h:127
rows_t rows
cells
Definition htmltable.h:135
htmlcell_t * parent
Definition htmltable.h:130
double * heights
heights of the rows
Definition htmltable.h:139
int8_t cellborder
Definition htmltable.h:138
size_t column_count
number of columns
Definition htmltable.h:142
struct htmltbl_t::@73::@74 n
boxf box
Definition htmltable.h:64
size_t nspans
Definition htmltable.h:62
char simple
Definition htmltable.h:63
htextspan_t * spans
Definition htmltable.h:61
cells_t rp
Definition htmltable.h:114
bool ruled
Definition htmltable.h:115