示例#1
0
static void
end_render(DiaRenderer *self)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  g_free(renderer->linestyle);

  xmlSetDocCompressMode(renderer->doc, 0);
  xmlDiaSaveFile(renderer->filename, renderer->doc);
  g_free(renderer->filename);
  xmlFreeDoc(renderer->doc);
}
示例#2
0
/**
 * dia_object_defaults_save:
 *
 * Saves all the currently created default objects into a
 * valid diagram file. All the objects are placed into
 * separate invisible layers.
 */
gboolean
dia_object_defaults_save (const gchar *filename)
{
    MyRootInfo ni;
    xmlDocPtr doc;
    gboolean ret;
    gchar *real_filename;
    int old_blanks_default = pretty_formated_xml;

    /* FIXME HACK: we always want nice readable default files,
     *  but toggling it by a global var is ugly   --hb
     */
    pretty_formated_xml = TRUE;

    if (!filename)
        real_filename = dia_config_filename("defaults.dia");
    else
        real_filename = g_strdup (filename);

    doc = xmlNewDoc((const xmlChar *)"1.0");
    doc->encoding = xmlStrdup((const xmlChar *)"UTF-8");

    doc->xmlRootNode = xmlNewDocNode(doc, NULL, (const xmlChar *)"diagram", NULL);

    ni.name_space = xmlNewNs(doc->xmlRootNode,
                             (const xmlChar *)DIA_XML_NAME_SPACE_BASE,
                             (const xmlChar *)"dia");
    xmlSetNs(doc->xmlRootNode, ni.name_space);

    ni.obj_nr = 0;
    ni.node = doc->xmlRootNode;
    ni.filename = real_filename;
    ni.layer_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
                                           g_free, g_free);

    g_hash_table_foreach (defaults_hash, _obj_store, &ni);

    ret = xmlDiaSaveFile (real_filename, doc);
    g_free (real_filename);
    xmlFreeDoc(doc);
    pretty_formated_xml = old_blanks_default;

    g_hash_table_destroy (ni.layer_hash);

    return ret;
}
示例#3
0
static void
end_render(DiaRenderer *self)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  g_free(renderer->linestyle);

  /* handle potential patterns */
  if (renderer->patterns) {
    xmlNodePtr root = xmlDocGetRootElement (renderer->doc);
    xmlNodePtr defs = xmlNewNode (renderer->svg_name_space, (const xmlChar *)"defs");
    GradientData gd = { renderer, defs };
    g_hash_table_foreach (renderer->patterns, _gradient_do, &gd);
    xmlAddPrevSibling (root->children, defs);
    g_hash_table_destroy (renderer->patterns);
    renderer->patterns = NULL;
  }
  xmlSetDocCompressMode(renderer->doc, 0);
  xmlDiaSaveFile(renderer->filename, renderer->doc);
  g_free(renderer->filename);
  xmlFreeDoc(renderer->doc);
}
示例#4
0
/* full overwrite */
static void
end_render(DiaRenderer *self)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  int old_blanks_default = pretty_formated_xml;

  /* FIXME HACK: we always want nice readable shape files,
   *  but toggling it by a global var is ugly   --hb 
   */
  pretty_formated_xml = TRUE;

  g_free(renderer->linestyle);
  renderer->linestyle = NULL;
  
  xmlSetDocCompressMode(renderer->doc, 0);
  xmlDiaSaveFile(renderer->filename, renderer->doc);
  g_free(renderer->filename);
  renderer->filename = NULL;
  xmlFreeDoc(renderer->doc);
  pretty_formated_xml = old_blanks_default;
}