[Libreoffice-commits] core.git: Branch 'private/kohei/double-border-fix' - sw/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Mar 4 12:44:09 PST 2014


 sw/source/core/layout/paintfrm.cxx |   69 ++++++++++++++++++++++++++++++++++---
 1 file changed, 65 insertions(+), 4 deletions(-)

New commits:
commit f3ef8e147787d0dd6a3ca656ad694a49e218a66e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Mar 4 14:05:12 2014 -0500

    Offset top- and left-most borders of a table to account for double lines.
    
    Change-Id: I99eb00740910f2acf244f2be0637ca26858c76b1

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index db8ef0d..3ea8ad8 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2258,6 +2258,7 @@ struct SwLineEntry
     SwTwips mnKey;
     SwTwips mnStartPos;
     SwTwips mnEndPos;
+    SwTwips mnOffset;
 
     svx::frame::Style maAttribute;
 
@@ -2279,6 +2280,7 @@ SwLineEntry::SwLineEntry( SwTwips nKey,
     :   mnKey( nKey ),
         mnStartPos( nStartPos ),
         mnEndPos( nEndPos ),
+        mnOffset( 0 ),
         maAttribute( rAttribute )
 {
 }
@@ -2361,6 +2363,8 @@ class SwTabFrmPainter
                             svx::frame::Style*,
                             bool bHori ) const;
 
+    void AdjustTopLeftFrames();
+
 public:
     SwTabFrmPainter( const SwTabFrm& rTabFrm );
 
@@ -2371,6 +2375,7 @@ SwTabFrmPainter::SwTabFrmPainter( const SwTabFrm& rTabFrm )
     : mrTabFrm( rTabFrm )
 {
     HandleFrame( rTabFrm );
+    AdjustTopLeftFrames();
 }
 
 void SwTabFrmPainter::HandleFrame( const SwLayoutFrm& rLayoutFrm )
@@ -2479,6 +2484,26 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
                 aEnd.Y() = rEntry.mnEndPos;
             }
 
+            svx::frame::Style aStyles[ 7 ];
+            aStyles[ 0 ] = rEntryStyle;
+            FindStylesForLine( aStart, aEnd, aStyles, bHori );
+
+            // Account for double line thicknesses for the top- and left-most borders.
+            if (bHori)
+            {
+                aStart.Y() -= rEntry.mnOffset;
+                aEnd.Y() -= rEntry.mnOffset;
+                aStart.X() -= rEntry.mnOffset;
+                aEnd.X() += rEntry.mnOffset;
+            }
+            else
+            {
+                aStart.X() -= rEntry.mnOffset;
+                aEnd.X() -= rEntry.mnOffset;
+                aStart.Y() -= rEntry.mnOffset;
+                aEnd.Y() += rEntry.mnOffset;
+            }
+
             SwRect aRepaintRect( aStart, aEnd );
 
             // the repaint rectangle has to be moved a bit for the centered lines:
@@ -2499,10 +2524,6 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
                 continue;
             }
 
-            svx::frame::Style aStyles[ 7 ];
-            aStyles[ 0 ] = rEntryStyle;
-            FindStylesForLine( aStart, aEnd, aStyles, bHori );
-
             // subsidiary lines
             const Color* pTmpColor = 0;
             if (0 == aStyles[ 0 ].GetWidth())
@@ -2742,6 +2763,46 @@ void SwTabFrmPainter::FindStylesForLine( const Point& rStartPoint,
     }
 }
 
+namespace {
+
+void calcOffsetForDoubleLine( SwLineEntryMap& rLines )
+{
+    SwLineEntryMap aNewLines;
+    SwLineEntryMap::iterator it = rLines.begin(), itEnd = rLines.end();
+    bool bFirst = true;
+    for (; it != itEnd; ++it)
+    {
+        if (bFirst)
+        {
+            // First line needs to be offset to account for double line thickness.
+            SwLineEntrySet aNewSet;
+            const SwLineEntrySet& rSet = it->second;
+            SwLineEntrySet::iterator itSet = rSet.begin(), itSetEnd = rSet.end();
+            for (; itSet != itSetEnd; ++itSet)
+            {
+                SwLineEntry aLine = *itSet;
+                aLine.mnOffset = static_cast<SwTwips>(aLine.maAttribute.Dist());
+                aNewSet.insert(aLine);
+            }
+
+            aNewLines.insert(SwLineEntryMap::value_type(it->first, aNewSet));
+        }
+        else
+            aNewLines.insert(SwLineEntryMap::value_type(it->first, it->second));
+
+        bFirst = false;
+    }
+    rLines.swap(aNewLines);
+}
+
+}
+
+void SwTabFrmPainter::AdjustTopLeftFrames()
+{
+    calcOffsetForDoubleLine(maHoriLines);
+    calcOffsetForDoubleLine(maVertLines);
+}
+
 // special case: #i9860#
 // first line in follow table without repeated headlines
 static bool lcl_IsFirstRowInFollowTableWithoutRepeatedHeadlines(


More information about the Libreoffice-commits mailing list