[gnome-db] Gda-Report



Hello,

Here you have my firsts steps in gda-report framework.  I'm just
begining, but I think that it could be usefull that you can see my work,
in order to detect mistakes and problems.  And, after that, begin to
commit changes in CVS (I haven't an account yet, so I send a patch + a
lot of new files).

As we have talked before, I have used libxml to implement the working
structure, to make some validations againts the DTD, and also for take
some default values from the DTD.

The fast way to see all this is using the testing subdirectory (in
testing.tar.gz), that should be uncompressed under libgda/report/.

I'm waiting for your suggestions. 

Cheers

Santi Camps
? libgda/report/libgda-report/gda-report-item-report.c
? libgda/report/libgda-report/gda-report-item-report.h
? libgda/report/libgda-report/gda-report-item-reportheader.c
? libgda/report/libgda-report/gda-report-item-reportheader.h
? libgda/report/libgda-report/gda-report-item.c
? libgda/report/libgda-report/gda-report-item.h
? libgda/report/libgda-report/gda-report-types.c
? libgda/report/libgda-report/gda-report-valid.c
? libgda/report/libgda-report/gda-report-valid.h
Index: libgda/report/gda-report.dtd.in
===================================================================
RCS file: /cvs/gnome/libgda/report/gda-report.dtd.in,v
retrieving revision 1.4
diff -u -r1.4 gda-report.dtd.in
--- libgda/report/gda-report.dtd.in	26 May 2002 00:53:53 -0000	1.4
+++ libgda/report/gda-report.dtd.in	7 Dec 2002 22:48:08 -0000
@@ -1,12 +1,13 @@
 <!-- gda-report.dtd
      Copyright (C) 2000-2002 Carlos Perello Marin <carlos gnome-db org>
                              Gerhard Dieringer
+			     Santi Camps <scamps users sourceforge net>
 
      Based on the Mutiny Bay Software's
      reportviewer's DTD (http://www.mutinybaysoftware.com)
 -->
 
-<!ENTITY % query SYSTEM "@dtddir@/gda-xml-query.dtd">
+<!ENTITY % query SYSTEM "@prefix@/share/libgda/xml/gda-xml-query.dtd">
 %query;
 
 
@@ -18,7 +19,7 @@
 <!ENTITY % halignment      "standard|left|center|right">
 <!ENTITY % valignment      "top|center|bottom">
 
-<!ELEMENT report (reportheader?, pageheaderlist?, dataheader?,  datalist?, 
+<!ELEMENT report (query?, reportheader?, pageheaderlist?, dataheader?,  datalist?, 
                   datafooter?,   pagefooterlist?, reportfooter?)>
 <!ATTLIST report
   reportstyle     (form|list)       "list"
@@ -51,9 +52,7 @@
   linestyle       (%linestyle;)     "solid"
 >
 
-<!ELEMENT reportelementlist   (%reportelement;)+>
-
-<!ELEMENT reportheader (reportelementlist)>
+<!ELEMENT reportheader ((%reportelement;)+)>
 <!ATTLIST reportheader 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -82,7 +81,7 @@
 >
 
 
-<!ELEMENT reportfooter (reportelementlist)>
+<!ELEMENT reportfooter ((%reportelement;)+)>
 <!ATTLIST reportfooter 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -117,7 +116,7 @@
 
 <!ELEMENT pageheaderlist (pageheader+)>
 
-<!ELEMENT pageheader (reportelementlist)>
+<!ELEMENT pageheader ((%reportelement;)+)>
 <!ATTLIST pageheader 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -149,7 +148,7 @@
 
 <!ELEMENT pagefooterlist (pagefooter+)>
 
-<!ELEMENT pagefooter (reportelementlist)>
+<!ELEMENT pagefooter ((%reportelement;)+)>
 <!ATTLIST pagefooter 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -182,7 +181,7 @@
 <!-- the dataheader/-footer ist like a groupheader/-footer for a virtuell group,
      that contains all the data
 -->
-<!ELEMENT dataheader (reportelementlist)>
+<!ELEMENT dataheader ((%reportelement;)+)>
 <!ATTLIST dataheader 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -210,7 +209,7 @@
 >
 
 
-<!ELEMENT datafooter (reportelementlist)>
+<!ELEMENT datafooter ((%reportelement;)+)>
 <!ATTLIST datafooter 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -243,7 +242,7 @@
 <!ELEMENT reportdata (detail|(groupheader?,reportdata,groupfooter?))>
 
 
-<!ELEMENT detail (reportelementlist)>
+<!ELEMENT detail ((%reportelement;)+)>
 <!ATTLIST detail 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -271,7 +270,7 @@
 >
 
 
-<!ELEMENT groupheader (reportelementlist)>
+<!ELEMENT groupheader ((%reportelement;)+)>
 <!ATTLIST groupheader 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
@@ -301,7 +300,7 @@
 >
 
 
-<!ELEMENT groupfooter (reportelementlist)>
+<!ELEMENT groupfooter ((%reportelement;)+)>
 <!ATTLIST groupfooter 
   active          (yes|no)          "yes"
   visible         (yes|no)          "yes"
Index: libgda/report/gda-report-example.xml
===================================================================
RCS file: /cvs/gnome/libgda/report/gda-report-example.xml,v
retrieving revision 1.2
diff -u -r1.2 gda-report-example.xml
--- libgda/report/gda-report-example.xml	15 Oct 2000 23:48:02 -0000	1.2
+++ libgda/report/gda-report-example.xml	7 Dec 2002 22:48:08 -0000
@@ -5,6 +5,21 @@
 -->
 
 <report borderstyle="solid" units="pt">
+   <query id="gfoundation-library">
+	<select>
+		<targetlist>
+			<target name="table_name" />
+		</targetlist>
+		<valuelist>
+			<value id="publishing"><field name="publishing" /></value>
+			<value id="price"><field name="price" /></value>
+			<value id="author"><field name="price" /></value>
+			<value id="isbn"><field name="isbn" /></value>
+			<value id="title"><field name="title" /></value>
+		</valuelist>
+	</select>
+  </query>
+
   <reportheader>
     <label text="Gnome Foundation Library" x="0" y="0" width="255" height="31" borderwidth="0"
            borderstyle="none" fontsize="24" fontweight="bold" fontitalic="yes"/>
Index: libgda/report/Makefile.am
===================================================================
RCS file: /cvs/gnome/libgda/report/Makefile.am,v
retrieving revision 1.23
diff -u -r1.23 Makefile.am
--- libgda/report/Makefile.am	14 May 2002 20:43:53 -0000	1.23
+++ libgda/report/Makefile.am	7 Dec 2002 22:48:09 -0000
@@ -1,7 +1,7 @@
 SUBDIRS = libgda-report
 
-DTD_FILES=gda-report.dtd
-dtddir=$(datadir)/libgda/dtd
+DTD_FILES=gda-report.dtd 
+dtddir=$(datadir)/libgda/xml
 dtd_DATA=$(DTD_FILES)
 
 
Index: libgda/report/libgda-report/Makefile.am
===================================================================
RCS file: /cvs/gnome/libgda/report/libgda-report/Makefile.am,v
retrieving revision 1.9
diff -u -r1.9 Makefile.am
--- libgda/report/libgda-report/Makefile.am	23 Aug 2002 11:37:01 -0000	1.9
+++ libgda/report/libgda-report/Makefile.am	7 Dec 2002 22:48:10 -0000
@@ -5,16 +5,27 @@
 	-I$(top_srcdir)/report \
 	-I$(top_builddir) \
 	-I$(top_srcdir) \
-	$(LIBGDA_CFLAGS)
+	$(LIBGDA_CFLAGS) \
+	-DLIBGDA_REPORT_DTDDIR=\""$(datadir)/libgda/xml"\"
+
 
 gda_report_headers = \
 	gda-report-document.h \
+	gda-report-valid.h \
 	gda-report-types.h \
+	gda-report-item.h \
+	gda-report-item-report.h \
+	gda-report-item-reportheader.h \
 	gda-report.h
 
-libgda_report_2_la_SOURCES = \
-	$(gda_report_headers) \
-	gda-report-document.c
+libgda_report_2_la_SOURCES =	\
+	$(gda_report_headers)	\
+	gda-report-document.c	\
+	gda-report-valid.c	\
+	gda-report-types.c	\
+	gda-report-item.c	\
+	gda-report-item-report.c \
+	gda-report-item-reportheader.c
 
 libgda_report_2_la_LDFLAGS = -version-info $(GDA_CURRENT):$(GDA_REVISION):$(GDA_AGE)
 libgda_report_2_la_LIBADD = $(LIBGDA_LIBS) $(top_builddir)/libgda/libgda-2.la
Index: libgda/report/libgda-report/gda-report-document.c
===================================================================
RCS file: /cvs/gnome/libgda/report/libgda-report/gda-report-document.c,v
retrieving revision 1.10
diff -u -r1.10 gda-report-document.c
--- libgda/report/libgda-report/gda-report-document.c	18 Sep 2002 23:27:30 -0000	1.10
+++ libgda/report/libgda-report/gda-report-document.c	7 Dec 2002 22:48:10 -0000
@@ -3,6 +3,7 @@
  *
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
+ *	Santi Camps <scamps users sourceforge net>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -21,47 +22,21 @@
  */
 
 #include <config.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
 #include <libgda/gda-intl.h>
 #include <libgda/gda-log.h>
 #include <libgda/gda-util.h>
+#include <libgda-report/gda-report-item-report.h>
 #include <libgda-report/gda-report-document.h>
 
-#define PARENT_TYPE GDA_TYPE_XML_DOCUMENT
-
-#define OBJECT_REPORT         "report"
-#define OBJECT_REPORT_ELEMENT "reportelement"
 
 struct _GdaReportDocumentPrivate {
-	GdaReportStyle        reportstyle;
-	GdaReportPageSize     pagesize;
-	GdaReportOrientation  orientation;
-	GdaReportUnits        units;
-	gfloat                topmargin;
-	gfloat                bottommargin;
-	gfloat                leftmargin;
-	gfloat                rightmargin;
-	GdaReportColor       *bgcolor;
-	GdaReportColor       *fgcolor;
-	GdaReportColor       *bordercolor;
-	gfloat                borderwidth;
-	GdaReportLineStyle    borderstyle;
-	gchar                *fontfamily;
-	gint                  fontsize;
-	GdaReportFontWeight   fontweight;
-	gboolean              fontitalic;
-	GdaReportHAlignment   halignment;
-	GdaReportVAlignment   valignment;
-	gboolean              wordwrap;
-	GdaReportColor       *negvaluecolor;
-	gchar                *dateformat;
-	gint8                 precision;
-	gchar                *currency;
-	gboolean              commaseparator;
-	gfloat                linewidth;
-	GdaReportColor       *linecolor;
-	GdaReportLineStyle    linestyle;
+	xmlDocPtr       doc;
+	GdaReportValid *valid;
 };
 
+
 static void gda_report_document_class_init (GdaReportDocumentClass *klass);
 static void gda_report_document_init       (GdaReportDocument *document,
 					    GdaReportDocumentClass *klass);
@@ -69,27 +44,29 @@
 
 static GObjectClass *parent_class = NULL;
 
+GdaReportDocument *gda_report_document_construct (GdaReportValid *valid);
+
+
 /*
  * GdaReportDocument class implementation
  */
-
 static void
 gda_report_document_class_init (GdaReportDocumentClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
 	parent_class = g_type_class_peek_parent (klass);
-
 	object_class->finalize = gda_report_document_finalize;
 }
 
 static void
 gda_report_document_init (GdaReportDocument *document, GdaReportDocumentClass *klass)
 {
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
+	g_return_if_fail (GDA_REPORT_IS_DOCUMENT (document));
 
-	/* allocate private structure */
 	document->priv = g_new0 (GdaReportDocumentPrivate, 1);
+	document->priv->doc 	= NULL;
+	document->priv->valid 	= NULL;
 }
 
 static void
@@ -97,16 +74,16 @@
 {
 	GdaReportDocument *document = (GdaReportDocument *) object;
 
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
+	g_return_if_fail (GDA_REPORT_IS_DOCUMENT (document));
 
-	/* free memory */
+	xmlFreeDoc (document->priv->doc);
 	g_free (document->priv);
 	document->priv = NULL;
-
-	/* chain to parent class */
+	
 	parent_class->finalize (object);
 }
 
+
 GType
 gda_report_document_get_type (void)
 {
@@ -124,11 +101,27 @@
 			0,
 			(GInstanceInitFunc) gda_report_document_init
 		};
-		type = g_type_register_static (PARENT_TYPE, "GdaReportDocument", &info, 0);
+		type = g_type_register_static (G_TYPE_OBJECT, "GdaReportDocument", &info, 0);
 	}
 	return type;
 }
 
