drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 181 +++++++++++----- sc/qa/unit/data/xls/cell-borders.xls |binary 2 files changed, 135 insertions(+), 46 deletions(-)
New commits: commit 74af71890f588deffb20ce096c6c89a47acbf54e Author: Kohei Yoshida <[email protected]> Date: Mon Jan 20 11:10:52 2014 -0500 Better on-screen drawing of vertical dashed lines. Change-Id: I53d5f8b0278d1228cd941221a07cd360943c5ce6 diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index d037d0c..06ca763 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -267,6 +267,20 @@ namespace drawinglayer double fX2 = rE.getX(); double fY2 = rE.getY(); + bool bHorizontal = false; + if (fX1 == fX2) + { + // Vertical line. + } + else if (fY1 == fY2) + { + // Horizontal line. + bHorizontal = true; + } + else + // Neither. Bail out. + return false; + switch (rSource.getStyle()) { case table::BorderLineStyle::SOLID: @@ -275,14 +289,12 @@ namespace drawinglayer maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft()); double nThick = rtl::math::round(rSource.getLeftWidth()); - bool bDraw = false; bool bAsLine = false; basegfx::B2DPolygon aTarget; - if (fY1 == fY2) + if (bHorizontal) { // Horizontal line. Draw it as a rectangle. - bDraw = true; aTarget = makeRectPolygon(fX1, fY1, fX2-fX1, nThick); aTarget.transform(maCurrentTransformation); @@ -299,10 +311,9 @@ namespace drawinglayer bAsLine = true; } } - else if (fX1 == fX2) + else { // Vertical line. Draw it as a rectangle. - bDraw = true; aTarget = makeRectPolygon(fX1, fY1, nThick, fY2-fY1); aTarget.transform(maCurrentTransformation); @@ -320,9 +331,6 @@ namespace drawinglayer } } - if (!bDraw) - return false; - if (bAsLine) { mpOutputDevice->SetFillColor(); @@ -342,30 +350,37 @@ namespace drawinglayer case table::BorderLineStyle::DASHED: case table::BorderLineStyle::FINE_DASHED: { - double fH = rtl::math::round(rSource.getLeftWidth()); + std::vector<double> aPattern = + svtools::GetLineDashing(rSource.getStyle(), rSource.getPatternScale()*10.0); - if (fY1 == fY2) - { - // Horizontal line. + if (aPattern.empty()) + // Failed to get pattern values. + return false; - basegfx::B2DPolyPolygon aDashes; - std::vector<double> aPattern = - svtools::GetLineDashing(rSource.getStyle(), rSource.getPatternScale()*10.0); + double nThick = rtl::math::round(rSource.getLeftWidth()); + + // Transform the current line range before using it for rendering. + basegfx::B2DRange aRange(fX1, fY1, fX2, fY2); + aRange.transform(maCurrentTransformation); + fX1 = aRange.getMinX(); + fX2 = aRange.getMaxX(); + fY1 = aRange.getMinY(); + fY2 = aRange.getMaxY(); - if (aPattern.empty()) - // Failed to get pattern values. - return false; + basegfx::B2DPolyPolygon aTarget; + + if (bHorizontal) + { + // Horizontal line. // Create a dash unit polygon set. + basegfx::B2DPolyPolygon aDashes; std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end(); for (; it != itEnd; ++it) - { - double fW = *it; - aDashes.append(makeRectPolygon(0, 0, fW, fH)); - } + aDashes.append(makeRectPolygon(0, 0, *it, nThick)); aDashes.transform(maCurrentTransformation); - rtl::math::setNan(&fH); + rtl::math::setNan(&nThick); // Pixelize the dash unit. We use the same height for // all dash polygons. @@ -374,24 +389,15 @@ namespace drawinglayer for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i) { basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i); - basegfx::B2DRange aRange = aPoly.getB2DRange(); + aRange = aPoly.getB2DRange(); double fW = rtl::math::round(aRange.getWidth()); - if (rtl::math::isNan(fH)) - fH = rtl::math::round(aRange.getHeight()); + if (rtl::math::isNan(nThick)) + nThick = rtl::math::round(aRange.getHeight()); - aDashesPix.append(makeRectPolygon(0, 0, fW, fH)); + aDashesPix.append(makeRectPolygon(0, 0, fW, nThick)); } - // Transform the current line range before using it for rendering. - basegfx::B2DRange aRange(fX1, fY1, fX2, fY2); - aRange.transform(maCurrentTransformation); - fX1 = aRange.getMinX(); - fX2 = aRange.getMaxX(); - fY1 = aRange.getMinY(); - fY2 = aRange.getMaxY(); - // Make all dash polygons and render them. - basegfx::B2DPolyPolygon aTarget; double fX = fX1; bool bLine = true; sal_uInt32 i = 0, n = aDashesPix.count(); @@ -415,16 +421,68 @@ namespace drawinglayer if (i >= n) i = 0; } + } + else + { + // Vertical line. - const basegfx::BColor aLineColor = - maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft()); - mpOutputDevice->SetFillColor(Color(aLineColor)); - mpOutputDevice->SetLineColor(); + // Create a dash unit polygon set. + basegfx::B2DPolyPolygon aDashes; + std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end(); + for (; it != itEnd; ++it) + aDashes.append(makeRectPolygon(0, 0, nThick, *it)); - mpOutputDevice->DrawPolyPolygon(aTarget); + aDashes.transform(maCurrentTransformation); + rtl::math::setNan(&nThick); - return true; + // Pixelize the dash unit. We use the same width for + // all dash polygons. + basegfx::B2DPolyPolygon aDashesPix; + + for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i) + { + basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i); + aRange = aPoly.getB2DRange(); + double fH = rtl::math::round(aRange.getHeight()); + if (rtl::math::isNan(nThick)) + nThick = rtl::math::round(aRange.getWidth()); + + aDashesPix.append(makeRectPolygon(0, 0, nThick, fH)); + } + + // Make all dash polygons and render them. + double fY = fY1; + bool bLine = true; + sal_uInt32 i = 0, n = aDashesPix.count(); + while (fY <= fY2) + { + basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i); + aRange = aPoly.getB2DRange(); + if (bLine) + { + double fBlockH = aRange.getHeight(); + 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)); + } + + bLine = !bLine; // line and blank alternate. + fY += aRange.getHeight(); + + ++i; + if (i >= n) + i = 0; + } } + + const basegfx::BColor aLineColor = + maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft()); + mpOutputDevice->SetFillColor(Color(aLineColor)); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawPolyPolygon(aTarget); + + return true; } break; default: commit 33a1e8f1b305174742667e39d053a825de4e6b3c Author: Kohei Yoshida <[email protected]> Date: Mon Jan 20 10:12:53 2014 -0500 Same solid line treatment for vertical lines during on-screen drawing. Change-Id: Idb352dc2afeb2ee7b48620c972c2a186209228ea diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index f1429a1..d037d0c 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -271,15 +271,20 @@ namespace drawinglayer { case table::BorderLineStyle::SOLID: { + const basegfx::BColor aLineColor = + maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft()); + double nThick = rtl::math::round(rSource.getLeftWidth()); + + bool bDraw = false; + bool bAsLine = false; + basegfx::B2DPolygon aTarget; + if (fY1 == fY2) { // Horizontal line. Draw it as a rectangle. + bDraw = true; - const basegfx::BColor aLineColor = - maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft()); - double nThick = rtl::math::round(rSource.getLeftWidth()); - - basegfx::B2DPolygon aTarget = makeRectPolygon(fX1, fY1, fX2-fX1, nThick); + aTarget = makeRectPolygon(fX1, fY1, fX2-fX1, nThick); aTarget.transform(maCurrentTransformation); basegfx::B2DRange aRange = aTarget.getB2DRange(); @@ -291,20 +296,46 @@ namespace drawinglayer aTarget.clear(); aTarget.append(basegfx::B2DPoint(aRange.getMinX(), aRange.getMinY())); aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), aRange.getMinY())); + bAsLine = true; + } + } + else if (fX1 == fX2) + { + // Vertical line. Draw it as a rectangle. + bDraw = true; + + aTarget = makeRectPolygon(fX1, fY1, nThick, fY2-fY1); + aTarget.transform(maCurrentTransformation); - mpOutputDevice->SetFillColor(); - mpOutputDevice->SetLineColor(Color(aLineColor)); + basegfx::B2DRange aRange = aTarget.getB2DRange(); + double fW = aRange.getWidth(); - mpOutputDevice->DrawPolyLine(aTarget); - return true; + 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; } + } + + if (!bDraw) + return false; + if (bAsLine) + { + mpOutputDevice->SetFillColor(); + mpOutputDevice->SetLineColor(Color(aLineColor)); + mpOutputDevice->DrawPolyLine(aTarget); + } + else + { mpOutputDevice->SetFillColor(Color(aLineColor)); mpOutputDevice->SetLineColor(); - mpOutputDevice->DrawPolygon(aTarget); - return true; } + return true; } break; case table::BorderLineStyle::DOTTED: commit b8f707aecb99a58dd1bb09626bd36dccb5ae864d Author: Kohei Yoshida <[email protected]> Date: Mon Jan 20 10:04:26 2014 -0500 Add vertical lines for testing. Change-Id: I93d3613547b74a37cebbb6e791e0d23ea405401b diff --git a/sc/qa/unit/data/xls/cell-borders.xls b/sc/qa/unit/data/xls/cell-borders.xls index 87d6cf9..5bdf57f 100644 Binary files a/sc/qa/unit/data/xls/cell-borders.xls and b/sc/qa/unit/data/xls/cell-borders.xls differ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
