tdf#117539 Assert after cut and paste operation of a chart stick
Change-Id: I314d263dc37a7af3969ba9eb32ac00997457003d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136574
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 40da194..2d67c5c 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -367,14 +367,30 @@ void ChartController::impl_PasteGraphic(
xGraphicShape->SvxShape::setPropertyValue( "Graphic", uno::Any( xGraphic ));
awt::Size aGraphicSize( 1000, 1000 );
bool bGotGraphicSize = false;
try
{
bGotGraphicSize = xGraphicShape->SvxShape::getPropertyValue( "Size100thMM") >>= aGraphicSize;
}
catch (css::beans::UnknownPropertyException& )
{}
auto pChartWindow(GetChartWindow());
// first try size in 100th mm, then pixel size
if( ! ( xGraphicShape->SvxShape::getPropertyValue( "Size100thMM") >>= aGraphicSize ) &&
( ( xGraphicShape->SvxShape::getPropertyValue( "SizePixel") >>= aGraphicSize ) && pChartWindow ))
if( !bGotGraphicSize )
{
::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height )));
aGraphicSize.Width = aVCLSize.getWidth();
aGraphicSize.Height = aVCLSize.getHeight();
bool bGotSizePixel = false;
try
{
bGotSizePixel = xGraphicShape->SvxShape::getPropertyValue( "SizePixel") >>= aGraphicSize;
}
catch (css::beans::UnknownPropertyException& )
{}
if ( bGotSizePixel && pChartWindow )
{
::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height )));
aGraphicSize.Width = aVCLSize.getWidth();
aGraphicSize.Height = aVCLSize.getHeight();
}
}
xGraphicShape->setSize( aGraphicSize );
xGraphicShape->setPosition( awt::Point( 0, 0 ) );