summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2a1bba2)
raw | patch | inline | side by side (parent: 2a1bba2)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 5 Feb 2006 00:44:16 +0000 (00:44 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 5 Feb 2006 00:44:16 +0000 (00:44 +0000) |
src/text-editing.cpp | patch | blob | history | |
src/text-editing.h | patch | blob | history |
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 44450f8fa7e39a7281c72b85f872f9cf84d44adc..d5a53fc49c5b88482bc050af680a9ee1100094d7 100644 (file)
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
return length;
}
+/** Recursively gets the length of all the SPStrings at or below the given
+\a item. Also adds 1 for each line break encountered. */
+unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto)
+{
+ unsigned length = 0;
+
+ if (SP_IS_STRING(item)) return SP_STRING(item)->string.length();
+ if (is_line_break_object(item)) length++;
+ for (SPObject const *child = item->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) {
+ if (child == upto)
+ return length;
+ if (SP_IS_STRING(child)) length += SP_STRING(child)->string.length();
+ else {
+ if (child->isAncestorOf(upto)) {
+ length += sp_text_get_length(child);
+ return length;
+ } else {
+ length += sp_text_get_length(child);
+ }
+ }
+ }
+ return length;
+}
+
static Inkscape::XML::Node* duplicate_node_without_children(Inkscape::XML::Node const *old_node)
{
switch (old_node->type()) {
diff --git a/src/text-editing.h b/src/text-editing.h
index 619bec89fb3d954f5485d804b5d542125db3069e..dba763f75e7c0c5d8fe3f294252874f445aa159d 100644 (file)
--- a/src/text-editing.h
+++ b/src/text-editing.h
bool sp_te_input_is_empty (SPObject const *item);
unsigned sp_text_get_length(SPObject const *item);
+unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto);
std::vector<NR::Point> sp_te_create_selection_quads(SPItem const *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, NR::Matrix const &transform);
Inkscape::Text::Layout::iterator sp_te_get_position_by_coords (SPItem const *item, NR::Point &i_p);