[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 3 commits - sw/source

Michael Stahl mst at kemper.freedesktop.org
Thu Jun 28 05:24:40 PDT 2012


 sw/source/core/layout/paintfrm.cxx |   71 ++++++++++++++++++++++---------------
 1 file changed, 43 insertions(+), 28 deletions(-)

New commits:
commit 91b6ab615b4f72832412b4f4a8c633f93952a17f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jun 27 23:10:00 2012 +0200

    fdo#39415: sw: fix vertical collapsing border painting:
    
    For borders in vertically oriented text it's necessary to correct
    positions at different sides, i.e., right and left instead of
    top and bottom; refactor SwTabFrmPainter::Insert some more
    to handle this properly.
    
    Change-Id: If20b9477415e9bd12e63aab4eed2f070065eb473
    (cherry picked from commit d0bbbfdef6b31650a351883de09b5338562048a2)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 9ecd59a..15b6bf1 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2716,42 +2716,44 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
 
     bool const bBottomAsTop(lcl_IsFirstRowInFollowTableWithoutRepeatedHeadlines(
                 mrTabFrm, rFrm, rBoxItem));
-
-    // these are positions of the lines
-    const SwTwips nLeft   = aBorderRect._Left();
-    const SwTwips nRight  = aBorderRect._Right();
-    const SwTwips nTop    = aBorderRect._Top();
-    const SwTwips nBottom = aBorderRect._Bottom();
+    bool const bVert = mrTabFrm.IsVertical();
+    bool const bR2L  = mrTabFrm.IsRightToLeft();
 
     svx::frame::Style aL( rBoxItem.GetLeft() );
     svx::frame::Style aR( rBoxItem.GetRight() );
     svx::frame::Style aT( rBoxItem.GetTop() );
     svx::frame::Style aB( rBoxItem.GetBottom() );
 
+    aR.MirrorSelf();
+    aB.MirrorSelf();
+
     const SwTwips nHalfBottomWidth = aB.GetWidth() / 2;
     const SwTwips nHalfTopWidth = (bBottomAsTop)
             ? nHalfBottomWidth : aT.GetWidth() / 2;
 
-    aR.MirrorSelf();
-    aB.MirrorSelf();
-
-    bool bVert = mrTabFrm.IsVertical();
-    bool bR2L  = mrTabFrm.IsRightToLeft();
+    // these are positions of the lines
+    const SwTwips nLeft   =
+        aBorderRect._Left()  - ((bVert) ? nHalfBottomWidth : 0);
+    const SwTwips nRight  =
+        aBorderRect._Right() - ((bVert) ? nHalfTopWidth : 0);
+    const SwTwips nTop    =
+        aBorderRect._Top()   + ((bVert) ? 0 : nHalfTopWidth);
+    const SwTwips nBottom =
+        aBorderRect._Bottom()+ ((bVert) ? 0 : nHalfBottomWidth);
 
     aL.SetRefMode( svx::frame::REFMODE_CENTERED );
     aR.SetRefMode( svx::frame::REFMODE_CENTERED );
     aT.SetRefMode( !bVert ? svx::frame::REFMODE_BEGIN : svx::frame::REFMODE_END );
     aB.SetRefMode( !bVert ? svx::frame::REFMODE_BEGIN : svx::frame::REFMODE_END );
 
-    SwLineEntry aLeft  ( nLeft,   nTop + nHalfTopWidth,
-            nBottom + nHalfBottomWidth, bVert ? aB : ( bR2L ? aR : aL ) );
-    SwLineEntry aRight ( nRight,  nTop + nHalfTopWidth,
-            nBottom + nHalfBottomWidth,
-            bVert ? ((bBottomAsTop) ? aB : aT) : ( bR2L ? aL : aR ) );
-    SwLineEntry aTop   ( nTop + nHalfTopWidth,
-            nLeft, nRight,  bVert ? aL : ((bBottomAsTop) ? aB : aT) );
-    SwLineEntry aBottom( nBottom + nHalfBottomWidth,
-            nLeft, nRight,  bVert ? aR : aB );
+    SwLineEntry aLeft  (nLeft,   nTop,  nBottom,
+            (bVert) ? aB                         : ((bR2L) ? aR : aL));
+    SwLineEntry aRight (nRight,  nTop,  nBottom,
+            (bVert) ? ((bBottomAsTop) ? aB : aT) : ((bR2L) ? aL : aR));
+    SwLineEntry aTop   (nTop,    nLeft, nRight,
+            (bVert) ? aL                         : ((bBottomAsTop) ? aB : aT));
+    SwLineEntry aBottom(nBottom, nLeft, nRight,
+            (bVert) ? aR                         : aB);
 
     Insert( aLeft, false );
     Insert( aRight, false );
commit aee5c2ec17ffdfacc9190f6467d7ecc291ac8e3d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jun 27 20:51:24 2012 +0200

    fdo#39415: sw: fix collapsing border painting more:
    
    There is a special case for i#9860, which is for first line in follow
    table (i.e. continued on new page) without repeated headlines:
    Here the bottom border of the cell is used as the top border in case
    the cell does not have a top border; this is fixed now with a bit of
    refactoring, so the correct half width adjustment can be made.
    
    Change-Id: I58ef81b7e13544014ef75973ea793f673a242488
    (cherry picked from commit 3a4b7c3555f2ffb4e89502bb04ff063d8c08f628)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 36e4d8b..9ecd59a 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2681,6 +2681,24 @@ void SwTabFrmPainter::FindStylesForLine( const Point& rStartPoint,
     }
 }
 
