chart2/source/controller/main/ChartController_Tools.cxx | 45 ++++++---------- 1 file changed, 19 insertions(+), 26 deletions(-)
New commits: commit 2678e4467f2d7d193b93e4cdd1b96b12d3ff53f1 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Jan 2 14:13:06 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jan 3 06:49:46 2022 +0100 use more SvxShape in chart2 Change-Id: Iedc03bd4e55ecb35012432c774a7510957c22333 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127871 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 0515bc84ccb7..27454b66ae70 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -69,6 +69,7 @@ #include <svx/svdundo.hxx> #include <svx/unoapi.hxx> #include <svx/unopage.hxx> +#include <svx/unoshape.hxx> #include <svx/xgrad.hxx> #include <svx/xflgrit.hxx> #include <PropertyHelper.hxx> @@ -350,12 +351,8 @@ void ChartController::impl_PasteGraphic( DrawModelWrapper * pDrawModelWrapper( GetDrawModelWrapper()); if( ! (xGraphic.is() && xModelProp.is())) return; - uno::Reference< lang::XMultiServiceFactory > xFact( pDrawModelWrapper->getShapeFactory()); - uno::Reference< drawing::XShape > xGraphicShape( - xFact->createInstance( "com.sun.star.drawing.GraphicObjectShape" ), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xGraphicShapeProp( xGraphicShape, uno::UNO_QUERY ); - if( !(xGraphicShapeProp.is() && xGraphicShape.is())) - return; + rtl::Reference<SvxGraphicObject> xGraphicShape = new SvxGraphicObject(nullptr); + xGraphicShape->setShapeKind(OBJ_GRAF); uno::Reference< drawing::XShapes > xPage = pDrawModelWrapper->getMainDrawPage(); if( xPage.is()) @@ -371,14 +368,13 @@ void ChartController::impl_PasteGraphic( m_aSelection.setSelection( xGraphicShape ); m_aSelection.applySelection( m_pDrawViewWrapper.get() ); } - xGraphicShapeProp->setPropertyValue( "Graphic", uno::Any( xGraphic )); - uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY ); + xGraphicShape->SvxShape::setPropertyValue( "Graphic", uno::Any( xGraphic )); awt::Size aGraphicSize( 1000, 1000 ); auto pChartWindow(GetChartWindow()); // first try size in 100th mm, then pixel size - if( ! ( xGraphicProp->getPropertyValue( "Size100thMM") >>= aGraphicSize ) && - ( ( xGraphicProp->getPropertyValue( "SizePixel") >>= aGraphicSize ) && pChartWindow )) + if( ! ( xGraphicShape->SvxShape::getPropertyValue( "Size100thMM") >>= aGraphicSize ) && + ( ( xGraphicShape->SvxShape::getPropertyValue( "SizePixel") >>= aGraphicSize ) && pChartWindow )) { ::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height ))); aGraphicSize.Width = aVCLSize.getWidth(); @@ -449,32 +445,29 @@ void ChartController::impl_PasteStringAsTextShape( const OUString& rString, cons if ( !(pDrawModelWrapper && m_pDrawViewWrapper) ) return; - const Reference< lang::XMultiServiceFactory >& xShapeFactory( pDrawModelWrapper->getShapeFactory() ); const Reference< drawing::XDrawPage >& xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - OSL_ASSERT( xShapeFactory.is() && xDrawPage.is() ); + OSL_ASSERT( xDrawPage.is() ); - if ( !(xShapeFactory.is() && xDrawPage.is()) ) + if ( !xDrawPage ) return; try { - Reference< drawing::XShape > xTextShape( - xShapeFactory->createInstance( "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY_THROW ); + rtl::Reference<SvxShapeText> xTextShape = new SvxShapeText(nullptr); + xTextShape->setShapeKind(OBJ_TEXT); xDrawPage->add( xTextShape ); - Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW ); - xRange->setString( rString ); + xTextShape->setString( rString ); float fCharHeight = 10.0; - Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW ); - xProperties->setPropertyValue( "TextAutoGrowHeight", uno::Any( true ) ); - xProperties->setPropertyValue( "TextAutoGrowWidth", uno::Any( true ) ); - xProperties->setPropertyValue( "CharHeight", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "CharHeightAsian", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "CharHeightComplex", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "TextVerticalAdjust", uno::Any( drawing::TextVerticalAdjust_CENTER ) ); - xProperties->setPropertyValue( "TextHorizontalAdjust", uno::Any( drawing::TextHorizontalAdjust_CENTER ) ); - xProperties->setPropertyValue( "CharFontName", uno::Any( OUString("Albany") ) ); + xTextShape->SvxShape::setPropertyValue( "TextAutoGrowHeight", uno::Any( true ) ); + xTextShape->SvxShape::setPropertyValue( "TextAutoGrowWidth", uno::Any( true ) ); + xTextShape->SvxShape::setPropertyValue( "CharHeight", uno::Any( fCharHeight ) ); + xTextShape->SvxShape::setPropertyValue( "CharHeightAsian", uno::Any( fCharHeight ) ); + xTextShape->SvxShape::setPropertyValue( "CharHeightComplex", uno::Any( fCharHeight ) ); + xTextShape->SvxShape::setPropertyValue( "TextVerticalAdjust", uno::Any( drawing::TextVerticalAdjust_CENTER ) ); + xTextShape->SvxShape::setPropertyValue( "TextHorizontalAdjust", uno::Any( drawing::TextHorizontalAdjust_CENTER ) ); + xTextShape->SvxShape::setPropertyValue( "CharFontName", uno::Any( OUString("Albany") ) ); xTextShape->setPosition( rPosition );