gwenhywfar  4.99.8beta
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);
43 
44  /* set virtual functions */
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 
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 
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);
95  fnt=HtmlProps_GetFont(pr);
96  fnt=HtmlCtx_GetFont(ctx,
100  if (fnt) {
101  HtmlProps_SetFont(pr, fnt);
102  //HtmlFont_free(fnt);
103  }
104  HtmlGroup_SetProperties(gNew, pr);
105  HtmlProps_free(pr);
106 
109  HtmlObject_GridEntry_SetColumn(o, xg->columns++);
110  HtmlObject_GridEntry_SetRow(o, xg->row);
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)
120  else if (strcasecmp(s, "center")==0)
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);
136  HtmlObject_GridEntry_SetColumn(o, xg->columns++);
137  HtmlObject_GridEntry_SetRow(o, xg->row);
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)
147  else if (strcasecmp(s, "center")==0)
149  }
150  }
151 
152  HtmlObject_Tree_AddChild(HtmlGroup_GetObject(g), o);
153  HtmlGroup_SetObject(gNew, o);
154  }
155  else {
157  "Unexpected group [%s]", tagName);
158  return GWEN_ERROR_BAD_DATA;
159  }
160 
161  if (gNew) {
162  HtmlCtx_SetCurrentGroup(ctx, gNew);
164  }
165 
166  return 0;
167 }
168 
169 
170 
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 
const char * HtmlFont_GetFontName(const HTML_FONT *fnt)
Definition: htmlfont.c:64
struct HTML_GROUP HTML_GROUP
Definition: htmlgroup_l.h:19
HTML_OBJECT * HtmlGroup_GetObject(const HTML_GROUP *g)
Definition: htmlgroup.c:83
int HtmlFont_GetFontSize(const HTML_FONT *fnt)
Definition: htmlfont.c:82
void HtmlGroup_SetObject(HTML_GROUP *g, HTML_OBJECT *o)
Definition: htmlgroup.c:90
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
void HtmlProps_free(HTML_PROPS *pr)
Definition: htmlprops.c:39
void HtmlObject_GridEntry_SetColumn(HTML_OBJECT *o, int i)
Definition: o_gridentry.c:89
#define HTML_OBJECT_FLAGS_JUSTIFY_HCENTER
Definition: htmlobject_be.h:35
HTML_GROUP_STARTTAG_FN HtmlGroup_SetStartTagFn(HTML_GROUP *g, HTML_GROUP_STARTTAG_FN f)
Definition: htmlgroup.c:120
void HtmlProps_SetFont(HTML_PROPS *pr, HTML_FONT *fnt)
Definition: htmlprops.c:86
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:290
int HtmlGroup_TableRow_GetColumns(const HTML_GROUP *g)
Definition: g_tablerow.c:62
#define GWEN_LOGDOMAIN
Definition: logger.h:35
void GWENHYWFAR_CB HtmlGroup_TableRow_FreeData(void *bp, void *p)
Definition: g_tablerow.c:52
void HtmlObject_GridEntry_SetIsHeader(HTML_OBJECT *o, int i)
Definition: o_gridentry.c:113
HTML_OBJECT * HtmlObject_GridEntry_new(GWEN_XML_CONTEXT *ctx)
Definition: o_gridentry.c:27
#define GWEN_ERROR_BAD_DATA
Definition: error.h:121
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:86
HTML_PROPS * HtmlProps_dup(const HTML_PROPS *pro)
Definition: htmlprops.c:55
#define HTML_OBJECT_FLAGS_JUSTIFY_RIGHT
Definition: htmlobject_be.h:34
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
void HtmlObject_AddFlags(HTML_OBJECT *o, uint32_t fl)
Definition: htmlobject.c:249
void HtmlObject_GridEntry_SetRow(HTML_OBJECT *o, int i)
Definition: o_gridentry.c:65
void GWEN_XmlCtx_IncDepth(GWEN_XML_CONTEXT *ctx)
Definition: xmlctx.c:117
struct HTML_FONT HTML_FONT
Definition: htmlfont_be.h:23
HTML_GROUP * HtmlGroup_Box_new(const char *groupName, HTML_GROUP *parent, GWEN_XML_CONTEXT *ctx)
Definition: g_box.c:36
void HtmlObject_SetProperties(HTML_OBJECT *o, HTML_PROPS *pr)
Definition: htmlobject.c:106
struct HTML_PROPS HTML_PROPS
Definition: htmlprops_be.h:15
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:897
GWEN_DB_NODE * HtmlCtx_GetCurrentAttributes(const GWEN_XML_CONTEXT *ctx)
Definition: htmlctx.c:230
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
HTML_PROPS * HtmlGroup_GetProperties(const HTML_GROUP *g)
Definition: htmlgroup.c:97
GWEN_XML_CONTEXT * HtmlGroup_GetXmlContext(const HTML_GROUP *g)
Definition: htmlgroup.c:69
HTML_FONT * HtmlProps_GetFont(const HTML_PROPS *pr)
Definition: htmlprops.c:78
#define HTML_FONT_FLAGS_STRONG
Definition: htmlfont_be.h:29
HTML_FONT * HtmlCtx_GetFont(GWEN_XML_CONTEXT *ctx, const char *fontName, int fontSize, uint32_t fontFlags)
Definition: htmlctx.c:609
void HtmlCtx_SetCurrentGroup(GWEN_XML_CONTEXT *ctx, HTML_GROUP *g)
Definition: htmlctx.c:192
HTML_GROUP * HtmlGroup_TableRow_new(const char *groupName, HTML_GROUP *parent, GWEN_XML_CONTEXT *ctx)
Definition: g_tablerow.c:32
#define GWEN_INHERIT(bt, t)
Definition: inherit.h:264
void HtmlGroup_TableRow_SetRow(HTML_GROUP *g, int row)
Definition: g_tablerow.c:171
void HtmlGroup_SetProperties(HTML_GROUP *g, HTML_PROPS *pr)
Definition: htmlgroup.c:104
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
Definition: inherit.h:292
int HtmlGroup_TableRow_StartTag(HTML_GROUP *g, const char *tagName)
Definition: g_tablerow.c:74
HTML_GROUP * HtmlGroup_Generic_new(const char *groupName, HTML_GROUP *parent, GWEN_XML_CONTEXT *ctx)
Definition: g_generic.c:26
uint32_t HtmlFont_GetFontFlags(const HTML_FONT *fnt)
Definition: htmlfont.c:98
struct GWEN_XML_CONTEXT GWEN_XML_CONTEXT
Definition: xmlctx.h:39
#define GWEN_INHERIT_GETDATA(bt, t, element)
Definition: inherit.h:271
struct HTML_OBJECT HTML_OBJECT
Definition: htmlobject_be.h:25