+// special case: #i9860#
+// first line in follow table without repeated headlines
+static bool lcl_IsFirstRowInFollowTableWithoutRepeatedHeadlines(
+        SwTabFrm const& rTabFrm, SwFrm const& rFrm, SvxBoxItem const& rBoxItem)
+{
+    SwRowFrm const*const pThisRowFrm =
+        dynamic_cast<const SwRowFrm*>(rFrm.GetUpper());
+    return (pThisRowFrm
+        && (pThisRowFrm->GetUpper() == &rTabFrm)
+        && rTabFrm.IsFollow()
+        && !rTabFrm.GetTable()->GetRowsToRepeat()
+        &&  (  !pThisRowFrm->GetPrev()
+            || static_cast<const SwRowFrm*>(pThisRowFrm->GetPrev())
+                    ->IsRowSpanLine())
+        && !rBoxItem.GetTop()
+        && rBoxItem.GetBottom());
+}
+
 void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
 {
     std::vector< const SwFrm* > aTestVec;
@@ -2696,6 +2714,10 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
         aBorderRect.Pos() += rFrm.Frm().Pos();
     }
 
+    bool const bBottomAsTop(lcl_IsFirstRowInFollowTableWithoutRepeatedHeadlines(
+                mrTabFrm, rFrm, rBoxItem));
+
+    // these are positions of the lines
     const SwTwips nLeft   = aBorderRect._Left();
     const SwTwips nRight  = aBorderRect._Right();
     const SwTwips nTop    = aBorderRect._Top();
@@ -2706,8 +2728,9 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
     svx::frame::Style aT( rBoxItem.GetTop() );
     svx::frame::Style aB( rBoxItem.GetBottom() );
 
-    const SwTwips nHalfTopWidth = aT.GetWidth() / 2;
     const SwTwips nHalfBottomWidth = aB.GetWidth() / 2;
+    const SwTwips nHalfTopWidth = (bBottomAsTop)
+            ? nHalfBottomWidth : aT.GetWidth() / 2;
 
     aR.MirrorSelf();
     aB.MirrorSelf();
@@ -2723,9 +2746,10 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
     SwLineEntry aLeft  ( nLeft,   nTop + nHalfTopWidth,
             nBottom + nHalfBottomWidth, bVert ? aB : ( bR2L ? aR : aL ) );
     SwLineEntry aRight ( nRight,  nTop + nHalfTopWidth,
-            nBottom + nHalfBottomWidth, bVert ? aT : ( bR2L ? aL : aR ) );
+            nBottom + nHalfBottomWidth,
+            bVert ? ((bBottomAsTop) ? aB : aT) : ( bR2L ? aL : aR ) );
     SwLineEntry aTop   ( nTop + nHalfTopWidth,
-            nLeft, nRight,  bVert ? aL : aT );
+            nLeft, nRight,  bVert ? aL : ((bBottomAsTop) ? aB : aT) );
     SwLineEntry aBottom( nBottom + nHalfBottomWidth,
             nLeft, nRight,  bVert ? aR : aB );
 
