repr-io.cpp revision 1429966f97e1425f068a42fe9b4f96d3294d225a
#define __SP_REPR_IO_C__
/*
* Dirty DOM-like tree
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdexcept>
#include "xml/attribute-record.h"
#include "io/uristream.h"
#include "io/gzipstream.h"
static Node *sp_repr_svg_read_node (xmlNodePtr node, const gchar *default_ns, GHashTable *prefix_map);
static gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar *default_ns, GHashTable *prefix_map);
static void sp_repr_write_stream_root_element (Node *repr, Writer &out, gboolean add_whitespace, gchar const *default_ns);
static void sp_repr_write_stream (Node *repr, Writer &out, gint indent_level, gboolean add_whitespace, Glib::QueryQuark elide_prefix);
static void sp_repr_write_stream_element (Node *repr, Writer &out, gint indent_level, gboolean add_whitespace, Glib::QueryQuark elide_prefix, List<AttributeRecord const> attributes);
#ifdef HAVE_LIBWMF
static char * sp_wmf_image_name (void * context);
#endif /* HAVE_LIBWMF */
class XmlSource
{
public:
: filename(0),
fp(0),
first(false),
dummy("x"),
instr(0),
gzin(0)
{
}
virtual ~XmlSource()
{
close();
}
int close();
private:
const char* filename;
bool first;
};
{
}
first = true;
}
{
int retVal = -1;
if ( context ) {
}
return retVal;
}
{
if ( context ) {
}
return 0;
}
{
int retVal = 0;
if ( first ) {
first = false;
char tmp[] = {0,0};
//g_message(" the file being read is gzip'd. extract it");
fp = 0;
int single = 0;
{
if ( single >= 0 ) {
} else {
break;
}
}
//g_message(" extracted %d bytes this pass", got );
} else {
}
} else if ( gzin ) {
int single = 0;
{
if ( single >= 0 ) {
} else {
break;
}
}
//g_message(" extracted %d bytes this pass b", got );
} else {
}
}
retVal = -1;
}
else {
}
return retVal;
}
{
if ( gzin ) {
delete gzin;
gzin = 0;
}
if ( instr ) {
fp = 0;
delete instr;
instr = 0;
}
if ( fp ) {
fp = 0;
}
return 0;
}
/**
* Reads XML from a file, including WMF files, and returns the Document.
* The default namespace can also be specified, if desired.
*/
Document *
{
// TODO: bulia, please look over
gsize bytesWritten = 0;
// TODO: need to replace with our own fopen and reading
try
{
}
catch (...)
{
return NULL;
}
&src,
NULL, //"UTF-8",
#ifdef HAVE_LIBWMF
else
}
else {
}
#else /* !HAVE_LIBWMF */
//doc = xmlParseFile (localFilename);
#endif /* !HAVE_LIBWMF */
//rdoc = sp_repr_do_read (doc, default_ns);
if (doc)
xmlFreeDoc (doc);
if ( localFilename != NULL )
{
xmlFreeDoc( doubleDoc );
}
return rdoc;
}
/**
* Reads and parses XML from a buffer, returning it as an Document
*/
Document *
{
if (doc)
xmlFreeDoc (doc);
return rdoc;
}
namespace Inkscape {
struct compare_quark_ids {
}
};
}
namespace {
static PrefixMap prefix_map;
} else {
if (prefix_end) {
return prefix;
} else {
return GQuark(0);
}
}
}
}
namespace {
}
}
}
}
}
/**
* Reads in a XML file to create a Document
*/
Document *
{
if (!root) {
} else {
break;
}
}
}
/* promote elements of SVG documents that don't use namespaces
* into the SVG namespace */
{
}
}
}
return rdoc;
}
sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar *default_ns, GHashTable *prefix_map)
{
} else {
}
if (prefix)
else
}
static Node *
{
gchar c[256];
return NULL; // empty text node
xmlChar *p;
; // skip all whitespace
if (!(*p)) { // this is an all-whitespace node, and preserve == default
return NULL; // we do not preserve all-whitespace nodes unless we are asked to
}
return rdoc;
}
repr = sp_repr_new (c);
/* TODO remember node->ns->prefix if node->ns != NULL */
/* TODO remember prop->ns->prefix if prop->ns != NULL */
}
}
if (crepr) {
}
}
return repr;
}
void
{
Inkscape::IO::OutputStreamWriter *out = compress ? new Inkscape::IO::OutputStreamWriter( *gout ) : new Inkscape::IO::OutputStreamWriter( bout );
/* fixme: do this The Right Way */
if (str) {
}
{
} else {
}
}
if ( out ) {
delete out;
}
if ( gout ) {
delete gout;
}
}
/* Returns TRUE if file successfully saved; FALSE if not
*/
gchar const *default_ns)
{
return FALSE;
}
bool compress = false;
{
tmp[5] = 0;
{
//g_message("TIME TO COMPRESS THE OUTPUT FOR SVGZ");
compress = true;
}
}
}
return FALSE;
}
return FALSE;
}
return TRUE;
}
void
{
return;
}
/* (No doubt this function already exists elsewhere.) */
static void
{
if (!val) return;
switch (*val) {
}
}
}
namespace {
typedef std::map<Glib::QueryQuark, Inkscape::Util::SharedCStringPtr, Inkscape::compare_quark_ids> NSMap;
static LocalNameMap local_name_map;
} else {
if (prefix_end) {
return prefix_end + 1;
} else {
return name_string;
}
}
}
if (uri) {
} else if ( prefix != xml_prefix ) {
}
} else {
}
}
}
{
}
}
{
}
}
}
}
void
sp_repr_write_stream_root_element (Node *repr, Writer &out, gboolean add_whitespace, gchar const *default_ns)
{
}
{
if ( prefix != xml_prefix ) {
if ( elide_prefix == prefix ) {
}
}
} else {
// if there are non-namespaced elements, we can't globally
// use a default namespace
elide_prefix = GQuark(0);
}
}
}
void
{
sp_repr_write_stream_element(repr, out, indent_level, add_whitespace, elide_prefix, repr->attributeList());
} else {
}
}
void
{
gint i;
if ( indent_level > 16 )
indent_level = 16;
if (add_whitespace) {
for ( i = 0 ; i < indent_level ; i++ ) {
}
}
gchar const *element_name;
} else {
}
// if this is a <text> element, suppress formatting whitespace
// for its content and children:
}
{
for ( i = 0 ; i < indent_level + 1 ; i++ ) {
}
}
break;
}
}
if (repr->firstChild()) {
if (loose && add_whitespace) {
}
}
if (loose && add_whitespace) {
for (i = 0; i < indent_level; i++) {
}
}
} else {
}
// text elements cannot nest, so we can output newline
// after closing text
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :