]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Changed rpt_common_convert_to_str_color()'s name in rpt_common_rptcolor_to_string().
authorAndrea Zagli <azagli@libero.it>
Sun, 22 Apr 2007 15:00:15 +0000 (15:00 +0000)
committerAndrea Zagli <azagli@libero.it>
Sun, 22 Apr 2007 15:00:15 +0000 (15:00 +0000)
Added function rpt_common_styke_to_array().
Managed attributes *-style.

git-svn-id: svn+ssh://saetta.homelinux.org/svn/libreptool/trunk@13 3191ed1d-3fce-41bb-ab4a-0cebc0943b59

13 files changed:
ChangeLog
data/reptool.dtd
data/reptool_report.dtd
docs/reference/libreptool-sections.txt
docs/reference/tmpl/libreptool-unused.sgml
docs/reference/tmpl/rptcommon.sgml
docs/reference/tmpl/rptreport.sgml
src/rptcommon.c
src/rptcommon.h
src/rptobjectrect.c
src/rptobjecttext.c
src/rptprint.c
tests/test_report_db.rpt

index 31b4c1de34142fd7b0968e8f8956f87b8900dfd3..7b21192442044483bab31fc0415e3a16fdff692a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-04-22 Andrea Zagli <azagli@inwind.it>
+
+       * src/rptcommon.h:
+       * src/rptcommon.c: changed rpt_common_convert_to_str_color()'s name in
+       rpt_common_rptcolor_to_string()
+       added function rpt_common_styke_to_array()
+       * src/rptcommon.h:
+       * src/rptcommon.c:
+       * src/rptprint.c:
+       * src/rptreport.c: managed attributes *-style
+
 2007-04-15 Andrea Zagli <azagli@inwind.it>
 
        * src/rptreport.c:
index 874ca70a3bfa93f6c15e95baa30db78f8351e60e..9039c2897048b419d9cf4a6f43150019e04a2391 100644 (file)
@@ -66,7 +66,6 @@
   padding-right      CDATA #IMPLIED
   padding-bottom     CDATA #IMPLIED
   padding-left       CDATA #IMPLIED
-  adapt              (to-text | none) #IMPLIED
 >
 
 <!ELEMENT line EMPTY>
index 13fcb6dda67889ea01494d4e8885882bdf628231..38e722c477c553ca6e1c754abcd73732d2a82467 100644 (file)
@@ -60,7 +60,6 @@
   padding-right      CDATA #IMPLIED
   padding-bottom     CDATA #IMPLIED
   padding-left       CDATA #IMPLIED
-  adapt              (to-text | none) #IMPLIED
 >
 
 <!ELEMENT line EMPTY>
index 7901e4352a59f52e6a72a1186672c58fe740d469..788a1df0cc362f1f87f891f399b07eaab4968e0d 100644 (file)
@@ -79,6 +79,7 @@ rpt_report_new_from_xml
 rpt_report_new_from_file
 rpt_report_set_database
 rpt_report_set_page_size
+rpt_report_set_page_margins
 rpt_report_set_section_height
 rpt_report_set_report_header_new_page_after
 rpt_report_set_report_footer_new_page_before
@@ -174,6 +175,7 @@ rpt_common_set_align
 rpt_common_get_stroke
 rpt_common_set_stroke
 rpt_common_parse_color
-rpt_common_convert_to_str_color
+rpt_common_rptcolor_to_string
+rpt_common_style_to_array
 </SECTION>
 
index bdcd8d0a76feda7c1143d3bf9e4c31a33254fec6..b05da5fc3c2de742fbfdf7b34dd2e0ec1f36622c 100644 (file)
 </para>
 
 
+<!-- ##### FUNCTION rpt_common_convert_to_str_color ##### -->
+<para>
+
+</para>
+
+@color: 
+@Returns: 
+
 <!-- ##### FUNCTION rpt_obj_image_get_type ##### -->
 <para>
 
index 082b54d78c3bc5f46e02d60128005142f1398d08..4b5d20bf4de5e06e003a8c3df2a20835ce2a5d2e 100644 (file)
@@ -69,6 +69,10 @@ Usefull functions and struct.
 @right_color: 
 @bottom_color: 
 @left_color: 
