#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:
}
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));
}
}
}
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)
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;
}
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));
+ }
}
}
}
stroke->color->b = 0.0;
stroke->color->a = 1.0;
+ stroke->style = NULL;
+
prop = xmlGetProp (xnode, "stroke-width");
if (prop != NULL)
{
stroke->color = rpt_common_parse_color (prop);
}
+ prop = xmlGetProp (xnode, "stroke-style");
+ if (prop != NULL)
+ {
+ stroke->style = rpt_common_parse_style (prop);
+ }
+
return 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));
+ }
}
}
}
/**
- * 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;
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;
+}
{
/*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
{
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
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)
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)
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)
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);
}
}