Code

better way to deal with undo+id collisions
[inkscape.git] / src / document.cpp
index 9fc6dc4dae13491a348cbecf999dbe60164a39e8..c6dc66a514cd5675f5eaaf1831c561a648600f3e 100644 (file)
@@ -106,6 +106,7 @@ SPDocument::SPDocument() {
     p->history_size = 0;
     p->undo = NULL;
     p->redo = NULL;
+    p->seeking = false;
 
     priv = p;
 
@@ -220,7 +221,7 @@ sp_document_create(Inkscape::XML::Document *rdoc,
     Inkscape::XML::Node *rroot;
     Inkscape::Version sodipodi_version;
 
-    rroot = sp_repr_document_root(rdoc);
+    rroot = rdoc->root();
 
     document = new SPDocument();
 
@@ -261,10 +262,7 @@ sp_document_create(Inkscape::XML::Document *rdoc,
 
     /* Quick hack 3 - Set uri attributes */
     if (uri) {
-        /* fixme: Think, what this means for images (Lauris) */
         rroot->setAttribute("sodipodi:docname", uri);
-        if (document->base)
-            rroot->setAttribute("sodipodi:docbase", document->base);
     }
     /* End of quick hack 3 */
 
@@ -341,7 +339,7 @@ sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new)
         rdoc = sp_repr_read_file(uri, SP_SVG_NS_URI);
         /* If file cannot be loaded, return NULL without warning */
         if (rdoc == NULL) return NULL;
-        rroot = sp_repr_document_root(rdoc);
+        rroot = rdoc->root();
         /* If xml file is not svg, return NULL without warning */
         /* fixme: destroy document */
         if (strcmp(rroot->name(), "svg:svg") != 0) return NULL;
@@ -390,7 +388,7 @@ sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepaliv
     /* If it cannot be loaded, return NULL without warning */
     if (rdoc == NULL) return NULL;
 
-    rroot = sp_repr_document_root(rdoc);
+    rroot = rdoc->root();
     /* If xml file is not svg, return NULL without warning */
     /* fixme: destroy document */
     if (strcmp(rroot->name(), "svg:svg") != 0) return NULL;
@@ -494,7 +492,7 @@ gdouble sp_document_height(SPDocument *document)
  */
 void SPDocument::fitToRect(NRRect const & rect)
 {
-    g_return_if_fail(!empty(rect));
+    g_return_if_fail(!nr_rect_d_test_empty(&rect));
     
     gdouble w = rect.x1 - rect.x0;
     gdouble h = rect.y1 - rect.y0;
@@ -548,8 +546,6 @@ void sp_document_set_uri(SPDocument *document, gchar const *uri)
     // changing uri in the document repr must not be not undoable
     bool saved = sp_document_get_undo_sensitive(document);
     sp_document_set_undo_sensitive(document, false);
-    if (document->base)
-        repr->setAttribute("sodipodi:docbase", document->base);
 
     repr->setAttribute("sodipodi:docname", document->name);
     sp_document_set_undo_sensitive(document, saved);
@@ -837,8 +833,8 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey,
             s = find_items_in_area(s, SP_GROUP(o), dkey, area, test);
         } else {
             SPItem *child = SP_ITEM(o);
-            NR::Rect box = sp_item_bbox_desktop(child);
-            if (test(area, box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
+            NR::Maybe<NR::Rect> box = sp_item_bbox_desktop(child);
+            if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
                 s = g_slist_append(s, child);
             }
         }
@@ -1160,6 +1156,10 @@ vacuum_document(SPDocument *document)
     return start - newend;
 }
 
+bool SPDocument::isSeeking() const {
+    return priv->seeking;
+}
+
 
 /*
   Local Variables: