From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/ui/tools/text-tool.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/ui/tools/text-tool.cpp') diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 1888551cf..559187764 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -23,7 +23,6 @@ #include #include #include -#include #include "context-fns.h" @@ -36,7 +35,6 @@ #include "message-stack.h" #include "pixmaps/cursor-text-insert.xpm" #include "pixmaps/cursor-text.xpm" -#include "preferences.h" #include "rubberband.h" #include "selection-chemistry.h" #include "selection.h" @@ -50,8 +48,6 @@ #include "ui/control-manager.h" #include "verbs.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" -#include using Inkscape::ControlManager; using Inkscape::DocumentUndo; -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/ui/tools/text-tool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ui/tools/text-tool.cpp') diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 559187764..1888551cf 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include #endif #include @@ -23,6 +23,7 @@ #include #include #include +#include #include "context-fns.h" @@ -35,6 +36,7 @@ #include "message-stack.h" #include "pixmaps/cursor-text-insert.xpm" #include "pixmaps/cursor-text.xpm" +#include "preferences.h" #include "rubberband.h" #include "selection-chemistry.h" #include "selection.h" @@ -48,6 +50,8 @@ #include "ui/control-manager.h" #include "verbs.h" #include "xml/node-event-vector.h" +#include "xml/repr.h" +#include using Inkscape::ControlManager; using Inkscape::DocumentUndo; -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/ui/tools/text-tool.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/ui/tools/text-tool.cpp') diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 1888551cf..559187764 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -23,7 +23,6 @@ #include #include #include -#include #include "context-fns.h" @@ -36,7 +35,6 @@ #include "message-stack.h" #include "pixmaps/cursor-text-insert.xpm" #include "pixmaps/cursor-text.xpm" -#include "preferences.h" #include "rubberband.h" #include "selection-chemistry.h" #include "selection.h" @@ -50,8 +48,6 @@ #include "ui/control-manager.h" #include "verbs.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" -#include using Inkscape::ControlManager; using Inkscape::DocumentUndo; -- cgit v1.2.3 From 0fad68e35604556b9a3af81b90d8cc6b89e817b8 Mon Sep 17 00:00:00 2001 From: Alexandru-Daniel Roman Date: Tue, 28 Feb 2017 13:48:29 +0200 Subject: This patch adds the copy-paste formated text functionality to the text tool. It doesn't retain the font-size and font-style properties. (bzr r15553) --- src/ui/tools/text-tool.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'src/ui/tools/text-tool.cpp') diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 559187764..649bbb045 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -48,6 +48,8 @@ #include "ui/control-manager.h" #include "verbs.h" #include "xml/node-event-vector.h" +#include "xml/attribute-record.h" +#include "xml/sp-css-attr.h" using Inkscape::ControlManager; using Inkscape::DocumentUndo; @@ -1357,6 +1359,59 @@ SPCSSAttr *sp_text_get_style_at_cursor(ToolBase const *ec) return NULL; } +static bool css_attrs_are_equal(SPCSSAttr const *first, SPCSSAttr const *second) +{ + Inkscape::Util::List attrs = first->attributeList(); + for ( ; attrs ; attrs++) { + gchar const *other_attr = second->attribute(g_quark_to_string(attrs->key)); + if (other_attr == NULL || strcmp(attrs->value, other_attr)) + return false; + } + attrs = second->attributeList(); + for ( ; attrs ; attrs++) { + gchar const *other_attr = first->attribute(g_quark_to_string(attrs->key)); + if (other_attr == NULL || strcmp(attrs->value, other_attr)) + return false; + } + return true; +} + +std::vector sp_text_get_selected_style(ToolBase const *ec, unsigned *k, int *b, std::vector *positions) +{ + std::vector vec; + SPCSSAttr *css, *css_new; + TextTool *tc = SP_TEXT_CONTEXT(ec); + Inkscape::Text::Layout::iterator i = std::min(tc->text_sel_start, tc->text_sel_end); + SPObject const *obj = sp_te_object_at_position(tc->text, i); + if (obj) { + css = take_style_from_item(const_cast(obj)); + } + vec.push_back(css); + positions->push_back(0); + i.nextCharacter(); + *k = 1; + *b = 1; + while (i != std::max(tc->text_sel_start, tc->text_sel_end)) + { + obj = sp_te_object_at_position(tc->text, i); + if (obj) { + css_new = take_style_from_item(const_cast(obj)); + } + if(!css_attrs_are_equal(css, css_new)) + { + vec.push_back(css_new); + css = sp_repr_css_attr_new(); + sp_repr_css_merge(css, css_new); + positions->push_back(*k); + (*b)++; + } + i.nextCharacter(); + (*k)++; + } + positions->push_back(*k); + return vec; +} + /** Deletes the currently selected characters. Returns false if there is no text selection currently. @@ -1442,7 +1497,6 @@ bool TextTool::_styleSet(SPCSSAttr const *css) _("Set text style")); sp_text_context_update_cursor(this); sp_text_context_update_text_selection(this); - return true; } -- cgit v1.2.3