dev/null |binary drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 66 +++++++++++ drawinglayer/source/processor2d/vclpixelprocessor2d.hxx | 2 sc/qa/unit/subsequent_filters-test.cxx | 91 +++++++++------- 4 files changed, 121 insertions(+), 38 deletions(-)
New commits: commit 608863dc345e73e024a13accb05bd24d326363f3 Author: Kohei Yoshida <[email protected]> Date: Sat Jan 18 18:17:52 2014 -0500 Draw horizontal solid border lines directly in the pixel processor. This makes slightly skinnier solid lines which look better on screen. Change-Id: Ia7764be4a53d1dd6bb60ecb3ba5c8966403e4e6c diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 9b020f7..97a6791 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -34,6 +34,7 @@ #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx> #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> #include <drawinglayer/primitive2d/controlprimitive2d.hxx> +#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx> #include <com/sun/star/awt/XWindow2.hpp> #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> @@ -52,6 +53,8 @@ #include <toolkit/helper/vclunohelper.hxx> #include <vcl/window.hxx> +#include <com/sun/star/table/BorderLineStyle.hpp> + ////////////////////////////////////////////////////////////////////////////// using namespace com::sun::star; @@ -239,6 +242,63 @@ namespace drawinglayer return bTryWorked; } + 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(); + + double nX1 = rS.getX(); + double nY1 = rS.getY(); + double nX2 = rE.getX(); + double nY2 = rE.getY(); + + if (nY1 == nY2) + { + // Horizontal line. Draw it as a rectangle. + basegfx::B2DPolygon aTarget; + + 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::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())); + + mpOutputDevice->SetFillColor(); + mpOutputDevice->SetLineColor(Color(aLineColor)); + + mpOutputDevice->DrawPolyLine(aTarget); + return true; + } + + mpOutputDevice->SetFillColor(Color(aLineColor)); + mpOutputDevice->SetLineColor(); + + mpOutputDevice->DrawPolygon(aTarget); + return true; + } + + } + return false; + } + void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { switch(rCandidate.getPrimitive2DID()) @@ -851,7 +911,11 @@ namespace drawinglayer sal_uInt16 nAntiAliasing = mpOutputDevice->GetAntialiasing(); mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW); - process(rCandidate.get2DDecomposition(getViewInformation2D())); + const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder = + static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate); + + if (!tryDrawBorderLinePrimitive2DDirect(rBorder)) + process(rCandidate.get2DDecomposition(getViewInformation2D())); mpOutputDevice->SetAntialiasing(nAntiAliasing); break; diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx index a55962d..c9c2d742 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx @@ -34,6 +34,7 @@ namespace drawinglayer { namespace primitive2d { class PolyPolygonColorPrimitive2D; class PolygonHairlinePrimitive2D; class PolygonStrokePrimitive2D; + class BorderLinePrimitive2D; }} ////////////////////////////////////////////////////////////////////////////// @@ -64,6 +65,7 @@ namespace drawinglayer bool tryDrawPolyPolygonColorPrimitive2DDirect(const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D& rSource, double fTransparency); bool tryDrawPolygonHairlinePrimitive2DDirect(const drawinglayer::primitive2d::PolygonHairlinePrimitive2D& rSource, double fTransparency); bool tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency); + bool tryDrawBorderLinePrimitive2DDirect(const drawinglayer::primitive2d::BorderLinePrimitive2D& rSource); public: /// constructor/destructor commit 3bede34f958e4f970d76c27d434c136212dd90d9 Author: Kohei Yoshida <[email protected]> Date: Sat Jan 18 00:48:49 2014 -0500 fdo#73487: Write unit tests for this. Also remove the files used for the old tests. Change-Id: I4fbf6acce205d15a35780524120e351e01dc6642 diff --git a/sc/qa/unit/data/xls/border.xls b/sc/qa/unit/data/xls/border.xls deleted file mode 100644 index 876839b..0000000 Binary files a/sc/qa/unit/data/xls/border.xls and /dev/null differ diff --git a/sc/qa/unit/data/xlsx/border.xlsx b/sc/qa/unit/data/xlsx/border.xlsx deleted file mode 100755 index e33c083..0000000 Binary files a/sc/qa/unit/data/xlsx/border.xlsx and /dev/null differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index f0f8a92..1f3b3d4 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -102,8 +102,8 @@ public: void testMatrixODS(); void testMatrixXLS(); void testBorderODS(); - void testBorderXLS(); - void testBorderXLSX(); + void testCellBordersXLS(); + void testCellBordersXLSX(); void testBordersOoo33(); void testBugFixesODS(); void testBugFixesXLS(); @@ -174,8 +174,8 @@ public: CPPUNIT_TEST(testMatrixODS); CPPUNIT_TEST(testMatrixXLS); CPPUNIT_TEST(testBorderODS); -// CPPUNIT_TEST(testBorderXLS); -// CPPUNIT_TEST(testBorderXLSX); + CPPUNIT_TEST(testCellBordersXLS); + CPPUNIT_TEST(testCellBordersXLSX); CPPUNIT_TEST(testBordersOoo33); CPPUNIT_TEST(testBugFixesODS); CPPUNIT_TEST(testBugFixesXLS); @@ -232,7 +232,7 @@ public: private: void testPassword_Impl(const OUString& rFileNameBase); - void testBorderImpl( sal_uLong nFormatType ); + void testExcelCellBorders( sal_uLong nFormatType ); uno::Reference<uno::XInterface> m_xCalcComponent; }; @@ -776,51 +776,68 @@ void ScFiltersTest::testBorderODS() xDocSh->DoClose(); } -void ScFiltersTest::testBorderImpl( sal_uLong nFormatType ) +namespace { + +const char* toBorderName( sal_Int16 eStyle ) { - ScDocShellRef xDocSh = loadDoc("border.", nFormatType ); + switch (eStyle) + { + case table::BorderLineStyle::SOLID: return "SOLID"; + case table::BorderLineStyle::DOTTED: return "DOTTED"; + case table::BorderLineStyle::DASHED: return "DASHED"; + case table::BorderLineStyle::DOUBLE: return "DOUBLE"; + case table::BorderLineStyle::FINE_DASHED: return "FINE_DASHED"; + default: + ; + } - CPPUNIT_ASSERT_MESSAGE("Failed to load border.xls", xDocSh.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); + return ""; +} - const editeng::SvxBorderLine* pLeft = NULL; - const editeng::SvxBorderLine* pTop = NULL; - const editeng::SvxBorderLine* pRight = NULL; - const editeng::SvxBorderLine* pBottom = NULL; +} - pDoc->GetBorderLines( 2, 3, 0, &pLeft, &pTop, &pRight, &pBottom ); - CPPUNIT_ASSERT(pRight); - CPPUNIT_ASSERT_EQUAL( - table::BorderLineStyle::SOLID, pRight->GetBorderLineStyle()); - CPPUNIT_ASSERT_EQUAL(1L, pRight->GetWidth()); +void ScFiltersTest::testExcelCellBorders( sal_uLong nFormatType ) +{ + ScDocShellRef xDocSh = loadDoc("cell-borders.", nFormatType); - pDoc->GetBorderLines( 3, 5, 0, &pLeft, &pTop, &pRight, &pBottom ); - CPPUNIT_ASSERT(pRight); - CPPUNIT_ASSERT_EQUAL( - table::BorderLineStyle::SOLID, pRight->GetBorderLineStyle()); - CPPUNIT_ASSERT_EQUAL(20L, pRight->GetWidth()); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); - pDoc->GetBorderLines( 5, 7, 0, &pLeft, &pTop, &pRight, &pBottom ); - CPPUNIT_ASSERT(pRight); - CPPUNIT_ASSERT_EQUAL( - table::BorderLineStyle::SOLID, pRight->GetBorderLineStyle()); - CPPUNIT_ASSERT_EQUAL(30L, pRight->GetWidth()); + struct + { + SCROW mnRow; + sal_Int16 mnStyle; + long mnWidth; + } aChecks[] = { + { 1, table::BorderLineStyle::SOLID, 1L }, // hair + { 3, table::BorderLineStyle::DOTTED, 15L }, // thin + { 9, table::BorderLineStyle::FINE_DASHED, 15L }, // dashed + { 11, table::BorderLineStyle::SOLID, 15L }, // thin + { 19, table::BorderLineStyle::DASHED, 35L }, // medium dashed + { 21, table::BorderLineStyle::SOLID, 35L }, // medium + { 23, table::BorderLineStyle::SOLID, 50L }, // thick + { 25, table::BorderLineStyle::DOUBLE, -1L }, // double (don't check width) + }; - pDoc->GetBorderLines( 7, 9, 0, &pLeft, &pTop, &pRight, &pBottom ); - CPPUNIT_ASSERT(pRight); - CPPUNIT_ASSERT_EQUAL( - table::BorderLineStyle::FINE_DASHED, pRight->GetBorderLineStyle()); - CPPUNIT_ASSERT_EQUAL(1L, pRight->GetWidth()); + for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) + { + const editeng::SvxBorderLine* pLine = NULL; + pDoc->GetBorderLines(2, aChecks[i].mnRow, 0, NULL, &pLine, NULL, NULL); + CPPUNIT_ASSERT(pLine); + CPPUNIT_ASSERT_EQUAL(toBorderName(aChecks[i].mnStyle), toBorderName(pLine->GetBorderLineStyle())); + if (aChecks[i].mnWidth >= 0) + CPPUNIT_ASSERT_EQUAL(aChecks[i].mnWidth, pLine->GetWidth()); + } } -void ScFiltersTest::testBorderXLS() +void ScFiltersTest::testCellBordersXLS() { - testBorderImpl( XLS ); + testExcelCellBorders(XLS); } -void ScFiltersTest::testBorderXLSX() +void ScFiltersTest::testCellBordersXLSX() { - testBorderImpl( XLSX ); + testExcelCellBorders(XLSX); } struct Border _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
