diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/chart/converterbase.cxx | 32 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 11 |
2 files changed, 34 insertions, 9 deletions
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx index 8acf77c619df..0b6b876a11a0 100644 --- a/oox/source/drawingml/chart/converterbase.cxx +++ b/oox/source/drawingml/chart/converterbase.cxx @@ -405,18 +405,34 @@ void LayoutConverter::convertFromModel( const Reference< XShape >& rxShape, doub lclCalcPosition( aChartSize.Height, mrModel.mfY, mrModel.mnYMode ) ); if( (aShapePos.X >= 0) && (aShapePos.Y >= 0) ) { + bool bPropSet = false; // the call to XShape.getSize() may recalc the chart view awt::Size aShapeSize = rxShape->getSize(); // rotated shapes need special handling... - double fSin = fabs( sin( basegfx::deg2rad(fRotationAngle) ) ); - // add part of height to X direction, if title is rotated down - if( fRotationAngle > 180.0 ) - aShapePos.X += static_cast< sal_Int32 >( fSin * aShapeSize.Height + 0.5 ); - // add part of width to Y direction, if title is rotated up - else if( fRotationAngle > 0.0 ) - aShapePos.Y += static_cast< sal_Int32 >( fSin * aShapeSize.Width + 0.5 ); + if( aShapeSize.Height > 0 || aShapeSize.Width > 0 ) + { + double fSin = fabs(sin(basegfx::deg2rad(fRotationAngle))); + // add part of height to X direction, if title is rotated down + if( fRotationAngle > 180.0 ) + aShapePos.X += static_cast<sal_Int32>(fSin * aShapeSize.Height + 0.5); + // add part of width to Y direction, if title is rotated up + else if( fRotationAngle > 0.0 ) + aShapePos.Y += static_cast<sal_Int32>(fSin * aShapeSize.Width + 0.5); + } + else if( fRotationAngle == 90.0 || fRotationAngle == 270.0 ) + { + PropertySet aShapeProp( rxShape ); + RelativePosition aPos( + getLimitedValue< double, double >(mrModel.mfX, 0.0, 1.0), + getLimitedValue< double, double >(mrModel.mfY, 0.0, 1.0), + fRotationAngle == 90.0 ? Alignment_TOP_RIGHT : Alignment_BOTTOM_LEFT ); + // set the resulting position at the shape + if( aShapeProp.setProperty(PROP_RelativePosition, aPos) ) + bPropSet = true; + } // set the resulting position at the shape - rxShape->setPosition( aShapePos ); + if( !bPropSet ) + rxShape->setPosition( aShapePos ); } } } diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index d51ab5191d33..4eb82d71805e 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1213,8 +1213,17 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape, const OUString Reference<embed::XVisualObject> xVisObject(mxChartModel, uno::UNO_QUERY); awt::Size aPageSize = xVisObject->getVisualAreaSize(embed::Aspects::MSOLE_CONTENT); - // awt::Size aSize = xShape->getSize(); + awt::Size aSize = xShape->getSize(); awt::Point aPos2 = xShape->getPosition(); + // rotated shapes need special handling... + double fSin = fabs(sin(basegfx::deg2rad(nRotation*0.01))); + // remove part of height from X direction, if title is rotated down + if( nRotation*0.01 > 180.0 ) + aPos2.X -= static_cast<sal_Int32>(fSin * aSize.Height + 0.5); + // remove part of width from Y direction, if title is rotated up + else if( nRotation*0.01 > 0.0 ) + aPos2.Y -= static_cast<sal_Int32>(fSin * aSize.Width + 0.5); + double x = static_cast<double>(aPos2.X) / static_cast<double>(aPageSize.Width); double y = static_cast<double>(aPos2.Y) / static_cast<double>(aPageSize.Height); /* |