@@ -2733,22 +2757,6 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
     Insert( aRight, false );
     Insert( aTop, true );
     Insert( aBottom, true );
-
-    const SwRowFrm* pThisRowFrm = dynamic_cast<const SwRowFrm*>(rFrm.GetUpper());
-
-    // special case: #i9860#
-    // first line in follow table without repeated headlines
-    if ( pThisRowFrm &&
-         pThisRowFrm->GetUpper() == &mrTabFrm &&
-         mrTabFrm.IsFollow() &&
-        !mrTabFrm.GetTable()->GetRowsToRepeat() &&
-        (!pThisRowFrm->GetPrev() || static_cast<const SwRowFrm*>(pThisRowFrm->GetPrev())->IsRowSpanLine()) &&
-        !rBoxItem.GetTop() &&
-         rBoxItem.GetBottom() )
-    {
-        SwLineEntry aFollowTop( !bVert ? nTop : nRight, !bVert ? nLeft : nTop, !bVert ? nRight : nBottom, aB );
-        Insert( aFollowTop, !bVert );
-    }
 }
 
 void SwTabFrmPainter::Insert( SwLineEntry& rNew, bool bHori )
commit 426dec966e09c0a43d00b80a4bd262d64ea208ee
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jun 27 15:58:16 2012 +0200

    fdo#39415: sw: fix collapsing border painting:
    
    In a table with collapsing borders, the horizontal borders  need to be
    painted "below" the reference line, and not "centered" on the line like
    the vertical borders.
    a0486f02433703744f487e599422714d03937956 was apparently an attempt to
    fix this, but unfortunately it adjusted both top and bottom borders
    with the top border width, which has horrible results if the top and
    bottom borders have different widths.
    
    Change-Id: I7605eda6ef8111612ceb1ded79c0811de9ca7b25
    (cherry picked from commit aa8240e80394887a4af45710de69aacacec66d25)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 2510c45..36e4d8b 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2707,6 +2707,7 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
     svx::frame::Style aB( rBoxItem.GetBottom() );
 
     const SwTwips nHalfTopWidth = aT.GetWidth() / 2;
+    const SwTwips nHalfBottomWidth = aB.GetWidth() / 2;
 
     aR.MirrorSelf();
     aB.MirrorSelf();
@@ -2719,10 +2720,14 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
     aT.SetRefMode( !bVert ? svx::frame::REFMODE_BEGIN : svx::frame::REFMODE_END );
     aB.SetRefMode( !bVert ? svx::frame::REFMODE_BEGIN : svx::frame::REFMODE_END );
 
-    SwLineEntry aLeft  ( nLeft,   nTop + nHalfTopWidth,  nBottom + nHalfTopWidth, bVert ? aB : ( bR2L ? aR : aL ) );
-    SwLineEntry aRight ( nRight,  nTop + nHalfTopWidth,  nBottom + nHalfTopWidth, bVert ? aT : ( bR2L ? aL : aR ) );
-    SwLineEntry aTop   ( nTop + nHalfTopWidth,    nLeft, nRight,  bVert ? aL : aT );
-    SwLineEntry aBottom( nBottom + nHalfTopWidth, nLeft, nRight,  bVert ? aR : aB );
+    SwLineEntry aLeft  ( nLeft,   nTop + nHalfTopWidth,
+            nBottom + nHalfBottomWidth, bVert ? aB : ( bR2L ? aR : aL ) );
+    SwLineEntry aRight ( nRight,  nTop + nHalfTopWidth,
+            nBottom + nHalfBottomWidth, bVert ? aT : ( bR2L ? aL : aR ) );
+    SwLineEntry aTop   ( nTop + nHalfTopWidth,
+            nLeft, nRight,  bVert ? aL : aT );
+    SwLineEntry aBottom( nBottom + nHalfBottomWidth,
+            nLeft, nRight,  bVert ? aR : aB );
 
     Insert( aLeft, false );
     Insert( aRight, false );


More information about the Libreoffice-commits mailing list