Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
text-editing.cpp File Reference

Go to the source code of this file.

Functions

static void move_child_nodes (Inkscape::XML::Node *from_repr, Inkscape::XML::Node *to_repr, bool prepend)
 moves all the children of from_repr to to_repr, either before the existing children or after them.
 
static bool tidy_xml_tree_recursively (SPObject *root, bool has_text_decoration)
 Recursively walks the xml tree calling a set of cleanup operations on every child.
 
Inkscape::Text::Layout const * te_get_layout (SPItem const *item)
 
static void te_update_layout_now (SPItem *item)
 
void te_update_layout_now_recursive (SPItem *item)
 
bool sp_te_output_is_empty (SPItem const *item)
 Returns true if there are no visible characters on the canvas.
 
bool sp_te_input_is_empty (SPObject const *item)
 Returns true if the user has typed nothing in the text box.
 
Inkscape::Text::Layout::iterator sp_te_get_position_by_coords (SPItem const *item, Geom::Point const &i_p)
 
std::vector< Geom::Pointsp_te_create_selection_quads (SPItem const *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, Geom::Affine const &transform)
 
void sp_te_get_cursor_coords (SPItem const *item, Inkscape::Text::Layout::iterator const &position, Geom::Point &p0, Geom::Point &p1)
 
SPStyle const * sp_te_style_at_position (SPItem const *text, Inkscape::Text::Layout::iterator const &position)
 
SPObject const * sp_te_object_at_position (SPItem const *text, Inkscape::Text::Layout::iterator const &position)
 
Inkscape::Text::Layout::iterator sp_te_replace (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, gchar const *utf8)
 
static bool is_line_break_object (SPObject const *object)
 
static TextTagAttributesattributes_for_object (SPObject *object)
 returns the attributes for an object, or NULL if it isn't a text, tspan, tref, or textpath.
 
static const char * span_name_for_text_object (SPObject const *object)
 
unsigned sp_text_get_length (SPObject const *item)
 Recursively gets the length of all the SPStrings at or below the given item.
 
unsigned sp_text_get_length_upto (SPObject const *item, SPObject const *upto)
 Recursively gets the length of all the SPStrings at or below the given item, before and not including upto.
 
static Inkscape::XML::Nodeduplicate_node_without_children (Inkscape::XML::Document *xml_doc, Inkscape::XML::Node const *old_node)
 
static unsigned sum_sibling_text_lengths_before (SPObject const *item)
 returns the sum of the (recursive) lengths of all the SPStrings prior to item at the same level.
 
static void split_attributes (SPObject *first_item, SPObject *second_item, unsigned char_index)
 splits the attributes for the first object at the given char_index and moves the ones after that point into second_item.
 
static SPObjectsplit_text_object_tree_at (SPObject *split_obj, unsigned char_index)
 recursively divides the XML node tree into two objects: the original will contain all objects up to and including split_obj and the returned value will be the new leaf which represents the copy of split_obj and extends down the tree with new elements all the way to the common root which is the parent of the first line break node encountered.
 
Inkscape::Text::Layout::iterator sp_te_insert_line (SPItem *item, Inkscape::Text::Layout::iterator &position)
 inserts a new line break at the given position in a text or flowtext object.
 
static SPStringsp_te_seek_next_string_recursive (SPObject *start_obj)
 finds the first SPString after the given position, including children, excluding parents
 
static void insert_into_spstring (SPString *string_item, Glib::ustring::iterator iter_at, gchar const *utf8)
 inserts the given characters into the given string and inserts corresponding new x/y/dx/dy/rotate attributes into all its parents.
 
Inkscape::Text::Layout::iterator sp_te_insert (SPItem *item, Inkscape::Text::Layout::iterator const &position, gchar const *utf8)
 Inserts the given text into a text or flowroot object.
 
static SPObjectget_common_ancestor (SPObject *text, SPObject *one, SPObject *two)
 returns the object in the tree which is the closest ancestor of both one and two.
 
static void move_to_end_of_paragraph (SPObject **para_obj, Glib::ustring::iterator *text_iter)
 positions para_obj and text_iter to be pointing at the end of the last string in the last leaf object of para_obj.
 
