From d3ffe3ed3fa1b80c7e54439673029e105940db80 Mon Sep 17 00:00:00 2001 From: Ri GangHu Date: Sun, 4 Aug 2013 14:39:18 +0300 Subject: fdo#67737 : fix for flip not being imported & rendered correctly Signed-off-by: Adam Co Reviewed-on: https://gerrit.libreoffice.org/5272 Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: I5c8440edad0381e33b64f64bb54aa8f1bc304007 --- oox/source/export/vmlexport.cxx | 21 ++++++++++++++------ oox/source/vml/vmlshape.cxx | 44 ++++++++++++++++++++++++++++++----------- 2 files changed, 48 insertions(+), 17 deletions(-) (limited to 'oox/source') diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 0c24040f0b91..6274e19b0b5e 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -795,6 +796,17 @@ OString VMLExport::ShapeIdString( sal_uInt32 nId ) return OStringBuffer( 20 ).append( "shape_" ).append( sal_Int64( nId ) ).makeStringAndClear(); } +void VMLExport::AddFlipXY( ) +{ + const sal_uInt32 nFlipHandV = SHAPEFLAG_FLIPH + SHAPEFLAG_FLIPV; + switch ( m_nShapeFlags & nFlipHandV ) + { + case SHAPEFLAG_FLIPH: m_pShapeStyle->append( ";flip:x" ); break; + case SHAPEFLAG_FLIPV: m_pShapeStyle->append( ";flip:y" ); break; + case (nFlipHandV): m_pShapeStyle->append( ";flip:xy" ); break; + } +} + void VMLExport::AddLineDimensions( const Rectangle& rRectangle ) { // style @@ -803,12 +815,7 @@ void VMLExport::AddLineDimensions( const Rectangle& rRectangle ) m_pShapeStyle->append( "position:absolute" ); - switch ( m_nShapeFlags & 0xC0 ) - { - case 0x40: m_pShapeStyle->append( ";flip:y" ); break; - case 0x80: m_pShapeStyle->append( ";flip:x" ); break; - case 0xC0: m_pShapeStyle->append( ";flip:xy" ); break; - } + AddFlipXY(); // the actual dimensions OString aLeft, aTop, aRight, aBottom; @@ -862,6 +869,8 @@ void VMLExport::AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& .append( ";width:" ).append( rRectangle.Right() - rRectangle.Left() ) .append( ";height:" ).append( rRectangle.Bottom() - rRectangle.Top() ); } + + AddFlipXY(); } void VMLExport::AddShapeAttribute( sal_Int32 nAttribute, const OString& rValue ) diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 40281cf545df..e5eb0175996b 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -501,21 +501,18 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes { awt::Rectangle aShapeRect(rShapeRect); boost::optional oRotation; + bool bFlipX = false, bFlipY = false; if (!maTypeModel.maRotation.isEmpty()) oRotation.reset(maTypeModel.maRotation.toInt32()); if (!maTypeModel.maFlip.isEmpty()) { if (maTypeModel.maFlip.equalsAscii("x")) { - aShapeRect.X += aShapeRect.Width; - aShapeRect.Width *= -1; - if (oRotation) - oRotation.reset(360 - *oRotation); + bFlipX = true; } else if (maTypeModel.maFlip.equalsAscii("y")) { - aShapeRect.Y += aShapeRect.Height; - aShapeRect.Height *= -1; + bFlipY = true; } } @@ -604,12 +601,37 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes } PropertySet aPropertySet(xShape); - if (xShape.is() && oRotation) + if (xShape.is()) { - lcl_SetRotation(aPropertySet, *oRotation); - // If rotation is used, simple setPosition() is not enough. - aPropertySet.setAnyProperty(PROP_HoriOrientPosition, makeAny( aShapeRect.X ) ); - aPropertySet.setAnyProperty(PROP_VertOrientPosition, makeAny( aShapeRect.Y ) ); + if (oRotation) + { + lcl_SetRotation(aPropertySet, *oRotation); + // If rotation is used, simple setPosition() is not enough. + aPropertySet.setAnyProperty(PROP_HoriOrientPosition, makeAny( aShapeRect.X ) ); + aPropertySet.setAnyProperty(PROP_VertOrientPosition, makeAny( aShapeRect.Y ) ); + } + + // When flip has 'x' or 'y', the associated ShapeRect will be changed but direction change doesn't occur. + // It might occur internally in SdrObject of "sw" module, not here. + // The associated properties "PROP_MirroredX" and "PROP_MirroredY" have to be set here so that direction change will occur internally. + if (bFlipX || bFlipY) + { + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aPropSequence (2); + int nPropertyIndex = 0; + if (bFlipX) + { + aPropSequence [nPropertyIndex].Name = "MirroredX"; + aPropSequence [nPropertyIndex].Value = makeAny (bFlipX); + nPropertyIndex++; + } + if (bFlipY) + { + aPropSequence [nPropertyIndex].Name = "MirroredY"; + aPropSequence [nPropertyIndex].Value = makeAny (bFlipY); + nPropertyIndex++; + } + aPropertySet.setAnyProperty(PROP_CustomShapeGeometry, makeAny( aPropSequence ) ); + } } lcl_SetAnchorType(aPropertySet, maTypeModel); -- cgit