Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifdef HAVE_CONFIG_H
00011 # include <config.h>
00012 #endif
00013
00014 #define DISABLE_DEBUGLOG
00015
00016
00017 #include "g_table_p.h"
00018 #include "g_generic_l.h"
00019 #include "htmlctx_l.h"
00020 #include "o_grid_l.h"
00021 #include "g_tablerow_l.h"
00022
00023 #include <gwenhywfar/debug.h>
00024
00025
00026
00027 HTML_GROUP *HtmlGroup_Table_new(const char *groupName,
00028 HTML_GROUP *parent,
00029 GWEN_XML_CONTEXT *ctx) {
00030 HTML_GROUP *g;
00031
00032
00033 g=HtmlGroup_Generic_new(groupName, parent, ctx);
00034 assert(g);
00035
00036
00037 HtmlGroup_SetStartTagFn(g, HtmlGroup_Table_StartTag);
00038 HtmlGroup_SetEndSubGroupFn(g, HtmlGroup_Table_EndSubGroup);
00039
00040 return g;
00041 }
00042
00043
00044
00045 int HtmlGroup_Table_StartTag(HTML_GROUP *g, const char *tagName) {
00046 HTML_GROUP *gNew=NULL;
00047 GWEN_XML_CONTEXT *ctx;
00048
00049 assert(g);
00050
00051 ctx=HtmlGroup_GetXmlContext(g);
00052
00053 if (strcasecmp(tagName, "tr")==0) {
00054 HTML_OBJECT *o;
00055 int rows;
00056
00057 o=HtmlGroup_GetObject(g);
00058 assert(o);
00059 rows=HtmlObject_Grid_GetRows(o);
00060
00061
00062 gNew=HtmlGroup_TableRow_new(tagName, g, ctx);
00063 HtmlGroup_TableRow_SetRow(gNew, rows);
00064 HtmlGroup_SetProperties(gNew, HtmlGroup_GetProperties(g));
00065 HtmlObject_Grid_SetRows(o, ++rows);
00066 HtmlGroup_SetObject(gNew, o);
00067 }
00068 else {
00069 DBG_ERROR(GWEN_LOGDOMAIN,
00070 "Unexpected group [%s]", tagName);
00071 return GWEN_ERROR_BAD_DATA;
00072 }
00073
00074 if (gNew) {
00075 HtmlCtx_SetCurrentGroup(ctx, gNew);
00076 GWEN_XmlCtx_IncDepth(ctx);
00077 }
00078
00079 return 0;
00080 }
00081
00082
00083
00084 int HtmlGroup_Table_EndSubGroup(HTML_GROUP *g, HTML_GROUP *sg) {
00085 GWEN_XML_CONTEXT *ctx;
00086 const char *s;
00087
00088 assert(g);
00089
00090 ctx=HtmlGroup_GetXmlContext(g);
00091
00092 s=HtmlGroup_GetGroupName(sg);
00093 if (strcasecmp(s, "tr")==0) {
00094 HTML_OBJECT *o;
00095 int i;
00096 int j;
00097
00098 o=HtmlGroup_GetObject(g);
00099 i=HtmlObject_Grid_GetColumns(o);
00100 j=HtmlGroup_TableRow_GetColumns(sg);
00101 if (j>i)
00102 HtmlObject_Grid_SetColumns(o, j);
00103 }
00104
00105 return 0;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00115