static SPObjectdelete_line_break (SPObject *root, SPObject *item, bool *next_is_sibling)
 delete the line break pointed to by item by merging its children into the next suitable object and deleting item.
 
static void erase_from_spstring (SPString *string_item, Glib::ustring::iterator iter_from, Glib::ustring::iterator iter_to)
 erases the given characters from the given string and deletes the corresponding x/y/dx/dy/rotate attributes from all its parents.
 
bool sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, iterator_pair &iter_pair)
 
static void sp_te_get_ustring_multiline (SPObject const *root, Glib::ustring *string, bool *pending_line_break)
 Gets a text-only representation of the given text or flowroot object, replacing line break elements with '
'.
 
Glib::ustring sp_te_get_string_multiline (SPItem const *text)
 Gets a text-only representation of the given text or flowroot object, replacing line break elements with '
'.
 
Glib::ustring sp_te_get_string_multiline (SPItem const *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end)
 Gets a text-only representation of the characters in a text or flowroot object from start to end only.
 
void sp_te_set_repr_text_multiline (SPItem *text, gchar const *str)
 
TextTagAttributestext_tag_attributes_at_position (SPItem *item, Inkscape::Text::Layout::iterator const &position, unsigned *char_index)
 Returns the attributes block and the character index within that block which represents the iterator position.
 
void sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, Geom::Point by)
 
void sp_te_adjust_dx (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, double delta)
 
void sp_te_adjust_dy (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, double delta)
 
void sp_te_adjust_rotation_screen (SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble pixels)
 
void sp_te_adjust_rotation (SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, gdouble degrees)
 
void sp_te_set_rotation (SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *, gdouble degrees)
 
void sp_te_adjust_tspan_letterspacing_screen (SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, gdouble by)
 
double sp_te_get_average_linespacing (SPItem *text)
 
void sp_te_adjust_line_height (SPObject *object, double amount, double average, bool top_level=true)
 Adjust the line height by 'amount'.
 
void sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator const &, Inkscape::Text::Layout::iterator const &, SPDesktop *desktop, gdouble by)
 
static unsigned char_index_of_iterator (Glib::ustring const &string, Glib::ustring::const_iterator text_iter)
 converts an iterator to a character index, mainly because ustring::substr() doesn't have a version that takes iterators as parameters.
 
static void overwrite_style_with_string (SPObject *item, gchar const *style_string)
 applies the given style string on top of the existing styles for item, as opposed to sp_style_merge_from_style_string which merges its parameter underneath the existing styles (ie ignoring already set properties).
 
static bool objects_have_equal_style (SPObject const *parent, SPObject const *child)
 Returns true if the style of parent and the style of child are equivalent (and hence the children of both will appear the same).
 
static bool css_attrs_are_equal (SPCSSAttr const *first, SPCSSAttr const *second)
 returns true if first and second contain all the same attributes with the same values as each other.
 
static void apply_css_recursive (SPObject *o, SPCSSAttr const *css)
 sets the given css attribute on this object and all its descendants.
 
static void recursively_apply_style (SPObject *common_ancestor, SPCSSAttr const *css, SPObject *start_item, Glib::ustring::iterator start_text_iter, SPObject *end_item, Glib::ustring::iterator end_text_iter, char const *span_object_name)
 applies the given style to all the objects at the given level and below which are between start_item and end_item, creating spans as necessary.
 
static SPObjectascend_while_first (SPObject *item, Glib::ustring::iterator text_iter, SPObject *common_ancestor)
 
static bool tidy_operator_empty_spans (SPObject **item, bool)
 empty spans: abc<span>def -> abcdef

 
static bool tidy_operator_inexplicable_spans (SPObject **item, bool)
 inexplicable spans: abcdefghi -> "abc""def""ghi" the repeated strings will be merged by another operator.
 
static bool tidy_operator_repeated_spans (SPObject **item, bool)
 repeated spans: <font a>abc</font><font a>def</font> -> <font a>abcdef</font>

 
