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

Kohei Yoshida kohei.yoshida at collabora.com
Tue Mar 4 13:30:04 PST 2014


 sw/source/core/layout/paintfrm.cxx |   60 ++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 13 deletions(-)

New commits:
commit d6e371953d28a9bf5f3d164fa27375e6cf5da975
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Mar 4 16:26:57 2014 -0500

    Limit application of offset values to avoid overlapping borders.
    
    They show up when exporting to PDF.  It's quite ugly.
    
    Change-Id: Ib1efb68d9481dca06fafe1aab293dac5aa54e8ea

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 3ea8ad8..b090ae1 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2260,6 +2260,10 @@ struct SwLineEntry
     SwTwips mnEndPos;
     SwTwips mnOffset;
 
+    bool mbOffsetPerp;
+    bool mbOffsetStart;
+    bool mbOffsetEnd;
+
     svx::frame::Style maAttribute;
 
     enum OverlapType { NO_OVERLAP, OVERLAP1, OVERLAP2, OVERLAP3 };
@@ -2281,6 +2285,9 @@ SwLineEntry::SwLineEntry( SwTwips nKey,
         mnStartPos( nStartPos ),
         mnEndPos( nEndPos ),
         mnOffset( 0 ),
+        mbOffsetPerp(false),
+        mbOffsetStart(false),
+        mbOffsetEnd(false),
         maAttribute( rAttribute )
 {
 }
@@ -2489,19 +2496,38 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
             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
+            if (rEntry.mnOffset)
             {
-                aStart.X() -= rEntry.mnOffset;
-                aEnd.X() -= rEntry.mnOffset;
-                aStart.Y() -= rEntry.mnOffset;
-                aEnd.Y() += rEntry.mnOffset;
+                if (bHori)
+                {
+                    if (rEntry.mbOffsetPerp)
+                    {
+                        // Apply offset in perpendicular direction.
+                        aStart.Y() -= rEntry.mnOffset;
+                        aEnd.Y() -= rEntry.mnOffset;
+                    }
+                    if (rEntry.mbOffsetStart)
+                        // Apply offset at the start of a border.
+                        aStart.X() -= rEntry.mnOffset;
+                    if (rEntry.mbOffsetEnd)
+                        // Apply offset at the end of a border.
+                        aEnd.X() += rEntry.mnOffset;
+                }
+                else
+                {
+                    if (rEntry.mbOffsetPerp)
+                    {
+                        // Apply offset in perpendicular direction.
+                        aStart.X() -= rEntry.mnOffset;
+                        aEnd.X() -= rEntry.mnOffset;
+                    }
+                    if (rEntry.mbOffsetStart)
+                        // Apply offset at the start of a border.
+                        aStart.Y() -= rEntry.mnOffset;
+                    if (rEntry.mbOffsetEnd)
+                        // Apply offset at the end of a border.
+                        aEnd.Y() += rEntry.mnOffset;
+                }
             }
 
             SwRect aRepaintRect( aStart, aEnd );
@@ -2778,10 +2804,18 @@ void calcOffsetForDoubleLine( SwLineEntryMap& rLines )
             SwLineEntrySet aNewSet;
             const SwLineEntrySet& rSet = it->second;
             SwLineEntrySet::iterator itSet = rSet.begin(), itSetEnd = rSet.end();
-            for (; itSet != itSetEnd; ++itSet)
+            size_t nEntryCount = rSet.size();
+            for (size_t i = 0; itSet != itSetEnd; ++itSet, ++i)
             {
                 SwLineEntry aLine = *itSet;
                 aLine.mnOffset = static_cast<SwTwips>(aLine.maAttribute.Dist());
+                aLine.mbOffsetPerp = true;
+
+                if (i == 0)
+                    aLine.mbOffsetStart = true;
+                if (i == nEntryCount - 1)
+                    aLine.mbOffsetEnd = true;
+
                 aNewSet.insert(aLine);
             }
 


More information about the Libreoffice-commits mailing list