diff options
author | Paul Trojahn <paul.trojahn@gmail.com> | 2017-09-08 19:05:19 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-09-16 17:14:38 +0200 |
commit | 33a6eb3df861009d0fe9ffee344ef00cd2906520 (patch) | |
tree | 17dec3fc32d3ab9618f38a722860ad2923fe8b0b /oox | |
parent | update freetype to version 2.8 (diff) | |
download | core-33a6eb3df861009d0fe9ffee344ef00cd2906520.tar.gz core-33a6eb3df861009d0fe9ffee344ef00cd2906520.zip |
tdf#100065 PPTX Fix import of custom shapes in groups
A negative scale of the parent matrix indicates that the shape needs to
be flipped. This commit fixes text rotation as well, so
d742c0019435d0bc90c9342492583636099a057f is no longer needed.
Change-Id: I67bba34519b3af9215fe64a71f5137aa510edf7a
Reviewed-on: https://gerrit.libreoffice.org/42250
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/shape.cxx | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 8e418d19e22a..e75f6e8ca3d1 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -116,7 +116,6 @@ Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight ) , mnDiagramRotation( 0 ) , mbFlipH( false ) , mbFlipV( false ) -, mbInheritedTextFlipV(false) , mbHidden( false ) , mbHiddenMasterShape( false ) , mbLockedCanvas( false ) @@ -160,7 +159,6 @@ Shape::Shape( const ShapePtr& pSourceShape ) , mnDiagramRotation( pSourceShape->mnDiagramRotation ) , mbFlipH( pSourceShape->mbFlipH ) , mbFlipV( pSourceShape->mbFlipV ) -, mbInheritedTextFlipV(pSourceShape->mbInheritedTextFlipV) , mbHidden( pSourceShape->mbHidden ) , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape ) , mbLockedCanvas( pSourceShape->mbLockedCanvas ) @@ -317,7 +315,6 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText ) mnRotation = rReferencedShape.mnRotation; mbFlipH = rReferencedShape.mbFlipH; mbFlipV = rReferencedShape.mbFlipV; - mbInheritedTextFlipV = rReferencedShape.mbInheritedTextFlipV; mbHidden = rReferencedShape.mbHidden; } @@ -391,7 +388,6 @@ void Shape::addChildren( std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() ); while( aIter != rMaster.maChildren.end() ) { (*aIter)->setMasterTextListStyle( mpMasterTextListStyle ); - (*aIter)->applyParentTextFlipV(mbInheritedTextFlipV != mbFlipV); (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, getFillProperties(), pShapeMap ); } } @@ -492,7 +488,8 @@ Reference< XShape > const & Shape::createAndInsert( maSize.Height ? maSize.Height : 1.0 ); } - if( mbFlipH || mbFlipV || mnRotation != 0) + bool bInGroup = !aParentTransformation.isIdentity(); + if( mbFlipH || mbFlipV || mnRotation != 0 || bInGroup ) { // calculate object's center basegfx::B2DPoint aCenter(0.5, 0.5); @@ -507,30 +504,33 @@ Reference< XShape > const & Shape::createAndInsert( aTransformation.scale( mbFlipH ? -1.0 : 1.0, mbFlipV ? -1.0 : 1.0 ); } - if( bUseRotationTransform && mnRotation != 0 ) + if( bUseRotationTransform ) { // OOXML flips shapes before rotating them. - sal_Int32 nRotation = mnRotation; - if(bIsCustomShape) + double fRotation = F_PI180 * ( (double)mnRotation / 60000.0 ); + if( bIsCustomShape ) { - if(mbFlipH) + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aParentTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + // A negative scale means that the shape needs to be flipped + if(aScale.getX() < 0) { - nRotation = nRotation * -1 + 60000*360; + mbFlipH = !mbFlipH; } - if(mbFlipV) + if(aScale.getY() < 0) { - nRotation = nRotation * -1 + 60000*360; + mbFlipV = !mbFlipV; } } // rotate around object's center - aTransformation.rotate( F_PI180 * ( (double)nRotation / 60000.0 ) ); + aTransformation.rotate( fRotation ); } // move object back from center aTransformation.translate( aCenter.getX(), aCenter.getY() ); } - bool bInGroup = !aParentTransformation.isIdentity(); if( maPosition.X != 0 || maPosition.Y != 0) { // if global position is used, add it to transformation @@ -544,6 +544,25 @@ Reference< XShape > const & Shape::createAndInsert( aParentTransformation = aTransformation; aTransformation.scale(1/double(EMU_PER_HMM), 1/double(EMU_PER_HMM)); + if( bIsCustomShape ) + { + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + + // OOXML rotates shapes before flipping them, so the rotation needs to be inverted. + if( mbFlipH != mbFlipV) + { + // calculate object's center + basegfx::B2DPoint aCenter(0.5, 0.5); + aCenter *= aTransformation; + + aTransformation.translate( -aCenter.getX(), -aCenter.getY() ); + aTransformation.rotate( fRotate * -2.0 ); + aTransformation.translate( aCenter.getX(), aCenter.getY() ); + } + } + // special for lineshape if ( aServiceName == "com.sun.star.drawing.LineShape" ) { @@ -1093,8 +1112,6 @@ Reference< XShape > const & Shape::createAndInsert( if( getTextBody() ) { sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) ); - if(mbInheritedTextFlipV) - nTextRotateAngle -= 180 * 60000; nTextRotateAngle -= mnDiagramRotation; /* OOX measures text rotation clockwise in 1/60000th degrees, relative to the containing shape. setTextRotateAngle wants |