static bool tidy_operator_excessive_nesting (SPObject **item, bool)
 redundant nesting: <font a><font b>abc</font></font> -> <font b>abc</font> excessive nesting: <font a><size 1>abc</size></font> -> <font a,size 1>abc</font>

 
static bool redundant_double_nesting_processor (SPObject **item, SPObject *child, bool prepend)
 helper for tidy_operator_redundant_double_nesting()
 
static bool tidy_operator_redundant_double_nesting (SPObject **item, bool)
 redundant double nesting: <font b><font a><font b>abc</font>def</font>ghi</font> -> <font b>abc<font a>def</font>ghi</font> this function does its work when the parameter is the <font a> tag in the example.
 
static bool redundant_semi_nesting_processor (SPObject **item, SPObject *child, bool prepend)
 helper for tidy_operator_redundant_semi_nesting().
 
static bool tidy_operator_redundant_semi_nesting (SPObject **item, bool)
 redundant semi-nesting: <font a><font b>abc</font>def</font> -> <font b>abc</font><font>def</font> test this by applying a colour to a region, then a different colour to a partially-overlapping region.
 
static SPStringfind_last_string_child_not_equal_to (SPObject *root, SPObject *not_obj)
 helper for tidy_operator_styled_whitespace(), finds the last string object in a paragraph which is not not_obj.
 
static bool tidy_operator_styled_whitespace (SPObject **item, bool has_text_decoration)
 whitespace-only spans: abc<font> </font>def -> abc<font></font> def abcdef ghi -> abcdef ghi
 
void sp_te_apply_style (SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPCSSAttr const *css)
 Applies the given CSS fragment to the characters of the given text or flowtext object between start and end, creating or removing span elements as necessary and optimal.
 
bool is_part_of_text_subtree (SPObject const *obj)
 
bool is_top_level_text_object (SPObject const *obj)
 
bool has_visible_text (SPObject const *obj)
 

Variables

static const gchar * tref_edit_message = _("You cannot edit <b>cloned character data</b>.")
 

Function Documentation

◆ apply_css_recursive()

static void apply_css_recursive ( SPObject o,
SPCSSAttr const *  css 
)
static

sets the given css attribute on this object and all its descendants.

Annoyingly similar to sp_desktop_apply_css_recursive(), except without the transform stuff.

Definition at line 1497 of file text-editing.cpp.

References apply_css_recursive(), child, SPObject::children, css, SPObject::getRepr(), sp_repr_css_attr_new(), sp_repr_css_attr_unref(), sp_repr_css_change(), sp_repr_css_merge(), sp_repr_css_property(), and sp_repr_css_set_property().

Referenced by apply_css_recursive(), and recursively_apply_style().

◆ ascend_while_first()

static SPObject * ascend_while_first ( SPObject item,
Glib::ustring::iterator  text_iter,
SPObject common_ancestor 
)
static

Definition at line 1629 of file text-editing.cpp.

References SPObject::firstChild(), item, parent, and SPObject::parent.

Referenced by sp_te_apply_style().

◆ attributes_for_object()

◆ char_index_of_iterator()

static unsigned char_index_of_iterator ( Glib::ustring const &  string,
Glib::ustring::const_iterator  text_iter 
)
static

converts an iterator to a character index, mainly because ustring::substr() doesn't have a version that takes iterators as parameters.

Definition at line 1410 of file text-editing.cpp.

Referenced by recursively_apply_style().

◆ css_attrs_are_equal()

static bool css_attrs_are_equal ( SPCSSAttr const *  first,
SPCSSAttr const *  second 
)
static

returns true if first and second contain all the same attributes with the same values as each other.

Note that we have to compare both forwards and backwards to make sure we don't miss any attributes that are in one but not the other.

Definition at line 1479 of file text-editing.cpp.

References Inkscape::XML::Node::attribute(), and Inkscape::XML::Node::attributeList().

Referenced by redundant_semi_nesting_processor().

◆ delete_line_break()

◆ duplicate_node_without_children()

◆ erase_from_spstring()

static void erase_from_spstring ( SPString string_item,
Glib::ustring::iterator  iter_from,
Glib::ustring::iterator  iter_to 
)
static

