include/svx/constructhelper.hxx | 6 ++++++ sd/source/ui/func/fuconrec.cxx | 31 ++++--------------------------- svx/source/svdraw/constructhelper.cxx | 9 +++++---- 3 files changed, 15 insertions(+), 31 deletions(-)
New commits: commit a780c820f5cf3bfbb5d88bd5c6ca670e0a0c730f Author: Dr. David Alan Gilbert <d...@treblig.org> AuthorDate: Sat Jul 1 14:34:19 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jul 3 22:21:18 2023 +0200 tdf#155630 Use common getPolygon for sd Unfortunately the SetLineEnds in sw is different enough from sw and sc to make sharing it a pain. However we can share the GetPolygon function we already moved into svx. Expose the svx function into the header and use it in sd. Change-Id: I05b0f820286c8ce848fa0d6c69603d3625c2b4d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153828 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/svx/constructhelper.hxx b/include/svx/constructhelper.hxx index 449a7ba7d1d0..928e6b1d3c68 100644 --- a/include/svx/constructhelper.hxx +++ b/include/svx/constructhelper.hxx @@ -19,15 +19,21 @@ #pragma once +#include <basegfx/polygon/b2dpolygontools.hxx> #include <svx/svxdllapi.h> #include <tools/long.hxx> +#include <unotools/resmgr.hxx> +class SdrModel; class SdrObject; class SfxItemSet; class SVXCORE_DLLPUBLIC ConstructHelper { public: + // Helper to find the shape for a given line end + static ::basegfx::B2DPolyPolygon GetLineEndPoly(TranslateId pResId, const SdrModel& rModel); + // set line starts and ends for newly created objects static void SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_uInt16 nSlotId, tools::Long nWidth); diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index a1f4e5f3c6cf..3561a6eb8c47 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -26,6 +26,7 @@ #include <app.hrc> #include <svl/itemset.hxx> +#include <svx/constructhelper.hxx> #include <svx/xlineit0.hxx> #include <svx/xlnstwit.hxx> #include <svx/xlnedwit.hxx> @@ -666,30 +667,6 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj) /** * set line starts and ends for the object to be created */ -static ::basegfx::B2DPolyPolygon getPolygon(TranslateId pResId, const SdrModel& rModel) -{ - ::basegfx::B2DPolyPolygon aRetval; - XLineEndListRef pLineEndList(rModel.GetLineEndList()); - - if( pLineEndList.is() ) - { - OUString aArrowName(SvxResId(pResId)); - ::tools::Long nCount = pLineEndList->Count(); - ::tools::Long nIndex; - for( nIndex = 0; nIndex < nCount; nIndex++ ) - { - const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nIndex); - if( pEntry->GetName() == aArrowName ) - { - aRetval = pEntry->GetLineEnd(); - break; - } - } - } - - return aRetval; -} - void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj) { if ( !((rObj.GetObjIdentifier() == SdrObjKind::Edge && @@ -710,7 +687,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj SdrModel& rModel(rObj.getSdrModelFromSdrObject()); // arrowhead - ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) ); + ::basegfx::B2DPolyPolygon aArrow(ConstructHelper::GetLineEndPoly(RID_SVXSTR_ARROW, rModel)); if( !aArrow.count() ) { ::basegfx::B2DPolygon aNewArrow; @@ -722,7 +699,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj } // Circles - ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) ); + ::basegfx::B2DPolyPolygon aCircle(ConstructHelper::GetLineEndPoly(RID_SVXSTR_CIRCLE, rModel)); if( !aCircle.count() ) { ::basegfx::B2DPolygon aNewCircle = ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0); @@ -731,7 +708,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj } // Square - ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) ); + ::basegfx::B2DPolyPolygon aSquare(ConstructHelper::GetLineEndPoly(RID_SVXSTR_SQUARE, rModel)); if( !aSquare.count() ) { ::basegfx::B2DPolygon aNewSquare; diff --git a/svx/source/svdraw/constructhelper.cxx b/svx/source/svdraw/constructhelper.cxx index f09d11787809..d7c7f20a5cc8 100644 --- a/svx/source/svdraw/constructhelper.cxx +++ b/svx/source/svdraw/constructhelper.cxx @@ -34,7 +34,8 @@ //using namespace ::com::sun::star; -static ::basegfx::B2DPolyPolygon lcl_getPolygon(TranslateId pResId, const SdrModel& rModel) +::basegfx::B2DPolyPolygon ConstructHelper::GetLineEndPoly(TranslateId pResId, + const SdrModel& rModel) { ::basegfx::B2DPolyPolygon aRetval; XLineEndListRef pLineEndList(rModel.GetLineEndList()); @@ -72,7 +73,7 @@ void ConstructHelper::SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_ // set attributes of line start and ends // arrowhead - ::basegfx::B2DPolyPolygon aArrow(lcl_getPolygon(RID_SVXSTR_ARROW, rModel)); + ::basegfx::B2DPolyPolygon aArrow(GetLineEndPoly(RID_SVXSTR_ARROW, rModel)); if (!aArrow.count()) { ::basegfx::B2DPolygon aNewArrow; @@ -84,7 +85,7 @@ void ConstructHelper::SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_ } // Circles - ::basegfx::B2DPolyPolygon aCircle(lcl_getPolygon(RID_SVXSTR_CIRCLE, rModel)); + ::basegfx::B2DPolyPolygon aCircle(GetLineEndPoly(RID_SVXSTR_CIRCLE, rModel)); if (!aCircle.count()) { ::basegfx::B2DPolygon aNewCircle = ::basegfx::utils::createPolygonFromEllipse( @@ -94,7 +95,7 @@ void ConstructHelper::SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_ } // Square - ::basegfx::B2DPolyPolygon aSquare(lcl_getPolygon(RID_SVXSTR_SQUARE, rModel)); + ::basegfx::B2DPolyPolygon aSquare(GetLineEndPoly(RID_SVXSTR_SQUARE, rModel)); if (!aSquare.count()) { ::basegfx::B2DPolygon aNewSquare;