+
+/*
+ * gda_report_document_construct
+ */
+GdaReportDocument *
+gda_report_document_construct (GdaReportValid *valid)
+{
+	GdaReportDocument *document;
+
+	document = g_object_new (GDA_TYPE_REPORT_DOCUMENT, NULL);
+	document->priv->valid = valid;
+	
+	return document;
+}
+
+
 /**
  * gda_report_document_new
  *
@@ -138,39 +131,49 @@
  * Returns: the newly created object.
  */
 GdaReportDocument *
-gda_report_document_new (void)
+gda_report_document_new (GdaReportValid *valid)
 {
 	GdaReportDocument *document;
 
-	document = g_object_new (GDA_TYPE_REPORT_DOCUMENT, NULL);
-	gda_xml_document_construct (GDA_XML_DOCUMENT (document), OBJECT_REPORT);
-
+	g_return_val_if_fail (GDA_IS_REPORT_VALID(valid), NULL);
+	document = gda_report_document_construct(valid);
+	document->priv->doc = xmlNewDoc ("1.0");
+	document->priv->doc->intSubset = gda_report_valid_to_dom (valid);
+	
 	return document;
 }
 
+
 /**
  * gda_report_document_new_from_string
  */
 GdaReportDocument *
-gda_report_document_new_from_string (const gchar *xml)
+gda_report_document_new_from_string (const gchar *xml, 
+				     GdaReportValid *valid)
 {
 	GdaReportDocument *document;
 
 	g_return_val_if_fail (xml != NULL, NULL);
+	g_return_val_if_fail (GDA_IS_REPORT_VALID(valid), NULL);
 
-	/* parse the XML string */
-	document = g_object_new (GDA_TYPE_REPORT_DOCUMENT, NULL);
-
-	GDA_XML_DOCUMENT (document)->doc = xmlParseMemory (xml, strlen (xml));
-	if (!GDA_XML_DOCUMENT (document)->doc) {
+	document = gda_report_document_construct (valid);
+	document->priv->doc = xmlParseMemory (xml, strlen (xml));
+	if (!document->priv->doc) {
 		gda_log_error (_("Could not parse XML document"));
 		g_object_unref (G_OBJECT (document));
 		return NULL;
 	}
-
-	GDA_XML_DOCUMENT (document)->root =
-		xmlDocGetRootElement (GDA_XML_DOCUMENT (document)->doc);
-
+	document->priv->doc->intSubset = gda_report_valid_to_dom (valid);
+	
+	if (!gda_report_valid_validate_document (
+				document->priv->valid, 
+				document->priv->doc))
+	{
+		gda_log_error (_("XML document is not valid"));
+		g_object_unref (G_OBJECT (document));
+		return NULL;
+	}			
+	
 	return document;
 }
 
@@ -178,668 +181,104 @@
  * gda_report_document_new_from_uri
  */
 GdaReportDocument *
-gda_report_document_new_from_uri (const gchar *uri)
+gda_report_document_new_from_uri (const gchar *uri,
+				  GdaReportValid *valid)
 {
 	gchar *body;
 	GdaReportDocument *document;
 
 	g_return_val_if_fail (uri != NULL, NULL);
+	g_return_val_if_fail (GDA_IS_REPORT_VALID(valid), NULL);
 
-	/* get the file contents from the given URI */
 	body = gda_file_load (uri);
-	if (!body) {
+	if (!body) 
+	{
 		gda_log_error (_("Could not get file from %s"), uri);
 		return NULL;
 	}
 
-	/* create the GdaReportDocument object */
-	document = gda_report_document_new_from_string (body);
+	document = gda_report_document_new_from_string (body, valid);
 	g_free (body);
 
 	return document;
 }
 
 
-/**
- * gda_report_document_get_report_style
- */
-GdaReportStyle
-gda_report_document_get_report_style (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->reportstyle;
-}
-
-/**
- * gda_report_document_set_report_style
- */
-void
-gda_report_document_set_report_style (GdaReportDocument *document,
-				     GdaReportStyle reportstyle)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->reportstyle = reportstyle;
-}
-
-/**
- * gda_report_document_get_page_size
- */
-GdaReportPageSize
-gda_report_document_get_page_size (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->pagesize;
-}
-
-/**
- * gda_report_document_set_page_size
- */
-void
-gda_report_document_set_page_size (GdaReportDocument *document,
-				  GdaReportPageSize pagesize)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->pagesize = pagesize;
-}
-
-/**
- * gda_report_document_get_orientation
- */
-GdaReportOrientation
-gda_report_document_get_orientation (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->orientation;
-}
-
-/**
- * gda_report_document_set_orientation
- */
-void
-gda_report_document_set_orientation (GdaReportDocument *document,
-				     GdaReportOrientation orientation)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->orientation = orientation;
-}
-
-/**
- * gda_report_document_get_units
- */
-GdaReportUnits
-gda_report_document_get_units (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->units;
-}
-
-/**
- * gda_report_document_set_units
- */
-void
-gda_report_document_set_units (GdaReportDocument *document,
-			       GdaReportUnits units)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->units = units;
-}
-
-/**
- * gda_report_document_get_top_margin
- */
-gfloat
-gda_report_document_get_top_margin (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->topmargin;
-}
-
-/**
- * gda_report_document_set_top_margin
- */
-void
-gda_report_document_set_top_margin (GdaReportDocument *document,
-				   gfloat topmargin)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->topmargin = topmargin;
-}
-
-/**
- * gda_report_document_get_bottom_margin
- */
-gfloat
-gda_report_document_get_bottom_margin (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->bottommargin;
-}
-
-/**
- * gda_report_document_set_bottom_margin
- */
-void
-gda_report_document_set_bottom_margin (GdaReportDocument *document,
-				      gfloat bottommargin)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->bottommargin = bottommargin;
-}
-
-/**
- * gda_report_document_get_left_margin
- */
-gfloat
-gda_report_document_get_left_margin (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->leftmargin;
-}
-
-/**
- * gda_report_document_set_left_margin
- */
-void
-gda_report_document_set_left_margin (GdaReportDocument *document,
-				    gfloat leftmargin)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->leftmargin = leftmargin;
-}
-
-/**
- * gda_report_document_get_right_margin
- */
-gfloat
-gda_report_document_get_right_margin (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->rightmargin;
-}
-
-/**
- * gda_report_document_set_righ_tmargin
- */
-void
-gda_report_document_set_right_margin (GdaReportDocument *document,
-				     gfloat rightmargin)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->rightmargin = rightmargin;
-}
-
-/**
- * gda_report_document_get_bg_color
- */
-GdaReportColor *
-gda_report_document_get_bg_color (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
-
-	return document->priv->bgcolor;
-}
-
-/**
- * gda_report_document_set_bg_color
- */
-void
-gda_report_document_set_bg_color (GdaReportDocument *document,
-				 GdaReportColor *bgcolor)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->bgcolor = bgcolor;
-}
-
-/**
- * gda_report_document_get_fg_color
- */
-GdaReportColor *
-gda_report_document_get_fg_color (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
-
-	return document->priv->fgcolor;
-}
-
-/**
- * gda_report_document_set_fg_color
- */
-void
-gda_report_document_set_fg_color (GdaReportDocument *document,
-				 GdaReportColor *fgcolor)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->fgcolor = fgcolor;
-}
-
-/**
- * gda_report_document_get_border_color
- */
-GdaReportColor *
-gda_report_document_get_border_color (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
-
-	return document->priv->bordercolor;
-}
-
-/**
- * gda_report_document_set_border_color
- */
-void
-gda_report_document_set_border_color (GdaReportDocument *document,
-				     GdaReportColor *bordercolor)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->bordercolor = bordercolor;
-}
-
-/**
- * gda_report_document_get_border_width
- */
-gfloat
-gda_report_document_get_border_width (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->borderwidth;
-}
-
-/**
- * gda_report_document_set_border_width
- */
-void
-gda_report_document_set_border_width (GdaReportDocument *document,
-				     gfloat borderwidth)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->borderwidth = borderwidth;
-}
-
-/**
- * gda_report_document_get_border_style
- */
-GdaReportLineStyle
-gda_report_document_get_border_style (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->borderstyle;
-}
-
-/**
- * gda_report_document_set_border_style
- */
-void
-gda_report_document_set_border_style (GdaReportDocument *document,
-				     GdaReportLineStyle borderstyle)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->borderstyle = borderstyle;
-}
-
-/**
- * gda_report_document_get_font_family
- */
-gchar *
-gda_report_document_get_font_family (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
-
-	return document->priv->fontfamily;
-}
-
-/**
- * gda_report_document_set_font_family
- */
-void
-gda_report_document_set_font_family (GdaReportDocument *document,
-				    gchar *fontfamily)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->fontfamily = fontfamily;
-}
-
-/**
- * gda_report_document_get_font_size
- */
-gint
-gda_report_document_get_font_size (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->fontsize;
-}
-
-/**
- * gda_report_document_set_font_size
- */
-void
-gda_report_document_set_font_size (GdaReportDocument *document,
-				  gint fontsize)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->fontsize = fontsize;
-}
-
-/**
- * gda_report_document_get_font_weight
- */
-GdaReportFontWeight
-gda_report_document_get_font_weight (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->fontweight;
-}
-
-/**
- * gda_report_document_set_font_weight
- */
-void
-gda_report_document_set_font_weight (GdaReportDocument *document,
-				    GdaReportFontWeight fontweight)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->fontweight = fontweight;
-}
-
-/**
- * gda_report_document_get_font_italic
- */
-gboolean
-gda_report_document_get_font_italic (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->fontitalic;
-}
-
-/**
- * gda_report_document_set_font_italic
+/*
+ * gda_report_document_to_dom
  */