erases the given characters from the given string and deletes the corresponding x/y/dx/dy/rotate attributes from all its parents.

Definition at line 754 of file text-editing.cpp.

References attributes_for_object(), TextTagAttributes::erase(), SPObject::getRepr(), SPObject::parent, Inkscape::XML::Node::setContent(), SPString::string, sum_sibling_text_lengths_before(), and TextTagAttributes::writeTo().

Referenced by sp_te_delete().

◆ find_last_string_child_not_equal_to()

static SPString * find_last_string_child_not_equal_to ( SPObject root,
SPObject not_obj 
)
static

helper for tidy_operator_styled_whitespace(), finds the last string object in a paragraph which is not not_obj.

Definition at line 1911 of file text-editing.cpp.

References child, find_last_string_child_not_equal_to(), SPObject::lastChild(), and root.

Referenced by find_last_string_child_not_equal_to(), and tidy_operator_styled_whitespace().

◆ get_common_ancestor()

static SPObject * get_common_ancestor ( SPObject text,
SPObject one,
SPObject two 
)
static

returns the object in the tree which is the closest ancestor of both one and two.

It will never return anything higher than text.

Definition at line 657 of file text-editing.cpp.

References SPObject::isAncestorOf(), and SPObject::parent.

Referenced by sp_te_apply_style(), and sp_te_delete().

◆ has_visible_text()

bool has_visible_text ( SPObject const *  obj)

Definition at line 2166 of file text-editing.cpp.

References child, SPObject::children, has_visible_text(), and is_part_of_text_subtree().

Referenced by has_visible_text().

◆ insert_into_spstring()

static void insert_into_spstring ( SPString string_item,
Glib::ustring::iterator  iter_at,
gchar const *  utf8 
)
static

inserts the given characters into the given string and inserts corresponding new x/y/dx/dy/rotate attributes into all its parents.

Definition at line 531 of file text-editing.cpp.

References attributes_for_object(), TextTagAttributes::insert(), SPObject::parent, SPString::string, and sum_sibling_text_lengths_before().

Referenced by sp_te_insert().

◆ is_line_break_object()

◆ is_part_of_text_subtree()

bool is_part_of_text_subtree ( SPObject const *  obj)

Definition at line 2148 of file text-editing.cpp.

Referenced by has_visible_text(), and sp_te_get_ustring_multiline().

◆ is_top_level_text_object()

bool is_top_level_text_object ( SPObject const *  obj)

Definition at line 2160 of file text-editing.cpp.

◆ move_child_nodes()

static void move_child_nodes ( Inkscape::XML::Node from_repr,
Inkscape::XML::Node to_repr,
bool  prepend 
)
static

◆ move_to_end_of_paragraph()

static void move_to_end_of_paragraph ( SPObject **  para_obj,
Glib::ustring::iterator *  text_iter 
)
static

positions para_obj and text_iter to be pointing at the end of the last string in the last leaf object of para_obj.

If the last leaf is not an SPString then text_iter will be unchanged.

Definition at line 674 of file text-editing.cpp.

References SPObject::lastChild().

Referenced by sp_te_delete().

◆ objects_have_equal_style()

static bool objects_have_equal_style ( SPObject const *  parent,
SPObject const *  child 
)
static

Returns true if the style of parent and the style of child are equivalent (and hence the children of both will appear the same).

It is a limitation of the current implementation that parent must be a (not necessarily immediate) ancestor of child.

Definition at line 1439 of file text-editing.cpp.

References child, SPStyle::mergeString(), parent, SP_STYLE_FLAG_ALWAYS(), and SPStyle::write().

Referenced by redundant_double_nesting_processor(), and tidy_operator_inexplicable_spans().

◆ overwrite_style_with_string()

static void overwrite_style_with_string ( SPObject item,
gchar const *  style_string 
)
static

applies the given style string on top of the existing styles for item, as opposed to sp_style_merge_from_style_string which merges its parameter underneath the existing styles (ie ignoring already set properties).

Definition at line 1422 of file text-editing.cpp.

References Inkscape::XML::Node::attribute(), SPObject::document, SPObject::getRepr(), item, SPStyle::mergeString(), SPObject::setAttributeOrRemoveIfEmpty(), and SPStyle::write().