+@top_style: 
+@right_style: 
+@bottom_style: 
+@left_style: 
 
 <!-- ##### ENUM eRptHAlign ##### -->
 <para>
@@ -104,6 +108,7 @@ Usefull functions and struct.
 
 @width: 
 @color: 
+@style: 
 
 <!-- ##### FUNCTION rpt_common_get_position ##### -->
 <para>
@@ -222,7 +227,7 @@ Usefull functions and struct.
 @Returns: 
 
 
-<!-- ##### FUNCTION rpt_common_convert_to_str_color ##### -->
+<!-- ##### FUNCTION rpt_common_rptcolor_to_string ##### -->
 <para>
 
 </para>
@@ -231,3 +236,12 @@ Usefull functions and struct.
 @Returns: 
 
 
+<!-- ##### FUNCTION rpt_common_style_to_array ##### -->
+<para>
+
+</para>
+
+@style: 
+@Returns: 
+
+
index 94045b45bf58001459d842e74bf864bd3cc06e87..791502502dcfa154ec104429cc0cb30f98043da0 100644 (file)
@@ -91,6 +91,18 @@ Manage report definition files and produces the xml report/print's file.
 @size: 
 
 
+<!-- ##### FUNCTION rpt_report_set_page_margins ##### -->
+<para>
+
+</para>
+
+@rpt_report: 
+@top: 
+@right: 
+@bottom: 
+@left: 
+
+
 <!-- ##### FUNCTION rpt_report_set_section_height ##### -->
 <para>
 
index 48676e84fc59e34d617fc02e17949154feca94e8..ac9b378bf07994efa7498c543c1224643131af6a 100644 (file)
@@ -21,6 +21,9 @@
 
 #include "rptcommon.h"
 