-void
-gda_report_document_set_font_italic (GdaReportDocument *document,
-				    gboolean fontitalic)
+xmlDocPtr 
+gda_report_document_to_dom (GdaReportDocument *document) 
 {
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->fontitalic = fontitalic;
+	g_return_val_if_fail (GDA_REPORT_IS_DOCUMENT (document), NULL);
+	return document->priv->doc;
 }
 
-/**
- * gda_report_document_get_halignment
- */
-GdaReportHAlignment
-gda_report_document_get_halignment (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->halignment;
-}
 
-/**
- * gda_report_document_set_halignment
+/*
+ * gda_report_document_get_valid
  */
-void
-gda_report_document_set_halignment (GdaReportDocument *document,
-				    GdaReportHAlignment alignment)
+GdaReportValid*
+gda_report_document_get_valid (GdaReportDocument *document)
 {
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->halignment = alignment;
+	g_return_val_if_fail (GDA_REPORT_IS_DOCUMENT (document), NULL);
+	return document->priv->valid;
 }
 
-/**
- * gda_report_document_get_valignment
- */
-GdaReportVAlignment
-gda_report_document_get_valignment (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
 
-	return document->priv->valignment;
-}
-
-/**
- * gda_report_document_set_valignment
- */
-void
-gda_report_document_set_valignment (GdaReportDocument *document,
-				    GdaReportVAlignment alignment)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->valignment = alignment;
-}
-
-/**
- * gda_report_document_get_word_wrap
+/*
+ * gda_report_document_set_root_item
  */
 gboolean
-gda_report_document_get_word_wrap (GdaReportDocument *document)
+gda_report_document_set_root_item (GdaReportDocument *document,
+				   GdaReportItem *item)
 {
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->wordwrap;
-}
-
-/**
- * gda_report_document_set_word_wrap
- */
-void
-gda_report_document_set_word_wrap (GdaReportDocument *document,
-				  gboolean wordwrap)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->wordwrap = wordwrap;
-}
-
-/**
- * gda_report_document_get_neg_value_color
- */
-GdaReportColor *
-gda_report_document_get_neg_value_color (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
-
-	return document->priv->negvaluecolor;
-}
-
-/**
- * gda_report_document_set_neg_value_color
- */
-void
-gda_report_document_set_neg_value_color (GdaReportDocument *document,
-				       GdaReportColor *negvaluecolor)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->negvaluecolor = negvaluecolor;
-}
-
-/**
- * gda_report_document_get_date_format
- */
-gchar *
-gda_report_document_get_date_format (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
-
-	return document->priv->dateformat;
-}
-
-/**
- * gda_report_document_set_date_format
- */
-void
-gda_report_document_set_date_format (GdaReportDocument *document,
-				     gchar *dateformat)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->dateformat = dateformat;
+	xmlNodePtr node;
+	
+	g_return_val_if_fail (GDA_REPORT_IS_DOCUMENT (document), FALSE);
+	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT (item), FALSE);
+
+	node = gda_report_item_to_dom(item);
+	if (node != NULL)
+	{
+		xmlDocSetRootElement (document->priv->doc, node);
+		return TRUE;
+	}
+	else
+		return FALSE;
 }
 
-/**
- * gda_report_document_get_precision
- */
-gint8
-gda_report_document_get_precision (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
 
-	return document->priv->precision;
-}
-
-/**
- * gda_report_document_set_precision
- */
-void
-gda_report_document_set_precision (GdaReportDocument *document,
-				   gint8 precision)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->precision = precision;
-}
-
-/**
- * gda_report_document_get_currency
+/*
+ * gda_report_document_get_root_item
  */
-gchar *
-gda_report_document_get_currency (GdaReportDocument *document)
+GdaReportItem *
+gda_report_document_get_root_item (GdaReportDocument *document)
 {
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
+	xmlNodePtr node;
+	
+	g_return_val_if_fail (GDA_REPORT_IS_DOCUMENT (document), NULL);
+	node = xmlDocGetRootElement (document->priv->doc);
 
-	return document->priv->currency;
+	return gda_report_item_report_new_from_dom (node);
 }
 
-/**
- * gda_report_document_set_currency
- */
-void
-gda_report_document_set_currency (GdaReportDocument *document,
-				  gchar *currency)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
 
-	document->priv->currency = currency;
-}
-
-/**
- * gda_report_document_get_comma_separator
+/*
+ * gda_report_document_save_file
  */
 gboolean
-gda_report_document_get_comma_separator (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->commaseparator;
-}
-
-/**
- * gda_report_document_set_comma_separator
- */
-void
-gda_report_document_set_comma_separator (GdaReportDocument *document,
-					 gboolean commaseparator)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->commaseparator = commaseparator;
-}
-
-/**
- * gda_report_document_get_line_width
- */
-gfloat
-gda_report_document_get_line_width (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->linewidth;
-}
-
-/**
- * gda_report_document_set_line_width
- */
-void
-gda_report_document_set_line_width (GdaReportDocument *document,
-				   gfloat linewidth)
+gda_report_document_save_file (const char *filename,
+			       GdaReportDocument *document)
 {
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
+	g_return_val_if_fail (GDA_REPORT_IS_DOCUMENT (document), FALSE);
 
-	document->priv->linewidth = linewidth;
+	if (xmlSaveFile (filename, document->priv->doc))		
+		return TRUE;
+	else
+		return FALSE;
 }
 
-/**
- * gda_report_document_get_line_color
- */
-GdaReportColor *
-gda_report_document_get_line_color (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), NULL);
 
-	return document->priv->linecolor;
-}
 
-/**
- * gda_report_document_set_line_color
- */
-void
-gda_report_document_set_line_color (GdaReportDocument *document,
-				    GdaReportColor *linecolor)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
 
-	document->priv->linecolor = linecolor;
-}
-
-/**
- * gda_report_document_get_line_style
- */
-GdaReportLineStyle
-gda_report_document_get_line_style (GdaReportDocument *document)
-{
-	g_return_val_if_fail (GDA_IS_REPORT_DOCUMENT (document), -1);
-
-	return document->priv->linestyle;
-}
-
-/**
- * gda_report_document_set_line_style
- */
-void
-gda_report_document_set_line_style (GdaReportDocument *document,
-				   GdaReportLineStyle linestyle)
-{
-	g_return_if_fail (GDA_IS_REPORT_DOCUMENT (document));
-
-	document->priv->linestyle = linestyle;
-}
Index: libgda/report/libgda-report/gda-report-document.h
===================================================================
RCS file: /cvs/gnome/libgda/report/libgda-report/gda-report-document.h,v
retrieving revision 1.5
diff -u -r1.5 gda-report-document.h
--- libgda/report/libgda-report/gda-report-document.h	18 Sep 2002 23:27:30 -0000	1.5
+++ libgda/report/libgda-report/gda-report-document.h	7 Dec 2002 22:48:10 -0000
@@ -3,6 +3,7 @@
  *
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
+ *	Santi Camps <scamps users sourceforge net>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -23,119 +24,60 @@
 #if !defined(__gda_report_document_h__)
 #  define __gda_report_document_h__
 
-#include <libgda/gda-xml-document.h>
-#include <libgda-report/gda-report-types.h>
+#include <libxml/tree.h>
+#include <glib-object.h>
+#include <libgda-report/gda-report-valid.h>
+#include <libgda-report/gda-report-item.h>
 
 G_BEGIN_DECLS
 
 #define GDA_TYPE_REPORT_DOCUMENT            (gda_report_document_get_type())
 #define GDA_REPORT_DOCUMENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_REPORT_DOCUMENT, GdaReportDocument))
 #define GDA_REPORT_DOCUMENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_REPORT_DOCUMENT, GdaReportDocumentClass))
