diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2019-01-25 00:30:57 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2019-01-29 01:16:51 +0100 |
commit | 76c7a6c39d769cb9bdb9b951d9f95507c0139372 (patch) | |
tree | e718b89423f52c71d3f94afa12a738edfff21639 /xmloff | |
parent | ecc855aa1c86d88a99c3be06c70ed382180be688 (diff) |
Improve ODF enhanced-path command moveTo to follow spec
ODF 1.2 section 19.145 says 'If a moveto is followed by multiple
pairs of coordinates, they are treated as lineto.' The patch does
this on import.
Change-Id: Ib493ca49288cdb2d34b7ee801bd052281617d2e8
Reviewed-on: https://gerrit.libreoffice.org/66888
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/draw/ximpcustomshape.cxx | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index da15e3458cbb..35de24ba2562 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -792,16 +792,33 @@ static void GetEnhancedPath( std::vector< css::beans::PropertyValue >& rDest, } else if ( nParameterCount >= nParametersNeeded ) { - // check if the last command is identical, - // if so, we just need to increment the count - if ( !vSegments.empty() && ( vSegments[ vSegments.size() - 1 ].Command == nLatestSegmentCommand ) ) - vSegments[ vSegments.size() -1 ].Count++; - else + // Special rule for moveto in ODF 1.2 section 19.145 + // "If a moveto is followed by multiple pairs of coordinates, they are treated as lineto." + if ( nLatestSegmentCommand == css::drawing::EnhancedCustomShapeSegmentCommand::MOVETO ) { css::drawing::EnhancedCustomShapeSegment aSegment; - aSegment.Command = nLatestSegmentCommand; + aSegment.Command = css::drawing::EnhancedCustomShapeSegmentCommand::MOVETO; aSegment.Count = 1; vSegments.push_back( aSegment ); + nIndex--; + nLatestSegmentCommand = css::drawing::EnhancedCustomShapeSegmentCommand::LINETO; + nParametersNeeded = 1; + } + else + { + // General rule in ODF 1.2. section 19.145 + // "If a command is repeated multiple times, all repeated command characters + // except the first one may be omitted." Thus check if the last command is identical, + // if so, we just need to increment the count + if ( !vSegments.empty() && ( vSegments[ vSegments.size() - 1 ].Command == nLatestSegmentCommand ) ) + vSegments[ vSegments.size() -1 ].Count++; + else + { + css::drawing::EnhancedCustomShapeSegment aSegment; + aSegment.Command = nLatestSegmentCommand; + aSegment.Count = 1; + vSegments.push_back( aSegment ); + } } nParameterCount = 0; } |