Kaydet (Commit) 4e223fab authored tarafından Michael Stahl's avatar Michael Stahl

fdo#79602: sw: fix text formatting of proportional line space < 100%

SwTxtFormatter::CalcRealHeight(): Apply the special treatment of < 100%
line space shrinking the Height() of the line only to the first line
in a paragraph; the subsequent ones are shrunk again (to the square of
the desired proportion) 30 lines later.

Also set the Ascent of the line, as the wrong base-line causes the lower
part of the line to be clipped.

(regression from 42532d42)

Change-Id: I0424396263293deaa318c80eedc2237cdb01b22b
üst 9d522e21
...@@ -1742,24 +1742,30 @@ void SwTxtFormatter::CalcRealHeight( bool bNewLine ) ...@@ -1742,24 +1742,30 @@ void SwTxtFormatter::CalcRealHeight( bool bNewLine )
switch( pSpace->GetLineSpaceRule() ) switch( pSpace->GetLineSpaceRule() )
{ {
case SVX_LINE_SPACE_AUTO: case SVX_LINE_SPACE_AUTO:
if (pSpace->GetInterLineSpaceRule()==SVX_INTER_LINE_SPACE_PROP) { // shrink first line of paragraph too on spacing < 100%
if (IsParaLine() &&
pSpace->GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP)
{
long nTmp = pSpace->GetPropLineSpace(); long nTmp = pSpace->GetPropLineSpace();
// Word will render < 50% too but it's just not readable
if( nTmp < 50 )
nTmp = nTmp ? 50 : 100;
if (nTmp<100) { // code adaped from fixed line height if (nTmp<100) { // code adaped from fixed line height
nTmp *= nLineHeight; nTmp *= nLineHeight;
nTmp /= 100; nTmp /= 100;
if( !nTmp ) if( !nTmp )
++nTmp; ++nTmp;
nLineHeight = (sal_uInt16)nTmp; nLineHeight = (sal_uInt16)nTmp;
/*
//@TODO figure out how WW maps ascent and descent
//in case of prop line spacing <100%
sal_uInt16 nAsc = ( 4 * nLineHeight ) / 5; // 80% sal_uInt16 nAsc = ( 4 * nLineHeight ) / 5; // 80%
#if 0
// could do clipping here (like Word does)
// but at 0.5 its unreadable either way...
if( nAsc < pCurr->GetAscent() || if( nAsc < pCurr->GetAscent() ||
nLineHeight - nAsc < pCurr->Height() - nLineHeight - nAsc < pCurr->Height() -
pCurr->GetAscent() ) pCurr->GetAscent() )
pCurr->SetClipping( true ); pCurr->SetClipping( true );
#endif
pCurr->SetAscent( nAsc ); pCurr->SetAscent( nAsc );
*/
pCurr->Height( nLineHeight ); pCurr->Height( nLineHeight );
pInf->GetParaPortion()->SetFixLineHeight(); pInf->GetParaPortion()->SetFixLineHeight();
} }
...@@ -1785,6 +1791,8 @@ void SwTxtFormatter::CalcRealHeight( bool bNewLine ) ...@@ -1785,6 +1791,8 @@ void SwTxtFormatter::CalcRealHeight( bool bNewLine )
break; break;
default: OSL_FAIL( ": unknown LineSpaceRule" ); default: OSL_FAIL( ": unknown LineSpaceRule" );
} }
// Note: for the _first_ line the line spacing of the previous
// paragraph is applied in SwFlowFrm::CalcUpperSpace()
if( !IsParaLine() ) if( !IsParaLine() )
switch( pSpace->GetInterLineSpaceRule() ) switch( pSpace->GetInterLineSpaceRule() )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment