diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2018-08-11 08:28:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-11 11:49:39 +0200 |
commit | d99af1a67cbe4e23661467843e7d72194b45b313 (patch) | |
tree | 76b39523a6ccbacf9c4e68f810981ecf49e8b45a /chart2 | |
parent | b26f83b1cc184a79caa9e9c0ae15717ef61dde4a (diff) |
loplugin:mergeclasses AbstractShapeFactory into ShapeFactory
Change-Id: I9cc607bcc84a14ffdbe22bdbe1a038f5b22b719a
Reviewed-on: https://gerrit.libreoffice.org/58871
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
32 files changed, 500 insertions, 762 deletions
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk index bed8c218d79b..c23c4a046f3a 100644 --- a/chart2/Library_chartcore.mk +++ b/chart2/Library_chartcore.mk @@ -108,7 +108,6 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\ chart2/source/view/main/PolarLabelPositionHelper \ chart2/source/view/main/PropertyMapper \ chart2/source/view/main/ShapeFactory \ - chart2/source/view/main/AbstractShapeFactory \ chart2/source/view/main/Stripe \ chart2/source/view/main/VDataSeries \ chart2/source/view/main/VLegend \ diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index f88a45fe56dc..1ef31cae6664 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -19,7 +19,7 @@ #include "VCartesianAxis.hxx" #include <PlottingPositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <CommonConverters.hxx> #include <ViewDefines.hxx> #include <PropertyMapper.hxx> @@ -93,7 +93,7 @@ void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape > const sal_Int32 nMaxLabelsHeight = nFullHeight - rAxisLabelProperties.m_aMaximumSpaceForLabels.Height - rAxisLabelProperties.m_aMaximumSpaceForLabels.Y; const sal_Int32 nAvgCharWidth = xShape2DText->getSize().Width / rLabel.getLength(); - const sal_Int32 nTextSize = AbstractShapeFactory::getSizeAfterRotation( xShape2DText, + const sal_Int32 nTextSize = ShapeFactory::getSizeAfterRotation( xShape2DText, rAxisLabelProperties.fRotationAngleDegree ).Height; if( !nAvgCharWidth ) @@ -138,10 +138,10 @@ Reference< drawing::XShape > createSingleLabel( // #i78696# use mathematically correct rotation now const double fRotationAnglePi(-basegfx::deg2rad(rAxisLabelProperties.fRotationAngleDegree)); - uno::Any aATransformation = AbstractShapeFactory::makeTransformation( rAnchorScreenPosition2D, fRotationAnglePi ); - OUString aLabel = AbstractShapeFactory::getStackedString( rLabel, rAxisLabelProperties.bStackCharacters ); + uno::Any aATransformation = ShapeFactory::makeTransformation( rAnchorScreenPosition2D, fRotationAnglePi ); + OUString aLabel = ShapeFactory::getStackedString( rLabel, rAxisLabelProperties.bStackCharacters ); - Reference< drawing::XShape > xShape2DText = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory) + Reference< drawing::XShape > xShape2DText = ShapeFactory::getOrCreateShapeFactory(xShapeFactory) ->createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation ); if( rAxisProperties.m_bLimitSpaceForLabels ) @@ -160,7 +160,7 @@ bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShap if(!xShape.is()) return false; - ::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(),AbstractShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree )); + ::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(), ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree )); basegfx::B2IVector aPosition( static_cast<sal_Int32>( rTickScreenPosition.getX() ) @@ -331,7 +331,7 @@ B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTick xShape2DText = pTickInfo->xTextShape; if( xShape2DText.is() ) { - awt::Size aSize = AbstractShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree ); + awt::Size aSize = ShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree ); if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY())) nDistance = std::max(nDistance,aSize.Width); else @@ -1714,7 +1714,7 @@ void VCartesianAxis::updatePositions() // #i78696# use mathematically correct rotation now const double fRotationAnglePi(-basegfx::deg2rad(fRotationAngleDegree)); - uno::Any aATransformation = AbstractShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi); + uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi); //set new position uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY ); @@ -1848,7 +1848,7 @@ void VCartesianAxis::createShapes() m_xGroupShape_Shapes, aPoints , &m_aAxisProperties.m_aLineProperties ); //because of this name this line will be used for marking the axis - ::chart::AbstractShapeFactory::setShapeName( xShape, "MarkHandles" ); + ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" ); } //create an additional line at NULL if( !AxisHelper::isAxisPositioningEnabled() ) diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index e56608fd0b5c..2ce8066b014f 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -272,7 +272,7 @@ void VCartesianGrid::createShapes() aHandleLineProperties.LineStyle <<= drawing::LineStyle_NONE; Reference< drawing::XShape > xHandleShape = m_pShapeFactory->createLine2D( xTarget, aHandlesPoints, &aHandleLineProperties ); - ::chart::AbstractShapeFactory::setShapeName( xHandleShape, "HandlesOnly" ); + ::chart::ShapeFactory::setShapeName( xHandleShape, "HandlesOnly" ); } else //if(2!=m_nDimension) { diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index c7fedfd8c80b..b6446e3462c1 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -23,7 +23,7 @@ #include "VPolarCoordinateSystem.hxx" #include <ScaleAutomatism.hxx> #include <VSeriesPlotter.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <servicenames_coosystems.hxx> #include <AxisIndexDefines.hxx> #include <ObjectIdentifier.hxx> @@ -107,7 +107,7 @@ 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 - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); if(nDimensionCount==2) { //create and add to target diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index bc13eb5830a9..3bfb7d6b5221 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -21,7 +21,7 @@ #include "VPolarAngleAxis.hxx" #include "VPolarGrid.hxx" -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <NumberFormatterWrapper.hxx> #include <PolarLabelPositionHelper.hxx> #include <tools/color.hxx> @@ -52,7 +52,7 @@ void VPolarAngleAxis::createTextShapes_ForAngleAxis( , double fLogicRadius , double fLogicZ ) { - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); FixedNumberFormatter aFixedNumberFormatter( m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey ); @@ -123,8 +123,8 @@ void VPolarAngleAxis::createTextShapes_ForAngleAxis( // #i78696# use mathematically correct rotation now const double fRotationAnglePi(-basegfx::deg2rad(rAxisLabelProperties.fRotationAngleDegree)); - uno::Any aATransformation = AbstractShapeFactory::makeTransformation( aAnchorScreenPosition2D, fRotationAnglePi ); - OUString aStackedLabel = AbstractShapeFactory::getStackedString( aLabel, rAxisLabelProperties.bStackCharacters ); + uno::Any aATransformation = ShapeFactory::makeTransformation( aAnchorScreenPosition2D, fRotationAnglePi ); + OUString aStackedLabel = ShapeFactory::getStackedString( aLabel, rAxisLabelProperties.bStackCharacters ); pTickInfo->xTextShape = pShapeFactory->createText( xTarget, aStackedLabel, aPropNames, aPropValues, aATransformation ); } @@ -198,7 +198,7 @@ void VPolarAngleAxis::createShapes() uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties ); //because of this name this line will be used for marking the axis - ::chart::AbstractShapeFactory::setShapeName( xShape, "MarkHandles" ); + ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" ); //create labels createLabels(); diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index ac829ad92b0d..f77b02a792eb 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -205,7 +205,7 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( xTarget, aAllPoints, &rLinePropertiesList[nDepth] ); //because of this name this line will be used for marking - ::chart::AbstractShapeFactory::setShapeName( xShape, "MarkHandles" ); + ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" ); } } diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 5b94b31acedb..4c3726b9bbe0 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -19,7 +19,7 @@ #include "AreaChart.hxx" #include <PlottingPositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <CommonConverters.hxx> #include <ExplicitCategoriesProvider.hxx> #include <ViewDefines.hxx> @@ -406,7 +406,7 @@ bool AreaChart::impl_createLine( VDataSeries* pSeries Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly ); } - if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly)) + if(!ShapeFactory::hasPolygonAnyLines(aPoly)) return false; //transformation 3) -> 4) @@ -448,7 +448,7 @@ bool AreaChart::impl_createLine( VDataSeries* pSeries , pSeries->getPropertiesOfSeries() , PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); //because of this name this line will be used for marking - ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles"); + ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles"); } return true; } @@ -492,17 +492,17 @@ bool AreaChart::impl_createArea( VDataSeries* pSeries { appendPoly( aPoly, *pPreviousSeriesPoly ); } - AbstractShapeFactory::closePolygon(aPoly); + ShapeFactory::closePolygon(aPoly); //apply clipping { drawing::PolyPolygonShape3D aClippedPoly; Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false ); - AbstractShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping + ShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping aPoly = aClippedPoly; } - if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly)) + if(!ShapeFactory::hasPolygonAnyLines(aPoly)) return false; //transformation 3) -> 4) @@ -524,7 +524,7 @@ bool AreaChart::impl_createArea( VDataSeries* pSeries , pSeries->getPropertiesOfSeries() , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); //because of this name this line will be used for marking - ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles"); + ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles"); return true; } diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index ce25ee3b359f..eff88ac355b7 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -19,7 +19,7 @@ #include "BubbleChart.hxx" #include <PlottingPositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <CommonConverters.hxx> #include <ViewDefines.hxx> #include <ObjectIdentifier.hxx> @@ -304,7 +304,7 @@ void BubbleChart::createShapes() } } - ::chart::AbstractShapeFactory::setShapeName( xShape, "MarkHandles" ); + ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" ); //create data point label if( pSeries->getDataPointLabelIfLabel(nIndex) ) diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index d4fe9c4eeb08..d94453ea5e3f 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -19,7 +19,7 @@ #include "NetChart.hxx" #include <PlottingPositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <ExplicitCategoriesProvider.hxx> #include <CommonConverters.hxx> #include <ViewDefines.hxx> @@ -127,7 +127,7 @@ bool NetChart::impl_createLine( VDataSeries* pSeries drawing::PolyPolygonShape3D aPoly; { bool bIsClipped = false; - if( !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) ) + if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) ) { // do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP double fFirstY = pSeries->getYValue( 0 ); @@ -150,7 +150,7 @@ bool NetChart::impl_createLine( VDataSeries* pSeries Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly ); } - if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly)) + if(!ShapeFactory::hasPolygonAnyLines(aPoly)) return false; //transformation 3) -> 4) @@ -165,7 +165,7 @@ bool NetChart::impl_createLine( VDataSeries* pSeries , pSeries->getPropertiesOfSeries() , PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); //because of this name this line will be used for marking - ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles"); + ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles"); } return true; } @@ -182,7 +182,7 @@ bool NetChart::impl_createArea( VDataSeries* pSeries drawing::PolyPolygonShape3D aPoly( *pSeriesPoly ); //add second part to the polygon (grounding points or previous series points) - if( !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) ) + if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) ) { if( pPreviousSeriesPoly ) addPolygon( aPoly, *pPreviousSeriesPoly ); @@ -212,17 +212,17 @@ bool NetChart::impl_createArea( VDataSeries* pSeries { appendPoly( aPoly, *pPreviousSeriesPoly ); } - AbstractShapeFactory::closePolygon(aPoly); + ShapeFactory::closePolygon(aPoly); //apply clipping { drawing::PolyPolygonShape3D aClippedPoly; Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false ); - AbstractShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping + ShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping aPoly = aClippedPoly; } - if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly)) + if(!ShapeFactory::hasPolygonAnyLines(aPoly)) return false; //transformation 3) -> 4) @@ -236,7 +236,7 @@ bool NetChart::impl_createArea( VDataSeries* pSeries , pSeries->getPropertiesOfSeries() , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); //because of this name this line will be used for marking - ::chart::AbstractShapeFactory::setShapeName(xShape, "MarkHandles"); + ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles"); return true; } diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 06e70c59180f..b5737f80055b 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -21,7 +21,7 @@ #include <VLineProperties.hxx> #include "PieChart.hxx" #include <PlottingPositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <PolarLabelPositionHelper.hxx> #include <CommonConverters.hxx> #include <ViewDefines.hxx> @@ -687,7 +687,7 @@ void PieChart::createShapes() if(!bDoExplode) { - AbstractShapeFactory::setShapeName( xPointShape + ShapeFactory::setShapeName( xPointShape , ObjectIdentifier::createPointCID( pSeries->getPointCID_Stub(), nPointIndex ) ); } else try @@ -714,7 +714,7 @@ void PieChart::createShapes() nOffsetPercent, aMinimumPosition, aMaximumPosition ) ) ); - AbstractShapeFactory::setShapeName( xPointShape + ShapeFactory::setShapeName( xPointShape , ObjectIdentifier::createPointCID( aPointCIDStub, nPointIndex ) ); } catch( const uno::Exception& e ) diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index a52911ee76da..ce592dcc89eb 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -20,7 +20,7 @@ #include <memory> #include <VSeriesPlotter.hxx> #include <VLineProperties.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <chartview/ExplicitValueProvider.hxx> #include <svl/zformat.hxx> @@ -633,9 +633,9 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re (*pPropValues)[ nProperties ] <<= style::ParagraphAdjust_CENTER; // create text shape - xTextShape = AbstractShapeFactory::getOrCreateShapeFactory( m_xShapeFactory )-> + xTextShape = ShapeFactory::getOrCreateShapeFactory( m_xShapeFactory )-> createText( xTarget_, aFormattedLabels, *pPropNames, *pPropValues, - AbstractShapeFactory::makeTransformation( aScreenPosition2D ) ); + ShapeFactory::makeTransformation( aScreenPosition2D ) ); } else if( bMultiLineLabel ) { @@ -655,9 +655,9 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re aParaPropValues[2][0] <<= style::ParagraphAdjust_CENTER; //create text shape - xTextShape = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory)-> + xTextShape = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory)-> createText( xTarget_, aTextList, aParaPropNames, aParaPropValues - , *pPropNames, *pPropValues, AbstractShapeFactory::makeTransformation( aScreenPosition2D ) ); + , *pPropNames, *pPropValues, ShapeFactory::makeTransformation( aScreenPosition2D ) ); } else { @@ -676,9 +676,9 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re } //create text shape - xTextShape = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory)-> + xTextShape = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory)-> createText( xTarget_, aText.makeStringAndClear() - , *pPropNames, *pPropValues, AbstractShapeFactory::makeTransformation( aScreenPosition2D ) ); + , *pPropNames, *pPropValues, ShapeFactory::makeTransformation( aScreenPosition2D ) ); } if( !xTextShape.is() ) @@ -727,7 +727,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re const double fDegreesPi( -basegfx::deg2rad(fRotationDegrees) ); uno::Reference< beans::XPropertySet > xProp( xTextShape, uno::UNO_QUERY ); if( xProp.is() ) - xProp->setPropertyValue( "Transformation", AbstractShapeFactory::makeTransformation( aScreenPosition2D, fDegreesPi ) ); + xProp->setPropertyValue( "Transformation", ShapeFactory::makeTransformation( aScreenPosition2D, fDegreesPi ) ); LabelPositionHelper::correctPositionForRotation( xTextShape, eAlignment, fRotationDegrees, true /*bRotateAroundCenter*/ ); } @@ -1262,7 +1262,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer createGroupShape( xTarget, rVDataSeries.getDataCurveCID( nN, bAverageLine ) ); uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( xRegressionGroupShapes, PolyToPointSequence( aRegressionPoly ), &aVLineProperties ); - AbstractShapeFactory::setShapeName( xShape, "MarkHandles" ); + ShapeFactory::setShapeName( xShape, "MarkHandles" ); aDefaultPos = xShape->getPosition(); } @@ -1400,12 +1400,12 @@ void VSeriesPlotter::createRegressionCurveEquationShapes( uno::Reference< drawing::XShape > xTextShape = m_pShapeFactory->createText( xEquationTarget, aFormula.makeStringAndClear(), - aNames, aValues, AbstractShapeFactory::makeTransformation( aScreenPosition2D )); + aNames, aValues, ShapeFactory::makeTransformation( aScreenPosition2D )); OSL_ASSERT( xTextShape.is()); if( xTextShape.is()) { - AbstractShapeFactory::setShapeName( xTextShape, rEquationCID ); + ShapeFactory::setShapeName( xTextShape, rEquationCID ); awt::Size aSize( xTextShape->getSize() ); awt::Point aPos( RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( aScreenPosition2D, aSize, aRelativePosition.Anchor ) ); @@ -2475,7 +2475,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( for( sal_Int32 nIdx=0; nIdx<aCategoryNames.getLength(); ++nIdx ) { // symbol - uno::Reference< drawing::XShapes > xSymbolGroup( AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createGroup2D( xTarget )); + uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createGroup2D( xTarget )); // create the symbol Reference< drawing::XShape > xShape( createLegendSymbolForPoint( rEntryKeyAspectRatio, @@ -2489,7 +2489,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( OUString aChildParticle( ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_DATA_POINT, nIdx ) ); aChildParticle = ObjectIdentifier::addChildParticle( aChildParticle, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_LEGEND_ENTRY, 0 ) ); OUString aCID = ObjectIdentifier::createClassifiedIdentifierForParticles( rSeries.getSeriesParticle(), aChildParticle ); - AbstractShapeFactory::setShapeName( xShape, aCID ); + ShapeFactory::setShapeName( xShape, aCID ); } // label @@ -2504,7 +2504,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( else { // symbol - uno::Reference< drawing::XShapes > xSymbolGroup( AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createGroup2D( xTarget )); + uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createGroup2D( xTarget )); // create the symbol Reference< drawing::XShape > xShape( createLegendSymbolForSeries( @@ -2517,7 +2517,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( OUString aChildParticle( ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_LEGEND_ENTRY, 0 ) ); OUString aCID = ObjectIdentifier::createClassifiedIdentifierForParticles( rSeries.getSeriesParticle(), aChildParticle ); - AbstractShapeFactory::setShapeName( xShape, aCID ); + ShapeFactory::setShapeName( xShape, aCID ); } // label @@ -2547,7 +2547,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( xContext, aResStr, xTextProperties ); // symbol - uno::Reference< drawing::XShapes > xSymbolGroup( AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createGroup2D( xTarget )); + uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createGroup2D( xTarget )); // create the symbol Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio, @@ -2565,7 +2565,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( OUString aChildParticle( ObjectIdentifier::createChildParticleWithIndex( eObjectType, i ) ); aChildParticle = ObjectIdentifier::addChildParticle( aChildParticle, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_LEGEND_ENTRY, 0 ) ); OUString aCID = ObjectIdentifier::createClassifiedIdentifierForParticles( rSeries.getSeriesParticle(), aChildParticle ); - AbstractShapeFactory::setShapeName( xShape, aCID ); + ShapeFactory::setShapeName( xShape, aCID ); } aResult.push_back(aEntry); diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index bdebf2516703..f751469d19b9 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <VDiagram.hxx> #include <PropertyMapper.hxx> #include <ViewDefines.hxx> @@ -94,7 +94,7 @@ void VDiagram::init( m_xTarget = xTarget; m_xShapeFactory = xFactory; - m_pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xFactory); + m_pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xFactory); } void VDiagram::createShapes( const awt::Point& rPos, const awt::Size& rSize ) @@ -131,10 +131,10 @@ void VDiagram::createShapes( const awt::Point& rPos, const awt::Size& rSize ) //do not change aspect ratio awt::Size aAspectRatio( static_cast<sal_Int32>(m_aPreferredAspectRatio.DirectionX*FIXED_SIZE_FOR_3D_CHART_VOLUME), static_cast<sal_Int32>(m_aPreferredAspectRatio.DirectionY*FIXED_SIZE_FOR_3D_CHART_VOLUME )); - m_aCurrentSizeWithoutAxes = awt::Size( AbstractShapeFactory::calculateNewSizeRespectingAspectRatio( + m_aCurrentSizeWithoutAxes = awt::Size( ShapeFactory::calculateNewSizeRespectingAspectRatio( rAvailableSize, aAspectRatio ) ); //center diagram position - m_aCurrentPosWithoutAxes = awt::Point( AbstractShapeFactory::calculateTopLeftPositionToCenterObject( + m_aCurrentPosWithoutAxes = awt::Point( ShapeFactory::calculateTopLeftPositionToCenterObject( rPos, rAvailableSize, m_aCurrentSizeWithoutAxes ) ); } @@ -170,7 +170,7 @@ void VDiagram::createShapes_2d() //add back wall { - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); m_xWall2D = pShapeFactory->createRectangle( xGroupForWall ); @@ -190,7 +190,7 @@ void VDiagram::createShapes_2d() { //we always need this object as dummy object for correct scene dimensions //but it should not be visible in this case: - AbstractShapeFactory::makeShapeInvisible( m_xWall2D ); + ShapeFactory::makeShapeInvisible( m_xWall2D ); } else { @@ -455,12 +455,12 @@ void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize ) adjustAspectRatio3d( rAvailableSize ); //do not change aspect ratio of 3D scene with 2D bound rect - m_aCurrentSizeWithoutAxes = AbstractShapeFactory::calculateNewSizeRespectingAspectRatio( + m_aCurrentSizeWithoutAxes = ShapeFactory::calculateNewSizeRespectingAspectRatio( rAvailableSize, m_xOuterGroupShape->getSize() ); m_xOuterGroupShape->setSize( m_aCurrentSizeWithoutAxes ); //center diagram position - m_aCurrentPosWithoutAxes= AbstractShapeFactory::calculateTopLeftPositionToCenterObject( + m_aCurrentPosWithoutAxes= ShapeFactory::calculateTopLeftPositionToCenterObject( rPos, rAvailableSize, m_aCurrentSizeWithoutAxes ); m_xOuterGroupShape->setPosition(m_aCurrentPosWithoutAxes); @@ -527,7 +527,7 @@ void VDiagram::createShapes_3d() { //we always need this object as dummy object for correct scene dimensions //but it should not be visible in this case: - AbstractShapeFactory::makeShapeInvisible( xShape ); + ShapeFactory::makeShapeInvisible( xShape ); } } //add back wall @@ -555,7 +555,7 @@ void VDiagram::createShapes_3d() { //we always need this object as dummy object for correct scene dimensions //but it should not be visible in this case: - AbstractShapeFactory::makeShapeInvisible( xShape ); + ShapeFactory::makeShapeInvisible( xShape ); } } } @@ -632,12 +632,12 @@ void VDiagram::createShapes_3d() { //we always need this object as dummy object for correct scene dimensions //but it should not be visible in this case: - AbstractShapeFactory::makeShapeInvisible( xShape ); + ShapeFactory::makeShapeInvisible( xShape ); } else { OUString aFloorCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_FLOOR, OUString() ) );//@todo read CID from model - AbstractShapeFactory::setShapeName( xShape, aFloorCID ); + ShapeFactory::setShapeName( xShape, aFloorCID ); } } diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx deleted file mode 100644 index 5aa0d9bfeb68..000000000000 --- a/chart2/source/view/inc/AbstractShapeFactory.hxx +++ /dev/null @@ -1,283 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_ABSTRACTSHAPEFACTORY_HXX -#define INCLUDED_CHART2_SOURCE_VIEW_INC_ABSTRACTSHAPEFACTORY_HXX - -#include "PropertyMapper.hxx" -#include <basegfx/range/b2irectangle.hxx> -#include <com/sun/star/awt/Size.hpp> -#include <com/sun/star/awt/Point.hpp> -#include <com/sun/star/drawing/PointSequenceSequence.hpp> - -#include <rtl/ustring.hxx> - -namespace chart { struct VLineProperties; } -namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } -namespace com { namespace sun { namespace star { namespace chart2 { class XFormattedString; } } } } -namespace com { namespace sun { namespace star { namespace drawing { class XDrawPage; } } } } -namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } } -namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } } } } -namespace com { namespace sun { namespace star { namespace drawing { struct HomogenMatrix; } } } } -namespace com { namespace sun { namespace star { namespace drawing { struct PolyPolygonShape3D; } } } } -namespace com { namespace sun { namespace star { namespace drawing { struct Position3D; } } } } -namespace com { namespace sun { namespace star { namespace graphic { class XGraphic; } } } } -namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } } -namespace com { namespace sun { namespace star { namespace drawing { struct Direction3D; } } } } - -namespace chart { - -// Be careful here not to clash with the SYMBOL_FOO #defines in -// <vcl/vclenum.hxx> -enum SymbolEnum { Symbol_Square=0 - , Symbol_Diamond - , Symbol_DownArrow - , Symbol_UpArrow - , Symbol_RightArrow - , Symbol_LeftArrow - , Symbol_Bowtie - , Symbol_Sandglass - , Symbol_Circle - , Symbol_Star - , Symbol_X - , Symbol_Plus - , Symbol_Asterisk - , Symbol_HorizontalBar - , Symbol_VerticalBar - , Symbol_COUNT -}; - -class Stripe; - -class AbstractShapeFactory -{ -protected: - css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; - -public: - - enum StackPosition { Top, Bottom }; - - static AbstractShapeFactory* getOrCreateShapeFactory(const css::uno::Reference< css::lang::XMultiServiceFactory>& xFactory); - - virtual ~AbstractShapeFactory() {}; - - virtual css::uno::Reference< css::drawing::XShapes > - createGroup2D( - const css::uno::Reference< css::drawing::XShapes >& xTarget - , const OUString& aName = OUString() ) = 0; - - virtual css::uno::Reference< css::drawing::XShapes > - createGroup3D( - const css::uno::Reference< css::drawing::XShapes >& xTarget - , const OUString& aName = OUString() ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createCube( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPosition - , const css::drawing::Direction3D& rSize - , sal_Int32 nRotateZAngleHundredthDegree - , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp - , const tPropertyNameMap& rPropertyNameMap - , bool bRounded = false) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createCylinder( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPosition - , const css::drawing::Direction3D& rSize - , sal_Int32 nRotateZAngleHundredthDegree ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createPyramid( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPosition - , const css::drawing::Direction3D& rSize - , double fTopHeight - , bool bRotateZ - , const css::uno::Reference< - css::beans::XPropertySet >& xSourceProp - , const tPropertyNameMap& rPropertyNameMap) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createCone( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPosition - , const css::drawing::Direction3D& rSize - , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createPieSegment2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree - , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius - , const css::drawing::Direction3D& rOffset - , const css::drawing::HomogenMatrix& rUnitCircleToScene ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createPieSegment( const css::uno::Reference< css::drawing::XShapes >& xTarget - , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree - , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius - , const css::drawing::Direction3D& rOffset - , const css::drawing::HomogenMatrix& rUnitCircleToScene - , double fDepth ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createStripe( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const Stripe& rStripe - , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp - , const tPropertyNameMap& rPropertyNameMap - , bool bDoubleSided - , short nRotatedTexture = 0 //0 to 7 are the different possibilities - , bool bFlatNormals=true ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createArea3D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::PolyPolygonShape3D& rPolyPolygon - , double fDepth) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createArea2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::PolyPolygonShape3D& rPolyPolygon) = 0; - - static sal_Int32 getSymbolCount() { return Symbol_COUNT; } - - virtual css::uno::Reference< css::drawing::XShape > - createSymbol2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPos - , const css::drawing::Direction3D& rSize - , sal_Int32 nStandardSymbol - , sal_Int32 nBorderColor - , sal_Int32 nFillColor ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createGraphic2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPos - , const css::drawing::Direction3D& rSize - , const css::uno::Reference< css::graphic::XGraphic >& xGraphic ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createLine2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::PointSequenceSequence& rPoints - , const VLineProperties* pLineProperties = nullptr ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createLine ( const css::uno::Reference< css::drawing::XShapes >& xTarget, - const css::awt::Size& rSize, const css::awt::Point& rPosition ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createLine3D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::PolyPolygonShape3D& rPoints - , const VLineProperties& rLineProperties ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createCircle2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::Position3D& rPos - , const css::drawing::Direction3D& rSize ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createCircle( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::awt::Size& rSize - , const css::awt::Point& rPosition ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D - , const OUString& rText - , const tNameSequence& rPropNames - , const tAnySequence& rPropValues - , const css::uno::Any& rATransformation - ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createText( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::uno::Sequence< OUString >& rTextParagraphs - , const css::uno::Sequence< tNameSequence >& rParaPropNames - , const css::uno::Sequence< tAnySequence >& rParaPropValues - , const tNameSequence& rPropNames - , const tAnySequence& rPropValues - , const css::uno::Any& rATransformation ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createText(const css::uno::Reference< css::drawing::XShapes >& xTarget - , css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString - , const tNameSequence& rPropNames - , const tAnySequence& rPropValues - , const css::uno::Any& rATransformation) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D, - const css::awt::Size& rSize, - const css::awt::Point& rPosition, - css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString, - const css::uno::Reference< css::beans::XPropertySet > & xTextProperties, - double nRotation, const OUString& aName ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createInvisibleRectangle( - const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::awt::Size& rSize ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createRectangle( - const css::uno::Reference< css::drawing::XShapes >& xTarget, - const css::awt::Size& rSize, - const css::awt::Point& rPosition, - const tNameSequence& rPropNames, - const tAnySequence& rPropValues, - StackPosition ePos = Top ) = 0; - - virtual css::uno::Reference< css::drawing::XShape > - createRectangle( - const css::uno::Reference< css::drawing::XShapes >& xTarget ) = 0; - - virtual css::uno::Reference< css::drawing::XShapes > - getOrCreateChartRootShape( const css::uno::Reference< css::drawing::XDrawPage>& xPage ) = 0; - - virtual void setPageSize( css::uno::Reference < css::drawing::XShapes > xChartShapes, const css::awt::Size& rSize ) = 0; - - virtual void clearPage(css::uno::Reference< css::drawing::XShapes > xRootShape) = 0; - - static css::uno::Reference< css::drawing::XShapes > - getChartRootShape( const css::uno::Reference< css::drawing::XDrawPage>& xPage ); - - static void makeShapeInvisible( const css::uno::Reference< css::drawing::XShape >& xShape ); - - static void setShapeName( const css::uno::Reference< css::drawing::XShape >& xShape - , const OUString& rName ); - - static OUString getShapeName( const css::uno::Reference< css::drawing::XShape >& xShape ); - - static css::uno::Any makeTransformation( const css::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 ); - - static OUString getStackedString( const OUString& rString, bool bStacked ); - - static bool hasPolygonAnyLines( css::drawing::PolyPolygonShape3D& rPoly ); - static bool isPolygonEmptyOrSinglePoint( css::drawing::PolyPolygonShape3D& rPoly ); - static void closePolygon( css::drawing::PolyPolygonShape3D& rPoly ); - - static css::awt::Size calculateNewSizeRespectingAspectRatio( - const css::awt::Size& rTargetSize - , const css::awt::Size& rSourceSizeWithCorrectAspectRatio ); - - static css::awt::Point calculateTopLeftPositionToCenterObject( - const css::awt::Point& rTargetAreaPosition - , const css::awt::Size& rTargetAreaSize - , const css::awt::Size& rObjectSize ); - - static ::basegfx::B2IRectangle getRectangleOfShape( - const css::uno::Reference< css::drawing::XShape >& xShape ); - - static css::awt::Size getSizeAfterRotation( - const css::uno::Reference< css::drawing::XShape >& xShape, double fRotationAngleDegree ); - - static void removeSubShapes( const css::uno::Reference< css::drawing::XShapes >& xShapes ); - -}; - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/LabelPositionHelper.hxx b/chart2/source/view/inc/LabelPositionHelper.hxx index 48b5ab72c73a..6cf2876f766d 100644 --- a/chart2/source/view/inc/LabelPositionHelper.hxx +++ b/chart2/source/view/inc/LabelPositionHelper.hxx @@ -33,7 +33,7 @@ namespace chart { class PlottingPositionHelper; -class AbstractShapeFactory; +class ShapeFactory; class LabelPositionHelper { @@ -42,7 +42,7 @@ public: LabelPositionHelper( sal_Int32 nDimensionCount , const css::uno::Reference< css::drawing::XShapes >& xLogicTarget - , AbstractShapeFactory* pShapeFactory ); + , ShapeFactory* pShapeFactory ); virtual ~LabelPositionHelper(); css::awt::Point transformSceneToScreenPosition( @@ -62,7 +62,7 @@ protected: private: //these members are only necessary for transformation from 3D to 2D css::uno::Reference< css::drawing::XShapes > m_xLogicTarget; - AbstractShapeFactory* m_pShapeFactory; + ShapeFactory* m_pShapeFactory; }; } //namespace chart diff --git a/chart2/source/view/inc/PlotterBase.hxx b/chart2/source/view/inc/PlotterBase.hxx index 788992dc3de3..1ddea6f0396e 100644 --- a/chart2/source/view/inc/PlotterBase.hxx +++ b/chart2/source/view/inc/PlotterBase.hxx @@ -33,8 +33,8 @@ namespace chart { struct ExplicitScaleData; } namespace chart { -class AbstractShapeFactory; class PlottingPositionHelper; +class ShapeFactory; /** This class provides methods for setting axis scales and for performing * scene to screen transformations. It is used as the base class for all @@ -72,7 +72,7 @@ protected: //member css::uno::Reference< css::drawing::XShapes > m_xLogicTarget; css::uno::Reference< css::drawing::XShapes > m_xFinalTarget; css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; - AbstractShapeFactory* m_pShapeFactory; + ShapeFactory* m_pShapeFactory; OUString m_aCID; const sal_Int32 m_nDimension; diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx index bce3ceefeb9b..b5e54d3cc06d 100644 --- a/chart2/source/view/inc/PlottingPositionHelper.hxx +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -37,7 +37,7 @@ namespace com { namespace sun { namespace star { namespace drawing { struct Poly namespace chart { -class AbstractShapeFactory; +class ShapeFactory; class PlottingPositionHelper { @@ -83,7 +83,7 @@ public: static css::awt::Point transformSceneToScreenPosition( const css::drawing::Position3D& rScenePosition3D , const css::uno::Reference< css::drawing::XShapes >& xSceneTarget - , AbstractShapeFactory* pShapeFactory, sal_Int32 nDimensionCount ); + , ShapeFactory* pShapeFactory, sal_Int32 nDimensionCount ); inline double getLogicMinX() const; inline double getLogicMinY() const; diff --git a/chart2/source/view/inc/PolarLabelPositionHelper.hxx b/chart2/source/view/inc/PolarLabelPositionHelper.hxx index 9119889643c4..2c6ed3a93795 100644 --- a/chart2/source/view/inc/PolarLabelPositionHelper.hxx +++ b/chart2/source/view/inc/PolarLabelPositionHelper.hxx @@ -35,7 +35,7 @@ public: PolarPlottingPositionHelper* pPosHelper , sal_Int32 nDimensionCount , const css::uno::Reference< css::drawing::XShapes >& xLogicTarget - , AbstractShapeFactory* pShapeFactory ); + , ShapeFactory* pShapeFactory ); virtual ~PolarLabelPositionHelper() override; css::awt::Point getLabelScreenPositionAndAlignmentForLogicValues( diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 459908531e71..a21b3499b0f5 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -19,138 +19,184 @@ #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_SHAPEFACTORY_HXX #define INCLUDED_CHART2_SOURCE_VIEW_INC_SHAPEFACTORY_HXX -#include "AbstractShapeFactory.hxx" +#include "PropertyMapper.hxx" +#include <basegfx/range/b2irectangle.hxx> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> + +#include <rtl/ustring.hxx> + +namespace chart { struct VLineProperties; } +namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } +namespace com { namespace sun { namespace star { namespace chart2 { class XFormattedString; } } } } +namespace com { namespace sun { namespace star { namespace drawing { class XDrawPage; } } } } +namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } } +namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } } } } +namespace com { namespace sun { namespace star { namespace drawing { struct HomogenMatrix; } } } } +namespace com { namespace sun { namespace star { namespace drawing { struct PolyPolygonShape3D; } } } } +namespace com { namespace sun { namespace star { namespace drawing { struct Position3D; } } } } +namespace com { namespace sun { namespace star { namespace graphic { class XGraphic; } } } } +namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } } +namespace com { namespace sun { namespace star { namespace drawing { struct Direction3D; } } } } + namespace chart { +class Stripe; + +// Be careful here not to clash with the SYMBOL_FOO #defines in +// <vcl/vclenum.hxx> +enum SymbolEnum { Symbol_Square=0 + , Symbol_Diamond + , Symbol_DownArrow + , Symbol_UpArrow + , Symbol_RightArrow + , Symbol_LeftArrow + , Symbol_Bowtie + , Symbol_Sandglass + , Symbol_Circle + , Symbol_Star + , Symbol_X + , Symbol_Plus + , Symbol_Asterisk + , Symbol_HorizontalBar + , Symbol_VerticalBar + , Symbol_COUNT +}; + -class ShapeFactory : public AbstractShapeFactory +class ShapeFactory { - friend class AbstractShapeFactory; + css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; ShapeFactory(css::uno::Reference< css::lang::XMultiServiceFactory> const & xFactory) {m_xShapeFactory = xFactory;} public: + enum StackPosition { Top, Bottom }; + + static ShapeFactory* getOrCreateShapeFactory(const css::uno::Reference< css::lang::XMultiServiceFactory>& xFactory); + ShapeFactory() = delete; - virtual css::uno::Reference< css::drawing::XShapes > + css::uno::Reference< css::drawing::XShapes > createGroup2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const OUString& aName = OUString() ) override; + , const OUString& aName = OUString() ); - virtual css::uno::Reference< css::drawing::XShapes > + css::uno::Reference< css::drawing::XShapes > createGroup3D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const OUString& aName = OUString() ) override; + , const OUString& aName = OUString() ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createCube( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPosition , const css::drawing::Direction3D& rSize , sal_Int32 nRotateZAngleHundredthDegree , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp , const tPropertyNameMap& rPropertyNameMap - , bool bRounded = false) override; + , bool bRounded = false); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createCylinder( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPosition , const css::drawing::Direction3D& rSize - , sal_Int32 nRotateZAngleHundredthDegree ) override; + , sal_Int32 nRotateZAngleHundredthDegree ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createPyramid( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPosition , const css::drawing::Direction3D& rSize , double fTopHeight , bool bRotateZ , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp - , const tPropertyNameMap& rPropertyNameMap) override; + , const tPropertyNameMap& rPropertyNameMap); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createCone( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPosition , const css::drawing::Direction3D& rSize - , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ) override; + , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createPieSegment2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius , const css::drawing::Direction3D& rOffset - , const css::drawing::HomogenMatrix& rUnitCircleToScene ) override; + , const css::drawing::HomogenMatrix& rUnitCircleToScene ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createPieSegment( const css::uno::Reference< css::drawing::XShapes >& xTarget , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius , const css::drawing::Direction3D& rOffset , const css::drawing::HomogenMatrix& rUnitCircleToScene - , double fDepth ) override; + , double fDepth ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createStripe( const css::uno::Reference< css::drawing::XShapes >& xTarget , const Stripe& rStripe , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp , const tPropertyNameMap& rPropertyNameMap , bool bDoubleSided , short nRotatedTexture = 0 //0 to 7 are the different possibilities - , bool bFlatNormals=true ) override; + , bool bFlatNormals=true ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createArea3D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::PolyPolygonShape3D& rPolyPolygon - , double fDepth) override; + , double fDepth); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createArea2D( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::drawing::PolyPolygonShape3D& rPolyPolygon) override; + , const css::drawing::PolyPolygonShape3D& rPolyPolygon); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createSymbol2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPos , const css::drawing::Direction3D& rSize , sal_Int32 nStandardSymbol , sal_Int32 nBorderColor - , sal_Int32 nFillColor ) override; + , sal_Int32 nFillColor ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createGraphic2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPos , const css::drawing::Direction3D& rSize - , const css::uno::Reference< css::graphic::XGraphic >& xGraphic ) override; + , const css::uno::Reference< css::graphic::XGraphic >& xGraphic ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createLine2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::PointSequenceSequence& rPoints - , const VLineProperties* pLineProperties = nullptr ) override; + , const VLineProperties* pLineProperties = nullptr ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createLine ( const css::uno::Reference< css::drawing::XShapes >& xTarget, - const css::awt::Size& rSize, const css::awt::Point& rPosition ) override; + const css::awt::Size& rSize, const css::awt::Point& rPosition ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createLine3D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::PolyPolygonShape3D& rPoints - , const VLineProperties& rLineProperties ) override; + , const VLineProperties& rLineProperties ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createCircle2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPos - , const css::drawing::Direction3D& rSize ) override; + , const css::drawing::Direction3D& rSize ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createCircle( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::awt::Size& rSize - , const css::awt::Point& rPosition ) override; + , const css::awt::Point& rPosition ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D , const OUString& rText , const tNameSequence& rPropNames , const tAnySequence& rPropValues , const css::uno::Any& rATransformation - ) override; + ); /** This method creates a text shape made up by a set of paragraphs. * For each paragraph the related text style is passed to the method. @@ -179,55 +225,90 @@ public: * a transformation to be applied to the text shape as final step. * */ - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createText( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::uno::Sequence< OUString >& rTextParagraphs , const css::uno::Sequence< tNameSequence >& rParaPropNames , const css::uno::Sequence< tAnySequence >& rParaPropValues , const tNameSequence& rPropNames , const tAnySequence& rPropValues - , const css::uno::Any& rATransformation ) override; + , const css::uno::Any& rATransformation ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createText(const css::uno::Reference< css::drawing::XShapes >& xTarget , css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString , const tNameSequence& rPropNames , const tAnySequence& rPropValues - , const css::uno::Any& rATransformation) override; + , const css::uno::Any& rATransformation); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createText( const css::uno::Reference< css::drawing::XShapes >& xTarget2D, const css::awt::Size& rSize, const css::awt::Point& rPosition, css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString, const css::uno::Reference< css::beans::XPropertySet > & xTextProperties, - double nRotation, const OUString& aName ) override; + double nRotation, const OUString& aName ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createInvisibleRectangle( const css::uno::Reference< css::drawing::XShapes >& xTarget - , const css::awt::Size& rSize ) override; + , const css::awt::Size& rSize ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createRectangle( const css::uno::Reference< css::drawing::XShapes >& xTarget, const css::awt::Size& rSize, const css::awt::Point& rPosition, const tNameSequence& rPropNames, const tAnySequence& rPropValues, - StackPosition ePos = Top ) override; + StackPosition ePos = Top ); - virtual css::uno::Reference< css::drawing::XShape > + css::uno::Reference< css::drawing::XShape > createRectangle( - const css::uno::Reference< css::drawing::XShapes >& xTarget ) override; + const css::uno::Reference< css::drawing::XShapes >& xTarget ); - virtual css::uno::Reference< css::drawing::XShapes > + css::uno::Reference< css::drawing::XShapes > getOrCreateChartRootShape( const css::uno::Reference< - css::drawing::XDrawPage>& xPage ) override; + css::drawing::XDrawPage>& xPage ); + + void setPageSize( css::uno::Reference < css::drawing::XShapes > xChartShapes, const css::awt::Size& rSize ); + + static css::uno::Reference< css::drawing::XShapes > + getChartRootShape( const css::uno::Reference< css::drawing::XDrawPage>& xPage ); + + static void makeShapeInvisible( const css::uno::Reference< css::drawing::XShape >& xShape ); + + static void setShapeName( const css::uno::Reference< css::drawing::XShape >& xShape + , const OUString& rName ); + + static OUString getShapeName( const css::uno::Reference< css::drawing::XShape >& xShape ); + + static css::uno::Any makeTransformation( const css::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 ); + + static OUString getStackedString( const OUString& rString, bool bStacked ); + + static bool hasPolygonAnyLines( css::drawing::PolyPolygonShape3D& rPoly ); + static bool isPolygonEmptyOrSinglePoint( css::drawing::PolyPolygonShape3D& rPoly ); + static void closePolygon( css::drawing::PolyPolygonShape3D& rPoly ); + + static css::awt::Size calculateNewSizeRespectingAspectRatio( + const css::awt::Size& rTargetSize + , const css::awt::Size& rSourceSizeWithCorrectAspectRatio ); + + static css::awt::Point calculateTopLeftPositionToCenterObject( + const css::awt::Point& rTargetAreaPosition + , const css::awt::Size& rTargetAreaSize + , const css::awt::Size& rObjectSize ); + + static ::basegfx::B2IRectangle getRectangleOfShape( + const css::uno::Reference< css::drawing::XShape >& xShape ); + + static css::awt::Size getSizeAfterRotation( + const css::uno::Reference< css::drawing::XShape >& xShape, double fRotationAngleDegree ); - virtual void setPageSize( css::uno::Reference < css::drawing::XShapes > xChartShapes, const css::awt::Size& rSize ) override; + static void removeSubShapes( const css::uno::Reference< css::drawing::XShapes >& xShapes ); - virtual void clearPage(css::uno::Reference< css::drawing::XShapes > ) override {} + static sal_Int32 getSymbolCount() { return Symbol_COUNT; } private: css::uno::Reference< css::drawing::XShape > diff --git a/chart2/source/view/inc/VDiagram.hxx b/chart2/source/view/inc/VDiagram.hxx index 4c960776a59e..da6504d19328 100644 --- a/chart2/source/view/inc/VDiagram.hxx +++ b/chart2/source/view/inc/VDiagram.hxx @@ -34,7 +34,7 @@ namespace com { namespace sun { namespace star { namespace drawing { class XShap namespace chart { -class AbstractShapeFactory; +class ShapeFactory; /** The VDiagram is responsible to generate the visible parts of the Diagram that is wall, floor, axes and data series. @@ -88,7 +88,7 @@ private: //members css::uno::Reference< css::drawing::XShapes > m_xTarget; css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; - AbstractShapeFactory* m_pShapeFactory; + ShapeFactory* m_pShapeFactory; // this is the surrounding shape which contains floor, wall and coordinate css::uno::Reference< css::drawing::XShape > m_xOuterGroupShape; diff --git a/chart2/source/view/main/AbstractShapeFactory.cxx b/chart2/source/view/main/AbstractShapeFactory.cxx deleted file mode 100644 index c6c718a2e4dc..000000000000 --- a/chart2/source/view/main/AbstractShapeFactory.cxx +++ /dev/null @@ -1,303 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <PropertyMapper.hxx> -#include <CommonConverters.hxx> - -#include <AbstractShapeFactory.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/drawing/CircleKind.hpp> -#include <com/sun/star/drawing/DoubleSequence.hpp> -#include <com/sun/star/drawing/FlagSequence.hpp> -#include <com/sun/star/drawing/FillStyle.hpp> -#include <com/sun/star/drawing/LineStyle.hpp> -#include <com/sun/star/drawing/NormalsKind.hpp> -#include <com/sun/star/drawing/PointSequence.hpp> -#include <com/sun/star/drawing/PolygonKind.hpp> -#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> -#include <com/sun/star/drawing/ProjectionMode.hpp> -#include <com/sun/star/drawing/ShadeMode.hpp> -#include <com/sun/star/drawing/TextFitToSizeType.hpp> -#include <com/sun/star/drawing/TextureProjectionMode.hpp> -#include <com/sun/star/drawing/XShapes.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/uno/Any.hxx> - -#include <editeng/unoprnms.hxx> -#include <rtl/math.hxx> -#include <tools/helpers.hxx> -#include <tools/svlibrary.h> -#include <svx/svdocirc.hxx> -#include <svx/svdopath.hxx> -#include <vcl/svapp.hxx> -#include <sal/log.hxx> - -#include <BaseGFXHelper.hxx> -#include <basegfx/point/b2dpoint.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/matrix/b3dhommatrix.hxx> - -#include <osl/module.hxx> - -#include <ShapeFactory.hxx> - -#include <config_features.h> - -using namespace com::sun::star; - -namespace chart { - -AbstractShapeFactory* AbstractShapeFactory::getOrCreateShapeFactory(const uno::Reference< lang::XMultiServiceFactory>& xFactory) -{ - static AbstractShapeFactory* pShapeFactory = nullptr; - - if (pShapeFactory) - return pShapeFactory; - - if (!pShapeFactory) - pShapeFactory = new ShapeFactory(xFactory); - - return pShapeFactory; -} - -uno::Reference< drawing::XShapes > AbstractShapeFactory::getChartRootShape( - const uno::Reference< drawing::XDrawPage>& xDrawPage ) -{ - uno::Reference< drawing::XShapes > xRet; - uno::Reference< drawing::XShapes > xShapes( xDrawPage, uno::UNO_QUERY ); - if( xShapes.is() ) - { - sal_Int32 nCount = xShapes->getCount(); - uno::Reference< drawing::XShape > xShape; - for( sal_Int32 nN = nCount; nN--; ) - { - if( xShapes->getByIndex( nN ) >>= xShape ) - { - if( AbstractShapeFactory::getShapeName( xShape ) == "com.sun.star.chart2.shapes" ) - { - xRet.set( xShape, uno::UNO_QUERY ); - break; - } - } - } - } - return xRet; -} - -void AbstractShapeFactory::makeShapeInvisible( const uno::Reference< drawing::XShape >& xShape ) -{ - uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); - OSL_ENSURE(xShapeProp.is(), "created shape offers no XPropertySet"); - if( xShapeProp.is()) - { - try - { - xShapeProp->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE )); - xShapeProp->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE )); - } - catch( const uno::Exception& e ) - { - SAL_WARN("chart2", "Exception caught. " << e ); - } - } -} - -// set a name/CID at a shape (is used for selection handling) - -void AbstractShapeFactory::setShapeName( const uno::Reference< drawing::XShape >& xShape - , const OUString& rName ) -{ - if(!xShape.is()) - return; - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - OSL_ENSURE(xProp.is(), "shape offers no XPropertySet"); - if( xProp.is()) - { - try - { - xProp->setPropertyValue( UNO_NAME_MISC_OBJ_NAME - , uno::Any( rName ) ); - } - catch( const uno::Exception& e ) - { - SAL_WARN("chart2", "Exception caught. " << e ); - } - } -} - -OUString AbstractShapeFactory::getShapeName( const uno::Reference< drawing::XShape >& xShape ) -{ - OUString aRet; - - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - OSL_ENSURE(xProp.is(), "shape offers no XPropertySet"); - if( xProp.is()) - { - try - { - xProp->getPropertyValue( UNO_NAME_MISC_OBJ_NAME ) >>= aRet; - } - catch( const uno::Exception& e ) - { - SAL_WARN("chart2", "Exception caught. " << e ); - } - } - - return aRet; -} - -uno::Any AbstractShapeFactory::makeTransformation( const awt::Point& rScreenPosition2D, double fRotationAnglePi ) -{ - ::basegfx::B2DHomMatrix aM; - //As autogrow is active the rectangle is automatically expanded to that side - //to which the text is not adjusted. - // aM.scale( 1, 1 ); Oops? A scale with this parameters is neutral, line commented out - aM.rotate( fRotationAnglePi ); - aM.translate( rScreenPosition2D.X, rScreenPosition2D.Y ); - uno::Any aATransformation( B2DHomMatrixToHomogenMatrix3(aM) ); - return aATransformation; -} - -OUString AbstractShapeFactory::getStackedString( const OUString& rString, bool bStacked ) -{ - sal_Int32 nLen = rString.getLength(); - if(!bStacked || !nLen) - return rString; - - OUStringBuffer aStackStr; - - //add a newline after each letter - //as we do not no letters here add a newline after each char - for( sal_Int32 nPosSrc=0; nPosSrc < nLen; nPosSrc++ ) - { - if( nPosSrc ) - aStackStr.append( '\r' ); - aStackStr.append(rString[nPosSrc]); - } - return aStackStr.makeStringAndClear(); -} - -bool AbstractShapeFactory::hasPolygonAnyLines( drawing::PolyPolygonShape3D& rPoly) -{ - // #i67757# check all contained polygons, if at least one polygon contains 2 or more points, return true - for( sal_Int32 nIdx = 0, nCount = rPoly.SequenceX.getLength(); nIdx < nCount; ++nIdx ) - if( rPoly.SequenceX[ nIdx ].getLength() > 1 ) - return true; - return false; -} - -bool AbstractShapeFactory::isPolygonEmptyOrSinglePoint( drawing::PolyPolygonShape3D& rPoly) -{ - // true, if empty polypolygon or one polygon with one point - return (rPoly.SequenceX.getLength() == 0) || - ((rPoly.SequenceX.getLength() == 1) && (rPoly.SequenceX[0].getLength() <= 1)); -} - -void AbstractShapeFactory::closePolygon( drawing::PolyPolygonShape3D& rPoly) -{ - OSL_ENSURE( rPoly.SequenceX.getLength() <= 1, "AbstractShapeFactory::closePolygon - single polygon expected" ); - //add a last point == first point - if(isPolygonEmptyOrSinglePoint(rPoly)) - return; - drawing::Position3D aFirst(rPoly.SequenceX[0][0],rPoly.SequenceY[0][0],rPoly.SequenceZ[0][0]); - AddPointToPoly( rPoly, aFirst ); -} - -awt::Size AbstractShapeFactory::calculateNewSizeRespectingAspectRatio( - const awt::Size& rTargetSize - , const awt::Size& rSourceSizeWithCorrectAspectRatio ) -{ - awt::Size aNewSize; - - double fFactorWidth = double(rTargetSize.Width)/double(rSourceSizeWithCorrectAspectRatio.Width); - double fFactorHeight = double(rTargetSize.Height)/double(rSourceSizeWithCorrectAspectRatio.Height); - double fFactor = std::min(fFactorWidth,fFactorHeight); - aNewSize.Width=static_cast<sal_Int32>(fFactor*rSourceSizeWithCorrectAspectRatio.Width); - aNewSize.Height=static_cast<sal_Int32>(fFactor*rSourceSizeWithCorrectAspectRatio.Height); - - return aNewSize; -} - -awt::Point AbstractShapeFactory::calculateTopLeftPositionToCenterObject( - const awt::Point& rTargetAreaPosition - , const awt::Size& rTargetAreaSize - , const awt::Size& rObjectSize ) -{ - awt::Point aNewPosition(rTargetAreaPosition); - aNewPosition.X += static_cast<sal_Int32>(double(rTargetAreaSize.Width-rObjectSize.Width)/2.0); - aNewPosition.Y += static_cast<sal_Int32>(double(rTargetAreaSize.Height-rObjectSize.Height)/2.0); - return aNewPosition; -} - -::basegfx::B2IRectangle AbstractShapeFactory::getRectangleOfShape( - const uno::Reference< drawing::XShape >& xShape ) -{ - ::basegfx::B2IRectangle aRet; - - if( xShape.is() ) - { - awt::Point aPos = xShape->getPosition(); - awt::Size aSize = xShape->getSize(); - aRet = BaseGFXHelper::makeRectangle(aPos,aSize); - } - return aRet; - -} - -awt::Size AbstractShapeFactory::getSizeAfterRotation( - const uno::Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) -{ - awt::Size aRet(0,0); - if(xShape.is()) - { - const awt::Size aSize( xShape->getSize() ); - - if( fRotationAngleDegree == 0.0 ) - aRet = aSize; - else - { - fRotationAngleDegree = NormAngle360(fRotationAngleDegree); - if(fRotationAngleDegree>270.0) - fRotationAngleDegree=360.0-fRotationAngleDegree; - else if(fRotationAngleDegree>180.0) - fRotationAngleDegree=fRotationAngleDegree-180.0; - else if(fRotationAngleDegree>90.0) - fRotationAngleDegree=180.0-fRotationAngleDegree; - - const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree); - - aRet.Height = static_cast<sal_Int32>( - aSize.Width*rtl::math::sin( fAnglePi ) - + aSize.Height*rtl::math::cos( fAnglePi )); - aRet.Width = static_cast<sal_Int32>( - aSize.Width*rtl::math::cos( fAnglePi ) - + aSize.Height*rtl::math::sin( fAnglePi )); - } - } - return aRet; -} - -void AbstractShapeFactory::removeSubShapes( const uno::Reference< drawing::XShapes >& xShapes ) -{ - if( xShapes.is() ) - { - sal_Int32 nSubCount = xShapes->getCount(); - uno::Reference< drawing::XShape > xShape; - for( sal_Int32 nS = nSubCount; nS--; ) - { - if( xShapes->getByIndex( nS ) >>= xShape ) - xShapes->remove( xShape ); - } - } -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 0d8852dd791a..27eea131cae8 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -26,7 +26,7 @@ #include <VDiagram.hxx> #include "VTitle.hxx" #include "VButton.hxx" -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <VCoordinateSystem.hxx> #include <VSeriesPlotter.hxx> #include <CommonConverters.hxx> @@ -1521,7 +1521,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D } uno::Reference< drawing::XShapes > xTextTargetShapes = - AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory)->createGroup2D(rParam.mxDiagramWithAxesShapes); + ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory)->createGroup2D(rParam.mxDiagramWithAxesShapes); // - create axis and grids for all coordinate systems @@ -1549,7 +1549,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D VCoordinateSystem* pVCooSys = rVCooSysList[0]; pVCooSys->createMaximumAxesLabels(); - aConsumedOuterRect = AbstractShapeFactory::getRectangleOfShape(xBoundingShape); + aConsumedOuterRect = ShapeFactory::getRectangleOfShape(xBoundingShape); ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() ); if (!rParam.mbUseFixedInnerSize) aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect ); @@ -1566,7 +1566,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D bool bLessSpaceConsumedThanExpected = false; { - aConsumedOuterRect = AbstractShapeFactory::getRectangleOfShape(xBoundingShape); + aConsumedOuterRect = ShapeFactory::getRectangleOfShape(xBoundingShape); if( aConsumedOuterRect.getMinX() > aAvailableOuterRect.getMinX() || aConsumedOuterRect.getMaxX() < aAvailableOuterRect.getMaxX() || aConsumedOuterRect.getMinY() > aAvailableOuterRect.getMinY() @@ -1629,7 +1629,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D { m_bPointsWereSkipped = false; - aConsumedOuterRect = ::basegfx::B2IRectangle( AbstractShapeFactory::getRectangleOfShape(xBoundingShape) ); + aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) ); ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() ); if (!rParam.mbUseFixedInnerSize) aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect ); @@ -1640,9 +1640,9 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D } //clear and recreate - AbstractShapeFactory::removeSubShapes( xSeriesTargetInFrontOfAxis ); //xSeriesTargetBehindAxis is a sub shape of xSeriesTargetInFrontOfAxis and will be removed here + ShapeFactory::removeSubShapes( xSeriesTargetInFrontOfAxis ); //xSeriesTargetBehindAxis is a sub shape of xSeriesTargetInFrontOfAxis and will be removed here xSeriesTargetBehindAxis.clear(); - AbstractShapeFactory::removeSubShapes( xTextTargetShapes ); + ShapeFactory::removeSubShapes( xTextTargetShapes ); //set new transformation for( nC=0; nC < rVCooSysList.size(); nC++) @@ -2409,7 +2409,7 @@ void formatPage( tAnySequence aValues; PropertyMapper::getMultiPropertyListsFromValueMap( aNames, aValues, aNameValueMap ); - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); pShapeFactory->createRectangle( xTarget, rPageSize, awt::Point(0, 0), aNames, aValues); } @@ -2502,7 +2502,7 @@ void ChartView::createShapes() awt::Size aPageSize = mrChartModel.getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); if(!mxRootShape.is()) mxRootShape = pShapeFactory->getOrCreateChartRootShape( m_xDrawPage ); @@ -2514,7 +2514,6 @@ void ChartView::createShapes() OSL_FAIL("could not set page size correctly"); } pShapeFactory->setPageSize(mxRootShape, aPageSize); - pShapeFactory->clearPage(mxRootShape); createShapes2D(aPageSize); @@ -2968,7 +2967,7 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased, Timer *, void) void ChartView::createShapes2D( const awt::Size& rPageSize ) { - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); SolarMutexGuard aSolarGuard; @@ -2990,11 +2989,11 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) aParam.mxMarkHandles = pShapeFactory->createInvisibleRectangle( xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0)); - AbstractShapeFactory::setShapeName(aParam.mxMarkHandles, "MarkHandles"); + ShapeFactory::setShapeName(aParam.mxMarkHandles, "MarkHandles"); aParam.mxPlotAreaWithAxes = pShapeFactory->createInvisibleRectangle( xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0, 0)); - AbstractShapeFactory::setShapeName(aParam.mxPlotAreaWithAxes, "PlotAreaIncludingAxes"); + ShapeFactory::setShapeName(aParam.mxPlotAreaWithAxes, "PlotAreaIncludingAxes"); aParam.mxDiagramWithAxesShapes = pShapeFactory->createGroup2D(xDiagramPlusAxesPlusMarkHandlesGroup_Shapes); diff --git a/chart2/source/view/main/DataPointSymbolSupplier.cxx b/chart2/source/view/main/DataPointSymbolSupplier.cxx index fa0f4abffa8e..7f446139ac22 100644 --- a/chart2/source/view/main/DataPointSymbolSupplier.cxx +++ b/chart2/source/view/main/DataPointSymbolSupplier.cxx @@ -18,7 +18,7 @@ */ #include <chartview/DataPointSymbolSupplier.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <com/sun/star/drawing/Position3D.hpp> namespace chart @@ -30,12 +30,12 @@ uno::Reference< drawing::XShapes > DataPointSymbolSupplier::create2DSymbolList( , const uno::Reference< drawing::XShapes >& xTarget , const drawing::Direction3D& rSize ) { - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); uno::Reference< drawing::XShapes > xGroupShapes = pShapeFactory->createGroup2D( xTarget ); drawing::Position3D aPos(0,0,0); - for(sal_Int32 nS=0;nS<AbstractShapeFactory::getSymbolCount();nS++) + for(sal_Int32 nS=0;nS<ShapeFactory::getSymbolCount();nS++) { pShapeFactory->createSymbol2D( xGroupShapes, aPos, rSize, nS, 0, 0 ); } diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index e3a4dc52e9e2..94b6a96323d3 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -18,7 +18,7 @@ */ #include <chartview/DrawModelWrapper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include "ChartItemPool.hxx" #include <ObjectIdentifier.hxx> #include <svx/unomodel.hxx> @@ -188,7 +188,7 @@ uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getMainDrawPage() //ensure that additional shapes are in front of the chart objects so create the chart root before // let us disable this call for now // TODO:moggi - // AbstractShapeFactory::getOrCreateShapeFactory(getShapeFactory())->getOrCreateChartRootShape( m_xMainDrawPage ); + // ShapeFactory::getOrCreateShapeFactory(getShapeFactory())->getOrCreateChartRootShape( m_xMainDrawPage ); return m_xMainDrawPage; } uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getHiddenDrawPage() @@ -218,7 +218,7 @@ uno::Reference< drawing::XDrawPage > const & DrawModelWrapper::getHiddenDrawPage void DrawModelWrapper::clearMainDrawPage() { //uno::Reference<drawing::XShapes> xChartRoot( m_xMainDrawPage, uno::UNO_QUERY ); - uno::Reference<drawing::XShapes> xChartRoot( AbstractShapeFactory::getChartRootShape( m_xMainDrawPage ) ); + uno::Reference<drawing::XShapes> xChartRoot( ShapeFactory::getChartRootShape( m_xMainDrawPage ) ); if( xChartRoot.is() ) { sal_Int32 nSubCount = xChartRoot->getCount(); @@ -234,7 +234,7 @@ void DrawModelWrapper::clearMainDrawPage() uno::Reference< drawing::XShapes > DrawModelWrapper::getChartRootShape( const uno::Reference< drawing::XDrawPage>& xDrawPage ) { - return AbstractShapeFactory::getChartRootShape( xDrawPage ); + return ShapeFactory::getChartRootShape( xDrawPage ); } void DrawModelWrapper::lockControllers() diff --git a/chart2/source/view/main/LabelPositionHelper.cxx b/chart2/source/view/main/LabelPositionHelper.cxx index d97de691fc18..432af9b81c6e 100644 --- a/chart2/source/view/main/LabelPositionHelper.cxx +++ b/chart2/source/view/main/LabelPositionHelper.cxx @@ -21,7 +21,7 @@ #include <PlottingPositionHelper.hxx> #include <CommonConverters.hxx> #include <PropertyMapper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <RelativeSizeHelper.hxx> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> @@ -35,7 +35,7 @@ using namespace ::com::sun::star::chart2; LabelPositionHelper::LabelPositionHelper( sal_Int32 nDimensionCount , const uno::Reference< drawing::XShapes >& xLogicTarget - , AbstractShapeFactory* pShapeFactory ) + , ShapeFactory* pShapeFactory ) : m_nDimensionCount(nDimensionCount) , m_xLogicTarget(xLogicTarget) , m_pShapeFactory(pShapeFactory) diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx index 9c710ba9846b..0778c2954a42 100644 --- a/chart2/source/view/main/PlotterBase.cxx +++ b/chart2/source/view/main/PlotterBase.cxx @@ -19,7 +19,7 @@ #include <PlotterBase.hxx> #include <PlottingPositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <rtl/math.hxx> #include <osl/diagnose.h> #include <com/sun/star/chart2/DataPointLabel.hpp> @@ -50,7 +50,7 @@ void PlotterBase::initPlotter( const uno::Reference< drawing::XShapes >& xLogic m_xLogicTarget = xLogicTarget; m_xFinalTarget = xFinalTarget; m_xShapeFactory = xShapeFactory; - m_pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); + m_pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); m_aCID = rCID; } diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index 32aa4394127f..0af1fe3d35fc 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -22,7 +22,7 @@ #include <ViewDefines.hxx> #include <Linear3DTransformation.hxx> #include <VPolarTransformation.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <PropertyMapper.hxx> #include <DateHelper.hxx> #include <defines.hxx> @@ -201,7 +201,7 @@ drawing::Position3D PlottingPositionHelper::transformScaledLogicToScene( awt::Point PlottingPositionHelper::transformSceneToScreenPosition( const drawing::Position3D& rScenePosition3D , const uno::Reference< drawing::XShapes >& xSceneTarget - , AbstractShapeFactory* pShapeFactory + , ShapeFactory* pShapeFactory , sal_Int32 nDimensionCount ) { //@todo would like to have a cheaper method to do this transformation diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx index ac2f1c50d317..aca4a2b6f0c1 100644 --- a/chart2/source/view/main/PolarLabelPositionHelper.cxx +++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx @@ -36,7 +36,7 @@ PolarLabelPositionHelper::PolarLabelPositionHelper( PolarPlottingPositionHelper* pPosHelper , sal_Int32 nDimensionCount , const uno::Reference< drawing::XShapes >& xLogicTarget - , AbstractShapeFactory* pShapeFactory ) + , ShapeFactory* pShapeFactory ) : LabelPositionHelper( nDimensionCount, xLogicTarget, pShapeFactory ) , m_pPosHelper(pPosHelper) { diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index a5f58bcc3c25..351bf209c376 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -18,6 +18,7 @@ */ #include <ShapeFactory.hxx> +#include <BaseGFXHelper.hxx> #include <ViewDefines.hxx> #include <Stripe.hxx> #include <CommonConverters.hxx> @@ -2515,6 +2516,250 @@ uno::Reference< drawing::XShape > return xShape; } +ShapeFactory* ShapeFactory::getOrCreateShapeFactory(const uno::Reference< lang::XMultiServiceFactory>& xFactory) +{ + static ShapeFactory* pShapeFactory = nullptr; + + if (pShapeFactory) + return pShapeFactory; + + if (!pShapeFactory) + pShapeFactory = new ShapeFactory(xFactory); + + return pShapeFactory; +} + +uno::Reference< drawing::XShapes > ShapeFactory::getChartRootShape( + const uno::Reference< drawing::XDrawPage>& xDrawPage ) +{ + uno::Reference< drawing::XShapes > xRet; + uno::Reference< drawing::XShapes > xShapes( xDrawPage, uno::UNO_QUERY ); + if( xShapes.is() ) + { + sal_Int32 nCount = xShapes->getCount(); + uno::Reference< drawing::XShape > xShape; + for( sal_Int32 nN = nCount; nN--; ) + { + if( xShapes->getByIndex( nN ) >>= xShape ) + { + if( ShapeFactory::getShapeName( xShape ) == "com.sun.star.chart2.shapes" ) + { + xRet.set( xShape, uno::UNO_QUERY ); + break; + } + } + } + } + return xRet; +} + +void ShapeFactory::makeShapeInvisible( const uno::Reference< drawing::XShape >& xShape ) +{ + uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); + OSL_ENSURE(xShapeProp.is(), "created shape offers no XPropertySet"); + if( xShapeProp.is()) + { + try + { + xShapeProp->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE )); + xShapeProp->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE )); + } + catch( const uno::Exception& e ) + { + SAL_WARN("chart2", "Exception caught. " << e ); + } + } +} + +// set a name/CID at a shape (is used for selection handling) + +void ShapeFactory::setShapeName( const uno::Reference< drawing::XShape >& xShape + , const OUString& rName ) +{ + if(!xShape.is()) + return; + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + OSL_ENSURE(xProp.is(), "shape offers no XPropertySet"); + if( xProp.is()) + { + try + { + xProp->setPropertyValue( UNO_NAME_MISC_OBJ_NAME + , uno::Any( rName ) ); + } + catch( const uno::Exception& e ) + { + SAL_WARN("chart2", "Exception caught. " << e ); + } + } +} + +OUString ShapeFactory::getShapeName( const uno::Reference< drawing::XShape >& xShape ) +{ + OUString aRet; + + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + OSL_ENSURE(xProp.is(), "shape offers no XPropertySet"); + if( xProp.is()) + { + try + { + xProp->getPropertyValue( UNO_NAME_MISC_OBJ_NAME ) >>= aRet; + } + catch( const uno::Exception& e ) + { + SAL_WARN("chart2", "Exception caught. " << e ); + } + } + + return aRet; +} + +uno::Any ShapeFactory::makeTransformation( const awt::Point& rScreenPosition2D, double fRotationAnglePi ) +{ + ::basegfx::B2DHomMatrix aM; + //As autogrow is active the rectangle is automatically expanded to that side + //to which the text is not adjusted. + // aM.scale( 1, 1 ); Oops? A scale with this parameters is neutral, line commented out + aM.rotate( fRotationAnglePi ); + aM.translate( rScreenPosition2D.X, rScreenPosition2D.Y ); + uno::Any aATransformation( B2DHomMatrixToHomogenMatrix3(aM) ); + return aATransformation; +} + +OUString ShapeFactory::getStackedString( const OUString& rString, bool bStacked ) +{ + sal_Int32 nLen = rString.getLength(); + if(!bStacked || !nLen) + return rString; + + OUStringBuffer aStackStr; + + //add a newline after each letter + //as we do not no letters here add a newline after each char + for( sal_Int32 nPosSrc=0; nPosSrc < nLen; nPosSrc++ ) + { + if( nPosSrc ) + aStackStr.append( '\r' ); + aStackStr.append(rString[nPosSrc]); + } + return aStackStr.makeStringAndClear(); +} + +bool ShapeFactory::hasPolygonAnyLines( drawing::PolyPolygonShape3D& rPoly) +{ + // #i67757# check all contained polygons, if at least one polygon contains 2 or more points, return true + for( sal_Int32 nIdx = 0, nCount = rPoly.SequenceX.getLength(); nIdx < nCount; ++nIdx ) + if( rPoly.SequenceX[ nIdx ].getLength() > 1 ) + return true; + return false; +} + +bool ShapeFactory::isPolygonEmptyOrSinglePoint( drawing::PolyPolygonShape3D& rPoly) +{ + // true, if empty polypolygon or one polygon with one point + return (rPoly.SequenceX.getLength() == 0) || + ((rPoly.SequenceX.getLength() == 1) && (rPoly.SequenceX[0].getLength() <= 1)); +} + +void ShapeFactory::closePolygon( drawing::PolyPolygonShape3D& rPoly) +{ + OSL_ENSURE( rPoly.SequenceX.getLength() <= 1, "ShapeFactory::closePolygon - single polygon expected" ); + //add a last point == first point + if(isPolygonEmptyOrSinglePoint(rPoly)) + return; + drawing::Position3D aFirst(rPoly.SequenceX[0][0],rPoly.SequenceY[0][0],rPoly.SequenceZ[0][0]); + AddPointToPoly( rPoly, aFirst ); +} + +awt::Size ShapeFactory::calculateNewSizeRespectingAspectRatio( + const awt::Size& rTargetSize + , const awt::Size& rSourceSizeWithCorrectAspectRatio ) +{ + awt::Size aNewSize; + + double fFactorWidth = double(rTargetSize.Width)/double(rSourceSizeWithCorrectAspectRatio.Width); + double fFactorHeight = double(rTargetSize.Height)/double(rSourceSizeWithCorrectAspectRatio.Height); + double fFactor = std::min(fFactorWidth,fFactorHeight); + aNewSize.Width=static_cast<sal_Int32>(fFactor*rSourceSizeWithCorrectAspectRatio.Width); + aNewSize.Height=static_cast<sal_Int32>(fFactor*rSourceSizeWithCorrectAspectRatio.Height); + + return aNewSize; +} + +awt::Point ShapeFactory::calculateTopLeftPositionToCenterObject( + const awt::Point& rTargetAreaPosition + , const awt::Size& rTargetAreaSize + , const awt::Size& rObjectSize ) +{ + awt::Point aNewPosition(rTargetAreaPosition); + aNewPosition.X += static_cast<sal_Int32>(double(rTargetAreaSize.Width-rObjectSize.Width)/2.0); + aNewPosition.Y += static_cast<sal_Int32>(double(rTargetAreaSize.Height-rObjectSize.Height)/2.0); + return aNewPosition; +} + +::basegfx::B2IRectangle ShapeFactory::getRectangleOfShape( + const uno::Reference< drawing::XShape >& xShape ) +{ + ::basegfx::B2IRectangle aRet; + + if( xShape.is() ) + { + awt::Point aPos = xShape->getPosition(); + awt::Size aSize = xShape->getSize(); + aRet = BaseGFXHelper::makeRectangle(aPos,aSize); + } + return aRet; + +} + +awt::Size ShapeFactory::getSizeAfterRotation( + const uno::Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) +{ + awt::Size aRet(0,0); + if(xShape.is()) + { + const awt::Size aSize( xShape->getSize() ); + + if( fRotationAngleDegree == 0.0 ) + aRet = aSize; + else + { + fRotationAngleDegree = NormAngle360(fRotationAngleDegree); + if(fRotationAngleDegree>270.0) + fRotationAngleDegree=360.0-fRotationAngleDegree; + else if(fRotationAngleDegree>180.0) + fRotationAngleDegree=fRotationAngleDegree-180.0; + else if(fRotationAngleDegree>90.0) + fRotationAngleDegree=180.0-fRotationAngleDegree; + + const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree); + + aRet.Height = static_cast<sal_Int32>( + aSize.Width*rtl::math::sin( fAnglePi ) + + aSize.Height*rtl::math::cos( fAnglePi )); + aRet.Width = static_cast<sal_Int32>( + aSize.Width*rtl::math::cos( fAnglePi ) + + aSize.Height*rtl::math::sin( fAnglePi )); + } + } + return aRet; +} + +void ShapeFactory::removeSubShapes( const uno::Reference< drawing::XShapes >& xShapes ) +{ + if( xShapes.is() ) + { + sal_Int32 nSubCount = xShapes->getCount(); + uno::Reference< drawing::XShape > xShape; + for( sal_Int32 nS = nSubCount; nS--; ) + { + if( xShapes->getByIndex( nS ) >>= xShape ) + xShapes->remove( xShape ); + } + } +} + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/VButton.cxx b/chart2/source/view/main/VButton.cxx index 0be4b1a3c2b0..c9c6255974b0 100644 --- a/chart2/source/view/main/VButton.cxx +++ b/chart2/source/view/main/VButton.cxx @@ -9,7 +9,7 @@ #include "VButton.hxx" -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> @@ -92,7 +92,7 @@ uno::Reference<drawing::XShape> VButton::createTriangle(awt::Size aSize) void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp) { - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); std::unique_ptr<tNameSequence> pPropNames(new tNameSequence); std::unique_ptr<tAnySequence> pPropValues(new tAnySequence); diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 34511f3885e7..52d2bf2d7a14 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -23,7 +23,7 @@ #include <CommonConverters.hxx> #include <ObjectIdentifier.hxx> #include <RelativePositionHelper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <RelativeSizeHelper.hxx> #include <LegendEntryProvider.hxx> #include <chartview/DrawModelWrapper.hxx> @@ -154,7 +154,7 @@ awt::Size lcl_createTextShapes( const tPropertyValues & rTextProperties ) { awt::Size aResult; - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); for (ViewLegendEntry const & rEntry : rEntries) { @@ -880,7 +880,7 @@ void VLegend::createShapes( try { //create shape and add to page - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); OUString aLegendParticle( ObjectIdentifier::createParticleForLegend( mrModel ) ); m_xShape.set( pShapeFactory->createGroup2D( m_xTarget, ObjectIdentifier::createClassifiedIdentifierForParticle( aLegendParticle )), @@ -999,10 +999,10 @@ void VLegend::createShapes( aLegendSize, awt::Point(0,0), aLineFillProperties.first, - aLineFillProperties.second, AbstractShapeFactory::Bottom ); + aLineFillProperties.second, ShapeFactory::Bottom ); //because of this name this border will be used for marking the legend - AbstractShapeFactory::setShapeName( xBorder, "MarkHandles" ); + ShapeFactory::setShapeName( xBorder, "MarkHandles" ); } } catch( const uno::Exception & ) diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx index 0112682bb7c4..2db777910dae 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -19,7 +19,7 @@ #include <VLegendSymbolFactory.hxx> #include <PropertyMapper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <ObjectIdentifier.hxx> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/Position3D.hpp> @@ -105,7 +105,7 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( if( ! (rSymbolContainer.is() && xShapeFactory.is())) return xResult; - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); xResult.set( pShapeFactory->createGroup2D( rSymbolContainer ), uno::UNO_QUERY ); Reference< drawing::XShapes > xResultGroup( xResult, uno::UNO_QUERY ); @@ -136,7 +136,7 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( { drawing::Direction3D aSymbolSize( nSize, nSize, 0 ); drawing::Position3D aPos( rEntryKeyAspectRatio.Width/2.0, rEntryKeyAspectRatio.Height/2.0, 0 ); - AbstractShapeFactory* pFactory = AbstractShapeFactory::getOrCreateShapeFactory( xShapeFactory ); + ShapeFactory* pFactory = ShapeFactory::getOrCreateShapeFactory( xShapeFactory ); if( aSymbol.Style == chart2::SymbolStyle_STANDARD ) { // take series color as fill color diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index 43f7a42b3337..a746c2a61427 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -20,7 +20,7 @@ #include "VTitle.hxx" #include <CommonConverters.hxx> #include <PropertyMapper.hxx> -#include <AbstractShapeFactory.hxx> +#include <ShapeFactory.hxx> #include <com/sun/star/chart2/XFormattedString.hpp> #include <rtl/math.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -75,7 +75,7 @@ awt::Size VTitle::getUnrotatedSize() const //size before rotation awt::Size VTitle::getFinalSize() const //size after rotation { - return AbstractShapeFactory::getSizeAfterRotation( + return ShapeFactory::getSizeAfterRotation( m_xShape, m_fRotationAngleDegree ); } @@ -131,7 +131,7 @@ void VTitle::createShapes( SAL_WARN("chart2", "Exception caught. " << e ); } - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); m_xShape =pShapeFactory->createText( m_xTarget, rReferenceSize, rPos, aStringList, xTitleProperties, m_fRotationAngleDegree, m_aCID ); } |