Index: src/text/fmt/xp/fb_LineBreaker.cpp =================================================================== --- src/text/fmt/xp/fb_LineBreaker.cpp (revision 32771) +++ src/text/fmt/xp/fb_LineBreaker.cpp (working copy) @@ -91,6 +91,8 @@ pLine->resetJustification(true); // permanent reset } + + while (pLine) { #if DEBUG @@ -121,7 +123,7 @@ fp_Run* pCurrentRun = m_pFirstRunToKeep; fp_Run* pPreviousRun = NULL; - + while (true) { // If this run is past the end of the line... @@ -162,7 +164,7 @@ else { //m_iWorkingLineWidth -= iTrailingSpace; - if(pCurrentRun) + if(pCurrentRun && pCurrentRun->getWidth()>0) { xxx_UT_DEBUGMSG(("Break at 2 Trailing Space %d \n",iTrailingSpace)); _splitAtNextNonBlank(pCurrentRun); @@ -642,12 +644,38 @@ } fp_Run* pRunToBump = pLine->getLastRun(); + UT_sint32 singleTSWidth =60; UT_ASSERT(pRunToBump); xxx_UT_DEBUGMSG(("!!!RunToBump %x Type %d Offset %d Length %d \n",pRunToBump,pRunToBump->getType(),pRunToBump->getBlockOffset(),pRunToBump->getLength())); while (pRunToBump && pLine->getNumRunsInLine() && (pLine->getLastRun() != m_pLastRunToKeep)) { UT_ASSERT(pRunToBump->getLine() == pLine); + if(pRunToBump->getType() == FPRUN_ENDOFPARAGRAPH) + { + fp_Run* prevRun = pRunToBump->getPrevRun(); + if(prevRun && prevRun->findTrailingSpaceDistance()) + { + if(prevRun->findTrailingSpaceDistance() > singleTSWidth) + { + if(pLine->getFilledWidth() - prevRun->findTrailingSpaceDistance() < m_iMaxLineWidth) + { + //dont break the line - there is trailing space + xxx_UT_DEBUGMSG(("FW %d TS %d FW-TS %d MW %d",pLine->getFilledWidth(),prevRun->findTrailingSpaceDistance(),pLine->getFilledWidth() - prevRun->findTrailingSpaceDistance(), m_iMaxLineWidth)); + break; + } + } + else if(prevRun->findTrailingSpaceDistance() == singleTSWidth) + { + if(prevRun->getPrevRun()->findTrailingSpaceDistance()) + { + //dont break the line - new line break is created using white space + break; + } + } + //trailing space over + } + } xxx_UT_DEBUGMSG(("RunToBump %x Type %d Offset %d Length %d \n",pRunToBump,pRunToBump->getType(),pRunToBump->getBlockOffset(),pRunToBump->getLength())); if(!pLine->removeRun(pRunToBump)) { @@ -674,7 +702,6 @@ } } - UT_ASSERT((!m_pLastRunToKeep) || (pLine->getLastRun() == m_pLastRunToKeep)); #if DEBUG pLine->assertLineListIntegrity(); if(pNextLine)