/*
- * Copyright (C) 2007-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
RptPoint *point;
point = (RptPoint *)g_malloc0 (sizeof (RptPoint));
+ point->x = 0.0;
+ point->y = 0.0;
return point;
}
RptSize *size;
size = (RptSize *)g_malloc0 (sizeof (RptSize));
+ size->width = 0.0;
+ size->height = 0.0;
return size;
}
RptRotation *rotation;
rotation = (RptRotation *)g_malloc0 (sizeof (RptRotation));
+ rotation->angle = 0.0;
return rotation;
}
}
}
+/**
+ * rpt_common_rptmargin_new:
+ *
+ * Returns: an new allocated #RptMargin struct.
+ */
+RptMargin
+*rpt_common_rptmargin_new (void)
+{
+ RptMargin *margin;
+
+ margin = (RptMargin *)g_malloc0 (sizeof (RptMargin));
+ margin->top = 0.0;
+ margin->right = 0.0;
+ margin->bottom = 0.0;
+ margin->left = 0.0;
+
+ return margin;
+}
+
+/**
+ * rpt_common_get_margin:
+ * @xnode: an #xmlNode.
+ *
+ * Returns: an #RptMargin struct that represent the page's margin specified
+ * on @xnode.
+ */
+RptMargin
+*rpt_common_get_margin (xmlNode *xnode)
+{
+ RptMargin *margin = NULL;
+ gchar *prop;
+
+ margin = rpt_common_rptmargin_new ();
+
+ prop = xmlGetProp (xnode, (const xmlChar *)"top");
+ if (prop != NULL)
+ {
+ margin->top = g_strtod (prop, NULL);
+ }
+ prop = xmlGetProp (xnode, (const xmlChar *)"right");
+ if (prop != NULL)
+ {
+ margin->right = g_strtod (prop, NULL);
+ }
+ prop = xmlGetProp (xnode, (const xmlChar *)"bottom");
+ if (prop != NULL)
+ {
+ margin->bottom = g_strtod (prop, NULL);
+ }
+ prop = xmlGetProp (xnode, (const xmlChar *)"left");
+ if (prop != NULL)
+ {
+ margin->left = g_strtod (prop, NULL);
+ }
+
+ return margin;
+}
+
+/**
+ * rpt_common_set_margin:
+ * @xnode: an #xmlNode.
+ * @margin:
+ *
+ */
+void
+rpt_common_set_margin (xmlNode *xnode, const RptMargin *margin)
+{
+ if (margin != NULL)
+ {
+ xmlSetProp (xnode, "top", g_strdup_printf ("%f", margin->top));
+ xmlSetProp (xnode, "right", g_strdup_printf ("%f", margin->right));
+ xmlSetProp (xnode, "bottom", g_strdup_printf ("%f", margin->bottom));
+ xmlSetProp (xnode, "left", g_strdup_printf ("%f", margin->left));
+ }
+}
+
/**
* rpt_common_rptfont_new:
*
/*
- * Copyright (C) 2007-2010 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@inwind.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
typedef struct
{
RptSize *size;
- gdouble margin_top;
- gdouble margin_right;
- gdouble margin_bottom;
- gdouble margin_left;
+ RptMargin *margin;
} Page;
typedef struct
priv->db = NULL;
priv->page = (Page *)g_malloc0 (sizeof (Page));
- priv->page->size = (RptSize *)g_malloc0 (sizeof (RptSize));
- priv->page->size->width = 0.0;
- priv->page->size->height = 0.0;
+
+ priv->page->size = rpt_common_rptsize_new ();
+ priv->page->margin = rpt_common_rptmargin_new ();
priv->report_header = NULL;
priv->report_footer = NULL;
{
RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
- priv->page->margin_top = top;
- priv->page->margin_right = right;
- priv->page->margin_bottom = bottom;
- priv->page->margin_left = left;
+ priv->page->margin->top = top;
+ priv->page->margin->right = right;
+ priv->page->margin->bottom = bottom;
+ priv->page->margin->left = left;
}
/**
{
RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
- *top = priv->page->margin_top;
- *right = priv->page->margin_right;
- *bottom = priv->page->margin_bottom;
- *left = priv->page->margin_left;
+ *top = priv->page->margin->top;
+ *right = priv->page->margin->right;
+ *bottom = priv->page->margin->bottom;
+ *left = priv->page->margin->left;
+}
+
+RptMargin
+*rpt_report_get_page_margins_struct (RptReport *rpt_report)
+{
+ RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+ return g_memdup (priv->page->margin, sizeof (RptMargin));
+}
+
+void
+rpt_report_set_page_margins_struct (RptReport *rpt_report, RptMargin margin)
+{
+ RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+ g_free (priv->page->margin);
+ priv->page->margin = g_memdup (&margin, sizeof (RptMargin));
}
/**
xnode = xmlNewNode (NULL, "page");
rpt_common_set_size (xnode, priv->page->size);
- if (priv->page->margin_top != 0.0)
+ if (priv->page->margin->top != 0.0)
{
- xmlSetProp (xnode, "margin-top", g_strdup_printf ("%f", priv->page->margin_top));
+ xmlSetProp (xnode, "margin-top", g_strdup_printf ("%f", priv->page->margin->top));
}
- if (priv->page->margin_right != 0.0)
+ if (priv->page->margin->right != 0.0)
{
- xmlSetProp (xnode, "margin-right", g_strdup_printf ("%f", priv->page->margin_right));
+ xmlSetProp (xnode, "margin-right", g_strdup_printf ("%f", priv->page->margin->right));
}
- if (priv->page->margin_bottom != 0.0)
+ if (priv->page->margin->bottom != 0.0)
{
- xmlSetProp (xnode, "margin-bottom", g_strdup_printf ("%f", priv->page->margin_bottom));
+ xmlSetProp (xnode, "margin-bottom", g_strdup_printf ("%f", priv->page->margin->bottom));
}
- if (priv->page->margin_left != 0.0)
+ if (priv->page->margin->left != 0.0)
{
- xmlSetProp (xnode, "margin-left", g_strdup_printf ("%f", priv->page->margin_left));
+ xmlSetProp (xnode, "margin-left", g_strdup_printf ("%f", priv->page->margin->left));
}
xmlAddChild (xroot, xnode);
{
if (row == 0 ||
priv->body->new_page_after ||
- (priv->page_footer != NULL && (cur_y + priv->body->height > priv->page->size->height - priv->page->margin_bottom - priv->page_footer->height)) ||
- cur_y > (priv->page->size->height - priv->page->margin_bottom))
+ (priv->page_footer != NULL && (cur_y + priv->body->height > priv->page->size->height - priv->page->margin->bottom - priv->page_footer->height)) ||
+ cur_y > (priv->page->size->height - priv->page->margin->bottom))
{
if (priv->cur_page > 0 && priv->page_footer != NULL)
{
if ((priv->cur_page == 1 && priv->page_footer->first_page) ||
priv->cur_page > 1)
{
- cur_y = priv->page->size->height - priv->page->margin_bottom - priv->page_footer->height;
+ cur_y = priv->page->size->height - priv->page->margin->bottom - priv->page_footer->height;
rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1);
}
}
- cur_y = priv->page->margin_top;
+ cur_y = priv->page->margin->top;
xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
if (priv->page_header != NULL)
if (priv->cur_page > 0 && priv->report_footer != NULL)
{
- if ((cur_y + priv->report_footer->height > priv->page->size->height - priv->page->margin_bottom - (priv->page_footer != NULL ? priv->page_footer->height : 0.0)) ||
+ if ((cur_y + priv->report_footer->height > priv->page->size->height - priv->page->margin->bottom - (priv->page_footer != NULL ? priv->page_footer->height : 0.0)) ||
priv->report_footer->new_page_before)
{
if (priv->page_header != NULL)
rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER, row - 1);
}
- cur_y = priv->page->margin_top;
+ cur_y = priv->page->margin->top;
xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
if (priv->cur_page > 0 && priv->page_footer != NULL)
{
- cur_y = priv->page->size->height - priv->page->margin_bottom - priv->page_footer->height;
+ cur_y = priv->page->size->height - priv->page->margin->bottom - priv->page_footer->height;
rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1);
}
}
}
if (priv->cur_page > 0 && priv->page_footer != NULL && priv->page_footer->last_page)
{
- cur_y = priv->page->size->height - priv->page->margin_bottom - priv->page_footer->height;
+ cur_y = priv->page->size->height - priv->page->margin->bottom - priv->page_footer->height;
rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1);
}
}
else
{
- cur_y = priv->page->margin_top;
+ cur_y = priv->page->margin->top;
xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
if (priv->page_header != NULL)
}
if (priv->page_footer != NULL)
{
- cur_y = priv->page->size->height - priv->page->margin_bottom - priv->page_footer->height;
+ cur_y = priv->page->size->height - priv->page->margin->bottom - priv->page_footer->height;
rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, -1);
}
}
xmlAddChild (xroot, xnode);
rpt_common_set_size (xnode, priv->page->size);
- if (priv->page->margin_top != 0.0)
+ if (priv->page->margin->top != 0.0)
{
- xmlSetProp (xnode, "margin-top", g_strdup_printf ("%f", priv->page->margin_top));
+ xmlSetProp (xnode, "margin-top", g_strdup_printf ("%f", priv->page->margin->top));
}
- if (priv->page->margin_right != 0.0)
+ if (priv->page->margin->right != 0.0)
{
- xmlSetProp (xnode, "margin-right", g_strdup_printf ("%f", priv->page->margin_right));
+ xmlSetProp (xnode, "margin-right", g_strdup_printf ("%f", priv->page->margin->right));
}
- if (priv->page->margin_bottom != 0.0)
+ if (priv->page->margin->bottom != 0.0)
{
- xmlSetProp (xnode, "margin-bottom", g_strdup_printf ("%f", priv->page->margin_bottom));
+ xmlSetProp (xnode, "margin-bottom", g_strdup_printf ("%f", priv->page->margin->bottom));
}
- if (priv->page->margin_left != 0.0)
+ if (priv->page->margin->left != 0.0)
{
- xmlSetProp (xnode, "margin-left", g_strdup_printf ("%f", priv->page->margin_left));
+ xmlSetProp (xnode, "margin-left", g_strdup_printf ("%f", priv->page->margin->left));
}
priv->cur_page++;
xmlRemoveProp (attr);
}
- if (priv->page->margin_left != 0.0)
+ if (priv->page->margin->left != 0.0)
{
prop = (gchar *)xmlGetProp (xnode, "x");
if (prop == NULL)
{
prop = g_strdup ("0.0");
}
- xmlSetProp (xnode, "x", g_strdup_printf ("%f", strtod (prop, NULL) + priv->page->margin_left));
+ xmlSetProp (xnode, "x", g_strdup_printf ("%f", strtod (prop, NULL) + priv->page->margin->left));
}
prop = (gchar *)xmlGetProp (xnode, "y");
<?xml version="1.0"?>
<reptool>
- <database>
- <provider>
-SQLite
- </provider>
- <connection-string>
-DB_DIR=.;DB_NAME=db_test.db
- </connection-string>
- <sql>
-SELECT * FROM articles ORDER BY name
- </sql>
- </database>
- <page width="595.000000" height="842.000000"/>
+ <properties>
+ <unit-length>pt</unit-length>
+ <output-type>df</output-type>
+ <output-filename>rptreport.pdf</output-filename>
+ <copies>1</copies>
+ </properties>
+ <page width="595.000000" height="842.000000" margin-top="200.000000" margin-left="100.000000"/>
<report>
- <report-header height="80.000000">
- <text name="rephead" x="10.000000" y="10.000000" width="300.000000" height="70.000000" font-name="Verdana" font-size="16.000000" font-bold="y" font-color="#0000FFFF" source=""the report's header""/>
- </report-header>
- <page-header first-page="y" height="80.000000">
- <text name="title" x="10.000000" y="10.000000" width="300.000000" height="50.000000" font-name="Courier New" font-size="10.000000" font-bold="y" source=""the page's title" & " - " & @Page"/>
- <line name="line1" x="10.000000" y="65.000000" width="500.000000" height="0.000000" stroke-width="1.000000" stroke-color="#000000FF"/>
- </page-header>
- <body height="200.000000">
- <text name="txt_id" x="50.000000" y="50.000000" width="100.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="[id]"/>
- <text name="txt_name" x="200.000000" y="50.000000" width="100.000000" height="50.000000" font-name="Sans" font-size="12.000000" source="[name]"/>
- <text name="txt_req" x="50.000000" y="100.000000" width="100.000000" height="50.000000" font-name="Sans" font-size="12.000000" source="[nonexistent]"/>
- <rect name="rect1" x="400.000000" y="10.000000" width="20.000000" height="20.000000" stroke-width="1.000000" stroke-color="#000000FF" fill-color="#00FF00FF"/>
- <image name="img1" x="450.000000" y="10.000000" width="60.000000" height="60.000000" border-bottom-width="1.000000" border-bottom-color="#FF0000FF" border-bottom-style="10.000000;10.000000;" source="tests/gnome-globe.png"/>
+ <body height="0.000000">
+ <text name="txt_id" x="50.000000" y="50.000000" width="100.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source=""text with new line""/>
</body>
- <report-footer height="50.000000">
- <line name="line3" x="10.000000" y="10.000000" width="500.000000" height="0.000000" stroke-width="1.000000" stroke-color="#FFFF00FF" stroke-style="50.000000;10.000000;"/>
- <text name="txt_report_footer" x="10.000000" y="20.000000" width="500.000000" height="30.000000" font-name="Sans" font-size="12.000000" horizontal-align="center" source=""the report's footer""/>
- <line name="line4" x="10.000000" y="50.000000" width="500.000000" height="0.000000" stroke-width="1.000000" stroke-color="#FFFF00FF" stroke-style="1.000000;5.000000;"/>
- </report-footer>
- <page-footer first-page="y" last-page="y" height="80.000000">
- <line name="line2" x="10.000000" y="10.000000" width="500.000000" height="0.000000" stroke-width="1.000000" stroke-color="#000000FF"/>
- <text name="footer" x="10.000000" y="20.000000" width="300.000000" height="50.000000" font-name="Sans" font-size="12.000000" source=""the page's footer""/>
- <ellipse name="ellipse1" x="400.000000" y="50.000000" width="20.000000" height="10.000000" stroke-width="1.000000" stroke-color="#FF0000FF" fill-color="#00FF00FF"/>
- <text name="page_n" x="500.000000" y="20.000000" width="50.000000" height="50.000000" font-name="Sans" font-size="12.000000" source="@Page & "/" & @Pages"/>
- </page-footer>
</report>
</reptool>