summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRi GangHu <sweetdream201@163.com>2013-08-04 14:39:18 +0300
committerMiklos Vajna <vmiklos@suse.cz>2013-08-22 17:06:10 +0200
commitd3ffe3ed3fa1b80c7e54439673029e105940db80 (patch)
treeb327a7ea5397c47be50109d15d7efd917d37d2ec /oox
parent84184f957d004e1f7b7a361935d34b1fc2af51d6 (diff)
fdo#67737 : fix for flip not being imported & rendered correctly
Signed-off-by: Adam Co <rattles2013@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/5272 Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: I5c8440edad0381e33b64f64bb54aa8f1bc304007
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/vmlexport.cxx21
-rw-r--r--oox/source/vml/vmlshape.cxx44
2 files changed, 48 insertions, 17 deletions
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 <svx/svdotext.hxx>
#include <vcl/cvtgrf.hxx>
#include <filter/msfilter/msdffimp.hxx>
+#include <filter/msfilter/escherex.hxx>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
@@ -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<sal_Int32> 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);