-#define GDA_IS_REPORT_DOCUMENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_REPORT_DOCUMENT))
-#define GDA_IS_REPORT_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_REPORT_DOCUMENT))
+#define GDA_REPORT_IS_DOCUMENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_REPORT_DOCUMENT))
+#define GDA_REPORT_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_REPORT_DOCUMENT))
 
 typedef struct _GdaReportDocument GdaReportDocument;
 typedef struct _GdaReportDocumentClass GdaReportDocumentClass;
 typedef struct _GdaReportDocumentPrivate GdaReportDocumentPrivate;
+typedef struct _GdaReportValidator GdaReportValidator;
+typedef struct _GdaReportValidatorPrivate GdaReportValidatorPrivate;
 
 struct _GdaReportDocument {
-	GdaXmlDocument document;
+	GObject object;
 	GdaReportDocumentPrivate *priv;
 };
 
 struct _GdaReportDocumentClass {
-	GdaXmlDocumentClass parent_class;
+	GObjectClass parent_class;
+};
+
+struct _GdaReportValidator {
+	GdaReportValidatorPrivate *priv;
 };
 
 GType gda_report_document_get_type (void);
-GdaReportDocument   *gda_report_document_new (void);
-GdaReportDocument   *gda_report_document_new_from_string (const gchar * xml);
-GdaReportDocument   *gda_report_document_new_from_uri (const gchar * uri);
-
-GdaReportStyle       gda_report_document_get_report_style (GdaReportDocument *document);
-void                 gda_report_document_set_report_style (GdaReportDocument * document,
-							   GdaReportStyle reportstyle);
-GdaReportPageSize    gda_report_document_get_page_size (GdaReportDocument *document);
-void                 gda_report_document_set_page_size (GdaReportDocument * document,
-							GdaReportPageSize pagesize);
-GdaReportOrientation gda_report_document_get_orientation (GdaReportDocument * document);
-void                 gda_report_document_set_orientation (GdaReportDocument * document,
-							  GdaReportOrientation orientation);
-GdaReportUnits       gda_report_document_get_units (GdaReportDocument *document);
-void                 gda_report_document_set_units (GdaReportDocument * document,
-						    GdaReportUnits units);
-gfloat               gda_report_document_get_top_margin (GdaReportDocument * document);
-void                 gda_report_document_set_top_margin (GdaReportDocument * document,
-							 gfloat topmargin);
-gfloat               gda_report_document_get_bottom_margin (GdaReportDocument * document);
-void                 gda_report_document_set_bottom_margin (GdaReportDocument * document,
-							    gfloat bottommargin);
-gfloat               gda_report_document_get_left_margin (GdaReportDocument * document);
-void                 gda_report_document_set_left_margin (GdaReportDocument * document,
-							  gfloat leftmargin);
-gfloat               gda_report_document_get_right_margin (GdaReportDocument * document);
-void                 gda_report_document_set_right_margin (GdaReportDocument * document,
-							  gfloat rightmargin);
-GdaReportColor      *gda_report_document_get_bg_color (GdaReportDocument *document);
-void                 gda_report_document_set_bg_color (GdaReportDocument * document,
-						       GdaReportColor * bgcolor);
-GdaReportColor      *gda_report_document_get_fg_color (GdaReportDocument *document);
-void                 gda_report_document_set_fg_color (GdaReportDocument * document,
-						       GdaReportColor * fgcolor);
-GdaReportColor      *gda_report_document_get_border_color (GdaReportDocument *document);
-void                 gda_report_document_set_border_color (GdaReportDocument * document,
-							   GdaReportColor * bordercolor);
-gfloat               gda_report_document_get_border_width (GdaReportDocument * document);
-void                 gda_report_document_set_border_width (GdaReportDocument * document,
-							   gfloat borderwidth);
-GdaReportLineStyle   gda_report_document_get_border_style (GdaReportDocument * document);
-void                 gda_report_document_set_border_style (GdaReportDocument * document,
-							   GdaReportLineStyle borderstyle);
-gchar               *gda_report_document_get_font_family (GdaReportDocument * document);
-void                 gda_report_document_set_font_family (GdaReportDocument * document,
-							  gchar * fontfamily);
-gint                 gda_report_document_get_font_size (GdaReportDocument * document);
-void                 gda_report_document_set_font_size (GdaReportDocument * document,
-							gint fontsize);
-GdaReportFontWeight  gda_report_document_get_font_weight (GdaReportDocument *document);
-void                 gda_report_document_set_font_weight (GdaReportDocument * document,
-							  GdaReportFontWeight fontweight);
-gboolean             gda_report_document_get_font_italic (GdaReportDocument * document);
-void                 gda_report_document_set_fonti_talic (GdaReportDocument * document,
-							  gboolean fontitalic);
-GdaReportHAlignment  gda_report_document_get_halignment (GdaReportDocument *document);
-void                 gda_report_document_set_halignment (GdaReportDocument * document,
-							 GdaReportHAlignment alignment);
-GdaReportVAlignment  gda_report_document_get_valignment (GdaReportDocument *document);
-void                 gda_report_document_set_valignment (GdaReportDocument * document,
-							 GdaReportVAlignment alignment);
-gboolean             gda_report_document_get_word_wrap (GdaReportDocument * document);
-void                 gda_report_document_set_word_wrap (GdaReportDocument * document,
-							gboolean wordwrap);
-GdaReportColor      *gda_report_document_get_neg_value_color (GdaReportDocument *document);
-void                 gda_report_document_set_neg_value_color (GdaReportDocument * document,
-							      GdaReportColor * negvaluecolor);
-gchar               *gda_report_document_get_date_format (GdaReportDocument * document);
-void                 gda_report_document_set_date_format (GdaReportDocument * document,
-							  gchar * dateformat);
-gint8                gda_report_document_get_precision (GdaReportDocument * document);
-void                 gda_report_document_set_precision (GdaReportDocument * document,
-							gint8 precision);
-gchar               *gda_report_document_get_currency (GdaReportDocument * document);
-void                 gda_report_document_set_currency (GdaReportDocument * document,
-						       gchar * currency);
-gboolean             gda_report_document_get_comma_separator (GdaReportDocument *document);
-void                 gda_report_document_set_comma_separator (GdaReportDocument * document,
-							      gboolean commaseparator);
-gfloat               gda_report_document_get_line_width (GdaReportDocument * document);
-void                 gda_report_document_set_line_width (GdaReportDocument * document,
-							 gfloat linewidth);
-GdaReportColor      *gda_report_document_get_line_color (GdaReportDocument *document);
-void                 gda_report_document_set_line_color (GdaReportDocument * document,
-							 GdaReportColor * linecolor);
-GdaReportLineStyle   gda_report_document_get_line_style (GdaReportDocument *document);
-void                 gda_report_document_set_line_style (GdaReportDocument * document,
-							 GdaReportLineStyle linestyle);
+
+GdaReportDocument *gda_report_document_new (GdaReportValid *valid);
+
+GdaReportDocument *gda_report_document_new_from_string (const gchar * xml, 
+							GdaReportValid *valid);
+
+GdaReportDocument *gda_report_document_new_from_uri (const gchar * uri, 
+						     GdaReportValid *valid);
+
+xmlDocPtr gda_report_document_to_dom (GdaReportDocument *document);
+
+GdaReportValid *gda_report_document_get_valid (GdaReportDocument *document);
+
+gboolean gda_report_document_set_root_item (GdaReportDocument *document,
+	 				    GdaReportItem *item);
+
+GdaReportItem *gda_report_document_get_root_item (GdaReportDocument *document);
+
+gboolean gda_report_document_save_file (const char *filename, 
+					GdaReportDocument *document);
+
 
 G_END_DECLS
 
Index: libgda/report/libgda-report/gda-report-types.h
===================================================================
RCS file: /cvs/gnome/libgda/report/libgda-report/gda-report-types.h,v
retrieving revision 1.2
diff -u -r1.2 gda-report-types.h
--- libgda/report/libgda-report/gda-report-types.h	26 May 2002 01:05:21 -0000	1.2
+++ libgda/report/libgda-report/gda-report-types.h	7 Dec 2002 22:48:11 -0000
@@ -3,6 +3,7 @@
  *
  * AUTHORS:
  *	Carlos Perelló Marín <carlos gnome-db org>
+ *	Santi Camps <scamps users sourceforge net>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -23,71 +24,21 @@
 #if !defined(__gda_report_types_h__)
 #  define __gda_report_types_h__
 
-typedef enum {
-        GDA_REPORT_STYLE_FORM,
-	GDA_REPORT_STYLE_LIST
-} GdaReportStyle;
-
-/* FIXME: This one should come from the available papers not a fixed value */
-typedef enum {
-	GDA_REPORT_PAGE_SIZE_A3,
-	GDA_REPORT_PAGE_SIZE_A4,
-	GDA_REPORT_PAGE_SIZE_A5,
-	GDA_REPORT_PAGE_SIZE_A6,
-	GDA_REPORT_PAGE_SIZE_B3,
-	GDA_REPORT_PAGE_SIZE_B4,
-	GDA_REPORT_PAGE_SIZE_B5,
-	GDA_REPORT_PAGE_SIZE_B6,
-	GDA_REPORT_PAGE_SIZE_LETTER,
-	GDA_REPORT_PAGE_SIZE_LEGAL,
-	GDA_REPORT_PAGE_SIZE_EXECUTIVE
-} GdaReportPageSize;
-
-typedef enum {
-	GDA_REPORT_ORIENTATION_PORTRAIT,
-	GDA_REPORT_ORIENTATION_LANDSCAPE
-} GdaReportOrientation;
-
-typedef enum {
-	GDA_REPORT_UNITS_INCH,
-	GDA_REPORT_UNITS_CM,
-	GDA_REPORT_UNITS_PT
-} GdaReportUnits;
-
-typedef enum {
-	GDA_REPORT_LINE_STYLE_NONE,
-	GDA_REPORT_LINE_STYLE_SOLID,
-	GDA_REPORT_LINE_STYLE_DASH,
-	GDA_REPORT_LINE_STYLE_DOT,
-	GDA_REPORT_LINE_STYLE_DASH_DOT,
-	GDA_REPORT_LINE_STYLE_DASH_DOT_DOT
-} GdaReportLineStyle;
-
-typedef enum {
-	GDA_REPORT_FONT_WEIGHT_LIGHT,
-	GDA_REPORT_FONT_WEIGHT_NORMAL,
-	GDA_REPORT_FONT_WEIGHT_SEMIBOLD,
-	GDA_REPORT_FONT_WEIGHT_BOLD,
-	GDA_REPORT_FONT_WEIGHT_BLACK
-} GdaReportFontWeight;
-
-typedef enum {
-	GDA_REPORT_H_ALIGNMENT_STANDAR,
-	GDA_REPORT_H_ALIGNMENT_LEFT,
-	GDA_REPORT_H_ALIGNMENT_CENTER,
-	GDA_REPORT_H_ALIGNMENT_RIGHT
-} GdaReportHAlignment;
-
-typedef enum {
-	GDA_REPORT_V_ALIGNMENT_TOP,
-	GDA_REPORT_V_ALIGNMENT_CENTER,
-	GDA_REPORT_V_ALIGNMENT_BOTTOM
-} GdaReportVAlignment;
-
-typedef struct {
-	guint8 red;
-	guint8 blue;
-	guint8 yellow;
-} GdaReportColor;
+#define GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH	 7
+
+typedef struct _GdaReportColor GdaReportColor;
+typedef struct _GdaReportColorPrivate GdaReportColorPrivate;
+
+struct _GdaReportColor {
+	GdaReportColorPrivate *priv;
+};
+
+
+GdaReportColor *gda_report_types_new_color (guint8 red, guint8 blue, guint8 yellow);
+
+gchar *gda_report_types_color_to_value (GdaReportColor *color);
+
+GdaReportColor *gda_report_types_value_to_color (gchar *value);
+
 
 #endif
Index: libgda/report/libgda-report/gda-report.h
===================================================================
RCS file: /cvs/gnome/libgda/report/libgda-report/gda-report.h,v
retrieving revision 1.4
diff -u -r1.4 gda-report.h
--- libgda/report/libgda-report/gda-report.h	14 May 2002 20:43:54 -0000	1.4
+++ libgda/report/libgda-report/gda-report.h	7 Dec 2002 22:48:11 -0000
@@ -3,6 +3,7 @@
  *
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
+ *	Santi Camps <scamps users sourceforge net>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -24,5 +25,10 @@
 #  define __gda_report_h__
 
 #include <libgda-report/gda-report-document.h>
+#include <libgda-report/gda-report-valid.h>
+#include <libgda-report/gda-report-types.h>
+#include <libgda-report/gda-report-item.h>
+#include <libgda-report/gda-report-item-report.h>
+#include <libgda-report/gda-report-item-reportheader.h>
 
 #endif
/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <libgda/gda-intl.h>
#include <libgda/gda-log.h>
#include <libgda/gda-util.h>
#include <libgda-report/gda-report-valid.h>
#include <libgda-report/gda-report-item-reportheader.h>
#include <libgda-report/gda-report-item-report.h>

#define ITEM_REPORT_NAME	"report"

static void gda_report_item_report_class_init (GdaReportItemReportClass *klass);
static void gda_report_item_report_init       (GdaReportItemReport *valid,
					       GdaReportItemReportClass *klass);
static void gda_report_item_report_finalize   (GObject *object);

static GdaReportItemClass *parent_class = NULL;

/*
 * GdaReportItemReport class implementation
 */
static void
gda_report_item_report_class_init (GdaReportItemReportClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

	parent_class = g_type_class_peek_parent (klass);
	object_class->finalize = gda_report_item_report_finalize;
}


static void
gda_report_item_report_init (GdaReportItemReport *item, 
		      	     GdaReportItemReportClass *klass)
{
	
}


static void
gda_report_item_report_finalize (GObject *object)
{
	g_return_if_fail (GDA_REPORT_IS_ITEM_REPORT (object));

	if(G_OBJECT_CLASS(parent_class)->finalize) \
                (* G_OBJECT_CLASS(parent_class)->finalize)(object);
}


GType
gda_report_item_report_get_type (void)
{
	static GType type = 0;

	if (!type) {
		static const GTypeInfo info = {
			sizeof (GdaReportItemReportClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gda_report_item_report_class_init,
			NULL,
			NULL,
			sizeof (GdaReportItemReport),
			0,
			(GInstanceInitFunc) gda_report_item_report_init
		};
		type = g_type_register_static (GDA_REPORT_TYPE_ITEM, "GdaReportItemReport", &info, 0);
	}
	return type;
}


/*
 * gda_report_item_report_new
 */
GdaReportItem *
gda_report_item_report_new (GdaReportValid *valid)
{
	GdaReportItem *item;
	
	item = g_object_new (GDA_REPORT_TYPE_ITEM_REPORT, NULL);
	item = gda_report_item_new (valid, ITEM_REPORT_NAME);
	return item;
}


/*
 * gda_report_item_report_new_from_dom
 */
GdaReportItem *
gda_report_item_report_new_from_dom (xmlNodePtr node)
{
	GdaReportItem *item;

	g_return_val_if_fail (node != NULL, NULL);
	item = g_object_new (GDA_REPORT_TYPE_ITEM_REPORT, NULL);
	GDA_REPORT_ITEM(item)->priv->valid = gda_report_valid_new_from_dom(xmlGetIntSubset(node->doc));
	GDA_REPORT_ITEM(item)->priv->node = node;	
	
	return item;	
}


/*
 * gda_report_item_report_get_reportheader
 */
GdaReportItem *
gda_report_item_report_get_reportheader (GdaReportItemReport *item)
{
	xmlNodePtr node;
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), NULL);
	node = xmlGetLastChild (GDA_REPORT_ITEM(item)->priv->node);
	while ((node != NULL) && (g_ascii_strcasecmp(node->name, "reportheader") != 0)) 
		node = node->prev;

	if (node == NULL)
	{
		gda_log_error ("There is no report header in this report \n");
		return NULL;
	}
	else
		return gda_report_item_reportheader_new_from_dom(node);
}


/*
 * gda_report_item_report_set_reportstyle
 */
gboolean 
gda_report_item_report_set_reportstyle (GdaReportItemReport *item,
					const gchar *value)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "reportstyle", value); 
}


/*
 * gda_report_item_report_get_reportstyle 
 */
gchar * 
gda_report_item_report_get_reportstyle (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), NULL);
	return gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "reportstyle");
}


/*
 * gda_report_item_report_set_pagesize
 */
gboolean 
gda_report_item_report_set_pagesize (GdaReportItemReport *item,
				     const gchar *value)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "pagesize", value); 
}


/*
 * gda_report_item_report_get_pagesize
 */
gchar * 
gda_report_item_report_get_pagesize (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), NULL);
	return gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "pagesize");
}


/*
 * gda_report_item_report_set_orientation
 */
gboolean 
gda_report_item_report_set_orientation (GdaReportItemReport *item,
				        const gchar *value)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "orientation", value); 
}


/*
 * gda_report_item_report_get_orientation
 */
gchar * 
gda_report_item_report_get_orientation (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), NULL);
	return gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "orientation");
}


/*
 * gda_report_item_report_set_units
 */
gboolean 
gda_report_item_report_set_units (GdaReportItemReport *item,
				  const gchar *value)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "units", value); 
}


/*
 * gda_report_item_report_get_units
 */
gchar * 
gda_report_item_report_get_units (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), NULL);
	return gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "units");
}


/*
 * gda_report_item_report_set_topmargin
 */
gboolean 
gda_report_item_report_set_topmargin (GdaReportItemReport *item,
				      const gdouble value)
{
	gchar c_value[GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH];
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	if (g_ascii_dtostr (c_value, GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH, value) == NULL) 
	{
		gda_log_error (_("%f is not a valid topmargin value\n"), value);
		return FALSE;
	}
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "topmargin", c_value); 
}


/*
 * gda_report_item_report_get_topmargin
 */
gdouble 
gda_report_item_report_get_topmargin (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), 0);
	return g_ascii_strtod (gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "topmargin"), NULL);
}


/*
 * gda_report_item_report_set_bottommargin
 */
gboolean 
gda_report_item_report_set_bottommargin (GdaReportItemReport *item,
				         const gdouble value)
{
	gchar c_value[GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH];
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	if (g_ascii_dtostr (c_value, GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH, value) == NULL) 
	{
		gda_log_error (_("%f is not a valid bottommargin value\n"), value);
		return FALSE;
	}
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "bottommargin", c_value); 
}


/*
 * gda_report_item_report_get_bottommargin
 */
gdouble 
gda_report_item_report_get_bottommargin (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), 0);
	return g_ascii_strtod (gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "bottommargin"), NULL);
}


/*
 * gda_report_item_report_set_leftmargin
 */
gboolean 
gda_report_item_report_set_leftmargin (GdaReportItemReport *item,
				      const gdouble value)
{
	gchar c_value[GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH];
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	if (g_ascii_dtostr (c_value, GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH, value) == NULL) 
	{
		gda_log_error (_("%f is not a valid leftmargin value\n"), value);
		return FALSE;
	}
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "leftmargin", c_value); 
}


/*
 * gda_report_item_report_get_leftmargin
 */
gdouble 
gda_report_item_report_get_leftmargin (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), 0);
	return g_ascii_strtod (gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "leftmargin"), NULL);
}


/*
 * gda_report_item_report_set_rightmargin
 */
