-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * label.c: GLabels xml label module
+ * xml-label.c
+ * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
*
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
+ * This file is part of gLabels.
*
- * This program is free software; you can redistribute it and/or modify
+ * gLabels is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * gLabels 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "xml-label.h"
#include <glib/gi18n.h>
+#include <glib.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xinclude.h>
#include <gdk-pixbuf/gdk-pixdata.h>
+#include <libglabels/libglabels.h>
#include "label.h"
#include "label-object.h"
#include "label-text.h"
#include "label-ellipse.h"
#include "label-image.h"
#include "label-barcode.h"
-#include "base64.h"
#include "xml-label-04.h"
-#include <libglabels/db.h>
-#include <libglabels/xml-template.h>
-#include <libglabels/xml.h>
#include "util.h"
#include "debug.h"
+
/*========================================================*/
/* Private macros and constants. */
/*========================================================*/
#define COMPAT04_NAME_SPACE "http://snaught.com/glabels/0.4/"
#define COMPAT20_NAME_SPACE "http://snaught.com/glabels/2.0/"
+
/*========================================================*/
/* Private types. */
/*========================================================*/
+
/*========================================================*/
/* Private globals. */
/*========================================================*/
+
/*========================================================*/
/* Private function prototypes. */
/*========================================================*/
filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
g_return_val_if_fail (filename, NULL);
- doc = xmlParseFile (filename);
+ doc = xmlReadFile (filename, NULL, XML_PARSE_HUGE);
if (!doc) {
g_message (_("xmlParseFile error"));
*status = XML_LABEL_ERROR_OPEN_PARSE;
return label;
}
+
/****************************************************************************/
/* Read label from xml buffer. */
/****************************************************************************/
gl_debug (DEBUG_XML, "START");
- doc = xmlParseDoc ((xmlChar *) buffer);
+ doc = xmlReadDoc ((xmlChar *) buffer, NULL, NULL, XML_PARSE_HUGE);
if (!doc) {
g_message (_("xmlParseFile error"));
*status = XML_LABEL_ERROR_OPEN_PARSE;
return label;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse xml doc structure and create label. */
/*--------------------------------------------------------------------------*/
return label;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse xml root node and create label. */
/*--------------------------------------------------------------------------*/
return label;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse Objects node. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Objects->Object-text Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Objects->Object-box Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Objects->Object-ellipse Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Objects->Object-line Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Objects->Object-image Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Objects->Object-barcode Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML merge fields tag. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML data tag. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML pixbuf data tag. */
/*--------------------------------------------------------------------------*/
{
gchar *name, *base64;
guchar *stream;
- guint stream_length;
+ gsize stream_length;
gboolean ret;
GdkPixdata *pixdata;
GdkPixbuf *pixbuf;
name = lgl_xml_get_prop_string (node, "name", NULL);
base64 = lgl_xml_get_node_content (node);
- stream = gl_base64_decode ((gchar *)base64, &stream_length);
+ stream = g_base64_decode ((gchar *)base64, &stream_length);
pixdata = g_new0 (GdkPixdata, 1);
ret = gdk_pixdata_deserialize (pixdata, stream_length, stream, NULL);
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse top-level Span tag. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse affine attributes. */
/*--------------------------------------------------------------------------*/
gl_label_object_set_matrix (object, &matrix);
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse shadow attributes. */
/*--------------------------------------------------------------------------*/
}
}
+
/****************************************************************************/
/* Save label to xml label file. */
/****************************************************************************/
gl_debug (DEBUG_XML, "END");
}
+
/****************************************************************************/
/* Save label to xml buffer. */
/****************************************************************************/
return (gchar *)buffer;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Convert label to xml doc structure. */
/*--------------------------------------------------------------------------*/
return doc;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects->Object-text Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects->Object-box Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects->Object-ellipse Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects->Object-line Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects->Object-image Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Objects->Object-barcode Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Label Merge Fields Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Label Data Node */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Label Data Pixbuf Node */
/*--------------------------------------------------------------------------*/
pixdata = g_new0 (GdkPixdata, 1);
gdk_pixdata_from_pixbuf (pixdata, pixbuf, FALSE);
stream = gdk_pixdata_serialize (pixdata, &stream_length);
- base64 = gl_base64_encode (stream, stream_length);
+ base64 = g_base64_encode (stream, stream_length);
node = xmlNewChild (root, ns, (xmlChar *)"Pixdata", (xmlChar *)base64);
lgl_xml_set_prop_string (node, "name", name);
gl_debug (DEBUG_XML, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Create top-level Span node. */
/*--------------------------------------------------------------------------*/
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Create affine attributes. */
/*--------------------------------------------------------------------------*/
lgl_xml_set_prop_double (node, "a5", matrix.y0);
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Create shadow attributes. */
/*--------------------------------------------------------------------------*/
}
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */