Code

Don't snap to points which are off-screen
[inkscape.git] / src / extension / output.cpp
index b0f254a9c07afbacd205bcb2f99f8c1fa5a8a4dc..742e938de20307e62f3d74763f4a34a2dec4f486 100644 (file)
@@ -2,6 +2,7 @@
  * Authors:
  *   Ted Gould <ted@gould.cx>
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2002-2004 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -48,10 +49,13 @@ Output::Output (Inkscape::XML::Node * in_repr, Implementation::Implementation *
         child_repr = sp_repr_children(repr);
 
         while (child_repr != NULL) {
-            if (!strcmp(child_repr->name(), "output")) {
+            if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "output")) {
                 child_repr = sp_repr_children(child_repr);
                 while (child_repr != NULL) {
                     char const * chname = child_repr->name();
+                                       if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
+                                               chname += strlen(INKSCAPE_EXTENSION_NS);
+                                       }
                     if (chname[0] == '_') /* Allow _ for translation of tags */
                         chname++;
                     if (!strcmp(chname, "extension")) {
@@ -71,7 +75,7 @@ Output::Output (Inkscape::XML::Node * in_repr, Implementation::Implementation *
                         filetypetooltip = g_strdup(sp_repr_children(child_repr)->content());
                     }
                     if (!strcmp(chname, "dataloss")) {
-                        if (!strcmp(sp_repr_children(child_repr)->content(), "FALSE")) {
+                        if (!strcmp(sp_repr_children(child_repr)->content(), "false")) {
                                                        dataloss = FALSE;
                                                }
                                        }
@@ -196,55 +200,27 @@ Output::prefs (void)
     \return  None
        \brief   Save a document as a file
        \param   doc  Document to save
-       \param   uri  File to save the document as
+       \param   filename  File to save the document as
 
        This function does a little of the dirty work involved in saving
        a document so that the implementation only has to worry about geting
        bits on the disk.
 
-       The big thing that it does is remove and readd the fields that are
+       The big thing that it does is remove and read the fields that are
        only used at runtime and shouldn't be saved.  One that may surprise
        people is the output extension.  This is not saved so that the IDs
        could be changed, and old files will still work properly.
-
-       After the file is saved by the implmentation the output_extension
-       and dataloss variables are recreated.  The output_extension is set
-       to this extension so that future saves use this extension.  Dataloss
-       is set so that a warning will occur on closing the document that
-       there may be some dataloss from this extension.
 */
 void
-Output::save (SPDocument * doc, const gchar * uri)
+Output::save(SPDocument *doc, gchar const *filename)
 {
-       bool modified = false;
-       Inkscape::XML::Node * repr = sp_document_repr_root(doc);
-
-        gboolean saved = sp_document_get_undo_sensitive(doc);
-       sp_document_set_undo_sensitive (doc, FALSE);
-       //repr->setAttribute("inkscape:output_extension", NULL);
-       repr->setAttribute("inkscape:dataloss", NULL);
-       if (repr->attribute("sodipodi:modified") != NULL)
-               modified = true;
-       repr->setAttribute("sodipodi:modified", NULL);
-       sp_document_set_undo_sensitive (doc, saved);
-
         try {
-            imp->save(this, doc, uri);
+            imp->save(this, doc, filename);
         }
         catch (...) {
-            if (modified)
-                repr->setAttribute("sodipodi:modified", "true");
-            throw;
+            throw Inkscape::Extension::Output::save_failed();
         }
 
-        saved = sp_document_get_undo_sensitive(doc);
-       sp_document_set_undo_sensitive (doc, FALSE);
-       //repr->setAttribute("inkscape:output_extension", get_id());
-       if (dataloss) {
-               repr->setAttribute("inkscape:dataloss", "true");
-       }
-       sp_document_set_undo_sensitive (doc, saved);
-
        return;
 }