1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <cppunit/TestAssert.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
13 
14 #include <tools/poly.hxx>
15 
16 namespace
17 {
18 class Test : public CppUnit::TestFixture
19 {
20 public:
21     void testTdf137068();
22 
23     CPPUNIT_TEST_SUITE(Test);
24     CPPUNIT_TEST(testTdf137068);
25     CPPUNIT_TEST_SUITE_END();
26 };
27 
testTdf137068()28 void Test::testTdf137068()
29 {
30     // Make sure PolyPolygon::Clip() does not break bezier curves.
31     const Point points[] = { { 1337, 411 }, { 1337, 471 }, { 1313, 530 }, { 1268, 582 } };
32     const PolyFlags flags[]
33         = { PolyFlags::Normal, PolyFlags::Control, PolyFlags::Control, PolyFlags::Normal };
34     tools::Polygon polygon(4, points, flags);
35     tools::PolyPolygon polyPolygon(polygon);
36     polyPolygon.Clip(tools::Rectangle(Point(0, 0), Size(1920, 1080)));
37     // operator== is stupid and just compares pointers, compare data manually
38     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), polyPolygon.Count());
39     tools::Polygon result = polyPolygon.GetObject(0);
40     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(4), result.GetSize());
41     CPPUNIT_ASSERT_EQUAL(points[0], result.GetPoint(0));
42     CPPUNIT_ASSERT_EQUAL(points[1], result.GetPoint(1));
43     CPPUNIT_ASSERT_EQUAL(points[2], result.GetPoint(2));
44     CPPUNIT_ASSERT_EQUAL(points[3], result.GetPoint(3));
45     CPPUNIT_ASSERT_EQUAL(flags[0], result.GetFlags(0));
46     CPPUNIT_ASSERT_EQUAL(flags[1], result.GetFlags(1));
47     CPPUNIT_ASSERT_EQUAL(flags[2], result.GetFlags(2));
48     CPPUNIT_ASSERT_EQUAL(flags[3], result.GetFlags(3));
49 }
50 
51 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
52 }
53 
54 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
55