[Libreoffice-commits] core.git: drawinglayer/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Jan 20 15:39:00 PST 2014


 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   81 +++++++++++++---
 1 file changed, 66 insertions(+), 15 deletions(-)

New commits:
commit 15974abe63f0d4fc88099634d5cd2ddb9760ec23
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jan 20 18:37:08 2014 -0500

    fdo#73487: Center thick border lines around cell grid.
    
    This reduces the amount of gap at line joins. Plus it generally looks better
    this way.
    
    Change-Id: Ifd21cd0bc1f61f8a875b1bad9cfb33564c18b9ae

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 61145f5..fc9a19c 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -317,22 +317,38 @@ namespace drawinglayer
                         basegfx::B2DRange aRange = aTarget.getB2DRange();
                         double fH = aRange.getHeight();
 
-                        if (fH <= 1.0 || bDouble)
+                        if (bDouble)
+                        {
+                            // Double line
+                            drawHairLine(
+                                mpOutputDevice, aRange.getMinX(), aRange.getMinY()-1.0, aRange.getMaxX(), aRange.getMinY()-1.0,
+                                aLineColor);
+
+                            drawHairLine(
+                                mpOutputDevice, aRange.getMinX(), aRange.getMinY()+1.0, aRange.getMaxX(), aRange.getMinY()+1.0,
+                                aLineColor);
+
+                            return true;
+                        }
+
+                        if (fH <= 1.0)
                         {
                             // Draw it as a line.
                             drawHairLine(
                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMaxX(), aRange.getMinY(),
                                 aLineColor);
 
-                            if (bDouble)
-                            {
-                                drawHairLine(
-                                    mpOutputDevice, aRange.getMinX(), aRange.getMinY()+2.0, aRange.getMaxX(), aRange.getMinY()+2.0,
-                                    aLineColor);
-                            }
-
                             return true;
                         }
+
+                        double fOffset = rtl::math::round(fH/2.0, 0, rtl_math_RoundingMode_Down);
+                        if (fOffset != 0.0)
+                        {
+                            // Move it up a bit to align it vertically centered.
+                            basegfx::B2DHomMatrix aMat;
+                            aMat.set(1, 2, -fOffset);
+                            aTarget.transform(aMat);
+                        }
                     }
                     else
                     {
@@ -344,21 +360,38 @@ namespace drawinglayer
                         basegfx::B2DRange aRange = aTarget.getB2DRange();
                         double fW = aRange.getWidth();
 
-                        if (fW <= 1.0 || bDouble)
+                        if (bDouble)
+                        {
+                            // Draw it as a line.
+                            drawHairLine(
+                                mpOutputDevice, aRange.getMinX()-1.0, aRange.getMinY(), aRange.getMinX()-1.0, aRange.getMaxY(),
+                                aLineColor);
+
+                            drawHairLine(
+                                mpOutputDevice, aRange.getMinX()+1.0, aRange.getMinY(), aRange.getMinX()+1.0, aRange.getMaxY(),
+                                aLineColor);
+
+                            return true;
+                        }
+
+                        if (fW <= 1.0)
                         {
                             // Draw it as a line.
                             drawHairLine(
                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMinX(), aRange.getMaxY(),
                                 aLineColor);
 
-                            if (bDouble)
-                            {
-                                drawHairLine(
-                                    mpOutputDevice, aRange.getMinX()+2.0, aRange.getMinY(), aRange.getMinX()+2.0, aRange.getMaxY(),
-                                    aLineColor);
-                            }
                             return true;
                         }
+
+                        double fOffset = rtl::math::round(fW/2.0, 0, rtl_math_RoundingMode_Down);
+                        if (fOffset != 0.0)
+                        {
+                            // Move it to the left a bit to center it horizontally.
+                            basegfx::B2DHomMatrix aMat;
+                            aMat.set(0, 2, -fOffset);
+                            aTarget.transform(aMat);
+                        }
                     }
 
                     mpOutputDevice->SetFillColor(Color(aLineColor));
@@ -463,6 +496,15 @@ namespace drawinglayer
                             if (i >= n)
                                 i = 0;
                         }
+
+                        double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
+                        if (fOffset != 0.0)
+                        {
+                            // Move it up a bit to align it vertically centered.
+                            basegfx::B2DHomMatrix aMat;
+                            aMat.set(1, 2, -fOffset);
+                            aTarget.transform(aMat);
+                        }
                     }
                     else
                     {
@@ -535,6 +577,15 @@ namespace drawinglayer
                             if (i >= n)
                                 i = 0;
                         }
+
+                        double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
+                        if (fOffset != 0.0)
+                        {
+                            // Move it to the left a bit to center it horizontally.
+                            basegfx::B2DHomMatrix aMat;
+                            aMat.set(0, 2, -fOffset);
+                            aTarget.transform(aMat);
+                        }
                     }
 
                     mpOutputDevice->SetFillColor(Color(aLineColor));


More information about the Libreoffice-commits mailing list