diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 02fec31d170f04495d7c8ae4ba753b85d815ba77..b92d85b15f03c8428464a3da065489f696335eb4 100644 (file)
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
# include "config.h"
#endif
# include "config.h"
#endif
+#include <cstring>
+#include <string>
#include <glibmm/i18n.h>
#include "desktop.h"
#include <glibmm/i18n.h>
#include "desktop.h"
Inkscape::Text::Layout::iterator
sp_te_get_position_by_coords (SPItem const *item, NR::Point &i_p)
{
Inkscape::Text::Layout::iterator
sp_te_get_position_by_coords (SPItem const *item, NR::Point &i_p)
{
- NR::Matrix im=sp_item_i2d_affine (item);
+ NR::Matrix im = from_2geom(sp_item_i2d_affine (item));
im = im.inverse();
NR::Point p = i_p * im;
im = im.inverse();
NR::Point p = i_p * im;
if (object) {
if (SP_IS_TEXT(object)
if (object) {
if (SP_IS_TEXT(object)
+ || (SP_IS_TSPAN(object) && SP_TSPAN(object)->role != SP_TSPAN_ROLE_UNSPECIFIED)
|| SP_IS_TEXTPATH(object)
|| SP_IS_FLOWDIV(object)
|| SP_IS_FLOWPARA(object)
|| SP_IS_TEXTPATH(object)
|| SP_IS_FLOWDIV(object)
|| SP_IS_FLOWPARA(object)
is_line_break = true;
}
is_line_break = true;
}
-
- if (SP_IS_TSPAN(object) && SP_TSPAN(object)->role != SP_TSPAN_ROLE_UNSPECIFIED) {
- SPObject *prev_object = SP_OBJECT_PREV(object);
- if (prev_object && SP_IS_TSPAN(prev_object)) {
- is_line_break = true;
- }
- }
}
return is_line_break;
}
return is_line_break;
@@ -274,6 +270,9 @@ static Inkscape::XML::Node* duplicate_node_without_children(Inkscape::XML::Docum
case Inkscape::XML::COMMENT_NODE:
return xml_doc->createComment(old_node->content());
case Inkscape::XML::COMMENT_NODE:
return xml_doc->createComment(old_node->content());
+ case Inkscape::XML::PI_NODE:
+ return xml_doc->createPI(old_node->name(), old_node->content());
+
case Inkscape::XML::DOCUMENT_NODE:
return NULL; // this had better never happen
}
case Inkscape::XML::DOCUMENT_NODE:
return NULL; // this had better never happen
}
@@ -399,7 +398,7 @@ Inkscape::Text::Layout::iterator sp_te_insert_line (SPItem *item, Inkscape::Text
// TODO
// I think the only case to put here is arbitrary gaps, which nobody uses yet
}
// TODO
// I think the only case to put here is arbitrary gaps, which nobody uses yet
}
- item->updateRepr(SP_OBJECT_REPR(item),SP_OBJECT_WRITE_EXT);
+ item->updateRepr();
unsigned char_index = layout->iteratorToCharIndex(position);
te_update_layout_now(item);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
unsigned char_index = layout->iteratorToCharIndex(position);
te_update_layout_now(item);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -521,7 +520,7 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
}
}
}
}
- item->updateRepr(SP_OBJECT_REPR(item),SP_OBJECT_WRITE_EXT);
+ item->updateRepr();
unsigned char_index = layout->iteratorToCharIndex(position);
te_update_layout_now(item);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
unsigned char_index = layout->iteratorToCharIndex(position);
te_update_layout_now(item);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -949,7 +948,7 @@ sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator cons
// divide increment by zoom
// divide increment by matrix expansion
gdouble factor = 1 / desktop->current_zoom();
// divide increment by zoom
// divide increment by matrix expansion
gdouble factor = 1 / desktop->current_zoom();
- NR::Matrix t = sp_item_i2doc_affine(item);
+ NR::Matrix t = from_2geom(sp_item_i2doc_affine(item));
factor = factor / NR::expansion(t);
by = factor * by;
factor = factor / NR::expansion(t);
by = factor * by;
@@ -971,7 +970,7 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons
// divide increment by zoom
// divide increment by matrix expansion
gdouble factor = 1 / desktop->current_zoom();
// divide increment by zoom
// divide increment by matrix expansion
gdouble factor = 1 / desktop->current_zoom();
- NR::Matrix t = sp_item_i2doc_affine(text);
+ NR::Matrix t = from_2geom(sp_item_i2doc_affine(text));
factor = factor / NR::expansion(t);
Inkscape::Text::Layout const *layout = te_get_layout(text);
if (layout == NULL) return;
factor = factor / NR::expansion(t);
Inkscape::Text::Layout const *layout = te_get_layout(text);
if (layout == NULL) return;
@@ -986,7 +985,7 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons
}
void
}
void
-sp_te_adjust_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble degrees)
+sp_te_adjust_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop */*desktop*/, gdouble degrees)
{
unsigned char_index;
TextTagAttributes *attributes = text_tag_attributes_at_position(text, std::min(start, end), &char_index);
{
unsigned char_index;
TextTagAttributes *attributes = text_tag_attributes_at_position(text, std::min(start, end), &char_index);
@@ -1056,7 +1055,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it
gdouble const zoom = desktop->current_zoom();
gdouble const zby = (by
/ (zoom * (nb_let > 1 ? nb_let - 1 : 1))
gdouble const zoom = desktop->current_zoom();
gdouble const zby = (by
/ (zoom * (nb_let > 1 ? nb_let - 1 : 1))
- / NR::expansion(sp_item_i2doc_affine(SP_ITEM(source_obj))));
+ / NR::expansion(from_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj)))));
val += zby;
if (start == end) {
val += zby;
if (start == end) {
@@ -1087,8 +1086,21 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it
text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
}
text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
}
+double
+sp_te_get_average_linespacing (SPItem *text)
+{
+ Inkscape::Text::Layout const *layout = te_get_layout(text);
+ if (!layout)
+ return 0;
+
+ unsigned line_count = layout->lineIndex(layout->end());
+ double all_lines_height = layout->characterAnchorPoint(layout->end())[NR::Y] - layout->characterAnchorPoint(layout->begin())[NR::Y];
+ double average_line_height = all_lines_height / (line_count == 0 ? 1 : line_count);
+ return average_line_height;
+}
+
void
void
-sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble by)
+sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator const &/*start*/, Inkscape::Text::Layout::iterator const &/*end*/, SPDesktop *desktop, gdouble by)
{
// TODO: use start and end iterators to delineate the area to be affected
g_return_if_fail (text != NULL);
{
// TODO: use start and end iterators to delineate the area to be affected
g_return_if_fail (text != NULL);
@@ -1115,7 +1127,7 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count));
// divide increment by matrix expansion
gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count));
// divide increment by matrix expansion
- NR::Matrix t = sp_item_i2doc_affine (SP_ITEM(text));
+ NR::Matrix t = from_2geom(sp_item_i2doc_affine (SP_ITEM(text)));
zby = zby / NR::expansion(t);
switch (style->line_height.unit) {
zby = zby / NR::expansion(t);
switch (style->line_height.unit) {
@@ -1134,27 +1146,27 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
else style->line_height.value *= (average_line_height + zby) / average_line_height;
break;
// absolute-type units
else style->line_height.value *= (average_line_height + zby) / average_line_height;
break;
// absolute-type units
- case SP_CSS_UNIT_PX:
+ case SP_CSS_UNIT_PX:
style->line_height.computed += zby;
style->line_height.value = style->line_height.computed;
break;
style->line_height.computed += zby;
style->line_height.value = style->line_height.computed;
break;
- case SP_CSS_UNIT_PT:
+ case SP_CSS_UNIT_PT:
style->line_height.computed += zby * PT_PER_PX;
style->line_height.value = style->line_height.computed;
break;
style->line_height.computed += zby * PT_PER_PX;
style->line_height.value = style->line_height.computed;
break;
- case SP_CSS_UNIT_PC:
+ case SP_CSS_UNIT_PC:
style->line_height.computed += zby * (PT_PER_PX / 12);
style->line_height.value = style->line_height.computed;
break;
style->line_height.computed += zby * (PT_PER_PX / 12);
style->line_height.value = style->line_height.computed;
break;
- case SP_CSS_UNIT_MM:
+ case SP_CSS_UNIT_MM:
style->line_height.computed += zby * MM_PER_PX;
style->line_height.value = style->line_height.computed;
break;
style->line_height.computed += zby * MM_PER_PX;
style->line_height.value = style->line_height.computed;
break;
- case SP_CSS_UNIT_CM:
+ case SP_CSS_UNIT_CM:
style->line_height.computed += zby * CM_PER_PX;
style->line_height.value = style->line_height.computed;
break;
style->line_height.computed += zby * CM_PER_PX;
style->line_height.value = style->line_height.computed;
break;
- case SP_CSS_UNIT_IN:
+ case SP_CSS_UNIT_IN:
style->line_height.computed += zby * IN_PER_PX;
style->line_height.value = style->line_height.computed;
break;
style->line_height.computed += zby * IN_PER_PX;
style->line_height.value = style->line_height.computed;
break;