2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * label.c: GLabels xml label 1.91 compat module
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <libxml/tree.h>
28 #include <libxml/parser.h>
29 #include <gdk-pixbuf/gdk-pixdata.h>
32 #include "label-object.h"
33 #include "label-text.h"
34 #include "label-box.h"
35 #include "label-line.h"
36 #include "label-ellipse.h"
37 #include "label-image.h"
38 #include "label-barcode.h"
42 #include "xml-label.h"
43 #include "xml-label-04.h"
44 #include "xml-template.h"
50 /*========================================================*/
51 /* Private macros and constants. */
52 /*========================================================*/
54 /*========================================================*/
56 /*========================================================*/
58 /*========================================================*/
59 /* Private globals. */
60 /*========================================================*/
62 /*========================================================*/
63 /* Private function prototypes. */
64 /*========================================================*/
66 static void xml191_parse_objects (xmlNodePtr node,
69 static void xml191_parse_object (xmlNodePtr node,
72 static glLabelObject *xml191_parse_text_props (xmlNodePtr node,
75 static glLabelObject *xml191_parse_box_props (xmlNodePtr node,
78 static glLabelObject *xml191_parse_line_props (xmlNodePtr node,
81 static glLabelObject *xml191_parse_ellipse_props (xmlNodePtr node,
84 static glLabelObject *xml191_parse_image_props (xmlNodePtr node,
87 static glLabelObject *xml191_parse_barcode_props (xmlNodePtr node,
90 static void xml191_parse_merge_fields (xmlNodePtr node,
93 static void xml191_parse_data (xmlNodePtr node,
96 static void xml191_parse_pixdata (xmlNodePtr node,
99 static glTemplate *xml191_parse_sheet (xmlNodePtr node);
101 static void xml191_parse_label (xmlNodePtr label_node,
102 glTemplate *template);
104 static void xml191_parse_layout (xmlNodePtr layout_node,
105 glTemplate *template);
107 static void xml191_parse_markup (xmlNodePtr markup_node,
108 glTemplate *template);
110 static void xml191_parse_alias (xmlNodePtr alias_node,
111 glTemplate *template);
115 /****************************************************************************/
116 /* Parse xml root node and create label. */
117 /****************************************************************************/
119 gl_xml_label_191_parse (xmlNodePtr root,
120 glXMLLabelStatus *status)
124 glTemplate *template;
126 gl_debug (DEBUG_XML, "START");
128 *status = XML_LABEL_OK;
130 if (!xmlStrEqual (root->name, "Document")) {
131 g_warning (_("Bad root node = \"%s\""), root->name);
132 *status = XML_LABEL_ERROR_OPEN_PARSE;
136 label = GL_LABEL(gl_label_new ());
138 /* Pass 1, extract data nodes to pre-load cache. */
139 for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
140 if (xmlStrEqual (node->name, "Data")) {
141 xml191_parse_data (node, label);
145 /* Pass 2, now extract everything else. */
146 for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
148 if (xmlStrEqual (node->name, "Sheet")) {
149 template = xml191_parse_sheet (node);
151 *status = XML_LABEL_UNKNOWN_MEDIA;
154 gl_template_register (template);
155 gl_label_set_template (label, template);
156 gl_template_free (&template);
157 } else if (xmlStrEqual (node->name, "Objects")) {
158 xml191_parse_objects (node, label);
159 } else if (xmlStrEqual (node->name, "Merge_Fields")) {
160 xml191_parse_merge_fields (node, label);
161 } else if (xmlStrEqual (node->name, "Data")) {
162 /* Handled in pass 1. */
164 if (!xmlNodeIsText (node)) {
165 g_warning (_("bad node in Document node = \"%s\""),
171 gl_debug (DEBUG_XML, "END");
176 /*--------------------------------------------------------------------------*/
177 /* PRIVATE. Parse Objects node. */
178 /*--------------------------------------------------------------------------*/
180 xml191_parse_objects (xmlNodePtr objects_node,
183 gboolean rotate_flag;
186 gl_debug (DEBUG_XML, "START");
188 rotate_flag = gl_xml_get_prop_boolean (objects_node, "rotate", FALSE);
189 gl_label_set_rotate_flag (label, rotate_flag);
191 for (node = objects_node->xmlChildrenNode; node != NULL; node = node->next) {
193 if (xmlStrEqual (node->name, "Object")) {
194 xml191_parse_object (node, label);
196 if (!xmlNodeIsText (node)) {
197 g_warning (_("bad node = \"%s\""), node->name);
202 gl_debug (DEBUG_XML, "END");
205 /*--------------------------------------------------------------------------*/
206 /* PRIVATE. Parse XML Object Node */
207 /*--------------------------------------------------------------------------*/
209 xml191_parse_object (xmlNodePtr object_node,
212 glLabelObject *object;
217 gl_debug (DEBUG_XML, "START");
219 string = xmlGetProp (object_node, "type");
221 if ( xmlStrEqual (string, "Text") ) {
222 object = xml191_parse_text_props (object_node, label);
223 } else if ( xmlStrEqual (string, "Box") ) {
224 object = xml191_parse_box_props (object_node, label);
225 } else if ( xmlStrEqual (string, "Line") ) {
226 object = xml191_parse_line_props (object_node, label);
227 } else if ( xmlStrEqual (string, "Ellipse") ) {
228 object = xml191_parse_ellipse_props (object_node, label);
229 } else if ( xmlStrEqual (string, "Image") ) {
230 object = xml191_parse_image_props (object_node, label);
231 } else if ( xmlStrEqual (string, "Barcode") ) {
232 object = xml191_parse_barcode_props (object_node, label);
234 g_warning ("Unknown label object type \"%s\"", string);
241 x = gl_xml_get_prop_length (object_node, "x", 0.0);
242 y = gl_xml_get_prop_length (object_node, "y", 0.0);
244 gl_label_object_set_position (object, x, y);
247 affine[0] = gl_xml_get_prop_double (object_node, "a0", 0.0);
248 affine[1] = gl_xml_get_prop_double (object_node, "a1", 0.0);
249 affine[2] = gl_xml_get_prop_double (object_node, "a2", 0.0);
250 affine[3] = gl_xml_get_prop_double (object_node, "a3", 0.0);
251 affine[4] = gl_xml_get_prop_double (object_node, "a4", 0.0);
252 affine[5] = gl_xml_get_prop_double (object_node, "a5", 0.0);
254 gl_label_object_set_affine (object, affine);
257 gl_debug (DEBUG_XML, "END");
260 /*--------------------------------------------------------------------------*/
261 /* PRIVATE. Parse XML Label->Text Node Properties */
262 /*--------------------------------------------------------------------------*/
263 static glLabelObject *
264 xml191_parse_text_props (xmlNodePtr object_node,
272 GnomeFontWeight font_weight;
273 gboolean font_italic_flag;
275 GtkJustification just;
276 xmlNodePtr line_node, text_node;
277 glTextNode *node_text;
281 gl_debug (DEBUG_XML, "START");
283 object = gl_label_text_new (label);
285 w = gl_xml_get_prop_length (object_node, "w", 0);
286 h = gl_xml_get_prop_length (object_node, "h", 0);
288 font_family = xmlGetProp (object_node, "font_family");
290 font_size = gl_xml_get_prop_double (object_node, "font_size", 0.0);
292 string = xmlGetProp (object_node, "font_weight");
293 font_weight = gl_util_string_to_weight (string);
296 font_italic_flag = gl_xml_get_prop_boolean (object_node, "font_italic", FALSE);
298 string = xmlGetProp (object_node, "justify");
299 just = gl_util_string_to_just (string);
302 color = gl_xml_get_prop_uint (object_node, "color", 0);
305 for (line_node = object_node->xmlChildrenNode;
307 line_node = line_node->next) {
309 if (xmlStrEqual (line_node->name, "Line")) {
312 for (text_node = line_node->xmlChildrenNode;
313 text_node != NULL; text_node = text_node->next) {
315 if (xmlStrEqual (text_node->name, "Field")) {
316 node_text = g_new0 (glTextNode, 1);
317 node_text->field_flag = TRUE;
318 node_text->data = xmlGetProp (text_node, "name");
319 nodes = g_list_append (nodes, node_text);
320 } else if (xmlStrEqual (text_node->name, "Literal")) {
321 node_text = g_new0 (glTextNode, 1);
322 node_text->field_flag = FALSE;
324 xmlNodeGetContent (text_node);
326 g_list_append (nodes, node_text);
327 } else if (!xmlNodeIsText (text_node)) {
328 g_warning ("Unexpected Text Line child: \"%s\"",
333 lines = g_list_append (lines, nodes);
335 } else if (!xmlNodeIsText (line_node)) {
336 g_warning ("Unexpected Text child: \"%s\"",
342 gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
343 gl_label_text_set_lines (GL_LABEL_TEXT(object), lines);
344 gl_label_object_set_font_family (GL_LABEL_OBJECT(object), font_family);
345 gl_label_object_set_font_size (GL_LABEL_OBJECT(object), font_size);
346 gl_label_object_set_font_weight (GL_LABEL_OBJECT(object), font_weight);
347 gl_label_object_set_font_italic_flag (GL_LABEL_OBJECT(object), font_italic_flag);
348 gl_label_object_set_text_color (GL_LABEL_OBJECT(object), color);
349 gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), just);
351 gl_text_node_lines_free (&lines);
352 g_free (font_family);
354 gl_debug (DEBUG_XML, "END");
356 return GL_LABEL_OBJECT(object);
359 /*--------------------------------------------------------------------------*/
360 /* PRIVATE. Parse XML Label->Box Node Properties */
361 /*--------------------------------------------------------------------------*/
362 static glLabelObject *
363 xml191_parse_box_props (xmlNodePtr node,
368 guint line_color, fill_color;
371 gl_debug (DEBUG_XML, "START");
373 object = gl_label_box_new (label);
375 w = gl_xml_get_prop_length (node, "w", 0);
376 h = gl_xml_get_prop_length (node, "h", 0);
378 line_width = gl_xml_get_prop_length (node, "line_width", 1.0);
380 line_color = gl_xml_get_prop_uint (node, "line_color", 0);
381 fill_color = gl_xml_get_prop_uint (node, "fill_color", 0);
383 gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
384 gl_label_object_set_line_width (GL_LABEL_OBJECT(object), line_width);
385 gl_label_object_set_line_color (GL_LABEL_OBJECT(object), line_color);
386 gl_label_object_set_fill_color (GL_LABEL_OBJECT(object), fill_color);
388 gl_debug (DEBUG_XML, "END");
390 return GL_LABEL_OBJECT(object);
393 /*--------------------------------------------------------------------------*/
394 /* PRIVATE. Parse XML Label->Line Node Properties */
395 /*--------------------------------------------------------------------------*/
396 static glLabelObject *
397 xml191_parse_line_props (xmlNodePtr node,
405 gl_debug (DEBUG_XML, "START");
407 object = gl_label_line_new (label);
409 w = gl_xml_get_prop_length (node, "dx", 0);
410 h = gl_xml_get_prop_length (node, "dy", 0);
412 line_width = gl_xml_get_prop_length (node, "line_width", 1.0);
414 line_color = gl_xml_get_prop_uint (node, "line_color", 0);
416 gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
417 gl_label_object_set_line_width (GL_LABEL_OBJECT(object), line_width);
418 gl_label_object_set_line_color (GL_LABEL_OBJECT(object), line_color);
420 gl_debug (DEBUG_XML, "END");
422 return GL_LABEL_OBJECT(object);
425 /*--------------------------------------------------------------------------*/
426 /* PRIVATE. Parse XML Label->Ellipse Node Properties */
427 /*--------------------------------------------------------------------------*/
428 static glLabelObject *
429 xml191_parse_ellipse_props (xmlNodePtr node,
434 guint line_color, fill_color;
437 gl_debug (DEBUG_XML, "START");
439 object = gl_label_ellipse_new (label);
441 w = gl_xml_get_prop_length (node, "w", 0);
442 h = gl_xml_get_prop_length (node, "h", 0);
444 line_width = gl_xml_get_prop_length (node, "line_width", 1.0);
446 line_color = gl_xml_get_prop_uint (node, "line_color", 0);
447 fill_color = gl_xml_get_prop_uint (node, "fill_color", 0);
449 gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
450 gl_label_object_set_line_width (GL_LABEL_OBJECT(object), line_width);
451 gl_label_object_set_line_color (GL_LABEL_OBJECT(object), line_color);
452 gl_label_object_set_fill_color (GL_LABEL_OBJECT(object), fill_color);
454 gl_debug (DEBUG_XML, "END");
456 return GL_LABEL_OBJECT(object);
459 /*--------------------------------------------------------------------------*/
460 /* PRIVATE. Parse XML Label->Image Node Properties */
461 /*--------------------------------------------------------------------------*/
462 static glLabelObject *
463 xml191_parse_image_props (xmlNodePtr node,
469 glTextNode *filename;
471 gl_debug (DEBUG_XML, "START");
473 object = gl_label_image_new (label);
475 w = gl_xml_get_prop_length (node, "w", 0);
476 h = gl_xml_get_prop_length (node, "h", 0);
478 filename = g_new0 (glTextNode, 1);
479 for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
480 if (xmlStrEqual (child->name, "Field")) {
481 filename->field_flag = TRUE;
482 filename->data = xmlGetProp (child, "name");
483 } else if (xmlStrEqual (child->name, "File")) {
484 filename->field_flag = FALSE;
485 filename->data = xmlGetProp (child, "src");
486 } else if (!xmlNodeIsText (child)) {
487 g_warning ("Unexpected Image child: \"%s\"", child->name);
491 gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
492 gl_label_image_set_filename (GL_LABEL_IMAGE(object), filename);
494 gl_text_node_free (&filename);
496 gl_debug (DEBUG_XML, "END");
498 return GL_LABEL_OBJECT(object);
501 /*--------------------------------------------------------------------------*/
502 /* PRIVATE. Parse XML Label->Barcode Node Properties */
503 /*--------------------------------------------------------------------------*/
504 static glLabelObject *
505 xml191_parse_barcode_props (xmlNodePtr node,
512 glTextNode *text_node;
513 glBarcodeStyle style;
515 gboolean checksum_flag;
518 gl_debug (DEBUG_XML, "START");
520 object = gl_label_barcode_new (label);
522 w = gl_xml_get_prop_length (node, "w", 0);
523 h = gl_xml_get_prop_length (node, "h", 0);
525 color = gl_xml_get_prop_uint (node, "color", 0);
527 string = xmlGetProp (node, "style");
528 style = gl_barcode_text_to_style (string);
531 text_flag = gl_xml_get_prop_boolean (node, "text", FALSE);
532 checksum_flag = gl_xml_get_prop_boolean (node, "checksum", TRUE);
534 text_node = g_new0 (glTextNode, 1);
535 for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
536 if (xmlStrEqual (child->name, "Field")) {
537 text_node->field_flag = TRUE;
538 text_node->data = xmlGetProp (child, "name");
539 } else if (xmlStrEqual (child->name, "Literal")) {
540 text_node->field_flag = FALSE;
541 text_node->data = xmlNodeGetContent (child);
542 } else if (!xmlNodeIsText (child)) {
543 g_warning ("Unexpected Barcode child: \"%s\"", child->name);
547 gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
549 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
550 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
551 style, text_flag, checksum_flag);
552 gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color);
554 gl_text_node_free (&text_node);
556 gl_debug (DEBUG_XML, "END");
558 return GL_LABEL_OBJECT(object);
561 /*--------------------------------------------------------------------------*/
562 /* PRIVATE. Parse XML merge fields tag. */
563 /*--------------------------------------------------------------------------*/
565 xml191_parse_merge_fields (xmlNodePtr node,
572 gl_debug (DEBUG_XML, "START");
574 string = xmlGetProp (node, "type");
575 merge = gl_merge_new (string);
578 string = xmlGetProp (node, "src");
579 gl_merge_set_src (merge, string);
582 gl_label_set_merge (label, merge);
584 g_object_unref (G_OBJECT(merge));
586 gl_debug (DEBUG_XML, "END");
589 /*--------------------------------------------------------------------------*/
590 /* PRIVATE. Parse XML data tag. */
591 /*--------------------------------------------------------------------------*/
593 xml191_parse_data (xmlNodePtr node,
598 gl_debug (DEBUG_XML, "START");
600 for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
602 if (xmlStrEqual (child->name, "Pixdata")) {
603 xml191_parse_pixdata (child, label);
605 if (!xmlNodeIsText (child)) {
606 g_warning (_("bad node in Data node = \"%s\""),
612 gl_debug (DEBUG_XML, "END");
615 /*--------------------------------------------------------------------------*/
616 /* PRIVATE. Parse XML pixbuf data tag. */
617 /*--------------------------------------------------------------------------*/
619 xml191_parse_pixdata (xmlNodePtr node,
622 gchar *name, *base64;
628 GHashTable *pixbuf_cache;
630 gl_debug (DEBUG_XML, "START");
632 name = xmlGetProp (node, "name");
633 base64 = xmlNodeGetContent (node);
635 stream = gl_base64_decode (base64, &stream_length);
636 pixdata = g_new0 (GdkPixdata, 1);
637 ret = gdk_pixdata_deserialize (pixdata, stream_length, stream, NULL);
640 pixbuf = gdk_pixbuf_from_pixdata (pixdata, TRUE, NULL);
642 pixbuf_cache = gl_label_get_pixbuf_cache (label);
643 gl_pixbuf_cache_add_pixbuf (pixbuf_cache, name, pixbuf);
651 gl_debug (DEBUG_XML, "END");
654 /*--------------------------------------------------------------------------*/
655 /* PRIVATE. Parse XML template Node. */
656 /*--------------------------------------------------------------------------*/
658 xml191_parse_sheet (xmlNodePtr sheet_node)
660 glTemplate *template;
665 gl_debug (DEBUG_TEMPLATE, "START");
667 template = g_new0 (glTemplate, 1);
669 template->name = xmlGetProp (sheet_node, "name");
670 template->alias = g_list_append (template->alias, g_strdup (template->name));
671 gl_debug (DEBUG_TEMPLATE, "Sheet = %s", template->name);
673 template->page_size = xmlGetProp (sheet_node, "size");
674 if (xmlStrEqual (template->page_size, "Other")) {
676 template->page_width = gl_xml_get_prop_length (sheet_node, "width", 0);
677 template->page_height = gl_xml_get_prop_length (sheet_node, "height", 0);
680 paper = gl_paper_from_id (template->page_size);
682 /* This should always be an id, but just in case a name
684 g_warning (_("Unknown page size id \"%s\", trying as name"),
685 template->page_size);
686 paper = gl_paper_from_name (template->page_size);
687 g_free (template->page_size);
688 template->page_size = g_strdup (paper->id);
691 template->page_width = paper->width;
692 template->page_height = paper->height;
694 g_warning (_("Unknown page size id or name \"%s\""),
695 template->page_size);
697 gl_paper_free (&paper);
700 description = xmlGetProp (sheet_node, "_description");
701 if (description != NULL) {
702 template->description = gettext (description);
704 template->description = xmlGetProp (sheet_node, "description");
707 for (node = sheet_node->xmlChildrenNode; node != NULL;
709 if (xmlStrEqual (node->name, "Label")) {
710 xml191_parse_label (node, template);
711 } else if (xmlStrEqual (node->name, "Alias")) {
712 xml191_parse_alias (node, template);
714 if (!xmlNodeIsText (node)) {
715 g_warning ("bad node = \"%s\"", node->name);
720 gl_debug (DEBUG_TEMPLATE, "END");
725 /*--------------------------------------------------------------------------*/
726 /* PRIVATE. Parse XML Sheet->Label Node. */
727 /*--------------------------------------------------------------------------*/
729 xml191_parse_label (xmlNodePtr label_node,
730 glTemplate *template)
735 gl_debug (DEBUG_TEMPLATE, "START");
737 style = xmlGetProp (label_node, "style");
738 if (xmlStrEqual (style, "rectangle")) {
739 template->label.style = GL_TEMPLATE_STYLE_RECT;
740 } else if (xmlStrEqual (style, "round")) {
741 template->label.style = GL_TEMPLATE_STYLE_ROUND;
742 } else if (xmlStrEqual (style, "cd")) {
743 template->label.style = GL_TEMPLATE_STYLE_CD;
745 template->label.style = GL_TEMPLATE_STYLE_RECT;
746 g_warning ("Unknown label style in template");
750 switch (template->label.style) {
752 case GL_TEMPLATE_STYLE_RECT:
753 template->label.rect.w = gl_xml_get_prop_length (label_node, "width", 0);
754 template->label.rect.h = gl_xml_get_prop_length (label_node, "height", 0);
755 template->label.rect.r = gl_xml_get_prop_length (label_node, "round", 0);
758 case GL_TEMPLATE_STYLE_ROUND:
759 template->label.round.r = gl_xml_get_prop_length (label_node, "radius", 0);
762 case GL_TEMPLATE_STYLE_CD:
763 template->label.cd.r1 = gl_xml_get_prop_length (label_node, "radius", 0);
764 template->label.cd.r2 = gl_xml_get_prop_length (label_node, "hole", 0);
765 template->label.cd.w = gl_xml_get_prop_length (label_node, "width", 0);
766 template->label.cd.h = gl_xml_get_prop_length (label_node, "height", 0);
774 for (node = label_node->xmlChildrenNode; node != NULL;
776 if (xmlStrEqual (node->name, "Layout")) {
777 xml191_parse_layout (node, template);
778 } else if (xmlStrEqual (node->name, "Markup")) {
779 xml191_parse_markup (node, template);
780 } else if (!xmlNodeIsText (node)) {
781 g_warning ("bad node = \"%s\"", node->name);
785 gl_debug (DEBUG_TEMPLATE, "END");
788 /*--------------------------------------------------------------------------*/
789 /* PRIVATE. Parse XML Sheet->Label->Layout Node. */
790 /*--------------------------------------------------------------------------*/
792 xml191_parse_layout (xmlNodePtr layout_node,
793 glTemplate *template)
796 gdouble x0, y0, dx, dy;
799 gl_debug (DEBUG_TEMPLATE, "START");
801 nx = gl_xml_get_prop_int (layout_node, "nx", 1);
802 ny = gl_xml_get_prop_int (layout_node, "ny", 1);
804 x0 = gl_xml_get_prop_length (layout_node, "x0", 0);
805 y0 = gl_xml_get_prop_length (layout_node, "y0", 0);
807 dx = gl_xml_get_prop_length (layout_node, "dx", 0);
808 dy = gl_xml_get_prop_length (layout_node, "dy", 0);
810 for (node = layout_node->xmlChildrenNode; node != NULL;
812 if (!xmlNodeIsText (node)) {
813 g_warning ("bad node = \"%s\"", node->name);
817 template->label.any.layouts =
818 g_list_append (template->label.any.layouts,
819 gl_template_layout_new (nx, ny, x0, y0, dx, dy));
821 gl_debug (DEBUG_TEMPLATE, "END");
824 /*--------------------------------------------------------------------------*/
825 /* PRIVATE. Parse XML Sheet->Label->Markup Node. */
826 /*--------------------------------------------------------------------------*/
828 xml191_parse_markup (xmlNodePtr markup_node,
829 glTemplate *template)
833 gdouble x1, y1, x2, y2;
836 gl_debug (DEBUG_TEMPLATE, "START");
838 type = xmlGetProp (markup_node, "type");
839 if (xmlStrEqual (type, "margin")) {
841 size = gl_xml_get_prop_length (markup_node, "size", 0);
843 template->label.any.markups =
844 g_list_append (template->label.any.markups,
845 gl_template_markup_margin_new (size));
847 } else if (xmlStrEqual (type, "line")) {
849 x1 = gl_xml_get_prop_length (markup_node, "x1", 0);
850 y1 = gl_xml_get_prop_length (markup_node, "y1", 0);
851 x2 = gl_xml_get_prop_length (markup_node, "x2", 0);
852 y2 = gl_xml_get_prop_length (markup_node, "y2", 0);
854 template->label.any.markups =
855 g_list_append (template->label.any.markups,
856 gl_template_markup_line_new (x1, y1, x2, y2));
860 for (node = markup_node->xmlChildrenNode; node != NULL;
862 if (!xmlNodeIsText (node)) {
863 g_warning ("bad node = \"%s\"", node->name);
867 gl_debug (DEBUG_TEMPLATE, "END");
870 /*--------------------------------------------------------------------------*/
871 /* PRIVATE. Parse XML Sheet->Alias Node. */
872 /*--------------------------------------------------------------------------*/
874 xml191_parse_alias (xmlNodePtr alias_node,
875 glTemplate *template)
877 gl_debug (DEBUG_TEMPLATE, "START");
879 template->alias = g_list_append (template->alias,
880 xmlGetProp (alias_node, "name"));
882 gl_debug (DEBUG_TEMPLATE, "END");