diff options
| author | Ted Gould <ted@gould.cx> | 2006-02-06 07:17:33 +0000 |
|---|---|---|
| committer | gouldtj <gouldtj@users.sourceforge.net> | 2006-02-06 07:17:33 +0000 |
| commit | 53e1c1a77a66d307715a796cb164d7f87ae9eba5 (patch) | |
| tree | 514aa9c110787f3c9abc480a223a254959199286 /src | |
| parent | Had to include fstream for overloaded def of << (diff) | |
| download | inkscape-53e1c1a77a66d307715a796cb164d7f87ae9eba5.tar.gz inkscape-53e1c1a77a66d307715a796cb164d7f87ae9eba5.zip | |
r10887@tres: ted | 2006-02-05 23:16:41 -0800
Okay, I'm basically undoing the last commit that SVK screwed up. All
this work is not mine, it was done by other people. Sorry to mess
things up.
(bzr r92)
Diffstat (limited to 'src')
| -rwxr-xr-x | src/libnrtype/Layout-TNG-Output.cpp | 4 | ||||
| -rw-r--r-- | src/removeoverlap/constraint.h | 4 | ||||
| -rw-r--r-- | src/removeoverlap/generate-constraints.cpp | 2 | ||||
| -rwxr-xr-x | src/removeoverlap/remove_rectangle_overlap.cpp | 2 | ||||
| -rw-r--r-- | src/sp-tspan.cpp | 6 | ||||
| -rw-r--r-- | src/style.cpp | 1 | ||||
| -rw-r--r-- | src/style.h | 2 | ||||
| -rw-r--r-- | src/text-editing.cpp | 29 |
8 files changed, 33 insertions, 17 deletions
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index b6249248b..bdcc6cf3f 100755 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -87,11 +87,11 @@ void Layout::getBoundingBox(NRRect *bounding_box, NR::Matrix const &transform, i { for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; glyph_index++) { if (_characters[_glyphs[glyph_index].in_character].in_glyph == -1) continue; - if (start != -1 && _glyphs[glyph_index].in_character < start) continue; + if (start != -1 && (int) _glyphs[glyph_index].in_character < start) continue; if (length != -1) { if (start == -1) start = 0; - if (_glyphs[glyph_index].in_character > start + length) continue; + if ((int) _glyphs[glyph_index].in_character > start + length) continue; } // this could be faster NRMatrix glyph_matrix; diff --git a/src/removeoverlap/constraint.h b/src/removeoverlap/constraint.h index 683d66da3..c8273376b 100644 --- a/src/removeoverlap/constraint.h +++ b/src/removeoverlap/constraint.h @@ -37,11 +37,11 @@ static inline bool compareConstraints(Constraint *const &l, Constraint *const &r double const sl = l->left->block->timeStamp > l->timeStamp ||l->left->block==l->right->block - ?DBL_MIN:l->slack(); + ?-DBL_MAX:l->slack(); double const sr = r->left->block->timeStamp > r->timeStamp ||r->left->block==r->right->block - ?DBL_MIN:r->slack(); + ?-DBL_MAX:r->slack(); if(sl==sr) { // arbitrary choice based on id if(l->left->id==r->left->id) { diff --git a/src/removeoverlap/generate-constraints.cpp b/src/removeoverlap/generate-constraints.cpp index efa477449..a8bfe28e7 100644 --- a/src/removeoverlap/generate-constraints.cpp +++ b/src/removeoverlap/generate-constraints.cpp @@ -140,7 +140,7 @@ Event **events; int compare_events(const void *a, const void *b) { Event *ea=*(Event**)a; Event *eb=*(Event**)b; - if(ea->v->r==ea->v->r) { + if(ea->v->r==eb->v->r) { // when comparing opening and closing from the same rect // open must come first if(ea->type==Open) return -1; diff --git a/src/removeoverlap/remove_rectangle_overlap.cpp b/src/removeoverlap/remove_rectangle_overlap.cpp index 34cedf481..9f98d5811 100755 --- a/src/removeoverlap/remove_rectangle_overlap.cpp +++ b/src/removeoverlap/remove_rectangle_overlap.cpp @@ -6,7 +6,7 @@ #include "constraint.h" #ifdef RECTANGLE_OVERLAP_LOGGING #include <fstream> -#include <blocks.h> +#include "blocks.h" using std::ios; using std::ofstream; using std::endl; diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 6be423125..f07783dbe 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -198,13 +198,13 @@ sp_tspan_modified(SPObject *object, unsigned flags) static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) { + // find out the ancestor text which holds our layout SPObject *parent_text = SP_OBJECT(item); for (; parent_text != NULL && !SP_IS_TEXT(parent_text); parent_text = SP_OBJECT_PARENT (parent_text)); if (parent_text == NULL) return; - Inkscape::Text::Layout layout = SP_TEXT(parent_text)->layout; - - SP_TEXT(parent_text)->layout.getBoundingBox(bbox, transform, sp_text_get_length_upto(parent_text, item) - 1, sp_text_get_length(item)); + // get the bbox of our portion of the layout + SP_TEXT(parent_text)->layout.getBoundingBox(bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); // Add stroke width SPStyle* style=SP_OBJECT_STYLE (item); diff --git a/src/style.cpp b/src/style.cpp index 5fe837fe7..e0a1dcc7d 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -390,6 +390,7 @@ sp_style_new() style->cloned = false; style->hreffed = false; + style->listening = false; return style; } diff --git a/src/style.h b/src/style.h index ba1900bde..333344ad9 100644 --- a/src/style.h +++ b/src/style.h @@ -323,6 +323,8 @@ struct SPStyle { bool cloned; /// style has hreffed its paintservers, needs to release bool hreffed; + /// style is listening to changes in paintservers, need to disconnect + bool listening; }; SPStyle *sp_style_new(); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index d5a53fc49..f0cb4bd9d 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -183,23 +183,36 @@ unsigned sp_text_get_length(SPObject const *item) } /** Recursively gets the length of all the SPStrings at or below the given -\a item. Also adds 1 for each line break encountered. */ +\a item, before and not including \a upto. 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++; + if (SP_IS_STRING(item)) { + return SP_STRING(item)->string.length(); + } + if (is_line_break_object(item) && !SP_IS_TEXT(item)) { + if (item != SP_OBJECT_PARENT(item)->firstChild()) { + // add 1 for each newline + length++; + } + } for (SPObject const *child = item->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) { - if (child == upto) + if (upto && child == upto) { + // hit upto, return immediately return length; - if (SP_IS_STRING(child)) length += SP_STRING(child)->string.length(); + } + if (SP_IS_STRING(child)) { + length += SP_STRING(child)->string.length(); + } else { - if (child->isAncestorOf(upto)) { - length += sp_text_get_length(child); + if (upto && child->isAncestorOf(upto)) { + // upto is below us, recurse and break loop + length += sp_text_get_length_upto(child, upto); return length; } else { - length += sp_text_get_length(child); + // recurse and go to the next sibling + length += sp_text_get_length_upto(child, upto); } } } |
