diff options
author | corvid <corvid@lavabit.com> | 2009-10-26 23:24:52 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2009-10-26 23:24:52 +0000 |
commit | 995da5c906c9a82da978e059e13a056488652152 (patch) | |
tree | fe47e091568c3f456cd482b82d0bd26fda249519 /dw | |
parent | 0eb66f6846deba4deb54a586eba157593043ff45 (diff) |
clean up addSpace
Diffstat (limited to 'dw')
-rw-r--r-- | dw/textblock.cc | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index 65521b5a..365d9b14 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -1683,22 +1683,14 @@ bool Textblock::addAnchor (const char *name, core::style::Style *style) */ void Textblock::addSpace (core::style::Style *style) { - int nl, nw; - int space; - - nl = lines->size () - 1; - if (nl >= 0) { - nw = words->size () - 1; - if (nw >= 0) { - /* TODO: remove this test case */ - //if (page->words[nw].orig_space != 0) { - // _MSG(" a_Dw_page_add_space:: already existing space!!!\n"); - //} - - space = style->font->spaceWidth; - words->getRef(nw)->origSpace = space; - words->getRef(nw)->effSpace = space; - words->getRef(nw)->content.space = true; + if (lines->size () > 0) { + int wordIndex = words->size () - 1; + + if (wordIndex >= 0) { + Word *word = words->getRef(wordIndex); + + word->effSpace = word->origSpace = style->font->spaceWidth; + word->content.space = true; //DBG_OBJ_ARRSET_NUM (page, "words.%d.orig_space", nw, // page->words[nw].orig_space); @@ -1706,9 +1698,9 @@ void Textblock::addSpace (core::style::Style *style) // page->words[nw].eff_space); //DBG_OBJ_ARRSET_NUM (page, "words.%d.content.space", nw, // page->words[nw].content.space); - if (style != words->getRef(nw)->spaceStyle) { - words->getRef(nw)->spaceStyle->unref (); - words->getRef(nw)->spaceStyle = style; + if (style != word->spaceStyle) { + word->spaceStyle->unref (); + word->spaceStyle = style; style->ref (); } } |