From 7911041df4692d68f115c853689174f265d74820 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Fri, 5 Jul 2024 07:19:15 +0200 Subject: Add escape direction support for glue points in the preset shapes Change-Id: I6727def5dd42ecd5dae3ddd27d2af733b5883e09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170006 Tested-by: Jenkins Reviewed-by: Nagy Tibor Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170089 --- svx/source/customshapes/EnhancedCustomShape2d.cxx | 34 +++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'svx') diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 4c68aa45ded2..5c8ba5fb64ad 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -565,6 +565,7 @@ void EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryIt static constexpr OUString sPath( u"Path"_ustr ); static constexpr OUStringLiteral sCoordinates( u"Coordinates" ); static constexpr OUStringLiteral sGluePoints( u"GluePoints" ); + static constexpr OUStringLiteral sGluePointLeavingDirections( u"GluePointLeavingDirections" ); static constexpr OUStringLiteral sSegments( u"Segments" ); static constexpr OUStringLiteral sSubViewSize( u"SubViewSize" ); static constexpr OUStringLiteral sStretchX( u"StretchX" ); @@ -585,6 +586,10 @@ void EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryIt if ( pAny ) *pAny >>= m_seqGluePoints; + // Path/GluePointLeavingDirections + pAny = const_cast(rGeometryItem).GetPropertyValueByName(sPath, sGluePointLeavingDirections); + if (pAny) + *pAny >>= m_seqGluePointLeavingDirections; // Path/Segments pAny = const_cast(rGeometryItem).GetPropertyValueByName( sPath, sSegments ); @@ -3064,19 +3069,38 @@ rtl::Reference EnhancedCustomShape2d::CreateObject( bool bLineGeometr return pRet; } -void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj ) +static SdrEscapeDirection lcl_GetEscapeDirection(sal_Int32 nDirection) +{ + switch (nDirection) + { + case 1: return SdrEscapeDirection::LEFT; + case 2: return SdrEscapeDirection::RIGHT; + case 3: return SdrEscapeDirection::TOP; + case 4: return SdrEscapeDirection::BOTTOM; + default: return SdrEscapeDirection::SMART; + } +} + +void EnhancedCustomShape2d::ApplyGluePoints(SdrObject* pObj) { if ( !pObj ) return; - for (const auto& rGluePoint : m_seqGluePoints) + SdrEscapeDirection aDirection = SdrEscapeDirection::SMART; + for (size_t i = 0; i < m_seqGluePoints.size(); i++) { - SdrGluePoint aGluePoint; + EnhancedCustomShapeParameterPair aGluePointPair = m_seqGluePoints[i]; + if (m_seqGluePointLeavingDirections.hasElements()) + { + sal_Int32 aGluePointLeavingDirection = m_seqGluePointLeavingDirections[i]; + aDirection = lcl_GetEscapeDirection(aGluePointLeavingDirection); + } - aGluePoint.SetPos( GetPoint( rGluePoint, !m_bOOXMLShape, true ) ); + SdrGluePoint aGluePoint; + aGluePoint.SetPos( GetPoint( aGluePointPair, !m_bOOXMLShape, true ) ); aGluePoint.SetPercent( false ); aGluePoint.SetAlign( SdrAlign::VERT_TOP | SdrAlign::HORZ_LEFT ); - aGluePoint.SetEscDir( SdrEscapeDirection::SMART ); + aGluePoint.SetEscDir( aDirection ); SdrGluePointList* pList = pObj->ForceGluePointList(); if( pList ) /* sal_uInt16 nId = */ pList->Insert( aGluePoint ); -- cgit