[Libreoffice-commits] core.git: drawinglayer/CppunitTest_drawinglayer_border.mk drawinglayer/Module_drawinglayer.mk drawinglayer/qa drawinglayer/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Apr 15 14:46:24 UTC 2016


 drawinglayer/CppunitTest_drawinglayer_border.mk           |   35 +++++
 drawinglayer/Module_drawinglayer.mk                       |    4 
 drawinglayer/qa/unit/border.cxx                           |   82 ++++++++++++++
 drawinglayer/source/primitive2d/borderlineprimitive2d.cxx |    2 
 4 files changed, 122 insertions(+), 1 deletion(-)

New commits:
commit 1ee570a4e625719f8bf270d372926c0d829ae6f0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Apr 15 15:46:06 2016 +0200

    Related: tdf#99315 BorderLinePrimitive2D: fix solid line primitive width
    
    Regression from commit 2c62596cf264ef10749d8bfdb2bb2ebef2d98fbc
    (fdo#75260: Correctly draw double lines for both Writer and Calc.,
    2014-03-03), the problem was that when decomposing a double border line
    promitive to solid line primitives (which happens for the legacy
    "border" type, while both the Calc UI and Excel importer creates
    "border-thin" ones), the decomposed inner line's height was larger than
    the requested width.
    
    As a result there was no gap between the polygon of the inner and the
    outer line of the double border, looking like a non-double border.
    
    The width of the outer border is still incorrect on the screen, though.
    
    Change-Id: Ia9713c315ce8f23e2579b257169798e7c82c0a64
    Reviewed-on: https://gerrit.libreoffice.org/24115
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/drawinglayer/CppunitTest_drawinglayer_border.mk b/drawinglayer/CppunitTest_drawinglayer_border.mk
new file mode 100644
index 0000000..d477c4ec
--- /dev/null
+++ b/drawinglayer/CppunitTest_drawinglayer_border.mk
@@ -0,0 +1,35 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,drawinglayer_border))
+
+$(eval $(call gb_CppunitTest_use_api,drawinglayer_border,\
+	offapi \
+	udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,drawinglayer_border, \
+	basegfx \
+	cppu \
+	sal \
+	salhelper \
+	drawinglayer \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,drawinglayer_border,\
+	boost_headers \
+	libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,drawinglayer_border, \
+	drawinglayer/qa/unit/border \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/drawinglayer/Module_drawinglayer.mk b/drawinglayer/Module_drawinglayer.mk
index 52f2482..6d329e9 100644
--- a/drawinglayer/Module_drawinglayer.mk
+++ b/drawinglayer/Module_drawinglayer.mk
@@ -13,4 +13,8 @@ $(eval $(call gb_Module_add_targets,drawinglayer,\
     Library_drawinglayer \
 ))
 
+$(eval $(call gb_Module_add_slowcheck_targets,drawinglayer,\
+    CppunitTest_drawinglayer_border \
+))
+
 # vim: set noet sw=4 ts=4:
diff --git a/drawinglayer/qa/unit/border.cxx b/drawinglayer/qa/unit/border.cxx
new file mode 100644
index 0000000..40fa122
--- /dev/null
+++ b/drawinglayer/qa/unit/border.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <com/sun/star/table/BorderLineStyle.hpp>
+
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+
+using namespace com::sun::star;
+
+namespace
+{
+
+class DrawinglayerBorderTest : public CppUnit::TestFixture
+{
+public:
+    void testDoubleDecompositionSolid();
+
+    CPPUNIT_TEST_SUITE(DrawinglayerBorderTest);
+    CPPUNIT_TEST(testDoubleDecompositionSolid);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void DrawinglayerBorderTest::testDoubleDecompositionSolid()
+{
+    // Create a border line primitive that's similar to the one from the bugdoc:
+    // 1.47 pixels is 0.03cm at 130% zoom and 96 DPI.
+    basegfx::B2DPoint aStart(0, 20);
+    basegfx::B2DPoint aEnd(100, 20);
+    double fLeftWidth = 1.47;
+    double fDistance = 1.47;
+    double fRightWidth = 1.47;
+    double fExtendLeftStart = 0;
+    double fExtendLeftEnd = 0;
+    double fExtendRightStart = 0;
+    double fExtendRightEnd = 0;
+    basegfx::BColor aColorRight;
+    basegfx::BColor aColorLeft;
+    basegfx::BColor aColorGap;
+    bool bHasGapColor = false;
+    sal_Int16 nStyle = table::BorderLineStyle::DOUBLE;
+    drawinglayer::primitive2d::BorderLinePrimitive2D aBorder(aStart, aEnd, fLeftWidth, fDistance, fRightWidth, fExtendLeftStart, fExtendLeftEnd, fExtendRightStart, fExtendRightEnd, aColorRight, aColorLeft, aColorGap, bHasGapColor, nStyle);
+
+    // Decompose it into polygons.
+    drawinglayer::geometry::ViewInformation2D aView;
+    drawinglayer::primitive2d::Primitive2DContainer aContainer = aBorder.get2DDecomposition(aView);
+
+    // Make sure it results in two borders as it's a double one.
+    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), aContainer.size());
+
+    // Get the inside line.
+    auto pInside = dynamic_cast<const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D*>(aContainer[0].get());
+    CPPUNIT_ASSERT(pInside);
+
+    // Make sure the inside line's height is fLeftWidth.
+    const basegfx::B2DPolyPolygon& rPolyPolygon = pInside->getB2DPolyPolygon();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(1), rPolyPolygon.count());
+    const basegfx::B2DPolygon& rPolygon = rPolyPolygon.getB2DPolygon(0);
+    const basegfx::B2DRange& rRange = rPolygon.getB2DRange();
+    // This was 2.47, i.e. the width of the inner line was 1 unit (in the bugdoc's case: 1 pixel) wider than expected.
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(fLeftWidth, rRange.getHeight(), basegfx::fTools::getSmallValue());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DrawinglayerBorderTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index b2df3a3..4a6a150 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -63,7 +63,7 @@ primitive2d::Primitive2DReference makeSolidLinePrimitive(
     const basegfx::B2DVector& rVector, const basegfx::BColor& rColor, double fLineWidth, double fGap)
 {
     const basegfx::B2DVector aPerpendicular = basegfx::getPerpendicular(rVector);
-    const basegfx::B2DVector aLineWidthOffset = ((fLineWidth + 1.0) * 0.5) * aPerpendicular;
+    const basegfx::B2DVector aLineWidthOffset = (fLineWidth * 0.5) * aPerpendicular;
 
     basegfx::B2DPolygon aPolygon;
     aPolygon.append(rStart + aLineWidthOffset);


More information about the Libreoffice-commits mailing list