From b79f3338a624d38a58133d70f0baa440f9a9ffd2 Mon Sep 17 00:00:00 2001 From: acspike Date: Fri, 28 Apr 2006 04:14:59 +0000 Subject: [PATCH] fix translation for fit page 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 | 4 ++-- src/sp-item-group.cpp | 14 ++++++++++++++ src/sp-item-group.h | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index ef04735ef..eca4ab2dc 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -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(root)->translateChildItems(tr); } void sp_document_set_uri(SPDocument *document, gchar const *uri) diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index cd11b3c41..b5f6881b7 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -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(o), tr); + } + } + } +} + CGroup::CGroup(SPGroup *group) { _group = group; } diff --git a/src/sp-item-group.h b/src/sp-item-group.h index ebf5c0402..b78291074 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -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; -- 2.30.2