]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Line with odd stroke width is thinner.
authorAndrea Zagli <azagli@libero.it>
Sun, 25 Sep 2011 09:17:28 +0000 (11:17 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 25 Sep 2011 09:17:28 +0000 (11:17 +0200)
fixes #78

src/rptprint.c
tests/test_report.rpt
tests/test_report_db.rpt
tests/test_rptreport_liststore.c

index 4c74c4cd4c034822b34679dcdc4f17f0fba0b863..6e39f8f3f4ad4475d2d6a3c2adecdb73e1c38adf 100644 (file)
@@ -224,7 +224,7 @@ RptPrint
                                }
                        else
                                {
-                                       /* TO DO */
+                                       /* TODO */
                                        g_warning ("Not a valid RepTool print report format.");
                                }
                }
@@ -339,7 +339,7 @@ rpt_print_print (RptPrint *rpt_print, GtkWindow *transient)
        xmlNode *cur = xmlDocGetRootElement (priv->xdoc);
        if (cur == NULL)
                {
-                       /* TO DO */
+                       /* TODO */
                        g_warning ("Xml isn't a valid reptool print definition.");
                        return;
                }
@@ -347,7 +347,7 @@ rpt_print_print (RptPrint *rpt_print, GtkWindow *transient)
                {
                        if (xmlStrcmp (cur->name, (const xmlChar *)"reptool_report") != 0)
                                {
-                                       /* TO DO */
+                                       /* TODO */
                                        g_warning ("Xml isn't a valid reptool print definition.");
                                        return;
                                }
@@ -398,7 +398,7 @@ rpt_print_print (RptPrint *rpt_print, GtkWindow *transient)
                }
        else
                {
-                       /* TO DO */
+                       /* TODO */
                        g_warning ("No pages found in xml.");
                        return;
                }
@@ -466,7 +466,7 @@ rpt_print_print (RptPrint *rpt_print, GtkWindow *transient)
                                        fout = fopen (priv->output_filename, "w");
                                        if (fout == NULL)
                                                {
-                                                       /* TO DO */
+                                                       /* TODO */
                                                        g_warning ("Unable to write to the output file.");
                                                        return;
                                                }
@@ -501,7 +501,7 @@ rpt_print_print (RptPrint *rpt_print, GtkWindow *transient)
                                                                                        fout = fopen (new_out_filename, "w");
                                                                                        if (fout == NULL)
                                                                                                {
-                                                                                                       /* TO DO */
+                                                                                                       /* TODO */
                                                                                                        g_warning ("Unable to write to the output file.");
                                                                                                        return;
                                                                                                }
@@ -552,25 +552,25 @@ rpt_print_print (RptPrint *rpt_print, GtkWindow *transient)
                                                                                                }
                                                                                        else
                                                                                                {
-                                                                                                       /* TO DO */
+                                                                                                       /* TODO */
                                                                                                        g_warning ("Cairo status not sucess: %d", cairo_status (priv->cr));
                                                                                                }
                                                                                }
                                                                        else
                                                                                {
-                                                                                       /* TO DO */
+                                                                                       /* TODO */
                                                                                        g_warning ("Cairo surface status not sucess.");
                                                                                }
                                                                }
                                                        else
                                                                {
-                                                                       /* TO DO */
+                                                                       /* TODO */
                                                                        g_warning ("Page width or height cannot be zero.");
                                                                }
                                                }
                                        else
                                                {
-                                                       /* TO DO */
+                                                       /* TODO */
                                                }
 
                                        cur = cur->next;
@@ -939,7 +939,7 @@ rpt_print_text_xml (RptPrint *rpt_print, xmlNode *xnode)
                                break;
                }
 
-       /* TO DO */
+       /* TODO */
        /* setting vertical alignment */
        switch (align->v_align)
                {
@@ -1069,7 +1069,7 @@ rpt_print_rect_xml (RptPrint *rpt_print, xmlNode *xnode)
                        rpt_print_rotate (rpt_print, position, size, rotation->angle);
                }
 
