diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-05-31 11:59:40 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-05-31 11:59:40 +0000 |
| commit | ad8c369ad3bbf157360ae4c0c479ca3cdb016cf5 (patch) | |
| tree | 58c03547e6f2ea21e80b2b4c2310cab41a85ac2e /src/object | |
| parent | More boilerplate for 'textPath' 'side' attribute. (diff) | |
| download | inkscape-ad8c369ad3bbf157360ae4c0c479ca3cdb016cf5.tar.gz inkscape-ad8c369ad3bbf157360ae4c0c479ca3cdb016cf5.zip | |
Implement rendering for 'textPath' 'side' attribute. No GUI.
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/sp-tspan.cpp | 33 | ||||
| -rw-r--r-- | src/object/sp-use-reference.cpp | 27 | ||||
| -rw-r--r-- | src/object/sp-use-reference.h | 4 |
3 files changed, 36 insertions, 28 deletions
diff --git a/src/object/sp-tspan.cpp b/src/object/sp-tspan.cpp index 5a604e4a2..9aee85d39 100644 --- a/src/object/sp-tspan.cpp +++ b/src/object/sp-tspan.cpp @@ -31,16 +31,22 @@ #include <string> #include <glibmm/i18n.h> -#include <livarot/Path.h> -#include "svg/stringstream.h" #include "attributes.h" -#include "sp-use-reference.h" -#include "sp-tspan.h" -#include "sp-tref.h" -#include "sp-textpath.h" +#include "document.h" #include "text-editing.h" + +#include "sp-textpath.h" +#include "sp-tref.h" +#include "sp-tspan.h" +#include "sp-use-reference.h" #include "style.h" -#include "document.h" + +#include "display/curve.h" + +#include "livarot/Path.h" + +#include "svg/stringstream.h" + /*##################################################### # SPTSPAN @@ -353,15 +359,24 @@ void refresh_textpath_source(SPTextPath* tp) tp->sourcePath->refresh_source(); tp->sourcePath->sourceDirty=false; - // finalisons if ( tp->sourcePath->originalPath ) { if (tp->originalPath) { delete tp->originalPath; } + SPCurve* curve_copy; + if (tp->side == SP_TEXT_PATH_SIDE_LEFT) { + curve_copy = tp->sourcePath->originalPath->copy(); + } else { + curve_copy = tp->sourcePath->originalPath->create_reverse(); + } + + SPItem *item = SP_ITEM(tp->sourcePath->sourceObject); tp->originalPath = new Path; - tp->originalPath->Copy(tp->sourcePath->originalPath); + tp->originalPath->LoadPathVector(curve_copy->get_pathvector(), item->transform, true); tp->originalPath->ConvertWithBackData(0.01); + + curve_copy->unref(); } } diff --git a/src/object/sp-use-reference.cpp b/src/object/sp-use-reference.cpp index ea8bc5e86..d35bdf579 100644 --- a/src/object/sp-use-reference.cpp +++ b/src/object/sp-use-reference.cpp @@ -36,7 +36,7 @@ static void sp_usepath_source_modified(SPObject *iSource, guint flags, SPUsePath SPUsePath::SPUsePath(SPObject* i_owner):SPUseReference(i_owner) { owner=i_owner; - originalPath = NULL; + originalPath = nullptr; sourceDirty=false; sourceHref = NULL; sourceRepr = NULL; @@ -48,8 +48,9 @@ SPUsePath::SPUsePath(SPObject* i_owner):SPUseReference(i_owner) SPUsePath::~SPUsePath(void) { - delete originalPath; - originalPath = NULL; + if (originalPath != nullptr) { + originalPath->unref(); + } _changed_connection.disconnect(); // to do before unlinking @@ -196,36 +197,28 @@ sp_usepath_source_modified(SPObject */*iSource*/, guint /*flags*/, SPUsePath *of void SPUsePath::refresh_source() { sourceDirty = false; - delete originalPath; - originalPath = NULL; - // le mauvais cas: pas d'attribut d => il faut verifier que c'est une SPShape puis prendre le contour - // [tr: The bad case: no d attribute. Must check that it's a SPShape and then take the outline.] + if (originalPath != nullptr) { + originalPath->unref(); + } + SPObject *refobj = sourceObject; if ( refobj == NULL ) return; SPItem *item = SP_ITEM(refobj); - SPCurve *curve = NULL; if (SP_IS_SHAPE(item)) { - curve = SP_SHAPE(item)->getCurve(); + originalPath = SP_SHAPE(item)->getCurve()->copy(); } else if (SP_IS_TEXT(item)) { - curve = SP_TEXT(item)->getNormalizedBpath(); + originalPath = SP_TEXT(item)->getNormalizedBpath()->copy(); } else { return; } - - if (curve == NULL) - return; - - originalPath = new Path; - originalPath->LoadPathVector(curve->get_pathvector(), item->transform, true); - curve->unref(); } diff --git a/src/object/sp-use-reference.h b/src/object/sp-use-reference.h index 297bdc26c..650bce2a8 100644 --- a/src/object/sp-use-reference.h +++ b/src/object/sp-use-reference.h @@ -14,7 +14,7 @@ #include "sp-item.h" #include "uri-references.h" -class Path; +class SPCurve; namespace Inkscape { namespace XML { @@ -39,7 +39,7 @@ protected: class SPUsePath : public SPUseReference { public: - Path *originalPath; + SPCurve *originalPath; bool sourceDirty; SPObject *owner; |
