diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2010-12-12 08:40:34 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2010-12-12 08:40:34 +0000 |
| commit | aadfea4113abc6863d7ab03d21b973802c41c503 (patch) | |
| tree | 3f890c0c112433fd850d59558208addf1baa85da /src/sp-string.cpp | |
| parent | Pot and Dutch translation update (diff) | |
| parent | A simple layout document as to what, why and how is cppification. (diff) | |
| download | inkscape-aadfea4113abc6863d7ab03d21b973802c41c503.tar.gz inkscape-aadfea4113abc6863d7ab03d21b973802c41c503.zip | |
Merge and cleanup of GSoC C++-ification project.
(bzr r9945.1.1)
Diffstat (limited to 'src/sp-string.cpp')
| -rw-r--r-- | src/sp-string.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/sp-string.cpp b/src/sp-string.cpp index b424ac3d8..c116e8dd8 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -1,10 +1,10 @@ -#define __SP_STRING_C__ - /* * SVG <text> and <tspan> implementation * * Author: * Lauris Kaplinski <lauris@kaplinski.com> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@ -116,12 +116,16 @@ sp_string_read_content(SPObject *object) SPString *string = SP_STRING(object); string->string.clear(); - gchar const *xml_string = string->repr->content(); + + //XML Tree being used directly here while it shouldn't be. + gchar const *xml_string = string->getRepr()->content(); // see algorithms described in svg 1.1 section 10.15 if (object->xml_space.value == SP_XML_SPACE_PRESERVE) { for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) { gunichar c = g_utf8_get_char(xml_string); - if (c == 0xa || c == 0xd || c == '\t') c = ' '; + if ((c == 0xa) || (c == 0xd) || (c == '\t')) { + c = ' '; + } string->string += c; } } @@ -129,17 +133,22 @@ sp_string_read_content(SPObject *object) bool whitespace = false; for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) { gunichar c = g_utf8_get_char(xml_string); - if (c == 0xa || c == 0xd) continue; - if (c == ' ' || c == '\t') whitespace = true; - else { - if (whitespace && (!string->string.empty() || SP_OBJECT_PREV(object) != NULL)) + if ((c == 0xa) || (c == 0xd)) { + continue; + } + if ((c == ' ') || (c == '\t')) { + whitespace = true; + } else { + if (whitespace && (!string->string.empty() || (object->getPrev() != NULL))) { string->string += ' '; + } string->string += c; whitespace = false; } } - if (whitespace && SP_OBJECT_REPR(object)->next() != NULL) // can't use SP_OBJECT_NEXT() when the SPObject tree is still being built + if (whitespace && SP_OBJECT_REPR(object)->next() != NULL) { // can't use SPObject::getNext() when the SPObject tree is still being built string->string += ' '; + } } object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } |
