From 803e249e999ab90caf2e3d61cc6782aa7dd3caba Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 15:00:40 -0400 Subject: Fix document unit change for transformed flow text and transformed text on path. (bzr r12475.1.18) --- src/sp-flowtext.cpp | 8 +++++++- src/sp-flowtext.h | 6 ++++++ src/sp-item-group.cpp | 25 +++++++++++++++++-------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 304d749c2..4fc922a82 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -86,6 +86,8 @@ sp_flowtext_init(SPFlowtext *group) { group->par_indent = 0; new (&group->layout) Inkscape::Text::Layout(); + + group->_optimizeScaledText = false; } static void @@ -706,9 +708,13 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, static Geom::Affine sp_flowtext_set_transform (SPItem *item, Geom::Affine const &xform) { - if (!xform.isNonzeroUniformScale()) { + SPFlowtext *ft = SP_FLOWTEXT(item); + if ((ft->_optimizeScaledText && !xform.withoutTranslation().isNonzeroUniformScale()) + || (!ft->_optimizeScaledText && !xform.isNonzeroUniformScale())) { + ft->_optimizeScaledText = false; return xform; } + ft->_optimizeScaledText = false; SPText *text = reinterpret_cast(item); diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index 944503a1e..6857f5760 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -43,6 +43,12 @@ struct SPFlowtext : public SPItem { double par_indent; + bool _optimizeScaledText; + + /** Optimize scaled flow text on next set_transform. */ + void optimizeScaledText() + {_optimizeScaledText = true;} + private: /** Recursively walks the xml tree adding tags and their contents. */ void _buildLayoutInput(SPObject *root, Shape const *exclusion_shape, std::list *shapes, SPObject **pending_line_break_object); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index be62764c3..1b8af43e1 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -51,8 +51,8 @@ #include "sp-defs.h" #include "verbs.h" #include "layer-model.h" -#include "selection-chemistry.h" #include "sp-textpath.h" +#include "sp-flowtext.h" using Inkscape::DocumentUndo; @@ -585,18 +585,27 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) old_center = item->getCenter(); } - if (SP_IS_TEXT_TEXTPATH(item) && item->transform.isIdentity()) { - if (item->transform.isIdentity()) { - SP_TEXT(item)->optimizeTextpathText(); - } else { - // TODO: transformed text on textpath - } + if (SP_IS_TEXT_TEXTPATH(item)) { + SP_TEXT(item)->optimizeTextpathText(); + } else if (SP_IS_FLOWTEXT(item)) { + SP_FLOWTEXT(item)->optimizeScaledText(); } else if (SP_IS_BOX3D(item)) { // Force recalculation from perspective box3d_position_set(SP_BOX3D(item)); } - if (SP_IS_USE(item)) { + if ((SP_IS_TEXT_TEXTPATH(item) || SP_IS_FLOWTEXT(item)) && !item->transform.isIdentity()) { + // Save and reset current transform + Geom::Affine tmp(item->transform); + item->transform = Geom::Affine(); + // Apply scale + item->set_i2d_affine(item->i2dt_affine() * sc); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + // Scale translation and restore original transform + tmp[4] *= sc[0]; + tmp[5] *= sc[1]; + item->doWriteTransform(item->getRepr(), tmp, NULL, true); + } else if (SP_IS_USE(item)) { // calculate the matrix we need to apply to the clone // to cancel its induced transform from its original Geom::Affine move = final.inverse() * item->transform * final; -- cgit v1.2.3