diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2019-09-16 14:41:18 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2019-09-16 14:41:18 +0000 |
| commit | c239b8d513fae662a4e3be85f85efb794d98d83d (patch) | |
| tree | c2528a5760b21acc685f13cde3b5426284d6fc5b /src | |
| parent | Allow paste on flowbox at same sice of origin, also improve creation to get r... (diff) | |
| download | inkscape-c239b8d513fae662a4e3be85f85efb794d98d83d.tar.gz inkscape-c239b8d513fae662a4e3be85f85efb794d98d83d.zip | |
Allow paste preserving new lines into a flowtext element
Diffstat (limited to 'src')
| -rw-r--r-- | src/object/sp-flowtext.cpp | 20 | ||||
| -rw-r--r-- | src/object/sp-flowtext.h | 1 | ||||
| -rw-r--r-- | src/object/sp-text.cpp | 11 | ||||
| -rw-r--r-- | src/ui/clipboard.cpp | 8 | ||||
| -rw-r--r-- | src/ui/toolbar/text-toolbar.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tools/text-tool.cpp | 7 |
6 files changed, 49 insertions, 4 deletions
diff --git a/src/object/sp-flowtext.cpp b/src/object/sp-flowtext.cpp index 05e06cff5..a488e208b 100644 --- a/src/object/sp-flowtext.cpp +++ b/src/object/sp-flowtext.cpp @@ -688,6 +688,26 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, return ft_item; } +void SPFlowtext::fix_overflow_flowregion(bool inverse) +{ + SPObject *object = dynamic_cast<SPObject *>(this); + SPFlowregion *flowregion = nullptr; + for (auto child : object->childList(false)) { + SPFlowregion *flowregion = dynamic_cast<SPFlowregion *>(child); + if (flowregion) { + object = dynamic_cast<SPObject *>(flowregion); + for (auto childshapes : object->childList(false)) { + Geom::Scale scale = Geom::Scale(1000); //200? maybe find better way to fix overglow issue removing new lines... + if (inverse) { + scale = scale.inverse(); + } + SP_SHAPE(childshapes)->doWriteTransform(scale, nullptr, true); + } + break; + } + } +} + Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) { if ((this->_optimizeScaledText && !xform.withoutTranslation().isNonzeroUniformScale()) diff --git a/src/object/sp-flowtext.h b/src/object/sp-flowtext.h index 386f0cc33..9baf64053 100644 --- a/src/object/sp-flowtext.h +++ b/src/object/sp-flowtext.h @@ -87,6 +87,7 @@ public: void update(SPCtx* ctx, unsigned int flags) override; void modified(unsigned int flags) override; + void fix_overflow_flowregion(bool inverse); Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags) override; diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp index 4dd5a9ff1..01e56633a 100644 --- a/src/object/sp-text.cpp +++ b/src/object/sp-text.cpp @@ -50,6 +50,7 @@ #include "sp-textpath.h" #include "sp-tref.h" #include "sp-tspan.h" +#include "sp-flowregion.h" #include "text-editing.h" @@ -390,9 +391,10 @@ void SPText::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape:: void SPText::hide_shape_inside() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + SPText *text = dynamic_cast<SPText *>(this); + SPObject *object = dynamic_cast<SPObject *>(this); SPStyle *item_style = this->style; - if (item_style && prefs->getBool("/tools/text/use_svg2") && item_style->shape_inside.set) { + if (item_style && text && 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"); @@ -405,8 +407,9 @@ void SPText::hide_shape_inside() void SPText::show_shape_inside() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (prefs->getBool("/tools/text/use_svg2") && css) { + SPText *text = dynamic_cast<SPText *>(this); + SPObject *object = dynamic_cast<SPObject *>(this); + if (text && css) { this->changeCSS(css, "style"); } } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index fb7bebc39..7341b8caf 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -65,6 +65,7 @@ #include "object/sp-rect.h" #include "object/sp-root.h" #include "object/sp-shape.h" +#include "object/sp-flowtext.h" #include "object/sp-textpath.h" #include "object/sp-use.h" #include "style.h" @@ -1093,6 +1094,10 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) if (textitem) { textitem->hide_shape_inside(); } + SPFlowtext *flowtext = dynamic_cast<SPFlowtext *>(tc->text); + if (flowtext) { + flowtext->fix_overflow_flowregion(false); + } // we realy only want to inherit container style /* SPCSSAttr *css = take_style_from_item(tc->text); for (int i = 0; i < nr_blocks; ++i) @@ -1123,6 +1128,9 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) if (textitem) { textitem->show_shape_inside(); } + if (flowtext) { + flowtext->fix_overflow_flowregion(true); + } } return true; } diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp index b0af522d3..aa9c0fecc 100644 --- a/src/ui/toolbar/text-toolbar.cpp +++ b/src/ui/toolbar/text-toolbar.cpp @@ -2296,6 +2296,9 @@ void TextToolbar::prepare_inner() if (text) { text->hide_shape_inside(); } + if (flowtext) { + flowtext->fix_overflow_flowregion(false); + } void *rawptr_start = nullptr; void *rawptr_end = nullptr; layout->getSourceOfCharacter(wrap_start, &rawptr_start); @@ -2303,6 +2306,9 @@ void TextToolbar::prepare_inner() if (text) { text->show_shape_inside(); } + if (flowtext) { + flowtext->fix_overflow_flowregion(true); + } if (!rawptr_start || !rawptr_end || !SP_IS_OBJECT(rawptr_start)|| !SP_IS_OBJECT(rawptr_end)) { return; } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 161b20aa2..5919d7fb2 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1326,6 +1326,10 @@ bool sp_text_paste_inline(ToolBase *ec) if (textitem) { textitem->hide_shape_inside(); } + SPFlowtext *flowtext = dynamic_cast<SPFlowtext *>(tc->text); + if (flowtext) { + flowtext->fix_overflow_flowregion(false); + } // Fix for 244940 // The XML standard defines the following as valid characters // (Extensible Markup Language (XML) 1.0 (Fourth Edition) paragraph 2.2) @@ -1374,6 +1378,9 @@ bool sp_text_paste_inline(ToolBase *ec) if (textitem) { textitem->show_shape_inside(); } + if (flowtext) { + flowtext->fix_overflow_flowregion(true); + } DocumentUndo::done(ec->desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Paste text")); |