gboolean 
gda_report_item_report_set_rightmargin (GdaReportItemReport *item,
				      const gdouble value)
{
	gchar c_value[GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH];
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	if (g_ascii_dtostr (c_value, GDA_REPORT_NUMERIC_ATTRIBUTE_LENGTH, value) == NULL) 
	{
		gda_log_error (_("%f is not a valid rightmargin value\n"), value);
		return FALSE;
	}
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "rightmargin", c_value); 
}


/*
 * gda_report_item_report_get_rightmargin
 */
gdouble 
gda_report_item_report_get_rightmargin (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), 0);
	return g_ascii_strtod (gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "rigthmargin"), NULL);
}


/*
 * gda_report_item_report_set_bgcolor
 */
gboolean 
gda_report_item_report_set_bgcolor (GdaReportItemReport *item,
				    GdaReportColor *color)
{
	gchar *value;
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), FALSE);
	value = gda_report_types_color_to_value (color);
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "bgcolor", value);
}


/*
 * gda_report_item_report_get_bgcolor
 */
GdaReportColor * 
gda_report_item_report_get_bgcolor (GdaReportItemReport *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORT(item), NULL);
	return gda_report_types_value_to_color (gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "bgcolor"));
}


/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined(__gda_report_item_report_h__)
#  define __gda_report_item_report_h__

#include <glib-object.h>
#include <libgda-report/gda-report-item.h>
#include <libgda-report/gda-report-types.h>


G_BEGIN_DECLS

#define GDA_REPORT_TYPE_ITEM_REPORT		(gda_report_item_report_get_type())
#define GDA_REPORT_ITEM_REPORT(obj)		(G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_REPORT_TYPE_ITEM_REPORT, GdaReportItemReport))
#define GDA_REPORT_ITEM_REPORT_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST (klass, GDA_REPORT_TYPE_ITEM_REPORT, GdaReportItemReportClass))
#define GDA_REPORT_IS_ITEM_REPORT(obj)		(G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_REPORT_TYPE_ITEM_REPORT))
#define GDA_REPORT_IS_ITEM_REPORT_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), GDA_REPORT_TYPE_ITEM_REPORT))

typedef struct _GdaReportItemReport GdaReportItemReport;
typedef struct _GdaReportItemReportClass GdaReportItemReportClass;

struct _GdaReportItemReport {
	GdaReportItem object;
};

struct _GdaReportItemReportClass {
	GdaReportItemClass parent_class;
};


GType gda_report_item_report_get_type (void);

GdaReportItem *gda_report_item_report_new (GdaReportValid *valid);

GdaReportItem *gda_report_item_report_new_from_dom (xmlNodePtr node);

gboolean gda_report_item_report_set_reportstyle (GdaReportItemReport *item, 
						const gchar* value);

GdaReportItem *gda_report_item_report_get_reportheader (GdaReportItemReport *item);

gchar *gda_report_item_report_get_reportstyle (GdaReportItemReport *item);

gboolean gda_report_item_report_set_pagesize (GdaReportItemReport *item,
					      const gchar *value);

gchar *gda_report_item_report_get_pagesize (GdaReportItemReport *item);

gboolean gda_report_item_report_set_orientation (GdaReportItemReport *item,
				                 const gchar *value);
						 
gchar *gda_report_item_report_get_orientation (GdaReportItemReport *item);
						 
gboolean gda_report_item_report_set_units (GdaReportItemReport *item,
				           const gchar *value);
					   
gchar *gda_report_item_report_get_units (GdaReportItemReport *item);

gboolean gda_report_item_report_set_topmargin (GdaReportItemReport *item,
				               const gdouble value);

gdouble gda_report_item_report_get_topmargin (GdaReportItemReport *item);

gboolean gda_report_item_report_set_bottommargin (GdaReportItemReport *item,
				                  const gdouble value);

gdouble gda_report_item_report_get_bottommargin (GdaReportItemReport *item);

gboolean gda_report_item_report_set_leftmargin (GdaReportItemReport *item,
				                const gdouble value);

gdouble gda_report_item_report_get_leftmargin (GdaReportItemReport *item);

gboolean gda_report_item_report_set_rightmargin (GdaReportItemReport *item,
				                 const gdouble value);

gdouble gda_report_item_report_get_rightmargin (GdaReportItemReport *item);

gboolean gda_report_item_report_set_bgcolor (GdaReportItemReport *item,
	 			             GdaReportColor *value);

GdaReportColor *gda_report_item_report_get_bgcolor (GdaReportItemReport *item);


G_END_DECLS


#endif
/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <libgda/gda-intl.h>
#include <libgda/gda-log.h>
#include <libgda/gda-util.h>
#include <libgda-report/gda-report-valid.h>
#include <libgda-report/gda-report-item-reportheader.h>

#define ITEM_REPORTHEADER_NAME	"reportheader"

static void gda_report_item_reportheader_class_init (GdaReportItemReportHeaderClass *klass);
static void gda_report_item_reportheader_init       (GdaReportItemReportHeader *valid,
					             GdaReportItemReportHeaderClass *klass);
static void gda_report_item_reportheader_finalize   (GObject *object);

static GdaReportItemClass *parent_class = NULL;

/*
 * GdaReportItemReportHeader class implementation
 */
static void
gda_report_item_reportheader_class_init (GdaReportItemReportHeaderClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

	parent_class = g_type_class_peek_parent (klass);
	object_class->finalize = gda_report_item_reportheader_finalize;
}


static void
gda_report_item_reportheader_init (GdaReportItemReportHeader *item, 
		      	           GdaReportItemReportHeaderClass *klass)
{
	
}


static void
gda_report_item_reportheader_finalize (GObject *object)
{
	g_return_if_fail (GDA_REPORT_IS_ITEM_REPORTHEADER (object));

	if(G_OBJECT_CLASS(parent_class)->finalize) \
                (* G_OBJECT_CLASS(parent_class)->finalize)(object);
}


GType
gda_report_item_reportheader_get_type (void)
{
	static GType type = 0;

	if (!type) {
		static const GTypeInfo info = {
			sizeof (GdaReportItemReportHeaderClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gda_report_item_reportheader_class_init,
			NULL,
			NULL,
			sizeof (GdaReportItemReportHeader),
			0,
			(GInstanceInitFunc) gda_report_item_reportheader_init
		};
		type = g_type_register_static (GDA_REPORT_TYPE_ITEM, "GdaReportItemReportHeader", &info, 0);
	}
	return type;
}


/*
 * gda_report_item_reportheader_new
 */
GdaReportItem *
gda_report_item_reportheader_new (GdaReportValid *valid)
{
	GdaReportItem *item;
	
	item = g_object_new (GDA_REPORT_TYPE_ITEM_REPORTHEADER, NULL);
	item = gda_report_item_new (valid, ITEM_REPORTHEADER_NAME);
	return item;
}


/*
 * gda_report_item_reportheader_new_from_parent
 */
GdaReportItem *
gda_report_item_reportheader_new_from_parent (GdaReportItem *parent)
{
	GdaReportItem *item;
	
	item = g_object_new (GDA_REPORT_TYPE_ITEM_REPORTHEADER, NULL);
	item = gda_report_item_new_child (parent, ITEM_REPORTHEADER_NAME);
	return item;	
}


/*
 * gda_report_item_reportheader_new_from_dom
 */
GdaReportItem *
gda_report_item_reportheader_new_from_dom (xmlNodePtr node)
{
	GdaReportItem *item;

	g_return_val_if_fail (node != NULL, NULL);
	item = g_object_new (GDA_REPORT_TYPE_ITEM_REPORTHEADER, NULL);
	GDA_REPORT_ITEM(item)->priv->valid = gda_report_valid_new_from_dom(xmlGetIntSubset(node->doc));
	GDA_REPORT_ITEM(item)->priv->node = node;	
	
	return item;	
}


/*
 * gda_report_item_reportheader_set_bgcolor
 */
gboolean 
gda_report_item_reportheader_set_bgcolor (GdaReportItemReportHeader *item,
				          GdaReportColor *color)
{
	gchar *value;
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORTHEADER(item), FALSE);
	value = gda_report_types_color_to_value (color);
	return gda_report_item_set_attribute (GDA_REPORT_ITEM(item), "bgcolor", value);
}


/*
 * gda_report_item_reportheader_get_bgcolor
 */
GdaReportColor * 
gda_report_item_reportheader_get_bgcolor (GdaReportItemReportHeader *item)
{
	gchar *value;
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM_REPORTHEADER(item), NULL);
	value = gda_report_item_get_attribute (GDA_REPORT_ITEM(item), "bgcolor");
	return gda_report_types_value_to_color (value);
}


/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined(__gda_report_item_reportheader_h__)
#  define __gda_report_item_reportheader_h__

#include <glib-object.h>
#include <libgda-report/gda-report-item.h>
#include <libgda-report/gda-report-types.h>


G_BEGIN_DECLS

#define GDA_REPORT_TYPE_ITEM_REPORTHEADER		(gda_report_item_reportheader_get_type())
#define GDA_REPORT_ITEM_REPORTHEADER(obj)		(G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_REPORT_TYPE_ITEM_REPORTHEADER, GdaReportItemReportHeader))
#define GDA_REPORT_ITEM_REPORTHEADER_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST (klass, GDA_REPORT_TYPE_ITEM_REPORTHEADER, GdaReportItemReportHeaderClass))
#define GDA_REPORT_IS_ITEM_REPORTHEADER(obj)		(G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_REPORT_TYPE_ITEM_REPORTHEADER))
#define GDA_REPORT_IS_ITEM_REPORTHEADER_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), GDA_REPORT_TYPE_ITEM_REPORTHEADER))

typedef struct _GdaReportItemReportHeader GdaReportItemReportHeader;
typedef struct _GdaReportItemReportHeaderClass GdaReportItemReportHeaderClass;

struct _GdaReportItemReportHeader {
	GdaReportItem object;
};

struct _GdaReportItemReportHeaderClass {
	GdaReportItemClass parent_class;
};


GType gda_report_item_reportheader_get_type (void);

GdaReportItem *gda_report_item_reportheader_new (GdaReportValid *valid);

GdaReportItem *gda_report_item_reportheader_new_from_parent (GdaReportItem *parent);

