diff options
author | Sebastian Geerken <devnull@localhost> | 2015-01-09 16:21:59 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-01-09 16:21:59 +0100 |
commit | 485d0d8e8e278c8a31fac4f8630b921e49745367 (patch) | |
tree | be412dd250624763dc96bb255fd9859d57859c41 /dw/textblock_linebreaking.cc | |
parent | 59b8def5a2214f387befc85f24db95ad3236797d (diff) | |
parent | b6d745ead51953b4afdb06a95b9a8eca0cad764c (diff) |
Merge with main repo.
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r-- | dw/textblock_linebreaking.cc | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index a987d62f..e9815d93 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -437,12 +437,12 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, // Until here, lineWidth refers does not include floats on the left // side. To include left floats, so that maxLineWidth, and - // eventually the requisition, is correct, line->textOffset has to - // be added, which was calculated just before in calcTextOffset(). - // The correction in sizeAllocateImpl() is irrelevant in this - // regard. Also, right floats are not regarded here, but in + // eventually the requisition, is correct, line->leftOffset (minus + // margin+border+padding) has to be added, which was calculated + // just before. The correction in sizeAllocateImpl() is irrelevant + // in this regard. Also, right floats are not regarded here, but in // OutOfFlowMgr::getSize(), - //lineWidth += line->textOffset; -- TODO: Does not work! + lineWidth += (line->leftOffset - getStyle()->boxOffsetX ()); if (lines->size () == 1) { // first line @@ -1763,16 +1763,24 @@ void Textblock::alignLine (int lineIndex) Line *line = lines->getRef (lineIndex); - if (line->firstWord <= line->lastWord) { - Word *firstWord = words->getRef (line->firstWord); - Word *lastWord = words->getRef (line->lastWord); - int lineBreakWidth = - this->lineBreakWidth - (line->leftOffset + line->rightOffset); + for (int i = line->firstWord; i <= line->lastWord; i++) + words->getRef(i)->effSpace = words->getRef(i)->origSpace; - for (int i = line->firstWord; i < line->lastWord; i++) - words->getRef(i)->effSpace = words->getRef(i)->origSpace; + // We are not interested in the alignment of floats etc. + int firstWordNotOofRef = line->firstWord; + while (firstWordNotOofRef <= line->lastWord && + words->getRef(firstWordNotOofRef)->content.type + == core::Content::WIDGET_OOF_REF) + firstWordNotOofRef++; + + if (firstWordNotOofRef <= line->lastWord) { + Word *firstWord = words->getRef (firstWordNotOofRef); if (firstWord->content.type != core::Content::BREAK) { + Word *lastWord = words->getRef (line->lastWord); + int lineBreakWidth = + this->lineBreakWidth - (line->leftOffset + line->rightOffset); + switch (firstWord->style->textAlign) { case core::style::TEXT_ALIGN_LEFT: DBG_OBJ_MSG ("construct.line", 1, @@ -1819,7 +1827,7 @@ void Textblock::alignLine (int lineIndex) // empty line (only line break); line->alignment = Line::LEFT; } else - // empty line + // empty line (or only OOF references). line->alignment = Line::LEFT; DBG_OBJ_LEAVE (); @@ -1834,21 +1842,27 @@ void Textblock::calcTextOffset (int lineIndex, int totalWidth) int lineWidth = line->firstWord <= line->lastWord ? words->getRef(line->lastWord)->totalWidth : 0; - DBG_OBJ_MSGF ("construct.line", 1, "leftOffset = %d, lineWidth = %d", - line->leftOffset, lineWidth); - switch (line->alignment) { case Line::LEFT: line->textOffset = line->leftOffset; + DBG_OBJ_MSGF ("construct.line", 1, "left: textOffset = %d", + line->textOffset); break; case Line::RIGHT: line->textOffset = totalWidth - line->rightOffset - lineWidth; + DBG_OBJ_MSGF ("construct.line", 1, + "right: textOffset = %d - %d - %d = %d", + totalWidth, line->rightOffset, lineWidth, line->textOffset); break; case Line::CENTER: line->textOffset = (line->leftOffset + totalWidth - line->rightOffset - lineWidth) / 2; + DBG_OBJ_MSGF ("construct.line", 1, + "center: textOffset = (%d + %d - %d - %d) /2 = %d", + line->leftOffset, totalWidth, line->rightOffset, lineWidth, + line->textOffset); break; default: |