include/tools/poly.hxx | 13 +++++++++ include/vcl/metaact.hxx | 2 - vcl/qa/cppunit/outdev.cxx | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-)
New commits: commit ed92e40aea759d435ec1c05877e6480654a06ab6 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Sat Oct 2 14:42:01 2021 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Oct 18 20:22:39 2021 +0200 vcl: test OutputDevice::DrawPolyPolygon() Change-Id: I166f715489ecff3095ccfb485153629050bfca20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122977 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx index 3c39f2d6c56b..d2ecf644af39 100644 --- a/include/tools/poly.hxx +++ b/include/tools/poly.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_TOOLS_POLY_HXX #define INCLUDED_TOOLS_POLY_HXX +#include <rtl/ustring.hxx> #include <tools/toolsdllapi.h> #include <tools/gen.hxx> #include <tools/degree.hxx> @@ -272,6 +273,18 @@ inline std::basic_ostream<charT, traits> & operator <<( if (i > 0) stream << "--"; stream << poly.GetPoint(i); + + OUString aFlag; + if (poly.GetFlags(i) == PolyFlags::Normal) + aFlag = "Normal"; + else if (poly.GetFlags(i) == PolyFlags::Smooth) + aFlag = "Smooth"; + else if (poly.GetFlags(i) == PolyFlags::Control) + aFlag = "Control"; + else if (poly.GetFlags(i) == PolyFlags::Symmetric) + aFlag = "Symmetric"; + + stream << ";f=" << aFlag; } stream << ">"; return stream; diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx index a80469bca1e5..ed74de84d5cd 100644 --- a/include/vcl/metaact.hxx +++ b/include/vcl/metaact.hxx @@ -435,7 +435,7 @@ public: void SetPolygon(const tools::Polygon& rPoly) { maPoly = rPoly; } }; -class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPolyPolygonAction final : public MetaAction +class VCL_DLLPUBLIC MetaPolyPolygonAction final : public MetaAction { private: diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 799a7fdc8708..df5d8b2c9bf4 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -13,6 +13,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/vector/b2enums.hxx> #include <vcl/lineinfo.hxx> @@ -86,6 +87,7 @@ public: void testDrawWaveLine(); void testDrawPolyLine(); void testDrawPolygon(); + void testDrawPolyPolygon(); CPPUNIT_TEST_SUITE(VclOutdevTest); CPPUNIT_TEST(testVirtualDevice); @@ -138,6 +140,7 @@ public: CPPUNIT_TEST(testDrawWaveLine); CPPUNIT_TEST(testDrawPolyLine); CPPUNIT_TEST(testDrawPolygon); + CPPUNIT_TEST(testDrawPolyPolygon); CPPUNIT_TEST_SUITE_END(); }; @@ -1947,6 +1950,69 @@ void VclOutdevTest::testDrawPolygon() } } +static tools::PolyPolygon createPolyPolygon() +{ + tools::Polygon aPolygon(4); + + aPolygon.SetPoint(Point(1, 8), 0); + aPolygon.SetPoint(Point(2, 7), 1); + aPolygon.SetPoint(Point(3, 6), 2); + aPolygon.SetPoint(Point(4, 5), 3); + + tools::PolyPolygon aPolyPolygon(aPolygon); + aPolyPolygon.Optimize(PolyOptimizeFlags::CLOSE); + + return aPolyPolygon; +} + +void VclOutdevTest::testDrawPolyPolygon() +{ + { + ScopedVclPtrInstance<VirtualDevice> pVDev; + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + pVDev->SetOutputSizePixel(Size(100, 100)); + + tools::PolyPolygon aPolyPolygon = createPolyPolygon(); + + pVDev->DrawPolyPolygon(aPolyPolygon); + + MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON, + pAction->GetType()); + + MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast<MetaPolyPolygonAction*>(pAction); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not the same polypolygon in polypolygon action", aPolyPolygon, + pPolyPolygonAction->GetPolyPolygon()); + } + + { + ScopedVclPtrInstance<VirtualDevice> pVDev; + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + pVDev->SetOutputSizePixel(Size(100, 100)); + + tools::PolyPolygon aPolyPolygon = createPolyPolygon(); + + basegfx::B2DPolyPolygon aB2DPolyPolygon(aPolyPolygon.getB2DPolyPolygon()); + + pVDev->DrawPolyPolygon(aB2DPolyPolygon); + + MetaAction* pAction = aMtf.GetAction(INITIAL_SETUP_ACTION_COUNT); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON, + pAction->GetType()); + + /* these should match, but the equality operator does not work on PolyPolygon for some reason + + MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast<MetaPolyPolygonAction*>(pAction); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not the same polypolygon in polypolygon action", aPolyPolygon, + pPolyPolygonAction->GetPolyPolygon()); + */ + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest); CPPUNIT_PLUGIN_IMPLEMENT();