Referenced by tidy_operator_excessive_nesting().

◆ recursively_apply_style()

static void recursively_apply_style ( SPObject common_ancestor,
SPCSSAttr const *  css,
SPObject start_item,
Glib::ustring::iterator  start_text_iter,
SPObject end_item,
Glib::ustring::iterator  end_text_iter,
char const *  span_object_name 
)
static

applies the given style to all the objects at the given level and below which are between start_item and end_item, creating spans as necessary.

If start_item or end_item are NULL then the style is applied to all objects to the beginning or end respectively. span_object_name is the name of the xml for a text span (ie tspan or flowspan).

Definition at line 1521 of file text-editing.cpp.

References Inkscape::XML::Node::addChild(), Inkscape::GC::anchor(), Inkscape::XML::Node::appendChild(), apply_css_recursive(), char_index_of_iterator(), child, Inkscape::XML::Document::createElement(), Inkscape::XML::Document::createTextNode(), css, SPObject::document, SPObject::firstChild(), SPObject::get_child_by_repr(), SPObject::getPrev(), SPObject::getRepr(), SPDocument::getReprDoc(), SPObject::isAncestorOf(), recursively_apply_style(), Inkscape::GC::release(), Inkscape::XML::Node::removeChild(), and sp_repr_css_set().

Referenced by recursively_apply_style(), and sp_te_apply_style().

◆ redundant_double_nesting_processor()

◆ redundant_semi_nesting_processor()

◆ sp_te_adjust_dx()

◆ sp_te_adjust_dy()

◆ sp_te_adjust_kerning_screen()

◆ sp_te_adjust_line_height()

void sp_te_adjust_line_height ( SPObject object,
double  amount,
double  average,
bool  top_level = true 
)

Adjust the line height by 'amount'.

If top_level is true then 'line-height' will be set where possible, otherwise objects that inherit line-height will not be touched.

Definition at line 1297 of file text-editing.cpp.

References child, Inkscape::Util::Quantity::convert(), SPStyle::line_height, Inkscape::Text::Layout::LINE_HEIGHT_NORMAL, SP_CSS_UNIT_CM, SP_CSS_UNIT_EM, SP_CSS_UNIT_EX, SP_CSS_UNIT_IN, SP_CSS_UNIT_MM, SP_CSS_UNIT_NONE, SP_CSS_UNIT_PC, SP_CSS_UNIT_PERCENT, SP_CSS_UNIT_PT, SP_CSS_UNIT_PX, and sp_te_adjust_line_height().

Referenced by sp_te_adjust_line_height(), and sp_te_adjust_linespacing_screen().

◆ sp_te_adjust_linespacing_screen()

◆ sp_te_adjust_rotation()

◆ sp_te_adjust_rotation_screen()

◆ sp_te_adjust_tspan_letterspacing_screen()

◆ sp_te_apply_style()

◆ sp_te_create_selection_quads()

std::vector< Geom::Point > sp_te_create_selection_quads ( SPItem const *  item,
Inkscape::Text::Layout::iterator const &  start,
Inkscape::Text::Layout::iterator const &  end,
Geom::Affine const &  transform 
)

◆ sp_te_delete()

◆ sp_te_get_average_linespacing()

◆ sp_te_get_cursor_coords()

void sp_te_get_cursor_coords ( SPItem const *  item,
Inkscape::Text::Layout::iterator const &  position,
Geom::Point p0,
Geom::Point p1 
)

◆ sp_te_get_position_by_coords()

◆ sp_te_get_string_multiline() [1/2]

◆ sp_te_get_string_multiline() [2/2]

Glib::ustring sp_te_get_string_multiline ( SPItem const *  text,
Inkscape::Text::Layout::iterator const &  start,
Inkscape::Text::Layout::iterator const &  end 
)

Gets a text-only representation of the characters in a text or flowroot object from start to end only.

Line break elements are replaced with '
'.

Definition at line 941 of file text-editing.cpp.

References end, Inkscape::Text::Layout::getSourceOfCharacter(), Inkscape::Text::Layout::iterator::nextCharacter(), result, start, and te_get_layout().

◆ sp_te_get_ustring_multiline()

static void sp_te_get_ustring_multiline ( SPObject const *  root,
Glib::ustring *  string,
bool *  pending_line_break 
)
static

Gets a text-only representation of the given text or flowroot object, replacing line break elements with '
'.

Definition at line 905 of file text-editing.cpp.

References child, is_line_break_object(), is_part_of_text_subtree(), root, and sp_te_get_ustring_multiline().

Referenced by sp_te_get_string_multiline(), and sp_te_get_ustring_multiline().

◆ sp_te_input_is_empty()

bool sp_te_input_is_empty ( SPObject const *  item)

Returns true if the user has typed nothing in the text box.

Definition at line 87 of file text-editing.cpp.

References child, SPObject::children, item, and sp_te_input_is_empty().

Referenced by sp_te_input_is_empty().

◆ sp_te_insert()

◆ sp_te_insert_line()

Inkscape::Text::Layout::iterator sp_te_insert_line ( SPItem item,
Inkscape::Text::Layout::iterator position 
)

◆ sp_te_object_at_position()

SPObject const * sp_te_object_at_position ( SPItem const *  text,
Inkscape::Text::Layout::iterator const &  position 
)

◆ sp_te_output_is_empty()

bool sp_te_output_is_empty ( SPItem const *  item)

Returns true if there are no visible characters on the canvas.

Definition at line 81 of file text-editing.cpp.

References Inkscape::Text::Layout::begin(), Inkscape::Text::Layout::end(), item, and te_get_layout().

◆ sp_te_replace()

◆ sp_te_seek_next_string_recursive()

static SPString * sp_te_seek_next_string_recursive ( SPObject start_obj)
static

finds the first SPString after the given position, including children, excluding parents

Definition at line 509 of file text-editing.cpp.

References SPObject::firstChild(), SPObject::getNext(), SPObject::hasChildren(), is_line_break_object(), and sp_te_seek_next_string_recursive().

Referenced by sp_te_insert(), sp_te_seek_next_string_recursive(), and tidy_operator_styled_whitespace().

◆ sp_te_set_repr_text_multiline()

◆ sp_te_set_rotation()

void sp_te_set_rotation ( SPItem text,
Inkscape::Text::Layout::iterator const &  start,
Inkscape::Text::Layout::iterator const &  end,
SPDesktop ,
gdouble  degrees 
)

◆ sp_te_style_at_position()

◆ sp_text_get_length()

unsigned sp_text_get_length ( SPObject const *  item)

Recursively gets the length of all the SPStrings at or below the given item.

Also adds 1 for each line break encountered.

Definition at line 227 of file text-editing.cpp.

References child, SPObject::children, is_line_break_object(), item, and sp_text_get_length().

Referenced by delete_line_break(), fix_blank_line(), sp_te_adjust_tspan_letterspacing_screen(), sp_text_get_length(), sum_sibling_text_lengths_before(), and tidy_operator_repeated_spans().

◆ sp_text_get_length_upto()

unsigned sp_text_get_length_upto ( SPObject const *  item,
SPObject const *  upto 
)

Recursively gets the length of all the SPStrings at or below the given item, before and not including upto.

Also adds 1 for each line break encountered.

Definition at line 250 of file text-editing.cpp.

References child, SPObject::children, SPObject::firstChild(), is_line_break_object(), SPObject::isAncestorOf(), item, SPObject::parent, and sp_text_get_length_upto().

Referenced by SPTRef::bbox(), SPTSpan::bbox(), fix_blank_line(), and sp_text_get_length_upto().

◆ span_name_for_text_object()

static const char * span_name_for_text_object ( SPObject const *  object)
static

Definition at line 220 of file text-editing.cpp.

Referenced by delete_line_break(), and sp_te_apply_style().

◆ split_attributes()

static void split_attributes ( SPObject first_item,
SPObject second_item,
unsigned  char_index 
)
static

splits the attributes for the first object at the given char_index and moves the ones after that point into second_item.

Definition at line 334 of file text-editing.cpp.

