a944f99
From b5dca3cf9b578984c295eab2ba480363b6a7f375 Mon Sep 17 00:00:00 2001
a944f99
From: Michael Stahl <mstahl@redhat.com>
a944f99
Date: Wed, 29 Oct 2014 23:50:21 +0100
a944f99
Subject: [PATCH 1/2] fdo#79602: sw: fix text formatting of proportional line
a944f99
 space < 100%
a944f99
a944f99
SwTxtFormatter::CalcRealHeight(): Apply the special treatment of < 100%
a944f99
line space shrinking the Height() of the line only to the first line
a944f99
in a paragraph; the subsequent ones are shrunk again (to the square of
a944f99
the desired proportion) 30 lines later.
a944f99
a944f99
Also set the Ascent of the line, as the wrong base-line causes the lower
a944f99
part of the line to be clipped.
a944f99
a944f99
(regression from 42532d42bfcdb12df86376cda009e8e315a82153)
a944f99
a944f99
(cherry picked from commit 4e223fab04279c3583689e69fa1342966e81de36)
a944f99
a944f99
Conflicts:
a944f99
	sw/source/core/text/itrform2.cxx
a944f99
a944f99
Reviewed-on: https://gerrit.libreoffice.org/12156
a944f99
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
a944f99
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
a944f99
(cherry picked from commit 7ca9c060155b79a037861a972843a70b8a518c4f)
a944f99
a944f99
Conflicts:
a944f99
	sw/source/core/text/itrform2.cxx
a944f99
a944f99
Change-Id: I0424396263293deaa318c80eedc2237cdb01b22b
a944f99
---
a944f99
 sw/source/core/text/itrform2.cxx | 18 +++++++++++++-----
a944f99
 1 file changed, 13 insertions(+), 5 deletions(-)
a944f99
a944f99
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
a944f99
index 9cb57bc..459d6c3 100644
a944f99
--- a/sw/source/core/text/itrform2.cxx
a944f99
+++ b/sw/source/core/text/itrform2.cxx
a944f99
@@ -1818,24 +1818,30 @@ void SwTxtFormatter::CalcRealHeight( sal_Bool bNewLine )
a944f99
             switch( pSpace->GetLineSpaceRule() )
a944f99
             {
a944f99
                 case SVX_LINE_SPACE_AUTO:
a944f99
-            if (pSpace->GetInterLineSpaceRule()==SVX_INTER_LINE_SPACE_PROP) {
a944f99
+                    // shrink first line of paragraph too on spacing < 100%
a944f99
+                    if (IsParaLine() &&
a944f99
+                        pSpace->GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP)
a944f99
+                    {
a944f99
                         long nTmp = pSpace->GetPropLineSpace();
a944f99
+                        // Word will render < 50% too but it's just not readable
a944f99
+                        if( nTmp < 50 )
a944f99
+                            nTmp = nTmp ? 50 : 100;
a944f99
                         if (nTmp<100) { // code adaped from fixed line height
a944f99
                             nTmp *= nLineHeight;
a944f99
                             nTmp /= 100;
a944f99
                             if( !nTmp )
a944f99
                                 ++nTmp;
a944f99
                             nLineHeight = (KSHORT)nTmp;
a944f99
-/*
a944f99
-                            //@TODO figure out how WW maps ascent and descent
a944f99
-                            //in case of prop  line spacing <100%
a944f99
                             KSHORT nAsc = ( 4 * nLineHeight ) / 5;  // 80%
a944f99
+#if 0
a944f99
+                            // could do clipping here (like Word does)
a944f99
+                            // but at 0.5 its unreadable either way...
a944f99
                             if( nAsc < pCurr->GetAscent() ||
a944f99
                                 nLineHeight - nAsc < pCurr->Height() -
a944f99
 pCurr->GetAscent() )
a944f99
                                 pCurr->SetClipping( sal_True );
a944f99
+#endif
a944f99
                             pCurr->SetAscent( nAsc );
a944f99
-*/
a944f99
                             pCurr->Height( nLineHeight );
a944f99
                             pInf->GetParaPortion()->SetFixLineHeight();
a944f99
                         }
a944f99
@@ -1861,6 +1867,8 @@ pCurr->GetAscent() )
a944f99
                 break;
a944f99
                 default: OSL_FAIL( ": unknown LineSpaceRule" );
a944f99
             }
a944f99
+            // Note: for the _first_ line the line spacing of the previous
a944f99
+            // paragraph is applied in SwFlowFrm::CalcUpperSpace()
a944f99
             if( !IsParaLine() )
a944f99
                 switch( pSpace->GetInterLineSpaceRule() )
a944f99
                 {
a944f99
-- 
a944f99
1.9.3
a944f99