From 6ee7c590a4e30b3fa5767bbabde8fa31e9f14927 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 26 May 2012 09:14:56 +0900 Subject: Fix for 903772 : Support --export-text-to-path when outputting plain SVG (bzr r11418) --- src/text-editing.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 8f005d86a..44b323989 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -34,6 +34,7 @@ #include "sp-flowtext.h" #include "sp-flowdiv.h" #include "sp-flowregion.h" +#include "sp-item-group.h" #include "sp-tref.h" #include "sp-tspan.h" @@ -62,6 +63,22 @@ static void te_update_layout_now (SPItem *item) item->updateRepr(); } +void te_update_layout_now_recursive(SPItem *item) +{ + if (SP_IS_GROUP(item)) { + GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); + for(GSList* elem = item_list; elem; elem = elem->next) { + SPItem* list_item = (SPItem*) elem->data; + te_update_layout_now_recursive(list_item); + } + g_slist_free(item_list); + } else if (SP_IS_TEXT(item)) + SP_TEXT(item)->rebuildLayout(); + else if (SP_IS_FLOWTEXT (item)) + SP_FLOWTEXT(item)->rebuildLayout(); + item->updateRepr(); +} + bool sp_te_output_is_empty(SPItem const *item) { Inkscape::Text::Layout const *layout = te_get_layout(item); -- cgit v1.2.3 From c8a761256b40300761c7ff6a0d642ac75b6f541a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 11 Feb 2013 23:34:59 +0000 Subject: A couple of forward declarations (bzr r12119) --- src/text-editing.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 44b323989..47b4d35ac 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -29,6 +29,7 @@ #include "document.h" #include "xml/repr.h" #include "xml/attribute-record.h" +#include "xml/sp-css-attr.h" #include "sp-textpath.h" #include "sp-flowtext.h" -- cgit v1.2.3 From f6c82a02188953dcb6d2119123ffc0aaa8d35010 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 16 Mar 2013 20:42:47 +0100 Subject: cppcheck (bzr r12217) --- src/text-editing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 47b4d35ac..401f56bb2 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -69,7 +69,7 @@ void te_update_layout_now_recursive(SPItem *item) if (SP_IS_GROUP(item)) { GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); for(GSList* elem = item_list; elem; elem = elem->next) { - SPItem* list_item = (SPItem*) elem->data; + SPItem* list_item = static_cast(elem->data); te_update_layout_now_recursive(list_item); } g_slist_free(item_list); -- cgit v1.2.3 From d19db89e2e22d4e09c539bd42823d511aebb669f Mon Sep 17 00:00:00 2001 From: David Mathog <> Date: Wed, 19 Jun 2013 19:20:33 +0200 Subject: changes_2013_05_22a.patch: 1. Resolves issue of bug #988601 message 170 (Support of 'Unset' styles in EMF export). 2. Implements CSS 3 (and CSS 2) text-decoration support. Note that it does not yet provide any method of adding these features - at present it just shows whatever is in the SVG. This new code is also used to display EMF/WMF strike-through and underline text decorations when these files are read in. Those decorations may also be written out to EMF/WMF. Other text decoration features, like overline, or dotted lines, are dropped. For SVG text-decoration -line, -style, -color are all implemented. CSS3 provides two ways to represent the same state, this code uses the compound text-decoration method rather than the 3 fields method. Also it leaves out keywords that are not needed and would break backwards compatibility. For instance: text-decoration: underline solid is valid, but would break CSS2. Solid is the default, so that sort of case is written as: text-decoration: underline If the state is CSS3 specific all of the needed fields are of course include, like text-decoration: underline wavy red 3. It incorporates the fix for bug 1181326 (Text edit mishandles span of just colored spaces) 4. It incorporates further changes to text editing so that style can be changed on spans consisting of only spaces when text decorations are present in the span. 5. It incorporates code to disable text decorations when text so marked is mapped onto a path. 6. Fixed more bugs in Hebrew language support than I can remember. Hebrew language export/import to EMF now works quite well. (See the examples in libTERE v 0.7.) WMF does not support unicode and for all intents and purposes Inkscape has no way to read or write Hebrew to it. Some of more important things that now work that didn't (or didn't always): Hebrew diacritical marks, R/L/center justification, and bidirectional text. The Hebrew fonts "Ezra SIL" and "EZRA SIL SR" should be installed before viewing the libTERE examples, otherwise font substitutions will cause some text shifts. 7. Implemented font failover in Text Reassemble, which makes the process more robust. (Again, see the examples in libTERE. ) (bzr r11668.1.71) --- src/text-editing.cpp | 58 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 401f56bb2..050917e03 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -43,7 +43,7 @@ static const gchar *tref_edit_message = _("You cannot edit cloned character data."); -static bool tidy_xml_tree_recursively(SPObject *root); +static bool tidy_xml_tree_recursively(SPObject *root, bool has_text_decoration); Inkscape::Text::Layout const * te_get_layout (SPItem const *item) { @@ -774,6 +774,10 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start, SPObject *common_ancestor = get_common_ancestor(item, start_item, end_item); + bool has_text_decoration = false; + gchar const *root_style = (item)->getRepr()->attribute("style"); + if(strstr(root_style,"text-decoration"))has_text_decoration = true; + if (start_item == end_item) { // the quick case where we're deleting stuff all from the same string if (SP_IS_STRING(start_item)) { // always true (if it_start != it_end anyway) @@ -835,7 +839,7 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start, } } - while (tidy_xml_tree_recursively(common_ancestor)){}; + while (tidy_xml_tree_recursively(common_ancestor, has_text_decoration)){}; te_update_layout_now(item); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); layout->validateIterator(&iter_pair.first); @@ -1554,7 +1558,7 @@ static SPObject* ascend_while_first(SPObject *item, Glib::ustring::iterator text /** empty spans: abcdef -> abcdef */ -static bool tidy_operator_empty_spans(SPObject **item) +static bool tidy_operator_empty_spans(SPObject **item, bool has_text_decoration) { bool result = false; if ( !(*item)->hasChildren() @@ -1572,7 +1576,7 @@ static bool tidy_operator_empty_spans(SPObject **item) /** inexplicable spans: abcdefghi -> "abc""def""ghi" the repeated strings will be merged by another operator. */ -static bool tidy_operator_inexplicable_spans(SPObject **item) +static bool tidy_operator_inexplicable_spans(SPObject **item, bool has_text_decoration) { //XML Tree being directly used here while it shouldn't be. if (*item && sp_repr_is_meta_element((*item)->getRepr())) { @@ -1607,7 +1611,7 @@ static bool tidy_operator_inexplicable_spans(SPObject **item) /** repeated spans: abcdef -> abcdef */ -static bool tidy_operator_repeated_spans(SPObject **item) +static bool tidy_operator_repeated_spans(SPObject **item, bool has_text_decoration) { SPObject *first = *item; SPObject *second = first->getNext(); @@ -1653,7 +1657,7 @@ static bool tidy_operator_repeated_spans(SPObject **item) -> abc excessive nesting: abc -> abc */ -static bool tidy_operator_excessive_nesting(SPObject **item) +static bool tidy_operator_excessive_nesting(SPObject **item, bool has_text_decoration) { if (!(*item)->hasChildren()) { return false; @@ -1731,7 +1735,7 @@ example. You may note that this only does its work when the doubly-nested child is the first or last. The other cases are called 'style inversion' below, and I'm not yet convinced that the result of that operation will be tidier in all cases. */ -static bool tidy_operator_redundant_double_nesting(SPObject **item) +static bool tidy_operator_redundant_double_nesting(SPObject **item, bool has_text_decoration) { if (!(*item)->hasChildren()) return false; if ((*item)->firstChild() == (*item)->lastChild()) return false; // this is excessive nesting, done above @@ -1792,7 +1796,7 @@ static bool redundant_semi_nesting_processor(SPObject **item, SPObject *child, b -> abcdef test this by applying a colour to a region, then a different colour to a partially-overlapping region. */ -static bool tidy_operator_redundant_semi_nesting(SPObject **item) +static bool tidy_operator_redundant_semi_nesting(SPObject **item, bool has_text_decoration) { if (!(*item)->hasChildren()) return false; if ((*item)->firstChild() == (*item)->lastChild()) return false; // this is redundant nesting, done above @@ -1819,13 +1823,21 @@ static SPString* find_last_string_child_not_equal_to(SPObject *root, SPObject *n return NULL; } -/** whitespace-only spans: abc def - -> abc def - abcdef ghi - -> abcdef ghi */ -static bool tidy_operator_styled_whitespace(SPObject **item) +/** whitespace-only spans: + abc def + -> abc def + abcdef ghi + -> abcdef ghi + + visible text-decoration changes on white spaces should not be subject + to this sort of processing. So + abc def + is unchanged. +*/ +static bool tidy_operator_styled_whitespace(SPObject **item, bool has_text_decoration) { - if (!SP_IS_STRING(*item)) { + // any type of visible text decoration is OK as pure spaces, so do nothing here in that case. + if (!SP_IS_STRING(*item) || has_text_decoration ) { return false; } Glib::ustring const &str = SP_STRING(*item)->string; @@ -1835,6 +1847,7 @@ static bool tidy_operator_styled_whitespace(SPObject **item) } } + SPObject *test_item = *item; SPString *next_string; for ( ; ; ) { // find the next string @@ -1862,7 +1875,7 @@ static bool tidy_operator_styled_whitespace(SPObject **item) if (next_string == NULL) { return false; // an empty paragraph } - next_string->string += str; + next_string->string = str + next_string->string; break; } } @@ -1896,9 +1909,11 @@ It may be that some of the later tidy operators that I wrote are actually general cases of the earlier operators, and hence the special-case-only versions can be removed. I haven't analysed my work in detail to figure out if this is so. */ -static bool tidy_xml_tree_recursively(SPObject *root) +static bool tidy_xml_tree_recursively(SPObject *root, bool has_text_decoration) { - static bool (* const tidy_operators[])(SPObject**) = { + gchar const *root_style = (root)->getRepr()->attribute("style"); + if(root_style && strstr(root_style,"text-decoration"))has_text_decoration = true; + static bool (* const tidy_operators[])(SPObject**, bool) = { tidy_operator_empty_spans, tidy_operator_inexplicable_spans, tidy_operator_repeated_spans, @@ -1915,12 +1930,12 @@ static bool tidy_xml_tree_recursively(SPObject *root) continue; } if (child->hasChildren()) { - changes |= tidy_xml_tree_recursively(child); + changes |= tidy_xml_tree_recursively(child, has_text_decoration); } unsigned i; for (i = 0 ; i < sizeof(tidy_operators) / sizeof(tidy_operators[0]) ; i++) { - if (tidy_operators[i](&child)) { + if (tidy_operators[i](&child, has_text_decoration)) { changes = true; break; } @@ -2018,7 +2033,10 @@ void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &sta and neither option can be made to work, a fallback could be to reduce everything to a single level of nesting and drop all pretence of roundtrippability. */ - while (tidy_xml_tree_recursively(common_ancestor)){}; + bool has_text_decoration = false; + gchar const *root_style = (text)->getRepr()->attribute("style"); + if(strstr(root_style,"text-decoration"))has_text_decoration = true; + while (tidy_xml_tree_recursively(common_ancestor, has_text_decoration)){}; // if we only modified subobjects this won't have been automatically sent text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); -- cgit v1.2.3 From f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 18:33:03 -0400 Subject: Eliminate "unit-constants.h". (bzr r12380.1.54) --- src/text-editing.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 401f56bb2..0d30863d9 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -24,7 +24,7 @@ #include "inkscape.h" #include "message-stack.h" #include "style.h" -#include "unit-constants.h" +#include "util/units.h" #include "document.h" #include "xml/repr.h" @@ -1278,23 +1278,23 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_PT: - style->line_height.computed += zby * PT_PER_PX; + style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "pt"); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_PC: - style->line_height.computed += zby * (PT_PER_PX / 12); + style->line_height.computed += zby * (Inkscape::Util::Quantity::convert(1, "px", "pt") / 12); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_MM: - style->line_height.computed += zby * MM_PER_PX; + style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "mm"); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_CM: - style->line_height.computed += zby * CM_PER_PX; + style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "cm"); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_IN: - style->line_height.computed += zby * IN_PER_PX; + style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "in"); style->line_height.value = style->line_height.computed; break; } -- cgit v1.2.3 From d98298d1434a666d24434aa08cdff878ee51a039 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Sep 2013 19:17:51 +0200 Subject: improve legibility (bzr r12505) --- src/text-editing.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 3cb896cb7..cf1c4811f 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1282,23 +1282,23 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_PT: - style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "pt"); + style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "pt"); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_PC: - style->line_height.computed += zby * (Inkscape::Util::Quantity::convert(1, "px", "pt") / 12); + style->line_height.computed += (Inkscape::Util::Quantity::convert(zby, "px", "pt") / 12); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_MM: - style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "mm"); + style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "mm"); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_CM: - style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "cm"); + style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "cm"); style->line_height.value = style->line_height.computed; break; case SP_CSS_UNIT_IN: - style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "in"); + style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "in"); style->line_height.value = style->line_height.computed; break; } -- cgit v1.2.3 From e3aea550bec92bbb79e9ce5d6d0e1c357eff60b7 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 28 Oct 2013 10:31:07 +0100 Subject: "fix" some "unused parameter" warnings (bzr r12738) --- src/text-editing.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index cf1c4811f..cae123616 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1558,7 +1558,7 @@ static SPObject* ascend_while_first(SPObject *item, Glib::ustring::iterator text /** empty spans: abcdef -> abcdef */ -static bool tidy_operator_empty_spans(SPObject **item, bool has_text_decoration) +static bool tidy_operator_empty_spans(SPObject **item, bool /*has_text_decoration*/) { bool result = false; if ( !(*item)->hasChildren() @@ -1576,7 +1576,7 @@ static bool tidy_operator_empty_spans(SPObject **item, bool has_text_decoration) /** inexplicable spans: abcdefghi -> "abc""def""ghi" the repeated strings will be merged by another operator. */ -static bool tidy_operator_inexplicable_spans(SPObject **item, bool has_text_decoration) +static bool tidy_operator_inexplicable_spans(SPObject **item, bool /*has_text_decoration*/) { //XML Tree being directly used here while it shouldn't be. if (*item && sp_repr_is_meta_element((*item)->getRepr())) { @@ -1611,7 +1611,7 @@ static bool tidy_operator_inexplicable_spans(SPObject **item, bool has_text_deco /** repeated spans: abcdef -> abcdef */ -static bool tidy_operator_repeated_spans(SPObject **item, bool has_text_decoration) +static bool tidy_operator_repeated_spans(SPObject **item, bool /*has_text_decoration*/) { SPObject *first = *item; SPObject *second = first->getNext(); @@ -1657,7 +1657,7 @@ static bool tidy_operator_repeated_spans(SPObject **item, bool has_text_decorati -> abc excessive nesting: abc -> abc */ -static bool tidy_operator_excessive_nesting(SPObject **item, bool has_text_decoration) +static bool tidy_operator_excessive_nesting(SPObject **item, bool /*has_text_decoration*/) { if (!(*item)->hasChildren()) { return false; @@ -1735,7 +1735,7 @@ example. You may note that this only does its work when the doubly-nested child is the first or last. The other cases are called 'style inversion' below, and I'm not yet convinced that the result of that operation will be tidier in all cases. */ -static bool tidy_operator_redundant_double_nesting(SPObject **item, bool has_text_decoration) +static bool tidy_operator_redundant_double_nesting(SPObject **item, bool /*has_text_decoration*/) { if (!(*item)->hasChildren()) return false; if ((*item)->firstChild() == (*item)->lastChild()) return false; // this is excessive nesting, done above @@ -1796,7 +1796,7 @@ static bool redundant_semi_nesting_processor(SPObject **item, SPObject *child, b -> abcdef test this by applying a colour to a region, then a different colour to a partially-overlapping region. */ -static bool tidy_operator_redundant_semi_nesting(SPObject **item, bool has_text_decoration) +static bool tidy_operator_redundant_semi_nesting(SPObject **item, bool /*has_text_decoration*/) { if (!(*item)->hasChildren()) return false; if ((*item)->firstChild() == (*item)->lastChild()) return false; // this is redundant nesting, done above -- cgit v1.2.3