diff options
author | Vasily Melenchuk <Vasily.Melenchuk@cib.de> | 2017-07-21 18:40:20 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-07-26 08:14:21 +0200 |
commit | 2d3b7a07c02c90d2d64a630ab84886ef3096edfc (patch) | |
tree | bd6060e696724dbacdb5e9e184c4868241a2a9d9 /oox | |
parent | 0efd702828abcfdcfb0799d9cf3de8d25c9c19b5 (diff) |
tdf#100491 fix DOCX import shape line with arrow marker
Line shape with arrow end markers was rendering rather thick
arrow, not connected to main line. Moreover, arrow width should
depend on actual line width.
Change-Id: I8d9a6e7f5d89a1645dcc5939ecc592e86e6fe34f
Reviewed-on: https://gerrit.libreoffice.org/40286
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/lineproperties.cxx | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index dabe5d71356b..43495e709561 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -205,14 +205,19 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap, if( !aBuffer.isEmpty() ) { + bool bIsArrow = nArrowType == XML_arrow; sal_Int32 nLength = lclGetArrowSize( rArrowProps.moArrowLength.get( XML_med ) ); sal_Int32 nWidth = lclGetArrowSize( rArrowProps.moArrowWidth.get( XML_med ) ); sal_Int32 nNameIndex = nWidth * 3 + nLength + 1; aBuffer.append( ' ' ).append( nNameIndex ); + if (bIsArrow) + { + // Arrow marker form depends also on line width + aBuffer.append(' ').append(nLineWidth); + } OUString aMarkerName = aBuffer.makeStringAndClear(); - bool bIsArrow = nArrowType == XML_arrow; double fArrowLength = 1.0; switch( nLength ) { @@ -229,7 +234,7 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap, } // set arrow width relative to line width sal_Int32 nBaseLineWidth = ::std::max< sal_Int32 >( nLineWidth, 70 ); - nMarkerWidth = static_cast< sal_Int32 >( fArrowWidth * nBaseLineWidth ); + nMarkerWidth = static_cast<sal_Int32>( fArrowWidth * nBaseLineWidth ); /* Test if the marker already exists in the marker table, do not create it again in this case. If markers are inserted explicitly @@ -238,7 +243,11 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap, if( !rPropMap.hasNamedLineMarkerInTable( aMarkerName ) ) { // pass X and Y as percentage to OOX_ARROW_POINT -#define OOX_ARROW_POINT( x, y ) awt::Point( static_cast< sal_Int32 >( fArrowWidth * x ), static_cast< sal_Int32 >( fArrowLength * y ) ) +#define OOX_ARROW_POINT( x, y ) awt::Point( static_cast< sal_Int32 >( fArrowWidth * ( x ) ), static_cast< sal_Int32 >( fArrowLength * ( y ) ) ) + // tdf#100491 Arrow line marker, unlike other markers, depends on line width. + // So calculate width of half line (more convinient during drawing) taking into account + // further conversions/scaling done in OOX_ARROW_POINT macro and scaling to nMarkerWidth. + const double fArrowLineHalfWidth = ::std::max< double >( 100.0 * 0.5 * nLineWidth / nMarkerWidth, 1 ); ::std::vector< awt::Point > aPoints; OSL_ASSERT((rArrowProps.moArrowType.get() & sal_Int32(0xFFFF0000))==0); @@ -251,13 +260,16 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap, aPoints.push_back( OOX_ARROW_POINT( 50, 0 ) ); break; case XML_arrow: - aPoints.push_back( OOX_ARROW_POINT( 50, 0 ) ); - aPoints.push_back( OOX_ARROW_POINT( 100, 91 ) ); - aPoints.push_back( OOX_ARROW_POINT( 85, 100 ) ); - aPoints.push_back( OOX_ARROW_POINT( 50, 36 ) ); - aPoints.push_back( OOX_ARROW_POINT( 15, 100 ) ); - aPoints.push_back( OOX_ARROW_POINT( 0, 91 ) ); - aPoints.push_back( OOX_ARROW_POINT( 50, 0 ) ); + aPoints.push_back( OOX_ARROW_POINT( 50, 0 ) ); + aPoints.push_back( OOX_ARROW_POINT( 100, 100 - fArrowLineHalfWidth * 1.5) ); + aPoints.push_back( OOX_ARROW_POINT( 100 - fArrowLineHalfWidth * 1.5, 100 ) ); + aPoints.push_back( OOX_ARROW_POINT( 50.0 + fArrowLineHalfWidth, 5.5 * fArrowLineHalfWidth) ); + aPoints.push_back( OOX_ARROW_POINT( 50.0 + fArrowLineHalfWidth, 100 ) ); + aPoints.push_back( OOX_ARROW_POINT( 50.0 - fArrowLineHalfWidth, 100 ) ); + aPoints.push_back( OOX_ARROW_POINT( 50.0 - fArrowLineHalfWidth, 5.5 * fArrowLineHalfWidth) ); + aPoints.push_back( OOX_ARROW_POINT( fArrowLineHalfWidth * 1.5, 100 ) ); + aPoints.push_back( OOX_ARROW_POINT( 0, 100 - fArrowLineHalfWidth * 1.5) ); + aPoints.push_back( OOX_ARROW_POINT( 50, 0 ) ); break; case XML_stealth: aPoints.push_back( OOX_ARROW_POINT( 50, 0 ) ); |