diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2022-05-03 00:18:00 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2022-05-03 18:54:49 +0200 |
commit | 8ad4fdb1687e705e31d9a4f30b385d50b91def08 (patch) | |
tree | 641a91b3c4bac01b159a7be07406e67c5dd096a7 /xmloff/source/draw/ximpcustomshape.cxx | |
parent | 6f94aa6f1a5990363b92689546241bc447096294 (diff) |
tdf#148714 Repair path in older CurvedArrow shapes
The CurvedArrow shapes had an error in their enhanced-path. The error
was fixed in the geometry definition with commit 4cfe4699. But the
wrong path was written to file markup. This patch repairs the path in
shapes in documents written before the fix of the geometry definition.
Change-Id: I6d7bc3b4ec4a61f16ce5dea3d352575525850b80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133740
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'xmloff/source/draw/ximpcustomshape.cxx')
-rw-r--r-- | xmloff/source/draw/ximpcustomshape.cxx | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index 6f4c586a9626..b50172624eec 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -577,8 +577,9 @@ static void GetEnhancedRectangleSequence( std::vector< css::beans::PropertyValue } } -static void GetEnhancedPath( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:enhanced-path - const OUString& rValue ) +static void +GetEnhancedPath(std::vector<css::beans::PropertyValue>& rDest, // e.g. draw:enhanced-path + const OUString& rValue, std::u16string_view rType) { std::vector< css::drawing::EnhancedCustomShapeParameterPair > vCoordinates; std::vector< css::drawing::EnhancedCustomShapeSegment > vSegments; @@ -820,6 +821,22 @@ static void GetEnhancedPath( std::vector< css::beans::PropertyValue >& rDest, } } + // Corrections for wrong paths in curvedArrow shapes written by older LO versions + if (!vSegments.empty() + && (rType == u"mso-spt102" || rType == u"mso-spt103" || rType == u"mso-spt104" + || rType == u"mso-spt105") + && vSegments[0].Count == 2) + { + vSegments[0].Count = 1; + css::drawing::EnhancedCustomShapeSegment aSegment; + aSegment.Count = 1; + aSegment.Command + = vSegments[0].Command == css::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC + ? css::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO + : css::drawing::EnhancedCustomShapeSegmentCommand::ARCTO; + vSegments.insert(vSegments.begin() + 1, aSegment); + } + // adding the Coordinates property beans::PropertyValue aProp; aProp.Name = EASGet( EAS_Coordinates ); @@ -868,12 +885,17 @@ void XMLEnhancedCustomShapeContext::startFastElement( { sal_Int32 nAttrNumber; std::optional<std::string_view> oSpecularityValue; // for postpone extrusion-specularity + std::optional<OUString> oPathValue; // for postpone GetEnhancedPath; + OUString sType("non-primitive"); // default in ODF for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { switch( EASGet( aIter.getToken() ) ) { case EAS_type : - GetString( mrCustomShapeGeometry, aIter.toString(), EAS_Type ); + { + sType = aIter.toString(); + GetString( mrCustomShapeGeometry, sType, EAS_Type ); + } break; case EAS_mirror_horizontal : GetBool( mrCustomShapeGeometry, aIter.toView(), EAS_MirroredX ); @@ -1054,7 +1076,7 @@ void XMLEnhancedCustomShapeContext::startFastElement( GetBool( maExtrusion, aIter.toView(), EAS_Color ); break; case EAS_enhanced_path : - GetEnhancedPath( maPath, aIter.toString() ); + oPathValue = aIter.toString(); break; case EAS_path_stretchpoint_x : { @@ -1133,6 +1155,8 @@ void XMLEnhancedCustomShapeContext::startFastElement( } if (oSpecularityValue) GetDoublePercentage( maExtrusion, *oSpecularityValue, EAS_Specularity ); + if (oPathValue) + GetEnhancedPath(maPath, *oPathValue, sType); } static void SdXMLCustomShapePropertyMerge( std::vector< css::beans::PropertyValue >& rPropVec, |