static void rpt_report_section_create (RptReport *rpt_report, RptReportSection section);
static xmlNode *rpt_report_section_get_xml (RptReport *rpt_report, RptReportSection section);
+static xmlNode *rpt_report_rptprint_get_properties_node (xmlDoc *xdoc);
+
static xmlNode *rpt_report_rptprint_new_page (RptReport *rpt_report,
- xmlNode *xroot);
+ xmlDoc *xdoc);
static void rpt_report_rptprint_section (RptReport *rpt_report,
xmlNode *xpage,
gdouble *cur_y,
guint cur_page;
};
-GType
-rpt_report_get_type (void)
-{
- static GType rpt_report_type = 0;
-
- if (!rpt_report_type)
- {
- static const GTypeInfo rpt_report_info =
- {
- sizeof (RptReportClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) rpt_report_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (RptReport),
- 0, /* n_preallocs */
- (GInstanceInitFunc) rpt_report_init,
- NULL
- };
-
- rpt_report_type = g_type_register_static (G_TYPE_OBJECT, "RptReport",
- &rpt_report_info, 0);
- }
-
- return rpt_report_type;
-}
+G_DEFINE_TYPE (RptReport, rpt_report, G_TYPE_OBJECT)
static void
rpt_report_class_init (RptReportClass *klass)
rpt_report = rpt_report_new ();
priv = RPT_REPORT_GET_PRIVATE (rpt_report);
- xpcontext = xmlXPathNewContext (xdoc);
/* search for node "properties" */
- xpcontext->node = cur;
- xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::properties", xpcontext);
- if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+ xmlNode *xnodeprop = rpt_report_rptprint_get_properties_node (xdoc);
+ if (xnodeprop != NULL)
{
- xnodeset = xpresult->nodesetval;
- if (xnodeset->nodeNr == 1)
+ xmlNode *cur_property = xnodeprop->children;
+ while (cur_property != NULL)
{
- xmlNode *cur_property = xnodeset->nodeTab[0]->children;
- while (cur_property != NULL)
+ if (g_strcmp0 (cur_property->name, "unit-length") == 0)
{
- if (g_strcmp0 (cur_property->name, "unit-length") == 0)
- {
- g_object_set (G_OBJECT (rpt_report), "unit-length", rpt_common_strunit_to_enum ((const gchar *)xmlNodeGetContent (cur_property)), NULL);
- }
- else if (g_strcmp0 (cur_property->name, "output-type") == 0)
- {
- rpt_report_set_output_type (rpt_report, rpt_common_stroutputtype_to_enum ((const gchar *)xmlNodeGetContent (cur_property)));
- }
- else if (g_strcmp0 (cur_property->name, "output-filename") == 0)
- {
- rpt_report_set_output_filename (rpt_report, (const gchar *)xmlNodeGetContent (cur_property));
- }
- else if (g_strcmp0 (cur_property->name, "copies") == 0)
- {
- rpt_report_set_copies (rpt_report, strtol ((const gchar *)xmlNodeGetContent (cur_property), NULL, 10));
- }
-
- cur_property = cur_property->next;
+ g_object_set (G_OBJECT (rpt_report), "unit-length", rpt_common_strunit_to_enum ((const gchar *)xmlNodeGetContent (cur_property)), NULL);
}
+ else if (g_strcmp0 (cur_property->name, "output-type") == 0)
+ {
+ rpt_report_set_output_type (rpt_report, rpt_common_stroutputtype_to_enum ((const gchar *)xmlNodeGetContent (cur_property)));
+ }
+ else if (g_strcmp0 (cur_property->name, "output-filename") == 0)
+ {
+ rpt_report_set_output_filename (rpt_report, (const gchar *)xmlNodeGetContent (cur_property));
+ }
+ else if (g_strcmp0 (cur_property->name, "copies") == 0)
+ {
+ rpt_report_set_copies (rpt_report, strtol ((const gchar *)xmlNodeGetContent (cur_property), NULL, 10));
+ }
+
+ cur_property = cur_property->next;
}
}
/* search for node "database" */
+ xpcontext = xmlXPathNewContext (xdoc);
xpcontext->node = cur;
xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::database", xpcontext);
if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
}
cur_y = priv->page->margin->top;
- xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
+ xpage = rpt_report_rptprint_new_page (rpt_report, xdoc);
if (priv->page_header != NULL)
{
if (priv->report_header->new_page_after)
{
cur_y = 0.0;
- xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
+ xpage = rpt_report_rptprint_new_page (rpt_report, xdoc);
}
}
}
}
cur_y = priv->page->margin->top;
- xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
+ xpage = rpt_report_rptprint_new_page (rpt_report, xdoc);
if (priv->cur_page > 0 && priv->page_footer != NULL)
{
else
{
cur_y = priv->page->margin->top;
- xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
+ xpage = rpt_report_rptprint_new_page (rpt_report, xdoc);
if (priv->page_header != NULL)
{
return xdoc;
}
-static xmlNode
-*rpt_report_rptprint_get_properties_node (xmlDoc *xdoc)
-{
- xmlNode *xnode;
-
- xmlXPathContextPtr xpcontext;
- xmlXPathObjectPtr xpresult;
- xmlNodeSetPtr xnodeset;
-
- xnode = NULL;
-
- xpcontext = xmlXPathNewContext (xdoc);
-
- /* search for node "properties" */
- xpcontext->node = xmlDocGetRootElement (xdoc);
- xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::properties", xpcontext);
- if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
- {
- xnodeset = xpresult->nodesetval;
- if (xnodeset->nodeNr > 0)
- {
- xnode = xnodeset->nodeTab[0];
- }
- }
-
- return xnode;
-}
-
void
rpt_report_rptprint_set_unit_length (xmlDoc *xdoc, eRptUnitLength unit)
{
xmlAddChild (xnodeprop, xnode);
}
+xmlNode
+*rpt_report_rptprint_page_new (xmlDoc *xdoc, RptSize *size, RptMargin *margin)
+{
+ xmlNode *xroot;
+ xmlNode *xnode;
+
+ xroot = xmlDocGetRootElement (xdoc);
+
+ xnode = xmlNewNode (NULL, "page");
+ xmlAddChild (xroot, xnode);
+
+ rpt_common_set_size (xnode, size);
+ rpt_common_set_margin (xnode, margin);
+
+ return xnode;
+}
+
/**
* rpt_report_add_object_to_section:
* @rpt_report: an #RptReport object.
}
static xmlNode
-*rpt_report_rptprint_new_page (RptReport *rpt_report, xmlNode *xroot)
+*rpt_report_rptprint_get_properties_node (xmlDoc *xdoc)
{
xmlNode *xnode;
- RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+ xmlXPathContextPtr xpcontext;
+ xmlXPathObjectPtr xpresult;
+ xmlNodeSetPtr xnodeset;
- xnode = xmlNewNode (NULL, "page");
- xmlAddChild (xroot, xnode);
+ xnode = NULL;
- rpt_common_set_size (xnode, priv->page->size);
- if (priv->page->margin->top != 0.0)
- {
- xmlSetProp (xnode, "margin-top", g_strdup_printf ("%f", priv->page->margin->top));
- }
- if (priv->page->margin->right != 0.0)
- {
- xmlSetProp (xnode, "margin-right", g_strdup_printf ("%f", priv->page->margin->right));
- }
- if (priv->page->margin->bottom != 0.0)
- {
- xmlSetProp (xnode, "margin-bottom", g_strdup_printf ("%f", priv->page->margin->bottom));
- }
- if (priv->page->margin->left != 0.0)
+ xpcontext = xmlXPathNewContext (xdoc);
+
+ /* search for node "properties" */
+ xpcontext->node = xmlDocGetRootElement (xdoc);
+ xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::properties", xpcontext);
+ if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
{
- xmlSetProp (xnode, "margin-left", g_strdup_printf ("%f", priv->page->margin->left));
+ xnodeset = xpresult->nodesetval;
+ if (xnodeset->nodeNr > 0)
+ {
+ xnode = xnodeset->nodeTab[0];
+ }
}
+ return xnode;
+}
+
+static xmlNode
+*rpt_report_rptprint_new_page (RptReport *rpt_report, xmlDoc *xdoc)
+{
+ xmlNode *xnode;
+
+ RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
+ xnode = rpt_report_rptprint_page_new (xdoc, priv->page->size, priv->page->margin);
+
priv->cur_page++;
return xnode;
<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"/>
+ <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"/>
<report>
- <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""/>
+ <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>
+ <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>