References attributes_for_object(), and TextTagAttributes::split().

Referenced by split_text_object_tree_at().

◆ split_text_object_tree_at()

static SPObject * split_text_object_tree_at ( SPObject split_obj,
unsigned  char_index 
)
static

recursively divides the XML node tree into two objects: the original will contain all objects up to and including split_obj and the returned value will be the new leaf which represents the copy of split_obj and extends down the tree with new elements all the way to the common root which is the parent of the first line break node encountered.

Definition at line 348 of file text-editing.cpp.

References Inkscape::XML::Node::addChild(), Inkscape::GC::anchor(), Inkscape::XML::Node::appendChild(), SPObject::document, duplicate_node_without_children(), SPObject::firstChild(), SPObject::getNext(), SPObject::getRepr(), SPDocument::getReprDoc(), is_line_break_object(), SPObject::parent, Inkscape::GC::release(), Inkscape::XML::Node::removeChild(), split_attributes(), split_text_object_tree_at(), and sum_sibling_text_lengths_before().

Referenced by sp_te_insert_line(), and split_text_object_tree_at().

◆ sum_sibling_text_lengths_before()

static unsigned sum_sibling_text_lengths_before ( SPObject const *  item)
static

returns the sum of the (recursive) lengths of all the SPStrings prior to item at the same level.

Definition at line 320 of file text-editing.cpp.

References SPObject::children, item, SPObject::parent, and sp_text_get_length().

Referenced by erase_from_spstring(), insert_into_spstring(), split_text_object_tree_at(), and text_tag_attributes_at_position().

◆ te_get_layout()

Inkscape::Text::Layout const * te_get_layout ( SPItem const *  item)

Definition at line 48 of file text-editing.cpp.

References item.

