[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-20 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   63 ++--
 1 file changed, 40 insertions(+), 23 deletions(-)

New commits:
commit 5446c05ffbf8a0e94955fc3cfa8653a8d0f254f8
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Jan 20 11:41:41 2014 -0500

Substitute dashed line with a solid line at lower zoom levels.

Change-Id: I0437409b6a5d6163fadf777df5c028950727e786

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 06ca763..68abfa4 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -73,6 +73,19 @@ basegfx::B2DPolygon makeRectPolygon( double fX, double fY, 
double fW, double fH
 return aPoly;
 }
 
+void drawHairLine(
+OutputDevice* pOutDev, double fX1, double fY1, double fX2, double fY2,
+const basegfx::BColor rColor )
+{
+basegfx::B2DPolygon aTarget;
+aTarget.append(basegfx::B2DPoint(fX1, fY1));
+aTarget.append(basegfx::B2DPoint(fX2, fY2));
+
+pOutDev-SetFillColor();
+pOutDev-SetLineColor(Color(rColor));
+pOutDev-DrawPolyLine(aTarget);
+}
+
 }
 
 namespace drawinglayer
@@ -289,7 +302,6 @@ namespace drawinglayer
 
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
 double nThick = rtl::math::round(rSource.getLeftWidth());
 
-bool bAsLine = false;
 basegfx::B2DPolygon aTarget;
 
 if (bHorizontal)
@@ -305,10 +317,10 @@ namespace drawinglayer
 if (fH = 1.0)
 {
 // Draw it as a line.
-aTarget.clear();
-aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMinY()));
-aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), 
aRange.getMinY()));
-bAsLine = true;
+drawHairLine(
+mpOutputDevice, aRange.getMinX(), 
aRange.getMinY(), aRange.getMaxX(), aRange.getMinY(),
+aLineColor);
+return true;
 }
 }
 else
@@ -324,25 +336,16 @@ namespace drawinglayer
 if (fW = 1.0)
 {
 // Draw it as a line.
-aTarget.clear();
-aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMinY()));
-aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMaxY()));
-bAsLine = true;
+drawHairLine(
+mpOutputDevice, aRange.getMinX(), 
aRange.getMinY(), aRange.getMinX(), aRange.getMaxY(),
+aLineColor);
+return true;
 }
 }
 
-if (bAsLine)
-{
-mpOutputDevice-SetFillColor();
-mpOutputDevice-SetLineColor(Color(aLineColor));
-mpOutputDevice-DrawPolyLine(aTarget);
-}
-else
-{
-mpOutputDevice-SetFillColor(Color(aLineColor));
-mpOutputDevice-SetLineColor();
-mpOutputDevice-DrawPolygon(aTarget);
-}
+mpOutputDevice-SetFillColor(Color(aLineColor));
+mpOutputDevice-SetLineColor();
+mpOutputDevice-DrawPolygon(aTarget);
 return true;
 }
 break;
@@ -358,6 +361,8 @@ namespace drawinglayer
 return false;
 
 double nThick = rtl::math::round(rSource.getLeftWidth());
+const basegfx::BColor aLineColor =
+
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
 
 // Transform the current line range before using it for 
rendering.
 basegfx::B2DRange aRange(fX1, fY1, fX2, fY2);
@@ -391,6 +396,13 @@ namespace drawinglayer
 basegfx::B2DPolygon aPoly = 
aDashes.getB2DPolygon(i);
 aRange = aPoly.getB2DRange();
 double fW = rtl::math::round(aRange.getWidth());
