summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2023-07-01 00:05:32 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-07-03 21:34:23 +0200
commitf239b3dec1acbe7ad70df31e8264bb16ac095502 (patch)
tree735c80aba368f8d2966011526f62c50771182712 /sw
parent32fd602d3918be032d79322f76021c6ebc27ccba (diff)
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.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/frmedt/feshview.cxx163
1 files changed, 2 insertions, 161 deletions
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 )