From b4a6977e05d87fe0a79b266ec30e4f403404f1b4 Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Sat, 21 Dec 2019 22:32:55 +0100 Subject: tdf#129532 tdf#98839 fixes for mirror of custom shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tdf#98839 In case a sheared custom shape was mirrored, the shear angle in draw:transform had a wrong sign in the saved file. tdf#129532 Mirroring given in draw:transform in file or via macro was wrongly applied. Errors: 1)Mirroring from draw:transform attribute had overwritten already existing mirroring in the enhanced-geometry. 2)Mirroring from draw:transform attribute was set in enhanced- geometry attributes but not really applied. Change-Id: Ifa52f3606b5a33e6492a02d6e19c883d28752da8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85670 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- xmloff/source/draw/ximpshap.cxx | 67 ++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 27 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 419c0174ae81..f0a8a169842a 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -3755,11 +3755,9 @@ void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAtt void SdXMLCustomShapeContext::EndElement() { - // for backward compatibility, the above SetTransformation() may already have - // applied a call to SetMirroredX/SetMirroredY. This is not yet added to the - // beans::PropertyValues in maCustomShapeGeometry. When applying these now, this - // would be lost again. - // TTTT: Remove again after aw080 + // Customshapes remember mirror state in its enhanced geometry. + // SetTransformation() in StartElement() may have applied mirroring, but that is not yet + // contained. Merge that information here before writing the property. if(!maUsedTransformation.isIdentity()) { basegfx::B2DVector aScale, aTranslate; @@ -3767,43 +3765,58 @@ void SdXMLCustomShapeContext::EndElement() maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX); - bool bFlippedX(aScale.getX() < 0.0); - bool bFlippedY(aScale.getY() < 0.0); - - if(bFlippedX && bFlippedY) + if (aScale.getX() < 0.0) { - // when both are used it is the same as 180 degree rotation; reset - bFlippedX = bFlippedY = false; + const OUString sName("MirroredX"); + //fdo#84043 Merge, if property exists, otherwise append it + auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(), + [&sName](beans::PropertyValue& rValue) { return rValue.Name == sName; }); + if (aI != maCustomShapeGeometry.end()) + { + beans::PropertyValue& rItem = *aI; + bool bMirroredX; + rItem.Value >>= bMirroredX; + rItem.Value <<= !bMirroredX; + rItem.Handle = -1; + rItem.State = beans::PropertyState_DIRECT_VALUE; + } + else + { + beans::PropertyValue* pItem; + maCustomShapeGeometry.emplace_back(); + pItem = &maCustomShapeGeometry.back(); + pItem->Name = sName; + pItem->Handle = -1; + pItem->Value <<= true; + pItem->State = beans::PropertyState_DIRECT_VALUE; + } } - if(bFlippedX || bFlippedY) + if (aScale.getY() < 0.0) { - OUString sName; - - if(bFlippedX) - sName = "MirroredX"; - else - sName = "MirroredY"; - - //fdo#84043 overwrite the property if it already exists, otherwise append it - beans::PropertyValue* pItem; + const OUString sName("MirroredY"); + //fdo#84043 Merge, if property exists, otherwise append it auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(), [&sName](beans::PropertyValue& rValue) { return rValue.Name == sName; }); if (aI != maCustomShapeGeometry.end()) { beans::PropertyValue& rItem = *aI; - pItem = &rItem; + bool bMirroredY; + rItem.Value >>= bMirroredY; + rItem.Value <<= !bMirroredY; + rItem.Handle = -1; + rItem.State = beans::PropertyState_DIRECT_VALUE; } else { + beans::PropertyValue* pItem; maCustomShapeGeometry.emplace_back(); pItem = &maCustomShapeGeometry.back(); + pItem->Name = sName; + pItem->Handle = -1; + pItem->Value <<= true; + pItem->State = beans::PropertyState_DIRECT_VALUE; } - - pItem->Name = sName; - pItem->Handle = -1; - pItem->Value <<= true; - pItem->State = beans::PropertyState_DIRECT_VALUE; } } -- cgit