From bd2d9e29701757bd8306a2a1e00ee57da9262e21 Mon Sep 17 00:00:00 2001 From: Vitaliy Anderson Date: Tue, 20 Dec 2016 03:00:51 -0500 Subject: tdf#104668 remove the difference between MSO and LO text alignment Change-Id: Id1964d87f6f4ec3dbcd617af2251a321c50ec428 Reviewed-on: https://gerrit.libreoffice.org/32213 Reviewed-by: Mike Kaganski Tested-by: Mike Kaganski Reviewed-by: jan iversen (cherry picked from commit 1c1747ac13a9d895df0fcba2fbb1bd266dccd74b) (cherry picked from commit b8f61b8046429030ab599862ac550e320596fd37) --- sw/source/core/text/guess.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index f9b24e02abca..e347013a4c9b 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -73,6 +73,28 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, SwTwips nLineWidth = rInf.Width() - rInf.X(); sal_Int32 nMaxLen = rInf.GetText().getLength() - rInf.GetIdx(); + const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust(); + + // tdf#104668 space chars at the end should be cut + if ( rAdjust == SVX_ADJUST_RIGHT || rAdjust == SVX_ADJUST_CENTER ) + { + sal_Int32 nSpaceCnt = 0; + for ( int i = (rInf.GetText().getLength() - 1); i >= rInf.GetIdx(); --i ) + { + sal_Unicode cChar = rInf.GetText()[i]; + if ( cChar != CH_BLANK && cChar != CH_FULL_BLANK ) + break; + ++nSpaceCnt; + } + sal_Int32 nCharsCnt = nMaxLen - nSpaceCnt; + if ( nSpaceCnt && nCharsCnt < rPor.GetLen() ) + { + nMaxLen = nCharsCnt; + if ( !nMaxLen ) + return true; + } + } + if ( rInf.GetLen() < nMaxLen ) nMaxLen = rInf.GetLen(); @@ -212,7 +234,6 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, nBreakPos = nCutPos; sal_Int32 nX = nBreakPos; - const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust(); if ( rAdjust == SVX_ADJUST_LEFT ) { // we step back until a non blank character has been found @@ -423,7 +444,6 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, CHAR_SOFTHYPHEN == rInf.GetText()[ nBreakPos - 1 ] ) nBreakPos = rInf.GetIdx() - 1; - const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust(); if( rAdjust != SVX_ADJUST_LEFT ) { // Delete any blanks at the end of a line, but be careful: -- cgit