Code

fix translation for fit page
authoracspike <acspike@users.sourceforge.net>
Fri, 28 Apr 2006 04:14:59 +0000 (04:14 +0000)
committeracspike <acspike@users.sourceforge.net>
Fri, 28 Apr 2006 04:14:59 +0000 (04:14 +0000)
the translation is now preserved across save by translating all child elements of the root
instead of just translating the root itself.

src/document.cpp
src/sp-item-group.cpp
src/sp-item-group.h

index ef04735ef6252f78aeaf95c658eb0e04abbfe617..eca4ab2dcae09a1be42a916789ee1fe4eeb0e487 100644 (file)
@@ -52,7 +52,7 @@
 #include "prefs-utils.h"
 #include "libavoid/router.h"
 #include "libnr/nr-rect.h"
-#include "sp-item-transform.h"
+#include "sp-item-group.h"
 
 #include "display/nr-arena-item.h"
 
@@ -499,7 +499,7 @@ void SPDocument::fitToRect(NRRect const & rect)
     sp_document_set_height(this, h, &unit);
 
     NR::translate tr = NR::translate::translate(-rect.x0,-(rect.y0 + (h - old_height)));
-    sp_item_move_rel((SPItem *) root, tr);
+    static_cast<SPGroup *>(root)->translateChildItems(tr);
 }
 
 void sp_document_set_uri(SPDocument *document, gchar const *uri)
index cd11b3c41be974c2e4e3ae95da4a2855e9debbb5..b5f6881b72e73909f6f9e2f3ba4b755b08bb4585 100644 (file)
@@ -29,6 +29,7 @@
 #include "document.h"
 #include "style.h"
 #include "attributes.h"
+#include "sp-item-transform.h"
 
 #include "sp-root.h"
 #include "sp-use.h"
@@ -524,6 +525,19 @@ void SPGroup::_updateLayerMode(unsigned int display_key) {
        }
 }
 
+void SPGroup::translateChildItems(NR::translate const &tr)
+{
+       if (this->hasChildren())
+       {
+               SPObject *o = NULL;
+               for (o = sp_object_first_child(SP_OBJECT(this)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
+                       if (SP_IS_ITEM (o)) {
+                               sp_item_move_rel(static_cast<SPItem *>(o), tr);
+                       }
+               }
+       }
+}
+
 CGroup::CGroup(SPGroup *group) {
     _group = group;
 }
index ebf5c040272fe4b21a7490a8250e8b93e74db6d9..b78291074697f8c30af899a26d164bf3b461703a 100644 (file)
@@ -24,6 +24,8 @@
 
 class CGroup;
 
+namespace NR{ struct translate; }
+
 struct SPGroup : public SPItem {
        enum LayerMode { GROUP, LAYER };
 
@@ -43,6 +45,7 @@ struct SPGroup : public SPItem {
 
        LayerMode layerDisplayMode(unsigned int display_key) const;
        void setLayerDisplayMode(unsigned int display_key, LayerMode mode);
+       void translateChildItems(NR::translate const &tr);
 
     CGroup *group;