+static GArray *rpt_common_parse_style (const gchar *style);
+static gchar *rpt_common_style_to_string (const GArray *style);
+
 
 /**
  * rpt_common_get_position:
@@ -233,7 +236,7 @@ rpt_common_set_font (xmlNode *xnode, const RptFont *font)
                                }
                        if (font->color != NULL)
                                {
-                                       xmlSetProp (xnode, "font-color", rpt_common_convert_to_str_color (font->color));
+                                       xmlSetProp (xnode, "font-color", rpt_common_rptcolor_to_string (font->color));
                                }
                }
 }
@@ -275,6 +278,10 @@ RptBorder
        border->left_color->g = 0.0;
        border->left_color->b = 0.0;
        border->left_color->a = 1.0;
+       border->top_style = NULL;
+       border->right_style = NULL;
+       border->bottom_style = NULL;
+       border->left_style = NULL;
 
        prop = (gchar *)xmlGetProp (xnode, "border-top-width");
        if (prop != NULL)
@@ -324,6 +331,30 @@ RptBorder
                        border->left_color = rpt_common_parse_color (prop);
                }
 
+       prop = (gchar *)xmlGetProp (xnode, "border-top-style");
+       if (prop != NULL)
+               {
+                       border->top_style = rpt_common_parse_style (prop);
+               }
+
+       prop = (gchar *)xmlGetProp (xnode, "border-right-style");
+       if (prop != NULL)
+               {
+                       border->right_style = rpt_common_parse_style (prop);
+               }
+
+       prop = (gchar *)xmlGetProp (xnode, "border-bottom-style");
+       if (prop != NULL)
+               {
+                       border->bottom_style = rpt_common_parse_style (prop);
+               }
+
+       prop = (gchar *)xmlGetProp (xnode, "border-left-style");
+       if (prop != NULL)
+               {
+                       border->left_style = rpt_common_parse_style (prop);
+               }
+
        return border;
 }
 
@@ -341,22 +372,38 @@ rpt_common_set_border (xmlNode *xnode, const RptBorder *border)
                        if (border->top_width > 0.0 && border->top_color != NULL)
                                {
                                        xmlSetProp (xnode, "border-top-width", g_strdup_printf ("%f", border->top_width));
-                                       xmlSetProp (xnode, "border-top-color", rpt_common_convert_to_str_color (border->top_color));
+                                       xmlSetProp (xnode, "border-top-color", rpt_common_rptcolor_to_string (border->top_color));
+                                       if (border->top_style != NULL)
+                                               {
+                                                       xmlSetProp (xnode, "border-top-style", rpt_common_style_to_string (border->top_style));
+                                               }
                                }
                        if (border->right_width > 0.0 && border->right_color != NULL)
                                {
                                        xmlSetProp (xnode, "border-right-width", g_strdup_printf ("%f", border->right_width));
-                                       xmlSetProp (xnode, "border-right-color", rpt_common_convert_to_str_color (border->right_color));
+                                       xmlSetProp (xnode, "border-right-color", rpt_common_rptcolor_to_string (border->right_color));
+                                       if (border->right_style != NULL)
+                                               {
+                                                       xmlSetProp (xnode, "border-right-style", rpt_common_style_to_string (border->right_style));
+                                               }
                                }
                        if (border->bottom_width > 0.0 && border->bottom_color != NULL)
                                {
                                        xmlSetProp (xnode, "border-bottom-width", g_strdup_printf ("%f", border->bottom_width));
-                                       xmlSetProp (xnode, "border-bottom-color", rpt_common_convert_to_str_color (border->bottom_color));
+                                       xmlSetProp (xnode, "border-bottom-color", rpt_common_rptcolor_to_string (border->bottom_color));
+                                       if (border->bottom_style != NULL)
+                                               {
+                                                       xmlSetProp (xnode, "border-bottom-style", rpt_common_style_to_string (border->bottom_style));
+                                               }
                                }
                        if (border->left_width > 0.0 && border->left_color != NULL)
                                {
                                        xmlSetProp (xnode, "border-left-width", g_strdup_printf ("%f", border->left_width));
-                                       xmlSetProp (xnode, "border-left-color", rpt_common_convert_to_str_color (border->left_color));
+                                       xmlSetProp (xnode, "border-left-color", rpt_common_rptcolor_to_string (border->left_color));
+                                       if (border->left_style != NULL)
+                                               {
+                                                       xmlSetProp (xnode, "border-left-style", rpt_common_style_to_string (border->left_style));
+                                               }
                                }
                }
 }
@@ -474,6 +521,8 @@ RptStroke
        stroke->color->b = 0.0;
        stroke->color->a = 1.0;
 
+       stroke->style = NULL;
+
        prop = xmlGetProp (xnode, "stroke-width");
        if (prop != NULL)
                {
@@ -486,6 +535,12 @@ RptStroke
                        stroke->color = rpt_common_parse_color (prop);
                }
 
+       prop = xmlGetProp (xnode, "stroke-style");
+       if (prop != NULL)
+               {
+                       stroke->style = rpt_common_parse_style (prop);
+               }
+
        return stroke;
 }
 
@@ -504,7 +559,11 @@ rpt_common_set_stroke (xmlNode *xnode, const RptStroke *stroke)
                                {
                                        xmlSetProp (xnode, "stroke-width", g_strdup_printf ("%f", stroke->width));
                                }
-                       xmlSetProp (xnode, "stroke-color", rpt_common_convert_to_str_color (stroke->color));
+                       xmlSetProp (xnode, "stroke-color", rpt_common_rptcolor_to_string (stroke->color));
+                       if (stroke->style != NULL)
+                               {
+                                       xmlSetProp (xnode, "stroke-style", rpt_common_style_to_string (stroke->style));
+                               }
                }
 }
 
@@ -569,13 +628,15 @@ RptColor
 }
 
 /**
- * rpt_common_convert_to_str_color:
+ * rpt_common_rptcolor_to_string:
  * @color: an #RptColor value.
  *
+ * Converts an #RptColor value to a string.
+ *
  * Returns: the color string correspondent to @color.
  */
 gchar
