sw/source/core/frmedt/feshview.cxx |  163 -------------------------------------
 1 file changed, 2 insertions(+), 161 deletions(-)

New commits:
commit f239b3dec1acbe7ad70df31e8264bb16ac095502
Author:     Dr. David Alan Gilbert <d...@treblig.org>
AuthorDate: Sat Jul 1 00:05:32 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Jul 3 21:34:23 2023 +0200

    tdf#155630 Use common SetLineEnds in sw
    
    Use the shared SetLineEnds code from sw.
    
    Change-Id: Ie388bb00401b6eb956ad5dc9032f1fae2d62d471
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153827
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/frmedt/feshview.cxx 
b/sw/source/core/frmedt/feshview.cxx
index 1c19ffb4eca4..537070f08c24 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <hintids.hxx>
+#include <svx/constructhelper.hxx>
 #include <svx/strings.hrc>
 #include <svx/sdrobjectfilter.hxx>
 #include <svx/svddrgmt.hxx>
@@ -105,38 +106,6 @@
 
 using namespace com::sun::star;
 
-/**
- * set line starts and ends for the object to be created
- */
-
-namespace {
-
-::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;
-}
-
-}
-
 SwFlyFrame *GetFlyFromMarked( const SdrMarkList *pLst, SwViewShell *pSh )
 {
     if ( !pLst )
@@ -953,135 +922,7 @@ static void lcl_NotifyNeighbours( const SdrMarkList *pLst 
)
 
 void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj, 
sal_uInt16 nSlotId)
 {
-    SdrModel& rModel(rObj.getSdrModelFromSdrObject());
-
-    if ( !(nSlotId == SID_LINE_ARROW_START      ||
-          nSlotId == SID_LINE_ARROW_END        ||
-          nSlotId == SID_LINE_ARROWS           ||
-          nSlotId == SID_LINE_ARROW_CIRCLE     ||
-          nSlotId == SID_LINE_CIRCLE_ARROW     ||
-          nSlotId == SID_LINE_ARROW_SQUARE     ||
-          nSlotId == SID_LINE_SQUARE_ARROW     ||
-          nSlotId == SID_DRAW_MEASURELINE) )
-        return;
-
-    // set attributes of line start and ends
-
-    // arrowhead
-    ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) );
-    if( !aArrow.count() )
-    {
-        ::basegfx::B2DPolygon aNewArrow;
-        aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0));
-        aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0));
-        aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0));
-        aNewArrow.setClosed(true);
-        aArrow.append(aNewArrow);
-    }
-
-    // Circles
-    ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) 
);
-    if( !aCircle.count() )
-    {
-        ::basegfx::B2DPolygon aNewCircle = 
::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 
250.0, 250.0);
-        aNewCircle.setClosed(true);
-        aCircle.append(aNewCircle);
-    }
-
-    // Square
-    ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) 
);
-    if( !aSquare.count() )
-    {
-        ::basegfx::B2DPolygon aNewSquare;
-        aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0));
-        aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0));
-        aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0));
-        aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0));
-        aNewSquare.setClosed(true);
-        aSquare.append(aNewSquare);
-    }
-
-    SfxItemSet aSet( rModel.GetItemPool() );
-    tools::Long nWidth = 100; // (1/100th mm)
-
-    // determine line width and calculate with it the line end width
-    if( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE )
-    {
-        tools::Long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue();
-        if( nValue > 0 )
-            nWidth = nValue * 3;
-    }
-
-    switch (nSlotId)
-    {
-        case SID_LINE_ARROWS:
-        case SID_DRAW_MEASURELINE:
-        {
-            // connector with arrow ends
-            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
-            rAttr.Put(XLineStartWidthItem(nWidth));
-            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
-            rAttr.Put(XLineEndWidthItem(nWidth));
-        }
-        break;
-
-        case SID_LINE_ARROW_START:
-        case SID_LINE_ARROW_CIRCLE:
-        case SID_LINE_ARROW_SQUARE:
-        {
-            // connector with arrow start
-            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
-            rAttr.Put(XLineStartWidthItem(nWidth));
-        }
-        break;
-
-        case SID_LINE_ARROW_END:
-        case SID_LINE_CIRCLE_ARROW:
-        case SID_LINE_SQUARE_ARROW:
-        {
-            // connector with arrow end
-            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
-            rAttr.Put(XLineEndWidthItem(nWidth));
-        }
-        break;
-    }
-
-    // and again, for the still missing ends
-    switch (nSlotId)
-    {
-        case SID_LINE_ARROW_CIRCLE:
-        {
-            // circle end
-            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
-            rAttr.Put(XLineEndWidthItem(nWidth));
-        }
-        break;
-
-        case SID_LINE_CIRCLE_ARROW:
-        {
-            // circle start
-            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
-            rAttr.Put(XLineStartWidthItem(nWidth));
-        }
-        break;
-
-        case SID_LINE_ARROW_SQUARE:
-        {
-            // square end
-            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
-            rAttr.Put(XLineEndWidthItem(nWidth));
-        }
-        break;
-
-        case SID_LINE_SQUARE_ARROW:
-        {
-            // square start
-            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
-            rAttr.Put(XLineStartWidthItem(nWidth));
-        }
-        break;
-    }
-
+    ConstructHelper::SetLineEnds(rAttr, rObj, nSlotId, 100);
 }
 
 void SwFEShell::SelectionToTop( bool bTop )

Reply via email to