gwenhywfar 5.12.0
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
27GWEN_INHERIT(HTML_GROUP, GROUP_TABLEROW)
28
29
30
31
32HTML_GROUP *HtmlGroup_TableRow_new(const char *groupName,
33 HTML_GROUP *parent,
35{
36 HTML_GROUP *g;
37 GROUP_TABLEROW *xg;
38
39 /* create base group */
40 g=HtmlGroup_Generic_new(groupName, parent, ctx);
41 assert(g);
42 GWEN_NEW_OBJECT(GROUP_TABLEROW, xg);
44
45 /* set virtual functions */
47
48 return g;
49}
50
51
52
54{
55 GROUP_TABLEROW *xg;
56
57 xg=(GROUP_TABLEROW *) p;
58
60}
61
62
63
65{
66 GROUP_TABLEROW *xg;
67
68 assert(g);
69 xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_TABLEROW, g);
70 assert(xg);
71
72 return xg->columns;
73}
74
75
76
77int HtmlGroup_TableRow_StartTag(HTML_GROUP *g, const char *tagName)
78{
79 GROUP_TABLEROW *xg;
80 HTML_GROUP *gNew=NULL;
82 GWEN_DB_NODE *dbAttribs;
83
84 assert(g);
85 xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_TABLEROW, g);
86 assert(xg);
87
89 dbAttribs=HtmlCtx_GetCurrentAttributes(ctx);
90
91 if (strcasecmp(tagName, "th")==0) {
92 HTML_OBJECT *o;
93 HTML_PROPS *pr;
94 HTML_FONT *fnt;
95
96 /* create new parser group */
97 gNew=HtmlGroup_Box_new(tagName, g, ctx);
99 fnt=HtmlProps_GetFont(pr);
100 fnt=HtmlCtx_GetFont(ctx,
104 if (fnt) {
105 HtmlProps_SetFont(pr, fnt);
106 //HtmlFont_free(fnt);
107 }
108 HtmlGroup_SetProperties(gNew, pr);
109 HtmlProps_free(pr);
110
113 HtmlObject_GridEntry_SetColumn(o, xg->columns++);
114 HtmlObject_GridEntry_SetRow(o, xg->row);
116
117 if (dbAttribs) {
118 const char *s;
119
120 s=GWEN_DB_GetCharValue(dbAttribs, "align", 0, "left");
121 if (s) {
122 if (strcasecmp(s, "right")==0)
124 else if (strcasecmp(s, "center")==0)
126 }
127 }
128
129 HtmlObject_Tree_AddChild(HtmlGroup_GetObject(g), o);
130 HtmlGroup_SetObject(gNew, o);
131 }
132 else if (strcasecmp(tagName, "td")==0) {
133 HTML_OBJECT *o;
134
135 /* create new parser group */
136 gNew=HtmlGroup_Box_new(tagName, g, ctx);
140 HtmlObject_GridEntry_SetColumn(o, xg->columns++);
141 HtmlObject_GridEntry_SetRow(o, xg->row);
143
144 if (dbAttribs) {
145 const char *s;
146
147 s=GWEN_DB_GetCharValue(dbAttribs, "align", 0, "left");
148 if (s) {
149 if (strcasecmp(s, "right")==0)
151 else if (strcasecmp(s, "center")==0)
153 }
154 }
155
156 HtmlObject_Tree_AddChild(HtmlGroup_GetObject(g), o);
157 HtmlGroup_SetObject(gNew, o);
158 }
159 else {
161 "Unexpected group [%s]", tagName);
162 return GWEN_ERROR_BAD_DATA;
163 }
164
165 if (gNew) {
166 HtmlCtx_SetCurrentGroup(ctx, gNew);
168 }
169
170 return 0;
171}
172
173
174
176{
177 GROUP_TABLEROW *xg;
178
179 assert(g);
180 xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_TABLEROW, g);
181 assert(xg);
182
183 xg->row=row;
184}
185
186
187
188
189
190
#define NULL
Definition binreloc.c:300
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition db.c:971
struct GWEN_DB_NODE GWEN_DB_NODE
Definition db.h:228
#define DBG_ERROR(dbg_logger, format,...)
Definition debug.h:97
#define GWEN_ERROR_BAD_DATA
Definition error.h:121
HTML_GROUP * HtmlGroup_Box_new(const char *groupName, HTML_GROUP *parent, GWEN_XML_CONTEXT *ctx)
Definition g_box.c:36
HTML_GROUP * HtmlGroup_Generic_new(const char *groupName, HTML_GROUP *parent, GWEN_XML_CONTEXT *ctx)
Definition g_generic.c:26
void GWENHYWFAR_CB HtmlGroup_TableRow_FreeData(GWEN_UNUSED void *bp, void *p)
Definition g_tablerow.c:53
HTML_GROUP * HtmlGroup_TableRow_new(const char *groupName, HTML_GROUP *parent, GWEN_XML_CONTEXT *ctx)
Definition g_tablerow.c:32
void HtmlGroup_TableRow_SetRow(HTML_GROUP *g, int row)
Definition g_tablerow.c:175
int HtmlGroup_TableRow_GetColumns(const HTML_GROUP *g)
Definition g_tablerow.c:64
int HtmlGroup_TableRow_StartTag(HTML_GROUP *g, const char *tagName)
Definition g_tablerow.c:77
#define GWEN_UNUSED
#define GWENHYWFAR_CB
void HtmlCtx_SetCurrentGroup(GWEN_XML_CONTEXT *ctx, HTML_GROUP *g)
Definition htmlctx.c:201
HTML_FONT * HtmlCtx_GetFont(GWEN_XML_CONTEXT *ctx, const char *fontName, int fontSize, uint32_t fontFlags)
Definition htmlctx.c:638
GWEN_DB_NODE * HtmlCtx_GetCurrentAttributes(const GWEN_XML_CONTEXT *ctx)
Definition htmlctx.c:244
int HtmlFont_GetFontSize(const HTML_FONT *fnt)
Definition htmlfont.c:89
uint32_t HtmlFont_GetFontFlags(const HTML_FONT *fnt)
Definition htmlfont.c:107
const char * HtmlFont_GetFontName(const HTML_FONT *fnt)
Definition htmlfont.c:67
#define HTML_FONT_FLAGS_STRONG
Definition htmlfont_be.h:29
struct HTML_FONT HTML_FONT
Definition htmlfont_be.h:23
void HtmlGroup_SetObject(HTML_GROUP *g, HTML_OBJECT *o)
Definition htmlgroup.c:96
HTML_OBJECT * HtmlGroup_GetObject(const HTML_GROUP *g)
Definition htmlgroup.c:88
GWEN_XML_CONTEXT * HtmlGroup_GetXmlContext(const HTML_GROUP *g)
Definition htmlgroup.c:72
HTML_PROPS * HtmlGroup_GetProperties(const HTML_GROUP *g)
Definition htmlgroup.c:104
void HtmlGroup_SetProperties(HTML_GROUP *g, HTML_PROPS *pr)
Definition htmlgroup.c:112
HTML_GROUP_STARTTAG_FN HtmlGroup_SetStartTagFn(HTML_GROUP *g, HTML_GROUP_STARTTAG_FN f)
Definition htmlgroup.c:128
struct HTML_GROUP HTML_GROUP
Definition htmlgroup_l.h:19
void HtmlObject_SetProperties(HTML_OBJECT *o, HTML_PROPS *pr)
Definition htmlobject.c:113
void HtmlObject_AddFlags(HTML_OBJECT *o, uint32_t fl)
Definition htmlobject.c:275
#define HTML_OBJECT_FLAGS_JUSTIFY_RIGHT
#define HTML_OBJECT_FLAGS_JUSTIFY_HCENTER
struct HTML_OBJECT HTML_OBJECT
HTML_PROPS * HtmlProps_dup(const HTML_PROPS *pro)
Definition htmlprops.c:57
HTML_FONT * HtmlProps_GetFont(const HTML_PROPS *pr)
Definition htmlprops.c:82
void HtmlProps_SetFont(HTML_PROPS *pr, HTML_FONT *fnt)
Definition htmlprops.c:91
void HtmlProps_free(HTML_PROPS *pr)
Definition htmlprops.c:40
struct HTML_PROPS HTML_PROPS
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
Definition inherit.h:300
#define GWEN_INHERIT(bt, t)
Definition inherit.h:264
#define GWEN_INHERIT_GETDATA(bt, t, element)
Definition inherit.h:279
#define GWEN_LOGDOMAIN
Definition logger.h:35
#define GWEN_FREE_OBJECT(varname)
Definition memory.h:61
#define GWEN_NEW_OBJECT(typ, varname)
Definition memory.h:55
void HtmlObject_GridEntry_SetColumn(HTML_OBJECT *o, int i)
Definition o_gridentry.c:94
void HtmlObject_GridEntry_SetRow(HTML_OBJECT *o, int i)
Definition o_gridentry.c:68
HTML_OBJECT * HtmlObject_GridEntry_new(GWEN_XML_CONTEXT *ctx)
Definition o_gridentry.c:27
void HtmlObject_GridEntry_SetIsHeader(HTML_OBJECT *o, int i)
void GWEN_XmlCtx_IncDepth(GWEN_XML_CONTEXT *ctx)
Definition xmlctx.c:166
struct GWEN_XML_CONTEXT GWEN_XML_CONTEXT
Definition xmlctx.h:39