-*rpt_common_convert_to_str_color (const RptColor *color)
+*rpt_common_rptcolor_to_string (const RptColor *color)
 {
        gchar *ret = NULL;
 
@@ -591,3 +652,70 @@ gchar
 
        return ret;
 }
+
+static GArray
+*rpt_common_parse_style (const gchar *style)
+{
+       gint i = 0;
+       gdouble val;
+       GArray *ret = NULL;
+
+       gchar **values = g_strsplit (style, ";", 0);
+
+       if (values != NULL)
+               {
+                       ret = g_array_new (FALSE, FALSE, sizeof (gdouble));
+                       while (values[i] != NULL)
+                               {
+                                       if (strtod (values[i], NULL) > 0.0)
+                                               {
+                                                       val = strtod (values[i], NULL);
+                                                       g_array_append_val (ret, val);
+                                               }
+               
+                                       i++;
+                               }
+                       g_strfreev (values);
+               }
+
+       return ret;
+}
+
+static gchar
+*rpt_common_style_to_string (const GArray *style)
+{
+       gint i;
+       gchar *ret = NULL;
+
+       if (style != NULL)
+               {
+                       ret = g_strdup ("");
+                       for (i = 0; i < style->len; i++)
+                               {
+                                       ret = g_strconcat (ret, g_strdup_printf ("%f;", g_array_index (style, gdouble, i)), NULL);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * rpt_common_style_to_array:
+ * @style:
+ *
+ */
+gdouble
+*rpt_common_style_to_array (const GArray *style)
+{
+       gint i;
+       gdouble *ret = NULL;
+
+       ret = (gdouble *)g_malloc (style->len * sizeof (gdouble));
+
+       for (i = 0; i < style->len; i++)
+               {
+                       ret[i] = g_array_index (style, gdouble, i);
+               }
+
+       return ret;
+}
index 71ad03f074f0f30259dbcd55bc0574037d1c740b..14988156bbd15b7f5e9b5bc5dec09b4e45585595 100644 (file)
@@ -90,6 +90,10 @@ struct _RptBorder
        RptColor *right_color;
        RptColor *bottom_color;
        RptColor *left_color;
+       GArray *top_style;
+       GArray *right_style;
+       GArray *bottom_style;
+       GArray *left_style;
 };
 typedef struct _RptBorder RptBorder;
 
@@ -119,6 +123,7 @@ struct _RptStroke
 {
        gdouble width;
        RptColor *color;
+       GArray *style;
 };
 typedef struct _RptStroke RptStroke;
 
@@ -148,7 +153,9 @@ void rpt_common_set_stroke (xmlNode *xnode,
                             const RptStroke *stroke);
 
 RptColor *rpt_common_parse_color (const gchar *str_color);
-gchar *rpt_common_convert_to_str_color (const RptColor *color);
+gchar *rpt_common_rptcolor_to_string (const RptColor *color);
+
+gdouble *rpt_common_style_to_array (const GArray *style);
 
 
 G_END_DECLS
index ae4609ae5c5eeb23a0145b94d1ca7acce08a1489..e0d1a6f6f2d73c5f9482a832b8078ce247f4f70e 100644 (file)
@@ -196,7 +196,7 @@ rpt_obj_rect_get_xml (RptObject *rpt_object, xmlNode *xnode)
 
        if (priv->fill_color != NULL)
                {
-                       xmlSetProp (xnode, "fill-color", rpt_common_convert_to_str_color (priv->fill_color));
+                       xmlSetProp (xnode, "fill-color", rpt_common_rptcolor_to_string (priv->fill_color));
                }
 }
 
index a8abc7bc78e8e7b788e24a6725884b56a4ef9c42..f2f44d036b5822e7c2393c7435e276924e1c28ad 100644 (file)
@@ -298,7 +298,7 @@ rpt_obj_text_get_xml (RptObject *rpt_objtext, xmlNode *xnode)
 
        if (priv->background_color != NULL)
                {
-                       xmlSetProp (xnode, "background-color", rpt_common_convert_to_str_color (priv->background_color));
+                       xmlSetProp (xnode, "background-color", rpt_common_rptcolor_to_string (priv->background_color));
                }
 
        if (priv->padding_top != 0.0)
index 696ebe05825544b0d9af125fad30b5d3a26c8009..c5e19bdae31859f1dff7e1eca92491f92100b081 100644 (file)
@@ -800,6 +800,11 @@ rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_
                {
                        /*cairo_set_line_width (priv->cr, stroke.width);*/
                        cairo_set_source_rgba (priv->cr, stroke->color->r, stroke->color->g, stroke->color->b, stroke->color->a);
+                       if (stroke->style != NULL)
+                               {
+                                       gdouble *dash = rpt_common_style_to_array (stroke->style);
+                                       cairo_set_dash (priv->cr, dash, stroke->style->len, 0.0);
+                               }
                }
        else
                {
@@ -808,6 +813,11 @@ rpt_print_line (RptPrint *rpt_print, const RptPoint *from_p, const RptPoint *to_
        cairo_move_to (priv->cr, from_p->x, from_p->y);
        cairo_line_to (priv->cr, to_p->x, to_p->y);
        cairo_stroke (priv->cr);
+
+       if (stroke != NULL && stroke->style != NULL)
+               {
+                       cairo_set_dash (priv->cr, NULL, 0, 0.0);
+               }
 }
 
 static void
@@ -829,6 +839,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        to_p->y = position->y;
                        stroke->width = border->top_width;
                        stroke->color = border->top_color;
+                       stroke->style = border->top_style;
                        rpt_print_line (rpt_print, from_p, to_p, stroke);
                }
        if (border->right_width != 0.0)
@@ -839,6 +850,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        to_p->y = position->y + size->height;
                        stroke->width = border->right_width;
                        stroke->color = border->right_color;
+                       stroke->style = border->right_style;
                        rpt_print_line (rpt_print, from_p, to_p, stroke);
                }
        if (border->bottom_width != 0.0)
