diff options
author | Vitaliy Anderson <vanderson@smartru.com> | 2016-12-20 03:00:51 -0500 |
---|---|---|
committer | jan iversen <jani@documentfoundation.org> | 2017-01-12 11:20:32 +0000 |
commit | 1c1747ac13a9d895df0fcba2fbb1bd266dccd74b (patch) | |
tree | 7ea36010ec2c46c445d77db9b0294be51b60603d | |
parent | 75367918028dffb7a137d29644a7a6e1f7af7c9b (diff) |
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 <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: jan iversen <jani@documentfoundation.org>
-rw-r--r-- | sw/source/core/text/guess.cxx | 24 |
1 files 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: |