+if (basegfx::fTools::equalZero(fW))
+{
+// Dash line segment too small to draw.  
Substitute it with a solid line.
+drawHairLine(mpOutputDevice, fX1, fY1, fX2, 
fY1, aLineColor);
+return true;

[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-20 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit c69e618225652a109a101ff213d9b8a21eff97a6
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Jan 20 11:48:36 2014 -0500

Do the same when the pixel thickness is zero.

Change-Id: Icfbb295abb19cf58477f4f14f4a7294a540151c2

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 68abfa4..ce22687 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -378,6 +378,13 @@ namespace drawinglayer
 {
 // Horizontal line.
 
+if (basegfx::fTools::equalZero(nThick))
+{
+// Dash line segment too small to draw.  
Substitute it with a solid line.
+drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, 
aLineColor);
+return true;
+}
+
 // Create a dash unit polygon set.
 basegfx::B2DPolyPolygon aDashes;
 std::vectordouble::const_iterator it = 
aPattern.begin(), itEnd = aPattern.end();
@@ -438,6 +445,13 @@ namespace drawinglayer
 {
 // Vertical line.
 
+if (basegfx::fTools::equalZero(nThick))
+{
+// Dash line segment too small to draw.  
Substitute it with a solid line.
+drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, 
aLineColor);
+return true;
+}
+
 // Create a dash unit polygon set.
 basegfx::B2DPolyPolygon aDashes;
 std::vectordouble::const_iterator it = 
aPattern.begin(), itEnd = aPattern.end();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-20 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 3b15f5324bc3dc6eeadee545d8a5884f670d811b
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Jan 20 12:03:39 2014 -0500

Ensure that the pixel line is at least 1 pixel wide.

Without this, some dashed lines may not get drawn at all at some zoom 
levels.

Change-Id: I273c1548325d14f56618df8ca4166aac58a3ff3f

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index ce22687..439ce61 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -430,7 +430,12 @@ namespace drawinglayer
 if (fX + fBlockW  fX2)
 // Clip the right end in case it spills 
over the range.
 fBlockW = fX2 - fX + 1;
-aTarget.append(makeRectPolygon(fX, fY1, 
fBlockW, aRange.getHeight()));
+
+double fH = aRange.getHeight();
+if (basegfx::fTools::equalZero(fH))
+fH = 1.0;
+
+aTarget.append(makeRectPolygon(fX, fY1, 
fBlockW, fH));
 }
 
 bLine = !bLine; // line and blank alternate.
@@ -497,7 +502,12 @@ namespace drawinglayer
 if (fY + fBlockH  fY2)
 // Clip the bottom end in case it spills 
over the range.
 fBlockH = fY2 - fY + 1;
-aTarget.append(makeRectPolygon(fX1, fY, 
aRange.getWidth(), fBlockH));
+
+double fW = aRange.getWidth();
+if (basegfx::fTools::equalZero(fW))
+fW = 1.0;
+
+aTarget.append(makeRectPolygon(fX1, fY, fW, 
fBlockH));
 }
 
 bLine = !bLine; // line and blank alternate.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-20 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   22 ++--
 1 file changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 80187cb4faeb7426dcb565abe43f5616b4e9d8a8
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Jan 20 12:30:11 2014 -0500

Handle double lines for screen rendering.

Double lines are always drawn as 2 parallel hair lines that are 1 pixel
apart, at any zoom level.

Change-Id: I2796477d0ea45c9880aa8057bd1a10104df96673

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 439ce61..61145f5 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -297,11 +297,14 @@ namespace drawinglayer
 switch (rSource.getStyle())
 {
 case table::BorderLineStyle::SOLID:
+case table::BorderLineStyle::DOUBLE:
 {
 const basegfx::BColor aLineColor =
 
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
 double nThick = rtl::math::round(rSource.getLeftWidth());
 
+bool bDouble = rSource.getStyle() == 
table::BorderLineStyle::DOUBLE;
+
 basegfx::B2DPolygon aTarget;
 
 if (bHorizontal)
@@ -314,12 +317,20 @@ namespace drawinglayer
 basegfx::B2DRange aRange = aTarget.getB2DRange();
 double fH = aRange.getHeight();
 
-if (fH = 1.0)
+if (fH = 1.0 || bDouble)
 {
 // 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;
 }
 }
@@ -333,12 +344,19 @@ namespace drawinglayer
 basegfx::B2DRange aRange = aTarget.getB2DRange();
 double fW = aRange.getWidth();
 
-if (fW = 1.0)
+if (fW = 1.0 || bDouble)
 {
 // 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;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-20 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   81 +---
 1 file changed, 66 insertions(+), 15 deletions(-)

New commits:
commit 6c4fc2b657a4c3e677c58604c6420ebeb73cdb9e
Author: Kohei Yoshida kohei.yosh...@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);
+}
 }
 
 