@@ -849,6 +861,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        to_p->y = position->y + size->height;
                        stroke->width = border->bottom_width;
                        stroke->color = border->bottom_color;
+                       stroke->style = border->bottom_style;
                        rpt_print_line (rpt_print, from_p, to_p, stroke);
                }
        if (border->left_width != 0.0)
@@ -859,6 +872,7 @@ rpt_print_border (RptPrint *rpt_print, const RptPoint *position, const RptSize *
                        to_p->y = position->y + size->height;
                        stroke->width = border->left_width;
                        stroke->color = border->left_color;
+                       stroke->style = border->left_style;
                        rpt_print_line (rpt_print, from_p, to_p, stroke);
                }
 }
index 40b759424b3f894f2983b2a3f79762ec7582a1f8..bef2885aaccc2a69c9ce3f183edc61f18e733d7f 100644 (file)
                        <text name="txt_name" x="200" y="50" width="100" height="50" source="[name]" />
                        <text name="txt_req" x="50" y="100" width="100" height="50" source="[nonexistent]" />
                        <rect name="rect1" x="400" y="10" width="20" height="20" fill-color="#00FF00" />
-                       <image name="img1" x="450" y="10" width="60" height="60" source="tests/gnome-globe.png" />
+                       <image name="img1" x="450" y="10" width="60" height="60" border-bottom-width="1.0" border-bottom-color="#FF0000" border-bottom-style="10;10" source="tests/gnome-globe.png" />
                </body>
                <report-footer height="50">
-                       <line name="line3" x="10" y="10" width="500" height="0" stroke-color="#FFFF00" />
+                       <line name="line3" x="10" y="10" width="500" height="0" stroke-color="#FFFF00" stroke-style="50;10" />
                        <text name="txt_report_footer" x="10" y="20" width="500" height="30" horizontal-align="center" source="&quot;the report's footer&quot;" />
-                       <line name="line4" x="10" y="50" width="500" height="0" stroke-color="#FFFF00" />
+                       <line name="line4" x="10" y="50" width="500" height="0" stroke-color="#FFFF00" stroke-style="1;5" />
                </report-footer>
                <page-footer height="80" first-page="y" last-page="y">
                        <line name="line2" x="10" y="10" width="500" height="0" />