From bf052b6e7cb79317c4f38ff144a77b6f9e49421e Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Fri, 13 Sep 2019 22:09:42 +0200 Subject: Allow to paste paragraphs in SVG2 Flow then paste overflow the shape --- src/object/sp-text.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/object/sp-text.cpp') diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp index 91ca65170..4dd5a9ff1 100644 --- a/src/object/sp-text.cpp +++ b/src/object/sp-text.cpp @@ -63,7 +63,12 @@ SPText::SPText() : SPItem() { } -SPText::~SPText() = default; +SPText::~SPText() +{ + if (css) { + sp_repr_css_attr_unref(css); + } +}; void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) { this->readAttr( "x" ); @@ -76,7 +81,7 @@ void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) { this->readAttr( "textLength" ); this->readAttr( "lengthAdjust" ); SPItem::build(doc, repr); - + css = nullptr; this->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } @@ -383,6 +388,29 @@ void SPText::snappoints(std::vector &p, Inkscape:: } } +void SPText::hide_shape_inside() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + SPStyle *item_style = this->style; + if (item_style && prefs->getBool("/tools/text/use_svg2") && item_style->shape_inside.set) { + SPCSSAttr *css_unset = sp_css_attr_from_style(item_style, SP_STYLE_FLAG_IFSET); + css = sp_css_attr_from_style(item_style, SP_STYLE_FLAG_IFSET); + sp_repr_css_unset_property(css_unset, "shape-inside"); + sp_repr_css_attr_unref(css_unset); + this->changeCSS(css_unset, "style"); + } else { + css = nullptr; + } +} + +void SPText::show_shape_inside() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/tools/text/use_svg2") && css) { + this->changeCSS(css, "style"); + } +} + Geom::Affine SPText::set_transform(Geom::Affine const &xform) { // See if 'shape-inside' has rectangle Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -- cgit v1.2.3