summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <g.araminowicz@gmail.com>2017-08-20 20:40:51 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-08-23 01:15:08 +0200
commitcf53f243d411b199ebf06661273c71de3b89753c (patch)
tree8b1b3bdbe1f42fbd4f88d1fe3288ea4c935a9a68 /oox
parent7d42e4b4c4fc3813eeb0f72807ffd17f47a86a64 (diff)
SmartArt: shape rotation support
Change-Id: I13bfbd3fafff5335ce8bc23b2579182aa5a94a80 Reviewed-on: https://gerrit.libreoffice.org/41393 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx15
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx2
-rw-r--r--oox/source/drawingml/shape.cxx11
3 files changed, 25 insertions, 3 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 672cfee8aff9..7bfe4996edef 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -284,23 +284,29 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
const sal_Int32 nStartAngle = maMap.count(XML_stAng) ? maMap.find(XML_stAng)->second : 0;
const sal_Int32 nSpanAngle = maMap.count(XML_spanAng) ? maMap.find(XML_spanAng)->second : 360;
+ const sal_Int32 nRotationPath = maMap.count(XML_rotPath) ? maMap.find(XML_rotPath)->second : XML_none;
const sal_Int32 nShapes = rShape->getChildren().size();
const awt::Size aCenter(rShape->getSize().Width / 2, rShape->getSize().Height / 2);
const awt::Size aChildSize(rShape->getSize().Width / 5, rShape->getSize().Height / 5);
- const sal_Int32 r = std::min(
+ const sal_Int32 nRadius = std::min(
(rShape->getSize().Width - aChildSize.Width) / 2,
(rShape->getSize().Height - aChildSize.Height) / 2);
sal_Int32 idx = 0;
for (auto & aCurrShape : rShape->getChildren())
{
+ const double fAngle = (double)idx*nSpanAngle/nShapes + nStartAngle;
const awt::Point aCurrPos(
- aCenter.Width + r*sin( (double(idx)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) - aChildSize.Width/2,
- aCenter.Height - r*cos( (double(idx)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) - aChildSize.Height/2);
+ aCenter.Width + nRadius*sin(fAngle*F_PI180) - aChildSize.Width/2,
+ aCenter.Height - nRadius*cos(fAngle*F_PI180) - aChildSize.Height/2);
aCurrShape->setPosition(aCurrPos);
aCurrShape->setSize(aChildSize);
aCurrShape->setChildSize(aChildSize);
+
+ if (nRotationPath == XML_alongPath)
+ aCurrShape->setRotation(fAngle * PER_DEGREE);
+
idx++;
}
break;
@@ -414,6 +420,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
break;
}
+ if (rShape->getRotation())
+ pTextBody->getTextProperties().moRotation = -rShape->getRotation();
+
// text centered vertically by default
pTextBody->getTextProperties().meVA = css::drawing::TextVerticalAdjust_CENTER;
pTextBody->getTextProperties().maPropertyMap.setProperty(PROP_TextVerticalAdjust, css::drawing::TextVerticalAdjust_CENTER);
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index ca41a568781b..77a3fa3b8ed8 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -263,6 +263,8 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
pShape.reset( new Shape("com.sun.star.drawing.GroupShape") );
}
+ pShape->setDiagramRotation(rAttribs.getInteger(XML_rot, 0) * PER_DEGREE);
+
ShapeAtomPtr pAtom( new ShapeAtom(mpNode->getLayoutNode(), pShape) );
mpNode->addChild( pAtom );
return new ShapeContext( *this, ShapePtr(), pShape );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index ada0aa35476e..8e418d19e22a 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -113,6 +113,7 @@ Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
, mnSubType( 0 )
, meFrameType( FRAMETYPE_GENERIC )
, mnRotation( 0 )
+, mnDiagramRotation( 0 )
, mbFlipH( false )
, mbFlipV( false )
, mbInheritedTextFlipV(false)
@@ -156,6 +157,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, maPosition( pSourceShape->maPosition )
, meFrameType( pSourceShape->meFrameType )
, mnRotation( pSourceShape->mnRotation )
+, mnDiagramRotation( pSourceShape->mnDiagramRotation )
, mbFlipH( pSourceShape->mbFlipH )
, mbFlipV( pSourceShape->mbFlipV )
, mbInheritedTextFlipV(pSourceShape->mbInheritedTextFlipV)
@@ -474,6 +476,14 @@ Reference< XShape > const & Shape::createAndInsert(
basegfx::B2DHomMatrix aTransformation;
+ if (bUseRotationTransform && mnDiagramRotation != 0)
+ {
+ // rotate diagram's shape around object's center before sizing
+ aTransformation.translate(-0.5, -0.5);
+ aTransformation.rotate(F_PI180 * (mnDiagramRotation / 60000.0));
+ aTransformation.translate(0.5, 0.5);
+ }
+
if( maSize.Width != 1 || maSize.Height != 1)
{
// take care there are no zeros used by error
@@ -1085,6 +1095,7 @@ Reference< XShape > const & Shape::createAndInsert(
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
degrees anticlockwise. */