-       /* TO DO */
+       /* TODO */
        /*cairo_set_line_width (priv->cr, stroke.width);*/
        cairo_rectangle (priv->cr,
                         rpt_common_value_to_points (priv->unit, position->x),
@@ -1113,7 +1113,7 @@ rpt_print_ellipse_xml (RptPrint *rpt_print, xmlNode *xnode)
        size = rpt_common_get_size (xnode);
        stroke = rpt_common_get_stroke (xnode);
 
-       /* TO DO */
+       /* TODO */
        /* rotation */
 
        if (position == NULL || size == NULL)
@@ -1262,16 +1262,23 @@ rpt_print_line (RptPrint *rpt_print,
 {
        RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
 
+       gdouble to_add;
+
        if (from_p == NULL || to_p == NULL)
                {
                        g_warning ("Line node from point and to point are mandatories.");
                        return;
                }
 
+       to_add = 0;
        if (stroke != NULL)
                {
-                       /* TO DO */
-                       /*cairo_set_line_width (priv->cr, stroke.width);*/
+                       cairo_set_line_width (priv->cr, stroke->width);
+                       if ((gint)stroke->width % 2 != 0)
+                               {
+                                       to_add = 0.5;
+                               }
+
                        if (stroke->color != NULL)
                                {
                                        cairo_set_source_rgba (priv->cr, stroke->color->r, stroke->color->g, stroke->color->b, stroke->color->a);
@@ -1305,10 +1312,10 @@ rpt_print_line (RptPrint *rpt_print,
 
        cairo_move_to (priv->cr,
                       rpt_common_value_to_points (priv->unit, from_p->x),
-                      rpt_common_value_to_points (priv->unit, from_p->y));
+                      rpt_common_value_to_points (priv->unit, from_p->y) + to_add);
        cairo_line_to (priv->cr,
                       rpt_common_value_to_points (priv->unit, to_p->x),
-                      rpt_common_value_to_points (priv->unit, to_p->y));
+                      rpt_common_value_to_points (priv->unit, to_p->y) + to_add);
        cairo_stroke (priv->cr);
 
        if (stroke != NULL && stroke->style != NULL)
index 4574a6d2732b29581ed9216a8624636a7c60eedd..b539beb6acc1776144e510ce8c25944288f61515 100644 (file)
@@ -2,14 +2,14 @@
 <reptool>
   <properties>
     <unit-length>pt</unit-length>
-    <output-type>pdf</output-type>
-    <output-filename>rptreport.pdf</output-filename>
+    <output-type>png</output-type>
+    <output-filename>test.png</output-filename>
     <copies>1</copies>
   </properties>
   <database>
-    <provider>SQLite</provider>
-    <connection-string>DB_DIR=.;DB_NAME=db_test.db</connection-string>
-    <sql>SELECT * FROM articles ORDER BY name</sql>
+    <provider/>
+    <connection-string/>
+    <sql/>
   </database>
   <page width="595.000000" height="842.000000"/>
   <report>
index 343ae30b32d5451028840f81716af40948280aa2..05d960ba0ad7d888678ef979ca8b5cddaa384fb3 100644 (file)
@@ -15,7 +15,7 @@
                </report-header>
                <page-header height="80" first-page="y">
                        <text name="title" x="10" y="10" width="300" height="50" font-name="Courier New" font-size="10" font-bold="y" source="&quot;the page's title&quot; &amp; &quot; - &quot; &amp; @Page" />
-                       <line name="line1" x="10" y="65" width="500" height="0" />
+                       <line name="line1" x="10" y="65" width="500" height="0" stroke-width="1.0" />
                </page-header>
                <body height="200">
                        <text name="txt_id" x="50" y="50" width="100" height="50" border-top-width="1.0" border-top-color="#FF0000" source="[id]" />
index cc9e22c22b29b4005fe21b4499c953e76b781fa9..27458dcbd497ba9254d8948f4b3417acd9414034 100644 (file)
@@ -100,6 +100,9 @@ main (int argc, char **argv)
 
        if (rptr != NULL)
                {
+                       rpt_report_set_output_type (rptr, RPT_OUTPUT_PNG);
+                       rpt_report_set_output_filename (rptr, "test.png");
+
                        xmlDoc *report = rpt_report_get_xml (rptr);
                        xmlSaveFormatFile ("test_report.rpt", report, 2);
 
@@ -111,8 +114,6 @@ main (int argc, char **argv)
                                {
                                        g_object_set (G_OBJECT (rptp), "path-relatives-to", "..", NULL);
 
-                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PDF);
-                                       rpt_print_set_output_filename (rptp, "test.pdf");
                                        rpt_print_print (rptp, NULL);
                                }
                }