[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source include/svtools svtools/source

2014-01-18 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |  177 
 include/svtools/borderhelper.hxx|2 
 svtools/source/control/ctrlbox.cxx  |   10 
 3 files changed, 152 insertions(+), 37 deletions(-)

New commits:
commit 89b33572ef5121245494d551146ddb260f98ac9e
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Jan 18 23:02:05 2014 -0500

Better pixcelization of dashed lines for screen rendering.

Now the dashed lines are evenly placed on screen.  For now, horizontal lines
only.  I'll work on vertical lines later.

Change-Id: I474e9c8214e5f079ea2cfca12b35381d8fcf2ae1

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 97a6791..f1429a1 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -52,6 +52,7 @@
 #include drawinglayer/primitive2d/svggradientprimitive2d.hxx
 #include toolkit/helper/vclunohelper.hxx
 #include vcl/window.hxx
+#include svtools/borderhelper.hxx
 
 #include com/sun/star/table/BorderLineStyle.hpp
 
@@ -59,7 +60,20 @@
 
 using namespace com::sun::star;
 
-//
+namespace {
+
+basegfx::B2DPolygon makeRectPolygon( double fX, double fY, double fW, double 
fH )
+{
+basegfx::B2DPolygon aPoly;
+aPoly.append(basegfx::B2DPoint(fX, fY));
+aPoly.append(basegfx::B2DPoint(fX+fW, fY));
+aPoly.append(basegfx::B2DPoint(fX+fW, fY+fH));
+aPoly.append(basegfx::B2DPoint(fX, fY+fH));
+aPoly.setClosed(true);
+return aPoly;
+}
+
+}
 
 namespace drawinglayer
 {
@@ -245,56 +259,145 @@ namespace drawinglayer
 bool VclPixelProcessor2D::tryDrawBorderLinePrimitive2DDirect(
 const drawinglayer::primitive2d::BorderLinePrimitive2D rSource)
 {
-if (rSource.getStyle() == table::BorderLineStyle::SOLID)
-{
-const basegfx::B2DPoint rS = rSource.getStart();
-const basegfx::B2DPoint rE = rSource.getEnd();
+const basegfx::B2DPoint rS = rSource.getStart();
+const basegfx::B2DPoint rE = rSource.getEnd();
 
-double nX1 = rS.getX();
-double nY1 = rS.getY();
-double nX2 = rE.getX();
-double nY2 = rE.getY();
+double fX1 = rS.getX();
+double fY1 = rS.getY();
+double fX2 = rE.getX();
+double fY2 = rE.getY();
 
-if (nY1 == nY2)
+switch (rSource.getStyle())
+{
+case table::BorderLineStyle::SOLID:
 {
-// Horizontal line.  Draw it as a rectangle.
-basegfx::B2DPolygon aTarget;
+if (fY1 == fY2)
+{
+// Horizontal line.  Draw it as a rectangle.
 
-const basegfx::BColor aLineColor =
-
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
-double nThick = rtl::math::round(rSource.getLeftWidth());
+const basegfx::BColor aLineColor =
+
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
+double nThick = 
rtl::math::round(rSource.getLeftWidth());
 
-aTarget.append(basegfx::B2DPoint(nX1, nY1));
-aTarget.append(basegfx::B2DPoint(nX2, nY1));
-aTarget.append(basegfx::B2DPoint(nX2, nY1+nThick));
-aTarget.append(basegfx::B2DPoint(nX1, nY1+nThick));
-aTarget.setClosed(true);
-aTarget.transform(maCurrentTransformation);
+basegfx::B2DPolygon aTarget = makeRectPolygon(fX1, 
fY1, fX2-fX1, nThick);
+aTarget.transform(maCurrentTransformation);
 
-basegfx::B2DRange aRange = aTarget.getB2DRange();
-double fH = aRange.getHeight();
+basegfx::B2DRange aRange = aTarget.getB2DRange();
+double fH = aRange.getHeight();
 
-if (fH = 1.0)
-{
-// Draw it as a line.
-aTarget.clear();
-aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMinY()));
-aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), 
aRange.getMinY()));
+if (fH = 1.0)
+{
+// Draw it as a line.
+aTarget.clear();
+aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMinY()));
+aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), 

[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source include/svtools svtools/source

2014-01-18 Thread Kohei Yoshida
Rebased ref, commits from common ancestor:
commit 0c89bc6aec5204cb7a7ce2d725ff60e6dea0c9e2
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Jan 18 23:02:05 2014 -0500

Better pixelization of dashed lines for screen rendering.

Now the dashed lines are evenly placed on screen.  For now, horizontal lines
only.  I'll work on vertical lines later.

Change-Id: I474e9c8214e5f079ea2cfca12b35381d8fcf2ae1

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 97a6791..f1429a1 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -52,6 +52,7 @@
 #include drawinglayer/primitive2d/svggradientprimitive2d.hxx
 #include toolkit/helper/vclunohelper.hxx
 #include vcl/window.hxx
+#include svtools/borderhelper.hxx
 
 #include com/sun/star/table/BorderLineStyle.hpp
 
@@ -59,7 +60,20 @@
 
 using namespace com::sun::star;
 
-//
+namespace {
+
+basegfx::B2DPolygon makeRectPolygon( double fX, double fY, double fW, double 
fH )
+{
+basegfx::B2DPolygon aPoly;
+aPoly.append(basegfx::B2DPoint(fX, fY));
+aPoly.append(basegfx::B2DPoint(fX+fW, fY));
+aPoly.append(basegfx::B2DPoint(fX+fW, fY+fH));
+aPoly.append(basegfx::B2DPoint(fX, fY+fH));
+aPoly.setClosed(true);
+return aPoly;
+}
+
+}
 
 namespace drawinglayer
 {
@@ -245,56 +259,145 @@ namespace drawinglayer
 bool VclPixelProcessor2D::tryDrawBorderLinePrimitive2DDirect(
 const drawinglayer::primitive2d::BorderLinePrimitive2D rSource)
 {
-if (rSource.getStyle() == table::BorderLineStyle::SOLID)
-{
-const basegfx::B2DPoint rS = rSource.getStart();
-const basegfx::B2DPoint rE = rSource.getEnd();
+const basegfx::B2DPoint rS = rSource.getStart();
+const basegfx::B2DPoint rE = rSource.getEnd();
 
-double nX1 = rS.getX();
-double nY1 = rS.getY();
-double nX2 = rE.getX();
-double nY2 = rE.getY();
+double fX1 = rS.getX();
+double fY1 = rS.getY();
+double fX2 = rE.getX();
+double fY2 = rE.getY();
 
-if (nY1 == nY2)
+switch (rSource.getStyle())
+{
+case table::BorderLineStyle::SOLID:
 {
-// Horizontal line.  Draw it as a rectangle.
-basegfx::B2DPolygon aTarget;
+if (fY1 == fY2)
+{
+// Horizontal line.  Draw it as a rectangle.
 
-const basegfx::BColor aLineColor =
-
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
-double nThick = rtl::math::round(rSource.getLeftWidth());
+const basegfx::BColor aLineColor =
+
maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
+double nThick = 
rtl::math::round(rSource.getLeftWidth());
 
-aTarget.append(basegfx::B2DPoint(nX1, nY1));
-aTarget.append(basegfx::B2DPoint(nX2, nY1));
-aTarget.append(basegfx::B2DPoint(nX2, nY1+nThick));
-aTarget.append(basegfx::B2DPoint(nX1, nY1+nThick));
-aTarget.setClosed(true);
-aTarget.transform(maCurrentTransformation);
+basegfx::B2DPolygon aTarget = makeRectPolygon(fX1, 
fY1, fX2-fX1, nThick);
+aTarget.transform(maCurrentTransformation);
 
-basegfx::B2DRange aRange = aTarget.getB2DRange();
-double fH = aRange.getHeight();
+basegfx::B2DRange aRange = aTarget.getB2DRange();
+double fH = aRange.getHeight();
 
-if (fH = 1.0)
-{
-// Draw it as a line.
-aTarget.clear();
-aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMinY()));
-aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), 
aRange.getMinY()));
+if (fH = 1.0)
+{
+// Draw it as a line.
+aTarget.clear();
+aTarget.append(basegfx::B2DPoint(aRange.getMinX(), 
aRange.getMinY()));
+aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), 
aRange.getMinY()));
 
-mpOutputDevice-SetFillColor();
-mpOutputDevice-SetLineColor(Color(aLineColor));
+mpOutputDevice-SetFillColor();
+

[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-15 Thread Kohei Yoshida
 drawinglayer/source/primitive2d/borderlineprimitive2d.cxx |  170 +-
 1 file changed, 63 insertions(+), 107 deletions(-)

New commits:
commit 05667a72e748e82a06be7c931c261a1a5f11fbb5
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Wed Jan 15 10:19:16 2014 -0500

Draw double lined table border somewhat more pleasantly.

Still a scaling issue remains when printed.

Change-Id: I4aab8b976fefc6fd9fc5c08da8173de1326b9a4c

diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx 
b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index a8d774a..381dc79 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -28,7 +28,23 @@
 #include numeric
 #include algorithm
 
-//
+namespace {
+
+void moveLine(basegfx::B2DPolygon rPoly, double fGap, const 
basegfx::B2DVector rVector)
+{
+if (basegfx::fTools::equalZero(rVector.getX()))
+{
+basegfx::B2DHomMatrix aMat(1, 0, fGap, 0, 1, 0);
+rPoly.transform(aMat);
+}
+else if (basegfx::fTools::equalZero(rVector.getY()))
+{
+basegfx::B2DHomMatrix aMat(1, 0, 0, 0, 1, fGap);
+rPoly.transform(aMat);
+}
+}
+
+}
 
 namespace drawinglayer
 {
@@ -114,134 +130,75 @@ namespace drawinglayer
 if(!getStart().equal(getEnd())  ( isInsideUsed() || 
isOutsideUsed() ) )
 {
 // get data and vectors
-const double fWidth(getWidth(rViewInformation));
 basegfx::B2DVector aVector(getEnd() - getStart());
 aVector.normalize();
 const basegfx::B2DVector 
aPerpendicular(basegfx::getPerpendicular(aVector));
+basegfx::B2DVector aScale = 
rViewInformation.getInverseObjectToViewTransformation() * aVector;
 
 const basegfx::B2DPolyPolygon aClipRegion =
 getClipPolygon(rViewInformation);
 
 if(isOutsideUsed()  isInsideUsed())
 {
-const double fExt = getWidth(rViewInformation);  // Extend 
a lot: it'll be clipped after
+basegfx::B2DPolygon aPolygon;
+const double fExt = getWidth(rViewInformation);  // Extend 
a lot: it'll be clipped later.
+const basegfx::B2DPoint aTmpStart(getStart() - (fExt * 
aVector));
+const basegfx::B2DPoint aTmpEnd(getEnd() + (fExt * 
aVector));
 
-// both used, double line definition. Create left and 
right offset
-xRetval.realloc(2);
-sal_uInt32 nInsert(0);
+// Get which is the line to show
+double nWidth = getLeftWidth();
+basegfx::BColor aColor = getRGBColorLeft();
 
-basegfx::B2DPolygon aGap;
+bool const bIsHairline = lcl_UseHairline(
+nWidth, getStart(), getEnd(), rViewInformation);
+nWidth = lcl_GetCorrectedWidth(nWidth,
+getStart(), getEnd(), rViewInformation);
 
+if (bIsHairline)
 {
-// create geometry for left
-const basegfx::B2DVector aLeftOff(aPerpendicular * 
(0.5 * (lcl_GetCorrectedWidth(mfLeftWidth, getStart(), getEnd(), 
rViewInformation) - fWidth + 1)));
-const basegfx::B2DPoint aTmpStart(getStart() + 
aLeftOff - ( fExt * aVector));
-const basegfx::B2DPoint aTmpEnd(getEnd() + aLeftOff + 
( fExt * aVector));
-basegfx::B2DPolygon aLeft;
-
-if (lcl_UseHairline(mfLeftWidth, getStart(), getEnd(),
-rViewInformation))
-{
-// create hairline primitive
-aLeft.append(aTmpStart);
-aLeft.append(aTmpEnd);
-
-basegfx::B2DPolyPolygon const aClipped =
-basegfx::tools::clipPolygonOnPolyPolygon(
-aLeft, aClipRegion, true, true);
-
-xRetval[nInsert++] =
-new PolyPolygonHairlinePrimitive2D(
-aClipped,
-getRGBColorLeft());
-
-aGap.append( getStart() - getExtendLeftStart() * 
aVector );
-aGap.append( getEnd() + getExtendLeftEnd() * 
aVector );
-}
-else
-{
-// create filled polygon primitive. Already tried 
to create thick lines
-// with the correct LineWidth, but this leads to 

[Libreoffice-commits] core.git: Branch 'feature/calc-cell-borders' - drawinglayer/source

2014-01-14 Thread Kohei Yoshida
 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   13 +
 1 file changed, 13 insertions(+)

New commits:
commit 8d1e8eac41d9bb6cfb5ff68c8fffc684724776f7
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Jan 14 19:07:02 2014 -0500

Always disable anti-aliasing when drawing table borders.

Change-Id: Idede8220ac36c5bd4a88ceda33a99333f7b9fe90

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 8f9b537..9b020f7 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -843,6 +843,19 @@ namespace drawinglayer
 RenderSvgRadialAtomPrimitive2D(static_cast const 
primitive2d::SvgRadialAtomPrimitive2D (rCandidate));
 break;
 }
+case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D:
+{
+// process recursively, but turn off anti-aliasing. Border
+// lines are always rectangular, and look horrible when
+// the anti-aliasing is enabled.
+sal_uInt16 nAntiAliasing = 
mpOutputDevice-GetAntialiasing();
+mpOutputDevice-SetAntialiasing(nAntiAliasing  
~ANTIALIASING_ENABLE_B2DDRAW);
+
+
process(rCandidate.get2DDecomposition(getViewInformation2D()));
+
+mpOutputDevice-SetAntialiasing(nAntiAliasing);
+break;
+}
 default :
 {
 // process recursively
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits