summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-10-17 12:37:04 +0200
committerLászló Németh <nemeth@numbertext.org>2019-10-22 14:33:46 +0200
commit9ff954d5f780cae5df6942e97b713cfc19449145 (patch)
tree68f1de08936b6e2cd138f38dc33fb3d535e14213 /oox
parent6fff5e07f63213b711d5ddd25e47e9593e306643 (diff)
tdf#127908 tdf#128193 Chart OOXML: Fix Custom Y axis title position
Import part: set the anchor position to the TOP_LEFT corner of the rectangle during the import, if the textbox is rotated with 90 or 270 degree. Because the OOXML files always contains the TOP_LEFT coordinates of a textbox, even if they are rotated. Note: Unfortunatelly we do not know the shape size, so this fix cannot handle rotations different than 0, 90 or 270 degrees. Export part: export the top left corner coordinates of axis title shape as the OOXML Standerd requires. Change-Id: Id0875d65884f6bfef8726135a7c03418d2ce3f23 Reviewed-on: https://gerrit.libreoffice.org/80939 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx32
-rw-r--r--oox/source/export/chartexport.cxx11
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);
/*