chart2/source/view/axes/VCoordinateSystem.cxx | 7 +--- chart2/source/view/diagram/VDiagram.cxx | 44 +++++++++++--------------- chart2/source/view/inc/ShapeFactory.hxx | 2 - chart2/source/view/main/PlotterBase.cxx | 2 - chart2/source/view/main/ShapeFactory.cxx | 36 +++++++-------------- include/svx/unoshape.hxx | 2 - 6 files changed, 39 insertions(+), 54 deletions(-)
New commits: commit 66a4ac244220add87f6972ab9961c3de8ce37ea2 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Wed Dec 29 22:38:17 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Dec 30 13:05:56 2021 +0100 use concrete types in chart2, Svx3DSceneObject Change-Id: Ic1cdc8a4efbb91bfabe84c32b703cb4868cd31a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127727 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index 98d819e56164..4ae45fd7c549 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -93,7 +93,6 @@ void VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); //create group shape for grids first thus axes are always painted above grids - ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); if(nDimensionCount==2) { //create and add to target @@ -104,9 +103,9 @@ void VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes else { //create and added to target - m_xLogicTargetForGrids = pShapeFactory->createGroup3D( xLogicTarget ); - xLogicTargetForSeriesBehindAxis = pShapeFactory->createGroup3D( xLogicTarget ); - m_xLogicTargetForAxes = pShapeFactory->createGroup3D( xLogicTarget ); + m_xLogicTargetForGrids = ShapeFactory::createGroup3D( xLogicTarget ); + xLogicTargetForSeriesBehindAxis = ShapeFactory::createGroup3D( xLogicTarget ); + m_xLogicTargetForAxes = ShapeFactory::createGroup3D( xLogicTarget ); } m_xFinalTarget = xFinalTarget; m_xShapeFactory = xShapeFactory; diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index b00a0e4f36ef..d229ffefcd80 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -449,12 +449,13 @@ void VDiagram::createShapes_3d() return; //create shape - m_xOuterGroupShape.set( m_pShapeFactory->createGroup3D( m_xTarget, "PlotAreaExcludingAxes" ), uno::UNO_QUERY); + rtl::Reference<Svx3DSceneObject> xShapes = ShapeFactory::createGroup3D( m_xTarget, "PlotAreaExcludingAxes" ); + m_xOuterGroupShape.set( static_cast<cppu::OWeakObject*>(xShapes.get()), uno::UNO_QUERY); uno::Reference< drawing::XShapes > xOuterGroup_Shapes( m_xOuterGroupShape, uno::UNO_QUERY ); //create additional group to manipulate the aspect ratio of the whole diagram: - xOuterGroup_Shapes = m_pShapeFactory->createGroup3D( xOuterGroup_Shapes ); + xOuterGroup_Shapes = ShapeFactory::createGroup3D( xOuterGroup_Shapes ); m_xAspectRatio3D.set( xOuterGroup_Shapes, uno::UNO_QUERY ); @@ -471,7 +472,7 @@ void VDiagram::createShapes_3d() OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, u"" ) );//@todo read CID from model if( !bAddFloorAndWall ) aWallCID.clear(); - uno::Reference< drawing::XShapes > xWallGroup_Shapes( m_pShapeFactory->createGroup3D( xOuterGroup_Shapes, aWallCID ) ); + rtl::Reference<Svx3DSceneObject> xWallGroup_Shapes = ShapeFactory::createGroup3D( xOuterGroup_Shapes, aWallCID ); CuboidPlanePosition eLeftWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) ); CuboidPlanePosition eBackWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) ); @@ -617,31 +618,26 @@ void VDiagram::createShapes_3d() //create an additional scene for the smaller inner coordinate region: { - uno::Reference< drawing::XShapes > xShapes = m_pShapeFactory->createGroup3D( xOuterGroup_Shapes,"testonly;CooContainer=XXX_CID" ); - m_xCoordinateRegionShape.set( xShapes, uno::UNO_QUERY ); + rtl::Reference<Svx3DSceneObject> xShapes2 = ShapeFactory::createGroup3D( xOuterGroup_Shapes,"testonly;CooContainer=XXX_CID" ); + m_xCoordinateRegionShape.set( static_cast<cppu::OWeakObject*>(xShapes2.get()), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xShapeProp( m_xCoordinateRegionShape, uno::UNO_QUERY ); - OSL_ENSURE(xShapeProp.is(), "created shape offers no XPropertySet"); - if( xShapeProp.is()) + try { - try - { - double fXScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME; - double fYScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME; - double fZScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME; + double fXScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME; + double fYScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME; + double fZScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME; - ::basegfx::B3DHomMatrix aM; - aM.translate(GRID_TO_WALL_DISTANCE/fXScale, GRID_TO_WALL_DISTANCE/fYScale, GRID_TO_WALL_DISTANCE/fZScale); - aM.scale( fXScale, fYScale, fZScale ); - E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); + ::basegfx::B3DHomMatrix aM; + aM.translate(GRID_TO_WALL_DISTANCE/fXScale, GRID_TO_WALL_DISTANCE/fYScale, GRID_TO_WALL_DISTANCE/fZScale); + aM.scale( fXScale, fYScale, fZScale ); + E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); - xShapeProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX - , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aM)) ); - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } + xShapes2->SvxShape::setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX + , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aM)) ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index ca94c3da1293..e01b4cdc2e68 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -85,7 +85,7 @@ public: const css::uno::Reference< css::drawing::XShapes >& xTarget , const OUString& aName = OUString() ); - css::uno::Reference< css::drawing::XShapes > + static rtl::Reference<Svx3DSceneObject> createGroup3D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const OUString& aName = OUString() ); diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx index c0d26dbdc8b5..382d3fa7a18a 100644 --- a/chart2/source/view/main/PlotterBase.cxx +++ b/chart2/source/view/main/PlotterBase.cxx @@ -87,7 +87,7 @@ uno::Reference< drawing::XShapes > PlotterBase::createGroupShape( else { //create and added to target - return m_pShapeFactory->createGroup3D( xTarget, rName ); + return ShapeFactory::createGroup3D( xTarget, rName ); } } diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 0e20f17cc975..14ac22fece68 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -1759,7 +1759,7 @@ rtl::Reference< SvxShapeGroup > return nullptr; } -uno::Reference< drawing::XShapes > +rtl::Reference<Svx3DSceneObject> ShapeFactory::createGroup3D( const uno::Reference< drawing::XShapes >& xTarget , const OUString& aName ) { @@ -1768,32 +1768,23 @@ uno::Reference< drawing::XShapes > try { //create shape - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.Shape3DSceneObject" ), uno::UNO_QUERY ); - + rtl::Reference<Svx3DSceneObject> xShape = new Svx3DSceneObject(nullptr, nullptr); + xShape->setShapeKind(E3D_SCENE_ID | E3D_INVENTOR_FLAG); xTarget->add(xShape); //it is necessary to set the transform matrix to initialize the scene properly //otherwise all objects which are placed into this Group will not be visible //the following should be unnecessary after the bug is fixed + //set properties + try { - //set properties - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet"); - if( xProp.is()) - { - try - { - ::basegfx::B3DHomMatrix aM; - xProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX - , uno::Any(B3DHomMatrixToHomogenMatrix(aM)) ); - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } - } + ::basegfx::B3DHomMatrix aM; + xShape->SvxShape::setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX + , uno::Any(B3DHomMatrixToHomogenMatrix(aM)) ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } //set name @@ -1801,8 +1792,7 @@ uno::Reference< drawing::XShapes > setShapeName( xShape , aName ); //return - uno::Reference< drawing::XShapes > xShapes( xShape, uno::UNO_QUERY ); - return xShapes; + return xShape; } catch( const uno::Exception& ) { diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx index 68430160871a..1112cf5e044e 100644 --- a/include/svx/unoshape.hxx +++ b/include/svx/unoshape.hxx @@ -662,7 +662,7 @@ protected: using SvxShape::getPropertyValue; public: - Svx3DSceneObject(SdrObject* pObj, SvxDrawPage* pDrawPage); + SVXCORE_DLLPUBLIC Svx3DSceneObject(SdrObject* pObj, SvxDrawPage* pDrawPage); // override these for special property handling in subcasses. Return true if property is handled virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) override; virtual bool getPropertyValueImpl(const OUString& rName, const SfxItemPropertyMapEntry* pProperty,