summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVitaliy Anderson <vanderson@smartru.com>2016-12-20 03:00:51 -0500
committerAron Budea <aron.budea@collabora.com>2018-03-14 21:23:44 +0100
commitbd2d9e29701757bd8306a2a1e00ee57da9262e21 (patch)
treec52b36a75dc34269ce80657b1d025f7df7188858 /sw
parenta3c63b3daba1da2328e2d7e11344650df9ca8ecf (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> (cherry picked from commit 1c1747ac13a9d895df0fcba2fbb1bd266dccd74b) (cherry picked from commit b8f61b8046429030ab599862ac550e320596fd37)
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/guess.cxx24
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: