diff --git a/src/document.cpp b/src/document.cpp
index 6ab08ffb62c7b5165bd38baee66bdcb09cd1ae2c..252c9b17379070e296bc2cc7b058400b42b841da 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -405,11 +405,6 @@ sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepaliv
return doc;
}
-SPDocument *sp_document_new_dummy() {
- SPDocument *document = new SPDocument();
- return document;
-}
-
SPDocument *
sp_document_ref(SPDocument *doc)
{
}
/**
- * Given an NRRect that may, for example, correspond to the bbox of an object
+ * Given an NR::Rect that may, for example, correspond to the bbox of an object,
* this function fits the canvas to that rect by resizing the canvas
* and translating the document root into position.
*/
-void SPDocument::fitToRect(NRRect const & rect)
+void SPDocument::fitToRect(NR::Rect const &rect)
{
- g_return_if_fail(!nr_rect_d_test_empty(&rect));
-
- gdouble w = rect.x1 - rect.x0;
- gdouble h = rect.y1 - rect.y0;
- gdouble old_height = sp_document_height(this);
- SPUnit unit = sp_unit_get_by_id(SP_UNIT_PX);
- sp_document_set_width(this, w, &unit);
- sp_document_set_height(this, h, &unit);
-
- NR::translate tr = NR::translate::translate(-rect.x0,-(rect.y0 + (h - old_height)));
- static_cast<SPGroup *>(root)->translateChildItems(tr);
+ g_return_if_fail(!rect.isEmpty());
+
+ using NR::X; using NR::Y;
+ double const w = rect.extent(X);
+ double const h = rect.extent(Y);
+
+ double const old_height = sp_document_height(this);
+ SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX));
+ sp_document_set_width(this, w, &px);
+ sp_document_set_height(this, h, &px);
+
+ NR::translate const tr(NR::Point(0, (old_height - h))
+ - rect.min());
+ SP_GROUP(root)->translateChildItems(tr);
}
void sp_document_set_uri(SPDocument *document, gchar const *uri)