{
xmlNodePtr node;
GList *p;
- gchar *string;
gl_debug (DEBUG_TEMPLATE, "START");
xmlSetProp (node, "size", template->page_size);
if (g_strcasecmp (template->page_size, "Other") == 0) {
- string = g_strdup_printf ("%g", template->page_width);
- xmlSetProp (node, "width", string);
- g_free (string);
+ gl_xml_set_prop_double (node, "width", template->page_width);
+ gl_xml_set_prop_double (node, "height", template->page_height);
- string = g_strdup_printf ("%g", template->page_height);
- xmlSetProp (node, "height", string);
- g_free (string);
}
xmlSetProp (node, "description", template->description);
xmlNsPtr ns)
{
xmlNodePtr node;
- gchar *string;
GList *p;
glTemplateMarkup *markup;
glTemplateLayout *layout;
xmlSetProp (node, "id", "0");
switch (template->label.style) {
+
case GL_TEMPLATE_STYLE_RECT:
xmlSetProp (node, "style", "rectangle");
- string = g_strdup_printf ("%g", template->label.rect.w);
- xmlSetProp (node, "width", string);
- g_free (string);
- string = g_strdup_printf ("%g", template->label.rect.h);
- xmlSetProp (node, "height", string);
- g_free (string);
- string = g_strdup_printf ("%g", template->label.rect.r);
- xmlSetProp (node, "round", string);
- g_free (string);
+ gl_xml_set_prop_double (node, "width", template->label.rect.w);
+ gl_xml_set_prop_double (node, "height", template->label.rect.h);
+ gl_xml_set_prop_double (node, "round", template->label.rect.r);
break;
+
case GL_TEMPLATE_STYLE_ROUND:
xmlSetProp (node, "style", "round");
- string = g_strdup_printf ("%g", template->label.round.r);
- xmlSetProp (node, "radius", string);
- g_free (string);
+ gl_xml_set_prop_double (node, "radius", template->label.round.r);
break;
+
case GL_TEMPLATE_STYLE_CD:
xmlSetProp (node, "style", "cd");
- string = g_strdup_printf ("%g", template->label.cd.r1);
- xmlSetProp (node, "radius", string);
- g_free (string);
- string = g_strdup_printf ("%g", template->label.cd.r2);
- xmlSetProp (node, "hole", string);
- g_free (string);
- if (template->label.cd.h != 0.0) {
- string = g_strdup_printf ("%g", template->label.cd.h);
- xmlSetProp (node, "width", string);
- g_free (string);
- }
+ gl_xml_set_prop_double (node, "radius", template->label.cd.r1);
+ gl_xml_set_prop_double (node, "hole", template->label.cd.r2);
if (template->label.cd.w != 0.0) {
- string = g_strdup_printf ("%g", template->label.cd.w);
- xmlSetProp (node, "height", string);
- g_free (string);
+ gl_xml_set_prop_double (node, "width", template->label.cd.w);
+ }
+ if (template->label.cd.h != 0.0) {
+ gl_xml_set_prop_double (node, "height", template->label.cd.h);
}
break;
+
default:
g_warning ("Unknown label style");
break;
+
}
for ( p=template->label.any.markups; p != NULL; p=p->next ) {
xmlNsPtr ns)
{
xmlNodePtr node;
- gchar *string;
gl_debug (DEBUG_TEMPLATE, "START");
node = xmlNewChild(root, ns, "Layout", NULL);
- string = g_strdup_printf ("%d", layout->nx);
- xmlSetProp (node, "nx", string);
- g_free (string);
- string = g_strdup_printf ("%d", layout->ny);
- xmlSetProp (node, "ny", string);
- g_free (string);
- string = g_strdup_printf ("%g", layout->x0);
- xmlSetProp (node, "x0", string);
- g_free (string);
- string = g_strdup_printf ("%g", layout->y0);
- xmlSetProp (node, "y0", string);
- g_free (string);
- string = g_strdup_printf ("%g", layout->dx);
- xmlSetProp (node, "dx", string);
- g_free (string);
- string = g_strdup_printf ("%g", layout->dy);
- xmlSetProp (node, "dy", string);
- g_free (string);
+ gl_xml_set_prop_int (node, "nx", layout->nx);
+ gl_xml_set_prop_int (node, "ny", layout->ny);
+ gl_xml_set_prop_double (node, "x0", layout->x0);
+ gl_xml_set_prop_double (node, "y0", layout->y0);
+ gl_xml_set_prop_double (node, "dx", layout->dx);
+ gl_xml_set_prop_double (node, "dy", layout->dy);
gl_debug (DEBUG_TEMPLATE, "END");
}
xmlNsPtr ns)
{
xmlNodePtr node;
- gchar *string;
gl_debug (DEBUG_TEMPLATE, "START");
node = xmlNewChild(root, ns, "Markup", NULL);
xmlSetProp (node, "type", "margin");
- string = g_strdup_printf ("%g", margin->size);
- xmlSetProp (node, "size", string);
- g_free (string);
+ gl_xml_set_prop_double (node, "size", margin->size);
gl_debug (DEBUG_TEMPLATE, "END");
}
xmlNsPtr ns)
{
xmlNodePtr node;
- gchar *string;
gl_debug (DEBUG_TEMPLATE, "START");
node = xmlNewChild(root, ns, "Markup", NULL);
xmlSetProp (node, "type", "line");
- string = g_strdup_printf ("%g", line->x1);
- xmlSetProp (node, "x1", string);
- g_free (string);
- string = g_strdup_printf ("%g", line->y1);
- xmlSetProp (node, "y1", string);
- g_free (string);
- string = g_strdup_printf ("%g", line->x2);
- xmlSetProp (node, "x2", string);
- g_free (string);
- string = g_strdup_printf ("%g", line->y2);
- xmlSetProp (node, "y2", string);
- g_free (string);
+ gl_xml_set_prop_double (node, "x1", line->x1);
+ gl_xml_set_prop_double (node, "y1", line->y1);
+ gl_xml_set_prop_double (node, "x2", line->x2);
+ gl_xml_set_prop_double (node, "y2", line->y2);
gl_debug (DEBUG_TEMPLATE, "END");
}
node = xmlNewChild (root, ns, "Objects", NULL);
xmlSetProp (node, "id", "0");
- xmlSetProp (node, "rotate", rotate_flag ? "True" : "False");
+ gl_xml_set_prop_boolean (node, "rotate", rotate_flag);
for (p = label->objects; p != NULL; p = p->next) {
xml_create_object (node, ns, GL_LABEL_OBJECT(p->data));
{
xmlNodePtr object_node;
gdouble x, y;
- gchar *string;
gdouble affine[6];
gl_debug (DEBUG_XML, "START");
object_node = xmlNewChild (root, ns, "Object", NULL);
gl_label_object_get_position (object, &x, &y);
- string = g_strdup_printf ("%g", x);
- xmlSetProp (object_node, "x", string);
- g_free (string);
- string = g_strdup_printf ("%g", y);
- xmlSetProp (object_node, "y", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "x", x);
+ gl_xml_set_prop_double (object_node, "y", y);
gl_label_object_get_affine (object, affine);
- string = g_strdup_printf ("%g", affine[0]);
- xmlSetProp (object_node, "a0", string);
- g_free (string);
- string = g_strdup_printf ("%g", affine[1]);
- xmlSetProp (object_node, "a1", string);
- g_free (string);
- string = g_strdup_printf ("%g", affine[2]);
- xmlSetProp (object_node, "a2", string);
- g_free (string);
- string = g_strdup_printf ("%g", affine[3]);
- xmlSetProp (object_node, "a3", string);
- g_free (string);
- string = g_strdup_printf ("%g", affine[4]);
- xmlSetProp (object_node, "a4", string);
- g_free (string);
- string = g_strdup_printf ("%g", affine[5]);
- xmlSetProp (object_node, "a5", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "a0", affine[0]);
+ gl_xml_set_prop_double (object_node, "a1", affine[1]);
+ gl_xml_set_prop_double (object_node, "a2", affine[2]);
+ gl_xml_set_prop_double (object_node, "a3", affine[3]);
+ gl_xml_set_prop_double (object_node, "a4", affine[4]);
+ gl_xml_set_prop_double (object_node, "a5", affine[5]);
if ( GL_IS_LABEL_TEXT(object) ) {
xml_create_text_props (object_node, ns, object);
gboolean font_italic_flag;
guint color;
GtkJustification just;
- gchar *string;
GList *p_line, *p_node;
glTextNode *node_text;
&font_italic_flag,
&color, &just);
- string = g_strdup_printf ("%g", w);
- xmlSetProp (object_node, "w", string);
- g_free (string);
- string = g_strdup_printf ("%g", h);
- xmlSetProp (object_node, "h", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "w", w);
+ gl_xml_set_prop_double (object_node, "h", h);
xmlSetProp (object_node, "font_family", font_family);
- string = g_strdup_printf ("%g", font_size);
- xmlSetProp (object_node, "font_size", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "font_size", font_size);
xmlSetProp (object_node, "font_weight",
gl_util_weight_to_string (font_weight));
- xmlSetProp (object_node, "font_italic",
- font_italic_flag?"True":"False");
+ gl_xml_set_prop_boolean (object_node, "font_italic", font_italic_flag);
xmlSetProp (object_node, "justify", gl_util_just_to_string (just));
- string = g_strdup_printf ("0x%08x", color);
- xmlSetProp (object_node, "color", string);
- g_free (string);
+ gl_xml_set_prop_uint_hex (object_node, "color", color);
for (p_line = lines; p_line != NULL; p_line = p_line->next) {
line_node = xmlNewChild (object_node, ns, "Line", NULL);
xmlNsPtr ns,
glLabelObject *object)
{
- gchar *string;
gdouble line_width;
guint line_color, fill_color;
gdouble w, h;
line_color = gl_label_box_get_line_color (GL_LABEL_BOX(object));
fill_color = gl_label_box_get_fill_color (GL_LABEL_BOX(object));
- string = g_strdup_printf ("%g", w);
- xmlSetProp (object_node, "w", string);
- g_free (string);
- string = g_strdup_printf ("%g", h);
- xmlSetProp (object_node, "h", string);
- g_free (string);
-
- string = g_strdup_printf ("%g", line_width);
- xmlSetProp (object_node, "line_width", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "w", w);
+ gl_xml_set_prop_double (object_node, "h", h);
- string = g_strdup_printf ("0x%08x", line_color);
- xmlSetProp (object_node, "line_color", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "line_width", line_width);
- string = g_strdup_printf ("0x%08x", fill_color);
- xmlSetProp (object_node, "fill_color", string);
- g_free (string);
+ gl_xml_set_prop_uint_hex (object_node, "line_color", line_color);
+ gl_xml_set_prop_uint_hex (object_node, "fill_color", fill_color);
gl_debug (DEBUG_XML, "END");
}
xmlNsPtr ns,
glLabelObject *object)
{
- gchar *string;
gdouble line_width;
guint line_color;
gdouble w, h;
line_width = gl_label_line_get_line_width (GL_LABEL_LINE(object));
line_color = gl_label_line_get_line_color (GL_LABEL_LINE(object));
- string = g_strdup_printf ("%g", w);
- xmlSetProp (object_node, "dx", string);
- g_free (string);
- string = g_strdup_printf ("%g", h);
- xmlSetProp (object_node, "dy", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "dx", w);
+ gl_xml_set_prop_double (object_node, "dy", h);
- string = g_strdup_printf ("%g", line_width);
- xmlSetProp (object_node, "line_width", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "line_width", line_width);
- string = g_strdup_printf ("0x%08x", line_color);
- xmlSetProp (object_node, "line_color", string);
- g_free (string);
+ gl_xml_set_prop_uint_hex (object_node, "line_color", line_color);
gl_debug (DEBUG_XML, "END");
}
xmlNsPtr ns,
glLabelObject *object)
{
- gchar *string;
gdouble line_width;
guint line_color, fill_color;
gdouble w, h;
line_color = gl_label_ellipse_get_line_color (GL_LABEL_ELLIPSE(object));
fill_color = gl_label_ellipse_get_fill_color (GL_LABEL_ELLIPSE(object));
- string = g_strdup_printf ("%g", w);
- xmlSetProp (object_node, "w", string);
- g_free (string);
- string = g_strdup_printf ("%g", h);
- xmlSetProp (object_node, "h", string);
- g_free (string);
-
- string = g_strdup_printf ("%g", line_width);
- xmlSetProp (object_node, "line_width", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "w", w);
+ gl_xml_set_prop_double (object_node, "h", h);
- string = g_strdup_printf ("0x%08x", line_color);
- xmlSetProp (object_node, "line_color", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "line_width", line_width);
- string = g_strdup_printf ("0x%08x", fill_color);
- xmlSetProp (object_node, "fill_color", string);
- g_free (string);
+ gl_xml_set_prop_uint_hex (object_node, "line_color", line_color);
+ gl_xml_set_prop_uint_hex (object_node, "fill_color", fill_color);
gl_debug (DEBUG_XML, "END");
}
xmlNsPtr ns,
glLabelObject *object)
{
- gchar *string;
gdouble w, h;
glTextNode *filename;
xmlNodePtr child;
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object));
- string = g_strdup_printf ("%g", w);
- xmlSetProp (object_node, "w", string);
- g_free (string);
- string = g_strdup_printf ("%g", h);
- xmlSetProp (object_node, "h", string);
- g_free (string);
+ gl_xml_set_prop_double (object_node, "w", w);
+ gl_xml_set_prop_double (object_node, "h", h);
if (filename->field_flag) {
child = xmlNewChild (object_node, ns, "Field", NULL);
guint color;
gdouble scale;
xmlNodePtr child;
- gchar *string;
gl_debug (DEBUG_XML, "START");
gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
&style, &text_flag, &color, &scale);
- string = g_strdup_printf ("0x%08x", color);
- xmlSetProp (object_node, "color", string);
- g_free (string);
+ gl_xml_set_prop_uint_hex (object_node, "color", color);
xmlSetProp (object_node, "style", gl_barcode_style_to_text (style));
- xmlSetProp (object_node, "text", text_flag?"True":"False");
- string = g_strdup_printf ("%g", scale);
- xmlSetProp (object_node, "scale", string);
- g_free (string);
+ gl_xml_set_prop_boolean (object_node, "text", text_flag);
+ gl_xml_set_prop_double (object_node, "scale", scale);
if (text_node->field_flag) {
child = xmlNewChild (object_node, ns, "Field", NULL);