GdaReportItem *gda_report_item_reportheader_new_from_dom (xmlNodePtr node);

gboolean gda_report_item_reportheader_set_bgcolor (GdaReportItemReportHeader *item,
	 			                   GdaReportColor *value);

GdaReportColor *gda_report_item_reportheader_get_bgcolor (GdaReportItemReportHeader *item);


G_END_DECLS


#endif
/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/valid.h>
#include <libgda/gda-intl.h>
#include <libgda/gda-log.h>
#include <libgda/gda-util.h>
#include <libgda-report/gda-report-item.h>


static void gda_report_item_class_init (GdaReportItemClass *klass);
static void gda_report_item_init       (GdaReportItem *valid,
					   GdaReportItemClass *klass);
static void gda_report_item_finalize   (GObject *object);

static GObjectClass *parent_class = NULL;


/*
 * GdaReportItem class implementation
 */
static void
gda_report_item_class_init (GdaReportItemClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

	parent_class = g_type_class_peek_parent (klass);
	object_class->finalize = gda_report_item_finalize;
}


static void
gda_report_item_init (GdaReportItem *item, 
		         GdaReportItemClass *klass)
{
	g_return_if_fail (GDA_REPORT_IS_ITEM (item));

	item->priv = g_new0 (GdaReportItemPrivate, 1);
	item->priv->node = NULL;
	item->priv->valid = NULL;
}


static void
gda_report_item_finalize (GObject *object)
{
	GdaReportItem *item = (GdaReportItem *) object;

	g_return_if_fail (GDA_REPORT_IS_ITEM (object));

	xmlFreeNode (item->priv->node);
	g_free (item->priv);
	
	parent_class->finalize (object);
}


GType
gda_report_item_get_type (void)
{
	static GType type = 0;

	if (!type) {
		static const GTypeInfo info = {
			sizeof (GdaReportItemClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gda_report_item_class_init,
			NULL,
			NULL,
			sizeof (GdaReportItem),
			0,
			(GInstanceInitFunc) gda_report_item_init
		};
		type = g_type_register_static (G_TYPE_OBJECT, "GdaReportItem", &info, 0);
	}
	return type;
}


/*
 * gda_report_item_new
 *
 * @valid: a #GdaReportValid object
 * @name: name of the item to be created
 *
 * Creates a new item with the given name, and using the given #GdaReportValid object
 *
 * Return: the new #GdaReportItem
 */
GdaReportItem *
gda_report_item_new (GdaReportValid *valid,
		     const gchar *name)
{
	GdaReportItem *item;

	g_return_val_if_fail (GDA_IS_REPORT_VALID (valid), NULL);
	
	item = g_object_new (GDA_REPORT_TYPE_ITEM, NULL);
	item->priv->valid = valid;
	item->priv->node = xmlNewNode (NULL, name);	
	return item;
}


/*
 * gda_report_item_new_child
 *
 * @parent: the parent #GdaReportItem object
 * @name: name of the item to be created
 *
 * Creates a new item with the given name, as a child of the parent object
 *
 * Return: the new #GdaReportItem
 */
GdaReportItem *
gda_report_item_new_child (GdaReportItem *parent,
		           const gchar *name)
{
	GdaReportItem *item;

	g_return_val_if_fail (GDA_REPORT_IS_ITEM (parent), NULL);

	item = g_object_new (GDA_REPORT_TYPE_ITEM, NULL);
	item->priv->valid = parent->priv->valid;
	item->priv->node = xmlNewNode (NULL, name);
	if (xmlAddChild (parent->priv->node, item->priv->node) == NULL)
	{
		gda_log_error (_("Error setting parent of new node"));
		g_object_unref (G_OBJECT(item));
		return NULL;
	}
	
	return item;
}


/*
 * gda_report_item_new_from_dom 
 *
 * @node: a xmlNodePtr, assumed to be a valid gda-report element
 *
 * Creates a new item from a given xml node
 *
 * Return: the new #GdaReportItem
 */
GdaReportItem *
gda_report_item_new_from_dom (xmlNodePtr node)
{
	GdaReportItem *item;

	g_return_val_if_fail (node != NULL, NULL);

	item = g_object_new (GDA_REPORT_TYPE_ITEM, NULL);
	item->priv->valid = gda_report_valid_new_from_dom(xmlGetIntSubset(node->doc));
	item->priv->node = node;

	return item;	
}


/*
 * gda_report_item_to_dom
 *
 * @item: a #GdaReportItem
 *
 * Returns: the xml representation of the item
 */
xmlNodePtr 
gda_report_item_to_dom (GdaReportItem *item)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM (item), NULL);
	return item->priv->node;
}


/*
 * gda_report_item_set_parent
 *
 * @parent: a #GdaReportItem
 * @child: an already created #GdaReportItem
 *
 * Sets child item as a child of parent item
 *
 * Returns: TRUE if all is ok, FALSE otherwise
 */
gboolean
gda_report_item_set_parent (GdaReportItem *parent,
			    GdaReportItem *child)
{
	if (xmlAddChild (parent->priv->node, child->priv->node) == NULL)
	{
		gda_log_error (_("Error setting parent -> child relation"));
		return FALSE;
	}	
	return TRUE;
}


/*
 * gda_report_item_set_attribute
 *
 * @item: a #GdaReportItem object
 * @name: name of the attribute to be set
 * @value: value to be set
 *
 * Validates the attribute and the value and, if all is right,
 * sets the given value to the attribute of given item
 *
 * Returns: TRUE if all is ok, FALSE otherwise
 */
gboolean 
gda_report_item_set_attribute (GdaReportItem *item,
			       const gchar *name,
			       const gchar *value)
{
	xmlAttrPtr attribute;
	
	g_return_val_if_fail (GDA_REPORT_IS_ITEM (item), FALSE);
	
	if (gda_report_valid_validate_attribute (
				item->priv->valid, 
				item->priv->node->name, 
				name, 
				value)) 
	{
		
		attribute = xmlSetProp (item->priv->node, name, value);
		if (attribute == NULL) 
		{
			gda_log_error (_("Error setting value %s to attribute %s of item %s"), 
					value, 
					name, 
					item->priv->node->name); 
			return FALSE;
		}
	}
	else
	{
		return FALSE;
	}
	return TRUE;
}


/*
 * gda_report_item_get_attribute
 * 
 * @item: a #GdaReportItem object
 * @name: an attribute name
 *
 * Returns: the value of given attribute in given item.  If attribute is not set, 
 * but a default value is defined in the DTD, this defaults value is returned
 */
gchar * 
gda_report_item_get_attribute (GdaReportItem *item, 
			       const gchar *name)
{
	g_return_val_if_fail (GDA_REPORT_IS_ITEM (item), NULL);
	return xmlGetProp(item->priv->node, name);
}

/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined(__gda_report_item_h__)
#  define __gda_report_item_h__

#include <glib-object.h>
#include <libxml/tree.h>
#include <libgda-report/gda-report-valid.h>

G_BEGIN_DECLS

#define GDA_REPORT_TYPE_ITEM            (gda_report_item_get_type())
#define GDA_REPORT_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_REPORT_TYPE_ITEM, GdaReportItem))
#define GDA_REPORT_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_REPORT_TYPE_ITEM, GdaReportItemClass))
#define GDA_REPORT_IS_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_REPORT_TYPE_ITEM))
#define GDA_REPORT_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_REPORT_TYPE_ITEM))

typedef struct _GdaReportItem GdaReportItem;
typedef struct _GdaReportItemClass GdaReportItemClass;
typedef struct _GdaReportItemPrivate GdaReportItemPrivate;

struct _GdaReportItem {
	GObject object;
	GdaReportItemPrivate *priv;
};

struct _GdaReportItemClass {
	GObjectClass parent_class;
};

/* Private structure in .h allowing use it in descendent classes */
struct _GdaReportItemPrivate {
	xmlNodePtr node;
	GdaReportValid *valid;
};


GType gda_report_item_get_type (void);

GdaReportItem *gda_report_item_new (GdaReportValid *valid,
				    const gchar *name);

GdaReportItem *gda_report_item_new_child (GdaReportItem *parent, 
				          const gchar *name);

GdaReportItem *gda_report_item_new_from_dom (xmlNodePtr node);

xmlNodePtr gda_report_item_to_dom (GdaReportItem *item);

gboolean gda_report_item_set_parent (GdaReportItem *parent,
				     GdaReportItem *child);

gboolean gda_report_item_set_attribute (GdaReportItem *item,
	 			        const gchar *name,
				        const gchar *value);

gchar *gda_report_item_get_attribute (GdaReportItem *item, 
				      const gchar *name);

G_END_DECLS


#endif
/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <glib.h>
#include <libgda/gda-intl.h>
#include <libgda/gda-log.h>
#include <libgda/gda-util.h>
#include <libgda-report/gda-report-types.h>

#define GDA_REPORT_COLOR_VALUE_LENGTH	12

struct _GdaReportColorPrivate {
        guint8 red;
        guint8 blue;
        guint8 yellow;
};


/*
 * gda_report_types_new_color
 */
GdaReportColor *
gda_report_types_new_color (guint8 red, guint8 blue, guint8 yellow)
{
	GdaReportColor *color;

	color = g_new0 (GdaReportColor, 1);
	color->priv = g_new0 (GdaReportColorPrivate, 1);
	color->priv->red = red;
	color->priv->blue = blue;
	color->priv->yellow = yellow;
	
	return color;
}


/*
 * gda_report_valid_color_to_value
 */
gchar *
gda_report_types_color_to_value (GdaReportColor *color)
{
	GString *string;

	g_return_val_if_fail (color != NULL, NULL);
	
	string = g_string_new_len ("", GDA_REPORT_COLOR_VALUE_LENGTH);	
	g_snprintf (string->str, GDA_REPORT_COLOR_VALUE_LENGTH, "%i %i %i", 
		    color->priv->red, color->priv->blue, color->priv->yellow);

	return string->str;
}


