From 124382eba6aaeb475b4077920c082bf5c51ac029 Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Thu, 5 May 2022 17:31:39 +0200 Subject: tdf#148707 implicit moveTo on all not only on first The current solution checks implicit moveTo only on the first arc in a sequence of arcs. The patch moves it into the loop, so that the implicit moveTo is done for each command in a sequence. Change-Id: I400fa8fc96d7377ede55296c71e7a82ce891cc24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133896 Tested-by: Jenkins Reviewed-by: Regina Henschel --- svx/qa/unit/customshapes.cxx | 23 +++++++++++++++++++++ svx/qa/unit/data/tdf148707_two_commands_B_V.odp | Bin 0 -> 13389 bytes svx/source/customshapes/EnhancedCustomShape2d.cxx | 24 +++++++++++----------- 3 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 svx/qa/unit/data/tdf148707_two_commands_B_V.odp (limited to 'svx') diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 62e7728f7556..0b1970378e2a 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -1377,6 +1377,29 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148714_CurvedArrows) } } } + +CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148707_two_commands_B_V) +{ + // tdf148707 custom shape with multiple command B or multiple command V were drawn with a line + // between the arcs as if the second command was a A or W respectively. + // The test document has a shape with path "V 0 0 50 100 0 50 25 0 50 0 100 100 75 0 100 50 N" + // and a shape with path "B 0 0 50 100 0 50 25 100 50 0 100 100 75 100 100 50 N". + OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf148707_two_commands_B_V.odp"; + mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + for (sal_uInt8 i = 0; i < 2; i++) + { + uno::Reference xShape(getShape(i)); + // In case no line is drawn, two polygons are generated; with line only one polygon + SdrObjCustomShape& rSdrObjCustomShape( + static_cast(*SdrObject::getSdrObjectFromXShape(xShape))); + EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); + SdrPathObjUniquePtr pPathObj( + static_cast(aCustomShape2d.CreateLineGeometry().release())); + CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj); + const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", sal_uInt32(2), aPolyPolygon.count()); + } +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/qa/unit/data/tdf148707_two_commands_B_V.odp b/svx/qa/unit/data/tdf148707_two_commands_B_V.odp new file mode 100644 index 000000000000..c26d371ef6a9 Binary files /dev/null and b/svx/qa/unit/data/tdf148707_two_commands_B_V.odp differ diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 1215433044ab..a521b6eb3120 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -2337,25 +2337,25 @@ void EnhancedCustomShape2d::CreateSubPath( case ARC : case CLOCKWISEARC : - { - if(aNewB2DPolygon.count() > 1) - { - // #i76201# Add conversion to closed polygon when first and last points are equal - basegfx::utils::checkClosed(aNewB2DPolygon); - aNewB2DPolyPolygon.append(aNewB2DPolygon); - } - - aNewB2DPolygon.clear(); - - [[fallthrough]]; - } case ARCTO : case CLOCKWISEARCTO : { bool bClockwise = ( nCommand == CLOCKWISEARC ) || ( nCommand == CLOCKWISEARCTO ); + bool bImplicitMoveTo = (nCommand == ARC) || (nCommand == CLOCKWISEARC); sal_uInt32 nXor = bClockwise ? 3 : 2; for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 3 ) < nCoordSize ); i++ ) { + if (bImplicitMoveTo) + { + if (aNewB2DPolygon.count() > 1) + { + // #i76201# Add conversion to closed polygon when first and last + // points are equal + basegfx::utils::checkClosed(aNewB2DPolygon); + aNewB2DPolyPolygon.append(aNewB2DPolygon); + } + aNewB2DPolygon.clear(); + } tools::Rectangle aRect = tools::Rectangle::Justify( GetPoint( seqCoordinates[ rSrcPt ], true, true ), GetPoint( seqCoordinates[ rSrcPt + 1 ], true, true ) ); if ( aRect.GetWidth() && aRect.GetHeight() ) { -- cgit