Referenced by Inkscape::ObjectSnapper::_collectPaths(), Inkscape::UI::Toolbar::TextToolbar::_cursorMoved(), Inkscape::UI::Tools::TextTool::_selectionChanged(), Inkscape::UI::Tools::TextTool::_styleQueried(), Inkscape::UI::Tools::TextTool::_updateCursor(), Inkscape::UI::Tools::TextTool::_validateCursorIterators(), curve_for_item(), curve_for_item_before_LPE(), SPText::description(), fix_blank_line(), Inkscape::LivePathEffect::getNodes(), Inkscape::UI::Tools::TextTool::item_handler(), Inkscape::UI::Dialog::Find::item_text_match(), Inkscape::UI::Dialog::SpellCheck::nextText(), object_align_text(), object_distribute_text(), Inkscape::UI::Dialog::SpellCheck::onObjModified(), Inkscape::UI::Toolbar::TextToolbar::prepare_inner(), Inkscape::UI::Tools::TextTool::root_handler(), Inkscape::UI::Tools::MeasureTool::showCanvasItems(), SPFlowtext::snappoints(), SPText::snappoints(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_flowtext_render(), sp_selected_item_to_curved_repr(), sp_te_adjust_linespacing_screen(), sp_te_adjust_rotation_screen(), sp_te_adjust_tspan_letterspacing_screen(), sp_te_apply_style(), sp_te_create_selection_quads(), sp_te_delete(), sp_te_get_average_linespacing(), sp_te_get_cursor_coords(), sp_te_get_position_by_coords(), sp_te_get_string_multiline(), sp_te_insert(), sp_te_insert_line(), sp_te_object_at_position(), sp_te_output_is_empty(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render(), Inkscape::UI::Toolbar::TextToolbar::subselection_wrap_toggle(), text_flow_into_shape(), text_put_on_path(), and Inkscape::Extension::Internal::OdfOutput::writeTree().

◆ te_update_layout_now()

static void te_update_layout_now ( SPItem item)
static

Definition at line 58 of file text-editing.cpp.

References item, and SPObject::updateRepr().

Referenced by sp_te_delete(), sp_te_insert(), and sp_te_insert_line().

◆ te_update_layout_now_recursive()

void te_update_layout_now_recursive ( SPItem item)

◆ text_tag_attributes_at_position()

◆ tidy_operator_empty_spans()

static bool tidy_operator_empty_spans ( SPObject **  item,
bool   
)
static

empty spans: abc<span>def -> abcdef

Definition at line 1652 of file text-editing.cpp.

References SPObject::deleteObject(), SPObject::getNext(), is_line_break_object(), item, and result.

Referenced by tidy_xml_tree_recursively().

◆ tidy_operator_excessive_nesting()

static bool tidy_operator_excessive_nesting ( SPObject **  item,
bool   
)
static

redundant nesting: <font a><font b>abc</font></font> -> <font b>abc</font> excessive nesting: <font a><size 1>abc</size></font> -> <font a,size 1>abc</font>

Definition at line 1751 of file text-editing.cpp.

References TextTagAttributes::anyAttributesSet(), attributes_for_object(), is_line_break_object(), item, move_child_nodes(), and overwrite_style_with_string().

Referenced by tidy_xml_tree_recursively().

◆ tidy_operator_inexplicable_spans()

static bool tidy_operator_inexplicable_spans ( SPObject **  item,
bool   
)
static

◆ tidy_operator_redundant_double_nesting()

static bool tidy_operator_redundant_double_nesting ( SPObject **  item,
bool   
)
static

redundant double nesting: <font b><font a><font b>abc</font>def</font>ghi</font> -> <font b>abc<font a>def</font>ghi</font> this function does its work when the parameter is the <font a> tag in the 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.

Definition at line 1829 of file text-editing.cpp.

References SPObject::firstChild(), item, SPObject::lastChild(), and redundant_double_nesting_processor().

Referenced by tidy_xml_tree_recursively().

◆ tidy_operator_redundant_semi_nesting()

static bool tidy_operator_redundant_semi_nesting ( SPObject **  item,
bool   
)
static

redundant semi-nesting: <font a><font b>abc</font>def</font> -> <font b>abc</font><font>def</font> test this by applying a colour to a region, then a different colour to a partially-overlapping region.

Definition at line 1890 of file text-editing.cpp.

References SPObject::firstChild(), item, SPObject::lastChild(), and redundant_semi_nesting_processor().

Referenced by tidy_xml_tree_recursively().

◆ tidy_operator_repeated_spans()

◆ tidy_operator_styled_whitespace()

static bool tidy_operator_styled_whitespace ( SPObject **  item,
bool  has_text_decoration 
)
static

whitespace-only spans: abc<font> </font>def -> abc<font></font> def abcdef ghi -> abcdef ghi

visible text-decoration changes on white spaces should not be subject to this sort of processing. So abc<text-decoration-color> </text-decoration-color>def is unchanged.

Definition at line 1936 of file text-editing.cpp.

References SPObject::deleteObject(), find_last_string_child_not_equal_to(), SPObject::getNext(), SPObject::getRepr(), is_line_break_object(), item, SPObject::parent, Inkscape::XML::Node::setContent(), sp_te_seek_next_string_recursive(), and SPString::string.

◆ tidy_xml_tree_recursively()

static bool tidy_xml_tree_recursively ( SPObject root,
bool  has_text_decoration 
)
static

Recursively walks the xml tree calling a set of cleanup operations on every child.

Returns true if any changes were made to the tree.

All the tidy operators return true if they made changes, and alter their parameter to point to the next object that should be processed, or NULL. They must not significantly alter (ie delete) any ancestor elements of the one they are passed.

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.

Definition at line 2012 of file text-editing.cpp.

References child, SPObject::firstChild(), root, tidy_operator_empty_spans(), tidy_operator_excessive_nesting(), tidy_operator_inexplicable_spans(), tidy_operator_redundant_double_nesting(), tidy_operator_redundant_semi_nesting(), tidy_operator_repeated_spans(), and tidy_xml_tree_recursively().

Referenced by sp_te_apply_style(), sp_te_delete(), and tidy_xml_tree_recursively().

Variable Documentation

◆ tref_edit_message

const gchar* tref_edit_message = _("You cannot edit <b>cloned character data</b>.")
static

Definition at line 43 of file text-editing.cpp.

Referenced by sp_te_delete(), sp_te_insert(), and sp_te_insert_line().