Graphviz 16.0.0~dev.20260810.2334
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 v2.0
7 * which accompanies this distribution, and is available at
8 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
9 *
10 * Contributors: Details at https://graphviz.org
11 *************************************************************************/
12
13#pragma once
14
15#include <common/textspan.h>
16#include <common/types.h>
17#include <stdbool.h>
18#include <stdint.h>
19#include <stdlib.h>
20#include <util/list.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define FIXED_FLAG 1
27#define HALIGN_RIGHT (1 << 1)
28#define HALIGN_LEFT (1 << 2)
29#define HALIGN_MASK (HALIGN_RIGHT | HALIGN_LEFT)
30#define HALIGN_TEXT HALIGN_MASK
31#define VALIGN_TOP (1 << 3)
32#define VALIGN_BOTTOM (1 << 4)
33#define VALIGN_MASK (VALIGN_TOP | VALIGN_BOTTOM)
34#define BORDER_SET (1 << 5)
35#define PAD_SET (1 << 6)
36#define SPACE_SET (1 << 7)
37#define BALIGN_RIGHT (1 << 8)
38#define BALIGN_LEFT (1 << 9)
39#define BALIGN_MASK (BALIGN_RIGHT | BALIGN_LEFT)
40#define BORDER_LEFT (1 << 10)
41#define BORDER_TOP (1 << 11)
42#define BORDER_RIGHT (1 << 12)
43#define BORDER_BOTTOM (1 << 13)
44#define BORDER_MASK (BORDER_LEFT | BORDER_TOP | BORDER_RIGHT | BORDER_BOTTOM)
45
46#define UNSET_ALIGN 0
47
48/* spans of text within a cell
49 * NOTE: As required, the str field in span is utf-8.
50 * This translation is done when libexpat scans the input.
51 */
52
53/* line of textspan_t's */
54typedef struct {
56 size_t nitems;
57 char just;
58 double size; /* width of span */
59 double lfsize; /* offset from previous baseline to current one */
61
62typedef struct {
64 size_t nspans;
65 char simple;
67} htmltxt_t;
68
69typedef struct {
71 char *src;
72 char *scale;
73} htmlimg_t;
74
75typedef struct {
76 bool radial : 1;
77 bool rounded : 1;
78 bool invisible : 1;
79 bool dotted : 1;
80 bool dashed : 1;
82
83typedef struct {
84 char *href; /* pointer to an external resource */
85 char *port;
86 char *target;
87 char *title;
88 char *id;
89 char *bgcolor;
90 char *pencolor;
92 signed char space;
93 unsigned char border;
94 unsigned char pad;
95 unsigned char sides; /* set of sides exposed to field */
96 unsigned short flags;
97 unsigned short width;
98 unsigned short height;
100 boxf box; /* its geometric placement in points */
101} htmldata_t;
102
104
105typedef struct htmlcell_t htmlcell_t;
106typedef struct htmltbl_t htmltbl_t;
107
108/* During parsing, table contents are stored as rows of cells.
109 * A row is a list of cells
110 * Rows is a list of rows.
111 */
112
113typedef struct {
115 bool ruled;
116} row_t;
117
119static inline void free_ritem(row_t *p) {
120 LIST_FREE(&p->rp);
121 free(p);
122}
123
124typedef LIST(row_t *) rows_t;
125
126struct htmltbl_t {
128 union {
129 struct {
130 htmlcell_t *parent; /* enclosing cell */
131 htmlcell_t **cells; /* cells */
132 };
133 struct {
134 htmltbl_t *prev; /* stack */
135 rows_t rows;
136 };
137 };
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
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
178
179htmllabel_t *parseHTML(char *, int *, htmlenv_t *);
180
181int make_html_label(void *obj, textlabel_t *lp);
183
184void free_html_label(htmllabel_t *, int);
187
188boxf *html_port(node_t *n, char *pname, unsigned char *sides);
189
190#ifdef __cplusplus
191}
192#endif
void free(void *)
void free_html_label(htmllabel_t *, int)
Definition htmltable.c:863
void emit_html_label(GVJ_t *job, htmllabel_t *lp, textlabel_t *)
Definition htmltable.c:747
void free_html_data(htmldata_t *)
Definition htmltable.c:794
boxf * html_port(node_t *n, char *pname, unsigned char *sides)
Definition htmltable.c:918
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:1858
void free_html_text(htmltxt_t *)
Definition htmltable.c:805
htmllabel_t * parseHTML(char *, int *, htmlenv_t *)
Definition htmlparse.c:2010
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:103
@ HTML_TBL
Definition htmltable.h:103
@ HTML_UNSET
Definition htmltable.h:103
@ HTML_TEXT
Definition htmltable.h:103
@ HTML_IMAGE
Definition htmltable.h:103
type-generic dynamically expanding list
#define LIST(type)
Definition list.h:55
#define LIST_FREE(list)
Definition list.h:350
graph or subgraph
Definition cgraph.h:424
Definition geom.h:41
double lfsize
Definition htmltable.h:59
size_t nitems
Definition htmltable.h:56
textspan_t * items
Definition htmltable.h:55
double size
Definition htmltable.h:58
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:89
unsigned char border
Definition htmltable.h:93
char * target
Definition htmltable.h:86
char * id
Definition htmltable.h:88
signed char space
Definition htmltable.h:92
unsigned short width
Definition htmltable.h:97
unsigned short height
Definition htmltable.h:98
int gradientangle
Definition htmltable.h:91
char * port
Definition htmltable.h:85
unsigned short flags
Definition htmltable.h:96
unsigned char sides
Definition htmltable.h:95
char * href
Definition htmltable.h:84
unsigned char pad
Definition htmltable.h:94
char * pencolor
Definition htmltable.h:90
htmlstyle_t style
Definition htmltable.h:99
char * title
Definition htmltable.h:87
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:72
char * src
Definition htmltable.h:71
boxf box
Definition htmltable.h:70
htmltxt_t * txt
Definition htmltable.h:151
htmltbl_t * tbl
Definition htmltable.h:150
htmlimg_t * img
Definition htmltable.h:152
label_type_t kind
Definition htmltable.h:154
union htmllabel_t::@50 u
bool dashed
Definition htmltable.h:80
bool dotted
Definition htmltable.h:79
bool rounded
Definition htmltable.h:77
bool radial
Definition htmltable.h:76
bool invisible
Definition htmltable.h:78
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
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
boxf box
Definition htmltable.h:66
size_t nspans
Definition htmltable.h:64
char simple
Definition htmltable.h:65
htextspan_t * spans
Definition htmltable.h:63
bool ruled
Definition htmltable.h:115
LIST(htmlcell_t *) rp
textspan_t, textfont_t, PostscriptAlias
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t