/*
 * gda_report_valid_value_to_color
 */
GdaReportColor *
gda_report_types_value_to_color (gchar *value)
{
	GdaReportColor *color;

	g_return_val_if_fail (value != NULL, NULL);

	color = g_new0 (GdaReportColor, 1);
	color->priv = g_new0 (GdaReportColorPrivate, 1);	
	sscanf (value, "%i %i %i", (int *) &color->priv->red, (int *) &color->priv->blue, (int *) &color->priv->yellow);

	return color;
}
/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/valid.h>
#include <libgda/gda-intl.h>
#include <libgda/gda-log.h>
#include <libgda/gda-util.h>
#include <libgda-report/gda-report-valid.h>

#define GDA_REPORT_DTD_URL		LIBGDA_REPORT_DTDDIR"/gda-report.dtd"
#define GDA_REPORT_EXTERNAL_ID		"report"


struct _GdaReportValidPrivate {
	xmlDtdPtr       dtd;
	xmlValidCtxtPtr context;
};


static void gda_report_valid_class_init (GdaReportValidClass *klass);
static void gda_report_valid_init       (GdaReportValid *valid,
					 GdaReportValidClass *klass);
static void gda_report_valid_finalize   (GObject *object);

static GObjectClass *parent_class = NULL;


/*
 * GdaReportValid class implementation
 */
static void
gda_report_valid_class_init (GdaReportValidClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

	parent_class = g_type_class_peek_parent (klass);
	object_class->finalize = gda_report_valid_finalize;
}


static void
gda_report_valid_init (GdaReportValid *valid, 
		       GdaReportValidClass *klass)
{
	g_return_if_fail (GDA_IS_REPORT_VALID (valid));

	/* allocate private structure */
	valid->priv = g_new0 (GdaReportValidPrivate, 1);
	valid->priv->dtd = NULL;
	valid->priv->context = NULL;
}


static void
gda_report_valid_finalize (GObject *object)
{
	GdaReportValid *valid = (GdaReportValid *) object;

	g_return_if_fail (GDA_IS_REPORT_VALID (object));

	/* free memory */
	xmlFreeDtd (valid->priv->dtd);
	g_free (valid->priv->context);
	g_free (valid->priv);
	
	parent_class->finalize (object);
}


GType
gda_report_valid_get_type (void)
{
	static GType type = 0;

	if (!type) {
		static const GTypeInfo info = {
			sizeof (GdaReportValidClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gda_report_valid_class_init,
			NULL,
			NULL,
			sizeof (GdaReportValid),
			0,
			(GInstanceInitFunc) gda_report_valid_init
		};
		type = g_type_register_static (G_TYPE_OBJECT, "GdaReportValid", &info, 0);
	}
	return type;
}

/**
 * gda_report_valid_load 
 * 
 * Loads the gda-report DTD into a #GdaReportValid structure, needed 
 * to create new report items or documents.
 *
 * Returns: The new #GdaReportValid object
 */
GdaReportValid *
gda_report_valid_load (void)
{
	GdaReportValid *valid;

	valid = g_object_new (GDA_TYPE_REPORT_VALID, NULL);
	valid->priv->dtd = xmlParseDTD (GDA_REPORT_EXTERNAL_ID, GDA_REPORT_DTD_URL);
	if (valid->priv->dtd == NULL) 
	{
		gda_log_error (_("could not get DTD from %s"), GDA_REPORT_DTD_URL);
		return NULL;
	}
	valid->priv->context = g_new0 (xmlValidCtxt, 1);
	valid->priv->context->userData = (void *) stderr;
	valid->priv->context->error = (xmlValidityErrorFunc) fprintf;
	valid->priv->context->warning = (xmlValidityWarningFunc) fprintf;

	return valid;
}


/*
 * gda_report_valid_new_from_dom 
 *
 * @dtd: a xmlDtdPtr object that should be the gda-report DTD
 *
 * Returns: The #GdaReportValid object created from the DTD
 */
GdaReportValid *
gda_report_valid_new_from_dom (xmlDtdPtr dtd)
{
	GdaReportValid *valid;
	
	g_return_val_if_fail (dtd != NULL, NULL);
	
	valid = g_object_new (GDA_TYPE_REPORT_VALID, NULL);
	valid->priv->dtd = dtd;
	valid->priv->context = g_new0 (xmlValidCtxt, 1);
	valid->priv->context->userData = (void *) stderr;
	valid->priv->context->error = (xmlValidityErrorFunc) fprintf;
	valid->priv->context->warning = (xmlValidityWarningFunc) fprintf;

	return valid;
}


/*
 * gda_report_valid_to_dom
 * 
 * @valid: a #GdaReportValid object
 *
 * Returns: The gda-report DTD in a xmlDtdPtr object
 */
xmlDtdPtr 
gda_report_valid_to_dom (GdaReportValid *valid)
{
	g_return_val_if_fail (GDA_IS_REPORT_VALID (valid), NULL);
	return valid->priv->dtd;	
}


/*
 * gda_report_valid_validate_document
 *
 * @valid: a #GdaReportValid object
 * @document: a xmlDocPtr object 
 *
 * Test if the document is a valid gda-report xml document
 *
 * Returns: TRUE if the document is valid, FALSE otherwise
 */
gboolean 
gda_report_valid_validate_document (GdaReportValid *valid, 
				    xmlDocPtr document)
{
	g_return_val_if_fail (GDA_IS_REPORT_VALID (valid), FALSE);
	g_return_val_if_fail (document != NULL, FALSE);
	
	document->intSubset = valid->priv->dtd;
	if (xmlValidateOneElement (valid->priv->context, document, xmlDocGetRootElement(document)))
		return TRUE;
	else
		return FALSE;
}


/*
 * gda_report_valid_validate_element
 *
 * @valid: a #GdaReportValid object
 * @element: a xmlNodePtr element
 *
 * Test if the element is a valid element of a gda-report xml document
 *
 * Returns: TRUE if the element is valid, FALSE otherwise
 */
gboolean 
gda_report_valid_validate_element (GdaReportValid *valid, 
				   xmlNodePtr element)
{
	xmlDocPtr  doc;	
	
	g_return_val_if_fail (GDA_IS_REPORT_VALID (valid), FALSE);
	g_return_val_if_fail (element != NULL, FALSE);
	
	doc = xmlNewDoc ("1.0");
	doc->intSubset = valid->priv->dtd;
	
	if (!xmlValidateOneElement(valid->priv->context, doc, element))
	{
		gda_log_error (_("Error validating element %s"), element->name);
		xmlFreeDoc (doc);
		return FALSE;
	}
	
	xmlFreeDoc (doc);
	return TRUE;
}


/*
 * gda_report_valid_validate_attribute
 *
 * @valid: a #GdaReportValid object
 * @element_name: name of the element witch attribute is to be set
 * @attribute_name: name of the attribute to be set
 * @value: value to be set to the attribute
 *
 * Test if the given value is a valid value for the given attribute, and also
 * if the given attribute is a valid attribute for the given element.  All this
 * using the gda-report DTD definition
 *
 * Returns: TRUE if valid, FALSE otherwise
 */
gboolean 
gda_report_valid_validate_attribute (GdaReportValid *valid, 
				     const gchar *element_name, 
				     const gchar *attribute_name,
				     const gchar *value)
{
	xmlAttributePtr   attr_decl  = NULL;
	xmlEnumerationPtr value_list = NULL;
	
	g_return_val_if_fail (GDA_IS_REPORT_VALID (valid), FALSE);
	
	attr_decl = xmlGetDtdAttrDesc(valid->priv->dtd, element_name, attribute_name);
	if (attr_decl == NULL) 
	{
		gda_log_error (_("No declaration for attribute %s of element %s\n"), attribute_name, element_name);
		return FALSE;
	}
	
	/* There is a list of valid values */ 
	if (attr_decl->tree != NULL)
	{
		value_list = attr_decl->tree;
		while (value_list != NULL) 
		{
		    if (g_ascii_strcasecmp(value_list->name, value) == 0) break;
		    value_list = value_list->next;			
		}
		if (value_list == NULL) {
			gda_log_error (_("Value \"%s\" for attribute %s of %s is not among the enumerated set\n"), value, attribute_name, element_name);
			return FALSE;
		}
	}
	return TRUE;
}
/* GDA report libary
 * Copyright (C) 1998-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *	Santi Camps <scamps users sourceforge net>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined(__gda_report_valid_h__)
#  define __gda_report_valid_h__

#include <glib-object.h>

G_BEGIN_DECLS


#define GDA_TYPE_REPORT_VALID            (gda_report_valid_get_type())
#define GDA_REPORT_VALID(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_REPORT_VALID, GdaReportValid))
#define GDA_REPORT_VALID_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_REPORT_VALID, GdaReportValidClass))
#define GDA_IS_REPORT_VALID(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_REPORT_VALID))
#define GDA_IS_REPORT_VALID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_REPORT_VALID))

typedef struct _GdaReportValid GdaReportValid;
typedef struct _GdaReportValidClass GdaReportValidClass;
typedef struct _GdaReportValidPrivate GdaReportValidPrivate;

struct _GdaReportValid {
	GObject object;
	GdaReportValidPrivate *priv;
};

struct _GdaReportValidClass {
	GObjectClass parent_class;
};


GType gda_report_valid_get_type (void);

GdaReportValid *gda_report_valid_load (void);

GdaReportValid *gda_report_valid_new_from_dom (xmlDtdPtr dtd);

xmlDtdPtr gda_report_valid_to_dom (GdaReportValid *valid);

gboolean gda_report_valid_validate_document (GdaReportValid *valid, 
					     xmlDocPtr document);

gboolean gda_report_valid_validate_element (GdaReportValid *valid, 
					    xmlNodePtr element);

gboolean gda_report_valid_validate_attribute (GdaReportValid *valid, 
					      const gchar *element_name, 
					      const gchar *attribute_name, 
					      const gchar *value);

G_END_DECLS


#endif

Attachment: testing.tar.gz
Description: GNU Zip compressed data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]