From: Andrea Zagli Date: Sun, 1 Apr 2007 15:21:58 +0000 (+0000) Subject: Added and managed RPT_REPORT_SECTION_REPORT_HEADER and RPT_REPORT_SECTION_REPORT_FOOTER. X-Git-Tag: 0.2.0~33 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=9c80a18ac1695a9f57399db677f1f796dfbb35dd;p=reptool%2Flibreptool Added and managed RPT_REPORT_SECTION_REPORT_HEADER and RPT_REPORT_SECTION_REPORT_FOOTER. Some bugfixes in RptObjText. The RptObjText's source attribute understand @Page, resulting in printing current page number. Managed "underline" and "strike" font's attributes. Version 0.0.2 git-svn-id: svn+ssh://saetta.homelinux.org/svn/libreptool/trunk@10 3191ed1d-3fce-41bb-ab4a-0cebc0943b59 --- diff --git a/ChangeLog b/ChangeLog index e69de29..6a29833 100644 --- a/ChangeLog +++ b/ChangeLog @@ -0,0 +1,29 @@ +2007-04-01 Andrea Zagli + + * src/rptreport.c: added and managed RPT_REPORT_SECTION_REPORT_HEADER and + RPT_REPORT_SECTION_REPORT_FOOTER + * src/rptobjtext.c: some bugfixes; the source attribute understand @Page, + resulting in printing current page number + * src/rptprint.c: managed "underline" and "strike" font's attributes + +2007-03-28 Andrea Zagli + + * Added object RptObjEllipse derived from RptObjrect + * src/rptprint.c: managed ellipse xml node + * src/rptobjline.c: + * src/rptobjline.h: extended RptObjLine (stroke attributes) + * src/rptobjimage.c: + * src/rptobjimage.h: extended RptObjImage (border attributes) + * src/rptobjrect.c: + * src/rptobjrect.h: extended RptObjRect (stroke and fill-color attributes) + +2007-03-26 Andrea Zagli + + * src/rptprint.c: + * src/rptprint.h: + * src/rptcommon.c: + * src/rptcommon.h: moved some functions from rpt_print to rpt_common + * src/rptobjtext.c: + * src/rptobjtext.h: extended RptObjText (border, font and align attributes) + * src/rptobjtext.c: RptObjText's source attribute now read values from db (if + there's a connection) diff --git a/data/reptool.dtd b/data/reptool.dtd index a7b7ae1..34ed4ab 100644 --- a/data/reptool.dtd +++ b/data/reptool.dtd @@ -43,7 +43,7 @@ font-size CDATA #IMPLIED font-bold (y | n) #IMPLIED font-italic (y | n) #IMPLIED - font-underline (y | n) #IMPLIED + font-underline (none | single | double | low | error) #IMPLIED font-strike (y | n) #IMPLIED font-color CDATA #IMPLIED" > @@ -129,7 +129,6 @@ diff --git a/data/reptool_report.dtd b/data/reptool_report.dtd index d3a9160..13fcb6d 100644 --- a/data/reptool_report.dtd +++ b/data/reptool_report.dtd @@ -38,7 +38,7 @@ font-size CDATA #IMPLIED font-bold (y | n) #IMPLIED font-italic (y | n) #IMPLIED - font-underline (y | n) #IMPLIED + font-underline (none | single | double | low | error) #IMPLIED font-strike (y | n) #IMPLIED font-color CDATA #IMPLIED" > diff --git a/docs/reference/libreptool-docs.sgml b/docs/reference/libreptool-docs.sgml index 6aa08b4..b325ad9 100644 --- a/docs/reference/libreptool-docs.sgml +++ b/docs/reference/libreptool-docs.sgml @@ -14,6 +14,7 @@ + diff --git a/docs/reference/libreptool-sections.txt b/docs/reference/libreptool-sections.txt index 1543bec..44feb8e 100644 --- a/docs/reference/libreptool-sections.txt +++ b/docs/reference/libreptool-sections.txt @@ -121,9 +121,47 @@ RPT_OBJ_RECT_GET_CLASS rpt_obj_rect_get_type +
+rptobjectellipse +RptObjEllipse +RptObjEllipse +rpt_obj_ellipse_new +rpt_obj_ellipse_new_from_xml +rpt_obj_ellipse_get_xml + +TYPE_RPT_OBJ_ELLIPSE +RPT_OBJ_ELLIPSE +RPT_OBJ_ELLIPSE_CLASS +IS_RPT_OBJ_ELLIPSE +IS_RPT_OBJ_ELLIPSE_CLASS +RPT_OBJ_ELLIPSE_GET_CLASS +rpt_obj_ellipse_get_type +
+
rptcommon +RptColor +RptPoint +RptSize +RptFont +RptBorder +eRptHAlign +eRptVAlign +RptAlign +RptStroke rpt_common_get_position +rpt_common_set_position rpt_common_get_size +rpt_common_set_size +rpt_common_get_font +rpt_common_set_font +rpt_common_get_border +rpt_common_set_border +rpt_common_get_align +rpt_common_set_align +rpt_common_get_stroke +rpt_common_set_stroke +rpt_common_parse_color +rpt_common_convert_to_str_color
diff --git a/docs/reference/libreptool.types b/docs/reference/libreptool.types index a37d90f..7c943db 100644 --- a/docs/reference/libreptool.types +++ b/docs/reference/libreptool.types @@ -3,6 +3,7 @@ #include #include #include +#include #include rpt_report_get_type @@ -10,5 +11,6 @@ rpt_object_get_type rpt_obj_text_get_type rpt_obj_line_get_type rpt_obj_rect_get_type +rpt_obj_ellipse_get_type rpt_obj_image_get_type rpt_print_get_type diff --git a/docs/reference/tmpl/rptcommon.sgml b/docs/reference/tmpl/rptcommon.sgml index ad23c81..4b9c0e0 100644 --- a/docs/reference/tmpl/rptcommon.sgml +++ b/docs/reference/tmpl/rptcommon.sgml @@ -2,7 +2,8 @@ rptcommon -Common functions usefull for the library's classes. +Usefull functions and struct. + @@ -17,6 +18,94 @@ Common functions usefull for the library's classes. + + + + + +@r: +@g: +@b: +@a: + + + + + + +@x: +@y: + + + + + + +@width: +@height: + + + + + + +@name: +@size: +@bold: +@italic: +@underline: +@strike: +@color: + + + + + + +@top_width: +@right_width: +@bottom_width: +@left_width: +@top_color: +@right_color: +@bottom_color: +@left_color: + + + + + + +@RPT_HALIGN_LEFT: +@RPT_HALIGN_CENTER: +@RPT_HALIGN_RIGHT: +@RPT_HALIGN_JUSTIFIED: + + + + + + +@RPT_VALIGN_TOP: +@RPT_VALIGN_CENTER: +@RPT_VALIGN_BOTTOM: + + + + + + +@h_align: +@v_align: + + + + + + +@width: +@color: + @@ -26,6 +115,15 @@ Common functions usefull for the library's classes. @position: + + + + + +@xnode: +@position: + + @@ -35,3 +133,102 @@ Common functions usefull for the library's classes. @size: + + + + + +@xnode: +@size: + + + + + + + +@xnode: +@font: + + + + + + + +@xnode: +@font: + + + + + + + +@xnode: +@border: + + + + + + + +@xnode: +@border: + + + + + + + +@xnode: +@align: + + + + + + + +@xnode: +@align: + + + + + + + +@xnode: +@stroke: + + + + + + + +@xnode: +@stroke: + + + + + + + +@str_color: +@color: + + + + + + + +@color: +@Returns: + + diff --git a/docs/reference/tmpl/rptobjectellipse.sgml b/docs/reference/tmpl/rptobjectellipse.sgml new file mode 100644 index 0000000..9436f85 --- /dev/null +++ b/docs/reference/tmpl/rptobjectellipse.sgml @@ -0,0 +1,53 @@ + +RptObjEllipse + + +An ellipse object. + + + + + + + + + + + + + + + + + + + + + + + + + +@name: +@position: +@Returns: + + + + + + + +@xnode: +@Returns: + + + + + + + +@rpt_object: +@xnode: + + diff --git a/docs/reference/tmpl/rptobjectimage.sgml b/docs/reference/tmpl/rptobjectimage.sgml index cffaa8a..027bdbf 100644 --- a/docs/reference/tmpl/rptobjectimage.sgml +++ b/docs/reference/tmpl/rptobjectimage.sgml @@ -23,6 +23,16 @@ An image object. + + + + + + + + + + diff --git a/docs/reference/tmpl/rptobjectline.sgml b/docs/reference/tmpl/rptobjectline.sgml index cd8c65a..333db86 100644 --- a/docs/reference/tmpl/rptobjectline.sgml +++ b/docs/reference/tmpl/rptobjectline.sgml @@ -28,6 +28,11 @@ A line object. + + + + + diff --git a/docs/reference/tmpl/rptobjectrect.sgml b/docs/reference/tmpl/rptobjectrect.sgml index 4d6c55a..0882080 100644 --- a/docs/reference/tmpl/rptobjectrect.sgml +++ b/docs/reference/tmpl/rptobjectrect.sgml @@ -23,6 +23,11 @@ A rectangular object. + + + + + diff --git a/docs/reference/tmpl/rptobjecttext.sgml b/docs/reference/tmpl/rptobjecttext.sgml index 23d3529..611d4ef 100644 --- a/docs/reference/tmpl/rptobjecttext.sgml +++ b/docs/reference/tmpl/rptobjecttext.sgml @@ -23,6 +23,21 @@ A textual object. + + + + + + + + + + + + + + + diff --git a/src/rptcommon.c b/src/rptcommon.c index a1c82c1..5ba8fe2 100644 --- a/src/rptcommon.c +++ b/src/rptcommon.c @@ -115,7 +115,7 @@ rpt_common_get_font (xmlNode *xnode, RptFont *font) font->size = 12.0; font->bold = FALSE; font->italic = FALSE; - font->underline = FALSE; + font->underline = PANGO_UNDERLINE_NONE; font->strike = FALSE; font->color.r = 0.0; font->color.g = 0.0; @@ -149,7 +149,24 @@ rpt_common_get_font (xmlNode *xnode, RptFont *font) prop = xmlGetProp (xnode, "font-underline"); if (prop != NULL) { - font->underline = (strcmp (g_strstrip (prop), "y") == 0); + g_strstrip (prop); + + if (strcmp (prop, "single") == 0) + { + font->underline = PANGO_UNDERLINE_SINGLE; + } + else if (strcmp (prop, "double") == 0) + { + font->underline = PANGO_UNDERLINE_DOUBLE; + } + else if (strcmp (prop, "low") == 0) + { + font->underline = PANGO_UNDERLINE_LOW; + } + else if (strcmp (prop, "error") == 0) + { + font->underline = PANGO_UNDERLINE_ERROR; + } } prop = xmlGetProp (xnode, "font-strike"); @@ -184,9 +201,26 @@ rpt_common_set_font (xmlNode *xnode, RptFont font) { xmlSetProp (xnode, "font-italic", "y"); } - if (font.underline) + if (font.underline != PANGO_UNDERLINE_NONE) { - xmlSetProp (xnode, "font-underline", "y"); + switch (font.underline) + { + case PANGO_UNDERLINE_SINGLE: + xmlSetProp (xnode, "font-underline", "single"); + break; + + case PANGO_UNDERLINE_DOUBLE: + xmlSetProp (xnode, "font-underline", "double"); + break; + + case PANGO_UNDERLINE_LOW: + xmlSetProp (xnode, "font-underline", "low"); + break; + + case PANGO_UNDERLINE_ERROR: + xmlSetProp (xnode, "font-underline", "error"); + break; + } } if (font.strike) { diff --git a/src/rptcommon.h b/src/rptcommon.h index 5b1bd82..e3af680 100644 --- a/src/rptcommon.h +++ b/src/rptcommon.h @@ -23,41 +23,64 @@ #include #include +#include + G_BEGIN_DECLS -typedef struct +/** + * RptColor: + * @r: the red channel + * @g: the green channel + * @b: the blue channel + * @a: the alpha channel + */ +struct _RptColor { gdouble r; gdouble g; gdouble b; gdouble a; -} RptColor; +}; +typedef struct _RptColor RptColor; -typedef struct +struct _RptPoint { gdouble x; gdouble y; -} RptPoint; +}; +typedef struct _RptPoint RptPoint; -typedef struct +struct _RptSize { gdouble width; gdouble height; -} RptSize; - -typedef struct +}; +typedef struct _RptSize RptSize; + +/** + * RptFont: + * @name: the font's family name. + * @size: the font's size in pixel. + * @bold: if the font is bold. + * @italic: if the font is italic. + * @underline: + * @strike: if the font is striked. + * @color: an #RptColor. + */ +struct _RptFont { gchar *name; gdouble size; gboolean bold; gboolean italic; - gboolean underline; + PangoUnderline underline; gboolean strike; RptColor color; -} RptFont; +}; +typedef struct _RptFont RptFont; -typedef struct +struct _RptBorder { gdouble top_width; gdouble right_width; @@ -67,7 +90,8 @@ typedef struct RptColor right_color; RptColor bottom_color; RptColor left_color; -} RptBorder; +}; +typedef struct _RptBorder RptBorder; typedef enum { @@ -84,17 +108,19 @@ typedef enum RPT_VALIGN_BOTTOM } eRptVAlign; -typedef struct +struct _RptAlign { eRptHAlign h_align; eRptVAlign v_align; -} RptAlign; +}; +typedef struct _RptAlign RptAlign; -typedef struct +struct _RptStroke { gdouble width; RptColor color; -} RptStroke; +}; +typedef struct _RptStroke RptStroke; void rpt_common_get_position (xmlNode *xnode, diff --git a/src/rptobjecttext.c b/src/rptobjecttext.c index 9cb0631..b88b582 100644 --- a/src/rptobjecttext.c +++ b/src/rptobjecttext.c @@ -193,6 +193,7 @@ RptObject rpt_common_get_size (xnode, priv->size); rpt_common_get_border (xnode, priv->border); rpt_common_get_font (xnode, priv->font); + rpt_common_get_align (xnode, priv->align); g_object_set (rpt_obj_text, "source", xmlGetProp (xnode, "source"), NULL); } @@ -208,9 +209,7 @@ rpt_obj_text_get_xml (RptObject *rpt_objtext, xmlNode *xnode) xmlNodeSetName (xnode, "text"); - xmlSetProp (xnode, "width", g_strdup_printf ("%f", priv->size->width)); - xmlSetProp (xnode, "height", g_strdup_printf ("%f", priv->size->height)); - + rpt_common_set_size (xnode, (RptSize)*priv->size); rpt_common_set_border (xnode, (RptBorder)*priv->border); rpt_common_set_font (xnode, (RptFont)*priv->font); rpt_common_set_align (xnode, (RptAlign)*priv->align); diff --git a/src/rptprint.c b/src/rptprint.c index 76e60e9..1352284 100644 --- a/src/rptprint.c +++ b/src/rptprint.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "rptprint.h" #include "rptcommon.h" @@ -362,6 +363,8 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode) PangoLayout *playout; PangoFontDescription *pfdesc; + PangoAttribute *pattr; + PangoAttrList *lpattr = NULL; gchar *text = (gchar *)xmlNodeGetContent (xnode), *prop, @@ -413,12 +416,6 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode) { str_font = g_strjoin (NULL, str_font, " italic", NULL); } - /*if (font.underline) - { - }*/ - /*if (font.strike) - { - }*/ if (font.size > 0) { str_font = g_strjoin (NULL, str_font, g_strdup_printf (" %f", font.size), NULL); @@ -433,6 +430,41 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode) pango_layout_set_font_description (playout, pfdesc); pango_font_description_free (pfdesc); + /* setting layout attributes */ + if (font.underline != PANGO_UNDERLINE_NONE) + { + PangoAttribute *pattr; + + pattr = pango_attr_underline_new (font.underline); + pattr->start_index = 0; + pattr->end_index = strlen (text) + 1; + + if (lpattr == NULL) + { + lpattr = pango_attr_list_new (); + } + pango_attr_list_insert (lpattr, pattr); + } + if (font.strike) + { + PangoAttribute *pattr; + + pattr = pango_attr_strikethrough_new (TRUE); + pattr->start_index = 0; + pattr->end_index = strlen (text) + 1; + + if (lpattr == NULL) + { + lpattr = pango_attr_list_new (); + } + pango_attr_list_insert (lpattr, pattr); + } + + if (lpattr != NULL) + { + pango_layout_set_attributes (playout, lpattr); + } + /* background */ prop = xmlGetProp (xnode, (const xmlChar *)"background-color"); if (prop != NULL) diff --git a/src/rptreport.c b/src/rptreport.c index f27dc8f..439678e 100644 --- a/src/rptreport.c +++ b/src/rptreport.c @@ -37,6 +37,8 @@ typedef enum { + RPTREPORT_SECTION_REPORT_HEADER, + RPTREPORT_SECTION_REPORT_FOOTER, RPTREPORT_SECTION_PAGE_HEADER, RPTREPORT_SECTION_PAGE_FOOTER, RPTREPORT_SECTION_BODY @@ -47,6 +49,18 @@ typedef struct RptSize *size; } Page; +typedef struct +{ + gdouble height; + GList *objects; +} ReportHeader; + +typedef struct +{ + gdouble height; + GList *objects; +} ReportFooter; + typedef struct { gdouble height; @@ -111,9 +125,13 @@ struct _RptReportPrivate GdaDataModel *gda_datamodel; Page *page; + ReportHeader *report_header; + ReportFooter *report_footer; PageHeader *page_header; PageFooter *page_footer; Body *body; + + guint cur_page; }; GType @@ -169,6 +187,14 @@ rpt_report_init (RptReport *rpt_report) priv->page->size->width = 0.0; priv->page->size->height = 0.0; + priv->report_header = (ReportHeader *)g_malloc0 (sizeof (ReportHeader)); + priv->report_header->height = 0.0; + priv->report_header->objects = NULL; + + priv->report_footer = (ReportFooter *)g_malloc0 (sizeof (ReportFooter)); + priv->report_footer->height = 0.0; + priv->report_footer->objects = NULL; + priv->page_header = (PageHeader *)g_malloc0 (sizeof (PageHeader)); priv->page_header->height = 0.0; priv->page_header->objects = NULL; @@ -305,6 +331,22 @@ RptReport xnodeset = xpresult->nodesetval; if (xnodeset->nodeNr == 1) { + /* search for node "report-header" */ + xpcontext->node = xnodeset->nodeTab[0]; + xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::report-header", xpcontext); + if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval) && xpresult->nodesetval->nodeNr == 1) + { + rpt_report_xml_parse_section (rpt_report, xpresult->nodesetval->nodeTab[0], RPTREPORT_SECTION_REPORT_HEADER); + } + + /* search for node "report-footer" */ + xpcontext->node = xnodeset->nodeTab[0]; + xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::report-footer", xpcontext); + if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval) && xpresult->nodesetval->nodeNr == 1) + { + rpt_report_xml_parse_section (rpt_report, xpresult->nodesetval->nodeTab[0], RPTREPORT_SECTION_REPORT_FOOTER); + } + /* search for node "page-header" */ xpcontext->node = xnodeset->nodeTab[0]; xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::page-header", xpcontext); @@ -396,6 +438,8 @@ xmlDoc * rpt_report_get_xml_rptprint: * @rpt_report: an #RptReport object. * + * Returns: an #xmlDoc, that represents the generated report, to pass to + * function rpt_print_new_from_xml(). */ xmlDoc *rpt_report_get_xml_rptprint (RptReport *rpt_report) @@ -403,7 +447,6 @@ xmlDoc xmlDoc *xdoc; xmlNode *xroot; xmlNode *xpage; - gint pages = 0; gdouble cur_y = 0.0; RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report); @@ -412,6 +455,7 @@ xmlDoc xroot = xmlNewNode (NULL, "reptool_report"); xmlDocSetRootElement (xdoc, xroot); + priv->cur_page = 0; if (priv->gda_datamodel != NULL) { gint row; @@ -422,19 +466,23 @@ xmlDoc for (row = 0; row < rows; row++) { if (row == 0 || - (priv->page_footer != NULL && (cur_y > priv->page->size->height - priv->page_footer->height)) || + (priv->page_footer != NULL && (cur_y + priv->body->height > priv->page->size->height - priv->page_footer->height)) || cur_y > priv->page->size->height) { - if (pages > 0 && priv->page_footer != NULL) + if (priv->cur_page > 0 && priv->page_footer != NULL) { cur_y = priv->page->size->height - priv->page_footer->height; rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1); } cur_y = 0.0; - pages++; + priv->cur_page++; xpage = rpt_report_rptprint_new_page (rpt_report, xroot); + if (priv->cur_page == 1 && priv->report_header != NULL) + { + rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_REPORT_HEADER, row); + } if (priv->page_header != NULL) { rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER, row); @@ -444,7 +492,11 @@ xmlDoc rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_BODY, row); } - if (pages > 0 && priv->page_footer != NULL) + if (priv->cur_page > 0 && priv->report_footer != NULL) + { + rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_REPORT_FOOTER, row - 1); + } + if (priv->cur_page > 0 && priv->page_footer != NULL) { cur_y = priv->page->size->height - priv->page_footer->height; rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1); @@ -452,15 +504,24 @@ xmlDoc } else { + priv->cur_page++; + xpage = rpt_report_rptprint_new_page (rpt_report, xroot); + + if (priv->report_header != NULL) + { + rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_REPORT_HEADER, -1); + } if (priv->page_header != NULL) { rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER, -1); } - pages++; - xpage = rpt_report_rptprint_new_page (rpt_report, xroot); rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_BODY, -1); + if (priv->report_footer != NULL) + { + rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_REPORT_FOOTER, -1); + } if (priv->page_footer != NULL) { cur_y = priv->page->size->height - priv->page_footer->height; @@ -563,6 +624,16 @@ rpt_report_xml_parse_section (RptReport *rpt_report, xmlNode *xnode, RptReportSe switch (section) { + case RPTREPORT_SECTION_REPORT_HEADER: + priv->report_header->height = height; + priv->report_header->objects = objects; + break; + + case RPTREPORT_SECTION_REPORT_FOOTER: + priv->report_footer->height = height; + priv->report_footer->objects = objects; + break; + case RPTREPORT_SECTION_PAGE_HEADER: priv->page_header->height = height; priv->page_header->objects = objects; @@ -587,7 +658,13 @@ static RptObject RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report); - if ((obj = rpt_report_get_object_from_name_in_list (priv->page_header->objects, name)) != NULL) + if ((obj = rpt_report_get_object_from_name_in_list (priv->report_header->objects, name)) != NULL) + { + } + else if ((obj = rpt_report_get_object_from_name_in_list (priv->report_footer->objects, name)) != NULL) + { + } + else if ((obj = rpt_report_get_object_from_name_in_list (priv->page_header->objects, name)) != NULL) { } else if ((obj = rpt_report_get_object_from_name_in_list (priv->page_footer->objects, name)) != NULL) @@ -651,6 +728,14 @@ rpt_report_rptprint_section (RptReport *rpt_report, xmlNode *xpage, gdouble *cur switch (section) { + case RPTREPORT_SECTION_REPORT_HEADER: + objects = g_list_first (priv->report_header->objects); + break; + + case RPTREPORT_SECTION_REPORT_FOOTER: + objects = g_list_first (priv->report_footer->objects); + break; + case RPTREPORT_SECTION_PAGE_HEADER: objects = g_list_first (priv->page_header->objects); break; @@ -700,6 +785,14 @@ rpt_report_rptprint_section (RptReport *rpt_report, xmlNode *xpage, gdouble *cur switch (section) { + case RPTREPORT_SECTION_REPORT_HEADER: + *cur_y += priv->report_header->height; + break; + + case RPTREPORT_SECTION_REPORT_FOOTER: + *cur_y += priv->report_footer->height; + break; + case RPTREPORT_SECTION_PAGE_HEADER: *cur_y += priv->page_header->height; break; @@ -724,7 +817,7 @@ rpt_report_rptprint_parse_text_source (RptReport *rpt_report, RptObject *rptobj, g_object_get (G_OBJECT (rptobj), "source", &source, NULL); - if (row > -1 && source[0] == '[' && source[strlen (source) - 1] == ']') + if (row > -1 && priv->gda_datamodel != NULL && source[0] == '[' && source[strlen (source) - 1] == ']') { gint col; gchar *field; @@ -736,6 +829,26 @@ rpt_report_rptprint_parse_text_source (RptReport *rpt_report, RptObject *rptobj, { source = gda_value_stringify ((GdaValue *)gda_data_model_get_value_at (priv->gda_datamodel, col, row)); } + else + { + /* TO DO */ + /* ask value */ + } + } + else if (source[0] == '[' && source[strlen (source) - 1] == ']') + { + /* TO DO */ + /* ask value */ + } + else if (source[0] == '@') + { + /* TO DO */ + /* special */ + + if (strcmp (source + 1, "Page") == 0) + { + source = g_strdup_printf ("%d", priv->cur_page); + } } xmlNodeSetContent (xnode, source); diff --git a/tests/test_report_db.rpt b/tests/test_report_db.rpt index b30d30f..c912e1f 100644 --- a/tests/test_report_db.rpt +++ b/tests/test_report_db.rpt @@ -4,13 +4,17 @@ SQLite + URI=///home/andreaz/files/c/reptool/libreptool/tests/db_test.db SELECT * FROM articles ORDER BY name + + + - + @@ -19,10 +23,16 @@ + + + + + - + + diff --git a/tests/test_rptprint.rptr b/tests/test_rptprint.rptr index 3763a03..499160f 100644 --- a/tests/test_rptprint.rptr +++ b/tests/test_rptprint.rptr @@ -11,5 +11,11 @@ Text sample on second page + Underline single + Underline double + Underline low + Underline error + Text striked and bold + Text italic diff --git a/tests/test_rptreport.c b/tests/test_rptreport.c index 9302321..ad35069 100644 --- a/tests/test_rptreport.c +++ b/tests/test_rptreport.c @@ -17,11 +17,13 @@ */ #include +#include int main (int argc, char **argv) { RptReport *rptr; + RptPrint *rptp; g_type_init (); @@ -31,6 +33,8 @@ main (int argc, char **argv) { xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr); xmlSaveFormatFile ("test_report.rptr", rptprint, 2); + + rpt_print_new_from_xml (rptprint, RPTP_OUTPUT_PDF, "test.pdf"); } return 0;