# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([libreptool], [0.0.1], [azagli@inwind.it])
+AC_INIT([libreptool], [0.0.2], [azagli@inwind.it])
AC_CONFIG_SRCDIR([src/rptprint.c])
AC_CONFIG_HEADER([config.h])
>
<!ENTITY % object_position_attrs
- "x CDATA #REQUIRED
- y CDATA #REQUIRED"
+ "x CDATA #REQUIRED
+ y CDATA #REQUIRED"
>
<!ENTITY % object_size_attrs
- "width CDATA #REQUIRED
- height CDATA #REQUIRED"
+ "width CDATA #REQUIRED
+ height CDATA #REQUIRED"
>
<!ENTITY % object_border_attrs
>
<!ENTITY % object_text_align_attrs
- "horizontal-align (left | center | right | justified) #IMPLIED
- vertical-align (top | center | bottom) #IMPLIED"
+ "horizontal-align (left | center | right | justified) #IMPLIED
+ vertical-align (top | center | bottom) #IMPLIED"
>
<!ELEMENT text (#PCDATA)>
#include "rptcommon.h"
+static gchar *convert_to_str_color (RptColor color);
+
/**
* rpt_common_get_position:
* @xnode:
size->height = strtod (prop, NULL);
}
}
+
+/**
+ * rpt_common_get_font:
+ * @xnode:
+ * @font:
+ *
+ */
+void
+rpt_common_get_font (xmlNode *xnode, RptFont *font)
+{
+ gchar *prop;
+
+ font->name = g_strdup ("sans");
+ font->size = 12.0;
+ font->bold = FALSE;
+ font->italic = FALSE;
+ font->underline = FALSE;
+ font->strike = FALSE;
+ font->color.r = 0.0;
+ font->color.g = 0.0;
+ font->color.b = 0.0;
+ font->color.a = 1.0;
+
+ prop = xmlGetProp (xnode, "font-name");
+ if (prop != NULL)
+ {
+ font->name = g_strdup (prop);
+ }
+
+ prop = xmlGetProp (xnode, "font-size");
+ if (prop != NULL)
+ {
+ font->size = strtod (prop, NULL);
+ }
+
+ prop = xmlGetProp (xnode, "font-bold");
+ if (prop != NULL)
+ {
+ font->bold = (strcmp (g_strstrip (prop), "y") == 0);
+ }
+
+ prop = xmlGetProp (xnode, "font-italic");
+ if (prop != NULL)
+ {
+ font->italic = (strcmp (g_strstrip (prop), "y") == 0);
+ }
+
+ prop = xmlGetProp (xnode, "font-underline");
+ if (prop != NULL)
+ {
+ font->underline = (strcmp (g_strstrip (prop), "y") == 0);
+ }
+
+ prop = xmlGetProp (xnode, "font-strike");
+ if (prop != NULL)
+ {
+ font->strike = (strcmp (g_strstrip (prop), "y") == 0);
+ }
+
+ prop = xmlGetProp (xnode, "font-color");
+ if (prop != NULL)
+ {
+ rpt_common_parse_color (prop, &font->color);
+ }
+}
+
+/**
+ * rpt_common_set_font:
+ * @xnode:
+ * @font:
+ *
+ */
+void
+rpt_common_set_font (xmlNode *xnode, RptFont font)
+{
+ xmlSetProp (xnode, "font-name", font.name);
+ xmlSetProp (xnode, "font-size", g_strdup_printf ("%f", font.size));
+ if (font.bold)
+ {
+ xmlSetProp (xnode, "font-bold", "y");
+ }
+ if (font.italic)
+ {
+ xmlSetProp (xnode, "font-italic", "y");
+ }
+ if (font.underline)
+ {
+ xmlSetProp (xnode, "font-underline", "y");
+ }
+ if (font.strike)
+ {
+ xmlSetProp (xnode, "font-strike", "y");
+ }
+ xmlSetProp (xnode, "font-color", convert_to_str_color (font.color));
+}
+
+/**
+ * rpt_common_get_border:
+ * @xnode:
+ * @border:
+ *
+ */
+void
+rpt_common_get_border (xmlNode *xnode, RptBorder *border)
+{
+ gchar *prop;
+
+ border->top_width = 0.0;
+ border->right_width = 0.0;
+ border->bottom_width = 0.0;
+ border->left_width = 0.0;
+ border->top_color.r = 0.0;
+ border->top_color.g = 0.0;
+ border->top_color.b = 0.0;
+ border->top_color.a = 1.0;
+ border->right_color.r = 0.0;
+ border->right_color.g = 0.0;
+ border->right_color.b = 0.0;
+ border->right_color.a = 1.0;
+ border->bottom_color.r = 0.0;
+ border->bottom_color.g = 0.0;
+ border->bottom_color.b = 0.0;
+ border->bottom_color.a = 1.0;
+ border->left_color.r = 0.0;
+ border->left_color.g = 0.0;
+ border->left_color.b = 0.0;
+ border->left_color.a = 1.0;
+
+ prop = xmlGetProp (xnode, "border-top-width");
+ if (prop != NULL)
+ {
+ border->top_width = strtod (prop, NULL);
+ }
+
+ prop = xmlGetProp (xnode, "border-right-width");
+ if (prop != NULL)
+ {
+ border->right_width = strtod (prop, NULL);
+ }
+
+ prop = xmlGetProp (xnode, "border-bottom-width");
+ if (prop != NULL)
+ {
+ border->bottom_width = strtod (prop, NULL);
+ }
+
+ prop = xmlGetProp (xnode, "border-left-width");
+ if (prop != NULL)
+ {
+ border->left_width = strtod (prop, NULL);
+ }
+
+ prop = xmlGetProp (xnode, "border-top-color");
+ if (prop != NULL)
+ {
+ rpt_common_parse_color (prop, &border->top_color);
+ }
+
+ prop = xmlGetProp (xnode, "border-right-color");
+ if (prop != NULL)
+ {
+ rpt_common_parse_color (prop, &border->right_color);
+ }
+
+ prop = xmlGetProp (xnode, "border-bottom-color");
+ if (prop != NULL)
+ {
+ rpt_common_parse_color (prop, &border->bottom_color);
+ }
+
+ prop = xmlGetProp (xnode, "border-left-color");
+ if (prop != NULL)
+ {
+ rpt_common_parse_color (prop, &border->left_color);
+ }
+}
+
+/**
+ * rpt_common_set_border:
+ * @xnode:
+ * @border:
+ *
+ */
+void
+rpt_common_set_border (xmlNode *xnode, RptBorder border)
+{
+ if (border.top_width > 0.0)
+ {
+ xmlSetProp (xnode, "border-top-width", g_strdup_printf ("%f", border.top_width));
+ xmlSetProp (xnode, "border-top-color", convert_to_str_color (border.top_color));
+ }
+ if (border.right_width > 0.0)
+ {
+ xmlSetProp (xnode, "border-right-width", g_strdup_printf ("%f", border.right_width));
+ xmlSetProp (xnode, "border-right-color", convert_to_str_color (border.right_color));
+ }
+ if (border.bottom_width > 0.0)
+ {
+ xmlSetProp (xnode, "border-bottom-width", g_strdup_printf ("%f", border.bottom_width));
+ xmlSetProp (xnode, "border-bottom-color", convert_to_str_color (border.bottom_color));
+ }
+ if (border.left_width > 0.0)
+ {
+ xmlSetProp (xnode, "border-left-width", g_strdup_printf ("%f", border.left_width));
+ xmlSetProp (xnode, "border-left-color", convert_to_str_color (border.left_color));
+ }
+}
+
+/**
+ * rpt_common_get_align:
+ * @xnode:
+ * @align:
+ *
+ */
+void
+rpt_common_get_align (xmlNode *xnode, RptAlign *align)
+{
+ gchar *prop;
+
+ align->h_align = RPT_HALIGN_LEFT;
+ align->v_align = RPT_VALIGN_TOP;
+
+ prop = xmlGetProp (xnode, "horizontal-align");
+ if (prop != NULL)
+ {
+ if (strcmp (prop, "center") == 0)
+ {
+ align->h_align = RPT_HALIGN_CENTER;
+ }
+ else if (strcmp (prop, "right") == 0)
+ {
+ align->h_align = RPT_HALIGN_RIGHT;
+ }
+ else if (strcmp (prop, "justified") == 0)
+ {
+ align->h_align = RPT_HALIGN_JUSTIFIED;
+ }
+ }
+
+ prop = xmlGetProp (xnode, "vertical-align");
+ if (prop != NULL)
+ {
+ if (strcmp (prop, "center") == 0)
+ {
+ align->v_align = RPT_VALIGN_CENTER;
+ }
+ else if (strcmp (prop, "bottom") == 0)
+ {
+ align->v_align = RPT_VALIGN_BOTTOM;
+ }
+ }
+}
+
+/**
+ * rpt_common_set_align:
+ * @xnode:
+ * @align:
+ *
+ */
+void
+rpt_common_set_align (xmlNode *xnode, RptAlign align)
+{
+ if (align.h_align != RPT_HALIGN_LEFT)
+ {
+ switch (align.h_align)
+ {
+ case RPT_HALIGN_CENTER:
+ xmlSetProp (xnode, "horizontal-align", "center");
+ break;
+
+ case RPT_HALIGN_RIGHT:
+ xmlSetProp (xnode, "horizontal-align", "right");
+ break;
+
+ case RPT_HALIGN_JUSTIFIED:
+ xmlSetProp (xnode, "horizontal-align", "justified");
+ break;
+ }
+ }
+ if (align.v_align != RPT_VALIGN_TOP)
+ {
+ switch (align.v_align)
+ {
+ case RPT_VALIGN_CENTER:
+ xmlSetProp (xnode, "vertical-align", "center");
+ break;
+
+ case RPT_VALIGN_BOTTOM:
+ xmlSetProp (xnode, "vertical-align", "bottom");
+ break;
+ }
+ }
+}
+
+/**
+ * rpt_common_get_stroke:
+ * @xnode:
+ * @stroke:
+ *
+ */
+void
+rpt_common_get_stroke (xmlNode *xnode, RptStroke *stroke)
+{
+ gchar *prop;
+
+ stroke->width = 1.0;
+ stroke->color.r = 0.0;
+ stroke->color.g = 0.0;
+ stroke->color.b = 0.0;
+ stroke->color.a = 1.0;
+
+ prop = xmlGetProp (xnode, "stroke-width");
+ if (prop != NULL)
+ {
+ stroke->width = strtod (prop, NULL);
+ }
+
+ prop = xmlGetProp (xnode, "stroke-color");
+ if (prop != NULL)
+ {
+ rpt_common_parse_color (prop, &stroke->color);
+ }
+}
+
+/**
+ * rpt_common_parse_color:
+ * @str_color:
+ * @color:
+ *
+ */
+void
+rpt_common_parse_color (const gchar *str_color, RptColor *color)
+{
+ gchar *c = g_strstrip (g_strdup (str_color));
+
+ if (c[0] == '#')
+ {
+ if (strlen (c) == 4 || strlen (c) == 5)
+ {
+ if (isxdigit (c[1]))
+ {
+ color->r = strtol (g_strdup_printf ("%c%c", c[1], c[1]), NULL, 16) / 255.0;
+ }
+ if (isxdigit (c[2]))
+ {
+ color->g = strtol (g_strdup_printf ("%c%c", c[2], c[2]), NULL, 16) / 255.0;
+ }
+ if (isxdigit (c[3]))
+ {
+ color->b = strtol (g_strdup_printf ("%c%c", c[3], c[3]), NULL, 16) / 255.0;
+ }
+ if (strlen (c) == 5 && isxdigit (c[4]))
+ {
+ color->a = strtol (g_strdup_printf ("%c%c", c[4], c[4]), NULL, 16) / 255.0;
+ }
+ }
+ else if (strlen (c) == 7 || strlen (c) == 9)
+ {
+ if (isxdigit (c[1]) && isxdigit (c[2]))
+ {
+ color->r = strtol (g_strndup (&c[1], 2), NULL, 16) / 255.0;
+ }
+ if (isxdigit (c[3]) && isxdigit (c[4]))
+ {
+ color->g = strtol (g_strndup (&c[3], 2), NULL, 16) / 255.0;
+ }
+ if (isxdigit (c[5]) && isxdigit (c[6]))
+ {
+ color->b = strtol (g_strndup (&c[5], 2), NULL, 16) / 255.0;
+ }
+ if (strlen (c) == 9)
+ {
+ color->a = strtol (g_strndup (&c[7], 2), NULL, 16) / 255.0;
+ }
+ }
+ }
+}
+
+static gchar *
+convert_to_str_color (RptColor color)
+{
+ gchar *ret = "#";
+
+ ret = g_strconcat (ret, g_strdup_printf ("%.2X", (gint)color.r * 255), NULL);
+ ret = g_strconcat (ret, g_strdup_printf ("%.2X", (gint)color.g * 255), NULL);
+ ret = g_strconcat (ret, g_strdup_printf ("%.2X", (gint)color.b * 255), NULL);
+ ret = g_strconcat (ret, g_strdup_printf ("%.2X", (gint)color.a * 255), NULL);
+
+ return ret;
+}
G_BEGIN_DECLS
+typedef struct
+{
+ gdouble r;
+ gdouble g;
+ gdouble b;
+ gdouble a;
+} RptColor;
+
typedef struct
{
gdouble x;
gdouble height;
} RptSize;
+typedef struct
+{
+ gchar *name;
+ gdouble size;
+ gboolean bold;
+ gboolean italic;
+ gboolean underline;
+ gboolean strike;
+ RptColor color;
+} RptFont;
+
+typedef struct
+{
+ gdouble top_width;
+ gdouble right_width;
+ gdouble bottom_width;
+ gdouble left_width;
+ RptColor top_color;
+ RptColor right_color;
+ RptColor bottom_color;
+ RptColor left_color;
+} RptBorder;
+
+typedef enum
+{
+ RPT_HALIGN_LEFT,
+ RPT_HALIGN_CENTER,
+ RPT_HALIGN_RIGHT,
+ RPT_HALIGN_JUSTIFIED
+} eRptHAlign;
+
+typedef enum
+{
+ RPT_VALIGN_TOP,
+ RPT_VALIGN_CENTER,
+ RPT_VALIGN_BOTTOM
+} eRptVAlign;
+
+typedef struct
+{
+ eRptHAlign h_align;
+ eRptVAlign v_align;
+} RptAlign;
+
+typedef struct
+{
+ gdouble width;
+ RptColor color;
+} RptStroke;
+
void rpt_common_get_position (xmlNode *xnode,
RptPoint *position);
void rpt_common_get_size (xmlNode *xnode,
RptSize *size);
+void rpt_common_get_font (xmlNode *xnode,
+ RptFont *font);
+void rpt_common_set_font (xmlNode *xnode,
+ RptFont font);
+void rpt_common_get_border (xmlNode *xnode,
+ RptBorder *border);
+void rpt_common_set_border (xmlNode *xnode,
+ RptBorder border);
+void rpt_common_get_align (xmlNode *xnode,
+ RptAlign *align);
+void rpt_common_set_align (xmlNode *xnode,
+ RptAlign align);
+void rpt_common_get_stroke (xmlNode *xnode,
+ RptStroke *stroke);
+void rpt_common_parse_color (const gchar *str_color,
+ RptColor *color);
G_END_DECLS
{
PROP_0,
PROP_SIZE,
+ PROP_BORDER,
+ PROP_FONT,
+ PROP_ALIGN,
PROP_SOURCE
};
static void rpt_obj_text_init (RptObjText *rpt_obj_text);
static void rpt_obj_text_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void rpt_obj_text_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
#define RPT_OBJ_TEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_RPT_OBJ_TEXT, RptObjTextPrivate))
struct _RptObjTextPrivate
{
RptSize *size;
-
+ RptBorder *border;
+ RptFont *font;
+ RptAlign *align;
gchar *source;
};
"Size",
"The object's size.",
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_BORDER,
+ g_param_spec_pointer ("border",
+ "Border",
+ "The object's border.",
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_FONT,
+ g_param_spec_pointer ("font",
+ "Font",
+ "The object's font.",
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_ALIGN,
+ g_param_spec_pointer ("align",
+ "Align",
+ "The text's align.",
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SOURCE,
g_param_spec_string ("source",
"Source",
priv->size = (RptSize *)g_malloc0 (sizeof (RptSize));
priv->size->width = 0.0;
priv->size->height = 0.0;
+
+ priv->border = (RptBorder *)g_malloc0 (sizeof (RptBorder));
+ priv->font = (RptFont *)g_malloc0 (sizeof (RptFont));
+ priv->align = (RptAlign *)g_malloc0 (sizeof (RptAlign));
}
/**
priv = RPT_OBJ_TEXT_GET_PRIVATE (rpt_obj_text);
rpt_common_get_size (xnode, priv->size);
+ rpt_common_get_border (xnode, priv->border);
+ rpt_common_get_font (xnode, priv->font);
g_object_set (rpt_obj_text, "source", xmlGetProp (xnode, "source"), NULL);
}
xmlSetProp (xnode, "width", g_strdup_printf ("%f", priv->size->width));
xmlSetProp (xnode, "height", g_strdup_printf ("%f", priv->size->height));
+
+ rpt_common_set_border (xnode, (RptBorder)*priv->border);
+ rpt_common_set_font (xnode, (RptFont)*priv->font);
+ rpt_common_set_align (xnode, (RptAlign)*priv->font);
}
static void
priv->size = g_memdup (g_value_get_pointer (value), sizeof (RptSize));
break;
+ case PROP_BORDER:
+ priv->border = g_memdup (g_value_get_pointer (value), sizeof (RptBorder));
+ break;
+
+ case PROP_FONT:
+ priv->font = g_memdup (g_value_get_pointer (value), sizeof (RptFont));
+ break;
+
+ case PROP_ALIGN:
+ priv->align = g_memdup (g_value_get_pointer (value), sizeof (RptAlign));
+ break;
+
case PROP_SOURCE:
priv->source = g_strstrip (g_strdup (g_value_get_string (value)));
break;
g_value_set_pointer (value, g_memdup (priv->size, sizeof (RptSize)));
break;
+ case PROP_BORDER:
+ g_value_set_pointer (value, g_memdup (priv->border, sizeof (RptBorder)));
+ break;
+
+ case PROP_FONT:
+ g_value_set_pointer (value, g_memdup (priv->font, sizeof (RptFont)));
+ break;
+
+ case PROP_ALIGN:
+ g_value_set_pointer (value, g_memdup (priv->align, sizeof (RptAlign)));
+ break;
+
case PROP_SOURCE:
g_value_set_string (value, priv->source);
break;
#include <string.h>
#include <cairo.h>
+#include <cairo-pdf.h>
+#include <cairo-ps.h>
+#include <cairo-svg.h>
#include <pango/pangocairo.h>
#include "rptprint.h"
#include "rptcommon.h"
-typedef enum
-{
- RPT_HALIGN_LEFT,
- RPT_HALIGN_CENTER,
- RPT_HALIGN_RIGHT,
- RPT_HALIGN_JUSTIFIED
-} eRptHAlign;
-
-typedef enum
-{
- RPT_VALIGN_TOP,
- RPT_VALIGN_CENTER,
- RPT_VALIGN_BOTTOM
-} eRptVAlign;
-
-typedef struct
-{
- eRptHAlign h_align;
- eRptVAlign v_align;
-} RptAlign;
-
-typedef struct
-{
- gdouble r;
- gdouble g;
- gdouble b;
- gdouble a;
-} RptColor;
-
-typedef struct
-{
- gdouble top_width;
- gdouble right_width;
- gdouble bottom_width;
- gdouble left_width;
- RptColor top_color;
- RptColor right_color;
- RptColor bottom_color;
- RptColor left_color;
-} RptBorder;
-
-typedef struct
-{
- gchar *name;
- gdouble size;
- gboolean bold;
- gboolean italic;
- gboolean underline;
- gboolean strike;
- RptColor color;
-} RptFont;
-
-typedef struct
-{
- gdouble width;
- RptColor color;
-} RptStroke;
-
enum
{
PROP_0
RptPoint position,
RptSize size,
RptBorder border);
-static void rpt_print_get_align (xmlNode *xnode,
- RptAlign *align);
-static void rpt_print_get_border (xmlNode *xnode,
- RptBorder *border);
-static void rpt_print_get_stroke (xmlNode *xnode,
- RptStroke *stroke);
-static void rpt_print_get_font (xmlNode *xnode,
- RptFont *font);
-static void rpt_print_parse_color (const gchar *str_color,
- RptColor *color);
#define RPT_PRINT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_RPT_PRINT, RptPrintPrivate))
rpt_common_get_position (xnode, &position);
rpt_common_get_size (xnode, &size);
- rpt_print_get_align (xnode, &align);
- rpt_print_get_border (xnode, &border);
- rpt_print_get_font (xnode, &font);
+ rpt_common_get_align (xnode, &align);
+ rpt_common_get_border (xnode, &border);
+ rpt_common_get_font (xnode, &font);
/* padding */
prop = xmlGetProp (xnode, (const xmlChar *)"padding-top");
prop = xmlGetProp (xnode, (const xmlChar *)"background-color");
if (prop != NULL)
{
- rpt_print_parse_color (prop, &color);
+ rpt_common_parse_color (prop, &color);
}
/* drawing border */
rpt_common_get_position (xnode, &position);
rpt_common_get_size (xnode, &size);
- rpt_print_get_stroke (xnode, &stroke);
+ rpt_common_get_stroke (xnode, &stroke);
from_p.x = position.x;
from_p.y = position.y;
rpt_common_get_position (xnode, &position);
rpt_common_get_size (xnode, &size);
- rpt_print_get_stroke (xnode, &stroke);
+ rpt_common_get_stroke (xnode, &stroke);
gchar *prop = xmlGetProp (xnode, (const xmlChar *)"fill-color");
if (prop != NULL)
fill_color.g = 0.0;
fill_color.b = 0.0;
fill_color.a = 1.0;
- rpt_print_parse_color (prop, &fill_color);
+ rpt_common_parse_color (prop, &fill_color);
}
/*cairo_set_line_width (priv->cr, stroke.width);*/
rpt_common_get_position (xnode, &position);
rpt_common_get_size (xnode, &size);
- rpt_print_get_border (xnode, &border);
+ rpt_common_get_border (xnode, &border);
image = cairo_image_surface_create_from_png (filename);
rpt_print_line (rpt_print, from_p, to_p, stroke);
}
}
-
-static void
-rpt_print_get_align (xmlNode *xnode, RptAlign *align)
-{
- gchar *prop;
-
- align->h_align = RPT_HALIGN_LEFT;
- align->v_align = RPT_VALIGN_TOP;
-
- prop = xmlGetProp (xnode, "horizontal-align");
- if (prop != NULL)
- {
- if (strcmp (prop, "center") == 0)
- {
- align->h_align = RPT_HALIGN_CENTER;
- }
- else if (strcmp (prop, "right") == 0)
- {
- align->h_align = RPT_HALIGN_RIGHT;
- }
- else if (strcmp (prop, "justified") == 0)
- {
- align->h_align = RPT_HALIGN_JUSTIFIED;
- }
- }
-
- prop = xmlGetProp (xnode, "vertical-align");
- if (prop != NULL)
- {
- if (strcmp (prop, "center") == 0)
- {
- align->v_align = RPT_VALIGN_CENTER;
- }
- else if (strcmp (prop, "bottom") == 0)
- {
- align->v_align = RPT_VALIGN_BOTTOM;
- }
- }
-}
-
-static void
-rpt_print_get_border (xmlNode *xnode, RptBorder *border)
-{
- gchar *prop;
-
- border->top_width = 0.0;
- border->right_width = 0.0;
- border->bottom_width = 0.0;
- border->left_width = 0.0;
- border->top_color.r = 0.0;
- border->top_color.g = 0.0;
- border->top_color.b = 0.0;
- border->top_color.a = 1.0;
- border->right_color.r = 0.0;
- border->right_color.g = 0.0;
- border->right_color.b = 0.0;
- border->right_color.a = 1.0;
- border->bottom_color.r = 0.0;
- border->bottom_color.g = 0.0;
- border->bottom_color.b = 0.0;
- border->bottom_color.a = 1.0;
- border->left_color.r = 0.0;
- border->left_color.g = 0.0;
- border->left_color.b = 0.0;
- border->left_color.a = 1.0;
-
- prop = xmlGetProp (xnode, "border-top-width");
- if (prop != NULL)
- {
- border->top_width = strtod (prop, NULL);
- }
-
- prop = xmlGetProp (xnode, "border-right-width");
- if (prop != NULL)
- {
- border->right_width = strtod (prop, NULL);
- }
-
- prop = xmlGetProp (xnode, "border-bottom-width");
- if (prop != NULL)
- {
- border->bottom_width = strtod (prop, NULL);
- }
-
- prop = xmlGetProp (xnode, "border-left-width");
- if (prop != NULL)
- {
- border->left_width = strtod (prop, NULL);
- }
-
- prop = xmlGetProp (xnode, "border-top-color");
- if (prop != NULL)
- {
- rpt_print_parse_color (prop, &border->top_color);
- }
-
- prop = xmlGetProp (xnode, "border-right-color");
- if (prop != NULL)
- {
- rpt_print_parse_color (prop, &border->right_color);
- }
-
- prop = xmlGetProp (xnode, "border-bottom-color");
- if (prop != NULL)
- {
- rpt_print_parse_color (prop, &border->bottom_color);
- }
-
- prop = xmlGetProp (xnode, "border-left-color");
- if (prop != NULL)
- {
- rpt_print_parse_color (prop, &border->left_color);
- }
-}
-
-static void
-rpt_print_get_stroke (xmlNode *xnode, RptStroke *stroke)
-{
- gchar *prop;
-
- stroke->width = 1.0;
- stroke->color.r = 0.0;
- stroke->color.g = 0.0;
- stroke->color.b = 0.0;
- stroke->color.a = 1.0;
-
- prop = xmlGetProp (xnode, "stroke-width");
- if (prop != NULL)
- {
- stroke->width = strtod (prop, NULL);
- }
-
- prop = xmlGetProp (xnode, "stroke-color");
- if (prop != NULL)
- {
- rpt_print_parse_color (prop, &stroke->color);
- }
-}
-
-static void
-rpt_print_get_font (xmlNode *xnode, RptFont *font)
-{
- gchar *prop;
-
- font->name = g_strdup ("sans");
- font->size = 12.0;
- font->bold = FALSE;
- font->italic = FALSE;
- font->underline = FALSE;
- font->strike = FALSE;
- font->color.r = 0.0;
- font->color.g = 0.0;
- font->color.b = 0.0;
- font->color.a = 1.0;
-
- prop = xmlGetProp (xnode, "font-name");
- if (prop != NULL)
- {
- font->name = g_strdup (prop);
- }
-
- prop = xmlGetProp (xnode, "font-size");
- if (prop != NULL)
- {
- font->size = strtod (prop, NULL);
- }
-
- prop = xmlGetProp (xnode, "font-bold");
- if (prop != NULL)
- {
- font->bold = (strcmp (g_strstrip (prop), "y") == 0);
- }
-
- prop = xmlGetProp (xnode, "font-italic");
- if (prop != NULL)
- {
- font->italic = (strcmp (g_strstrip (prop), "y") == 0);
- }
-
- prop = xmlGetProp (xnode, "font-underline");
- if (prop != NULL)
- {
- font->underline = (strcmp (g_strstrip (prop), "y") == 0);
- }
-
- prop = xmlGetProp (xnode, "font-strike");
- if (prop != NULL)
- {
- font->strike = (strcmp (g_strstrip (prop), "y") == 0);
- }
-
- prop = xmlGetProp (xnode, "font-color");
- if (prop != NULL)
- {
- rpt_print_parse_color (prop, &font->color);
- }
-}
-
-static void
-rpt_print_parse_color (const gchar *str_color, RptColor *color)
-{
- gchar *c = g_strstrip (g_strdup (str_color));
-
- if (c[0] == '#')
- {
- if (strlen (c) == 4 || strlen (c) == 5)
- {
- if (isxdigit (c[1]))
- {
- color->r = strtol (g_strdup_printf ("%c%c", c[1], c[1]), NULL, 16) / 255.0;
- }
- if (isxdigit (c[2]))
- {
- color->g = strtol (g_strdup_printf ("%c%c", c[2], c[2]), NULL, 16) / 255.0;
- }
- if (isxdigit (c[3]))
- {
- color->b = strtol (g_strdup_printf ("%c%c", c[3], c[3]), NULL, 16) / 255.0;
- }
- if (strlen (c) == 5 && isxdigit (c[4]))
- {
- color->a = strtol (g_strdup_printf ("%c%c", c[4], c[4]), NULL, 16) / 255.0;
- }
- }
- else if (strlen (c) == 7 || strlen (c) == 9)
- {
- if (isxdigit (c[1]) && isxdigit (c[2]))
- {
- color->r = strtol (g_strndup (&c[1], 2), NULL, 16) / 255.0;
- }
- if (isxdigit (c[3]) && isxdigit (c[4]))
- {
- color->g = strtol (g_strndup (&c[3], 2), NULL, 16) / 255.0;
- }
- if (isxdigit (c[5]) && isxdigit (c[6]))
- {
- color->b = strtol (g_strndup (&c[5], 2), NULL, 16) / 255.0;
- }
- if (strlen (c) == 9)
- {
- color->a = strtol (g_strndup (&c[7], 2), NULL, 16) / 255.0;
- }
- }
- }
-}
static void rpt_report_rptprint_section (RptReport *rpt_report,
xmlNode *xpage,
gdouble *cur_y,
- RptReportSection section);
+ RptReportSection section,
+ gint row);
static void rpt_report_rptprint_parse_text_source (RptReport *rpt_report,
RptObject *rptobj,
- xmlNode *xnode);
+ xmlNode *xnode,
+ gint row);
#define RPT_REPORT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_RPT_REPORT, RptReportPrivate))
if (pages > 0 && priv->page_footer != NULL)
{
cur_y = priv->page->size->height - priv->page_footer->height;
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1);
}
cur_y = 0.0;
if (priv->page_header != NULL)
{
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER, row);
}
}
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_BODY);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_BODY, row);
}
if (pages > 0 && priv->page_footer != NULL)
{
cur_y = priv->page->size->height - priv->page_footer->height;
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, row - 1);
}
}
else
{
if (priv->page_header != NULL)
{
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_HEADER, -1);
}
pages++;
xpage = rpt_report_rptprint_new_page (rpt_report, xroot);
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_BODY);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_BODY, -1);
if (priv->page_footer != NULL)
{
cur_y = priv->page->size->height - priv->page_footer->height;
- rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER);
+ rpt_report_rptprint_section (rpt_report, xpage, &cur_y, RPTREPORT_SECTION_PAGE_FOOTER, -1);
}
}
}
static void
-rpt_report_rptprint_section (RptReport *rpt_report, xmlNode *xpage, gdouble *cur_y, RptReportSection section)
+rpt_report_rptprint_section (RptReport *rpt_report, xmlNode *xpage, gdouble *cur_y, RptReportSection section, gint row)
{
GList *objects;
xmlAttrPtr attr;
if (IS_RPT_OBJ_TEXT (rptobj))
{
- rpt_report_rptprint_parse_text_source (rpt_report, rptobj, xnode);
+ rpt_report_rptprint_parse_text_source (rpt_report, rptobj, xnode, row);
}
else if (IS_RPT_OBJ_IMAGE (rptobj))
{
}
static void
-rpt_report_rptprint_parse_text_source (RptReport *rpt_report, RptObject *rptobj, xmlNode *xnode)
+rpt_report_rptprint_parse_text_source (RptReport *rpt_report, RptObject *rptobj, xmlNode *xnode, gint row)
{
/* TO DO */
gchar *source;
+ RptReportPrivate *priv = RPT_REPORT_GET_PRIVATE (rpt_report);
+
g_object_get (G_OBJECT (rptobj), "source", &source, NULL);
+ if (row > -1 && source[0] == '[' && source[strlen (source) - 1] == ']')
+ {
+ gint col;
+ gchar *field;
+
+ field = g_strstrip (g_strndup (source + 1, strlen (source) - 2));
+ col = gda_data_model_get_column_position (priv->gda_datamodel, field);
+
+ if (col > -1)
+ {
+ source = gda_value_stringify ((GdaValue *)gda_data_model_get_value_at (priv->gda_datamodel, col, row));
+ }
+ }
+
xmlNodeSetContent (xnode, source);
}
<report>
<page-header height="80">
- <text name="title" x="10" y="10" width="300" height="50" source="the page title" />
+ <text name="title" x="10" y="10" width="300" height="50" font-name="Courier New" font-size="10" font-bold="y" source="the page title" />
<line name="line1" x="10" y="65" width="500" height="0" />
</page-header>
<body height="200">
- <text name="txt_id" x="50" y="50" width="100" height="50" source="[id]" />
+ <text name="txt_id" x="50" y="50" width="100" height="50" border-top-width="1.0" border-top-color="#FF0000" source="[id]" />
<text name="txt_name" x="200" y="50" width="100" height="50" source="[name]" />
<rect name="rect1" x="400" y="10" width="20" height="20" />
<image name="img1" x="450" y="10" width="60" height="60" source="tests/gnome-globe.png" />