1 /* dia -- an diagram creation/manipulation program
2  * Copyright (C) 1998 Alexander Larsson
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 #ifndef DIA_XML_H
19 #define DIA_XML_H
20 
21 #include <glib.h>
22 #include "geometry.h"
23 #include "color.h"
24 #include "font.h"
25 #include "diavar.h"
26 #include <libxml/tree.h>
27 
28 /*
29  * Though the Dia homepage is now http://www.gnome.org/projects/dia
30  * Dia's xml namespace definition still needs to point to the
31  * original site. In fact the xml namespace definition has nothing to do
32  * with existing website, they just need to be unique to allow to
33  * differentiate between varying definitions. Changing the namespace
34  * from the old to the new site would strictly speaking break all
35  * older diagrams - although some tools may not take the actual
36  * key into account.
37  * See also : doc/diagram.dtd
38  */
39 #define DIA_XML_NAME_SPACE_BASE "http://www.lysator.liu.se/~alla/dia/"
40 
41 DIAVAR int pretty_formated_xml;
42 
43 typedef xmlNodePtr XML_NODE;
44 
45 typedef XML_NODE ObjectNode;
46 typedef XML_NODE AttributeNode;
47 typedef XML_NODE DataNode;
48 
49 typedef enum{
50   DATATYPE_COMPOSITE,
51   DATATYPE_INT,
52   DATATYPE_ENUM,
53   DATATYPE_REAL,
54   DATATYPE_BOOLEAN,
55   DATATYPE_COLOR,
56   DATATYPE_POINT,
57   DATATYPE_RECTANGLE,
58   DATATYPE_STRING,
59   DATATYPE_FONT,
60   DATATYPE_BEZPOINT,
61   DATATYPE_DICT
62 } DataType;
63 
64 AttributeNode object_find_attribute(ObjectNode obj_node,
65 				    const char *attrname);
66 AttributeNode composite_find_attribute(DataNode composite_node,
67 				       const char *attrname);
68 int attribute_num_data(AttributeNode attribute);
69 DataNode attribute_first_data(AttributeNode attribute);
70 DataNode data_next(DataNode data);
71 DataType data_type(DataNode data);
72 int data_int(DataNode data);
73 int data_enum(DataNode data);
74 real data_real(DataNode data);
75 int data_boolean(DataNode data);
76 void data_color(DataNode data, Color *col);
77 void data_point(DataNode data, Point *point);
78 void data_bezpoint(DataNode data, BezPoint *point);
79 void data_rectangle(DataNode data, Rectangle *rect);
80 char *data_string(DataNode data);
81 char *data_filename(DataNode data);
82 DiaFont *data_font(DataNode data);
83 
84 AttributeNode new_attribute(ObjectNode obj_node, const char *attrname);
85 AttributeNode composite_add_attribute(DataNode composite_node,
86 				      const char *attrname);
87 void data_add_int(AttributeNode attr, int data);
88 void data_add_enum(AttributeNode attr, int data);
89 void data_add_real(AttributeNode attr, real data);
90 void data_add_boolean(AttributeNode attr, int data);
91 void data_add_color(AttributeNode attr, const Color *col);
92 void data_add_point(AttributeNode attr, const Point *point);
93 void data_add_bezpoint(AttributeNode attr, const BezPoint *point);
94 void data_add_rectangle(AttributeNode attr, const Rectangle *rect);
95 void data_add_string(AttributeNode attr, const char *str);
96 void data_add_filename(AttributeNode attr, const char *str);
97 void data_add_font(AttributeNode attr, const DiaFont *font);
98 DataNode data_add_composite(AttributeNode attr,
99                             const char *type); /* can be NULL */
100 
101 GHashTable *data_dict (DataNode data);
102 void data_add_dict (AttributeNode attr, GHashTable *data);
103 
104 #endif /* DIA_XML_H */
105 
106