gwenhywfar
4.8.0beta
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
html
g_tablerow.c
Go to the documentation of this file.
1
/***************************************************************************
2
begin : Mon Feb 22 2010
3
copyright : (C) 2010 by Martin Preuss
4
email : martin@libchipcard.de
5
6
***************************************************************************
7
* Please see toplevel file COPYING for license details *
8
***************************************************************************/
9
10
#ifdef HAVE_CONFIG_H
11
# include <config.h>
12
#endif
13
14
#define DISABLE_DEBUGLOG
15
16
17
#include "g_tablerow_p.h"
18
#include "
g_box_l.h
"
19
#include "
g_generic_l.h
"
20
#include "
htmlctx_l.h
"
21
#include "
o_grid_l.h
"
22
#include "
o_gridentry_l.h
"
23
24
#include <gwenhywfar/debug.h>
25
26
27
GWEN_INHERIT
(
HTML_GROUP
, GROUP_TABLEROW)
28
29
30
31
32
HTML_GROUP
*
HtmlGroup_TableRow_new
(const
char
*groupName,
33
HTML_GROUP
*parent,
34
GWEN_XML_CONTEXT
*ctx) {
35
HTML_GROUP
*g;
36
GROUP_TABLEROW *xg;
37
38
/* create base group */
39
g=
HtmlGroup_Generic_new
(groupName, parent, ctx);
40
assert(g);
41
GWEN_NEW_OBJECT
(GROUP_TABLEROW, xg);
42
GWEN_INHERIT_SETDATA
(
HTML_GROUP
, GROUP_TABLEROW, g, xg,
HtmlGroup_TableRow_FreeData
);
43
44
/* set virtual functions */
45
HtmlGroup_SetStartTagFn
(g,
HtmlGroup_TableRow_StartTag
);
46
47
return
g;
48
}
49
50
51
52
void
GWENHYWFAR_CB
HtmlGroup_TableRow_FreeData
(
void
*bp,
void
*p) {
53
GROUP_TABLEROW *xg;
54
55
xg=(GROUP_TABLEROW*) p;
56
57
GWEN_FREE_OBJECT
(xg);
58
}
59
60
61
62
int
HtmlGroup_TableRow_GetColumns
(
const
HTML_GROUP
*g) {
63
GROUP_TABLEROW *xg;
64
65
assert(g);
66
xg=
GWEN_INHERIT_GETDATA
(
HTML_GROUP
, GROUP_TABLEROW, g);
67
assert(xg);
68
69
return
xg->columns;
70
}
71
72
73
74
int
HtmlGroup_TableRow_StartTag
(
HTML_GROUP
*g,
const
char
*tagName) {
75
GROUP_TABLEROW *xg;
76
HTML_GROUP
*gNew=
NULL
;
77
GWEN_XML_CONTEXT
*ctx;
78
GWEN_DB_NODE
*dbAttribs;
79
80
assert(g);
81
xg=
GWEN_INHERIT_GETDATA
(
HTML_GROUP
, GROUP_TABLEROW, g);
82
assert(xg);
83
84
ctx=
HtmlGroup_GetXmlContext
(g);
85
dbAttribs=
HtmlCtx_GetCurrentAttributes
(ctx);
86
87
if
(strcasecmp(tagName,
"th"
)==0) {
88
HTML_OBJECT
*o;
89
HTML_PROPS
*pr;
90
HTML_FONT
*fnt;
91
92
/* create new parser group */
93
gNew=
HtmlGroup_Box_new
(tagName, g, ctx);
94
pr=
HtmlProps_dup
(
HtmlGroup_GetProperties
(g));
95
fnt=
HtmlProps_GetFont
(pr);
96
fnt=
HtmlCtx_GetFont
(ctx,
97
HtmlFont_GetFontName
(fnt),
98
HtmlFont_GetFontSize
(fnt),
99
HtmlFont_GetFontFlags
(fnt) |
HTML_FONT_FLAGS_STRONG
);
100
if
(fnt) {
101
HtmlProps_SetFont
(pr, fnt);
102
//HtmlFont_free(fnt);
103
}
104
HtmlGroup_SetProperties
(gNew, pr);
105
HtmlProps_free
(pr);
106
107
o=
HtmlObject_GridEntry_new
(ctx);
108
HtmlObject_SetProperties
(o,
HtmlGroup_GetProperties
(g));
109
HtmlObject_GridEntry_SetColumn
(o, xg->columns++);
110
HtmlObject_GridEntry_SetRow
(o, xg->row);
111
HtmlObject_GridEntry_SetIsHeader
(o, 1);
112
113
if
(dbAttribs) {
114
const
char
*s;
115
116
s=
GWEN_DB_GetCharValue
(dbAttribs,
"align"
, 0,
"left"
);
117
if
(s) {
118
if
(strcasecmp(s,
"right"
)==0)
119
HtmlObject_AddFlags
(o,
HTML_OBJECT_FLAGS_JUSTIFY_RIGHT
);
120
else
if
(strcasecmp(s,
"center"
)==0)
121
HtmlObject_AddFlags
(o,
HTML_OBJECT_FLAGS_JUSTIFY_HCENTER
);
122
}
123
}
124
125
HtmlObject_Tree_AddChild(
HtmlGroup_GetObject
(g), o);
126
HtmlGroup_SetObject
(gNew, o);
127
}
128
else
if
(strcasecmp(tagName,
"td"
)==0) {
129
HTML_OBJECT
*o;
130
131
/* create new parser group */
132
gNew=
HtmlGroup_Box_new
(tagName, g, ctx);
133
HtmlGroup_SetProperties
(gNew,
HtmlGroup_GetProperties
(g));
134
o=
HtmlObject_GridEntry_new
(ctx);
135
HtmlObject_SetProperties
(o,
HtmlGroup_GetProperties
(g));
136
HtmlObject_GridEntry_SetColumn
(o, xg->columns++);
137
HtmlObject_GridEntry_SetRow
(o, xg->row);
138
HtmlObject_GridEntry_SetIsHeader
(o, 0);
139
140
if
(dbAttribs) {
141
const
char
*s;
142
143
s=
GWEN_DB_GetCharValue
(dbAttribs,
"align"
, 0,
"left"
);
144
if
(s) {
145
if
(strcasecmp(s,
"right"
)==0)
146
HtmlObject_AddFlags
(o,
HTML_OBJECT_FLAGS_JUSTIFY_RIGHT
);
147
else
if
(strcasecmp(s,
"center"
)==0)
148
HtmlObject_AddFlags
(o,
HTML_OBJECT_FLAGS_JUSTIFY_HCENTER
);
149
}
150
}
151
152
HtmlObject_Tree_AddChild(
HtmlGroup_GetObject
(g), o);
153
HtmlGroup_SetObject
(gNew, o);
154
}
155
else
{
156
DBG_ERROR
(
GWEN_LOGDOMAIN
,
157
"Unexpected group [%s]"
, tagName);
158
return
GWEN_ERROR_BAD_DATA
;
159
}
160
161
if
(gNew) {
162
HtmlCtx_SetCurrentGroup
(ctx, gNew);
163
GWEN_XmlCtx_IncDepth
(ctx);
164
}
165
166
return
0;
167
}
168
169
170
171
void
HtmlGroup_TableRow_SetRow
(
HTML_GROUP
*g,
int
row) {
172
GROUP_TABLEROW *xg;
173
174
assert(g);
175
xg=
GWEN_INHERIT_GETDATA
(
HTML_GROUP
, GROUP_TABLEROW, g);
176
assert(xg);
177
178
xg->row=row;
179
}
180
181
182
183
184
185
Generated on Tue Nov 12 2013 10:50:20 for gwenhywfar by
1.8.1.2