Code

NR::Maybe => boost::optional
[inkscape.git] / src / file.cpp
index fb03c25e765c0c85b79ee5a2d239e945aeddc0ff..b620e9c9e745c60272069c7f6274b47c8952da6d 100644 (file)
@@ -8,9 +8,10 @@
  *   Chema Celorio <chema@celorio.com>
  *   bulia byak <buliabyak@users.sf.net>
  *   Bruno Dilly <bruno.dilly@gmail.com>
+ *   Stephen Silver <sasilver@users.sourceforge.net>
  *
  * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
- * Copyright (C) 1999-2005 Authors
+ * Copyright (C) 1999-2008 Authors
  * Copyright (C) 2004 David Turner
  * Copyright (C) 2001-2002 Ximian, Inc.
  *
@@ -65,6 +66,7 @@
 #include "application/editor.h"
 #include "inkscape.h"
 #include "uri.h"
+#include "id-clash.h"
 
 #ifdef WITH_GNOME_VFS
 # include <libgnomevfs/gnome-vfs.h>
@@ -493,7 +495,7 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
         else
             g_warning( "ERROR CONVERTING OPEN FILENAME TO UTF-8" );
 
-        open_path = fileName;
+        open_path = Glib::path_get_dirname (fileName);
         open_path.append(G_DIR_SEPARATOR_S);
         prefs_set_string_attribute("dialogs.open", "path", open_path.c_str());
 
@@ -894,6 +896,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
         Inkscape::IO::fixupHrefs(doc, in_doc->base, true);
         Inkscape::XML::Document *xml_in_doc = sp_document_repr_doc(in_doc);
 
+        prevent_id_clashes(doc, in_doc);
+        
         SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc);
         Inkscape::XML::Node *last_def = SP_OBJECT_REPR(in_defs)->lastChild();
         
@@ -949,8 +953,6 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
                     for (SPObject *x = sp_object_first_child(child);
                          x != NULL; x = SP_OBJECT_NEXT(x))
                     {
-                        // FIXME: in case of id conflict, newly added thing will be re-ided
-                        // and thus likely break a reference to it from imported stuff
                         SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(x)->duplicate(xml_in_doc), last_def);
                     }
                 }
@@ -976,7 +978,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
                 int const saved_pref = prefs_get_int_attribute("options.transform", "pattern", 1);
                 prefs_set_int_attribute("options.transform", "pattern", 1);
                 sp_document_ensure_up_to_date(sp_desktop_document(desktop));
-                NR::Maybe<NR::Rect> sel_bbox = selection->bounds();
+                boost::optional<NR::Rect> sel_bbox = selection->bounds();
                 if (sel_bbox) {
                     NR::Point m( desktop->point() - sel_bbox->midpoint() );
                     sp_selection_move_relative(selection, m);